How do you change vanilla item damage type?

reboot404iw

Terrarian
I am very new to modding, and I was wondering if anyone could tell me how I could make an accessory that changes the damage type of weapons to a different one?
 
I am very new to modding, and I was wondering if anyone could tell me how I could make an accessory that changes the damage type of weapons to a different one?
Make a class inheriting a GlobalItem, override the SetDefaults method, make a conditional checking if the item's type is the same as the item you want to modify, then set the item's actual damage bool to false and set the other one to true.

Example:

C#:
public class Example : GlobalItem {
    public override void SetDefaults(Item item) {
        if (item.type == ItemID.IronPickaxe) {
            item.melee = false;
            item.ranged = true;
        }
    }
}
 
That looks like I would have to change the damage type of every item individually. I am trying to make something that automatically changes all items' damage types to just one.
 
That looks like I would have to change the damage type of every item individually. I am trying to make something that automatically changes all items' damage types to just one.
C#:
public class Example : GlobalItem {
    public override void SetDefaults(Item item) {
        item.melee = true;
        item.ranged = false;
        item.magic = false;
        item.thrown = false;
        item.summon = false;
    }
}
This would set all items to melee.
 
He wants to make an accessory that changes the damage type of weapons WHEN EQUIPPED. Not just blanket bomb all items
 
Here is me asking on the official tModLoader discord
1607950352062.png
 
Would it be possible to change using a buff that is applied by an accessory?
You'd have to loop through the player's inventory and manually change variables in some update hook.

It is entirely possible, Dire just gave the most basic answer (seeing as there's no direct hook for item variable modification based on something like a buff or accessory).
 
Back
Top Bottom