Example #1
0
        public bool HandleDeath(BlockID block, string customMsg = "", bool explode = false, bool immediate = false)
        {
            if (!immediate && lastDeath.AddSeconds(2) > DateTime.UtcNow)
            {
                return(false);
            }
            if (invincible || hidden)
            {
                return(false);
            }

            cancelDeath = false;
            OnPlayerDeathEvent.Call(this, block);
            if (cancelDeath)
            {
                cancelDeath = false; return(false);
            }

            onTrain = false; trainInvincible = false; trainGrab = false;
            ushort x = (ushort)Pos.BlockX, y = (ushort)Pos.BlockY, z = (ushort)Pos.BlockZ;

            string deathMsg = level.Props[block].DeathMessage;

            if (deathMsg != null)
            {
                Chat.MessageFromLevel(this, deathMsg.Replace("@p", "λNICK"));
            }

            if (block == Block.RocketHead)
            {
                level.MakeExplosion(x, y, z, 0);
            }
            if (block == Block.Creeper)
            {
                level.MakeExplosion(x, y, z, 1);
            }

            if (block == Block.Stone || block == Block.Cobblestone)
            {
                if (explode)
                {
                    level.MakeExplosion(x, y, z, 1);
                }
                if (block == Block.Stone)
                {
                    Chat.MessageFrom(this, customMsg.Replace("@p", "λNICK"));
                }
                else
                {
                    Chat.MessageFromLevel(this, customMsg.Replace("@p", "λNICK"));
                }
            }

            PlayerActions.Respawn(this);
            TimesDied++;
            // NOTE: If deaths column is ever increased past 16 bits, remove this clamp
            if (TimesDied > short.MaxValue)
            {
                TimesDied = short.MaxValue;
            }

            if (ServerConfig.AnnounceDeathCount && (TimesDied > 0 && TimesDied % 10 == 0))
            {
                Chat.MessageFromLevel(this, "λNICK %Shas died &3" + TimesDied + " times");
            }
            lastDeath = DateTime.UtcNow;
            return(true);
        }
Example #2
0
        public void HandleDeath(ExtBlock block, string customMsg = "", bool explode = false, bool immediate = false)
        {
            OnPlayerDeathEvent.Call(this, block);

            if (Server.lava.active && Server.lava.HasPlayer(this) && Server.lava.IsPlayerDead(this))
            {
                return;
            }
            if (!immediate && lastDeath.AddSeconds(2) > DateTime.UtcNow)
            {
                return;
            }
            if (!level.Config.KillerBlocks || invincible || hidden)
            {
                return;
            }

            onTrain = false; trainInvincible = false; trainGrab = false;
            ushort x = (ushort)Pos.BlockX, y = (ushort)Pos.BlockY, z = (ushort)Pos.BlockZ;

            string deathMsg = level.Props[block.Index].DeathMessage;

            if (deathMsg != null)
            {
                Chat.MessageLevel(this, deathMsg.Replace("@p", ColoredName), false, level);
            }

            if (block.BlockID == Block.RocketHead)
            {
                level.MakeExplosion(x, y, z, 0);
            }
            if (block.BlockID == Block.Creeper)
            {
                level.MakeExplosion(x, y, z, 1);
            }
            if (block.BlockID == Block.Stone || block.BlockID == Block.Cobblestone)
            {
                if (explode)
                {
                    level.MakeExplosion(x, y, z, 1);
                }
                if (block.BlockID == Block.Stone)
                {
                    Chat.MessageGlobal(this, customMsg.Replace("@p", ColoredName), false);
                }
                else
                {
                    Chat.MessageLevel(this, customMsg.Replace("@p", ColoredName), false, level);
                }
            }

            if (PlayingTntWars)
            {
                TntWarsKillStreak      = 0;
                TntWarsScoreMultiplier = 1f;
            }
            else if (Server.lava.active && Server.lava.HasPlayer(this))
            {
                if (!Server.lava.IsPlayerDead(this))
                {
                    Server.lava.KillPlayer(this);
                    Command.all.FindByName("Spawn").Use(this, "");
                }
            }
            else
            {
                Command.all.FindByName("Spawn").Use(this, "");
                TimesDied++;
                // NOTE: If deaths column is ever increased past 16 bits, remove this clamp
                if (TimesDied > short.MaxValue)
                {
                    TimesDied = short.MaxValue;
                }
            }

            if (ServerConfig.AnnounceDeathCount && (TimesDied > 0 && TimesDied % 10 == 0))
            {
                Chat.MessageLevel(this, ColoredName + " %Shas died &3" + TimesDied + " times", false, level);
            }
            lastDeath = DateTime.UtcNow;
        }
Example #3
0
        public void HandleDeath(byte block, byte extBlock, string customMessage = "",
                                bool explode = false, bool immediate = false)
        {
            if (OnDeath != null)
            {
                OnDeath(this, block);
            }
            if (PlayerDeath != null)
            {
                PlayerDeath(this, block);
            }
            OnPlayerDeathEvent.Call(this, block);

            if (Server.lava.active && Server.lava.HasPlayer(this) && Server.lava.IsPlayerDead(this))
            {
                return;
            }
            if (!immediate && lastDeath.AddSeconds(2) > DateTime.UtcNow)
            {
                return;
            }
            if (!level.Killer || invincible || hidden)
            {
                return;
            }

            onTrain = false; trainInvincible = false; trainGrab = false;
            ushort x = (ushort)(pos[0] / 32), y = (ushort)(pos[1] / 32), z = (ushort)(pos[2] / 32);

            string deathMsg = null;

            if (block != Block.custom_block)
            {
                deathMsg = Block.Props[block].DeathMessage;
            }
            else
            {
                deathMsg = level.CustomBlockProps[extBlock].DeathMessage;
            }
            if (deathMsg != null)
            {
                Chat.GlobalChatLevel(this, deathMsg.Replace("@p", ColoredName), false);
            }

            if (block == Block.rockethead)
            {
                level.MakeExplosion(x, y, z, 0);
            }
            if (block == Block.creeper)
            {
                level.MakeExplosion(x, y, z, 1);
            }
            if (block == Block.rock || block == Block.stone)
            {
                if (explode)
                {
                    level.MakeExplosion(x, y, z, 1);
                }
                if (block == Block.rock)
                {
                    SendChatFrom(this, ColoredName + "%S" + customMessage, false);
                }
                else
                {
                    Chat.GlobalChatLevel(this, ColoredName + "%S" + customMessage, false);
                }
            }

            if (Game.team != null && this.level.ctfmode)
            {
                //if (carryingFlag)
                //{
                // level.ctfgame.DropFlag(this, hasflag);
                //}
                Game.team.SpawnPlayer(this);
                //this.health = 100;
            }
            else if (Server.Countdown.playersleftlist.Contains(this))
            {
                Server.Countdown.Death(this);
                Command.all.Find("spawn").Use(this, "");
            }
            else if (PlayingTntWars)
            {
                TntWarsKillStreak      = 0;
                TntWarsScoreMultiplier = 1f;
            }
            else if (Server.lava.active && Server.lava.HasPlayer(this))
            {
                if (!Server.lava.IsPlayerDead(this))
                {
                    Server.lava.KillPlayer(this);
                    Command.all.Find("spawn").Use(this, "");
                }
            }
            else
            {
                Command.all.Find("spawn").Use(this, "");
                overallDeath++;
            }

            if (Server.deathcount && (overallDeath > 0 && overallDeath % 10 == 0))
            {
                Chat.GlobalChatLevel(this, ColoredName + " %Shas died &3" + overallDeath + " times", false);
            }
            lastDeath = DateTime.UtcNow;
        }