Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -4314,6 +4314,10 @@ if (msg.fromStatusEffect) return; + const cmpUnitAI = Engine.QueryInterface(msg.attacker, IID_UnitAI); + if (cmpUnitAI && cmpUnitAI.IsDangerousAnimal()) + this.CallPlayerOwnedEntitiesFunctionInRange("RespondToTargetedEntities", [[msg.attacker], true], 60); + this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg }); }; @@ -5039,7 +5043,7 @@ * given a list of entities that match our stance's target criteria. * Returns true if it responded. */ -UnitAI.prototype.RespondToTargetedEntities = function(ents) +UnitAI.prototype.RespondToTargetedEntities = function(ents, dangerousAnimal = false) { if (!ents.length) return false; @@ -5058,6 +5062,8 @@ if (this.GetStance().respondFlee) { + if (dangerousAnimal) + return this.AttackVisibleEntity(ents); if (this.order && this.order.type == "Flee") this.orderQueue.shift(); this.PushOrderFront("Flee", { "target": ents[0], "force": false }); @@ -6426,7 +6432,7 @@ return true; let cmpUnitAI = Engine.QueryInterface(e, IID_UnitAI); - return cmpUnitAI && (!cmpUnitAI.IsAnimal() || cmpUnitAI.IsDangerousAnimal()); + return cmpUnitAI && !cmpUnitAI.IsAnimal(); }; let entsByPreferences = {};