From 8eb9ba12cef918cb116aea8eaea5a1e757123b01 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 14:33:40 -0400 Subject: [PATCH 1/3] Fix crash when mob collides with nil entity --- mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua index 43b7592692..b56a0d3921 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua @@ -39,7 +39,7 @@ mobs.collision = function(self) end for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do - if object and object ~= self.object and (object:is_player() or object:get_luaentity()._cmi_is_mob == true) then--and + if object and object ~= self.object and (object:is_player() or (object:get_luaentity() and object:get_luaentity()._cmi_is_mob == true)) then--and --don't collide with rider, rider don't collide with thing --(not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and --(not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then From 16cc7e37d2fc83e50d4e2c380cef05224dbbed38 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 14:34:59 -0400 Subject: [PATCH 2/3] Randomize projectile cooldown timer --- mods/ENTITIES/mcl_mobs/api/api.lua | 11 ++++++----- .../api/mob_functions/attack_type_instructions.lua | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index c7d92c1e66..b1ea2d1e97 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -328,8 +328,13 @@ function mobs:register_mob(name, def) 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, - projectile_cooldown = def.projectile_cooldown or 2, death_animation_timer = 0, + hostile_cooldown = def.hostile_cooldown or 15, + tilt_fly = def.tilt_fly, + tilt_swim = def.tilt_swim, + fall_slow = def.fall_slow, + projectile_cooldown_min = def.projectile_cooldown_min or 2, + projectile_cooldown_max = def.projectile_cooldown_max or 6, --end j4i stuff -- MCL2 extensions @@ -353,10 +358,6 @@ function mobs:register_mob(name, def) ignited_by_sunlight = def.ignited_by_sunlight or false, eye_height = def.eye_height or 1.5, defuse_reach = def.defuse_reach or 4, - hostile_cooldown = def.hostile_cooldown or 15, - tilt_fly = def.tilt_fly, - tilt_swim = def.tilt_swim, - fall_slow = def.fall_slow, -- End of MCL2 extensions on_spawn = def.on_spawn, 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 ac5561adbf..7907f8c47d 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 @@ -2,6 +2,7 @@ local vector_direction = vector.direction local minetest_dir_to_yaw = minetest.dir_to_yaw local vector_distance = vector.distance local vector_multiply = vector.multiply +local math_random = math.random --[[ _ _ _ _ @@ -208,7 +209,7 @@ mobs.projectile_attack_walk = function(self,dtime) --do this to not load data into other mobs if not self.projectile_timer then - self.projectile_timer = self.projectile_cooldown + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) end --run projectile timer @@ -218,7 +219,7 @@ mobs.projectile_attack_walk = function(self,dtime) --shoot if self.projectile_timer <= 0 then --reset timer - self.projectile_timer = self.projectile_cooldown + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) mobs.shoot_projectile(self) end end @@ -291,7 +292,7 @@ mobs.projectile_attack_fly = function(self, dtime) --do this to not load data into other mobs if not self.projectile_timer then - self.projectile_timer = self.projectile_cooldown + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) end --run projectile timer @@ -301,7 +302,7 @@ mobs.projectile_attack_fly = function(self, dtime) --shoot if self.projectile_timer <= 0 then --reset timer - self.projectile_timer = self.projectile_cooldown + self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max) mobs.shoot_projectile(self) end end From 58bee2a2dd1b4d6d3d1873d3ac566be9e0aa7930 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 14:43:00 -0400 Subject: [PATCH 3/3] Fix projectile tails clipping through sprite --- mods/ENTITIES/mcl_mobs/api/api.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index b1ea2d1e97..df267b0526 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -45,6 +45,7 @@ local math_floor = math.floor -- localize vector functions local vector_new = vector.new +local vector_add = vector.add local vector_length = vector.length local vector_direction = vector.direction local vector_normalize = vector.normalize @@ -479,9 +480,7 @@ function mobs:register_arrow(name, def) if self.timer > 150 or not mobs.within_limits(pos, 0) then mcl_burning.extinguish(self.object) - print("removing 1") self.object:remove(); - return end @@ -490,8 +489,10 @@ function mobs:register_arrow(name, def) and def.tail == 1 and def.tail_texture then + --do this to prevent clipping through main entity sprite + local new_pos = vector_add(pos, vector_multiply(vector_normalize(vel), -1)) minetest.add_particle({ - pos = pos, + pos = new_pos, velocity = {x = 0, y = 0, z = 0}, acceleration = {x = 0, y = 0, z = 0}, expirationtime = def.expire or 0.25,