Standalone [1.3] tModLoader - A Modding API

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. :rslime::rslime::rslime::rslime::rslime:

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) :rslime::rslime::rslime::rslime::rslime::rslime::rslime:
 
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. :rslime::rslime::rslime::rslime::rslime:

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) :rslime::rslime::rslime::rslime::rslime::rslime::rslime:
I Can't help you with everything, but I can share a bit of information. player.armour[] actually is an array 20 items long. Here's a list of what numbers relate to which slots.
0:Head
1:Body
2:Legs
3:Acc1
4:Acc2
5:Acc3
6:Acc4
7:Acc5
8:Acc6
9:?
10:Vanity Head
11:Vanity Body
12:Vanity Legs
13:Vanity Acc1
14:Vanity Acc2
15:Vanity Acc3
16:Vanity Acc4
17:Vanity Acc5
18:Vanity Acc6
19:?
And I'm fairly sure that the contents of each slot is just the item ID, and a value of 0 means nothing is equipped. So "player.armour[1] == 0" should be true when nothing is equipped to the chest.

UseItem is called on any item that can be used, and it's called right at the beginning of the swing.
 
You'll have to explain, maybe with a gfycat of what you are talking about.
HomingR.gif
This is the GIF
 
Got another noob-level question for anyone. Making infinite ammo bags for crystal, chloro, ichor, and lumite bullets. The first three work perfectly. However, the lumite bullets (which are referred to in the scripts as ProjectileID.MoonlordBullet) technically work, but they are completely invisible. They still deal damage and produce particles when they hit stuff. This is strange, as the scripts are really really simple. In SetDefaults(), it's basically:

item.CloneDefaults(ItemID.MoonlordBullet);
item.maxStack = 1;
item.consumable = false;
item.rare = 5;
item.ammo = AmmoID.Bullet;
item.shoot = ProjectileID.MoonlordBullet;

Anything else i'm forgetting? Perhaps there is an auxiliary particle effect that i'm not initializing? The other bullet pouches use this format and work exactly as intended.
 
uh, Question, anyone else having problems with reserved homes for NPCs resetting when they die?
usually you can reserve a house for a specific NPC and when tehy die they will always go into the same home
 
somebody should either make a new prefixes for enemies or make a mod that makes all mobs split into 2-4 more of themselves, except for the ones who are the splitted mobs.
 
If you want a personal copy of tremor that is modified, you can download the tremor source, edit it, and build it for yourself.

hmm thanks, but the problem is that the file is in ".tmod" and I do not know what extension I should put in order to modify it. look in several pages but I did not find a solution, anyway thanks :).
 

Attachments

  • tgXxOtheScycIYfwngzyzA.png
    tgXxOtheScycIYfwngzyzA.png
    2.3 KB · Views: 122
no really, i have no idea why but this feature of assining an NPC to a house to keep another NPC from taking over it doesn't work with mods active.

and the Wiki even states how it works "NPCs that move in on their own will have a regular red flag. If they are assigned to a house, the banner will have a golden frame. This indicates that if the NPC currently inhabiting the home were to die, the replacement for that NPC would move into that specified home. Due to this, a golden NPC flag will not disappear unless the home it is in is destroyed or the NPC is reassigned."

but once a NPC dies the golden flag is gone. like, what...
 
Is there any possible way to have 2 different tmodloaders? What I mean is I have a folder to launch tmodloader for my main characters and stuff, is there a way to download tmodloader but not have the same characters or mods? So I can launch tmodloader one way and another?
 
Is there any possible way to have 2 different tmodloaders? What I mean is I have a folder to launch tmodloader for my main characters and stuff, is there a way to download tmodloader but not have the same characters or mods? So I can launch tmodloader one way and another?
Never mind... I was just too lazy to turn on and off mods
I don't want to lose my character.
 
Back
Top Bottom