diff --git a/mods/ENTITIES/mobs/api.lua b/mods/ENTITIES/mobs/api.lua index dfbf42058b..9cbfad4b81 100644 --- a/mods/ENTITIES/mobs/api.lua +++ b/mods/ENTITIES/mobs/api.lua @@ -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, diff --git a/mods/ENTITIES/mobs/api.txt b/mods/ENTITIES/mobs/api.txt index 75b2b98a84..127cfcc1f6 100644 --- a/mods/ENTITIES/mobs/api.txt +++ b/mods/ENTITIES/mobs/api.txt @@ -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 ---------------- diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index bd09131994..dec089070e 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -79,7 +79,7 @@ local skeleton = { }, water_damage = 1, lava_damage = 4, - light_damage = 1, + sunlight_damage = 1, view_range = 16, fear_height = 4, attack_type = "dogshoot", diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index 8d46c7eb77..22e082c7fb 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -75,7 +75,7 @@ mobs:register_mob("mobs_mc:villager_zombie", { }, water_damage = 1, lava_damage = 5, - light_damage = 1, + sunlight_damage = 1, view_range = 16, fear_height = 5, diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 9221ea9070..eb99c18a66 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -81,7 +81,7 @@ local zombie = { }, lava_damage = 4, -- TODO: Burn mob only when in direct sunlight - light_damage = 2, + sunlight_damage = 2, view_range = 16, attack_type = "dogfight", } @@ -96,7 +96,7 @@ baby_zombie.collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.94, 0.25} baby_zombie.visual_size = {x=zombie.visual_size.x/2, y=zombie.visual_size.y/2} baby_zombie.walk_velocity = 1.2 baby_zombie.run_velocity = 2.4 -baby_zombie.light_damage = 0 +baby_zombie.sunlight_damage = 0 mobs:register_mob("mobs_mc:baby_zombie", baby_zombie) @@ -104,7 +104,7 @@ mobs:register_mob("mobs_mc:baby_zombie", baby_zombie) -- Desert variant of the zombie local husk = table.copy(zombie) husk.textures = {{"mobs_mc_husk.png"}} -husk.light_damage = 0 +husk.sunlight_damage = 0 husk.water_damage = 3 husk.drops = drops_common -- TODO: Husks avoid water