/// <summary> /// This is the function that starts the game. /// </summary> /// <param name="lenght">Lenght of the game.</param> /// <param name="draw">If this is a draw game.</param> public static void StartGame(TimeSpan lenght, bool draw) { if( draw ) { CTFMessage( string.Format( "A Draw! Game will continue for {0}", MiscUtility.FormatTimeSpan( lenght ) ) ); } else { if (Spawn != null) Spawn.StartTimer(); Teams = Stone.Teams; if (Teams == 0) { int number = PlayerJoinList.Count; if ( number < 20 ) // Silver edit, old: (number < 16) || (number == 18) Teams = 2; else Teams = 4; } Item wall; if (Teams == 3) { wall = new Item(578); wall.Hue = 1150; wall.Movable = false; wall.MoveToWorld(new Point3D(5943, 451, 22), Map.Felucca); walls[0] = wall; wall = new Item(578); wall.Hue = 1150; wall.Movable = false; wall.MoveToWorld(new Point3D(5943, 452, 22), Map.Felucca); walls[1] = wall; } else if (Teams == 2) { wall = new Item(578); wall.Hue = 1150; wall.Movable = false; wall.MoveToWorld(new Point3D(5943, 451, 22), Map.Felucca); walls[0] = wall; wall = new Item(578); wall.Hue = 1150; wall.Movable = false; wall.MoveToWorld(new Point3D(5943, 452, 22), Map.Felucca); walls[1] = wall; wall = new Item(577); wall.Hue = 33; wall.Movable = false; wall.MoveToWorld(new Point3D(5955, 455, 22), Map.Felucca); walls[2] = wall; wall = new Item(577); wall.Hue = 33; wall.Movable = false; wall.MoveToWorld(new Point3D(5956, 455, 22), Map.Felucca); walls[3] = wall; } for (int i = 0; i < Teams; i++) GameData.TeamList.Add(new CTFTeamGameData(TeamArray[i])); List<CTFPlayerData> playerlist = new List<CTFPlayerData>(); foreach (Mobile m in PlayerJoinList) { CTFPlayerData pd = CTFData.GetPlayerData(m); if (pd != null) playerlist.Add(pd); else { pd = new CTFPlayerData(m); CTFData.PlayerDictionary[m] = pd; CTFData.PlayerList.Add(pd); playerlist.Add(pd); } } playerlist.Sort(); // Selection System by Silver int idx = 0; int max = playerlist.Count; if( Stone.CTFLeagueGame ) { int CTFLeagueTeam = -1; while( idx < max ) { CTFLeagueTeam = -1; CTFPlayerData pd = playerlist[idx]; if( pd.Mob.SolidHueOverride == 1109 ) CTFLeagueTeam = 0; else if( pd.Mob.SolidHueOverride == 1266 ) CTFLeagueTeam = 1; else LeaveGame( pd.Mob ); if( CTFLeagueTeam != -1 ) { CTFPlayerGameData pgd = new CTFPlayerGameData(pd.Mob, TeamArray[CTFLeagueTeam]); GameData.PlayerDictionary[pd.Mob] = pgd; GameData.PlayerList.Add(pgd); GameData.TeamList[CTFLeagueTeam].PlayerList.Add(pgd); ArmPlayer(pgd); pd.Mob.SendGump(new CTFRewardGump(pd.Mob, 0)); } pd.Mob.SolidHueOverride = -1; idx++; } } else { int startTeam = Utility.Random(Teams); bool revert = false; while( idx < max ) { for( int team = 0; team < Teams && idx < max; team++ ) { CTFPlayerData pd = playerlist[idx]; CTFPlayerGameData pgd = new CTFPlayerGameData(pd.Mob, TeamArray[((revert ? (Teams - team - 1) : team) + startTeam)%Teams]); GameData.PlayerDictionary[pd.Mob] = pgd; GameData.PlayerList.Add(pgd); GameData.TeamList[((revert ? (Teams - team - 1) : team) + startTeam)%Teams].PlayerList.Add(pgd); ArmPlayer(pgd); pd.Mob.SendGump(new CTFRewardGump(pd.Mob, 0)); idx++; } revert = !revert; } } PlayerJoinList.Clear(); ResetTeams(); CTFMessage( "The game has started." ); } // Set idle check 4 min after game starts NextIdleCheck = DateTime.Now + CTFGame.IdleTime; StartTime = DateTime.Now; CurLength = lenght; GameTimer = new CtfGameTimer(lenght, TimeSpan.FromMinutes(1.0)); GameTimer.Start(); }
/// <summary> /// This is the function gives weaponry to players. /// </summary> private static void ArmPlayer(CTFPlayerGameData pgd) { Mobile m = pgd.Mob; if (!m.Alive) m.Resurrect(); for (int i = m.Items.Count - 1; i >= 0; --i) { Item item = (Item)m.Items[i]; if (item.Layer == Layer.OuterTorso) { item.Delete(); break; } } List<Item> armthis = new List<Item>(); if(GiveRobe) armthis.Add(new CTFRobe(pgd.Team)); Item rankedCloth = null; CTFTeam team = pgd.Team; // 21 Ranks switch (CTFData.GetRank(m)) { default: case 0: rankedCloth = new JesterHat(team.Hue); break; case 1: rankedCloth = new TallStrawHat(team.Hue); break; case 2: rankedCloth = new FloppyHat(team.Hue); break; case 3: rankedCloth = new WideBrimHat(team.Hue); break; case 4: rankedCloth = new Cap(team.Hue); break; case 5: rankedCloth = new SkullCap(team.Hue); break; case 6: rankedCloth = new FlowerGarland(team.Hue); break; case 7: rankedCloth = new StrawHat(team.Hue); break; case 8: rankedCloth = new FeatheredHat(team.Hue); break; case 9: rankedCloth = new TricorneHat(team.Hue); break; case 10: rankedCloth = new TribalMask(team.Hue); break; case 11: rankedCloth = new HornedTribalMask(team.Hue); break; case 12: rankedCloth = new BearMask(team.Hue); break; case 13: rankedCloth = new DeerMask(team.Hue); break; case 14: rankedCloth = new OrcishKinMask(team.Hue); break; case 15: rankedCloth = new SavageMask(team.Hue); break; case 16: rankedCloth = new WizardsHat(team.Hue); break; case 17: rankedCloth = new Bandana(team.Hue); break; case 18: rankedCloth = new ClothNinjaHood(team.Hue); break; case 19: rankedCloth = new Kasa(team.Hue); break; case 20: rankedCloth = new BoneHelm(); rankedCloth.Hue = team.Hue; ((BaseArmor)rankedCloth).ArmorAttributes.MageArmor = 1; break; } if (rankedCloth != null) { rankedCloth.Movable = false; armthis.Add(rankedCloth); } //Alchemy removed by Blady /* if (m.Skills[SkillName.Alchemy].Value >= (m_MinSupplySkill + 15)) //80 Alchemy req - by Blady { for (int i = 0; i < 6; i++) //Amount reduced to 6 by Blady - used to be 10 { armthis.Add(new ExplosionPotion()); armthis.Add(new GreaterHealPotion()); armthis.Add(new GreaterCurePotion()); armthis.Add(new GreaterAgilityPotion()); armthis.Add(new RefreshPotion()); armthis.Add(new GreaterStrengthPotion()); } } */ if (m.Skills[SkillName.Chivalry].Value >= m_MinSupplySkill) { BookOfChivalry book = new BookOfChivalry(); book.Content = 1023;//all spells armthis.Add(book); } if (m.Skills[SkillName.Necromancy].Value >= m_MinSupplySkill) { NecromancerSpellbook book = new NecromancerSpellbook(); book.Content = 0x1FFFF; armthis.Add(book); } if (m.Skills[SkillName.Magery].Value >= m_MinSupplySkill) { GnarledStaff gs = new GnarledStaff(); gs.Attributes.SpellChanneling = 1; gs.WeaponAttributes.MageWeapon = 20; armthis.Add(gs); Spellbook book = new Spellbook(); book.Content = ulong.MaxValue; armthis.Add(book); } if (m.Skills[SkillName.Healing].Value >= m_MinSupplySkill) armthis.Add(new Bandage(1000)); if (m.Skills[SkillName.Fencing].Value >= m_MinSupplySkill) { Spear sp = new Spear(); sp.Attributes.SpellChanneling = 1; armthis.Add(sp); ShortSpear ssp = new ShortSpear(); ssp.Attributes.SpellChanneling = 1; armthis.Add(ssp); WarFork wf = new WarFork(); wf.Attributes.SpellChanneling = 1; armthis.Add(wf); Kryss k = new Kryss(); k.Attributes.SpellChanneling = 1; armthis.Add(k); } if (m.Skills[SkillName.Swords].Value >= m_MinSupplySkill) { if (m.Skills[SkillName.Lumberjacking].Value >= m_MinSupplySkill) { ExecutionersAxe ea = new ExecutionersAxe(); ea.Attributes.SpellChanneling = 1; armthis.Add(ea); } Katana k = new Katana(); k.Attributes.SpellChanneling = 1; armthis.Add(k); Longsword ls = new Longsword(); ls.Attributes.SpellChanneling = 1; armthis.Add(ls); Cleaver c = new Cleaver(); c.Attributes.SpellChanneling = 1; armthis.Add(c); BoneHarvester bh = new BoneHarvester(); bh.Attributes.SpellChanneling = 1; armthis.Add(bh); } if (m.Skills[SkillName.Macing].Value >= m_MinSupplySkill) { WarAxe wa = new WarAxe(); wa.Attributes.SpellChanneling = 1; armthis.Add(wa); HammerPick hp = new HammerPick(); hp.Attributes.SpellChanneling = 1; armthis.Add(hp); QuarterStaff qs = new QuarterStaff(); qs.Attributes.SpellChanneling = 1; armthis.Add(qs); } if (m.Skills[SkillName.Archery].Value >= m_MinSupplySkill) { Bow b = new Bow(); b.Attributes.SpellChanneling = 1; armthis.Add(b); Crossbow xb = new Crossbow(); xb.Attributes.SpellChanneling = 1; armthis.Add(xb); CompositeBow cb = new CompositeBow(); cb.Attributes.SpellChanneling = 1; armthis.Add(cb); armthis.Add(new Arrow(150)); armthis.Add(new Bolt(150)); } if (m.Skills[SkillName.Poisoning].Value >= m_MinSupplySkill) { for (int i = 0; i < 2; i++) armthis.Add(new GreaterPoisonPotion()); } if (m.Skills[SkillName.Parry].Value >= m_MinSupplySkill) { MetalKiteShield ks = new MetalKiteShield(); ks.Attributes.SpellChanneling = 1; armthis.Add(ks); } SunnySystem.ArmPlayer(m, armthis); }
/// <summary> /// Ressurects player and moves him to his base. /// </summary> public static void ResurrectPlayer(CTFPlayerGameData pgd) { if (pgd != null && pgd.InGame) { Mobile m = pgd.Mob; CTFFlag flag = CTFGame.GetTeamFlag(pgd.Team); if (flag != null) { m.Resurrect(); m.Hits = m.HitsMax; m.Mana = m.ManaMax; m.Stam = m.StamMax; ReArmPlayer(m); m.LogoutLocation = flag.FlagHome; m.MoveToWorld(flag.PlayerSpawn, flag.FlagHomeMap); } } }