From 8c9356a18cb60cd28691e3782723df763b75a1fa Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Tue, 20 Apr 2021 22:58:39 -0400 Subject: [PATCH] Implement eye_height and viewing range for hostile mobs, along with making punchy mobs jump over nodes --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 + mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 4 +--- .../api/mob_functions/attack_type_instructions.lua | 9 +++++++++ mods/ENTITIES/mobs_mc/creeper.lua | 2 +- mods/ENTITIES/mobs_mc/zombie.lua | 1 + 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 1819ce0603..fcec541775 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -345,6 +345,7 @@ function mobs:register_mob(name, def) fire_resistant = def.fire_resistant or false, fire_damage_resistant = def.fire_damage_resistant or false, ignited_by_sunlight = def.ignited_by_sunlight or false, + eye_height = def.eye_height or 1.5, -- End of MCL2 extensions on_spawn = def.on_spawn, diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 1c15f3a587..8dbe49a972 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -574,9 +574,7 @@ mobs.mob_step = function(self, dtime) if self.hostile then --true for line_of_sight is debug - --10 for radius is debug - --1 for eye height adjust is debug - local attacking = mobs.detect_closest_player_within_radius(self,true,10,1) + local attacking = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height) --go get the closest player ROAR >:O if attacking then 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 0f4d2bcb1c..34a87a745b 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 @@ -107,6 +107,15 @@ mobs.punch_attack_walk = function(self,dtime) mobs.set_mob_animation(self, "run") + --make punchy mobs jump + --check for nodes to jump over + --explosive mobs will just ride against walls for now + local node_in_front_of = mobs.jump_check(self) + if node_in_front_of == 1 then + mobs.jump(self) + end + + if self.punch_timer > 0 then self.punch_timer = self.punch_timer - dtime end diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 830a51dafc..8bb0897c7d 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -41,7 +41,7 @@ mobs:register_mob("mobs_mc:creeper", { run_velocity = 2.1, runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" }, attack_type = "explode", - + eye_height = 1.25, --hssssssssssss explosion_strength = 10, diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 93550a42aa..915f12e7b2 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -71,6 +71,7 @@ local zombie = { damage = "mobs_mc_zombie_hurt", distance = 16, }, + eye_height = 1.65, walk_velocity = 1, run_velocity = 3, damage = 3,