public static void Score(Player player) { if (NetworkMatch.m_postgame) { return; } if (!PlayerHasFlag.TryGetValue(player.netId, out int flag) || FlagStates[MPTeams.TeamNum(player.m_mp_team)] != FlagState.HOME) { return; } PlayerHasFlag.Remove(player.netId); if (!SendCTFLose(-1, player.netId, flag, FlagState.HOME, true)) { return; } if (!CTF.CarrierBoostEnabled) { player.c_player_ship.m_boost_overheat_timer = 0; player.c_player_ship.m_boost_heat = 0; } NetworkMatch.AddPointForTeam(player.m_mp_team); NotifyAll(CTFEvent.SCORE, string.Format(Loc.LS("{0} ({1}) CAPTURES THE {2} FLAG!"), player.m_mp_name, MPTeams.TeamName(player.m_mp_team), MPTeams.TeamName(MPTeams.AllTeams[flag])), player, flag); }
static void Postfix(CCInput cc_type) { if (MPObserver.Enabled && GameplayManager.IsMultiplayerActive) { if (cc_type == CCInput.SWITCH_WEAPON && Controls.JustPressed(CCInput.SWITCH_WEAPON)) { MPObserver.SwitchObservedPlayer(false); } if (cc_type == CCInput.PREV_WEAPON && Controls.JustPressed(CCInput.PREV_WEAPON)) { MPObserver.SwitchObservedPlayer(true); } if (cc_type == CCInput.FIRE_WEAPON && Controls.JustPressed(CCInput.FIRE_WEAPON) && MPObserver.ObservedPlayer != null) { MPObserver.SetObservedPlayer(null); } if (cc_type == CCInput.FIRE_MISSILE && Controls.JustPressed(CCInput.FIRE_MISSILE) && MPObserver.ObservedPlayer != null) { MPObserver.ThirdPerson = !MPObserver.ThirdPerson; MPObserver.SetPlayerVisibility(MPObserver.ObservedPlayer, MPObserver.ThirdPerson); GameManager.m_viewer.SetDamageEffects(-999); } if (cc_type == CCInput.SWITCH_MISSILE && Controls.JustPressed(CCInput.SWITCH_MISSILE) && CTF.IsActive) { var player = (from f in CTF.PlayerHasFlag join p in Overload.NetworkManager.m_Players on f.Key equals p.netId where p.m_mp_team == MpTeam.TEAM0 select p).FirstOrDefault(); if (player == null) { GameplayManager.AddHUDMessage($"No {MPTeams.TeamName(MpTeam.TEAM0)} player is carrying a flag."); } else { MPObserver.SetObservedPlayer(player); } } if (cc_type == CCInput.PREV_MISSILE && Controls.JustPressed(CCInput.PREV_MISSILE) && CTF.IsActive) { var player = (from f in CTF.PlayerHasFlag join p in Overload.NetworkManager.m_Players on f.Key equals p.netId where p.m_mp_team == MpTeam.TEAM1 select p).FirstOrDefault(); if (player == null) { GameplayManager.AddHUDMessage($"No {MPTeams.TeamName(MpTeam.TEAM1)} player is carrying a flag."); } else { MPObserver.SetObservedPlayer(player); } } } }
static bool Prefix(MpTeam team, ref string __result) { if (team < MpTeam.NUM_TEAMS) { return(true); } __result = MPTeams.TeamName(team) + " TEAM"; return(false); }
// pickup of flag item public static bool Pickup(Player player, int flag) { if (flag < 0 || flag >= FlagObjs.Count) { return(false); } var ownFlag = MPTeams.AllTeams[flag] == player.m_mp_team; if (ownFlag && FlagStates[flag] == FlagState.HOME) { if (CTF.PlayerHasFlag.ContainsKey(player.netId)) { CTF.Score(player); } return(false); } if (!ownFlag && (PlayerHasFlag.ContainsKey(player.netId) || PlayerHasFlag.ContainsValue(flag))) { return(false); } // this also sends to 'client 0' so it'll get processed on the server as well CTFEvent evt; if (ownFlag) { SendCTFFlagUpdate(-1, player.netId, flag, FlagState.HOME); SpawnAtHome(flag); evt = CTFEvent.RETURN; } else { SendCTFPickup(-1, player.netId, flag, FlagState.PICKEDUP); if (!CTF.CarrierBoostEnabled) { player.c_player_ship.m_boosting = false; player.c_player_ship.m_boost_overheat_timer = float.MaxValue; } evt = CTFEvent.PICKUP; } var msg = evt == CTFEvent.RETURN ? "{0} RETURNS THE {2} FLAG!" : FlagStates[flag] == FlagState.HOME ? "{0} ({1}) PICKS UP THE {2} FLAG!" : "{0} ({1}) FINDS THE {2} FLAG AMONG SOME DEBRIS!"; CTF.NotifyAll(evt, string.Format(Loc.LS(msg), player.m_mp_name, MPTeams.TeamName(player.m_mp_team), MPTeams.TeamName(MPTeams.AllTeams[flag])), player, flag); if (FlagReturnTimer[flag] != null) { GameManager.m_gm.StopCoroutine(FlagReturnTimer[flag]); FlagReturnTimer[flag] = null; } return(true); }
public static void Score(Player player) { if (NetworkMatch.m_postgame) { return; } if (!PlayerHasFlag.TryGetValue(player.netId, out int flag) || FlagStates[MPTeams.TeamNum(player.m_mp_team)] != FlagState.HOME) { return; } PlayerHasFlag.Remove(player.netId); SendCTFLose(-1, player.netId, flag, FlagState.HOME); SpawnAtHome(flag); NetworkMatch.AddPointForTeam(player.m_mp_team); NotifyAll(CTFEvent.SCORE, string.Format(Loc.LS("{0} ({1}) CAPTURES THE {2} FLAG!"), player.m_mp_name, MPTeams.TeamName(player.m_mp_team), MPTeams.TeamName(MPTeams.AllTeams[flag])), player, flag); }
private static string TeamName(MpTeam?team) { return(team == null || team == MpTeam.ANARCHY || team == (MpTeam)(-1) ? null : MPTeams.TeamName((MpTeam)team)); }
public static IEnumerator CreateReturnTimer(int flag) { yield return(new WaitForSeconds(CTF.ReturnTimeAmount)); if (!IsActiveServer || NetworkMatch.m_match_state != MatchState.PLAYING || CTF.FlagStates[flag] != FlagState.LOST) { yield break; } SendCTFLose(-1, default(NetworkInstanceId), flag, FlagState.HOME); foreach (var item in GameObject.FindObjectsOfType <Item>()) { if (item.m_type == ItemType.KEY_SECURITY && item.m_index == flag) { UnityEngine.Object.Destroy(item.gameObject); } } SpawnAtHome(flag); NotifyAll(CTFEvent.RETURN, string.Format(Loc.LS("LOST {0} FLAG RETURNED AFTER TIMER EXPIRED!"), MPTeams.TeamName(MPTeams.AllTeams[flag])), null, flag); FlagReturnTimer[flag] = null; }
public static void Drop(Player player) { if (!PlayerHasFlag.TryGetValue(player.netId, out int flag)) { return; } SendCTFLose(-1, player.netId, flag, FlagState.LOST); if (!CTF.CarrierBoostEnabled) { player.c_player_ship.m_boost_overheat_timer = 0; player.c_player_ship.m_boost_heat = 0; } NotifyAll(CTFEvent.DROP, string.Format(Loc.LS("{0} ({1}) DROPPED THE {2} FLAG!"), player.m_mp_name, MPTeams.TeamName(player.m_mp_team), MPTeams.TeamName(MPTeams.AllTeams[flag])), player, flag); if (FlagReturnTimer[flag] != null) { GameManager.m_gm.StopCoroutine(FlagReturnTimer[flag]); } GameManager.m_gm.StartCoroutine(FlagReturnTimer[flag] = CreateReturnTimer(flag)); }
public static IEnumerator CreateReturnTimer(int flag) { yield return(new WaitForSeconds(CTF.ReturnTimeAmount)); if (!IsActiveServer || NetworkMatch.m_match_state != MatchState.PLAYING || CTF.FlagStates[flag] != FlagState.LOST) { yield break; } if (!SendCTFLose(-1, default(NetworkInstanceId), flag, FlagState.HOME, true, true)) { yield break; } NotifyAll(CTFEvent.RETURN, string.Format(Loc.LS("LOST {0} FLAG RETURNED AFTER TIMER EXPIRED!"), MPTeams.TeamName(MPTeams.AllTeams[flag])), null, flag); FlagReturnTimer[flag] = null; }
static bool Prefix(MpTeam team, ref string __result) { __result = MPTeams.TeamName(team); return(false); }