/// <summary> /// calculate the aggro of this npc against another living /// </summary> /// <param name="target"></param> /// <returns></returns> public virtual int CalculateAggroLevelToTarget(GameLiving target) { if (GameServer.ServerRules.IsAllowedToAttack(Body, target, true) == false) return 0; // related to the pet owner if applicable if (target is GamePet) { GamePlayer thisLiving = (((GamePet)target).Brain as IControlledBrain).GetPlayerOwner(); if (thisLiving != null) if (thisLiving.IsObjectGreyCon(Body)) return 0; } if (target.IsObjectGreyCon(Body)) return 0; // only attack if green+ to target if (Body.Faction != null && target is GamePlayer) { GamePlayer player = (GamePlayer)target; AggroLevel = Body.Faction.GetAggroToFaction(player); } if (AggroLevel >= 100) return 100; return AggroLevel; }
/// <summary> /// calculate the aggro of this npc against another living /// </summary> /// <param name="target"></param> /// <returns></returns> public virtual int CalculateAggroLevelToTarget(GameLiving target) { if (GameServer.ServerRules.IsAllowedToAttack(Body, target, true) == false) return 0; // related to the pet owner if applicable if (target is GameNPC) { IControlledBrain brain = ((GameNPC)target).Brain as IControlledBrain; if (brain != null) { GameLiving thisLiving = (((GameNPC)target).Brain as IControlledBrain).GetLivingOwner(); if (thisLiving != null) { if (thisLiving.IsObjectGreyCon(Body)) return 0; } } } if (target.IsObjectGreyCon(Body)) return 0; // only attack if green+ to target if (Body.Faction != null && target is GamePlayer) { GamePlayer player = (GamePlayer)target; AggroLevel = Body.Faction.GetAggroToFaction(player); } else if (Body.Faction != null && target is GameNPC) { GameNPC npc = (GameNPC)target; if (npc.Faction != null) { if (npc.Brain is IControlledBrain && (npc.Brain as IControlledBrain).GetPlayerOwner() != null) { GamePlayer factionChecker = (npc.Brain as IControlledBrain).GetPlayerOwner(); AggroLevel = Body.Faction.GetAggroToFaction(factionChecker); } else { if (Body.Faction.EnemyFactions.Contains(npc.Faction)) AggroLevel = 100; } } } //we put this here to prevent aggroing non-factions npcs if (target.Realm == eRealm.None && target is GameNPC) return 0; if (AggroLevel >= 100) return 100; return AggroLevel; }