Restore killing mobs by lava

This commit is contained in:
kay27 2022-03-12 01:05:29 +04:00
parent ef08bfa5d9
commit 430c3ce636
1 changed files with 28 additions and 20 deletions

View File

@ -801,20 +801,6 @@ function mobs.mob_step(self, dtime)
return false return false
end end
--DEBUG TIME!
--REMEMBER TO MOVE THIS AFTER DEATH CHECK
--if self.has_head then
-- mobs.do_head_logic(self,dtime)
--end
--if true then--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
-- return
--end
--despawn mechanism --despawn mechanism
--don't despawned tamed or bred mobs --don't despawned tamed or bred mobs
if not self.tamed and not self.bred then if not self.tamed and not self.bred then
@ -893,14 +879,36 @@ function mobs.mob_step(self, dtime)
end end
end end
--water damage
if self.water_damage and self.water_damage ~= 0 then
local pos = self.object:get_pos() local pos = self.object:get_pos()
local node = minetest_get_node(pos).name local node = minetest_get_node(pos).name
if minetest_get_item_group(node, "water") ~= 0 then
--water damage
if self.water_damage and self.water_damage ~= 0 and minetest_get_item_group(node, "water") ~= 0 then
self.water_counter = (self.water_counter or 0) + dtime
if self.water_counter >= 1 then
mobs.smoke_effect(self) mobs.smoke_effect(self)
self.health = self.health - self.water_damage self.health = self.health - self.water_damage
self:teleport() self:teleport()
self.water_counter = 0
end
end
--lava damage
local lava_damage = self.lava_damage
if lava_damage and lava_damage ~= 0 and minetest_get_item_group(node, "lava") ~= 0 then
self.lava_counter = (self.lava_counter or 0) + dtime
if self.lava_counter >= 1 then
minetest.sound_play("default_punch", {
object = self.object,
max_hear_distance = 5
}, true)
self.object:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = self.lava_damage}
}, nil)
self.lava_counter = 0
self.health = self.health - lava_damage
self:teleport()
end end
end end