From 1478960b7f6dfe8a97935684f275f61574244354 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Thu, 25 Jan 2024 03:50:00 +0100 Subject: [PATCH] Improved ghast combat * ghast fireballs can now hit the shooter (used to just fly through) * improved ghast aim * increased ghast fireball lifetime * mob projectile lifetime is now counted in seconds (was in ticks) * improved variable naming * improved default mob projectile deflecting (applies to ghast fireball) --- mods/ENTITIES/mcl_mobs/init.lua | 26 +++++++++++++------------- mods/ENTITIES/mobs_mc/ghast.lua | 3 ++- mods/ENTITIES/mobs_mc/wither.lua | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index f4322bd31..15ca47050 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -362,12 +362,12 @@ function mcl_mobs.register_arrow(name, def) collisionbox = {0, 0, 0, 0, 0, 0}, -- remove box around arrows timer = 0, switch = 0, - _lifetime = def._lifetime or 150, + _lifetime = def._lifetime or 7, owner_id = def.owner_id, rotate = def.rotate, - on_punch = def.on_punch or function(self) - local vel = self.object:get_velocity() - self.object:set_velocity({x=vel.x * -1, y=vel.y * -1, z=vel.z * -1}) + on_punch = def.on_punch or function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) + local vel = self.object:get_velocity():length() + self.object:set_velocity({x=dir.x * vel, y=dir.y * vel, z=dir.z * vel}) end, collisionbox = def.collisionbox or {0, 0, 0, 0, 0, 0}, automatic_face_movement_dir = def.rotate @@ -377,7 +377,7 @@ function mcl_mobs.register_arrow(name, def) on_step = def.on_step or function(self, dtime) - self.timer = self.timer + 1 + self.timer = self.timer + dtime local pos = self.object:get_pos() @@ -443,24 +443,24 @@ function mcl_mobs.register_arrow(name, def) if self.hit_player or self.hit_mob or self.hit_object then - for _,player in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do + for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do if self.hit_player - and player:is_player() then + and object:is_player() then - self.hit_player(self, player) + self.hit_player(self, object) self.object:remove(); return end - local entity = player:get_luaentity() + local entity = object:get_luaentity() if entity and self.hit_mob and entity.is_mob == true - and tostring(player) ~= self.owner_id + and (tostring(object) ~= self.owner_id or self.timer > 2) and entity.name ~= self.object:get_luaentity().name then - self.hit_mob(self, player) + self.hit_mob(self, object) self.object:remove(); return end @@ -468,9 +468,9 @@ function mcl_mobs.register_arrow(name, def) if entity and self.hit_object and (not entity.is_mob) - and tostring(player) ~= self.owner_id + and (tostring(object) ~= self.owner_id or self.timer > 2) and entity.name ~= self.object:get_luaentity().name then - self.hit_object(self, player) + self.hit_object(self, object) self.object:remove(); return end diff --git a/mods/ENTITIES/mobs_mc/ghast.lua b/mods/ENTITIES/mobs_mc/ghast.lua index 0a9a95613..01e01f079 100644 --- a/mods/ENTITIES/mobs_mc/ghast.lua +++ b/mods/ENTITIES/mobs_mc/ghast.lua @@ -54,7 +54,7 @@ mcl_mobs.register_mob("mobs_mc:ghast", { attack_type = "dogshoot", arrow = "mobs_mc:fireball", shoot_interval = 3, - shoot_offset = -5, + shoot_offset = -0.5, dogshoot_switch = 1, dogshoot_count_max =1, passive = false, @@ -109,6 +109,7 @@ mcl_mobs.register_arrow("mobs_mc:fireball", { textures = {"mcl_fire_fire_charge.png"}, velocity = 5, collisionbox = {-.5, -.5, -.5, .5, .5, .5}, + _lifetime = 10, _is_fireball = true, hit_player = function(self, player) diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index cda3f0153..f1e1e6e78 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -463,7 +463,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", { }, velocity = 7, rotate = 90, - _lifetime = 350, + _lifetime = 15, on_punch = function(self) end, -- direct hit @@ -516,7 +516,7 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull_strong", { }, velocity = 4, rotate = 90, - _lifetime = 500, + _lifetime = 25, on_punch = function(self) end, -- direct hit