• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

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?
 

Pop000100

Terrarian
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)
 

Jofairden

Duke Fishron
tModLoader
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
 

Daddy Bowser

Terrarian
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:

Crysmax00D2FF

Skeletron Prime
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.
 
Top Bottom