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() { Mobile owner = m_Flag.RootParent as Mobile; CTFGame game = m_Flag.Game; TimeSpan left = MaxFlagHoldTime - (DateTime.Now - m_Start); if (left >= TimeSpan.FromSeconds(1.0)) { if (left > TimeSpan.FromMinutes(1.0)) { Interval = TimeSpan.FromSeconds(30.0); } else if (left > TimeSpan.FromSeconds(30.0)) { Interval = TimeSpan.FromSeconds(15.0); } else if (left >= TimeSpan.FromSeconds(10.0)) { Interval = TimeSpan.FromSeconds(5.0); } else { Interval = TimeSpan.FromSeconds(1.0); } if (owner != null) { owner.SendMessage("You must take the {0} flag to your flag in {1} seconds or be killed!", m_Flag.Team.Name, (int)left.TotalSeconds); } } else { if (owner != null) { owner.BoltEffect(0); owner.PlaySound(0xDC); //snake hiss owner.Kill(); } m_Flag.Game.AnnounceToPlayers("The {0} flag has been returned to base!", m_Flag.Team.Name); m_Flag.ReturnToHome(); Stop(); } }