forked from mtcontrib/mobs_redo
added mob suffocation setting (only inside full blocks)
This commit is contained in:
parent
4eb1c937e5
commit
18b90da257
36
api.lua
36
api.lua
|
@ -1,9 +1,9 @@
|
|||
|
||||
-- Mobs Api (4th June 2017)
|
||||
-- Mobs Api (10th June 2017)
|
||||
|
||||
mobs = {}
|
||||
mobs.mod = "redo"
|
||||
mobs.version = "20170604"
|
||||
mobs.version = "20170610"
|
||||
|
||||
|
||||
-- Intllib
|
||||
|
@ -511,7 +511,7 @@ local node_ok = function(pos, fallback)
|
|||
end
|
||||
|
||||
|
||||
-- environmental damage (water, lava, fire, light)
|
||||
-- environmental damage (water, lava, fire, light etc.)
|
||||
local do_env_damage = function(self)
|
||||
|
||||
-- feed/tame text timer (so mob 'full' messages dont spam chat)
|
||||
|
@ -563,15 +563,13 @@ local do_env_damage = function(self)
|
|||
--print ("--- stopping on ignore")
|
||||
end
|
||||
|
||||
if self.water_damage ~= 0
|
||||
or self.lava_damage ~= 0 then
|
||||
|
||||
local nodef = minetest.registered_nodes[self.standing_in]
|
||||
|
||||
pos.y = pos.y + 1
|
||||
pos.y = pos.y + 1 -- for particle effect position
|
||||
|
||||
-- water
|
||||
if nodef.groups.water then
|
||||
if self.water_damage
|
||||
and nodef.groups.water then
|
||||
|
||||
if self.water_damage ~= 0 then
|
||||
|
||||
|
@ -583,7 +581,8 @@ local do_env_damage = function(self)
|
|||
end
|
||||
|
||||
-- lava or fire
|
||||
elseif (nodef.groups.lava
|
||||
elseif self.lava_damage
|
||||
and (nodef.groups.lava
|
||||
or self.standing_in == "fire:basic_flame"
|
||||
or self.standing_in == "fire:permanent_flame") then
|
||||
|
||||
|
@ -597,14 +596,24 @@ local do_env_damage = function(self)
|
|||
end
|
||||
|
||||
-- damage_per_second node check
|
||||
elseif minetest.registered_nodes[self.standing_in].damage_per_second ~= 0 then
|
||||
elseif nodef.damage_per_second ~= 0 then
|
||||
|
||||
local dps = minetest.registered_nodes[self.standing_in].damage_per_second
|
||||
|
||||
self.health = self.health - dps
|
||||
self.health = self.health - nodef.damage_per_second
|
||||
|
||||
effect(pos, 5, "tnt_smoke.png")
|
||||
|
||||
if check_for_death(self, "dps") then return end
|
||||
end
|
||||
|
||||
--- suffocation inside solid node
|
||||
if self.suffocation ~= 0
|
||||
and nodef.walkable == true
|
||||
and nodef.groups.disable_suffocation ~= 1
|
||||
and nodef.drawtype == "normal" then
|
||||
|
||||
self.health = self.health - self.suffocation
|
||||
|
||||
if check_for_death(self, "suffocation") then return end
|
||||
end
|
||||
|
||||
check_for_death(self, "")
|
||||
|
@ -2500,6 +2509,7 @@ minetest.register_entity(name, {
|
|||
light_damage = def.light_damage or 0,
|
||||
water_damage = def.water_damage or 0,
|
||||
lava_damage = def.lava_damage or 0,
|
||||
suffocation = def.suffocation or 2,
|
||||
fall_damage = def.fall_damage or 1,
|
||||
fall_speed = def.fall_speed or -10, -- must be lower than -2 (default: -10)
|
||||
drops = def.drops or {},
|
||||
|
|
3
api.txt
3
api.txt
|
@ -1,5 +1,5 @@
|
|||
|
||||
MOB API (12th May 2017)
|
||||
MOB API (10th June 2017)
|
||||
|
||||
The mob api is a function that can be called on by other mods to add new animals or monsters into minetest.
|
||||
|
||||
|
@ -70,6 +70,7 @@ This functions registers a new mob as a Minetest entity.
|
|||
'water_damage' the damage per second if the mob is in water
|
||||
'lava_damage' the damage per second if the mob is in lava
|
||||
'light_damage' the damage per second if the mob is in light
|
||||
'suffocation' health value mob loses when inside a solid node
|
||||
'fall_damage' will mob be hurt when falling from height
|
||||
'fall_speed' speed mob falls (default: -10 and has to be lower than -2)
|
||||
'fear_height' when mob walks near a drop then anything over this value makes it stop and turn back (default is 0 to disable)
|
||||
|
|
Loading…
Reference in New Issue
Block a user