92 lines
3.6 KiB
C#
92 lines
3.6 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using ForgottenWawiTech.Content.Rarities;
|
|
|
|
namespace ForgottenWawiTech.Content.Items.Weapons.Magic
|
|
{
|
|
public class TomeOfUnyielding : ModItem
|
|
{
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 520;
|
|
Item.mana = 22;
|
|
Item.crit = 100;
|
|
Item.DamageType = DamageClass.Magic;
|
|
Item.width = 40;
|
|
Item.height = 40;
|
|
Item.useTime = 14;
|
|
Item.useAnimation = 14;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.knockBack = 4.5f;
|
|
Item.value = Item.sellPrice(gold: 32);
|
|
Item.rare = ModContent.RarityType<SingularityItem>();
|
|
Item.autoReuse = true;
|
|
Item.noMelee = true;
|
|
Item.shoot = ProjectileID.NebulaBlaze1;
|
|
Item.shootSpeed = 20f;
|
|
Item.useAmmo = AmmoID.None;
|
|
}
|
|
|
|
public override bool Shoot(Player player, Terraria.DataStructures.EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockBack)
|
|
{
|
|
Vector2 direction = velocity.LengthSquared() > 0.0001f ? Vector2.Normalize(velocity) : new Vector2(player.direction, 0f);
|
|
int[] primaryBolts =
|
|
{
|
|
ProjectileID.NebulaBlaze1,
|
|
ProjectileID.NebulaBlaze2,
|
|
ProjectileID.SkyFracture,
|
|
ProjectileID.ShadowBeamFriendly,
|
|
ProjectileID.CrystalShard,
|
|
ProjectileID.CrystalLeafShot
|
|
};
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
int projType = primaryBolts[Main.rand.Next(primaryBolts.Length)];
|
|
Vector2 perturbedVelocity = direction.RotatedByRandom(MathHelper.ToRadians(8f)) * Item.shootSpeed * Main.rand.NextFloat(0.98f, 1.18f);
|
|
int proj = Projectile.NewProjectile(source, position, perturbedVelocity, projType, (int)(damage * 0.95f), knockBack, player.whoAmI);
|
|
if (proj >= 0)
|
|
{
|
|
Main.projectile[proj].DamageType = DamageClass.Magic;
|
|
}
|
|
}
|
|
|
|
int lingeringType = ProjectileID.MagnetSphereBall;
|
|
Vector2 orbitalVel = direction.RotatedBy(MathHelper.ToRadians(Main.rand.NextBool() ? 22f : -22f)) * (Item.shootSpeed * 0.68f);
|
|
int sphere = Projectile.NewProjectile(source, position, orbitalVel, lingeringType, (int)(damage * 0.85f), 0f, player.whoAmI);
|
|
if (sphere >= 0)
|
|
{
|
|
Main.projectile[sphere].DamageType = DamageClass.Magic;
|
|
}
|
|
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
int burst = Projectile.NewProjectile(source, position, direction * (Item.shootSpeed * 0.85f), ProjectileID.NebulaArcanum, (int)(damage * 0.7f), knockBack * 0.6f, player.whoAmI);
|
|
if (burst >= 0)
|
|
{
|
|
Main.projectile[burst].DamageType = DamageClass.Magic;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override Vector2? HoldoutOffset() {
|
|
return new Vector2(2f, -2f);
|
|
}
|
|
|
|
public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) {
|
|
Vector2 direction = velocity.LengthSquared() > 0.0001f ? Vector2.Normalize(velocity) : new Vector2(player.direction, 0f);
|
|
Vector2 muzzleOffset = direction * 25f;
|
|
|
|
if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0)) {
|
|
position += muzzleOffset;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|