Files
CalamityModPublic/Projectiles/Typeless/GenericElectricSpark.cs
T
CongratsIsTrash f2e5a53e8d Amidias' Spark rework
* Attacks inflict Static Discharge while underwater
* Getting hit shocks the enemy, making them drop sparks for 2 seconds
* These changes are inherited by The Transformer, with longer Static Discharge infliction duration and faster spark spawning. Removed its damage reduction against bullet attacks.
* Amidias' Spark and The Transformer cannot be equipped at the same time
* Also contains tooltip consistency changes for making all instances of debuff multipliers end with "x"
2024-07-22 00:36:56 -04:00

78 lines
2.9 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
{
public class GenericElectricSpark : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Typeless";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 6;
Projectile.height = 12;
Projectile.friendly = true;
Projectile.penetrate = 5;
Projectile.timeLeft = 60;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 15;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
// Prevents Amidias' Spark sparks from inflicting it to not make its other effect worthless
if (Projectile.ai[1] != 1f)
target.AddBuff(ModContent.BuffType<StaticDischarge>(), 120);
}
public override void AI()
{
if (Projectile.velocity.X != Projectile.velocity.X)
Projectile.velocity.X *= -0.1f;
if (Projectile.velocity.Y != Projectile.velocity.Y && Projectile.velocity.Y > 1f)
Projectile.velocity.Y *= -0.5f;
Projectile.ai[0]++;
if (Projectile.ai[0] > 5f)
{
Projectile.ai[0] = 5f;
if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f)
{
Projectile.velocity.X *= 0.97f;
if (MathF.Abs(Projectile.velocity.X) < 0.01f)
{
Projectile.velocity.X = 0f;
Projectile.netUpdate = true;
}
}
Projectile.velocity.Y += 0.2f;
}
Dust spark = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.UnusedWhiteBluePurple, Alpha: 100);
spark.position.X -= 2f;
spark.position.Y += 2f;
spark.scale += Main.rand.NextFloat(0f, 0.5f);
spark.noGravity = true;
spark.velocity.Y -= 2f;
if (Main.rand.NextBool())
{
spark = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.UnusedWhiteBluePurple, Alpha: 100);
spark.position.X -= 2f;
spark.position.Y += 2f;
spark.scale += Main.rand.NextFloat(0.3f, 0.8f);
spark.noGravity = true;
spark.velocity *= 0.1f;
}
if (Projectile.velocity.Y > 16f)
Projectile.velocity.Y = 16f;
}
public override bool OnTileCollide(Vector2 oldVelocity) => false;
}
}