public void SendResults(ArenaTeam winner) { foreach (var part in GetParticipants()) { BaseGump.SendGump(new DuelResultsGump(part.Key, this, winner)); } }
public void RecordRankings(ArenaDuel duel, ArenaTeam winners) { List <ArenaStats> rankings; rankings = duel.BattleMode == BattleMode.Team ? TeamRankings : SurvivalRankings; foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in duel.GetParticipants()) { PlayerMobile pm = part.Key; ArenaStats stats = rankings.FirstOrDefault(r => r.Owner == pm); if (stats == null) { stats = new ArenaStats(pm); rankings.Add(stats); } ArenaTeam team = duel.GetTeam(pm); if (team != winners) { stats.Ranking -= 33; } else { stats.Ranking += 33; } } rankings.Sort(); }
public bool IsFriendly(Mobile one, Mobile two) { if (InPreFight) { return(false); } if (one is BaseCreature) { one = ((BaseCreature)one).GetMaster(); } if (two is BaseCreature) { two = ((BaseCreature)two).GetMaster(); } PlayerMobile pm1 = one as PlayerMobile; PlayerMobile pm2 = two as PlayerMobile; if (pm1 != null && pm2 != null) { ArenaTeam team1 = GetTeam(pm1); ArenaTeam team2 = GetTeam(pm2); return(team1 != null && team2 != null && team1 == team2); } return(false); }
public bool IsEnemy(Mobile one, Mobile two) { if (InPreFight) { return(false); } if (one is BaseCreature creature) { one = creature.GetMaster(); } if (two is BaseCreature baseCreature) { two = baseCreature.GetMaster(); } if (one is PlayerMobile pm1 && two is PlayerMobile pm2) { ArenaTeam team1 = GetTeam(pm1); ArenaTeam team2 = GetTeam(pm2); return(team1 != null && team2 != null && team1 != team2); } return(false); }
public void SendResults(ArenaTeam winner) { foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in GetParticipants()) { BaseGump.SendGump(new DuelResultsGump(part.Key, this, winner)); } }
public void RemovePlayer(PlayerMobile pm, bool ban = false) { ArenaTeam team = GetTeam(pm); if (team != null) { team.RemoveParticipant(pm); if (Teams[1] != team && team.Unoccupied) { Teams.Remove(team); } if (ban) { Banned.Add(pm); PVPArenaSystem.SendMessage(Host, 1115951); // You have banned the specified participant. PVPArenaSystem.SendParticipantMessage(this, 1115951); // You have been banned from the session by the host player. } else { PVPArenaSystem.SendMessage(pm, 1115948); // One of the participants has left your duel session. PVPArenaSystem.SendParticipantMessage(this, 1115948); // One of the participants has left your duel session. } PendingDuelGump.RefreshAll(this); } }
public void HandleDeath(Mobile victim) { Mobile killer = victim.LastKiller; if (killer is BaseCreature creature) { killer = creature.GetMaster(); } if (victim is PlayerMobile mobile) { if (killer != null) { KillRecord[mobile.Name] = killer.Name; } if (killer is PlayerMobile playerMobile && killer != victim) // if not ranked, does it keep track of this? { PlayerStatsEntry victimEntry = GetStats(mobile); PlayerStatsEntry killerEntry = GetStats(playerMobile); if (victimEntry != null) { victimEntry.Deaths++; victimEntry.HandleDeath(playerMobile, true); } if (killerEntry != null) { killerEntry.Kills++; killerEntry.HandleDeath(mobile, false); } } List <ArenaTeam> stillAlive = new List <ArenaTeam>(); for (var index = 0; index < Teams.Count; index++) { ArenaTeam team = Teams[index]; if (CheckTeamAlive(mobile, team)) { stillAlive.Add(team); } } if (stillAlive.Count == 1) { Timer.DelayCall(TimeSpan.FromSeconds(5), EndDuel, stillAlive[0]); } ColUtility.Free(stillAlive); } }
public void RemovePlayers(ArenaTeam winners) { foreach (var part in GetParticipants(true)) { Arena.RemovePlayer(part.Key, winners != null && winners.Contains(part.Key)); PVPArenaSystem.Instance.CheckTitle(part.Key); } PVPArenaSystem.SendParticipantMessage(this, 1115973); // Thank you for your participation! Please return to the arena stone for additional dueling opportunities! Arena.OnDuelEnd(this); Closeout(); }
public bool CheckTeamAlive(PlayerMobile justDied, ArenaTeam team) { PlayerMobile first = null; foreach (var p in team.Players.Keys) { if (p != justDied && p.Alive) { first = p; break; } } return(first != null); }
public void EndDuel(ArenaTeam winner) { Timer.DelayCall(KickTime, RemovePlayers, winner); Complete = true; SendResults(winner); if (winner != null) { foreach (PlayerMobile pm in winner.Players.Keys) { if (Pot > 0) { Banker.Deposit(pm, Pot / winner.Count, true); } PVPArenaSystem.SendMessage(pm, 1115975); // Congratulations! You have won the duel! Timer.DelayCall(TimeSpan.FromSeconds(1), player => { DoWinEffects(player); }, pm); } } foreach (ArenaTeam team in Teams) { if (team != winner) { foreach (PlayerMobile pm in team.Players.Keys) { PVPArenaSystem.SendMessage(pm, team.Count == 1 ? 1116489 : 1116488); // You have lost the duel... : Your team has lost the duel... } } } RecordStats(winner); if (Ranked) { Arena.RecordRankings(this, winner); } PVPArenaSystem.SendParticipantMessage(this, 1115965); // All participants will be ejected from this arena in 40 seconds. }
private List <ArenaTeam> GetTeamsPresent() { List <ArenaTeam> present = new List <ArenaTeam>(); foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in GetParticipants(true)) { ArenaTeam team = GetTeam(part.Key); if (!present.Contains(team)) { present.Add(team); } } return(present); }
public void RecordStats(ArenaTeam winner) { foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> kvp in GetParticipants(true)) { PlayerStatsEntry stats = kvp.Value; ArenaTeam team = null; for (var index = 0; index < Teams.Count; index++) { var t = Teams[index]; if (t.Contains(kvp.Key)) { team = t; break; } } if (winner == null) { switch (BattleMode) { case BattleMode.Survival: stats.SurvivalDraws++; break; case BattleMode.Team: stats.TeamDraws++; break; } } else if (team == winner) { switch (BattleMode) { case BattleMode.Survival: stats.SurvivalWins++; break; case BattleMode.Team: stats.TeamWins++; break; } } else { switch (BattleMode) { case BattleMode.Survival: stats.SurvivalLosses++; break; case BattleMode.Team: stats.TeamLosses++; break; } } } }
public void RecordRankings(ArenaDuel duel, ArenaTeam winners) { List <ArenaStats> rankings; rankings = duel.BattleMode == BattleMode.Team ? TeamRankings : SurvivalRankings; foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in duel.GetParticipants()) { PlayerMobile pm = part.Key; ArenaStats stats = null; for (var index = 0; index < rankings.Count; index++) { var r = rankings[index]; if (r.Owner == pm) { stats = r; break; } } if (stats == null) { stats = new ArenaStats(pm); rankings.Add(stats); } ArenaTeam team = duel.GetTeam(pm); if (team != winners) { stats.Ranking -= 33; } else { stats.Ranking += 33; } } rankings.Sort(); }
public IEnumerable <KeyValuePair <PlayerMobile, PlayerStatsEntry> > GetParticipants(bool inArena = false) { if (Teams == null || Teams.Count == 0) { yield break; } for (var index = 0; index < Teams.Count; index++) { ArenaTeam team = Teams[index]; foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> player in team.Players) { if (!inArena || InArena(player.Key)) { yield return(player); } } } }
public void RecordRankings(ArenaDuel duel, ArenaTeam winners) { List <ArenaStats> rankings; if (duel.BattleMode == BattleMode.Team) { rankings = TeamRankings; } else { rankings = SurvivalRankings; } foreach (var part in duel.GetParticipants()) { var pm = part.Key; ArenaStats stats = rankings.FirstOrDefault(r => r.Owner == pm); if (stats == null) { stats = new ArenaStats(pm); rankings.Add(stats); } var team = duel.GetTeam(pm); if (team != winners) { stats.Ranking -= 33; } else { stats.Ranking += 33; } } rankings.Sort(); }
public void MoveToArena(PlayerMobile pm) { Map map = Arena.Definition.Map; Rectangle2D rec = _StartPoints[pm]; Point3D p = map.GetRandomSpawnPoint(rec); BaseCreature.TeleportPets(pm, p, map); pm.MoveToWorld(p, Arena.Definition.Map); if (pm.Spell is Spell spell) { spell.Disturb(DisturbType.Hurt); } Targeting.Target.Cancel(pm); bool allin = true; for (var index = 0; index < Teams.Count; index++) { ArenaTeam team = Teams[index]; foreach (PlayerMobile player in team.Players.Keys) { if (!InArena(player)) { allin = false; break; } } } if (allin) { Timer.DelayCall(TimeSpan.FromSeconds(3), BeginDuel); } }
public void RecordStats(ArenaTeam winner) { foreach (var kvp in GetParticipants(true)) { var team = Teams.FirstOrDefault(t => t.Contains(kvp.Key)); var stats = kvp.Value; if (winner == null) { switch (BattleMode) { case BattleMode.Survival: stats.SurvivalDraws++; break; case BattleMode.Team: stats.TeamDraws++; break; } } else if (team == winner) { switch (BattleMode) { case BattleMode.Survival: stats.SurvivalWins++; break; case BattleMode.Team: stats.TeamWins++; break; } } else { switch (BattleMode) { case BattleMode.Survival: stats.SurvivalLosses++; break; case BattleMode.Team: stats.TeamLosses++; break; } } } }
public bool CheckTeamAlive(PlayerMobile justDied, ArenaTeam team) { return(team.Players.Keys.FirstOrDefault(p => p != justDied && p.Alive) != null); }