diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index e102430988..1819ce0603 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -323,6 +323,7 @@ function mobs:register_mob(name, def) neutral = def.neutral, attacking = nil, visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1}, + punch_timer_cooloff = def.punch_timer_cooloff or 0.5, --end j4i stuff -- MCL2 extensions diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 6278822c4b..1c15f3a587 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -159,8 +159,15 @@ local land_state_execution = function(self,dtime) elseif self.state == "attack" then + --execute mob attack type if self.attack_type == "explode" then + mobs.explode_attack_walk(self, dtime) + + elseif self.attack_type == "punch" then + + mobs.punch_attack_walk(self,dtime) + end end @@ -573,6 +580,14 @@ mobs.mob_step = function(self, dtime) --go get the closest player ROAR >:O if attacking then + + --set initial punch timer + if self.attacking == nil then + if self.attack_type == "punch" then + self.punch_timer = -1 + end + end + self.attacking = attacking --no player in area else diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua index 9d1ba1bf30..873cc5d629 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua @@ -68,4 +68,29 @@ mobs.reverse_explosion_animation = function(self,dtime) end mobs.handle_explosion_animation(self) +end + + + + +mobs.punch_attack_walk = function(self,dtime) + + --this needs an exception + if self.attacking == nil or not self.attacking:is_player() then + self.attacking = nil + return + end + + mobs.set_yaw_while_attacking(self) + + mobs.set_velocity(self, self.run_velocity) + + mobs.set_mob_animation(self, "run") + + if self.punch_timer > 0 then + self.punch_timer = self.punch_timer - dtime + end + + print(self.punch_timer) + end \ No newline at end of file diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 4d88b25772..14377de3e4 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -48,6 +48,8 @@ table.insert(drops_zombie, { local zombie = { type = "monster", spawn_class = "hostile", + hostile = true, + rotate = 270, hp_min = 20, hp_max = 20, xp_min = 5, @@ -89,6 +91,7 @@ local zombie = { sunlight_damage = 2, view_range = 16, attack_type = "punch", + punch_timer_cooloff = 0.5, harmed_by_heal = true, }