Commit of decompiled and "updated" code.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace FabusMod.Projectiles.Shortsword;
|
||||
|
||||
public class FumaShuriken : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
//Sets.Homing[Projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 32;
|
||||
Projectile.height = 32;
|
||||
Projectile.aiStyle = 2;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.localAI[0] == 0f)
|
||||
{
|
||||
AdjustMagnitude(ref Projectile.velocity);
|
||||
Projectile.localAI[0] = 1f;
|
||||
}
|
||||
Vector2 move = Vector2.Zero;
|
||||
float distance = 400f;
|
||||
bool target = false;
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && !Main.npc[i].friendly && Main.npc[i].lifeMax > 5)
|
||||
{
|
||||
Vector2 newMove = Main.npc[i].Center - Projectile.Center;
|
||||
float distanceTo = (float)Math.Sqrt(newMove.X * newMove.X + newMove.Y * newMove.Y);
|
||||
if (distanceTo < distance)
|
||||
{
|
||||
move = newMove;
|
||||
distance = distanceTo;
|
||||
target = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target)
|
||||
{
|
||||
AdjustMagnitude(ref move);
|
||||
Projectile.velocity = (5f * Projectile.velocity + move) / 6f;
|
||||
AdjustMagnitude(ref Projectile.velocity);
|
||||
}
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
int num1 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType<Dusts.RyuuDust>(), 0f, 0f, 0, default, 1f);
|
||||
Dust obj = Main.dust[num1];
|
||||
obj.velocity *= 0f;
|
||||
Main.dust[num1].noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustMagnitude(ref Vector2 vector)
|
||||
{
|
||||
float magnitude = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
if (magnitude > 16f)
|
||||
{
|
||||
vector *= 16f / magnitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user