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

◆ ToHitInfo()

HitInfo Terraria.NPC.HitModifiers.ToHitInfo ( float baseDamage,
bool crit,
float baseKnockback,
bool damageVariation = false,
float luck = 0f )
inline

Definition at line 319 of file NPC.cs.

320 {
321 HitInfo hitInfo2 = new HitInfo();
322 hitInfo2.DamageType = DamageType ?? DamageClass.Default;
323 hitInfo2.SourceDamage = Math.Max((int)SourceDamage.ApplyTo(baseDamage), 1);
324 hitInfo2.Damage = (_instantKill ? 1 : GetDamage(baseDamage, crit, damageVariation, luck));
325 hitInfo2.Crit = _critOverride ?? crit;
326 hitInfo2.Knockback = GetKnockback(baseKnockback);
327 hitInfo2.HitDirection = HitDirectionOverride ?? HitDirection;
328 hitInfo2.InstantKill = _instantKill;
329 hitInfo2.HideCombatText = _combatTextHidden;
330 HitInfo hitInfo = hitInfo2;
331 this.ModifyHitInfo?.Invoke(ref hitInfo);
332 this.ModifyHitInfo = null;
333 return hitInfo;
334 }
static DamageClass Default
Default damage class for non-classed weapons and items, does not benefit from Generic bonuses.
T:Terraria.ModLoader.DamageClass is used to determine the application of item effects,...
float ApplyTo(float baseValue)
Use this to apply the modifiers of this T:Terraria.ModLoader.StatModifier to the baseValue ....
StatModifier SourceDamage
Use this to enhance or scale the base damage of the item/projectile/hit. This damage modifier will ap...
Definition NPC.cs:66
HitInfoModifier ModifyHitInfo
Use with caution and consider other alternatives first. Can be used to register a callback to freely...
Definition NPC.cs:210
int HitDirection
The direction to apply knockback. If 0, no knockback will be applied. Could potentially be used for...
Definition NPC.cs:189
DamageClass DamageType
The DamageType of the hit.
Definition NPC.cs:182
int? HitDirectionOverride
Overrides the direction to apply knockback. Will not affect P:Terraria.NPC.HitModifiers....
Definition NPC.cs:203
readonly float GetKnockback(float baseKnockback)
Definition NPC.cs:314
readonly int GetDamage(float baseDamage, bool crit, bool damageVariation=false, float luck=0f)
Definition NPC.cs:286

References Terraria.NPC.HitModifiers._combatTextHidden, Terraria.NPC.HitModifiers._critOverride, Terraria.NPC.HitModifiers._instantKill, Terraria.ModLoader.StatModifier.ApplyTo(), Terraria.NPC.HitModifiers.DamageType, Terraria.ModLoader.DamageClass.Default, Terraria.NPC.HitModifiers.GetDamage(), Terraria.NPC.HitModifiers.GetKnockback(), Terraria.NPC.HitModifiers.HitDirection, Terraria.NPC.HitModifiers.HitDirectionOverride, and Terraria.NPC.HitModifiers.SourceDamage.

+ Here is the call graph for this function: