From 7e8e63b0e37300b16a4556aa45758d737514316e Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 23:15:40 -0400 Subject: [PATCH] If mob is in daylight and ignites_in_daylight = true, make mob burn --- mods/ENTITIES/mcl_mobs/api/api.lua | 4 ++++ .../mcl_mobs/api/mob_functions/ai.lua | 24 ++++++++++++++++++- .../attack_type_instructions.lua | 4 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index cdd5889fe..4cc49e322 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -355,6 +355,10 @@ function mobs:register_mob(name, def) backup_visual_size = def.visual_size, backup_collisionbox = collisionbox, backup_selectionbox = def.selectionbox or def.collisionbox, + + + --fire timer + burn_timer = 0, --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 93ec12f72..a2e48ba2a 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -12,6 +12,7 @@ local minetest_yaw_to_dir = minetest.yaw_to_dir local minetest_get_item_group = minetest.get_item_group local minetest_get_node = minetest.get_node local minetest_line_of_sight = minetest.line_of_sight +local minetest_get_node_light = minetest.get_node_light local DOUBLE_PI = math.pi * 2 local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125 @@ -828,10 +829,31 @@ mobs.mob_step = function(self, dtime) end end + --set mobs on fire when burned by sunlight + if self.ignited_by_sunlight then + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + + if self.burn_timer > 0 then + self.burn_timer = self.burn_timer - dtime + + if self.burn_timer <= 0 then + self.health = self.health - 4 + self.burn_timer = 0 + end + end + + if self.burn_timer == 0 and minetest_get_node_light(pos) > 12 and minetest_get_node_light(pos, 0.5) == 15 then + mcl_burning.set_on_fire(self.object, 1) + self.burn_timer = 1 --1.7 seconds + self.pause_timer = 0.4 + end + end + --color modifier which coincides with the pause_timer if self.old_health and self.health < self.old_health then self.object:set_texture_mod("^[colorize:red:120") - end + end self.old_health = self.health --do death logic (animation, poof, explosion, etc) 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 0df4a42f9..c973f3d1b 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 @@ -124,14 +124,14 @@ mobs.punch_attack_walk = function(self,dtime) if distance_from_attacking >= self.minimum_follow_distance then mobs.set_velocity(self, self.run_velocity) + mobs.set_mob_animation(self, "run") else mobs.set_velocity(self, 0) + mobs.set_mob_animation(self, "stand") end mobs.set_yaw_while_attacking(self) - 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