public CTFTeam RandomTeam() { CTFTeam lowest_count = null; CTFTeam test_team = null; if (m_Teams != null) { for (int i = 0; i < m_Teams.Count; i++) { test_team = (CTFTeam)m_Teams[i]; if (lowest_count == null || test_team.ActiveMemberCount <= lowest_count.ActiveMemberCount) { lowest_count = test_team; } } CTFTeam randomteam = (CTFTeam)m_Teams[Utility.Random(0, m_Teams.Count - 1)]; if (randomteam != null && randomteam.ActiveMemberCount <= lowest_count.ActiveMemberCount) { lowest_count = randomteam; } return(lowest_count); } return(null); }
private static void TeamMessage_Command(CommandEventArgs e) { string msg = e.ArgString; if (msg == null) { return; } msg = msg.Trim(); if (msg.Length <= 0) { return; } CTFTeam team = FindTeamFor(e.Mobile); if (team != null) { msg = String.Format("Team [{0}]: {1}", e.Mobile.Name, msg); for (int m = 0; m < team.Members.Count; m++) { ((Mobile)team.Members[m]).SendMessage(msg); } } }
public override void OnSingleClick(Mobile from) { LabelTo(from, "Scoreboard"); if (m_Game == null) { return; } string msg = ""; for (int i = 0; i < m_Game.Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Game.Teams[i]; if (msg != "") { msg += " <> "; } msg += team.Name + ": " + team.Points.ToString(); if (i % 2 == 1) { LabelTo(from, msg); msg = ""; } } if (msg.Length > 0) { LabelTo(from, msg); } }
public override void OnRemoved(object oldParent) { if (m_Game == null) { return; } Mobile m = null; if (oldParent is Item) { m = ((Item)oldParent).RootParent as Mobile; } else { m = oldParent as Mobile; } if (m != null) { CTFRobe robe = m.FindItemOnLayer(Layer.OuterTorso) as CTFRobe; CTFTeam team = m_Game.GetTeam(m); if (robe != null && team != null) { robe.Hue = team.Hue; } //m.SolidHueOverride = -1; } }
public CTFRobe( CTFTeam team ) : base(0x1F03, team.Hue) { Name = team.Name + "a robe"; Weight = 0.0; Movable = false; }
public override bool OnMoveOver(Mobile from) { if (m_Game == null || !CanDom || !from.Alive || from.AccessLevel != AccessLevel.Player) { return(true); } if (!m_Game.Running) { from.SendAsciiMessage("The game is currently closed."); return(false); } CTFTeam team = m_Game.GetTeam(from); if (team == null) { return(false); } if (team != m_TeamOwner) { TeamOwner = team; m_Game.PlayerMessage("{0} has taken point {1}!", team.Name, this.Name); DominationChange(); } return(true); }
public void PlayerMessage(string message) { message = "Game: " + message; for (int i = 0; i < m_Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Teams[i]; for (int j = 0; j < team.Members.Count; j++) { ((Mobile)team.Members[j]).SendMessage(0x489, message); } } if (m_Crystals != null && m_Crystals.Count > 0) { for (int i = 0; i < m_Crystals.Count; i++) { if (m_Crystals[i] != null && m_Crystals[i] is CTFCrystal) { ((CTFCrystal)m_Crystals[i]).Announce(message); } } } if (m_MsgStaff) { Server.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor, 0x489, message); } }
public DeathTimer(Mobile m, CTFTeam t, CTFTeam tkiller) : base(DeathDelay) { m_Mob = m; m_Team = t; m_KillerTeam = tkiller; Priority = TimerPriority.TwoFiftyMS; }
public static bool Mobile_AllowHarmful(Mobile from, Mobile target) { if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player) { return(true); } // MODIFICATIONS FOR Capture the Flag / Double Dom games Server.Items.CTFTeam ft = Server.Items.CTFGame.FindTeamFor(from); Server.Items.CTFTeam tt = Server.Items.CTFGame.FindTeamFor(target); if (ft != null && tt != null && ft == tt) { return(false); } Map map = from.Map; if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0) { return(true); // In felucca, anything goes } BaseCreature bc = from as BaseCreature; if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player)) { if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile && ((PlayerMobile)target).CheckYoungProtection(from)) { return(false); } return(true); // Uncontrolled NPCs are only restricted by the young system } Guild fromGuild = GetGuildFor(from.Guild as Guild, from); Guild targetGuild = GetGuildFor(target.Guild as Guild, target); if (fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))) { return(true); // Guild allies or enemies can be harmful } if (target is BaseCreature && (((BaseCreature)target).Controlled || (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster))) { return(false); // Cannot harm other controlled mobiles } if (target.Player) { return(false); // Cannot harm other players } if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent)) { if (Notoriety.Compute(from, target) == Notoriety.Innocent) { return(false); // Cannot harm innocent mobiles } } return(true); }
protected override void OnTick() { m_Game.PlayerMessage("Time left: {0:0}:{1:00}:{2:00} <> Scores:", (int)(m_Game.TimeLeft.TotalSeconds / 60 / 60), (int)(m_Game.TimeLeft.TotalSeconds / 60) % 60, (int)(m_Game.TimeLeft.TotalSeconds) % 60); for (int i = 0; i < m_Game.Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Game.Teams[i]; m_Game.PlayerMessage("Team {0}: {1} points", team.Name, team.Points); } }
private static void OnPlayerDeath(PlayerDeathEventArgs e) { CTFTeam team = FindTeamFor(e.Mobile); if (team != null) { new DeathTimer(e.Mobile, team).Start(); } }
protected override void OnTarget(Mobile from, object target) { if (!m_Flag.Game.Running) { from.SendMessage("You cannot pass or capture after the game end."); return; } CTFTeam fteam = m_Flag.Game.GetTeam(from); if (target is Mobile) { Mobile targ = (Mobile)target; CTFTeam tteam = m_Flag.Game.GetTeam(targ); if (targ.Alive && tteam == fteam && from != targ) { if (targ.Backpack != null) { m_Flag.RandomizeItemID(); targ.Backpack.DropItem(m_Flag); targ.SendMessage("{0} gave you the {1} flag!", from.Name, m_Flag.Team.Name); m_Flag.Game.PlayerMessage("{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) { CTFScoreBoard.Captured(from); if (m_Flag.Game != null && m_Flag.Game.IsLeagueGame) { CTFLScoreBoard.Captured(from); } from.SendMessage("You captured the {0} flag!", m_Flag.Team.Name); flag.Game.PlayerMessage("{0} ({1}) captured the {2} flag!", from.Name, fteam.Name, m_Flag.Team.Name); m_Flag.ReturnToHome(); fteam.Points += 15; } else { from.SendMessage("Your flag must be at home to capture!"); } } else { from.SendMessage("You can only capture for your own team!"); } } }
public void EndGame() { if (!m_Running) { return; } CTFTeam Winner = null; if (m_GameTimer != null) { m_GameTimer.Stop(); m_GameTimer = null; } if (m_ScoreTimer != null) { m_ScoreTimer.Stop(); m_ScoreTimer = null; } for (int i = 0; i < m_Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Teams[i]; if (team.Flag != null) { team.Flag.ReturnToHome(); } if (Winner == null || team.Points > Winner.Points) { Winner = team; } } if (Winner != null) { PlayerMessage("The game is over. The winner is {0} with {1} points!", Winner.Name, Winner.Points); /* * // Uncomment this and mofiy as nessessary to give prize(s) to the winning team members. * for (int j=0;j<Winner.Members.Count;j++) * { * Mobile m = (Mobile)Winner.Members[j]; * * m.BankBox.AddItem( ... ); * } */ } else { PlayerMessage("The game is over."); } m_Running = false; }
protected override void OnTick() { int sm = -1, ns = -1; int[] amc = new int[m_Game.m_Teams.Count]; for (int i = 0; i < m_Game.m_Teams.Count; i++) { amc[i] = ((CTFTeam)m_Game.m_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; m.CloseGump(typeof(GameTeamSelector)); 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.m_Teams[t]; m_Game.SwitchTeams(m, team); m.SendMessage("You have joined team {0}!", team.Name); } } m_Game.ResetGame(); }
public void GivePrize(CTFTeam team) { if (team == null || team.Members.Count == 0) { return; } foreach (PlayerMobile pm in team.Members) { GivePrize(pm); } }
public override void UseGate(Mobile m) { CTFTeam team = CTFGame.FindTeamFor(m); if (team != null) { team.Game.LeaveGame(m); } base.UseGate(m); }
public void UpdateTeam() { if (m_Game != null && m_TeamID != -1) { m_Team = m_Game.GetTeam(m_TeamID); if (m_Team != null) { this.Hue = m_Team.Hue; m_Team.Flag = this; } } }
/*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target ) * { * if ( from == GuildStatus.Waring && target == GuildStatus.Waring ) * return true; * * return false; * }*/ public static bool Mobile_AllowBeneficial(Mobile from, Mobile target) { if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player) { return(true); } // MODIFICATIONS FOR Capture the Flag / Double Dom games Server.Items.CTFTeam ft = Server.Items.CTFGame.FindTeamFor(from); Server.Items.CTFTeam tt = Server.Items.CTFGame.FindTeamFor(target); if (ft != null && tt != null && ft == tt) { return(true); } #region Factions Faction targetFaction = Faction.Find(target, true); if ((!Core.ML || Faction.IsFactionFacet(from.Map)) && targetFaction != null) { if (Faction.Find(from, true) != targetFaction) { return(false); } } #endregion if (from.Map != null && (from.Map.Rules & MapRules.BeneficialRestrictions) == 0) { return(true); // In felucca, anything goes } if (!from.Player) { return(true); // NPCs have no restrictions } if (target is BaseCreature && !((BaseCreature)target).Controlled) { return(false); // Players cannot heal uncontrolled mobiles } if (from is PlayerMobile && ((PlayerMobile)from).Young && (!(target is PlayerMobile) || !((PlayerMobile)target).Young)) { return(false); // Young players cannot perform beneficial actions towards older players } Guild fromGuild = from.Guild as Guild; Guild targetGuild = target.Guild as Guild; if (fromGuild != null && targetGuild != null && (targetGuild == fromGuild || fromGuild.IsAlly(targetGuild))) { return(true); // Guild members can be beneficial } return(CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target))); }
public void UpdateTeam() { if ( m_Game != null && m_TeamID != -1 ) { m_Team = m_Game.GetTeam( m_TeamID ); if ( m_Team != null ) { this.Hue = m_Team.Hue; this.Name = m_Team.Name + " Team Control"; } } }
public void UpdateTeam() { if ( m_Game != null && m_TeamID != -1 ) { m_Team = m_Game.GetTeam( m_TeamID ); if ( m_Team != null ) { this.Hue = m_Team.Hue; m_Team.Flag = this; } } }
public void UpdateTeam() { if (m_Game != null && m_TeamID != -1) { m_Team = m_Game.GetTeam(m_TeamID); if (m_Team != null) { this.Hue = m_Team.Hue; this.Name = m_Team.Name + " Team Control"; } } }
public static CTFTeam FindTeamFor(Mobile m) { for (int i = 0; i < m_Registry.Count; i++) { CTFGame game = (CTFGame)m_Registry[i]; CTFTeam team = game.GetTeam(m); if (team != null) { return(team); } } return(null); }
public override void OnSingleClick(Mobile from) { base.OnSingleClick(from); from.SendMessage("**** CTF Scores ****"); if (m_Game == null) { return; } for (int i = 0; i < m_Game.Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Game.Teams[i]; from.SendMessage(team.Name + ": " + team.Points.ToString()); } }
private static void OnPlayerDeath(PlayerDeathEventArgs e) { CTFTeam teamvictim = FindTeamFor(e.Mobile); CTFTeam teamkiller = null; if (e.Mobile.LastKiller != null) { teamkiller = FindTeamFor(e.Mobile.LastKiller); } if (teamvictim != null && teamvictim.Game != null && teamvictim.Game.ResPlayers) { new DeathTimer(e.Mobile, teamvictim, teamkiller).Start(); } }
public void StartGame(bool resetTeams) { m_Running = false; if (m_GameTimer != null) { m_GameTimer.Stop(); } if (m_ScoreTimer != null) { m_ScoreTimer.Stop(); } if (resetTeams) { PlayerMessage("The game will start in 30 seconds, please select your team."); int teamSize = this.TeamSize; ArrayList players = new ArrayList(); for (int i = 0; i < m_Teams.Count; i++) { CTFTeam t = (CTFTeam)m_Teams[i]; for (int j = 0; j < t.Members.Count; j++) { Mobile m = (Mobile)t.Members[i]; m.Frozen = true; m.SendGump(new GameTeamSelector(this, teamSize)); players.Add(m); } t.Members.Clear(); } new StartTimer(this, players).Start(); } else { ResetGame(); } if (m_GameType == 1) { m_Region = new GameRegion(1); } else { m_Region = new GameRegion(2); } }
public CTFTeam GetTeam(Mobile m) { if (m_Teams != null) { for (int i = 0; i < m_Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Teams[i]; if (team.Members.Contains(m)) { return(team); } } } return(null); }
public CTFTeam GetTeam(int uid) { if (m_Teams != null) { for (int i = 0; i < m_Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Teams[i]; if (team.UId == uid) { return(team); } } } return(null); }
public void ResetGame() { PlayerMessage("The game has started."); m_StartTime = DateTime.Now; m_GameTimer = Timer.DelayCall(Length, new TimerCallback(EndGame)); m_Running = true; if (m_ScoreTimer == null) { m_ScoreTimer = new ScoreTimer(this); } m_ScoreTimer.Start(); for (int i = 0; i < m_Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Teams[i]; team.Points = 0; if (team.Flag != null) { team.Flag.ReturnToHome(); } for (int j = 0; j < team.Members.Count; j++) { Mobile m = (Mobile)team.Members[j]; m.Kill(); if (m.Corpse != null && !m.Corpse.Deleted) { m.Corpse.Delete(); } m.LogoutLocation = team.Home; m.Location = team.Home; m.Location = team.Home; m.Map = team.Map; m.Resurrect(); m.Hits = m.HitsMax; m.Mana = m.ManaMax; m.Stam = m.StamMax; } } }
public override void OnAfterDelete() { for (int t = 0; t < m_Teams.Count; t++) { CTFTeam team = (CTFTeam)m_Teams[t]; while (team.Members.Count > 0) { LeaveGame((Mobile)team.Members[0]); } } m_Registry.Remove(this); m_Teams.Clear(); base.OnAfterDelete(); }
public void PlayerMessage(string message) { message = "Game: " + message; for (int i = 0; i < m_Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Teams[i]; for (int j = 0; j < team.Members.Count; j++) { ((Mobile)team.Members[j]).SendMessage(0x489, message); } } if (m_MsgStaff) { Server.Scripts.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor, 0x489, message); } }
public override DeathMoveResult OnInventoryDeath(Mobile parent) { if (parent != null) { CTFRobe robe = parent.FindItemOnLayer(Layer.OuterTorso) as CTFRobe; CTFTeam team = m_Game.GetTeam(parent); if (robe != null && team != null) { robe.Hue = team.Hue; } //m.SolidHueOverride = -1; } //parent.SolidHueOverride = -1; MoveToWorld(parent.Location, Map); //Timer.DelayCall( TimeSpan.Zero, new TimerCallback( MoveToGround ) ); return(DeathMoveResult.MoveToCorpse); }
protected override void OnTarget(Mobile from, object target) { CTFTeam fteam = m_Flag.Game.GetTeam(from); if (target is Mobile) { Mobile targ = (Mobile)target; CTFTeam tteam = m_Flag.Game.GetTeam(targ); if (tteam == fteam && from != targ) { if (targ.Backpack != null) { targ.Backpack.DropItem(m_Flag); targ.SendAsciiMessage("{0} gave you the {1} flag!", from.Name, m_Flag.Team.Name); m_Flag.Game.PlayerMessage("{0} passed the {1} flag to {2}!", from.Name, m_Flag.Team.Name, targ.Name); } } else { from.SendAsciiMessage("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.SendAsciiMessage("You captured the {0} flag!", m_Flag.Team.Name); flag.Game.PlayerMessage("{0} ({1}) captured the {2} flag!", from.Name, fteam.Name, m_Flag.Team.Name); m_Flag.ReturnToHome(); fteam.Points += 15; } else { from.SendAsciiMessage("Your flag must be at home to capture!"); } } else { from.SendAsciiMessage("You can only capture for your own team!"); } } }
public void SwitchTeams(Mobile from, CTFTeam team) { CTFTeam old = GetTeam(from); if (old == team) { return; } else if (old != null) { old.RemoveMember(from); } team.AddMember(from); from.Delta(MobileDelta.Noto); Item robe = from.FindItemOnLayer(Layer.OuterTorso); if (robe is CTFRobe) { robe.Name = team.Name + " Game Robe"; robe.Hue = team.Hue; } else { if (robe != null) { if (robe.Movable) { from.AddToBackpack(robe); } else { robe.Delete(); } } robe = new CTFRobe(team); from.EquipItem(robe); } }
public override bool OnMoveOver( Mobile from ) { if ( m_Game == null || !CanDom || !from.Alive || from.AccessLevel != AccessLevel.Player ) return true; if ( !m_Game.Running ) { from.SendMessage( "The game is currently closed." ); return false; } CTFTeam team = m_Game.GetTeam( from ); if ( team == null ) return false; if ( team != m_TeamOwner ) { TeamOwner = team; m_Game.PlayerMessage( "{0} has taken point {1}!", team.Name, this.Name ); DominationChange(); } return true; }
public DeathTimer( Mobile m, CTFTeam t ) : base( DeathDelay ) { m_Mob = m; m_Team = t; Priority = TimerPriority.TwoFiftyMS; }
public void SwitchTeams( Mobile from, CTFTeam team ) { CTFTeam old = GetTeam( from ); if ( old == team ) return; else if ( old != null ) old.RemoveMember( from ); team.AddMember( from ); from.Delta( MobileDelta.Noto ); from.Blessed = true; Item robe = from.FindItemOnLayer( Layer.OuterTorso ); if ( robe is CTFRobe ) { robe.Name = "Game Robe"; robe.Hue = 0; } else { if ( robe != null ) { if ( robe.Movable ) from.AddToBackpack( robe ); else robe.Delete(); } robe = new CTFRobe( team ); from.EquipItem( robe ); } }
public bool IsInGame( CTFTeam team ) { return m_Teams != null ? m_Teams.Contains( team ) : false; }
public CTFRobe( CTFTeam team ) : base( 0x1F03 ) { Name = "Game Robe"; Weight = 0.0; Movable = false; }
public void ReturnToHome() { CanDom = true; TeamOwner = null; if ( m_OtherPoint != null ) m_OtherPoint.TeamOwner = null; if ( m_Timer != null && m_Timer.Running ) m_Timer.Stop(); m_Timer = null; }