Standalone [1.3] tModLoader - A Modding API

where do you place Which NPC drops it?
The first one I linked to was the GlobalNPC code, the second thing I sent was the ModNPC code. Go back to the GlobalNPC code any you'll see the checks for the NPCIDs.

Here you go,
You don't have a Mod class. You don't have a mod without a mod class. Example Below, fix it with your namespace and mod name and save it in the mods folder.

(Although, you might as well use this to get the build.txt and description.txt too: http://javid.ddns.net/tModLoader/generator/ModSkeletonGenerator.html)

(Also, your sword won't build since you deleted the dust....just use the link.)

Code:
using Terraria.ModLoader;

namespace a
{
    class a : Mod
    {
        public a()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
}
 
thanks.
edit: now it shoots a few demon circle things in the bottom right... they do no damage... so what i mean is it shoots a few demon circle things to hte bottom right that do no damage, how to fix this?

In my experience this happens when the owner parameter of NewProjectile is set to 255 (which it defaults to). Replace it (or add it, if you didn't include it to begin with) with Main.myPlayer.
 
In my experience this happens when the owner parameter of NewProjectile is set to 255 (which it defaults to). Replace it (or add it, if you didn't include it to begin with) with Main.myPlayer.
and how exactly do i do that? also, i found this line of code that says it goes at angle 45, 45, so thats probably pointing at where it goes, whats the code for mouse position?
 
and how exactly do i do that? also, i found this line of code that says it goes at angle 45, 45, so thats probably pointing at where it goes, whats the code for mouse position?

Owner is the eight parameter of NewProjectile (after Knockback) and the first default parameter, so it's possible you're not actually using it yet. If Knockback is your last argument, insert , Main.myPlayer behind it. If it's not, find the argument directly after Knockback and change it to Main.myPlayer.

Not sure where you got angle from, but it seems like something used to calculate the velocity.

Mouse position is Main.mouseX and Main.mouseY (both ints).
 
Owner is the eight parameter of NewProjectile (after Knockback) and the first default parameter, so it's possible you're not actually using it yet. If Knockback is your last argument, insert , Main.myPlayer behind it. If it's not, find the argument directly after Knockback and change it to Main.myPlayer.

Not sure where you got angle from, but it seems like something used to calculate the velocity.

Mouse position is Main.mouseX and Main.mouseY (both ints).
i think the more i try to understand the more confused i get...
can you try it? seriously, i dont understand anything, im really bad at coding... so yeh... :c
Code:
using Terraria;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.ModLoader;

namespace ExampleMod.Items.Weapons
{
    public class ExampleGun : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Hotti Shotti";
            item.damage = 20;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "FEEL THE BURN";
            item.toolTip2 = "litteraly";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 11;
            item.autoReuse = false;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 16f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public static Microsoft.Xna.Framework.Vector2[] evenSpread (float speedX,  float speedY, int angle, int num)
        {
            var posArray = new Microsoft.Xna.Framework.Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
            double startAngle = System.Math.Atan2(speedX, speedY) - spread / 5 ; //i have no idea what to seat the spread / X at, so thats why it is at 5
            double deltaAngle = spread / (float)num;
            double offsetAngle;
            for (int i = 0; i < num; ++i)
            {
                offsetAngle = startAngle + deltaAngle * i;
                posArray[i] = new Microsoft.Xna.Framework.Vector2(baseSpeed * (float)System.Math.Sin(offsetAngle), baseSpeed * (float)System.Math.Cos(offsetAngle));
            }
            return (Microsoft.Xna.Framework.Vector2[])posArray;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2[] speeds = ExampleGun.evenSpread(16f, 16f, 45, 5);
            for (int i = 0; i < 5; ++i)
            {
                Terraria.Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, Main.mouseX, Main.mouseY, 15f);
            }
            return false;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10);
            recipe.AddTile(null, "ExampleWorkbench");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
You don't need to copy the whole folder, just either rename Vanilla Terraria.exe to TerrariaVanilla.exe or rename tmodloader Terraria.exe to tModLoader.exe.
So if I do this, how do choose which Terraria to open? I know nothing about modding, sorry to cause so much trouble :/
 
Is there a place I can get an image template or guide for the various Items?

I'm trying to make some custom armor and I want to make custom sprites to go with it but I'm looking through the Example Mod and I'm having a difficult time figuring out the patterns for the images. For example the ExampleHelmet has different numbers of pixels between all the various helmets in the image. Most are 36 pixels apart but some are 34 and I don't know if there are any other differences in there since I didn't check each and every one. Also I can't tell from the example file which sprite is used when.

Thanks in Advance

- Aerlock
Anyone?

- Aerlock
[doublepost=1460243730,1460243615][/doublepost]
So if I do this, how do choose which Terraria to open? I know nothing about modding, sorry to cause so much trouble :/
You just create shortcuts to both files and name one Terraria Vanilla and the other Terraria Mod. Then when you're in the mood for vanilla you run that one and when your working on your mod you run the other.

- Aerlock
 
Anyone?

- Aerlock
[doublepost=1460243730,1460243615][/doublepost]
You just create shortcuts to both files and name one Terraria Vanilla and the other Terraria Mod. Then when you're in the mood for vanilla you run that one and when your working on your mod you run the other.

- Aerlock
Ummm, and how do I do that?
ugh I feel like I know nothing...
 
Ummm, and how do I do that?
ugh I feel like I know nothing...
In your terraria folder, just do a folder called "Terraria Vanilla" and put the terraria.exe original file on it, after that, install tModLoader. If you want to use original terraria, just copy and replace the .exe again (you can do the same for the tModLoader, putting it in a "Terraria Mods" folder to play with mods after)

Anyone?

- Aerlock

Yeah, the reason for that is because the player (when it walks or jump) it moves. The easyest way to make a custom armor is using other armor and draw on it (in other layer, obviously)


For me, i dont remember how to check if a projectile is active. Someone can help me? :p
 
In your terraria folder, just do a folder called "Terraria Vanilla" and put the terraria.exe original file on it, after that, install tModLoader. If you want to use original terraria, just copy and replace the .exe again (you can do the same for the tModLoader, putting it in a "Terraria Mods" folder to play with mods after)
I see, thanks! I just need to make 2 different folders and switch them around! I just want to know if the other files that come with the Terraria.exe will affect it.
 
I see, thanks! I just need to make 2 different folders and switch them around! I just want to know if the other files that come with the Terraria.exe will affect it.
No, they won't affect it. Although if you did it the way I told you, you would just right click drag with your mouse to the desktop to create the two shortcuts, no need to keep moving the exe around.
 
No, they won't affect it. Although if you did it the way I told you, you would just right click drag with your mouse to the desktop to create the two shortcuts, no need to keep moving the exe around.
Alright, that's great!
[doublepost=1460246075,1460245685][/doublepost]Thanks everyone for helping me so much!
 
I just copied all of the files into the MacOS folder of Terraria and now Terraria isn't opening. On Steam it says Running... then Syncing... then it stops, and does not open.
I thought I was done asking noob questions... :/
Is this a problem with the game itself? I put back the Vanilla Terraria.exe file and it still won't open.
 
Last edited:
i think the more i try to understand the more confused i get...
can you try it? seriously, i dont understand anything, im really bad at coding... so yeh... :c
Code:
using Terraria;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.ModLoader;

namespace ExampleMod.Items.Weapons
{
    public class ExampleGun : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Hotti Shotti";
            item.damage = 20;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "FEEL THE BURN";
            item.toolTip2 = "litteraly";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 11;
            item.autoReuse = false;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 16f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public static Microsoft.Xna.Framework.Vector2[] evenSpread (float speedX,  float speedY, int angle, int num)
        {
            var posArray = new Microsoft.Xna.Framework.Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
            double startAngle = System.Math.Atan2(speedX, speedY) - spread / 5 ; //i have no idea what to seat the spread / X at, so thats why it is at 5
            double deltaAngle = spread / (float)num;
            double offsetAngle;
            for (int i = 0; i < num; ++i)
            {
                offsetAngle = startAngle + deltaAngle * i;
                posArray[i] = new Microsoft.Xna.Framework.Vector2(baseSpeed * (float)System.Math.Sin(offsetAngle), baseSpeed * (float)System.Math.Cos(offsetAngle));
            }
            return (Microsoft.Xna.Framework.Vector2[])posArray;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2[] speeds = ExampleGun.evenSpread(16f, 16f, 45, 5);
            for (int i = 0; i < 5; ++i)
            {
                Terraria.Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, Main.mouseX, Main.mouseY, 15f);
            }
            return false;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10);
            recipe.AddTile(null, "ExampleWorkbench");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Okay, so you're doing some rather strange stuff in your class. My advice to you, before we get to the code itself, is to use comment lines, and lots of them (comment lines are those lines that start with //). If I look at your evenSpread method, which isn't that difficult, it takes me a good few minutes to figure out what everything does, while with comment lines it would have taken me thirty seconds tops.

I cleaned up some general things, such as EvenSpread being static for no particular reason and redundant namespace usage (there are more messy things, but I can't change them with assurance that they'll work). This should fix the projectiles dealing no damage, but apart from that I didn't touch anything because I'm not sure what you are trying to do. Your mouseX was determining the type and your mouseY the damage, which I doubt was your original intention, so I reverted it to an earlier version you posted.
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExampleMod.Items.Weapons
{
    public class ExampleGun : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Hotti Shotti";
            item.damage = 20;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "FEEL THE BURN";
            item.toolTip2 = "litteraly";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 11;
            item.autoReuse = false;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 16f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public static Vector2[] EvenSpread (float speedX,  float speedY, int angle, int amount)
        {
            Vector2[] posArray = new Vector2[amount];
            float spread = angle * (float)(Math.PI / 180);
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double startAngle = Math.Atan2(speedX, speedY) - spread / 5 ; //i have no idea what to seat the spread / X at, so thats why it is at 5
            double deltaAngle = spread / (float)amount;
            double offsetAngle;
            for (int i = 0; i < num; ++i)
            {
                offsetAngle = startAngle + deltaAngle * i;
                posArray[i] = new Vector2(baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle));
            }
            return (Vector2[])posArray;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2[] speeds = EvenSpread(16f, 16f, 45, 5);
            for (int i = 0; i < 5; ++i)
            {
                Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, 45, 45, 15f, Main.myPlayer);
            }
            return false;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10);
            recipe.AddTile(null, "ExampleWorkbench");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

For me, i dont remember how to check if a projectile is active. Someone can help me? :p

Projectile.active
 
Does anyone know if it would be possible to make a constructed summon like there are a few staffs that each summon a piece of something and only when you have them all they will combine into this one huge thing?
 
Back
Top Bottom