Merge pull request 'Thunder/rain inconsistencies, sunburn and flashes of fire' (#4443) from burning_in_thunder into master

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4443
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
This commit is contained in:
the-real-herowl 2024-12-01 00:30:43 +01:00
commit 4e8c8f1cde
4 changed files with 42 additions and 57 deletions

@ -14,7 +14,21 @@ function mcl_burning.is_burning(obj)
end end
function mcl_burning.is_affected_by_rain(obj) function mcl_burning.is_affected_by_rain(obj)
return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) local pos = obj:get_pos()
if not pos then return false end
return mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) and mcl_weather.has_rain(pos)
end
function mcl_burning.is_affected_by_sunlight(obj, threshold)
threshold = threshold or core.LIGHT_MAX
local pos = obj:get_pos()
if not pos then return false end
local _,dim = mcl_worlds.y_to_layer(pos.y)
if dim ~= "overworld" then return false end
local sunlight = mcl_util.get_natural_light(pos, core.get_timeofday()) or 0
if sunlight > threshold then return true end
end end
function mcl_burning.get_collisionbox(obj, smaller, storage) function mcl_burning.get_collisionbox(obj, smaller, storage)

@ -1,4 +1,4 @@
name = mcl_burning name = mcl_burning
description = Burning Objects for VoxeLibre description = Burning Objects for VoxeLibre
author = Fleckenstein author = Fleckenstein
depends = mcl_weather depends = mcl_weather, mcl_worlds

@ -634,36 +634,26 @@ function mob_class:do_env_damage()
return true return true
end end
local node = minetest.get_node(pos) -- Simple light damage
if node then if (self.light_damage or 0) > 0 and mcl_burning.is_affected_by_sunlight(self.object, 12) then
if node.name ~= "ignore" then
-- put below code in this block if we can prove that unloaded maps are causing crash.
-- it should warn then error
else
--minetest.log("warning", "Pos is ignored: " .. dump(pos))
end
local sunlight = mcl_util.get_natural_light(pos, self.time_of_day)
if self.light_damage ~= 0 and (sunlight or 0) > 12 then
if self:deal_light_damage(pos, self.light_damage) then if self:deal_light_damage(pos, self.light_damage) then
return true return true
end end
end end
local _, dim = mcl_worlds.y_to_layer(pos.y)
if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then -- Sunlight burning/igniting mobs
if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and mcl_burning.is_affected_by_sunlight(self.object) then
if self.ignited_by_sunlight then if not (self.armor_list and (self.armor_list.helmet or "") ~= "") then
if self.ignited_by_sunlight and not mcl_burning.is_affected_by_rain(self.object) then
if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then
mcl_burning.set_on_fire(self.object, 10) mcl_burning.set_on_fire(self.object, 10)
end
else else
self:deal_light_damage(pos, self.sunlight_damage) self:deal_light_damage(pos, self.sunlight_damage)
return true
end end
end end
end end
end
local y_level = self.collisionbox[2] local y_level = self.collisionbox[2]
if self.child then if self.child then
@ -692,9 +682,11 @@ function mob_class:do_env_damage()
local nodef3 = minetest.registered_nodes[self.standing_under] local nodef3 = minetest.registered_nodes[self.standing_under]
-- rain -- rain
if self.rain_damage > 0 and mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then if self.rain_damage > 0 and mcl_burning.is_affected_by_rain(self.object) then
self.health = self.health - self.rain_damage self.health = self.health - self.rain_damage
if self:check_for_death("rain", {type = "environment", pos = pos, node = self.standing_in}) then
if self:check_for_death("rain", {type = "environment",
pos = pos, node = self.standing_in}) then
return true return true
end end
end end

@ -156,38 +156,16 @@ mcl_mobs.register_mob("mobs_mc:rover", {
-- RAIN DAMAGE / EVASIVE WARP BEHAVIOUR HERE. -- RAIN DAMAGE / EVASIVE WARP BEHAVIOUR HERE.
local enderpos = self.object:get_pos() local enderpos = self.object:get_pos()
local dim = mcl_worlds.pos_to_dimension(enderpos) local dim = mcl_worlds.pos_to_dimension(enderpos)
if dim == "overworld" then if dim == "overworld" and mcl_burning.is_affected_by_rain(self.object) then
if mcl_weather.state == "rain" or mcl_weather.state == "lightning" then
local damage = true
local enderpos = self.object:get_pos()
enderpos.y = enderpos.y+2.89
local height = {x=enderpos.x, y=enderpos.y+512,z=enderpos.z}
local ray = minetest.raycast(enderpos, height, true)
-- Check for blocks above enderman.
for pointed_thing in ray do
if pointed_thing.type == "node" then
local nn = minetest.get_node(minetest.get_pointed_thing_position(pointed_thing)).name
local def = minetest.registered_nodes[nn]
if (not def) or def.walkable then
-- There's a node in the way. Delete arrow without damage
damage = false
break
end
end
end
if damage == true then
self.state = "" self.state = ""
--rain hurts enderman --rain hurts rovers
self.object:punch(self.object, 1.0, { self.object:punch(self.object, 1.0, {
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=self._damage}, damage_groups={fleshy=self.rain_damage},
}, nil) }, nil)
--randomly teleport hopefully under something. --randomly teleport hopefully under something.
self:teleport(nil) self:teleport(nil)
end end
end
end
-- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE. -- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE.
if self.state == "attack" then if self.state == "attack" then
@ -488,6 +466,7 @@ mcl_mobs.register_mob("mobs_mc:rover", {
end, end,
armor = { fleshy = 100, water_vulnerable = 100 }, armor = { fleshy = 100, water_vulnerable = 100 },
water_damage = 8, water_damage = 8,
rain_damage = 2,
view_range = 64, view_range = 64,
fear_height = 4, fear_height = 4,
attack_type = "dogfight", attack_type = "dogfight",