2 - Stealth no longer gives movement speed. 3 - Moved a bunch of CalamityGlobalProjectile utilities to CalamityUtils where they belong. 4 - Renamed several things in CalamityGlobalProjectile
103 lines
4.2 KiB
C#
103 lines
4.2 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.CalPlayer;
|
|
using CalamityMod.Dusts;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class RadiantStar2 : ModProjectile
|
|
{
|
|
public override string Texture => "CalamityMod/Items/Weapons/Rogue/RadiantStar";
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Radiant Star");
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 24;
|
|
Projectile.height = 24;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.DamageType = RogueDamageClass.Instance;
|
|
}
|
|
|
|
public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 270 && target.CanBeChasedBy(Projectile);
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f);
|
|
if (Projectile.ai[0] == 1f)
|
|
{
|
|
float num472 = Projectile.Center.X;
|
|
float num473 = Projectile.Center.Y;
|
|
float num474 = Projectile.Calamity().stealthStrike ? 1800f : 600f;
|
|
float homingSpeed = 0.25f;
|
|
for (int num475 = 0; num475 < Main.maxNPCs; num475++)
|
|
{
|
|
if (Main.npc[num475].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses)
|
|
{
|
|
float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
|
|
float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
|
|
float num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY);
|
|
if (num478 < num474)
|
|
{
|
|
if (Main.npc[num475].position.X < num472)
|
|
{
|
|
Main.npc[num475].velocity.X += homingSpeed;
|
|
}
|
|
else
|
|
{
|
|
Main.npc[num475].velocity.X -= homingSpeed;
|
|
}
|
|
if (Main.npc[num475].position.Y < num473)
|
|
{
|
|
Main.npc[num475].velocity.Y += homingSpeed;
|
|
}
|
|
else
|
|
{
|
|
Main.npc[num475].velocity.Y -= homingSpeed;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (Projectile.timeLeft < 270)
|
|
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, Projectile.Calamity().stealthStrike ? 900f : 450f, 12f, 20f);
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 120);
|
|
}
|
|
|
|
public override void OnHitPvp(Player target, int damage, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 120);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, ModContent.DustType<AstralBlue>(), Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
}
|
|
}
|
|
}
|