Esempio n. 1
0
        public override void Run()
        {
            var vanilla = this.Method(() => (new Terraria.Player()).KillMe(null, 0, 0, false));

            double tmp  = 0;
            int    tmp1 = 0;
            bool   tmp2 = false;
            string tmp3 = null;

            Terraria.DataStructures.PlayerDeathReason tmpDs = null;
            var cbkBegin = this.SourceDefinition.MainModule.Import(
                this.Method(() => OTAPI.Callbacks.Terraria.Player.KillMeBegin(null, ref tmpDs, ref tmp, ref tmp1, ref tmp2, ref tmp3))
                );

            var cbkEnd = this.SourceDefinition.MainModule.Import(
                this.Method(() => OTAPI.Callbacks.Terraria.Player.KillMeEnd(null, null, 0, 0, false, null))
                );

            vanilla.Wrap
            (
                beginCallback: cbkBegin,
                endCallback: cbkEnd,
                beginIsCancellable: true,
                noEndHandling: false,
                allowCallbackInstance: true
            );
        }
Esempio n. 2
0
        public override void GetChat(NPC npc, ref string chat)
        {
            if (npc.type == 22)
            {
                Terraria.DataStructures.PlayerDeathReason wut = new Terraria.DataStructures.PlayerDeathReason();
                wut.SourceNPCIndex = 22;

                chat = "WUT WUT WUT WUT WUT WUT";
                Main.LocalPlayer.statLife = 0;
                Main.LocalPlayer.KillMe(wut, 1000, 0, false);
            }
        }
Esempio n. 3
0
        public override void Update(Player player, ref int buffIndex)
        {
            LightPlayer modPlayer = player.GetModPlayer <LightPlayer>();

            if (Main.expertMode)
            {
                player.buffTime[buffIndex]--;
            }

            /*player.magicDamage *= player.buffTime[buffIndex]/weakduration;
             * player.meleeDamage *= player.buffTime[buffIndex]/weakduration;
             * player.minionDamage *= player.buffTime[buffIndex]/weakduration;
             * player.thrownDamage *= player.buffTime[buffIndex]/weakduration;
             * modPlayer.lightdamage *= player.buffTime[buffIndex]/(weakduration/2);*/
            if (Main.rand.Next(3) == 0)
            {
                int dust2 = Dust.NewDust(player.Center, player.width, player.height, 226, 0f, 0f, 100, Color.Black);
                Main.dust[dust2].velocity /= 10f;
                Main.dust[dust2].scale     = 1f;
            }
            if (player.buffTime[buffIndex] > 0 && modPlayer.ShadeCure >= 1)
            {
                player.buffTime[buffIndex] = 0;
            }
            if (player.buffTime[buffIndex] <= 1 && modPlayer.ShadeCure < 1)
            {
                player.statLife = 0;
                for (int i = 0; i < 15; i++)
                {
                    Dust.NewDust(player.position, player.width, player.height, 14, 0f, 0f, 0, new Color(255, 0, 0));
                }
                //Main.PlaySound(2, player.position, 27); //crystal smash
                //Main.PlaySound(2, player.position, 45); //inferno fork
                //Main.PlaySound(2, player.position, 46); //hydra summon
                //Main.PlaySound(2, player.position, 104); //shadowflame?
                Main.PlaySound(2, player.position, 119);                 //phantasm dragon roar
                //Main.PlaySound(4, player.position, 6); //etherial gasp
                //Main.PlaySound(4, player.position, 39); //spectre
                //Main.PlaySound(4, player.position, 51); //reaper
                Main.PlaySound(5, player.position, 1);                //normal death
                //Main.PlaySound(2, player.position, 103);//shadowflame hex doll
                //player.dead = true;
                Terraria.DataStructures.PlayerDeathReason YUdie = new Terraria.DataStructures.PlayerDeathReason();
                YUdie.SourceCustomReason = player.name + " was edgy.";
                player.KillMe(YUdie, player.statLife, 0);
                player.respawnTimer = 300;
            }
        }
Esempio n. 4
0
        private void NetHooks_GetData(GetDataEventArgs args)
        {
            if (args.MsgID == PacketTypes.PlayerDeathV2)
            {
                args.Msg.reader.BaseStream.Position = args.Index;
                int    playerID = args.Msg.whoAmI;
                var    p        = Main.player[playerID];
                string whyudie  = "";
                using (var reader = new BinaryReader(new MemoryStream(args.Msg.readBuffer, args.Index, args.Length)))
                {
                    byte victimid = reader.ReadByte();

                    Terraria.DataStructures.PlayerDeathReason reason = Terraria.DataStructures.PlayerDeathReason.FromReader(reader);
                    whyudie = Convert.ToString(reason.GetDeathText(p.name));
                }

                var deathlogadd = DeathDropLog.Query("INSERT INTO PlayerDeathLog (Time, Account, WorldID, Message, LocationX, LocationY) VALUES (@0, @1, @2, @3, @4, @5);", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), p.name, Main.worldID, whyudie, p.position.X / 16, p.position.Y / 16);
                if (p.difficulty != 0 || !TShock.ServerSideCharacterConfig.Enabled)
                {
                    return;
                }
                StringBuilder notice = new StringBuilder();
                switch (config.UseDropWay)
                {
                case 1:
                {
                    Drop1AndAppendNotice(Main.player[playerID], Main.player[playerID].inventory, config.ItemDropAmount, notice, 0);
                    Drop1AndAppendNotice(Main.player[playerID], Main.player[playerID].armor, config.EquipDropAmount, notice, 59);
                    Drop1AndAppendNotice(Main.player[playerID], Main.player[playerID].miscEquips, config.MiscDropAmount, notice, 89);
                    break;
                }

                case 2:
                {
                    Drop2AndAppendNotice(Main.player[playerID], Main.player[playerID].inventory, config.ItemDropAmount, notice, 0);
                    Drop2AndAppendNotice(Main.player[playerID], Main.player[playerID].armor, config.EquipDropAmount, notice, 59);
                    Drop2AndAppendNotice(Main.player[playerID], Main.player[playerID].miscEquips, config.MiscDropAmount, notice, 89);
                    break;
                }
                }
                if (notice.Length >= 3)
                {
                    notice.Append(" was dropped from your inventory!");
                    NetMessage.SendChatMessageToClient(NetworkText.FromLiteral(notice.ToString()), Color.Red, playerID);
                }
            }
        }
Esempio n. 5
0
        public override void Run()
        {
            var vanilla = this.Method(() => (new Terraria.Player()).Hurt(null, 0, 0, false, false, false, 0));

            int    tmp  = 0;
            bool   tmp1 = false;
            string tmp2 = null;
            double tmp3 = 0;

            Terraria.DataStructures.PlayerDeathReason tmp4 = null;
            var cbkBegin =             //this.SourceDefinition.MainModule.Import(
                           this.Method(() => OTAPI.Callbacks.Terraria.Player.HurtBegin(ref tmp3, null, ref tmp4, ref tmp, ref tmp, ref tmp1, ref tmp1, ref tmp2, ref tmp1, ref tmp));

            //);

            vanilla.InjectNonVoidBeginCallback(cbkBegin);
        }
Esempio n. 6
0
        private void onGetData(GetDataEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            TSPlayer sender = TShock.Players[e.Msg.whoAmI];

            if (sender == null)
            {
                return;
            }

            switch (e.MsgID)
            {
            case PacketTypes.NpcStrike:
            {
                using (var reader = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length)))
                {
                    short npcid     = reader.ReadInt16();
                    short damage    = reader.ReadInt16();
                    float knockback = reader.ReadSingle();
                    byte  dir       = reader.ReadByte();
                    bool  crit      = reader.ReadBoolean();

                    NPC npc = TShock.Utils.GetNPCById(npcid);

                    if (npc == null)
                    {
                        return;
                    }

                    var pinfo = players.FirstOrDefault(x => x.Player.User.ID == sender.User.ID);

                    if (pinfo == null)
                    {
                        return;
                    }

                    if ((npc.life - damage) < 0)
                    {
                        pinfo.Kills += 1;
                        return;
                    }
                }
                break;
            }

            case PacketTypes.PlayerDeathV2:
            {
                using (var reader = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length)))
                {
                    byte victimid = reader.ReadByte();

                    Terraria.DataStructures.PlayerDeathReason reason = Terraria.DataStructures.PlayerDeathReason.FromReader(reader);

                    TSPlayer victim = TShock.Players[victimid];

                    var pinfo = players.FirstOrDefault(x => x.Player.Name == victim.Name);

                    if (pinfo == null)
                    {
                        return;
                    }

                    pinfo.Deaths += 1;

                    if (reason.SourcePlayerIndex != -1)
                    {
                        TSPlayer killer = TShock.Players[reason.SourcePlayerIndex];
                        var      pkinfo = players.FirstOrDefault(x => x.Player.Name == killer.Name);

                        if (pkinfo == null)
                        {
                            return;
                        }

                        pkinfo.Kills += 1;
                    }
                }
                break;
            }
            }
        }