Commit of decompiled and "updated" code.

This commit is contained in:
Big Duckie
2022-07-03 14:13:26 -06:00
parent 3d34e53842
commit e1441e74a5
731 changed files with 18423 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace FabusMod.Projectiles;
public class RainbowBullet : ModProjectile
{
public override void SetStaticDefaults()
{
//Sets.Homing[Projectile.type] = true;
}
public override void SetDefaults()
{
Projectile.width = 2;
Projectile.height = 20;
Projectile.aiStyle = 1;
Projectile.friendly = true;
Projectile.hostile = false;
Projectile.penetrate = 1;
Projectile.timeLeft = 600;
Projectile.alpha = 255;
Projectile.light = 0.5f;
Projectile.ignoreWater = false;
Projectile.tileCollide = true;
Projectile.extraUpdates = 2;
AIType = 14;
}
public override void AI()
{
if (Projectile.alpha > 70)
{
Projectile projectile = Projectile;
projectile.alpha -= 15;
if (Projectile.alpha < 70)
{
Projectile.alpha = 70;
}
}
if (Projectile.localAI[0] == 0f)
{
AdjustMagnitude(ref Projectile.velocity);
Projectile.localAI[0] = 1f;
}
Vector2 move = Vector2.Zero;
float distance = 200f;
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 dust1 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType<Dusts.RainbowDust>(), 0f, 0f, 0, default, 1f);
int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType<Dusts.RainbowDust2>(), 0f, 0f, 0, default, 1f);
int dust3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType<Dusts.RainbowDust3>(), 0f, 0f, 0, default, 1f);
Dust obj = Main.dust[dust1];
obj.velocity *= 0f;
Main.dust[dust1].noGravity = true;
Dust obj2 = Main.dust[dust2];
obj2.velocity *= 0f;
Main.dust[dust2].noGravity = true;
Dust obj3 = Main.dust[dust3];
obj3.velocity *= 0f;
Main.dust[dust3].noGravity = true;
}
}
private void AdjustMagnitude(ref Vector2 vector)
{
float magnitude = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
if (magnitude > 6f)
{
vector *= 6f / magnitude;
}
}
}