Undead mobs take light damage only in sunlight

This commit is contained in:
Wuzzy 2018-05-31 03:09:27 +02:00
parent b73e05d64a
commit 4513c6c35d
5 changed files with 19 additions and 12 deletions

View file

@ -617,21 +617,26 @@ local do_env_damage = function(self)
return
end
-- bright light harms mob
if self.light_damage ~= 0
and (minetest.get_node_light(pos) or 0) > 12 then
local deal_light_damage = function(self, pos, damage)
if not (mod_weather and (mcl_weather.rain.raining or mcl_weather.state == "snow") and mcl_weather.is_outdoor(pos)) then
self.health = self.health - self.light_damage
self.health = self.health - damage
effect(pos, 5, "tnt_smoke.png")
if check_for_death(self, "light", {type = "light"}) then return end
end
end
-- bright light harms mob
if self.light_damage ~= 0 and (minetest.get_node_light(pos) or 0) > 12 then
deal_light_damage(self, pos, self.light_damage)
end
local _, dim = mcl_worlds.y_to_layer(pos.y)
if self.sunlight_damage ~= 0 and (minetest.get_node_light(pos) or 0) >= minetest.LIGHT_MAX and dim == "overworld" then
deal_light_damage(self, pos, self.sunlight_damage)
end
local y_level = self.collisionbox[2]
if self.child then
@ -3017,6 +3022,7 @@ minetest.register_entity(name, {
run_velocity = def.run_velocity or 2,
damage = max(0, (def.damage or 0) * difficulty),
light_damage = def.light_damage or 0,
sunlight_damage = def.sunlight_damage or 0,
water_damage = def.water_damage or 0,
lava_damage = def.lava_damage or 0,
suffocation = def.suffocation or 2,

View file

@ -209,7 +209,8 @@ functions needed for the mob to work properly which contains the following:
'ignores_nametag' if true, mob cannot be named by nametag
'rain_damage' damage per second if mob is standing in rain (default: 0)
'sunlight_damage' holds the damage per second inflicted to mobs when they
are in direct sunlight
Node Replacement
----------------