Terraria v1.4.4.9
Terraria 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 36665 of file Player.cs.

36666 {
36667 if (creativeGodMode || dead)
36668 {
36669 return;
36670 }
36672 if (pvp)
36673 {
36674 pvpDeath = true;
36675 }
36676 if (trapDebuffSource)
36677 {
36679 }
36681 {
36683 }
36684 if (whoAmI == Main.myPlayer)
36685 {
36686 Main.NotifyOfEvent(GameNotificationType.SpawnOrDeath);
36687 }
36688 if (pvpDeath)
36689 {
36691 }
36692 else
36693 {
36695 }
36696 lastDeathPostion = base.Center;
36698 showLastDeath = true;
36699 bool overFlowing;
36700 long coinsOwned = Utils.CoinsCount(out overFlowing, inventory);
36701 if (Main.myPlayer == whoAmI)
36702 {
36704 lostCoinString = Main.ValueToCoins(lostCoins);
36705 }
36706 if (Main.myPlayer == whoAmI)
36707 {
36709 }
36710 if (Main.myPlayer == whoAmI)
36711 {
36712 Main.mapFullscreen = false;
36713 }
36714 if (Main.myPlayer == whoAmI)
36715 {
36717 if (difficulty == 0 || difficulty == 3)
36718 {
36719 for (int i = 0; i < 59; i++)
36720 {
36721 if (inventory[i].stack > 0 && ((inventory[i].type >= 1522 && inventory[i].type <= 1527) || inventory[i].type == 3643))
36722 {
36723 int num = Item.NewItem(GetItemSource_Death(), (int)position.X, (int)position.Y, width, height, inventory[i].type);
36724 Main.item[num].netDefaults(inventory[i].netID);
36725 Main.item[num].Prefix(inventory[i].prefix);
36726 Main.item[num].stack = inventory[i].stack;
36727 Main.item[num].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
36728 Main.item[num].velocity.X = (float)Main.rand.Next(-20, 21) * 0.2f;
36729 Main.item[num].noGrabDelay = 100;
36730 Main.item[num].favorited = false;
36731 Main.item[num].newAndShiny = false;
36732 if (Main.netMode == 1)
36733 {
36734 NetMessage.SendData(21, -1, -1, null, num);
36735 }
36737 }
36738 }
36739 }
36740 else if (difficulty == 1)
36741 {
36742 DropItems();
36743 }
36744 else if (difficulty == 2)
36745 {
36746 DropItems();
36747 KillMeForGood();
36748 }
36749 }
36750 if (Main.dontStarveWorld || Main.tenthAnniversaryWorld)
36751 {
36753 }
36754 else
36755 {
36756 SoundEngine.PlaySound(5, (int)position.X, (int)position.Y);
36757 }
36758 if (Main.tenthAnniversaryWorld)
36759 {
36760 for (int j = 0; j < 85; j++)
36761 {
36762 int type = Main.rand.Next(139, 143);
36763 int num2 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, type, 0f, -10f, 0, default(Color), 1.2f);
36764 Main.dust[num2].velocity.X += (float)Main.rand.Next(-50, 51) * 0.01f;
36765 Main.dust[num2].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.01f;
36766 Main.dust[num2].velocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
36767 Main.dust[num2].velocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
36768 Main.dust[num2].velocity.X += (float)Main.rand.Next(-50, 51) * 0.05f;
36769 Main.dust[num2].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.05f;
36770 Main.dust[num2].scale *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
36771 }
36772 for (int k = 0; k < 40; k++)
36773 {
36774 int type2 = Main.rand.Next(276, 283);
36775 int num3 = Gore.NewGore(position, new Vector2(0f, -10f), type2);
36776 Main.gore[num3].velocity.X += (float)Main.rand.Next(-50, 51) * 0.01f;
36777 Main.gore[num3].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.01f;
36778 Main.gore[num3].velocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
36779 Main.gore[num3].velocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
36780 Main.gore[num3].scale *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
36781 Main.gore[num3].velocity.X += (float)Main.rand.Next(-50, 51) * 0.05f;
36782 Main.gore[num3].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.05f;
36783 }
36784 }
36785 headVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
36786 bodyVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
36787 legVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
36788 headVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
36789 bodyVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
36790 legVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
36791 if (stoned)
36792 {
36796 }
36797 for (int l = 0; l < 100; l++)
36798 {
36799 if (stoned)
36800 {
36801 Dust.NewDust(position, width, height, 1, 2 * hitDirection, -2f);
36802 }
36803 else if (frostArmor)
36804 {
36805 int num4 = Dust.NewDust(position, width, height, 135, 2 * hitDirection, -2f);
36806 Main.dust[num4].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
36807 }
36808 else if (boneArmor)
36809 {
36810 int num5 = Dust.NewDust(position, width, height, 26, 2 * hitDirection, -2f);
36811 Main.dust[num5].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
36812 }
36813 else
36814 {
36815 Dust.NewDust(position, width, height, 5, 2 * hitDirection, -2f);
36816 }
36817 }
36818 mount.Dismount(this);
36819 dead = true;
36821 immuneAlpha = 0;
36822 if (!ChildSafety.Disabled)
36823 {
36824 immuneAlpha = 255;
36825 }
36826 palladiumRegen = false;
36827 iceBarrier = false;
36828 crystalLeaf = false;
36829 NetworkText deathText = damageSource.GetDeathText(name);
36830 if (Main.netMode == 2)
36831 {
36833 }
36834 else if (Main.netMode == 0)
36835 {
36836 Main.NewText(deathText.ToString(), 225, 25, 25);
36837 }
36838 if (Main.netMode == 1 && whoAmI == Main.myPlayer)
36839 {
36840 NetMessage.SendPlayerDeath(whoAmI, damageSource, (int)dmg, hitDirection, pvp);
36841 }
36842 if (whoAmI == Main.myPlayer && (difficulty == 0 || difficulty == 3))
36843 {
36844 if (!pvp)
36845 {
36846 DropCoins();
36847 }
36848 else
36849 {
36850 lostCoins = 0L;
36851 lostCoinString = Main.ValueToCoins(lostCoins);
36852 }
36853 }
36855 if (whoAmI != Main.myPlayer)
36856 {
36857 return;
36858 }
36859 try
36860 {
36861 WorldGen.saveToonWhilePlaying();
36862 }
36863 catch
36864 {
36865 }
36866 }
static void PlaySound(int type, Vector2 position, int style=1)
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:46
Vector2 position
Definition Entity.cs:14
static void HandleSpecialEvent(Player player, int eventID)
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static readonly LegacySoundStyle DSTMaleHurt
Definition SoundID.cs:986
int stack
Definition Item.cs:149
void SetDefaults(int Type=0)
Definition Item.cs:47332
void Dismount(Player mountedPlayer)
Definition Mount.cs:5229
DateTime lastDeathTime
Definition Player.cs:641
string name
Definition Player.cs:621
void DropItems()
Definition Player.cs:50809
bool palladiumRegen
Definition Player.cs:929
int GetRespawnTime(bool pvp)
Definition Player.cs:36868
int _framesLeftEligibleForDeadmansChestDeathAchievement
Definition Player.cs:1045
Vector2 bodyPosition
Definition Player.cs:1281
int numberOfDeathsPVE
Definition Player.cs:629
int ArmorSetDye()
Definition Player.cs:9255
bool creativeGodMode
Definition Player.cs:1529
bool trapDebuffSource
Definition Player.cs:2003
void EndOngoingTorchGodEvent()
Definition Player.cs:17399
IEntitySource GetItemSource_Death()
Definition Player.cs:9282
Vector2 lastDeathPostion
Definition Player.cs:639
void DropTombstone(long coinsOwned, NetworkText deathText, int hitDirection)
Definition Player.cs:36910
long DropCoins()
Definition Player.cs:50750
Vector2 legPosition
Definition Player.cs:1283
void StopVanityActions(bool multiplayerBroadcast=true)
Definition Player.cs:31204
bool showLastDeath
Definition Player.cs:643
int numberOfDeathsPVP
Definition Player.cs:631
Vector2 headPosition
Definition Player.cs:1279
bool iceBarrier
Definition Player.cs:891
void KillMeForGood()
Definition Player.cs:36647
Item[] inventory
Definition Player.cs:1257
string lostCoinString
Definition Player.cs:603
static DateTime Now
Definition DateTime.cs:103

References Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.Utils.CoinsCount(), Terraria.GameContent.ChildSafety.Disabled, Terraria.Main.dontStarveWorld, Terraria.ID.SoundID.DSTFemaleHurt, Terraria.ID.SoundID.DSTMaleHurt, Terraria.Main.dust, Terraria.Main.gore, Terraria.GameContent.Achievements.AchievementsHelper.HandleSpecialEvent(), Terraria.Main.item, System.L, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Dust.NewDust(), Terraria.Gore.NewGore(), Terraria.Item.NewItem(), Terraria.Main.NewText(), Terraria.Main.NotifyOfEvent(), System.DateTime.Now, Terraria.Audio.SoundEngine.PlaySound(), System.prefix, Terraria.Main.rand, Terraria.WorldGen.saveToonWhilePlaying(), Terraria.NetMessage.SendData(), Terraria.NetMessage.SendPlayerDeath(), Terraria.Item.SetDefaults(), Terraria.Item.stack, Terraria.Main.tenthAnniversaryWorld, System.type, Terraria.Item.type, Terraria.Main.ValueToCoins(), and Microsoft.Xna.Framework.Vector2.Zero.