1
0
Fork 0

If mob is in daylight and ignites_in_daylight = true, make mob burn

This commit is contained in:
jordan4ibanez 2021-04-24 23:15:40 -04:00
parent 49b01dca4f
commit 7e8e63b0e3
3 changed files with 29 additions and 3 deletions

View File

@ -355,6 +355,10 @@ function mobs:register_mob(name, def)
backup_visual_size = def.visual_size, backup_visual_size = def.visual_size,
backup_collisionbox = collisionbox, backup_collisionbox = collisionbox,
backup_selectionbox = def.selectionbox or def.collisionbox, backup_selectionbox = def.selectionbox or def.collisionbox,
--fire timer
burn_timer = 0,
--end j4i stuff --end j4i stuff
-- MCL2 extensions -- MCL2 extensions

View File

@ -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_item_group = minetest.get_item_group
local minetest_get_node = minetest.get_node local minetest_get_node = minetest.get_node
local minetest_line_of_sight = minetest.line_of_sight 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 DOUBLE_PI = math.pi * 2
local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125 local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125
@ -828,10 +829,31 @@ mobs.mob_step = function(self, dtime)
end end
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 --color modifier which coincides with the pause_timer
if self.old_health and self.health < self.old_health then if self.old_health and self.health < self.old_health then
self.object:set_texture_mod("^[colorize:red:120") self.object:set_texture_mod("^[colorize:red:120")
end end
self.old_health = self.health self.old_health = self.health
--do death logic (animation, poof, explosion, etc) --do death logic (animation, poof, explosion, etc)

View File

@ -124,14 +124,14 @@ mobs.punch_attack_walk = function(self,dtime)
if distance_from_attacking >= self.minimum_follow_distance then if distance_from_attacking >= self.minimum_follow_distance then
mobs.set_velocity(self, self.run_velocity) mobs.set_velocity(self, self.run_velocity)
mobs.set_mob_animation(self, "run")
else else
mobs.set_velocity(self, 0) mobs.set_velocity(self, 0)
mobs.set_mob_animation(self, "stand")
end end
mobs.set_yaw_while_attacking(self) mobs.set_yaw_while_attacking(self)
mobs.set_mob_animation(self, "run")
--make punchy mobs jump --make punchy mobs jump
--check for nodes to jump over --check for nodes to jump over
--explosive mobs will just ride against walls for now --explosive mobs will just ride against walls for now