97 lines
3.7 KiB
C#
97 lines
3.7 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Magic
|
|
{
|
|
public class HyphaeRod : ModItem
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Hyphae Rod");
|
|
Tooltip.SetDefault("Creates mushroom spores near the player");
|
|
Item.staff[item.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
item.damage = 20;
|
|
item.magic = true;
|
|
item.mana = 7;
|
|
item.width = 34;
|
|
item.height = 34;
|
|
item.useTime = 24;
|
|
item.useAnimation = 24;
|
|
item.useStyle = 5;
|
|
item.noMelee = true;
|
|
item.knockBack = 2f;
|
|
item.value = Item.buyPrice(0, 2, 0, 0);
|
|
item.rare = 2;
|
|
item.UseSound = SoundID.Item8;
|
|
item.autoReuse = true;
|
|
item.shoot = 590;
|
|
item.shootSpeed = 1f;
|
|
}
|
|
|
|
public override Vector2? HoldoutOrigin()
|
|
{
|
|
return new Vector2(15, 15);
|
|
}
|
|
|
|
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 i = Main.myPlayer;
|
|
float num72 = item.shootSpeed;
|
|
Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default);
|
|
Vector2 vector3 = Main.MouseWorld + vector2;
|
|
float num78 = (float)Main.mouseX + Main.screenPosition.X + vector2.X;
|
|
float num79 = (float)Main.mouseY + Main.screenPosition.Y + vector2.Y;
|
|
if (player.gravDir == -1f)
|
|
{
|
|
num79 = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + vector2.Y;
|
|
}
|
|
float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
|
|
if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f))
|
|
{
|
|
num78 = (float)player.direction;
|
|
num79 = 0f;
|
|
num80 = num72;
|
|
}
|
|
else
|
|
{
|
|
num80 = num72 / num80;
|
|
}
|
|
|
|
int num107 = 3;
|
|
for (int num108 = 0; num108 < num107; num108++)
|
|
{
|
|
vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y);
|
|
vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-100, 101);
|
|
vector2.Y -= (float)(50 * num108);
|
|
num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
if (num79 < 0f)
|
|
{
|
|
num79 *= -1f;
|
|
}
|
|
if (num79 < 20f)
|
|
{
|
|
num79 = 20f;
|
|
}
|
|
num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
|
|
num80 = num72 / num80;
|
|
num78 *= num80;
|
|
num79 *= num80;
|
|
float speedX4 = num78 + (float)Main.rand.Next(-180, 181) * 0.02f;
|
|
float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f;
|
|
int proj = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockBack, i, 0f, (float)Main.rand.Next(3));
|
|
Main.projectile[proj].Calamity().forceMagic = true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|