public override void AddGumpLayout() { AddPage(0); AddImage(0, 0, 30566); if (DateTime.UtcNow >= Battle.NextSigilSpawn && Battle.Sigil != null && !Battle.Sigil.Deleted) { AddImage(200, 300, 30583); } List <BattleTeam> teams = new List <BattleTeam>(Battle.Teams); teams.Sort(); double offset = 216 / VvVBattle.ScoreToWin; for (int i = 0; i < teams.Count; i++) { BattleTeam team = teams[i]; if (team.Guild != null) { AddHtml(87, 115 + (31 * i), 50, 20, string.Format("<basefont color=#FFFFFF>{0}", team.Guild.Abbreviation), false, false); } AddBackground(145, 120 + (31 * i), (int)Math.Min(216, (team.Score * offset)), 12, 30584); if (i == 2) // stupid gump only allows 3 to be shown { break; } } int count = Battle.Messages.Count - 1; int y = 206; for (int i = count; i >= 0; i--) { if (i <= count - 3) { break; } AddHtml(98, y, 250, 16, string.Format("<basefont color=#80BFFF>{0}", Battle.Messages[i]), false, false); y += 16; } if (User.Guild is Guild guild) { BattleTeam t = Battle.GetTeam(guild); AddHtml(87, 268, 50, 20, string.Format("<basefont color=#FFFFFF>{0}", guild.Abbreviation), false, false); AddBackground(145, 271, (int)Math.Min(216, (t.Score * offset)), 12, 30584); } TimeSpan left = Battle.StartTime + TimeSpan.FromMinutes(VvVBattle.Duration) - DateTime.UtcNow; AddHtml(210, 21, 100, 20, "<basefont color=#FF0000>" + string.Format("{0:mm\\:ss}", left), false, false); }
public void CheckParticipation() { if (Region == null) { return; } BattleTeam team = null; UnContested = true; bool checkAggression = ViceVsVirtueSystem.EnhancedRules && NextCombatHeatCycle < DateTime.UtcNow; foreach (PlayerMobile pm in Region.GetEnumeratedMobiles().OfType <PlayerMobile>()) { bool vvv = ViceVsVirtueSystem.IsVvV(pm); if (!vvv && !Warned.Contains(pm) && pm.AccessLevel == AccessLevel.Player) { pm.SendGump(new BattleWarningGump(pm)); Warned.Add(pm); } else if (vvv && pm.Alive && !pm.Hidden && BaseBoat.FindBoatAt(pm.Location, pm.Map) == null && BaseHouse.FindHouseAt(pm) == null) { Guild g = pm.Guild as Guild; if (g != null) { BattleTeam t = GetTeam(g); if (team == null) { team = t; } else if (t != team && UnContested) { UnContested = false; } } } if (checkAggression && (vvv || ViceVsVirtueSystem.IsVvVCombatant(pm))) { AddAggression(pm); } } if (checkAggression) { CheckBattleAggression(); NextCombatHeatCycle = DateTime.UtcNow + TimeSpan.FromMinutes(1); } }
public BattleTeam GetTeam(Guild g) { BattleTeam team = Teams.FirstOrDefault(t => t.Guild != null && (t.Guild == g || t.Guild.IsAlly(g))); if (team != null) { return(team); } team = new BattleTeam(g); Teams.Add(team); return(team); }
public void CheckOccupation() { if (!OnGoing) { return; } if (Teams.Count == 1) { BattleTeam team = Teams[0]; team.Score += (int)OccupyPoints; UpdateAllGumps(); CheckScore(); if (OnGoing && NextAnnouncement < DateTime.UtcNow) { if (ViceVsVirtueSystem.EnhancedRules) { System.SendVvVMessage(String.Format("{0} is occupying {1}!", team.Guild.Name, City == VvVCity.SkaraBrae ? "Skara Brae" : City.ToString())); } else { System.SendVvVMessage(1154957, team.Guild.Name); // ~1_NAME~ is occupying the city! } NextAnnouncement = DateTime.UtcNow + TimeSpan.FromMinutes(Announcement); } } else // Is this a bug? Verified on EA this is how it behaves { if (NextAnnouncement < DateTime.UtcNow) { if (ViceVsVirtueSystem.EnhancedRules) { System.SendVvVMessage(1050039, String.Format("#{0}\tis unoccupied! Slay opposing forces to claim the city for your guild!", ViceVsVirtueSystem.GetCityLocalization(City).ToString())); } else { System.SendVvVMessage(1154958); // The City is unoccupied! Slay opposing forces to claim the city for your guild! } NextAnnouncement = DateTime.UtcNow + TimeSpan.FromMinutes(Announcement); } } }
public VvVPlayerBattleStats GetPlayerStats(PlayerMobile pm) { if (pm == null || pm.Guild == null) { return(null); } Guild g = pm.Guild as Guild; BattleTeam team = GetTeam(g); VvVPlayerBattleStats stats = team.PlayerStats.FirstOrDefault(s => s.Player == pm); if (stats == null) { stats = new VvVPlayerBattleStats(pm); team.PlayerStats.Add(stats); } return(stats); }
public void OccupyAltar(Guild g) { BattleTeam team = GetTeam(g); team.Score += (int)AltarPoints; team.Silver += AltarSilver + (OppositionCount(g) * 50); SendStatusMessage(String.Format("{0} claimed the altar!", g != null ? g.Abbreviation : "somebody")); foreach (PlayerMobile p in Region.GetEnumeratedMobiles().Where(player => player is PlayerMobile)) { if (p.QuestArrow != null) { p.QuestArrow = null; } } CheckScore(); NextAltarActivate = DateTime.UtcNow + TimeSpan.FromMinutes(2); }
public BattleStatsGump(PlayerMobile pm, VvVBattle battle) : base(50, 50) { Battle = battle; BattleTeam leader = battle.GetLeader(); Guild myGuild = pm.Guild as Guild; if (leader == null || leader.Guild == null || myGuild == null) { return; } AddBackground(0, 0, 500, 500, 9380); AddHtmlLocalized(0, 40, 500, 20, 1154645, "#1154945", Color16, false, false); // The Battle between Vice and Virtue has ended! AddHtml(40, 65, 420, 20, string.Format("<basefont color=#B22222>{0} [{1}] has won the battle!", leader.Guild.Name, leader.Guild.Abbreviation), false, false); int y = 90; if (leader.Guild.Alliance != null) { AddHtml(40, y, 420, 20, string.Format("<basefont color=#B22222>The {0} Alliance has won the battle!", leader.Guild.Alliance.Name), false, false); y += 25; } BattleTeam team = Battle.GetTeam(myGuild); //TODO: Are totals the PLAYERS OVERALL totals, or the guild/alliance totals for that battle??? Or that players totals for that battle /*silver += (int)ViceVsVirtueSystem.Instance.GetPoints(pm); * * VvVPlayerEntry entry = ViceVsVirtueSystem.Instance.GetPlayerEntry<VvVPlayerEntry>(pm); * * if (entry != null) * { * score = entry.Score; * }*/ AddHtmlLocalized(40, y, 420, 20, 1154947, team.Silver.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); // Total Silver Points: ~1_val~ y += 25; AddHtmlLocalized(40, y, 420, 20, 1154948, team.Score.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); // Total Score: ~1_val~ y += 25; AddHtmlLocalized(40, y, 420, 20, 1154949, team.Kills.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; AddHtmlLocalized(40, y, 420, 20, 1154950, team.Assists.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; AddHtmlLocalized(40, y, 420, 20, 1154951, team.Deaths.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; AddHtmlLocalized(40, y, 420, 20, 1154952, team.Stolen.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; AddHtmlLocalized(40, y, 420, 20, 1154953, team.ReturnedSigils.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; AddHtmlLocalized(40, y, 420, 20, 1154954, team.ViceReturned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; AddHtmlLocalized(40, y, 420, 20, 1154955, team.VirtueReturned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; AddHtmlLocalized(40, y, 420, 20, 1154956, team.Disarmed.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); y += 25; }
public void Update(VvVPlayerEntry victim, VvVPlayerEntry killer, UpdateType type) { if (killer == null || killer.Player == null || killer.Guild == null) { return; } VvVPlayerBattleStats killerStats = GetPlayerStats(killer.Player); VvVPlayerBattleStats victimStats = victim == null ? null : GetPlayerStats(victim.Player); BattleTeam killerTeam = GetTeam(killer.Guild); BattleTeam victimTeam = null; if (victim != null) { victimTeam = GetTeam(victim.Guild); } switch (type) { case UpdateType.Kill: if (killerStats != null) { killerStats.Kills++; } if (victimStats != null) { victimStats.Deaths++; } if (killerTeam != null) { killerTeam.Kills++; } if (victimTeam != null) { victimTeam.Deaths++; } if (victim != null && victim.Player != null) { if (!KillCooldown.ContainsKey(victim.Player) || KillCooldown[victim.Player] < DateTime.UtcNow) { if (killerTeam != null) { killerTeam.Score += (int)KillPoints; killerTeam.Silver += AwardSilver(KillSilver + (OppositionCount(killer.Guild) * 50)); } SendStatusMessage(String.Format("{0} has killed {1}!", killer.Player.Name, victim.Player.Name)); KillCooldown[victim.Player] = DateTime.UtcNow + TimeSpan.FromMinutes(KillCooldownDuration); } } break; case UpdateType.Assist: if (killerStats != null) { killerStats.Assists++; } if (killerTeam != null) { killerTeam.Assists++; } break; case UpdateType.Steal: if (killerStats != null) { killerStats.Stolen++; SendStatusMessage(String.Format("{0} has stolen the sigil!", killer.Player.Name)); } if (killerTeam != null) { killerTeam.Stolen++; } break; case UpdateType.TurnInVice: case UpdateType.TurnInVirtue: if (killerTeam != null) { killerTeam.Score += (int)TurnInPoints; killerTeam.Silver += AwardSilver(TurnInSilver + (OppositionCount(killer.Guild) * 50)); } if (killerStats != null && killerTeam != null) { if (type == UpdateType.TurnInVirtue) { killerStats.VirtueReturned++; killerTeam.VirtueReturned++; } else { killerStats.ViceReturned++; killerTeam.ViceReturned++; } } SendStatusMessage(String.Format("{0} has returned the sigil!", killer.Player.Name)); NextSigilSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(1); RemovePriests(); break; case UpdateType.Disarm: SendStatusMessage(String.Format("{0} has disarmed a trap!", killer.Player.Name)); if (killerStats != null) { killerStats.Disarmed++; } if (killerTeam != null) { killerTeam.Silver += AwardSilver(DisarmSilver + (OppositionCount(killer.Guild) * 50)); killerTeam.Disarmed++; } break; } CheckScore(); }
public void TallyStats() { BattleTeam leader = GetLeader(); List <Guild> added = new List <Guild>(); if (leader == null || leader.Guild == null) { return; } leader.Silver += AwardSilver(WinSilver + (OppositionCount(leader.Guild) * 50)); foreach (Mobile m in Region.GetEnumeratedMobiles()) { Guild g = m.Guild as Guild; if (g == null) { continue; } PlayerMobile pm = m as PlayerMobile; if (pm != null) { BattleTeam team = GetTeam(g); VvVPlayerBattleStats stats = GetPlayerStats(pm); VvVPlayerEntry entry = ViceVsVirtueSystem.Instance.GetPlayerEntry <VvVPlayerEntry>(pm); if (entry != null) { entry.Score += team.Score; entry.Points += team.Silver; entry.Kills += stats.Kills; entry.Deaths += stats.Deaths; entry.Assists += stats.Assists; entry.ReturnedSigils += stats.ReturnedSigils; entry.DisarmedTraps += stats.Disarmed; entry.StolenSigils += stats.Stolen; if (added.Contains(g)) { continue; } else { added.Add(g); } if (!ViceVsVirtueSystem.Instance.GuildStats.ContainsKey(g)) { ViceVsVirtueSystem.Instance.GuildStats[g] = new VvVGuildStats(g); } VvVGuildStats gstats = ViceVsVirtueSystem.Instance.GuildStats[g]; gstats.Kills += team.Kills; gstats.ReturnedSigils += team.ReturnedSigils; gstats.Score += team.Score; } } } ColUtility.Free(added); }
public VvVBattle(GenericReader reader, ViceVsVirtueSystem system) { int version = reader.ReadInt(); System = system; Altars = new List <VvVAltar>(); KillCooldown = new Dictionary <Mobile, DateTime>(); Messages = new List <string>(); Traps = new List <VvVTrap>(); Warned = new List <Mobile>(); Turrets = new List <CannonTurret>(); Teams = new List <BattleTeam>(); OnGoing = reader.ReadBool(); if (reader.ReadInt() == 0) { StartTime = reader.ReadDateTime(); CooldownEnds = reader.ReadDateTime(); LastOccupationCheck = reader.ReadDateTime(); NextSigilSpawn = reader.ReadDateTime(); NextAnnouncement = reader.ReadDateTime(); NextAltarActivate = reader.ReadDateTime(); City = (VvVCity)reader.ReadInt(); Sigil = reader.ReadItem() as VvVSigil; VicePriest = reader.ReadMobile() as VvVPriest; VirtuePriest = reader.ReadMobile() as VvVPriest; if (Sigil != null) { Sigil.Battle = this; } if (VicePriest != null) { VicePriest.Battle = this; } if (VirtuePriest != null) { VirtuePriest.Battle = this; } int count = reader.ReadInt(); for (int i = 0; i < count; i++) { VvVAltar altar = reader.ReadItem() as VvVAltar; if (altar != null) { altar.Battle = this; Altars.Add(altar); } } if (version == 1) { count = reader.ReadInt(); for (int i = 0; i < count; i++) { BattleTeam team = new BattleTeam(reader); Teams.Add(team); } } else { count = reader.ReadInt(); for (int i = 0; i < count; i++) { Guild g = reader.ReadGuild() as Guild; VvVGuildBattleStats stats = new VvVGuildBattleStats(reader, g); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { VvVTrap t = reader.ReadItem() as VvVTrap; if (t != null) { Traps.Add(t); } } Timer.DelayCall(TimeSpan.FromSeconds(10), () => { if (Region is GuardedRegion) { GuardedRegion.Disable((GuardedRegion)Region); } BeginTimer(); ActivateArrows(); }); } }