From 6b52b945165a8501e09ca70c18514049df194c05 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Tue, 20 Apr 2021 22:30:34 -0400 Subject: [PATCH] Start setting up hostile punch attack type --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 + .../mcl_mobs/api/mob_functions/ai.lua | 15 +++++++++++ .../attack_type_instructions.lua | 25 +++++++++++++++++++ mods/ENTITIES/mobs_mc/zombie.lua | 3 +++ 4 files changed, 44 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index e10243098..1819ce060 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 6278822c4..1c15f3a58 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 9d1ba1bf3..873cc5d62 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 4d88b2577..14377de3e 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, }