Hey folks,
noob user here.
I have c# experience, but had never tried modding Terraria before. Gotta say, I was surprised how easy it was to make some basic items (with tmodloader's api) just with a few keywords and the item.CloneDefaults() method. I made a few basic things like new claws (Baghnakhs clone), different endless ammo bags (i think other mods have them as well.) Anyway, I have a few questions I was hoping anyone might be able to answer:
#1: I want my Greatsword weapon to increase the weapon's damage when the player isn't wearing a shirt (I know, it's weird, but its a dark souls-ish meme.) How do I reference the current armor slots? I tried player.body and player.armor[] (which I assumed was just a 3-length array of the slots, which would make armor[1] the body slot), but those didn't work. I know how to make live adjustments to the weapon's damage, but i just don't know how to actually check armor slots for empty, since I also couldn't find if there is an ID for empty slot or if it would be NULL.
#2: A bunch of mods have this already, but could anyone point me in the right direction for allowing melee weapons (or any weapon, for that matter), to charge up as the button is held, and then release as the button is released? I know that item.channeled (or whatever the syntax was) is part of it, but I would also like to know how to control when the animation for the swing is actually played. Do I have to make a custom UseStyle, or just have code that starts the animation at the appropriate time? The weapon should deal no damage while charging, deal normal damage if swung uncharged, and deal a modified amount of normal damage if swung charged, proportional to charge time. Obviously, I can just use a counter for the charge time and then modify that and apply it to the weapons normal damage, but I don't know how to control the time that the swing occurs.
#3: This probably goes along with the first problem, but my intention is to have an endless ammo bag that inherits the ammo type of the item directly below it in the player's ammo slot. (This is endgame stuff, not trying to break the juicy progression that terraria already has.) If the ammo bag is in the top slot, and a single (or multiple, doesn't matter) chlorophyte bullet is in the second slot, the ammo bag provides unlimited chlorophyte bullets for the weapon consuming them. I know how to make changes to the item's properties at runtime so I can already implement the part where it changes its bullet type, but again, I don't know how to reference the ammo slots in the inventory (and consequently check for ammo type within them).
#4: This is a quick one: is UseItem() called for every weapon, block, and consumable? Just wondering if its safe to put code in it for damage calculations and other effects and stuff. If so, does it occur at the beginning of the swing, or the end of the animation?
Sorry for the lengthy post, and sorry if I've violated any forum rules or anything, this is my first post. To anyone who has worked on the modloader or its resources, thank you! It has been fun to mess around with so far.
EDIT: Just as a side note, I have already been scouring the forums/google for answers to these questions, but documentation is unfortunately pretty scarce (and this forum has 941 pages, LuL)