tModLoader v2025.03
A mod to make and play Terraria mods
All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
PlayerDeathReason Class Reference

Public Member Functions

NetworkText GetDeathText (string deadPlayerName)
 
bool TryGetCausingEntity (out Entity entity)
 Only safe for use when the local player is the one taking damage!
Projectile ids are not synchronized across clients, and NPCs may have despawned/died by the time a strike/death packet arrives.
Just because the method returns true, doesn't mean that the correct NPC/Projectile is returned on remote clients. More...
 
void WriteSelfTo (BinaryWriter writer)
 

Static Public Member Functions

static PlayerDeathReason ByCustomReason (NetworkText reason)
 A localized custom death message. Each client will see the death message in their own language, unlike with ByCustomReason(string). Text substitutions can be provided by using LocalizedText.ToNetworkText(object[]) or NetworkText.FromKey(string, object[]).
 
static PlayerDeathReason ByCustomReason (string reasonInEnglish)
 A custom death message. This overload does not support localization, all players will see the same text regardless of their language settings. Use ByCustomReason(NetworkText) instead for localization support.
 
static PlayerDeathReason ByNPC (int index)
 
static PlayerDeathReason ByOther (int type, int playerIndex=-1)
 
static PlayerDeathReason ByPlayerItem (int index, Item item)
 
static PlayerDeathReason ByProjectile (int playerIndex, int projectileIndex)
 
static PlayerDeathReason FromReader (BinaryReader reader)
 
static PlayerDeathReason LegacyDefault ()
 
static PlayerDeathReason LegacyEmpty ()
 

Properties

ref NetworkText CustomReason [get]
 
ref string SourceCustomReason [get]
 
ref Item SourceItem [get]
 
ref int SourceNPCIndex [get]
 
ref int SourceOtherIndex [get]
 
ref int SourcePlayerIndex [get]
 
ref int SourceProjectileLocalIndex [get]
 
ref int SourceProjectileType [get]
 

Member Function Documentation

◆ TryGetCausingEntity()

bool PlayerDeathReason.TryGetCausingEntity ( out Entity  entity)

Only safe for use when the local player is the one taking damage!
Projectile ids are not synchronized across clients, and NPCs may have despawned/died by the time a strike/death packet arrives.
Just because the method returns true, doesn't mean that the correct NPC/Projectile is returned on remote clients.

Parameters
entity
Returns