TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ KillMe()

void Terraria.Player.KillMe ( PlayerDeathReason damageSource,
double dmg,
int hitDirection,
bool pvp = false )
inline

Definition at line 37626 of file Player.cs.

37627 {
37628 //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
37629 //IL_00a7: Unknown result type (might be due to invalid IL or missing references)
37630 //IL_07b1: Unknown result type (might be due to invalid IL or missing references)
37631 //IL_07b6: Unknown result type (might be due to invalid IL or missing references)
37632 //IL_07bc: Unknown result type (might be due to invalid IL or missing references)
37633 //IL_07c1: Unknown result type (might be due to invalid IL or missing references)
37634 //IL_07c7: Unknown result type (might be due to invalid IL or missing references)
37635 //IL_07cc: Unknown result type (might be due to invalid IL or missing references)
37636 //IL_03c9: Unknown result type (might be due to invalid IL or missing references)
37637 //IL_03e9: Unknown result type (might be due to invalid IL or missing references)
37638 //IL_03ef: Unknown result type (might be due to invalid IL or missing references)
37639 //IL_034e: Unknown result type (might be due to invalid IL or missing references)
37640 //IL_0568: Unknown result type (might be due to invalid IL or missing references)
37641 //IL_0577: Unknown result type (might be due to invalid IL or missing references)
37642 //IL_0998: Unknown result type (might be due to invalid IL or missing references)
37643 //IL_07e8: Unknown result type (might be due to invalid IL or missing references)
37644 //IL_0806: Unknown result type (might be due to invalid IL or missing references)
37645 //IL_080c: Unknown result type (might be due to invalid IL or missing references)
37646 //IL_0827: Unknown result type (might be due to invalid IL or missing references)
37647 //IL_0849: Unknown result type (might be due to invalid IL or missing references)
37648 //IL_084f: Unknown result type (might be due to invalid IL or missing references)
37649 //IL_08dd: Unknown result type (might be due to invalid IL or missing references)
37650 //IL_08fb: Unknown result type (might be due to invalid IL or missing references)
37651 //IL_0901: Unknown result type (might be due to invalid IL or missing references)
37652 //IL_0889: Unknown result type (might be due to invalid IL or missing references)
37653 //IL_08a8: Unknown result type (might be due to invalid IL or missing references)
37654 //IL_08ae: Unknown result type (might be due to invalid IL or missing references)
37655 if (creativeGodMode || dead)
37656 {
37657 return;
37658 }
37660 bool playSound = true;
37661 bool genGore = true;
37663 {
37664 return;
37665 }
37666 if (pvp)
37667 {
37668 pvpDeath = true;
37669 }
37670 if (trapDebuffSource)
37671 {
37673 }
37675 {
37677 }
37678 if (whoAmI == Main.myPlayer)
37679 {
37680 Main.NotifyOfEvent(GameNotificationType.SpawnOrDeath);
37681 }
37682 if (pvpDeath)
37683 {
37685 }
37686 else
37687 {
37689 }
37690 lastDeathPostion = base.Center;
37691 lastDeathTime = DateTime.Now;
37692 showLastDeath = true;
37693 bool overFlowing;
37694 long coinsOwned = Utils.CoinsCount(out overFlowing, inventory);
37695 if (Main.myPlayer == whoAmI)
37696 {
37698 lostCoinString = Main.ValueToCoins(lostCoins);
37699 }
37700 if (Main.myPlayer == whoAmI)
37701 {
37703 }
37704 if (Main.myPlayer == whoAmI)
37705 {
37706 Main.mapFullscreen = false;
37707 }
37708 if (Main.myPlayer == whoAmI)
37709 {
37711 if (difficulty == 0 || difficulty == 3)
37712 {
37713 for (int i = 0; i < 59; i++)
37714 {
37715 if (inventory[i].stack > 0 && ((inventory[i].type >= 1522 && inventory[i].type <= 1527) || inventory[i].type == 3643))
37716 {
37717 int num = Item.NewItem(GetItemSource_Death(), (int)position.X, (int)position.Y, width, height, inventory[i].type);
37718 Main.item[num].netDefaults(inventory[i].netID);
37719 Main.item[num].Prefix(inventory[i].prefix);
37720 Main.item[num].stack = inventory[i].stack;
37721 Main.item[num].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
37722 Main.item[num].velocity.X = (float)Main.rand.Next(-20, 21) * 0.2f;
37723 Main.item[num].noGrabDelay = 100;
37724 Main.item[num].favorited = false;
37725 Main.item[num].newAndShiny = false;
37726 if (Main.netMode == 1)
37727 {
37728 NetMessage.SendData(21, -1, -1, null, num);
37729 }
37731 }
37732 }
37733 }
37734 else if (difficulty == 1)
37735 {
37736 DropItems();
37737 }
37738 else if (difficulty == 2)
37739 {
37740 DropItems();
37741 KillMeForGood();
37742 }
37743 }
37744 if (playSound)
37745 {
37746 if (Main.dontStarveWorld || Main.tenthAnniversaryWorld)
37747 {
37748 SoundStyle style = (Male ? SoundID.DSTMaleHurt : SoundID.DSTFemaleHurt);
37750 }
37751 else
37752 {
37753 SoundEngine.PlaySound(5, (int)position.X, (int)position.Y);
37754 }
37755 }
37756 if (Main.tenthAnniversaryWorld)
37757 {
37758 for (int j = 0; j < 85; j++)
37759 {
37760 int type = Main.rand.Next(139, 143);
37761 int num2 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, type, 0f, -10f, 0, default(Color), 1.2f);
37762 Main.dust[num2].velocity.X += (float)Main.rand.Next(-50, 51) * 0.01f;
37763 Main.dust[num2].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.01f;
37764 Main.dust[num2].velocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
37765 Main.dust[num2].velocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
37766 Main.dust[num2].velocity.X += (float)Main.rand.Next(-50, 51) * 0.05f;
37767 Main.dust[num2].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.05f;
37768 Main.dust[num2].scale *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
37769 }
37770 for (int k = 0; k < 40; k++)
37771 {
37772 int type2 = Main.rand.Next(276, 283);
37773 int num3 = Gore.NewGore(position, new Vector2(0f, -10f), type2);
37774 Main.gore[num3].velocity.X += (float)Main.rand.Next(-50, 51) * 0.01f;
37775 Main.gore[num3].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.01f;
37776 Main.gore[num3].velocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
37777 Main.gore[num3].velocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
37778 Main.gore[num3].scale *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
37779 Main.gore[num3].velocity.X += (float)Main.rand.Next(-50, 51) * 0.05f;
37780 Main.gore[num3].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.05f;
37781 }
37782 }
37783 headVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
37784 bodyVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
37785 legVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
37786 headVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
37787 bodyVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
37788 legVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
37789 if (stoned || !genGore)
37790 {
37791 headPosition = Vector2.Zero;
37792 bodyPosition = Vector2.Zero;
37793 legPosition = Vector2.Zero;
37794 }
37795 if (genGore)
37796 {
37797 for (int l = 0; l < 100; l++)
37798 {
37799 if (stoned)
37800 {
37801 Dust.NewDust(position, width, height, 1, 2 * hitDirection, -2f);
37802 }
37803 else if (frostArmor)
37804 {
37805 int num4 = Dust.NewDust(position, width, height, 135, 2 * hitDirection, -2f);
37806 Main.dust[num4].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
37807 }
37808 else if (boneArmor)
37809 {
37810 int num5 = Dust.NewDust(position, width, height, 26, 2 * hitDirection, -2f);
37811 Main.dust[num5].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
37812 }
37813 else
37814 {
37815 Dust.NewDust(position, width, height, 5, 2 * hitDirection, -2f);
37816 }
37817 }
37818 }
37819 mount.Dismount(this);
37820 dead = true;
37823 immuneAlpha = 0;
37824 if (!ChildSafety.Disabled)
37825 {
37826 immuneAlpha = 255;
37827 }
37828 palladiumRegen = false;
37829 iceBarrier = false;
37830 crystalLeaf = false;
37831 NetworkText deathText = damageSource.GetDeathText(name);
37832 if (Main.netMode == 2)
37833 {
37834 ChatHelper.BroadcastChatMessage(deathText, new Color(225, 25, 25));
37835 }
37836 else if (Main.netMode == 0)
37837 {
37838 Main.NewText(deathText.ToString(), 225, 25, 25);
37839 }
37840 if (Main.netMode == 1 && whoAmI == Main.myPlayer)
37841 {
37842 NetMessage.SendPlayerDeath(whoAmI, damageSource, (int)dmg, hitDirection, pvp);
37843 }
37844 if (whoAmI == Main.myPlayer && (difficulty == 0 || difficulty == 3))
37845 {
37846 if (!pvp)
37847 {
37848 DropCoins();
37849 }
37850 else
37851 {
37852 lostCoins = 0L;
37853 lostCoinString = Main.ValueToCoins(lostCoins);
37854 }
37855 }
37857 if (whoAmI != Main.myPlayer)
37858 {
37859 return;
37860 }
37861 try
37862 {
37863 WorldGen.saveToonWhilePlaying();
37864 }
37865 catch
37866 {
37867 }
37868 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:51
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static void HandleSpecialEvent(Player player, int eventID)
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static readonly SoundStyle DSTFemaleHurt
Definition SoundID.cs:259
int stack
The current stack of the item. F:Terraria.Item.maxStack indicates the max possible stack.
Definition Item.cs:396
void SetDefaults(int Type=0)
Definition Item.cs:48800
int type
The Item ID of this item. The Item ID is a unique number assigned to each Item loaded into the game....
Definition Item.cs:345
Represents text that will be sent over the network in multiplayer and displayed to the receiving user...
static bool PreKill(Player player, double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
static void Kill(Player player, double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
This is where all ModPlayer hooks are gathered and called.
void Dismount(Player mountedPlayer)
Definition Mount.cs:6357
DateTime lastDeathTime
Definition Player.cs:1053
string name
This player's displayed name. Usually capped at 20 characters.
Definition Player.cs:1033
void DropItems()
Definition Player.cs:54936
bool palladiumRegen
Definition Player.cs:1390
int GetRespawnTime(bool pvp)
Definition Player.cs:37870
int _framesLeftEligibleForDeadmansChestDeathAchievement
Definition Player.cs:1520
Vector2 bodyPosition
Definition Player.cs:1791
int numberOfDeathsPVE
Definition Player.cs:1041
int ArmorSetDye()
Definition Player.cs:7809
bool creativeGodMode
Definition Player.cs:2046
bool trapDebuffSource
Definition Player.cs:2591
void EndOngoingTorchGodEvent()
Definition Player.cs:16160
IEntitySource GetItemSource_Death()
Definition Player.cs:7841
Vector2 lastDeathPostion
Definition Player.cs:1051
void DropTombstone(long coinsOwned, NetworkText deathText, int hitDirection)
Definition Player.cs:37916
long DropCoins()
Definition Player.cs:54877
Vector2 legPosition
Definition Player.cs:1793
Mount mount
This player's T:Terraria.Mount. Do not overwrite this value. Instead, call M:Terraria....
Definition Player.cs:2323
void StopVanityActions(bool multiplayerBroadcast=true)
Definition Player.cs:31655
bool showLastDeath
Definition Player.cs:1055
int numberOfDeathsPVP
Definition Player.cs:1043
Vector2 headPosition
Definition Player.cs:1789
void KillMeForGood()
Definition Player.cs:37599
Item[] inventory
The player's normal inventory. Indexes 0-9 hold the hotbar items, 10-49 the rest of the main inventor...
Definition Player.cs:1767
string lostCoinString
Definition Player.cs:1011
This data type describes in detail how a sound should be played. Passable to the M:Terraria....
Definition SoundStyle.cs:19

References Terraria.Player._framesLeftEligibleForDeadmansChestDeathAchievement, Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.Player.ArmorSetDye(), Terraria.Player.bodyPosition, Terraria.Player.boneArmor, Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.Utils.CoinsCount(), Terraria.Player.creativeGodMode, Terraria.Player.crystalLeaf, Terraria.Player.dead, Terraria.Player.difficulty, Terraria.GameContent.ChildSafety.Disabled, Terraria.Mount.Dismount(), Terraria.Main.dontStarveWorld, Terraria.Player.DropCoins(), Terraria.Player.DropItems(), Terraria.Player.DropTombstone(), Terraria.ID.SoundID.DSTFemaleHurt, Terraria.Main.dust, Terraria.Player.EndOngoingTorchGodEvent(), Terraria.Player.frostArmor, Terraria.Player.GetItemSource_Death(), Terraria.Player.GetRespawnTime(), Terraria.Main.gore, Terraria.GameContent.Achievements.AchievementsHelper.HandleSpecialEvent(), Terraria.Player.headPosition, Terraria.Entity.height, Terraria.Player.iceBarrier, Terraria.Player.immuneAlpha, Terraria.Player.inventory, Terraria.Main.item, Terraria.ModLoader.PlayerLoader.Kill(), Terraria.Player.KillMeForGood(), Terraria.Player.lastDeathPostion, Terraria.Player.lastDeathTime, Terraria.Player.legPosition, Terraria.Player.lostCoins, Terraria.Player.lostCoinString, Terraria.Player.Male, Terraria.Player.mount, Terraria.Main.myPlayer, Terraria.Player.name, Terraria.Main.netMode, Terraria.Dust.NewDust(), Terraria.Gore.NewGore(), Terraria.Item.NewItem(), Terraria.Main.NewText(), Terraria.Main.NotifyOfEvent(), Terraria.Player.numberOfDeathsPVE, Terraria.Player.numberOfDeathsPVP, Terraria.Player.palladiumRegen, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.ModLoader.PlayerLoader.PreKill(), Terraria.Player.pvpDeath, Terraria.Main.rand, Terraria.Player.respawnTimer, Terraria.WorldGen.saveToonWhilePlaying(), Terraria.NetMessage.SendData(), Terraria.NetMessage.SendPlayerDeath(), Terraria.Item.SetDefaults(), Terraria.Player.showLastDeath, Terraria.Item.stack, Terraria.Player.stoned, Terraria.Player.StopVanityActions(), Terraria.Main.tenthAnniversaryWorld, Terraria.Player.trapDebuffSource, Terraria.Player.trashItem, Terraria.Item.type, Terraria.Main.ValueToCoins(), Terraria.Entity.whoAmI, and Terraria.Entity.width.

Referenced by Terraria.Player.BordersMovement(), Terraria.Player.CheckDrowning(), Terraria.Player.Hurt(), Terraria.Player.ItemCheck_UseTeleportRod(), Terraria.Player.UpdateLifeRegen(), and Terraria.Player.WOFTongue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: