Files
CalamityModPublic/Projectiles/Typeless/ChaosGeyser.cs
T

118 lines
4.2 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
{
public class ChaosGeyser : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Geyser");
}
public override void SetDefaults()
{
projectile.width = 12;
projectile.height = 96;
projectile.friendly = true;
projectile.penetrate = 3;
projectile.timeLeft = 120;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 6;
}
// Reduce damage of projectiles if more than the cap are active
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type];
int cap = 3;
int oldDamage = damage;
if (projectileCount > cap)
{
damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05));
if (damage < 1)
damage = 1;
}
}
public override void AI()
{
if (projectile.velocity.X != projectile.velocity.X)
{
projectile.velocity.X = projectile.velocity.X * -0.1f;
}
if (projectile.velocity.X != projectile.velocity.X)
{
projectile.velocity.X = projectile.velocity.X * -0.5f;
}
if (projectile.velocity.Y != projectile.velocity.Y && projectile.velocity.Y > 1f)
{
projectile.velocity.Y = projectile.velocity.Y * -0.5f;
}
projectile.ai[0] += 1f;
if (projectile.ai[0] > 5f)
{
projectile.ai[0] = 5f;
if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f)
{
projectile.velocity.X = projectile.velocity.X * 0.97f;
if ((double)projectile.velocity.X > -0.01 && (double)projectile.velocity.X < 0.01)
{
projectile.velocity.X = 0f;
projectile.netUpdate = true;
}
}
projectile.velocity.Y = projectile.velocity.Y + 0.2f;
}
if (projectile.ai[1] == 0f)
{
projectile.ai[1] = 1f;
Main.PlaySound(SoundID.Item20, (int)projectile.position.X, (int)projectile.position.Y);
}
projectile.rotation += projectile.velocity.X * 0.1f;
int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 100, default, 1f);
Dust dust = Main.dust[num199];
dust.position.X -= 2f;
dust.position.Y += 2f;
dust.scale += (float)Main.rand.Next(50) * 0.01f;
dust.noGravity = true;
dust.velocity.Y -= 16f;
if (Main.rand.NextBool(2))
{
int num200 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 100, default, 1f);
Dust dust2 = Main.dust[num200];
dust2.position.X -= 2f;
dust2.position.Y += 2f;
dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f;
dust2.noGravity = true;
dust2.velocity *= 0.8f;
}
if ((double)projectile.velocity.Y < 0.25 && (double)projectile.velocity.Y > 0.15)
{
projectile.velocity.X = projectile.velocity.X * 0.8f;
}
projectile.rotation = -projectile.velocity.X * 0.05f;
if (projectile.velocity.Y > 16f)
{
projectile.velocity.Y = 16f;
}
}
public override bool OnTileCollide(Vector2 oldVelocity) => false;
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 180);
}
public override void OnHitPvp(Player target, int damage, bool crit)
{
target.AddBuff(BuffID.OnFire, 180);
}
}
}