diff --git a/api.lua b/api.lua index b38fd4b..dbb5051 100644 --- a/api.lua +++ b/api.lua @@ -19,7 +19,7 @@ end mobs = { mod = "redo", - version = "20241122", + version = "20241127", spawning_mobs = {}, translate = S, node_snow = has(minetest.registered_aliases["mapgen_snow"]) @@ -1039,9 +1039,22 @@ function mob_class:do_env_damage() if self.node_damage and nodef.damage_per_second and nodef.damage_per_second ~= 0 and nodef.groups.lava == nil and nodef.groups.fire == nil then - self.health = self.health - nodef.damage_per_second + local damage = nodef.damage_per_second - effect(py, 5, "tnt_smoke.png") + -- check for node immunity or special damage + for n = 1, #self.immune_to do + + if self.immune_to[n][1] == self.standing_in then + + damage = self.immune_to[n][2] or 0 + + break + end + end + + self.health = self.health - damage + + if damage > 0 then effect(py, 5, "tnt_smoke.png") end if self:check_for_death({type = "environment", pos = pos, node = self.standing_in}) then return true end diff --git a/api.txt b/api.txt index 4a26824..11699ea 100644 --- a/api.txt +++ b/api.txt @@ -85,8 +85,6 @@ functions needed for the mob to work properly which contains the following: 'fire_damage' holds the damage per second inflicted to mobs when standing 'node_damage' True by default, will harm mobs when inside damage_per_second nodes. - in fire. - 'light_damage' holds the damage per second inflicted to mobs when light level is between the min and max values below 'light_damage_min' minimum light value when mob is affected (default: 14) @@ -178,6 +176,9 @@ functions needed for the mob to work properly which contains the following: {"default:gold_lump", -10} -- heals by 10 health points. {"default:coal_block", 20} -- 20 damage when hit on head with coal blocks. {"all"} -- stops all weapons causing damage apart from those on list. + nodes can also be added so that node_per_second damage + does not affect the mob either e.g. + {"ethereal:crystal_spike", 0} -- causes no damage. 'makes_footstep_sound' when true you can hear mobs walking. 'sounds' this is a table with sounds of the mob