Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace HarvestReaper.Items.Weapons
{
public class HarvestReaper : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Harvest Reaper");
Tooltip.SetDefault("The Jack o' Reaper's Scythe");
}
public override void SetDefaults()
{
item.useStyle = 1;
item.melee = true;
item.useAnimation = 30;
item.damage = 160;
item.knockBack = 5;
item.autoReuse = true;
item.useTurn = true;
item.crit = 20;
item.width = 80;
item.height = 80;
item.scale = 0.75f;
item.value = 1000000;
item.rare = 8;
item.stack = 1;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.TheHorsemansBlade, 1);
recipe.AddIngredient(ItemID.LunarBar, 999);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
Projectile.NewProjectile(target.position.X, target.position.Y, 0, 0, item.shoot, item.damage, item.knockBack, item.owner, target.whoAmI, 0f);
int numProjectiles2 = 3;
float spread = MathHelper.ToRadians(10);
float baseSpeed = (float)Math.Sqrt(75 * 75 + 75 * 75);
double startAngle = Math.Atan2(75, 75) - spread / 2;
double deltaAngle = spread / (float)numProjectiles2;
double offsetAngle;
Random randomSeed = new Random();
for (int j = 0; j < numProjectiles2; j++)
{
int[] negPos = { -1, 1 };
int posX = npc.position.X + randomSeed.Next(1000, 1500) * negPos[randomSeed.Next(2)];
int posY = npc.position.Y + randomSeed.Next(1000, 1500) * negPos[randomSeed.Next(2)];
offsetAngle = startAngle + deltaAngle * j;
Projectile.NewProjectile(position.X, position.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, knockBack, player.whoAmI);
}
}
}
}
Errors:
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(63,28) : error CS0103: The name 'npc' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(64,28) : error CS0103: The name 'npc' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(66,42) : error CS0103: The name 'position' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(66,54) : error CS0103: The name 'position' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(66,150) : error CS0103: The name 'type' does not exist in the current context
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace HarvestReaper.Items.Weapons
{
public class HarvestReaper : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Harvest Reaper");
Tooltip.SetDefault("The Jack o' Reaper's Scythe");
}
public override void SetDefaults()
{
item.useStyle = 1;
item.melee = true;
item.useAnimation = 30;
item.damage = 160;
item.knockBack = 5;
item.autoReuse = true;
item.useTurn = true;
item.crit = 20;
item.width = 80;
item.height = 80;
item.scale = 0.75f;
item.value = 1000000;
item.rare = 8;
item.stack = 1;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.TheHorsemansBlade, 1);
recipe.AddIngredient(ItemID.LunarBar, 999);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
Projectile.NewProjectile(target.position.X, target.position.Y, 0, 0, item.shoot, item.damage, item.knockBack, item.owner, target.whoAmI, 0f);
int numProjectiles2 = 3;
float spread = MathHelper.ToRadians(10);
float baseSpeed = (float)Math.Sqrt(75 * 75 + 75 * 75);
double startAngle = Math.Atan2(75, 75) - spread / 2;
double deltaAngle = spread / (float)numProjectiles2;
double offsetAngle;
Random randomSeed = new Random();
for (int j = 0; j < numProjectiles2; j++)
{
int[] negPos = { -1, 1 };
int posX = npc.position.X + randomSeed.Next(1000, 1500) * negPos[randomSeed.Next(2)];
int posY = npc.position.Y + randomSeed.Next(1000, 1500) * negPos[randomSeed.Next(2)];
offsetAngle = startAngle + deltaAngle * j;
Projectile.NewProjectile(position.X, position.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, knockBack, player.whoAmI);
}
}
}
}
Errors:
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(63,28) : error CS0103: The name 'npc' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(64,28) : error CS0103: The name 'npc' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(66,42) : error CS0103: The name 'position' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(66,54) : error CS0103: The name 'position' does not exist in the current context
c:\Users\Legen\Documents\My Games\Terraria\ModLoader\Mod Sources\HarvestReaper\Items\Weapons\HarvestReaper.cs(66,150) : error CS0103: The name 'type' does not exist in the current context