Update master #1

Merged
THE-NERD2 merged 296 commits from VoxeLibre/VoxeLibre:master into master 2024-11-21 19:51:04 +01:00
2 changed files with 60 additions and 94 deletions
Showing only changes of commit d85febdb15 - Show all commits

View File

@ -692,14 +692,10 @@ 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 then if self.rain_damage > 0 and mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then
if mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) 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
return true
if self:check_for_death("rain", {type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end end
end end
@ -707,14 +703,10 @@ function mob_class:do_env_damage()
-- water damage -- water damage
if self.water_damage > 0 and nodef.groups.water then if self.water_damage > 0 and nodef.groups.water then
if self.water_damage ~= 0 then self.health = self.health - self.water_damage
self.health = self.health - self.water_damage mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png", nil, nil, 1, nil)
mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png", nil, nil, 1, nil) if self:check_for_death("water", {type = "environment", pos = pos, node = self.standing_in}) then
return true
if self:check_for_death("water", {type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end end
elseif self.lava_damage > 0 and (nodef.groups.lava) then elseif self.lava_damage > 0 and (nodef.groups.lava) then
-- lava damage -- lava damage
@ -730,91 +722,69 @@ function mob_class:do_env_damage()
end end
elseif self.fire_damage > 0 and (nodef2.groups.fire) then elseif self.fire_damage > 0 and (nodef2.groups.fire) then
-- magma damage -- magma damage
if self.fire_damage ~= 0 then self.health = self.health - self.fire_damage
self.health = self.health - self.fire_damage if self:check_for_death("fire", {type = "environment", pos = pos, node = self.standing_in}) then
return true
if self:check_for_death("fire", {type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end end
elseif self.fire_damage > 0 and (nodef.groups.fire) then elseif self.fire_damage > 0 and (nodef.groups.fire) then
-- fire damage -- fire damage
if self.fire_damage ~= 0 then self.health = self.health - self.fire_damage
self.health = self.health - self.fire_damage mcl_mobs.effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil)
mcl_mobs.effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) mcl_burning.set_on_fire(self.object, 5)
mcl_burning.set_on_fire(self.object, 5) if self:check_for_death("fire", {type = "environment", pos = pos, node = self.standing_in}) then
return true
if self:check_for_death("fire", {type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end end
elseif nodef.damage_per_second ~= 0 and not nodef.groups.lava and not nodef.groups.fire then elseif nodef.damage_per_second ~= 0 and not nodef.groups.lava and not nodef.groups.fire then
-- damage_per_second node check -- damage_per_second node check
self.health = self.health - nodef.damage_per_second self.health = self.health - nodef.damage_per_second
mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png") mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png")
if self:check_for_death("dps", {type = "environment", pos = pos, node = self.standing_in}) then
if self:check_for_death("dps", {type = "environment",
pos = pos, node = self.standing_in}) then
return true return true
end end
end end
-- Cactus damage -- Cactus damage
local near = minetest.find_node_near(pos, 1, "mcl_core:cactus", true) if self.standing_on == "mcl_core:cactus" or self.standing_in == "mcl_core:cactus" or self.standing_under == "mcl_core:cactus" then
if not near and near ~= nil then self:damage_mob("cactus", 2)
near = find_node_near({x=pos.x, y=pos.y-1, z=pos.z}, 1, "mcl_core:cactus", true) if self:check_for_death("cactus", {type = "environment", pos = pos, node = self.standing_in}) then
end return true
if near then
-- is mob touching the cactus?
local dist = vector.distance(pos, near)
local dist_feet = vector.distance({x=pos.x, y=pos.y-1, z=pos.z}, near)
local large_mob = false
local medium_mob = false
if self.name == "mobs_mc:ender_dragon" or
self.name == "mobs_mc:ghast" or
self.name == "mobs_mc:guardian_elder" or
self.name == "mobs_mc:slime_big" or
self.name == "mobs_mc:magma_cube_big" or
self.name == "mobs_mc:wither" then
large_mob = true
elseif self.name == "mobs_mc:hoglin" or
self.name == "mobs_mc:zoglin" or
self.name == "mobs_mc:horse" or
self.name == "mobs_mc:skeleton_horse" or
self.name == "mobs_mc:zombie_horse" or
self.name == "mobs_mc:donkey" or
self.name == "mobs_mc:mule" or
self.name == "mobs_mc:iron_golem" or
self.name == "mobs_mc:polar_bear" or
self.name == "mobs_mc:spider" or
self.name == "mobs_mc:cave_spider" or
self.name == "mobs_mc:strider" then
medium_mob = true
end end
if (not large_mob and not medium_mob and (dist < 1.03 or dist_feet < 1.6)) or (medium_mob and (dist < 1.165 or dist_feet < 1.73)) or (large_mob and (dist < 1.25 or dist_feet < 1.9)) then else
if self.health ~= 0 then local near = minetest.find_node_near(pos, 1, "mcl_core:cactus")
if near then
-- is mob touching the cactus?
local dist = vector.distance(pos, near)
local threshold = 1.04 -- small mobs
-- medium mobs
if self.name == "mobs_mc:spider" or
self.name == "mobs_mc:iron_golem" or
self.name == "mobs_mc:horse" or
self.name == "mobs_mc:donkey" or
self.name == "mobs_mc:mule" or
self.name == "mobs_mc:polar_bear" or
self.name == "mobs_mc:cave_spider" or
self.name == "mobs_mc:skeleton_horse" or
self.name == "mobs_mc:zombie_horse" or
self.name == "mobs_mc:strider" or
self.name == "mobs_mc:hoglin" or
self.name == "mobs_mc:zoglin" then
threshold = 1.165
elseif self.name == "mobs_mc:slime_big" or
self.name == "mobs_mc:magma_cube_big" or
self.name == "mobs_mc:ghast" or
self.name == "mobs_mc:guardian_elder" or
self.name == "mobs_mc:wither" or
self.name == "mobs_mc:ender_dragon" then
threshold = 1.25
end
if dist < threshold then
self:damage_mob("cactus", 2) self:damage_mob("cactus", 2)
if self:check_for_death("cactus", {type = "environment", pos = pos, node = self.standing_in}) then
if self:check_for_death("cactus", {type = "environment",
pos = pos, node = self.standing_in}) then
return true return true
end end
end end
end end
end end
-- is mob standing on the cactus?
if self.standing_on == "mcl_core:cactus" or self.standing_in == "mcl_core:cactus" or self.standing_under == "mcl_core:cactus" then
self:damage_mob("cactus", 2)
if self:check_for_death("cactus", {type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end
-- Drowning damage -- Drowning damage
if self.breath_max ~= -1 then if self.breath_max ~= -1 then

View File

@ -560,22 +560,18 @@ minetest.register_globalstep(function(dtime)
and (node_head ~= "ignore") and (node_head ~= "ignore")
-- Check privilege, too -- Check privilege, too
and (not check_player_privs(name, {noclip = true})) then and (not check_player_privs(name, {noclip = true})) then
if player:get_hp() > 0 then mcl_util.deal_damage(player, 1, {type = "in_wall"})
mcl_util.deal_damage(player, 1, {type = "in_wall"})
end
end end
-- Am I near a cactus? -- Am I near a cactus?
local near = find_node_near(pos, 1, "mcl_core:cactus") if node_stand == "mcl_core:cactus" or node_feet == "mcl_core:cactus" or node_head == "mcl_core:cactus" then
if not near then mcl_util.deal_damage(player, 1, {type = "cactus"})
near = find_node_near({x=pos.x, y=pos.y-1, z=pos.z}, 1, "mcl_core:cactus") else
end local near = find_node_near(pos, 1, "mcl_core:cactus")
if near then if near then
-- Am I touching the cactus? If so, it hurts -- Am I touching the cactus? If so, it hurts
local dist = vector.distance(pos, near) local dist = vector.distance(pos, near)
local dist_feet = vector.distance({x=pos.x, y=pos.y-1, z=pos.z}, near) if dist < 1.1 then
if dist < 1.1 or dist_feet < 1.1 then
if player:get_hp() > 0 then
mcl_util.deal_damage(player, 1, {type = "cactus"}) mcl_util.deal_damage(player, 1, {type = "cactus"})
end end
end end