Standalone [1.3] tModLoader - A Modding API

I'm not sure what you mean by "attack interval", I don't think there is a field named that. Also, you can just check the vanilla item field spreadsheet and learn from there if you want to. Are you actually talking about how many times it can hit on a single swing?

I'm not sure what you mean. The recipe is passed in, you don't need to "refer to" it at all, it's just there. Maybe you can explain what you mean, which OnCraft method you are using, and what you need to know to do it correctly.
Sorry. I know I would express this ambiguously.
By Attack Interval, it's just the use time. Only I found a little something wrong with it. Let's say the night's edge, it has a DPS of 50. And I actually set a melee weapon (it's a mod sword) as the same damage as that of the night's edge. And a really slow speed, definitely not faster than the night's edge, maybe an use time of 40, but its DPS still reaches 70 easily. Even if I change the use time of my sword to 50 or something higher, the DPS won't change too much, seems to remain at 70 or 68. So by these strange phenomenon, I suspected that a melee weapon's use time doesn't depend on, or merely depend on the use time of the item, which is defined with the weapon's item.cs. Also, I can find use time of guns, bows or let's say all the ranged weapons. But no, I can't find any melee weapon in Item.cs has been granted with a specific use time. Then where is the vanilla melee weapon's use time?

By this recipe stuff... Well, let me first tell you the details about my ideas(not some good ideas but ideas:))!
I made myself some throwing knives right? They're with durability types, you know. In order to resupply this durability when a throwing knife's durability reached 0, I think I should make a certain item, which will resupply the relative throwing knife when being crafted... So what I was wondering was, how far can OnCraft influence?
Let's say I made an item named "Ichro Throwing Knife Supply". And it is only a simply item can't be used to do nothing. But it has its OnCraft hook. I guess I may be supposed to write the same codes what I write in OnPickup before, only with a larger supply number. Something like:
Code:
        public override void OnCraft(Recipe recipe)
        {
            Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 0);
            ItemText.NewText(item, item.stack, false, false);
            for (int i = 0; i < 50; i++)
            {
                Item item2 = player.inventory[i];
                if (item2.stack > 0 && item2.type > 0 && item2.type == mod.ItemType("IchorThrowingKnife"))
                {
                    ((IchorThrowingKnife)item2.modItem).durability += 100; break;
                }
            }
But, does this mean, whenever this "Knife Supply" item was crafted, as long as the recipe's output includes this item, this hook will be called? I was wondering what this "Recipe recipe" parameter refers to...

EDIT: Oh! And I found some bug of my durability system just now! I made 2 knives, but only used one of them. So there would be a lot of items on the ground waiting for my picking up. However, there is actually only one throwing knife, with its full durability, in my inventory. The items on the ground still can be picked up, and the OnPickup hook still got called. How to ban the picking behavior when the player's inventory has no available durability to fulfill or simply has no throwing knife?
 
Last edited:
Sorry. I know I would express this ambiguously.
By Attack Interval, it's just the use time. Only I found a little something wrong with it. Let's say the night's edge, it has a DPS of 50. And I actually set a melee weapon (it's a mod sword) as the same damage as that of the night's edge. And a really slow speed, definitely not faster than the night's edge, maybe an use time of 40, but its DPS still reaches 70 easily. Even if I change the use time of my sword to 50 or something higher, the DPS won't change too much, seems to remain at 70 or 68. So by these strange phenomenon, I suspected that a melee weapon's use time doesn't depend on, or merely depend on the use time of the item, which is defined with the weapon's item.cs. Also, I can find use time of guns, bows or let's say all the ranged weapons. But no, I can't find any melee weapon in Item.cs has been granted with a specific use time. Then where is the vanilla melee weapon's use time?

By this recipe stuff... Well, let me first tell you the details about my ideas(not some good ideas but ideas:))!
I made myself some throwing knives right? They're with durability types, you know. In order to resupply this durability when a throwing knife's durability reached 0, I think I should make a certain item, which will resupply the relative throwing knife when being crafted... So what I was wondering was, how far can OnCraft influence?
Let's say I made an item named "Ichro Throwing Knife Supply". And it is only a simply item can't be used to do nothing. But it has its OnCraft hook. I guess I may be supposed to write the same codes what I write in OnPickup before, only with a larger supply number. Something like:
Code:
        public override void OnCraft(Recipe recipe)
        {
            Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 0);
            ItemText.NewText(item, item.stack, false, false);
            for (int i = 0; i < 50; i++)
            {
                Item item2 = player.inventory[i];
                if (item2.stack > 0 && item2.type > 0 && item2.type == mod.ItemType("IchorThrowingKnife"))
                {
                    ((IchorThrowingKnife)item2.modItem).durability += 100; break;
                }
            }
But, does this mean, whenever this "Knife Supply" item was crafted, as long as the recipe's output includes this item, this hook will be called? I was wondering what this "Recipe recipe" parameter refers to...
If you aren't changing useTime and useAnimation at the same time, I don't think your tests will prove all that useful. Also, looking at the code, all the swords have various useTimes.

For the recipe, that is the recipe that was used to craft the item. For example, consider a mod that has 2 recipes for the same thing, with a high quality recipe and a low quality recipe. The mod can check the recipe and maybe "break" the item half of the time with the low quality recipe. The issue you might have with your idea is how do craft the item but not actually end up with the item in your inventory. Maybe setdefaults to 0?
 
If you aren't changing useTime and useAnimation at the same time, I don't think your tests will prove all that useful. Also, looking at the code, all the swords have various useTimes.

For the recipe, that is the recipe that was used to craft the item. For example, consider a mod that has 2 recipes for the same thing, with a high quality recipe and a low quality recipe. The mod can check the recipe and maybe "break" the item half of the time with the low quality recipe. The issue you might have with your idea is how do craft the item but not actually end up with the item in your inventory. Maybe setdefaults to 0?
K, I'll think about it. And I dunno whether you received my bug just now, any idea?
EDIT: Oh! And I found some bug of my durability system just now! I made 2 knives, but only used one of them. So there would be a lot of items on the ground waiting for my picking up. However, there is actually only one throwing knife, with its full durability, in my inventory. The items on the ground still can be picked up, and the OnPickup hook still got called. How to ban the picking behavior when the player's inventory has no available durability to fulfill or simply has no throwing knife?
 
uCE9Fkh.gif

Code:
public override void AI()
        {
          
            projectile.rotation +=  1.5f * projectile.direction * (-1);
          
          
                if (Main.rand.Next(3) == 0 && player.direction == 1)
                {
                    //projectile.velocity.Y *= 1.0f;
                    projectile.velocity.X *= 1.05f;
                }
                else if (Main.rand.Next(3) == 1 && player.direction == -1)
                {
                    //projectile.velocity.Y *= 1.0f;
                    projectile.velocity.X *= 1.05f;
              
                  

                }

There is some kind of "force" pushing the shurikens, how to use the normal gravity?

EDIT:
x2U9YWu.gif
 
My next problem ...
b3ABmk0.gif

Player is holding all 4 sprites I use for the animation in the inventory. why ?
 
Code:
public override void AI()
        {
        
            projectile.rotation +=  1.5f * projectile.direction * (-1);
        
        
                if (Main.rand.Next(3) == 0 && player.direction == 1)
                {
                    //projectile.velocity.Y *= 1.0f;
                    projectile.velocity.X *= 1.05f;
                }
                else if (Main.rand.Next(3) == 1 && player.direction == -1)
                {
                    //projectile.velocity.Y *= 1.0f;
                    projectile.velocity.X *= 1.05f;
            
                

                }

There is some kind of "force" pushing the shurikens, how to use the normal gravity?
Just taking a guess I would say what you're seeing is the projectile.velocity.X *= 1.05f; line increasing the velocity over time.
My next problem ...
Player is holding all 4 sprites I use for the animation in the inventory. why ?
Not seeing the code for the item I'm going to guess that theres something wrong with the code that sets the number of frames in the animation.

When I try to run the installer it says ''Could not find a place to install to!'' How can I fix this?
What OS?
What version of the OS?
Are you using the Steam version of Terraria or the GOG version? I believe that tModLoader is setup to only work with the Steam version.
Can you copy the files into the Terraria folder and have it work? Make a backup of your Terraria folder before you do this so you can easily restore to vanilla Terraria if you want to.

- Aerlock
 
modded chest (any mod) turn into dresser why is that?
We don't know yet.

My next problem ...
b3ABmk0.gif

Player is holding all 4 sprites I use for the animation in the inventory. why ?
I'm not sure if animated use items is fixed yet, but you have an exception being thrown in your draw code

When I try to run the installer it says ''Could not find a place to install to!'' How can I fix this?
do it manually, read the readme.
[doublepost=1461526469,1461526425][/doublepost]
What i need to do if PostUpdate for player and world doesn't work correctly on the server? I've already asked about it
What makes you think it doesn't work?
 
I believe tmodloader only works with the steam version

Too bad I really wanted to try Thorium and Tremor :sigh:
If there are mod loaders that work on GOG I'd be grateful if someone can tell me about them as all the ones I found now are discontinued and don't work on 1.3.
Thanks anyway guys.
 
I need help, every time i cast my Guardian Sphere spell tome it always shoots the projectile towards the bottom right corner of my screen no matter which was i'm facing. Help would be much appreciated, thank you in advance.


Code:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace RCT.Projectiles
{
    public class GuardianSphereProj : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Guardian Sphere Projectile";
            projectile.width = 20;
            projectile.height = 20;
            projectile.aiStyle = 47;
            projectile.ranged = true;
            projectile.penetrate = 2;
            projectile.timeLeft = 1800;
            projectile.ignoreWater = true;
            projectile.friendly = true;
            projectile.hostile = false;
            projectile.tileCollide = false;
           
        }
        public override void AI()
        {
            projectile.rotation += (float)projectile.direction * 0.8f;
            projectile.velocity.X = 0.5f;
            projectile.velocity.Y = 0.5f;
           
            projectile.light = 1;
            Player owner = Main.player[projectile.owner];
            if (projectile.position.X < owner.position.X + owner.width && projectile.position.X + projectile.width > owner.position.X && projectile.position.Y < owner.position.Y + owner.height && projectile.position.Y + projectile.height > owner.position.Y) // Need to fix (make it so if within a certain radius)
            {
           
                    owner.AddBuff(2, 1800);

            }
        }
    }
}
 
EDIT: Oh! And I found some bug of my durability system just now! I made 2 knives, but only used one of them. So there would be a lot of items on the ground waiting for my picking up. However, there is actually only one throwing knife, with its full durability, in my inventory. The items on the ground still can be picked up, and the OnPickup hook still got called. How to ban the picking behavior when the player's inventory has no available durability to fulfill or simply has no throwing knife?
How to deny an item's being picked up under certain conditions?
 
So I have this code here that is supposed to spawn in skeletron. Sometimes it works fine and sometimes the message saying he has spawned appears, but he isn't actually there. This has nothing to do with the time of day. Any thoughts?
Code:
public override bool UseItem(Player player)
        {

            NPC.SpawnOnPlayer(player.whoAmI, NPCID.SkeletronHead);
           
           
            Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);
            return true;
        }
 
We don't know yet.


I'm not sure if animated use items is fixed yet, but you have an exception being thrown in your draw code

do it manually, read the readme.
[doublepost=1461526469,1461526425][/doublepost]
What makes you think it doesn't work?
He could just make it use the hide the items graphic code when using
and then spawn a projectile that is animated
 
Back
Top Bottom