public void ResetGame() { AnnounceToPlayers("The game has started."); AnnounceToPlayers("Game will end when one of the teams reaches {0} Score.", MaxScore); AnnounceToPlayers("Team gets 15 Score for each flag captured and 1 point for each kill."); for (int i = 0; i < Teams.Count; i++) { CTFTeam team = (CTFTeam)Teams[i]; team.Score = 0; if (team.Flag != null) { team.Flag.ReturnToHome(); Item flagItem = (Item)team.Flag; flagItem.EventItem = true; } else { CTFFlag flag = new CTFFlag(this, team); flag.EventItem = true; } } }
public override void OnPlayerDeath(Mobile m) { base.OnPlayerDeath(m); CTFTeam team = GetTeam(m) as CTFTeam; if (team == null) { return; } RemoveTimer(m); Timer t = new DeathTimer(m, team, this, DeathDelay); m_Table[m] = t; t.Start(); Mobile killer = m.LastKiller; CTFTeam killerteam = GetTeam(killer) as CTFTeam; if (killerteam != null && team != null && ((CTFGame)killerteam.Game).DeathPoint && killerteam != team) { ++killerteam.Score; AddPlayerScore(killer, 1); SendGMGump(); SendPlayerGumps(); } }
protected override void OnTarget(Mobile from, object target) { if (m_Flag.Game == null || !m_Flag.Game.Running) { return; } CTFTeam fteam = m_Flag.Game.GetTeam(from) as CTFTeam; if (target is Mobile) { Mobile targ = (Mobile)target; CTFTeam tteam = m_Flag.Game.GetTeam(targ) as CTFTeam; if (tteam == fteam && from != targ) { if (targ.Backpack != null) { targ.Backpack.DropItem(m_Flag); targ.SendMessage("{0} gave you the {1} flag!", from.Name, m_Flag.Team.Name); m_Flag.Game.AnnounceToPlayers("{0} passed the {1} flag to {2}!", from.Name, m_Flag.Team.Name, targ.Name); } } else { from.SendMessage("You cannot give the flag to them!"); } } else if (target is CTFFlag) { CTFFlag flag = target as CTFFlag; if (flag.Team == fteam) { if (flag.Home) { from.SendMessage("You captured the {0} flag!", m_Flag.Team.Name); flag.Game.AnnounceToPlayers("{0} ({1}) captured the {2} flag!", from.Name, fteam.Name, m_Flag.Team.Name); m_Flag.ReturnToHome(); fteam.Score += 15; m_Flag.Game.AddPlayerScore(from, 15); m_Flag.Game.AnnounceScore(); m_Flag.Game.SendGMGump(); m_Flag.Game.SendPlayerGumps(); } else { from.SendMessage("Your flag must be at home to capture!"); } } else { from.SendMessage("You can only capture for your own team!"); } } }
protected override void OnTick() { int sm = -1, ns = -1; int[] amc = new int[m_Game.Teams.Count]; for (int i = 0; i < m_Game.Teams.Count; i++) { amc[i] = ((CTFTeam)m_Game.Teams[i]).ActiveMemberCount; if (sm == -1 || amc[i] < amc[sm]) { ns = sm; sm = i; } else if (amc[i] < amc[ns]) { ns = i; } } for (int i = 0; i < m_List.Count; i++) { Mobile m = (Mobile)m_List[i]; m.Frozen = false; if (m_Game.GetTeam(m) == null) { int t; if (m.NetState == null) { t = Utility.Random(amc.Length); } else { if (amc[sm] >= amc[ns]) { t = Utility.Random(amc.Length); } else { t = sm; } amc[t]++; } CTFTeam team = (CTFTeam)m_Game.Teams[t]; m_Game.SwitchTeam(m, team); m.SendMessage("You have joined {0}!", team.Name); } } m_Game.ResetGame(); }
public override bool OnMoveOver(Mobile m) { if (!m.Alive) { return(true); } if (m_Team != null && m_Game != null) { if (!m_Game.Running) { m.SendMessage("The game is currently closed."); return(true); } CTFTeam team = m_Game.GetTeam(m) as CTFTeam; if (team != null) { if (team != m_Team && !m_Home) { if (m.Backpack != null) { m.RevealingAction(); m.Backpack.DropItem(this); m.SendMessage("You got the enemy flag!"); //BeginCapture(); m_Game.AnnounceToPlayers("{0} ({1}) got the {2} flag!", m.Name, team.Name, m_Team.Name); } else { m.SendMessage("You have no backpack to carry that flag!"); } } else { if (!m_Home) { m_Game.AnnounceToPlayers("{0} has returned the {1} flag!", m.Name, m_Team.Name); ReturnToHome(); } } } else { m.SendMessage("You are not part of the game."); } } return(base.OnMoveOver(m)); }
public DeathTimer(Mobile m, CTFTeam t, CTFGame g, TimeSpan DeathDelay) : base(TimeSpan.Zero, TimeSpan.FromMilliseconds(250)) { m_Mob = m; m_Team = t; m_Game = g; m_Res = DateTime.Now + DeathDelay; if (m is PlayerMobile) { m_GumpItem = new CustomGumpItem("Resurrect in", DeathDelay.Hours + ":" + DeathDelay.Minutes + ":" + DeathDelay.Seconds, m_Game, (PlayerMobile)m); GameInfoGump.AddCustomMessage((PlayerMobile)m, m_GumpItem); } Priority = TimerPriority.TwoFiftyMS; }
public CTFFlag(CTFGame game, CTFTeam team) : base(0x1591) { Movable = false; Weight = 1.0; m_Home = true; m_Game = game; m_Team = team; team.Flag = this; Hue = team.Hue; ReturnToHome(); game.EndGameEvent += OnEndGame; }
public CTFFlag(CTFGame game, CTFTeam team) : base( 0x1591 ) { Movable = false; Weight = 1.0; m_Home = true; m_Game = game; m_Team = team; team.Flag = this; Hue = team.Hue; ReturnToHome(); game.EndGameEvent += OnEndGame; }
public override void EndGame() { if (!Running) { return; } base.EndGame(); foreach (BaseGameTeam t in Teams) { CTFTeam team = (CTFTeam)t; if (team.Flag != null) { team.Flag.ReturnToHome(); Item flagItem = (Item)team.Flag; flagItem.EventItem = false; } } }
public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) { if (m_Game == null || m_Team == null) { from.SendGump(new PropertiesGump(from, this)); } else { from.SendGump(new PropertiesGump(from, m_Team)); } } else if (m_Team != null && m_Game != null) { if (!m_Game.Running) { from.SendMessage("The game is currently closed."); return; } CTFTeam team = m_Game.GetTeam(from) as CTFTeam; if (team != null) { if (!from.InLOS(GetWorldLocation())) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } else if (from.GetDistanceToSqrt(GetWorldLocation()) > 3) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } if (RootParent is Mobile) { if (RootParent == from) { from.Target = new CaptureTarget(this); from.SendMessage("Target your flag to capture, or target a team-mate to pass the flag."); //"What do you wish to do with the flag?" ); } } else { if (team != m_Team) { if (!m_Home) { from.SendAsciiMessage("Simply step on the flag to grab it"); } else { if (from.Backpack != null) { from.RevealingAction(); from.Backpack.DropItem(this); from.SendMessage("You got the enemy flag!"); BeginCapture(); m_Game.AnnounceToPlayers("{0} ({1}) got the {2} flag!", from.Name, team.Name, m_Team.Name); } else { from.SendMessage("You have no backpack to carry that flag!"); } } } else if (!m_Home) { from.SendAsciiMessage("Simply step on the flag to return it"); } } } else { from.SendMessage("You are not part of the game."); } } }