add attack_ignore feature (thx ShadowOfHassen for idea)

This commit is contained in:
tenplus1 2024-03-01 16:01:18 +00:00
parent 95f3e98867
commit 17dafff8ef
2 changed files with 6 additions and 2 deletions

View File

@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
-- Global
mobs = {
mod = "redo",
version = "20240227",
version = "20240301",
translate = S,
invis = minetest.global_exists("invisibility") and invisibility or {},
node_snow = minetest.registered_aliases["mapgen_snow"]
@ -191,6 +191,7 @@ mobs.mob_class = {
attack_animals = false,
attack_players = true,
attack_npcs = true,
attack_ignore = nil,
friendly_fire = true,
facing_fence = false,
_breed_countdown = nil,
@ -1908,8 +1909,9 @@ function mob_class:general_attack()
-- or are we a mob?
elseif ent and ent._cmi_is_mob then
-- remove mobs not to attack
-- remove mobs to not attack
if self.name == ent.name
or check_for(ent.name, self.attack_ignore)
or (not self.attack_animals and ent.type == "animal")
or (not self.attack_monsters and ent.type == "monster")
or (not self.attack_npcs and ent.type == "npc")
@ -3688,6 +3690,7 @@ minetest.register_entity(":" .. name, setmetatable({
attack_animals = def.attack_animals,
attack_players = def.attack_players,
attack_npcs = def.attack_npcs,
attack_ignore = def.attack_ignore,
specific_attack = def.specific_attack,
friendly_fire = def.friendly_fire,
runaway_from = def.runaway_from,

View File

@ -111,6 +111,7 @@ functions needed for the mob to work properly which contains the following:
'attack_animals' when true mob will attack animals.
'attack_npcs' when true mob will attack npcs within range.
'attack_players' when true mob will attack players nearby.
'attack_ignore' string or table of mob names not to attack.
'owner_loyal' when true non-docile tamed mobs attack anything player
punches when nearby.
'group_attack' when true has same mob type grouping together to attack