Standalone [1.3] tModLoader - A Modding API

you can always be helpful, can you just tell me a code line that uses all variables given by the Shoot function that doesn't change any part of the projectile
[DOUBLEPOST=1450549690,1450549615][/DOUBLEPOST]not like all the variables that dont change the projectile, i mean all the variables combined, and used in a way its not an error and it doesn't affect the projectile
 
you can always be helpful, can you just tell me a code line that uses all variables given by the Shoot function that doesn't change any part of the projectile
like i said earlier, that's not my strong suit. i don't know all those X and Y variable things.
 
not all code paths return a value

the projectile works fine, item code:
Code:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
                {
                position.Y -= 110;
                }
Notice the method you are overriding returns a bool, and yet your function does not return anything at all, hence the error telling you that not all code paths return a value.

I'd refer to the documentation to figure out if you want to return true or false: https://github.com/bluemagic123/tMo...f-int-type-ref-int-damage-ref-float-knockback
 
So I'm trying to make an accessory that modifies potion healLife values. What would be the recommended way to go about that? Is there a way to call an item type in my accessory's ModItem class and modify its healLife value?
 
Like this ?
item.shoot = mod.ProjectileType("Laser");
item.useAmmo = mod.ProjectileType("Laser");
 
Last edited:
How do you exacly use the SHoot function to change a projectile's trajectory and velocity?
Can someone show me a code snippet of a projectile using this code and always the trajectory is down and velocity is equal to the speed of the projectile?
Code:
                public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
                {
                position.Y -= 11000;
                return true;
                }
You mispelled "Projectile", just saying so you don't keep getting errors when writing projectile code
 
Still, I got another question about the laser. Since it's a projectile, it can produce lights, using "item.light". But this only defines luminance, where controls the color?
 
Almost right, except the Random.Next(int maxVale) function's upper bound is exclusive, meaning "Main.rand.Next(15) == 0" has a 1 in 15 chance of being true, not a 1 in 16 chance. (15 is never returned, just 0 through 14)

As for expert mode, the code that would help you was right above the code you quoted to me:
Code:
            int num25 = 1;
            if (Main.expertMode && Main.rand.Next(2) == 0)
            {
                num25 = 2;
            }
            for (int m = 0; m < num25; m++)
            {
                if (this.type == 290)
                {
                    if (Main.rand.Next(15) == 0)
                    {
                        Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, 1513, 1, false, -1, false, false);
                    }
                    else if (Main.rand.Next(10) == 0)
                    {
                        Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, 938, 1, false, -1, false, false);
                    }
                }
This code just makes the drop rates of everything in this block 50% more likely, since there is a 50% chance the for loop will run 2 times instead of 1.
So, 6.66% to 10% and 10% to 15%, ignoring the compound probability thing, which matches up with the wiki: http://terraria.wiki.gg/Paladin

Other useful code:
int maxValue = Main.expertMode ? 150 : 200; // setting a value based on whether or not it is expert mode
if (Main.rand.Next(100) == 0 || (Main.expertMode && Main.rand.Next(100) == 0)) // 1% normal mode, or 2% Expert mode

where does it get this number from and why

if (this.type == 290)
 
:eek:People always post on this thread the most when I'm not around to be able to look at things :eek: I probably won't be able to answer everyone, sorry about that.

How can i make gun shooting only one specific ammo that i created ?
Set your gun's useAmmo field to your ammo item's type, and set your ammo item's ammo field to the ammo item's type.

is there a limit to how many items a mod can have?
There isn't any limit on individual mods. However, there is a limit on how many items can exist in the game, including vanilla items. There can only be a maximum of 2,147,483,647 types of items.

what does the Lang mean in creating crafting groups ?
What do you mean? What does Lang have to do with CraftGroup?

So I'm trying to make an accessory that modifies potion healLife values. What would be the recommended way to go about that? Is there a way to call an item type in my accessory's ModItem class and modify its healLife value?
You'll probably have to wait until the next update, since at the moment hooks don't work for items used through shortcuts such as the H key. I might also end up adding a hook to change the behavior of used vanilla items.

How do you exacly use the SHoot function to change a projectile's trajectory and velocity?
Can someone show me a code snippet of a projectile using this code and always the trajectory is down and velocity is equal to the speed of the projectile?
Code:
                public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
                {
                position.Y -= 11000;
                return true;
                }
You mispelled "Projectile", just saying so you don't keep getting errors when writing projectile code
To change the velocity, modify the speedX and speedY parameters.

Can you add a pet to the Example Mod? I am looking to create a Pet Pack Mod but I am not very good at coding and could use some basic templates. Greatest thanks, Jo Goes Rogue
There will be official pet support (probably with an example in the example mod) in the next update.
 
So, I haven't properly looked into it just yet, but noticing the lack of the specific hooks tAPI used to have, is it currently possible to draw custom UIs or just draw on screen in general?
 
So, I haven't properly looked into it just yet, but noticing the lack of the specific hooks tAPI used to have, is it currently possible to draw custom UIs or just draw on screen in general?
Nope, that hasn't been added yet. I'm trying to add in hooks for ModPlayer and ModWorld first; after that I'll decide between focusing on custom UIs or server support.
 
  • Like
Reactions: W1K
:eek:People always post on this thread the most when I'm not around to be able to look at things :eek: I probably won't be able to answer everyone, sorry about that.
Well, I think this is what you said to be "upside down":). I hardly realized you're dreaming, while I'm thinking what I'm gonna eat for lunch!
Anyway, I do get a lot of questions that almonst freak me out... Maybe I'd better ask piece by piece.
So, how to change the color of the light that a projectile produces? "item.light" only defines its luminescence.
 
Well, I think this is what you said to be "upside down":). I hardly realized you're dreaming, while I'm thinking what I'm gonna eat for lunch!
Anyway, I do get a lot of questions that almonst freak me out... Maybe I'd better ask piece by piece.
So, how to change the color of the light that a projectile produces? "item.light" only defines its luminescence.
Don't use item.light. It's only for vanilla items. In the projectile's AI, call Lighting.AddLight(projectile.Center, r, g, b), where r is the red value between 0f and 1f, g is the green value between 0f and 1f, and b is the blue value between 0f and 1f.
 
Don't use item.light. It's only for vanilla items. In the projectile's AI, call Lighting.AddLight(projectile.Center, r, g, b), where r is the red value between 0f and 1f, g is the green value between 0f and 1f, and b is the blue value between 0f and 1f.
Yes, it works like a charm.
And next thing I wanna ask is about the texture.
Only when I made myself a sniper rifle, did I discover this matter about the texture. Since the sniper rifle can be super long compare to other melee weapons, it looks quite odd when shoots, especially the stock. So I looked into the vanilla sniper rifle carefully, its stock actually sinks into player's body... Well, kinda like the one I set in NPC: public override void DrawTownAttackGun(ref float scale, ref int item, ref int closeness).
This closeness, it defines these stuff. I guess there may also be a closeness definition of mod items, using public virtual void UseStyle(Player player).
:sigh:But I don't know how to call it.
 
Yes, it works like a charm.
And next thing I wanna ask is about the texture.
Only when I made myself a sniper rifle, did I discover this matter about the texture. Since the sniper rifle can be super long compare to other melee weapons, it looks quite odd when shoots, especially the stock. So I looked into the vanilla sniper rifle carefully, its stock actually sinks into player's body... Well, kinda like the one I set in NPC: public override void DrawTownAttackGun(ref float scale, ref int item, ref int closeness).
This closeness, it defines these stuff. I guess there may also be a closeness definition of mod items, using public virtual void UseStyle(Player player).
:sigh:But I don't know how to call it.
I'll actually be adding a hook in the next update to make it easier to adjust the texture's offset when the player uses an item.
 
Back
Top Bottom