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.where do you place Which NPC drops it?
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.Here you go,
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?
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?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.
Oh ok, thanksI forget what this problem is, just zip up your mod sources and I'll look.
ExampleMod has plenty of examples, here is for vanilla npc: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/NPCs/ExampleGlobalNPC.cs#L32
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.
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?
i think the more i try to understand the more confused i get...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).
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();
}
}
}
So if I do this, how do choose which Terraria to open? I know nothing about modding, sorry to cause so much trouble :/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.
Anyone?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
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.So if I do this, how do choose which Terraria to open? I know nothing about modding, sorry to cause so much trouble :/
Ummm, and how do I do that?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
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)Ummm, and how do I do that?
ugh I feel like I know nothing...
Anyone?
- Aerlock
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.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)
That will not happenI 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.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.
Alright, that's great!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.
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(); } } }
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?