public static bool IsAllied(Mobile a, Mobile b) { var guildA = a.Guild as Guild; var guildB = b.Guild as Guild; if (guildA != null && guildB != null && (guildA == guildB || guildA.IsAlly(guildB))) { return(true); } if (TempCombatants == null) { return(false); } var tempA = TempCombatants.FirstOrDefault(c => c.From == a); var tempB = TempCombatants.FirstOrDefault(c => c.From == b); if (tempA != null && (tempA.Friendly == b || (tempA.FriendlyGuild != null && tempA.FriendlyGuild == guildB))) { return(true); } if (tempB != null && (tempB.Friendly == a || (tempB.FriendlyGuild != null && tempB.FriendlyGuild == guildA))) { return(true); } return(false); }
public static void OnMapChange(PlayerMobile pm) { if (TempCombatants == null || pm.Map == Map.Internal || pm.Map == null) { return; } TempCombatants.Where(t => t.From == pm).IterateReverse(RemoveTempCombatant); }
public static void CheckTempCombatants() { if (TempCombatants == null) { StopTempCombatantTimer(); } TempCombatants.IterateReverse(c => { if (c.Expired) { TempCombatants.Remove(c); } }); }
public static void RemoveTempCombatant(TemporaryCombatant tempCombatant) { if (TempCombatants == null) { return; } TempCombatants.Remove(tempCombatant); tempCombatant.From.Delta(MobileDelta.Noto); tempCombatant.From.ProcessDelta(); if (TempCombatants.Count == 0) { TempCombatants = null; StopTempCombatantTimer(); } }
public static TemporaryCombatant GetTempCombatant(Mobile from, Mobile to) { foreach (var combatant in TempCombatants.Where(c => c.From == from)) { if (combatant.Friendly == null && to == null) { return(combatant); } if (combatant.Friendly == to || (combatant.FriendlyGuild != null && combatant.FriendlyGuild == from.Guild as Guild)) { return(combatant); } } return(null); }
public static void AddTempParticipant(Mobile m, Mobile friendlyTo) { if (TempCombatants == null) { TempCombatants = new List <TemporaryCombatant>(); AddTempCombatantTimer(); } var combatant = GetTempCombatant(m, friendlyTo); if (combatant == null) { combatant = new TemporaryCombatant(m, friendlyTo); } else { combatant.Reset(); } TempCombatants.Add(combatant); m.Delta(MobileDelta.Noto); m.ProcessDelta(); }
public static bool IsVvVCombatant(Mobile mobile) { CheckTempCombatants(); return(IsVvV(mobile) || (TempCombatants != null && TempCombatants.Any(c => c.From == mobile))); }