From c54e6c1e50e63ef051dd2d7b032b93ee6884e6ec Mon Sep 17 00:00:00 2001 From: Nicholas Hayashi Date: Sun, 7 Feb 2021 21:15:29 -0500 Subject: [PATCH] mob fix --- src/mob.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mob.lua b/src/mob.lua index 5c21b35..c8faf3d 100644 --- a/src/mob.lua +++ b/src/mob.lua @@ -11,13 +11,16 @@ MOB_SIZE = MAX_MOB_SIZE MOB_SPECS = { [MOB_TYPE.BEEPER] = { - health = 10, + health = 20, speed = 10, bounty = 5, hurtbox_radius = MOB_SIZE/2 } } +function get_mob_health(mob_type) + return MOB_SPECS[mob_type].health +end function get_mob_spec(mob_type) return MOB_SPECS[mob_type] end @@ -60,7 +63,7 @@ function do_hit_mob(mob, damage, mob_index) mob_die(mob, mob_index) else mob.healthbar:action(coroutine.create(function(self) - self:child(2).x2 = -HEALTHBAR_WIDTH/2 + mob.health/10 * HEALTHBAR_WIDTH/2 + self:child(2).x2 = -HEALTHBAR_WIDTH/2 + mob.health/get_mob_health(mob.type) * HEALTHBAR_WIDTH/2 self.hidden = false am.wait(am.delay(0.8)) self.hidden = true @@ -189,6 +192,7 @@ local function update_mob(mob, mob_index) if mob_can_pass_through(mob, mob.frame_target) then local from = state.map.get(mob.hex.x, mob.hex.y) local to = state.map.get(mob.frame_target.x, mob.frame_target.y) + -- @FIXME changing this '4' constant to '1' breaks mob pathing and I don't know why local rate = 4 * mob.speed * am.delta_time - math.abs(from.elevation - to.elevation) mob.position = mob.position + math.normalize(hex_to_pixel(mob.frame_target) - mob.position) * rate