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

◆ ApplyStatsFromSource()

void Terraria.Projectile.ApplyStatsFromSource ( IEntitySource spawnSource)
inline

Transfers stat modifiers from the spawn source to the projectile.
Adds P:Terraria.Projectile.CritChance and P:Terraria.Projectile.ArmorPenetration bonuses from players (T:Terraria.DataStructures.EntitySource_Parent), weapons (T:Terraria.DataStructures.EntitySource_ItemUse)
If the source is a T:Terraria.DataStructures.EntitySource_Parent projectile, CritChance and ArmorPenetration from the parent will be added, in order to transfer the original item/player bonus values.


To support minions, sentries and P:Terraria.Projectile.ContinuouslyUpdateDamageStats, P:Terraria.Projectile.OriginalCritChance and P:Terraria.Projectile.OriginalArmorPenetration are also copied from item sources and parent projectiles.

Parameters
spawnSource

Definition at line 93095 of file Projectile.cs.

93096 {
93100 if (spawnSource is EntitySource_Parent { Entity: Player player })
93101 {
93103 {
93104 Item item = entitySource_WithStatsFromItem.Item;
93105 if (item != null)
93106 {
93107 CritChance += player.GetWeaponCrit(item);
93108 ArmorPenetration += player.GetWeaponArmorPenetration(item);
93109 if (item.damage >= 0)
93110 {
93111 originalDamage = item.damage;
93112 }
93113 OriginalCritChance += item.crit;
93114 OriginalArmorPenetration += item.ArmorPenetration;
93115 return;
93116 }
93117 }
93118 CritChance += (int)(player.GetTotalCritChance(DamageType) + 5E-06f);
93119 ArmorPenetration += (int)(player.GetTotalArmorPenetration(DamageType) + 5E-06f);
93120 }
93121 else if (spawnSource is EntitySource_Parent { Entity: Projectile parentProjectile })
93122 {
93123 CritChance += parentProjectile.CritChance;
93124 ArmorPenetration += parentProjectile.ArmorPenetration;
93125 OriginalCritChance += parentProjectile.OriginalCritChance;
93126 OriginalArmorPenetration += parentProjectile.OriginalArmorPenetration;
93127 }
93128 }
Use when the parent can be considered the 'owner' or 'responsible for' the effect....
int damage
This will always be set in Projectile.NewProjectile based on the weapons damage and player stat modif...
int OriginalCritChance
The crit chance of this projectile, without any player bonuses, similar to F:Terraria....
int ArmorPenetration
The number of defense points that this projectile can ignore on its own. Cannot be set to negative va...
int CritChance
The critical strike chance modifier of this projectile. Cannot be set to negative values....
int OriginalArmorPenetration
The crit chance of this projectile, without any player bonuses, similar to F:Terraria....
DamageClass DamageType
The damage type assigned to this projectile, represented as a DamageClass. Leave blank or use DamageC...
Used along with T:Terraria.DataStructures.EntitySource_Parent to indicate that stats from the item sh...

References Terraria.Item.ArmorPenetration, Terraria.Item.crit, and Terraria.Item.damage.

Referenced by Terraria.Projectile.NewProjectile().

+ Here is the caller graph for this function: