示例#1
0
        private static bool HandlePlayerKillMe(GetDataHandlerArgs args)
        {
            int   index        = args.Player.Index;
            byte  PlayerID     = (byte)args.Data.ReadByte();
            byte  hitDirection = (byte)args.Data.ReadByte();
            Int16 Damage       = (Int16)args.Data.ReadInt16();
            bool  PVP          = args.Data.ReadBoolean();
            var   player       = STools.GetPlayer(PlayerID);

            if (player.KillingPlayer != null)
            {
                if (PVP == true)
                {
                    player.KillingPlayer.kills++;
                    player.deaths++;
                }
                player.KillingPlayer = null;
            }
            else
            {
                player.deaths++;
            }

            return(false);
        }
示例#2
0
        private static bool HandlePlayerKillMe(GetDataHandlerArgs args)
        {
            if (args.Player == null)
            {
                return(false);
            }
            var index = args.Player.Index;

            args.Data.ReadByte();
            args.Data.ReadByte();
            args.Data.ReadInt16();
            var pvp    = args.Data.ReadBoolean();
            var player = TShock.Players.First(p => p != null && p.IsLoggedIn && p.Index == index);

            if (player == null)
            {
                return(false);
            }

            if (player.Name == null)
            {
                return(false);
            }

//            Console.WriteLine("player  " + player.User.ID);
            if (Statistics.PlayerKilling[player] != null)
            {
                //Only update killer if the killer is logged in
                if (Statistics.PlayerKilling[player].IsLoggedIn && pvp)
                {
                    Statistics.database.UpdateKillingSpree(Statistics.PlayerKilling[player].Account.ID, 0, 0, 1);  // byDii
                    Statistics.database.UpdateKills(Statistics.PlayerKilling[player].Account.ID, KillType.Player); // byDii
                    KillingSpree.SendKillingNotice(player.Name, player.Account.ID, 0, 0, 1);                       // byDii
                    SpeedKills.PlayerKill(index);
                    Statistics.database.UpdateHighScores(Statistics.PlayerKilling[player].Account.ID);             // byDii
                    Statistics.database.UpdatePlayerDamageGiven(Statistics.PlayerKilling[player].Account.ID,       // byDii
                                                                Statistics.PlayerKilling[player].Index);
                    Statistics.database.UpdateDamageReceived(Statistics.PlayerKilling[player].Account.ID,          // byDii
                                                             Statistics.PlayerKilling[player].Index);
                }
                Statistics.PlayerKilling[player] = null;
            }

            Statistics.database.UpdateDeaths(player.Account.ID);                          // byDii
            Statistics.database.UpdatePlayerDamageGiven(player.Account.ID, player.Index); // byDii
            //update all received damage on death
            Statistics.database.UpdateDamageReceived(player.Account.ID, player.Index);    // byDii
            Statistics.database.UpdateHighScores(player.Account.ID);                      // byDii

            Statistics.database.CloseKillingSpree(player.Account.ID);                     // byDii
            KillingSpree.ClearBlitzEvent(player.Account.ID);                              // byDii
            SpeedKills.ResetPlayer(index);

            return(false);
        }
示例#3
0
        private static bool HandlePlayerDamage(GetDataHandlerArgs args)
        {
            var index        = args.Player.Index;
            var playerId     = (byte)args.Data.ReadByte();
            var hitDirection = (byte)args.Data.ReadByte();
            var damage       = args.Data.ReadInt16();
            var player       = Statistics.Tools.GetPlayer(playerId);
            var pvp          = args.Data.ReadBoolean();
            var crit         = (byte)args.Data.ReadByte();

            player.killingPlayer = index != playerId?Statistics.Tools.GetPlayer(index) : null;

            return(false);
        }
示例#4
0
        private static bool HandlePlayerKillMe(GetDataHandlerArgs args)
        {
            if (args.Player == null)
            {
                return(false);
            }
            var index = args.Player.Index;

            args.Data.ReadByte();
            args.Data.ReadByte();
            args.Data.ReadInt16();
            var pvp    = args.Data.ReadBoolean();
            var player = TShock.Players.First(p => p != null && p.IsLoggedIn && p.Index == index);

            if (player == null)
            {
                return(false);
            }

            if (Statistics.PlayerKilling[player] != null)
            {
                //Only update killer if the killer is logged in
                if (Statistics.PlayerKilling[player].IsLoggedIn && pvp)
                {
                    Statistics.database.UpdateKills(Statistics.PlayerKilling[player].User.ID, KillType.Player);
                    Statistics.database.UpdateHighScores(Statistics.PlayerKilling[player].User.ID);
                    Statistics.database.UpdatePlayerDamageGiven(Statistics.PlayerKilling[player].User.ID,
                                                                Statistics.PlayerKilling[player].Index);
                    Statistics.database.UpdateDamageReceived(Statistics.PlayerKilling[player].User.ID,
                                                             Statistics.PlayerKilling[player].Index);
                }
                Statistics.PlayerKilling[player] = null;
            }

            Statistics.database.UpdateDeaths(player.User.ID);
            Statistics.database.UpdatePlayerDamageGiven(player.User.ID, player.Index);
            //update all received damage on death
            Statistics.database.UpdateDamageReceived(player.User.ID, player.Index);
            Statistics.database.UpdateHighScores(player.User.ID);

            return(false);
        }
示例#5
0
        private static bool HandleNpcEvent(GetDataHandlerArgs args)
        {
            var index        = args.Player.Index;
            var npcId        = (byte)args.Data.ReadByte();
            var hitDirection = (byte)args.Data.ReadByte();
            var damage       = args.Data.ReadInt16();
            var crit         = args.Data.ReadBoolean();
            var player       = Statistics.Tools.GetPlayer(index);

            if (Main.npc[npcId].target < 255)
            {
                var critical = 1;
                if (crit)
                {
                    critical = 2;
                }
                var hitDamage = (damage - Main.npc[npcId].defense / 2) * critical;

                if (hitDamage > Main.npc[npcId].life && Main.npc[npcId].active && Main.npc[npcId].life > 0)
                {
                    if (!Main.npc[npcId].boss)
                    {
                        player.mobkills++;
                    }
                    else
                    {
                        player.bosskills++;
                    }

                    Statistics.HighScores.highScores.GetHighScore(player.Name)
                    .UpdateHighScore(player.kills, player.mobkills, player.deaths, player.bosskills,
                                     player.timePlayed);
                }
            }
            else
            {
                return(true);
            }

            return(false);
        }
示例#6
0
        private static bool HandlePlayerDamage(GetDataHandlerArgs args)
        {
            int   index        = args.Player.Index;
            byte  PlayerID     = (byte)args.Data.ReadByte();
            byte  hitDirection = (byte)args.Data.ReadByte();
            Int16 Damage       = (Int16)args.Data.ReadInt16();
            var   player       = STools.GetPlayer(PlayerID);
            bool  PVP          = args.Data.ReadBoolean();
            byte  Crit         = (byte)args.Data.ReadByte();

            if (index != PlayerID)
            {
                player.KillingPlayer = STools.GetPlayer(index);
            }
            else
            {
                player.KillingPlayer = null;
            }

            return(false);
        }
示例#7
0
        private static bool HandlePlayerDamage(GetDataHandlerArgs args)
        {
            if (args.Player == null)
            {
                return(false);
            }
            var index    = args.Player.Index;
            var playerId = (byte)args.Data.ReadByte();

            args.Data.ReadByte();
            var damage = args.Data.ReadInt16();
            //player being attacked
            var player = TShock.Players.First(p => p != null && p.IsLoggedIn && p.Index == index);

            if (player == null)
            {
                return(false);
            }

            var crit = args.Data.ReadBoolean();

            args.Data.ReadByte();

            //Attacking player
            Statistics.PlayerKilling[player] = index != playerId ? args.Player : null;

            damage = (short)Main.CalculateDamagePlayersTake(damage, player.TPlayer.statDefense);              // .CalculateDamage

            if (Statistics.PlayerKilling[player] != null)
            {
                Statistics.SentDamageCache[args.Player.Index][KillType.Player] += damage;
                Statistics.RecvDamageCache[player.Index] += damage;
            }
            else
            {
                Statistics.RecvDamageCache[player.Index] += (damage * (crit ? 2 : 1));
            }

            return(false);
        }
示例#8
0
        private static bool HandleNPCEvent(GetDataHandlerArgs args)
        {
            int   index        = args.Player.Index;
            byte  npcID        = (byte)args.Data.ReadByte();
            byte  hitDirection = (byte)args.Data.ReadByte();
            Int16 Damage       = (Int16)args.Data.ReadInt16();
            bool  Crit         = args.Data.ReadBoolean();
            var   player       = STools.GetPlayer(index);

            if (Main.npc[npcID].target < 255)
            {
                int critical = 1;
                if (Crit)
                {
                    critical = 2;
                }
                int hitDamage = (Damage - Main.npc[npcID].defense / 2) * critical;

                if (hitDamage > Main.npc[npcID].life && Main.npc[npcID].active && Main.npc[npcID].life > 0)
                {
                    if (!Main.npc[npcID].boss)
                    {
                        player.mobkills++;
                    }
                    else
                    {
                        player.bosskills++;
                    }
                }
            }
            else
            {
                return(true);
            }

            return(false);
        }
示例#9
0
        private static bool HandlePlayerKillMe(GetDataHandlerArgs args)
        {
            var index        = args.Player.Index;
            var playerId     = (byte)args.Data.ReadByte();
            var hitDirection = (byte)args.Data.ReadByte();
            var damage       = args.Data.ReadInt16();
            var pvp          = args.Data.ReadBoolean();
            var player       = Statistics.Tools.GetPlayer(playerId);

            if (player.killingPlayer != null)
            {
                if (pvp)
                {
                    player.killingPlayer.kills++;
                    player.deaths++;

                    Statistics.HighScores.highScores.GetHighScore(player.Name)
                    .UpdateHighScore(player.kills, player.mobkills, player.deaths, player.bosskills,
                                     player.timePlayed);

                    Statistics.HighScores.highScores.GetHighScore(player.killingPlayer.Name)
                    .UpdateHighScore(player.killingPlayer.kills, player.killingPlayer.mobkills,
                                     player.killingPlayer.deaths, player.killingPlayer.bosskills, player.killingPlayer.timePlayed);
                }
                player.killingPlayer = null;
            }
            else
            {
                player.deaths++;
                Statistics.HighScores.highScores.GetHighScore(player.Name)
                .UpdateHighScore(player.kills, player.mobkills, player.deaths, player.bosskills,
                                 player.timePlayed);
            }

            return(false);
        }
示例#10
0
        private static bool HandleNpcEvent(GetDataHandlerArgs args)
        {
            if (args.Player == null)
            {
                return(false);
            }
            var index = args.Player.Index;
            var npcId = (byte)args.Data.ReadByte();

            args.Data.ReadByte();
            var damage = args.Data.ReadInt16();
            var crit   = args.Data.ReadBoolean();
            var player = TShock.Players.First(p => p != null && p.IsLoggedIn && p.Index == index);

            if (player == null)
            {
                return(false);
            }

            if (IsTargeting(Main.npc[npcId]))
            {
                var critical = 1;
                if (crit)
                {
                    critical = 2;
                }


                var hitDamage = (damage - Main.npc[npcId].defense / 2) * critical;

                if (hitDamage > Main.npc[npcId].life && Main.npc[npcId].active && Main.npc[npcId].life > 0)
                {
                    //not a boss kill
                    if (!Main.npc[npcId].boss && !Main.npc[npcId].friendly)
                    {
                        Statistics.database.UpdateKillingSpree(player.Account.ID, 1, 0, 0);      // byDii
                        Statistics.database.UpdateKills(player.Account.ID, KillType.Mob);        // byDii
                        KillingSpree.SendKillingNotice(player.Name, player.Account.ID, 1, 0, 0); // byDii
                        SpeedKills.PlayerKill(index);
                        Statistics.SentDamageCache[player.Index][KillType.Mob] += Main.npc[npcId].life;
                        //Push damage to database on kill
                        Statistics.database.UpdateMobDamageGiven(player.Account.ID, player.Index);                         // byDii
                    }
                    //a boss kill
                    else
                    {
                        Statistics.database.UpdateKillingSpree(player.Account.ID, 0, 1, 0);      // byDii
                        Statistics.database.UpdateKills(player.Account.ID, KillType.Boss);       // byDii
                        KillingSpree.SendKillingNotice(player.Name, player.Account.ID, 0, 1, 0); // byDii
                        SpeedKills.PlayerKill(index);
                        Statistics.SentDamageCache[player.Index][KillType.Boss] += Main.npc[npcId].life;
                        Statistics.database.UpdateBossDamageGiven(player.Account.ID, player.Index);                         // byDii
                    }

                    //Push player damage dealt and damage received as well
                    Statistics.database.UpdatePlayerDamageGiven(player.Account.ID, player.Index); // byDii
                    Statistics.database.UpdateDamageReceived(player.Account.ID, player.Index);    // byDii
                    Statistics.database.UpdateHighScores(player.Account.ID);                      // byDii
                }
                else
                {
                    if (Main.npc[npcId].boss || _bossParts.Contains(Main.npc[npcId].type))               // boss parts
                    {
                        Statistics.SentDamageCache[player.Index][KillType.Boss] += hitDamage;
                    }
                    else
                    {
                        Statistics.SentDamageCache[player.Index][KillType.Mob] += hitDamage;
                    }
                }
            }
            else
            {
                return(true);
            }

            return(false);
        }