Skip to main content

Terraria

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.useSound = 71;
            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)

        {

            int numProjectiles2 = 3;
            float spread = MathHelper.ToRadians(10);
            float baseSpeed = (float)Math.Sqrt(15 * 15 + 15 * 15);
            double startAngle = Math.Atan2(15, 15) - 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 = (int)target.position.X + randomSeed.Next(1000, 1500) * negPos[randomSeed.Next(2)];
                int posY = (int)target.position.Y + randomSeed.Next(1000, 1500) * negPos[randomSeed.Next(2)];
                offsetAngle = startAngle + deltaAngle * j;
                Projectile.NewProjectile(posX, posY, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), ProjectileID.FlamingJack, damage, knockBack, target.whoAmI);
            }
        }
    }
}