Any help?
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1514: { expected
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1519: Invalid token '-' in class, struct, or interface member declaration
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,30) : error CS1519: Invalid token '-' in class, struct, or interface member declaration
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,35) : error CS1519: Invalid token ':' in class, struct, or interface member declaration
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(10,5) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
This is my code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace TestWeapon.Items.Weapons
{
public class Shot-Machine-Gun : ModItem
{
public override void SetDefaults()
{
item.name = "Shot-Machine-Gun";
item.damage = 10;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is the fastest shotgun we have.";
item.useTime = 1;
item.useAnimation = 38;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 7;
item.value = 10000;
item.rare = 2;
item.useSound = 14;
item.autoReuse = false;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = ProjectileID.Bullet;
}
public override void AddRecipes() //How to craft this gun
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HallowedBar, 12); //you need 1 DirtBlock
recipe.AddTile(TileID.WorkBenches); //at work bench
recipe.SetResult(this);
recipe.AddRecipe();
}
public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)(angle * 0.0174532925);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray
= new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
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 = randomSpread(speedX, speedY, 8, 6);
for (int i = 0; i < 5; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
}
[doublepost=1480117235,1480117149][/doublepost]
Any help?
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1514: { expected
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1519: Invalid token '-' in class, struct, or interface member declaration
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,30) : error CS1519: Invalid token '-' in class, struct, or interface member declaration
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,35) : error CS1519: Invalid token ':' in class, struct, or interface member declaration
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(10,5) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
This is my code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace TestWeapon.Items.Weapons
{
public class Shot-Machine-Gun : ModItem
{
public override void SetDefaults()
{
item.name = "Shot-Machine-Gun";
item.damage = 10;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is the fastest shotgun we have.";
item.useTime = 1;
item.useAnimation = 38;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 7;
item.value = 10000;
item.rare = 2;
item.useSound = 14;
item.autoReuse = false;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = ProjectileID.Bullet;
}
public override void AddRecipes() //How to craft this gun
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HallowedBar, 12); //you need 1 DirtBlock
recipe.AddTile(TileID.WorkBenches); //at work bench
recipe.SetResult(this);
recipe.AddRecipe();
}
public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)(angle * 0.0174532925);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
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 = randomSpread(speedX, speedY, 8, 6);
for (int i = 0; i < 5; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
}
When i copy and pasted, the spaces for different codes did not copy and paste.
In my original thing, they were all correct.