Пример #1
0
        private static void Prefix(Player __instance, DamageInfo di)
        {
            if (!CTF.IsActiveServer)
            {
                return;
            }

            if (!CTF.PlayerHasFlag.TryGetValue(__instance.netId, out int flag))
            {
                return;
            }

            CTF.NotifyAll(CTFEvent.CARRIER_DIED, null, __instance, flag);

            if (di.owner == null)
            {
                return;
            }

            Player attacker = di.owner.GetComponent <Player>();

            if (attacker == null || attacker.netId == __instance.netId)
            {
                return;
            }

            ServerStatLog.AddFlagEvent(attacker, "CarrierKill", MPTeams.AllTeams[flag]);
        }
Пример #2
0
        // 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);
        }