Exemple #1
0
        private static void HandleKilled(NetworkMessage msg)
        {
            MsgKilled k = msg as MsgKilled;

            WriteLine("MsgKilled Killer" + k.KillerID.ToString() + " Victim " + k.VictimID.ToString());
            WriteLine("\tShot " + k.ShotID.ToString());
            WriteLine("\tFlag " + k.FlagAbreviation);
        }
Exemple #2
0
        internal void HandleKilled(ServerPlayer player, MsgKilled msgKilled)
        {
            if (msgKilled == null || player == null)
            {
                return;
            }

            KilledEventArgs args = new KilledEventArgs();

            msgKilled.VictimID = player.PlayerID;
            args.Victim        = player;
            args.Killer        = GetPlayerByID(msgKilled.KillerID);
            args.Shot          = Shots.FindKillableShot(msgKilled.KillerID, msgKilled.ShotID);
            args.KillInfo      = msgKilled;

            KillPlayer(player, args);
        }
Exemple #3
0
        public void HandleKilled(NetworkMessage msg)
        {
            MsgKilled killed = msg as MsgKilled;

            KilledEventArgs args = new KilledEventArgs();

            args.Victim       = GetPlayerByID(killed.VictimID);
            args.Killer       = GetPlayerByID(killed.KillerID);
            args.Reason       = killed.Reason;
            args.KilledByFlag = FlagTypeList.GetFromAbriv(killed.FlagAbreviation);
            if (killed.Reason == BlowedUpReasons.DeathTouch)
            {
                args.InstrumentID = killed.PhysicsDriverID;
            }
            else
            {
                args.InstrumentID = killed.ShotID;

                if (killed.ShotID > 0)
                {
                    // kill shot
                    int bzfsShotID = (killed.KillerID * byte.MaxValue) + killed.ShotID;
                    // tell the shot manager to kill that thar shot
                }
            }

            if (args.Victim != null)
            {
                args.Victim.SetTeleport(-1, null, null);
                args.Victim.Active   = false;
                args.Victim.IsRabbit = false;
            }


            if (PlayerKilled != null)
            {
                PlayerKilled.Invoke(this, args);
            }
        }
Exemple #4
0
        public void KillPlayer(ServerPlayer player, KilledEventArgs args)
        {
            if (args == null || player == null)
            {
                return;
            }

            if (!player.Info.Alive)
            {
                Logger.Log0("Player " + player.Callsign + " killed while dead");
            }

            player.Info.Alive = false;

            PlayerKilled?.Invoke(this, args);

            Logger.Log4("Player " + player.Callsign + " killed by " + args.KillInfo.Reason.ToString());

            bool wasFromAFlag = false;

            switch (args.KillInfo.Reason)
            {
            case BlowedUpReasons.GotKilledMsg:
                break;

            case BlowedUpReasons.GotShot:
                wasFromAFlag = true;
                Shots.RemoveShotForDeath(player, args.KillInfo.KillerID, args.KillInfo.ShotID);

                if (args.Shot != null)    // tell the flag it took a hit
                {
                    Flags.HandlePlayerTakeHit(player, args.Killer, args.Shot);
                }
                break;

            case BlowedUpReasons.GotRunOver:
                wasFromAFlag = true;
                break;

            case BlowedUpReasons.GotCaptured:
                break;

            case BlowedUpReasons.GenocideEffect:
                break;

            case BlowedUpReasons.SelfDestruct:
                break;

            case BlowedUpReasons.WaterDeath:
                break;

            case BlowedUpReasons.DeathTouch:
                break;

            case BlowedUpReasons.LastReason:
            case BlowedUpReasons.Unknown:
                Logger.Log0("Player " + player.Callsign + " killed by a method that should not happen");
                break;
            }

            if (wasFromAFlag)   // tell the flag it killed
            {
                Flags.HandlePlayerDoDamage(player, args.Killer, FlagTypeList.GetFromAbriv(args.KillInfo.FlagAbreviation));
            }

            // process any scores
            PlayerInfo.ScoreInfo vicScores    = new PlayerInfo.ScoreInfo();
            PlayerInfo.ScoreInfo killerScores = new PlayerInfo.ScoreInfo();
            if (ComputeScores(args.Victim, ref vicScores, args.Killer, ref killerScores, args.KillInfo.Reason))
            {
                args.Victim.Info.Score.ApplyScore(vicScores);
                if (args.Killer != null)
                {
                    args.Killer.Info.Score.ApplyScore(killerScores);
                }

                MsgScore scoreMessage = new MsgScore();
                if (!vicScores.Empty)
                {
                    Logger.Log3("Player " + player.Callsign + " score updated by " + vicScores.ToString());

                    ScoreUpdated?.Invoke(this, args.Victim);
                    args.Victim.Info.Score.Pack(args.Victim.PlayerID, scoreMessage);
                }

                if (args.Killer != null && !killerScores.Empty)
                {
                    Logger.Log3("Player " + player.Callsign + " score updated by " + killerScores.ToString());

                    ScoreUpdated?.Invoke(this, args.Killer);
                    args.Killer.Info.Score.Pack(args.Killer.PlayerID, scoreMessage);
                }

                if (scoreMessage.Scores.Count > 0)
                {
                    SendToAll(scoreMessage, false);
                }
            }

            MsgKilled killedMessage = new MsgKilled();

            killedMessage.VictimID        = args.Victim.PlayerID;
            killedMessage.KillerID        = args.Killer != null ? args.Killer.PlayerID : PlayerConstants.ServerPlayerID;
            killedMessage.ShotID          = args.Shot != null ? args.Shot.PlayerShotID : -1;
            killedMessage.Reason          = args.KillInfo.Reason;
            killedMessage.FlagAbreviation = (args.Shot != null && args.Shot.SourceFlag != null) ? args.Shot.SourceFlag.FlagAbbv : string.Empty;
            killedMessage.PhysicsDriverID = args.KillInfo.PhysicsDriverID;

            SendToAll(killedMessage, false);
        }