1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-12-25 02:00:21 +01:00

add check to see what hit mob, player or entity for immune_to

This commit is contained in:
tenplus1 2023-07-02 17:17:14 +01:00
parent e32d87c70d
commit cc0798b617

11
api.lua
View File

@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20230613",
version = "20230702",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -2873,10 +2873,17 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
end
end
-- check if hit by player item or entity
local hit_item = weapon_def.name
if not hitter:is_player() then
hit_item = hitter:get_luaentity().name
end
-- check for tool immunity or special damage
for n = 1, #self.immune_to do
if self.immune_to[n][1] == weapon_def.name then
if self.immune_to[n][1] == hit_item then
damage = self.immune_to[n][2] or 0