Added a telegraph to Destroyer.

1. Added a telegraph to Destroyer's lasers.
2. Added two new particles related to Destroyer's telegraph.
This commit is contained in:
Memes committed 2024-03-17 02:49:06 +01:00
1 parent 16eedc191d
commit fd86358164
4 files changed
+188

No files matched your search

@@ -1,6 +1,7 @@
using System;
using CalamityMod.Events;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -18,6 +19,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
public const float DRIncraeseTime = 600f;
public const float DeathModeLaserBreathGateValue = 600f;
public const float LaserTelegraphTime = 120f;
public const float SparkTelegraphTime = 30f;
public const float FlightPhaseGateValue = 900f;
public const float FlightPhaseResetGateValue = FlightPhaseGateValue * 2f;
private const float Phase4FlightPhaseTimerSetValue = FlightPhaseGateValue * 0.5f;
@@ -483,6 +485,43 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (calamityGlobalNPC.newAI[0] % 20f == 0f && ableToFireLaser)
npc.SyncExtraAI();
Color telegraphColor = Color.Transparent;
switch (calamityGlobalNPC.destroyerLaserColor)
{
case 0:
telegraphColor = Color.Red;
break;
case 1:
telegraphColor = Color.Green;
break;
case 2:
telegraphColor = Color.Cyan;
break;
}
if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime)
{
Particle telegraph = new DestroyerReticleTelegraph(
npc,
telegraphColor,
1.5f,
0.15f,
(int)LaserTelegraphTime);
GeneralParticleHandler.SpawnParticle(telegraph);
}
if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime)
{
Particle spark = new DestroyerSparkTelegraph(
npc,
telegraphColor * 2f,
Color.White,
3f,
30,
Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt());
GeneralParticleHandler.SpawnParticle(spark);
}
// Shoot lasers
// Shoot nothing if probe has been launched
if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser)
@@ -1186,6 +1225,43 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (npc.localAI[0] % 20f == 0f && ableToFireLaser)
npc.SyncVanillaLocalAI();
Color telegraphColor = Color.Transparent;
switch (npc.Calamity().destroyerLaserColor)
{
case 0:
telegraphColor = Color.Red;
break;
case 1:
telegraphColor = Color.Green;
break;
case 2:
telegraphColor = Color.Cyan;
break;
}
if (npc.localAI[0] == shootProjectileGateValue - LaserTelegraphTime)
{
Particle telegraph = new DestroyerReticleTelegraph(
npc,
telegraphColor,
1.5f,
0.15f,
(int)LaserTelegraphTime);
GeneralParticleHandler.SpawnParticle(telegraph);
}
if (npc.localAI[0] == shootProjectileGateValue - SparkTelegraphTime)
{
Particle spark = new DestroyerSparkTelegraph(
npc,
telegraphColor * 2f,
Color.White,
3f,
30,
Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt());
GeneralParticleHandler.SpawnParticle(spark);
}
if (npc.localAI[0] >= shootProjectileGateValue && ableToFireLaser)
{
int numProbeSegments = 0;
+53
View File
@@ -0,0 +1,53 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Particles
{
public class DestroyerReticleTelegraph : Particle
{
public override string Texture => "CalamityMod/Particles/DestroyerReticleTelegraph";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
public override bool UseCustomDraw => true;
public override bool Important => true;
private NPC NPCToFollow;
private float OriginalScale;
private float FinalScale;
private float Opacity;
private int RotationDirection;
public DestroyerReticleTelegraph(NPC npcToFollow, Color color, float originalScale, float finalScale, int lifeTime)
{
NPCToFollow = npcToFollow;
Color = color;
OriginalScale = originalScale;
Scale = originalScale;
FinalScale = finalScale;
Lifetime = lifeTime;
RotationDirection = Main.rand.NextBool().ToDirectionInt();
}
public override void Update()
{
float pulseProgress = PiecewiseAnimation(LifetimeCompletion, [new(EasingType.PolyOut, 0f, 0f, 1f, 4)]);
Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress);
Opacity = pulseProgress;
Rotation += MathHelper.ToRadians(8f) * (1f - pulseProgress) * RotationDirection;
if (NPCToFollow != null && NPCToFollow.active && !Main.tile[NPCToFollow.Center.ToSafeTileCoordinates()].IsTileSolid())
Position = NPCToFollow.Center;
else
Kill();
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * Opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+59
View File
@@ -0,0 +1,59 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class DestroyerSparkTelegraph : Particle
{
public override string Texture => "CalamityMod/Particles/Sparkle2";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public override bool Important => true;
private NPC NPCToFollow;
private float Spin;
private float Opacity;
private Color Bloom;
private float BloomScale;
public DestroyerSparkTelegraph(NPC npcToFollow, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 0f, float bloomScale = 1f)
{
NPCToFollow = npcToFollow;
Color = color;
Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
Spin = rotationSpeed;
BloomScale = bloomScale;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
}
public override void Update()
{
Opacity = MathF.Sin(LifetimeCompletion * MathHelper.Pi);
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
if (NPCToFollow != null && NPCToFollow.active && !Main.tile[NPCToFollow.Center.ToSafeTileCoordinates()].IsTileSolid())
Position = NPCToFollow.Center;
else
Kill();
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D starTexture = ModContent.Request<Texture2D>(Texture).Value;
Texture2D bloomTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
// Ajust the bloom's texture to be the same size as the star's.
float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * Opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * Opacity * 0.5f, Rotation + MathHelper.PiOver4, starTexture.Size() / 2f, Scale * 0.75f, SpriteEffects.None, 0);
spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * Opacity, Rotation, starTexture.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}