Permalink![Dmg Dmg](https://s1.dmcdn.net/v/A3U0A1LRS8nRJxW56/x1080)
Join GitHub today
This page was last edited on 10 April 2019, at 21:17. Content is available under CC BY-NC-SA 3.0 unless otherwise noted. Game content and materials are trademarks and copyrights of their respective publisher and its licensors. The problem appears in the wiki, where weapons started calculating stats from gear+prefix in their display,making much fake information in some weapon stats. In example weapon that have x dmg and y rate got in wiki info x+gear dmg and y+gear crit rate instead of the base. Titanium Helmet: +16% ranged damage, +7% ranged critical strike probability. This site is not affiliated with Terraria, Re-Logic, the game developer, or the game publisher. All game content and materials are trademarks and copyrights of their respective owners and licensors. We do not assert any claim of copyright for Terraria.
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Terraria Crit Vs Damage
Sign up Find file Copy path
Cannot retrieve contributors at this time
Terraria Crit Build
usingMicrosoft.Xna.Framework; |
usingTerraria; |
usingTerraria.ID; |
usingstaticTerraria.ModLoader.ModContent; |
namespaceExampleMod.Items.ExampleDamageClass |
{ |
publicclassMundane : ExampleDamageItem |
{ |
publicoverridestringTexture=>'Terraria/Item_'+ItemID.HellwingBow; |
// Called when the mod loads, so our changes are added to the game |
publicstaticvoidAddHacks() |
{ |
// Set ourselves to be ranged temporarily to benefit from ranged bonuses |
// This is needed because terraria changes the variables before calling tML's method |
// based on if the item was set to be ranged. Ours isn't, but we still want our custom bow |
// to benefit from ranged bonuses, despite being an Example damage weapon. |
// This is how to do it. |
On.Terraria.Player.GetWeaponDamage+=PlayerOnGetWeaponDamage; |
On.Terraria.Player.GetWeaponKnockback+=PlayerOnGetWeaponKnockback; |
} |
privatestaticfloatPlayerOnGetWeaponKnockback(On.Terraria.Player.orig_GetWeaponKnockbackorig, Playerself, Itemsitem, floatknockback) |
{ |
boolisMundane=sitem.typeItemType<Mundane>(); |
if (isMundane)sitem.ranged=true; |
floatkb=orig(self, sitem, knockback); |
if (isMundane) sitem.ranged=false; |
returnkb; |
} |
privatestaticintPlayerOnGetWeaponDamage(On.Terraria.Player.orig_GetWeaponDamageorig, Playerself, Itemsitem) |
{ |
boolisMundane=sitem.typeItemType<Mundane>(); |
if (isMundane) sitem.ranged=true; |
intdmg=orig(self, sitem); |
if (isMundane) sitem.ranged=false; |
returndmg; |
} |
// Our ExampleDamageItem abstract class handles all code related to our custom damage class |
publicoverridevoidSafeSetDefaults() |
{ |
item.CloneDefaults(ItemID.WoodenBow); |
item.Size=newVector2(18, 46); |
item.damage=20; |
item.crit=20; |
item.knockBack=2; |
item.rare=10; |
} |
publicoverridevoidGetWeaponCrit(Playerplayer, refintcrit) |
{ |
// It is hard to hook into every place checking item's crit and fake item.ranged = true |
// Instead, we can mimick regular ranged crit assignment |
crit=Main.LocalPlayer.rangedCrit-Main.LocalPlayer.inventory[Main.LocalPlayer.selectedItem].crit+Main.HoverItem.crit; |
base.GetWeaponCrit(player, refcrit); |
} |
} |
} |
Copy lines Copy permalink