71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class MagnomalyBeam : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
public override string Texture => "CalamityMod/Projectiles/LaserProj";
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 5;
|
|
Projectile.height = 5;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.alpha = 255;
|
|
Projectile.penetrate = 1;
|
|
Projectile.extraUpdates = 5;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.tileCollide = false;
|
|
Projectile.ignoreWater = true;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Projectile.ai[1] == 1f)
|
|
{
|
|
Projectile.ai[1] = 0f;
|
|
}
|
|
if (Projectile.alpha > 0)
|
|
{
|
|
Projectile.alpha -= 25;
|
|
}
|
|
if (Projectile.alpha < 0)
|
|
{
|
|
Projectile.alpha = 0;
|
|
}
|
|
Lighting.AddLight(Projectile.Center, Main.DiscoR * 0.25f / 255f, Main.DiscoG * 0.25f / 255f, Main.DiscoB * 0.25f / 255f);
|
|
float num55 = 100f;
|
|
float num56 = 2f; //3
|
|
if (Projectile.ai[1] == 0f)
|
|
{
|
|
Projectile.localAI[0] += num56;
|
|
if (Projectile.localAI[0] > num55)
|
|
{
|
|
Projectile.localAI[0] = num55;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Projectile.localAI[0] -= num56;
|
|
if (Projectile.localAI[0] <= 0f)
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 2f, lightColor);
|
|
|
|
public override Color? GetAlpha(Color lightColor) => new Color(0, 250, 75, Projectile.alpha);
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<MiracleBlight>(), 300);
|
|
|
|
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<MiracleBlight>(), 300);
|
|
}
|
|
}
|