forked from MineClone5/MineClone5
Undead mobs take light damage only in sunlight
This commit is contained in:
parent
b73e05d64a
commit
4513c6c35d
|
@ -617,21 +617,26 @@ local do_env_damage = function(self)
|
||||||
return
|
return
|
||||||
end
|
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
|
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 - damage
|
||||||
self.health = self.health - self.light_damage
|
|
||||||
|
|
||||||
effect(pos, 5, "tnt_smoke.png")
|
effect(pos, 5, "tnt_smoke.png")
|
||||||
|
|
||||||
if check_for_death(self, "light", {type = "light"}) then return end
|
if check_for_death(self, "light", {type = "light"}) then return end
|
||||||
|
|
||||||
end
|
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]
|
local y_level = self.collisionbox[2]
|
||||||
|
|
||||||
if self.child then
|
if self.child then
|
||||||
|
@ -3017,6 +3022,7 @@ minetest.register_entity(name, {
|
||||||
run_velocity = def.run_velocity or 2,
|
run_velocity = def.run_velocity or 2,
|
||||||
damage = max(0, (def.damage or 0) * difficulty),
|
damage = max(0, (def.damage or 0) * difficulty),
|
||||||
light_damage = def.light_damage or 0,
|
light_damage = def.light_damage or 0,
|
||||||
|
sunlight_damage = def.sunlight_damage or 0,
|
||||||
water_damage = def.water_damage or 0,
|
water_damage = def.water_damage or 0,
|
||||||
lava_damage = def.lava_damage or 0,
|
lava_damage = def.lava_damage or 0,
|
||||||
suffocation = def.suffocation or 2,
|
suffocation = def.suffocation or 2,
|
||||||
|
|
|
@ -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
|
'ignores_nametag' if true, mob cannot be named by nametag
|
||||||
'rain_damage' damage per second if mob is standing in rain (default: 0)
|
'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
|
Node Replacement
|
||||||
----------------
|
----------------
|
||||||
|
|
|
@ -79,7 +79,7 @@ local skeleton = {
|
||||||
},
|
},
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
lava_damage = 4,
|
lava_damage = 4,
|
||||||
light_damage = 1,
|
sunlight_damage = 1,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
attack_type = "dogshoot",
|
attack_type = "dogshoot",
|
||||||
|
|
|
@ -75,7 +75,7 @@ mobs:register_mob("mobs_mc:villager_zombie", {
|
||||||
},
|
},
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
light_damage = 1,
|
sunlight_damage = 1,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
fear_height = 5,
|
fear_height = 5,
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ local zombie = {
|
||||||
},
|
},
|
||||||
lava_damage = 4,
|
lava_damage = 4,
|
||||||
-- TODO: Burn mob only when in direct sunlight
|
-- TODO: Burn mob only when in direct sunlight
|
||||||
light_damage = 2,
|
sunlight_damage = 2,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
attack_type = "dogfight",
|
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.visual_size = {x=zombie.visual_size.x/2, y=zombie.visual_size.y/2}
|
||||||
baby_zombie.walk_velocity = 1.2
|
baby_zombie.walk_velocity = 1.2
|
||||||
baby_zombie.run_velocity = 2.4
|
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)
|
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
|
-- Desert variant of the zombie
|
||||||
local husk = table.copy(zombie)
|
local husk = table.copy(zombie)
|
||||||
husk.textures = {{"mobs_mc_husk.png"}}
|
husk.textures = {{"mobs_mc_husk.png"}}
|
||||||
husk.light_damage = 0
|
husk.sunlight_damage = 0
|
||||||
husk.water_damage = 3
|
husk.water_damage = 3
|
||||||
husk.drops = drops_common
|
husk.drops = drops_common
|
||||||
-- TODO: Husks avoid water
|
-- TODO: Husks avoid water
|
||||||
|
|
Loading…
Reference in New Issue