1. 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.
    Dismiss Notice
  2. 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.
    Dismiss Notice

tModLoader Custom Weapon Types

Discussion in 'General Mod Discussion' started by Daddy Bowser, Jul 13, 2017.

  1. Daddy Bowser

    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?
     
  2. Pop000100

    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)
     
  3. Daddy Bowser

    Daddy Bowser Terrarian

    Sadly, as far as I know, Thorium is closed source so I can't use any of the code from that as reference.
     
  4. Jofairden

    Jofairden Golem

    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 likes this.
  5. Daddy Bowser

    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: Jul 17, 2017
  6. Crysmax00D2FF

    Crysmax00D2FF Skeletron Prime

    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.