Exemple #1
0
        public static void CreatureAggroEnter()
        {
            var entering = GetEnteringObject();
            var self     = GetAreaOfEffectCreator(OBJECT_SELF);

            if (!GetIsEnemy(entering, self))
            {
                var attackTarget = Enmity.GetHighestEnmityTarget(entering);
                // Non-enemy entered aggro range. If they're the same faction and fighting someone, help them out!
                if (GetFactionEqual(entering, self) &&
                    GetIsEnemy(attackTarget, self))
                {
                    Enmity.ModifyEnmity(attackTarget, self, 1);
                }

                return;
            }

            Enmity.ModifyEnmity(entering, self, 1);

            // All allies within 5m should also aggro the player if they're not already in combat.
            if (_creatureAllies.TryGetValue(self, out var allies))
            {
                foreach (var ally in allies)
                {
                    if (!GetIsEnemy(entering, ally))
                    {
                        continue;
                    }
                    if (GetDistanceBetween(self, ally) > 5f)
                    {
                        continue;
                    }

                    Enmity.ModifyEnmity(entering, ally, 1);
                }
            }
        }