non-passive mobs fight back when attacked (thx fluxionary)
* backported commitc48821df03
* the check for player must be already also in the name hitter * and yeah thanks to fluxionary cos we kjnow tenplus1 is not narcissist, petty that-s why the commit is only do by itselft and not by merge * includes commit7044e20382
cos i allows alrady made commits from others
This commit is contained in:
parent
a0e0719dfe
commit
b4a943690c
29
api.lua
29
api.lua
@ -34,7 +34,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230809",
|
version = "20230816",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
@ -3124,15 +3124,16 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||||||
self.following = nil
|
self.following = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = hitter:get_player_name() or ""
|
local hitter_name = ""
|
||||||
|
if hitter then if is_player(hitter) then hitter_name = hitter:get_player_name() end end
|
||||||
|
|
||||||
-- attack puncher and call other mobs for help
|
-- attack puncher and call other mobs for help
|
||||||
if self.passive == false
|
if self.passive == false
|
||||||
and self.state ~= "flop"
|
and self.state ~= "flop"
|
||||||
and self.child == false
|
and self.child == false
|
||||||
and self.attack_players == true
|
and self.attack_players == true
|
||||||
and hitter:get_player_name() ~= self.owner
|
and not (is_player(hitter) and hitter_name == self.owner)
|
||||||
and not is_invisible(self, name)
|
and not is_invisible(self, hitter_name)
|
||||||
and self.object ~= hitter then
|
and self.object ~= hitter then
|
||||||
|
|
||||||
-- attack whoever punched mob
|
-- attack whoever punched mob
|
||||||
@ -3141,25 +3142,25 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||||||
|
|
||||||
-- alert others to the attack
|
-- alert others to the attack
|
||||||
local objs = minetest.get_objects_inside_radius(hitter:get_pos(), self.view_range)
|
local objs = minetest.get_objects_inside_radius(hitter:get_pos(), self.view_range)
|
||||||
local obj
|
local ent
|
||||||
|
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
|
|
||||||
obj = objs[n]:get_luaentity()
|
ent = objs[n] and objs[n]:get_luaentity()
|
||||||
|
|
||||||
if obj and obj._cmi_is_mob then
|
if ent and ent._cmi_is_mob then
|
||||||
|
|
||||||
-- only alert members of same mob and assigned helper
|
-- only alert members of same mob and assigned helper
|
||||||
if obj.group_attack == true
|
if ent.group_attack == true
|
||||||
and obj.state ~= "attack"
|
and ent.state ~= "attack"
|
||||||
and obj.owner ~= name
|
and not (is_player(hitter) and ent.owner == hitter_name)
|
||||||
and (obj.name == self.name or obj.name == self.group_helper) then
|
and (ent.name == self.name or ent.name == self.group_helper) then
|
||||||
obj:do_attack(hitter)
|
ent:do_attack(hitter)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- have owned mobs attack player threat
|
-- have owned mobs attack player threat
|
||||||
if obj.owner == name and obj.owner_loyal then
|
if is_player(hitter) and ent.owner == hitter_name and ent.owner_loyal then
|
||||||
obj:do_attack(self.object)
|
ent:do_attack(self.object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user