tModLoader v2024.11
A mod to make and play Terraria mods
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 (string reasonInEnglish)
 
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 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