Skip to content

Commit

Permalink
Mobs: (Traders:) unify model size & collision box calc. Fixes #1172 h…
Browse files Browse the repository at this point in the history
…obbit fat.
  • Loading branch information
alek13 committed Sep 29, 2023
1 parent edc7d7d commit a505cc0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mods/lord/Entities/lord_traders/mod.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = lord_traders
description = Traders mobs for LORD. (Builtin game mod)
depends = mobs, lottmobs, lottarmor, lord_classes, lottother, lord_money
depends = dev_helpers, mobs, lottmobs, lottarmor, lord_classes, lottother, lord_money
optional_d = default, farming, boats, tools, lottblocks, lottplants, lottores, lottthrowing, lottfarming, lottpotion, lord_books

# mobs -- uses common engine 'mobs redo'
Expand Down
40 changes: 33 additions & 7 deletions mods/lord/Entities/lord_traders/src/traders.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@

local trader = require("traders.trader")

-- TODO move this into lord_mobs_common & use for other humanlike mobs
local MODEL_HEIGHT = 1.8
local lord_mobs = {}
lord_mobs.humanlike = {
height = { man = 1, elf = 1.15, hobbit = 0.75, dwarf = 0.85 },
fatness = { man = 1, elf = 0.90, hobbit = 1.1, dwarf = 1.25 }
}
lord_mobs.humanlike.get_collision_box = function(race)
local h = lord_mobs.humanlike.height[race]
local f = lord_mobs.humanlike.fatness[race]
local mh = MODEL_HEIGHT

return {
-0.3 * f, -h, -0.3 * f,
0.3 * f, (mh-1)*h, 0.3 * f
}
end
lord_mobs.humanlike.get_visual_size = function(race)
local h = lord_mobs.humanlike.height[race]
local f = lord_mobs.humanlike.fatness[race]

return { x = h * f, y = h }
end
local get_collision_box = lord_mobs.humanlike.get_collision_box
local get_visual_size = lord_mobs.humanlike.get_visual_size
-- end TODO-------------------------------------------------------------------

trader.register(":lottmobs:elf_trader", {
race = "elf",
hp_min = 20,
hp_max = 50,
collisionbox = { -0.3, -1.1, -0.3, 0.3, 0.91, 0.3 },
collisionbox = get_collision_box("elf"),
visual_size = get_visual_size("elf"),
textures = {
{ "lottmobs_elf_trader.png", "lottarmor_trans.png", "lottarmor_trans.png", "lottarmor_trans.png" },
},
visual_size = { x = 0.95, y = 1.15 },
view_range = 20,
walk_velocity = 1.5,
run_velocity = 5,
Expand All @@ -28,7 +54,7 @@ trader.register(":lottmobs:human_trader", {
race = "man",
hp_min = 15,
hp_max = 35,
collisionbox = { -0.3, -1.0, -0.3, 0.3, 0.8, 0.3 },
collisionbox = get_collision_box("man"),
textures = {
{ "lottmobs_human_trader.png", "lottarmor_trans.png", "lottarmor_trans.png", "lottarmor_trans.png" },
},
Expand All @@ -42,11 +68,11 @@ trader.register(":lottmobs:hobbit_trader", {
race = "hobbit",
hp_min = 5,
hp_max = 15,
collisionbox = { -0.3, -0.75, -0.3, 0.3, 0.7, 0.3 },
collisionbox = get_collision_box("hobbit"),
visual_size = get_visual_size("hobbit"),
textures = {
{ "lottmobs_hobbit_trader.png", "lottarmor_trans.png", "lottarmor_trans.png", "lottarmor_trans.png" },
},
visual_size = { x = 1.1, y = 0.75 },
armor = 300,
lava_damage = 5,
follow = nil,
Expand All @@ -60,11 +86,11 @@ trader.register(":lottmobs:dwarf_trader", {
race = "dwarf",
hp_min = 20,
hp_max = 30,
collisionbox = { -0.3, -.85, -0.3, 0.3, 0.68, 0.3 },
collisionbox = get_collision_box("dwarf"),
visual_size = get_visual_size("dwarf"),
textures = {
{ "lottmobs_dwarf_trader.png", "lottarmor_trans.png", "lottarmor_trans.png", "lottarmor_trans.png" },
},
visual_size = { x = 1.1, y = 0.85 },
view_range = 10,
run_velocity = 2,
armor = 200,
Expand Down
4 changes: 2 additions & 2 deletions mods/lord/Entities/lottmobs/dwarfs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ function lottmobs.register_dwarf(n, hpmin, hpmax, textures, wv, rv, damg, arm, d
type = "npc",
hp_min = hpmin,
hp_max = hpmax,
collisionbox = { -0.3, -0.85, -0.3, 0.3, 0.68, 0.3 },
collisionbox = { -0.375, -0.85, -0.375, 0.375, 0.68, 0.375 },
textures = textures,
visual = "mesh",
visual_size = { x = 0.85, y = 0.85 },
visual_size = { x = 1.0625, y = 0.85 },
mesh = "lottarmor_character_old.b3d",
view_range = 12,
makes_footstep_sound = true,
Expand Down
4 changes: 2 additions & 2 deletions mods/lord/Entities/lottmobs/elves.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ function lottmobs.register_elf(n, hpmin, hpmax, textures, wv, rv, damg, arm, dro
type = "npc",
hp_min = hpmin,
hp_max = hpmax,
collisionbox = { -0.3, -1.1, -0.3, 0.3, 0.91, 0.3 },
collisionbox = { -0.27, -1.15, -0.27, 0.27, 0.92, 0.27 },
textures = textures,
visual = "mesh",
visual_size = { x = 0.95, y = 1.15 },
visual_size = { x = 1.035, y = 1.15 },
mesh = "lottarmor_character_old.b3d",
view_range = 20,
makes_footstep_sound = true,
Expand Down
4 changes: 2 additions & 2 deletions mods/lord/Entities/lottmobs/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,15 @@ mobs:register_mob("lottmobs:hobbit", {
type = "npc",
hp_min = 5,
hp_max = 15,
collisionbox = {-0.3,-0.85,-0.3,0.3,0.68,0.3},
collisionbox = { -0.33, -0.75, -0.33, 0.33, 0.6, 0.33 },
textures = {
{"lottmobs_hobbit.png"},
{"lottmobs_hobbit_1.png"},
{"lottmobs_hobbit_2.png"},
{"lottmobs_hobbit_3.png"},
},
visual = "mesh",
visual_size = {x = 0.85, y = 0.85},
visual_size = {x = 0.825, y = 0.75},
mesh = "dwarf_character.b3d",
makes_footstep_sound = true,
view_range = 12,
Expand Down

0 comments on commit a505cc0

Please sign in to comment.