From 139b1000ffd6d739e765f4cba5bd4d9d474b79e7 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 31 Jan 2019 07:23:35 +0100 Subject: [PATCH] Implement mob suffocation --- mods/ENTITIES/mcl_mobs/api.lua | 23 ++++++++++++++--------- mods/ENTITIES/mcl_mobs/api.txt | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 562184d153..0d7cc4e15b 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -699,19 +699,24 @@ local do_env_damage = function(self) if check_for_death(self, "dps", {type = "environment", pos = pos, node = self.standing_in}) 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 + --- suffocation inside solid node + -- FIXME: Redundant with mcl_playerplus + if (self.suffocation == true) + and (nodef.walkable == nil or nodef.walkable == true) + and (nodef.collision_box == nil or nodef.collision_box.type == "regular") + and (nodef.node_box == nil or nodef.node_box.type == "regular") + and (nodef.groups.disable_suffocation ~= 1) + and (nodef.groups.opaque == 1) then + + -- 2 damage per second + -- TODO: Deal this damage once every 1/2 second + self.health = self.health - 2 if check_for_death(self, "suffocation", {type = "environment", pos = pos, node = self.standing_in}) then return end end -]] + check_for_death(self, "", {type = "unknown"}) end @@ -2995,7 +3000,7 @@ minetest.register_entity(name, { sunlight_damage = def.sunlight_damage or 0, water_damage = def.water_damage or 0, lava_damage = def.lava_damage or 0, - suffocation = def.suffocation or 2, + suffocation = def.suffocation or true, 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 {}, diff --git a/mods/ENTITIES/mcl_mobs/api.txt b/mods/ENTITIES/mcl_mobs/api.txt index fdc798d832..aa9dc5e156 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -61,7 +61,7 @@ functions needed for the mob to work properly which contains the following: in lava or fire. 'light_damage' holds the damage per second inflicted to mobs when it's too bright (above 13 light). - 'suffocation' when true causes mobs to suffocate inside solid blocks. + 'suffocation' when true causes mobs to suffocate inside solid blocks (2 damage per second). 'floats' when set to 1 mob will float in water, 0 has them sink. 'follow' mobs follow player when holding any of the items which appear on this table, the same items can be fed to a mob to tame or