Mobs drown instead of taking direct water damage
This commit is contained in:
parent
725602a72e
commit
d86f602b9f
@ -168,6 +168,8 @@ function mobs:register_mob(name, def)
|
|||||||
lifetimer = def.lifetimer or 180, -- 3 minutes
|
lifetimer = def.lifetimer or 180, -- 3 minutes
|
||||||
hp_min = def.hp_min or 5,
|
hp_min = def.hp_min or 5,
|
||||||
hp_max = def.hp_max or 10,
|
hp_max = def.hp_max or 10,
|
||||||
|
breath_max = def.breath_max or -1, -- how many seconds the mob can breathe in drowning nodes. -1 = no drowning damage
|
||||||
|
breath = def.breath_max,
|
||||||
physical = true,
|
physical = true,
|
||||||
collides_with_objects = def.collides_with_objects or true,
|
collides_with_objects = def.collides_with_objects or true,
|
||||||
collisionbox = def.collisionbox,
|
collisionbox = def.collisionbox,
|
||||||
@ -517,22 +519,6 @@ function mobs:register_mob(name, def)
|
|||||||
local nodef = minetest.registered_nodes[nod.name]
|
local nodef = minetest.registered_nodes[nod.name]
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
|
|
||||||
-- water
|
|
||||||
if self.water_damage ~= 0
|
|
||||||
and nodef.groups.water then
|
|
||||||
self.object:set_hp(self.object:get_hp() - self.water_damage)
|
|
||||||
effect(pos, 5, "bubble.png")
|
|
||||||
if check_for_death(self) then return end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- lava or fire
|
|
||||||
if self.lava_damage ~= 0
|
|
||||||
and nodef.groups.lava then
|
|
||||||
self.object:set_hp(self.object:get_hp() - self.lava_damage)
|
|
||||||
effect(pos, 5, "mobs_flame.png", 8)
|
|
||||||
if check_for_death(self) then return end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- node damage
|
-- node damage
|
||||||
if self.takes_node_damage == true
|
if self.takes_node_damage == true
|
||||||
and nodef.damage_per_second > 0 then
|
and nodef.damage_per_second > 0 then
|
||||||
@ -545,6 +531,43 @@ function mobs:register_mob(name, def)
|
|||||||
if check_for_death(self) then return end
|
if check_for_death(self) then return end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- drowning damage
|
||||||
|
if self.breath_max ~= - 1 then
|
||||||
|
if not self.breath then
|
||||||
|
self.breath = self.breath_max
|
||||||
|
end
|
||||||
|
if nodef.drowning > 0 then
|
||||||
|
self.breath = self.breath - 1
|
||||||
|
if self.breath < 0 then
|
||||||
|
self.breath = 0
|
||||||
|
self.object:set_hp(self.object:get_hp() - nodef.drowning)
|
||||||
|
effect(pos, 5, "bubble.png")
|
||||||
|
end
|
||||||
|
if check_for_death(self) then return end
|
||||||
|
else
|
||||||
|
self.breath = self.breath + 1
|
||||||
|
if self.breath > self.breath_max then
|
||||||
|
self.breath = self.breath_max
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- water damage
|
||||||
|
if self.water_damage ~= 0
|
||||||
|
and nodef.groups.water then
|
||||||
|
self.object:set_hp(self.object:get_hp() - self.water_damage)
|
||||||
|
effect(pos, 5, "bubble.png")
|
||||||
|
if check_for_death(self) then return end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- lava damage
|
||||||
|
if self.lava_damage ~= 0
|
||||||
|
and nodef.groups.lava then
|
||||||
|
self.object:set_hp(self.object:get_hp() - self.lava_damage)
|
||||||
|
effect(pos, 5, "mobs_flame.png", 8)
|
||||||
|
if check_for_death(self) then return end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local do_jump = function(self)
|
local do_jump = function(self)
|
||||||
|
@ -13,6 +13,7 @@ mobs:register_mob(
|
|||||||
damage = 2,
|
damage = 2,
|
||||||
hp_min = 16,
|
hp_min = 16,
|
||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
|
breath_max = 5,
|
||||||
armor = 200,
|
armor = 200,
|
||||||
collisionbox = {-0.5, -1, -0.5, 0.5, 0.1, 0.5},
|
collisionbox = {-0.5, -1, -0.5, 0.5, 0.1, 0.5},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
@ -37,7 +38,7 @@ mobs:register_mob(
|
|||||||
{name = "mobs:pork_raw",
|
{name = "mobs:pork_raw",
|
||||||
chance = 1, min = 1, max = 4},
|
chance = 1, min = 1, max = 4},
|
||||||
},
|
},
|
||||||
water_damage = 1,
|
water_damage = 0,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
animation = {
|
animation = {
|
||||||
|
@ -11,6 +11,7 @@ mobs:register_mob(
|
|||||||
attack_type = "explode",
|
attack_type = "explode",
|
||||||
hp_min = 10,
|
hp_min = 10,
|
||||||
hp_max = 15,
|
hp_max = 15,
|
||||||
|
breath_max = 20,
|
||||||
armor = 200,
|
armor = 200,
|
||||||
collisionbox = {-0.4, 0, -0.4, 0.4, 0.7, 0.4},
|
collisionbox = {-0.4, 0, -0.4, 0.4, 0.7, 0.4},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
@ -34,7 +35,7 @@ mobs:register_mob(
|
|||||||
{name = "tnt:tnt",
|
{name = "tnt:tnt",
|
||||||
chance = 1, min = 1, max = 3},
|
chance = 1, min = 1, max = 3},
|
||||||
},
|
},
|
||||||
water_damage = 1,
|
water_damage = 0,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
takes_node_damage = false,
|
takes_node_damage = false,
|
||||||
|
@ -90,6 +90,7 @@ for _, npc_type_table in pairs(npc_types) do
|
|||||||
attacks_monsters = true,
|
attacks_monsters = true,
|
||||||
hp_min = 10,
|
hp_min = 10,
|
||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
|
breath_max = 11,
|
||||||
armor = 80,
|
armor = 80,
|
||||||
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
|
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
@ -10,6 +10,7 @@ mobs:register_mob(
|
|||||||
passive = true,
|
passive = true,
|
||||||
hp_min = 10,
|
hp_min = 10,
|
||||||
hp_max = 14,
|
hp_max = 14,
|
||||||
|
breath_max = 5,
|
||||||
armor = 200,
|
armor = 200,
|
||||||
collisionbox = {-0.5, -1, -0.5, 0.5, 0.1, 0.5},
|
collisionbox = {-0.5, -1, -0.5, 0.5, 0.1, 0.5},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
@ -37,7 +38,7 @@ mobs:register_mob(
|
|||||||
{name = "mobs:wool",
|
{name = "mobs:wool",
|
||||||
chance = 1, min = 1, max = 2},
|
chance = 1, min = 1, max = 2},
|
||||||
},
|
},
|
||||||
water_damage = 1,
|
water_damage = 0,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
animation = {
|
animation = {
|
||||||
|
@ -9,6 +9,7 @@ mobs:register_mob(
|
|||||||
passive = false,
|
passive = false,
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
damage = 1,
|
damage = 1,
|
||||||
|
breath_max = 7,
|
||||||
hp_min = 16,
|
hp_min = 16,
|
||||||
hp_max = 22,
|
hp_max = 22,
|
||||||
armor = 130,
|
armor = 130,
|
||||||
@ -34,7 +35,7 @@ mobs:register_mob(
|
|||||||
{name = "mobs:meat_raw",
|
{name = "mobs:meat_raw",
|
||||||
chance = 1, min = 1, max = 2},
|
chance = 1, min = 1, max = 2},
|
||||||
},
|
},
|
||||||
water_damage = 1,
|
water_damage = 0,
|
||||||
lava_damage = 7,
|
lava_damage = 7,
|
||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
animation = {
|
animation = {
|
||||||
|
@ -11,6 +11,7 @@ mobs:register_mob(
|
|||||||
damage = 3,
|
damage = 3,
|
||||||
hp_min = 8,
|
hp_min = 8,
|
||||||
hp_max = 16,
|
hp_max = 16,
|
||||||
|
breath_max = -1,
|
||||||
armor = 200,
|
armor = 200,
|
||||||
collisionbox = {-0.3, 0, -0.3, 0.3, 1.5, 0.3},
|
collisionbox = {-0.3, 0, -0.3, 0.3, 1.5, 0.3},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
Loading…
Reference in New Issue
Block a user