tModLoader Custom Weapon Types

Daddy Bowser

Terrarian
I've been looking all day for specific information about creating different types of weapon damage, however I can't find anything definitive that actually explains how I would go about doing this. In terms of actually creating the damage I think I have a few ideas, but I'm clueless on how it would display said damage on the tooltip nor am I particularly certain about it.

I've tried looking at a number of examples, but it seems like this has only been implemented in closed-source mods. Anyone have some advice leading me in the right direction?
 
so in Thorium throwing damage is a coded as a ranged weapon that is using code to mask that(learned this reading replies to bug reports)
 
Let me go ahaid and just say that most mods that have 'custom' damage types do not really implement it correctly.
There's a few things you need:
  • A custom damage modifier in ModPlayer (float myDamageModifier)
  • (Preferably) a base (abstract) class for weapons with your custom damage type
  • Use the GetWeaponDamage() and ModifyTooltips() hooks
    • With GetWeaponDamage(), you can simply multiply the damage parameter with the modifier in your ModPlayer
    • With ModifyTooltips(), you should probably replace the vanilla damage tooltip with your own
  • Furthermore, make sure the vanilla damage bools are set to false: melee, summon, magic, ranged
 
Ah OK, ModifyTooltips was one of the functions I was eyeing, but I didn't see a lot of info so I didn't look into it too much. The rest is also very helpful, thank you very much!.

Edit: This was all way easier than I thought it'd be, was just overthinking it a lot. Thanks for steering me in the right direction.

Edit2: I noticed that the source for Tremor was out and took a look to see what they did, it seems it's structure is in line with your bullets. I'm curious, @Jofairden, do you think Tremor also implements them incorrectly? If so, I would like to hear what would be a more effective way of coding it.
 
Last edited:
Let me go ahaid and just say that most mods that have 'custom' damage types do not really implement it correctly.
There's a few things you need:
  • A custom damage modifier in ModPlayer (float myDamageModifier)
  • (Preferably) a base (abstract) class for weapons with your custom damage type
  • Use the GetWeaponDamage() and ModifyTooltips() hooks
    • With GetWeaponDamage(), you can simply multiply the damage parameter with the modifier in your ModPlayer
    • With ModifyTooltips(), you should probably replace the vanilla damage tooltip with your own
  • Furthermore, make sure the vanilla damage bools are set to false: melee, summon, magic, ranged
Hello, could you please send me a portion of your code? I'm trying to make custom damage types but I'm not really sure what to do, as I know very little about C#. If you could show me what your's looked like so I had an idea of how to make mine, that would be fantastic.
 
Back
Top Bottom