using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace JoshuasMod.Items.Weapons //We need this to basically indicate the folder where it is to be read from, so you the texture will load correctly
{
public class CosmicCataclysm : ModItem
{
public override void SetDefaults()
{
item.CloneDefaults(ItemID.StarWrath);
item.damage = 1000; //The damage stat for the Weapon.
item.melee = false; //This defines if it does melee damage and if its effected by melee increasing Armor/Accessories.
item.useTime = 10; //How fast the Weapon is used.
item.useAnimation = 10; //How long the Weapon is used for.
item.useStyle = 1; //The way your Weapon will be used, 5 is the Holding Out Used for: Guns, Spellbooks, Drills, Chainsaws, Flails, Spears for example
item.noMelee = true; //Setting to True allows the weapon sprite to stop doing damage, so only the projectile does the damge
item.knockBack = 10; //The knockback stat of your Weapon. The higher the number, the higher the Knockback.
item.value = Item.buyPrice(1, 20, 50, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (So this item price is 1 Platinum, 20 Gold and 50 Silver.)
item.rare = 11; //The color the title of your Weapon when hovering over it ingame
item.UseSound = SoundID.Item21; //item.UseSound = SoundID.Item1; //The sound played when using your Weapon
item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
item.shoot = 0;
item.useTurn = true;
}
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.Daybreak, 5 * 60);
target.AddBuff(BuffID.Frostburn, 5 * 60);
target.AddBuff(BuffID.DryadsWardDebuff, 5 * 60);
int healingAmount = damage/50;
player.statLife +=healingAmount;
player.HealEffect(healingAmount, true);
}
public override bool AltFunctionUse(Player player)
{
return true;
}
public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
{
item.useStyle = 1; //The way your Weapon will be used, 1 is the regular sword swing.
item.useTime = 12; //How fast the Weapon is used.
item.useAnimation = 12; //How long the Weapon is used for.
item.UseSound = SoundID.Item1;
item.damage = 1000;
item.shoot = mod.ProjectileType("CataclysmicBlaze");
item.shootSpeed = 18f;
item.useTurn = true;
}
else
{
item.useStyle = 1; //The way your Weapon will be used, 1 is the regular sword swing.
item.UseSound = SoundID.Item1; //The sound played when using your Weapon.
item.damage = 1000;
item.useTime = 10; //How fast the Weapon is used.
item.useAnimation = 10; //How long the Weapon is used for.
item.autoReuse = true;
item.melee = false;
item.rare = 11;
item.shoot = 0;
item.useTurn = true;
}
return base.CanUseItem(player);
}
//This is the "Star Wrath" style for the projectiles.
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
int numberProjectiles = 1 + Main.rand.Next(1); //Defines how many projectiles it will shoot. "numberProjectiles = 1" is 1 projectile, "numberProjectiles = 2" is 2 projectiles, etc.
for (int index = 0; index < numberProjectiles; ++index)
{
Vector2 vector2_1 = new Vector2((float)((double)player.position.X + (double)player.width * 0.5 + (double)(Main.rand.Next(100) * -player.direction) + ((double)Main.mouseX + (double)Main.screenPosition.X - (double)player.position.X)), (float)((double)player.position.Y + (double)player.height * 0.5 - 600.0)); //This defines the projectile width, direction and position.
vector2_1.X = (float)(((double)vector2_1.X + (double)player.Center.X) / 2.0) + (float)Main.rand.Next(-100, 100);
vector2_1.Y -= (float)(100 * index);
float num12 = (float)Main.mouseX + Main.screenPosition.X - vector2_1.X;
float num13 = (float)Main.mouseY + Main.screenPosition.Y - vector2_1.Y;
if ((double)num13 < 0.0) num13 *= -1f;
if ((double)num13 < 20.0) num13 = 20f;
float num14 = (float)Math.Sqrt((double)num12 * (double)num12 + (double)num13 * (double)num13);
float num15 = item.shootSpeed / num14;
float num16 = num12 * num15;
float num17 = num13 * num15;
float SpeedX = num16 + (float)Main.rand.Next(-12, 10) * 0.160f; //This defines the projectile X position speed and randomness.
float SpeedY = num17 + (float)Main.rand.Next(-12, 10) * 0.160f; //This defines the projectile Y position speed and randomness.
Projectile.NewProjectile(vector2_1.X, vector2_1.Y, SpeedX, SpeedY, type, damage, knockBack, Main.myPlayer, 0.0f, (float)Main.rand.Next(5));
}
return false;
}
}
}