Destroyer laser light telegraphs, someone else can handle any fancier vfx.
This commit is contained in:
1 parent
2a26750ff0
commit
efb810af03
3 files changed
+349
-245
No files matched your search
@@ -644,7 +644,6 @@ namespace CalamityMod
|
||||
{ new Tuple<int, int>(NPCID.TheDestroyerBody, ProjectileID.DeathLaser), new int[] { 44, 96, 116, 128, 150 } },
|
||||
{ new Tuple<int, int>(NPCID.TheDestroyerBody, ModContent.ProjectileType<DestroyerCursedLaser>()), new int[] { 46, 108, 128, 140, 186 } },
|
||||
{ new Tuple<int, int>(NPCID.TheDestroyerBody, ModContent.ProjectileType<DestroyerElectricLaser>()), new int[] { 48, 116, 136, 152, 210 } },
|
||||
{ new Tuple<int, int>(NPCID.TheDestroyerBody, ProjectileID.EyeLaser), new int[] { 40, 88, 100, 112, 132 } },
|
||||
{ new Tuple<int, int>(NPCID.Probe, ProjectileID.PinkLaser), new int[] { 50, 88, 100, 112, 132 } },
|
||||
|
||||
{ new Tuple<int, int>(ModContent.NPCType<BrimstoneElemental>(), ModContent.ProjectileType<BrimstoneHellfireball>()), new int[] { 80, 140, 160, 176, 234 } },
|
||||
|
||||
+127
-94
@@ -152,6 +152,12 @@ namespace CalamityMod.NPCs
|
||||
public const float CatchUpDistance200Tiles = 3200f;
|
||||
public const float CatchUpDistance350Tiles = 5600f;
|
||||
|
||||
/// <summary>
|
||||
/// Destroyer laser colors, used for telegraphs
|
||||
/// None = -1, Red = 0, Green = 1, Cyan = 2
|
||||
/// </summary>
|
||||
public int destroyerLaserColor = -1;
|
||||
|
||||
// Boss Zen distance
|
||||
private const float BossZenDistance = 6400f;
|
||||
|
||||
@@ -398,6 +404,8 @@ namespace CalamityMod.NPCs
|
||||
|
||||
myClone.miscDefenseLoss = miscDefenseLoss;
|
||||
|
||||
myClone.destroyerLaserColor = destroyerLaserColor;
|
||||
|
||||
myClone.dashImmunityTime = new int[maxPlayerImmunities];
|
||||
for (int i = 0; i < maxPlayerImmunities; ++i)
|
||||
myClone.dashImmunityTime[i] = dashImmunityTime[i];
|
||||
@@ -6673,6 +6681,125 @@ namespace CalamityMod.NPCs
|
||||
spriteBatch.ExitShaderRegion();
|
||||
}
|
||||
|
||||
// Destroyer drawing and laser telegraphs
|
||||
else if (CalamityLists.DestroyerIDs.Contains(npc.type))
|
||||
{
|
||||
Texture2D npcTexture = TextureAssets.Npc[npc.type].Value;
|
||||
int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type];
|
||||
|
||||
Vector2 halfSize = npc.frame.Size() / 2;
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (npc.spriteDirection == 1)
|
||||
spriteEffects = SpriteEffects.FlipHorizontally;
|
||||
|
||||
if (npc.type == NPCID.TheDestroyerBody)
|
||||
{
|
||||
if (npc.ai[2] == 0f)
|
||||
npc.frame.Y = 0;
|
||||
else
|
||||
npc.frame.Y = frameHeight;
|
||||
}
|
||||
|
||||
Color segmentDrawColor = npc.GetAlpha(drawColor);
|
||||
|
||||
// Check if Destroyer is behind tiles and, if so, how much of the segment is behind tiles and adjust color accordingly
|
||||
int x = (int)((npc.position.X - 8f) / 16f);
|
||||
int x2 = (int)((npc.position.X + npc.width + 8f) / 16f);
|
||||
int y = (int)((npc.position.Y - 8f) / 16f);
|
||||
int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f);
|
||||
for (int l = x; l <= x2; l++)
|
||||
{
|
||||
for (int m = y; m <= y2; m++)
|
||||
{
|
||||
if (Lighting.Brightness(l, m) == 0f)
|
||||
segmentDrawColor = Color.Black;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw segments
|
||||
spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY),
|
||||
npc.frame, segmentDrawColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f);
|
||||
|
||||
// Draw lights
|
||||
if (npc.ai[2] == 0f && segmentDrawColor != Color.Black)
|
||||
{
|
||||
float destroyerLifeRatio = 1f;
|
||||
if (npc.realLife >= 0)
|
||||
destroyerLifeRatio = Main.npc[npc.realLife].life / (float)Main.npc[npc.realLife].lifeMax;
|
||||
|
||||
// Light colors
|
||||
Color groundColor = new Color(128, 25, 25, 0) * (1f - npc.alpha / 255f);
|
||||
Color flightColor = new Color(25, 25, 128, 0) * (1f - npc.alpha / 255f);
|
||||
Color segmentColor = ((newAI[3] >= 900f && destroyerLifeRatio < 0.5f) || (newAI[1] < 600f && newAI[1] > 60f)) ? flightColor : groundColor;
|
||||
Color telegraphColor = Color.Red;
|
||||
|
||||
// Telegraph for the laser breath
|
||||
float telegraphProgress = 0f;
|
||||
if (npc.type == NPCID.TheDestroyer && (CalamityWorld.death || BossRushEvent.BossRushActive))
|
||||
{
|
||||
float telegraphGateValue = DestroyerAI.DeathModeLaserBreathGateValue - DestroyerAI.LaserTelegraphTime;
|
||||
if (newAI[0] > telegraphGateValue)
|
||||
{
|
||||
switch (destroyerLaserColor)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
telegraphColor = Color.Green;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
telegraphColor = Color.Cyan;
|
||||
break;
|
||||
}
|
||||
telegraphProgress = MathHelper.Clamp((newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f);
|
||||
}
|
||||
}
|
||||
else if (npc.type == NPCID.TheDestroyerBody && (CalamityWorld.revenge || BossRushEvent.BossRushActive))
|
||||
{
|
||||
float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 270f : 450f;
|
||||
float bodySegmentTime = npc.ai[0] * 30f;
|
||||
float shootProjectileGateValue = bodySegmentTime + shootProjectileTime;
|
||||
if (newAI[0] > shootProjectileGateValue - DestroyerAI.LaserTelegraphTime)
|
||||
{
|
||||
switch (destroyerLaserColor)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
telegraphColor = Color.Green;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
telegraphColor = Color.Cyan;
|
||||
break;
|
||||
}
|
||||
telegraphProgress = MathHelper.Clamp((newAI[0] - shootProjectileGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f);
|
||||
}
|
||||
}
|
||||
else if (npc.type == NPCID.TheDestroyerBody)
|
||||
{
|
||||
int laserGateValue = 1800;
|
||||
if (Main.expertMode)
|
||||
laserGateValue = (int)(laserGateValue * MathHelper.Lerp(Main.masterMode ? 0.5f : 0.7f, 1f, npc.life / (float)npc.lifeMax));
|
||||
|
||||
if (npc.localAI[0] > laserGateValue - DestroyerAI.LaserTelegraphTime)
|
||||
telegraphProgress = MathHelper.Clamp((npc.localAI[0] - laserGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f);
|
||||
}
|
||||
|
||||
int totalDraws = 3;
|
||||
for (int i = 0; i < totalDraws; i++)
|
||||
{
|
||||
spriteBatch.Draw(TextureAssets.Dest[npc.type - NPCID.TheDestroyer].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame,
|
||||
Color.Lerp(segmentColor, telegraphColor, telegraphProgress), npc.rotation, halfSize, npc.scale, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CalamityWorld.revenge || BossRushEvent.BossRushActive)
|
||||
{
|
||||
// Create additional afterimages in the cardinal directions in Rev+
|
||||
@@ -6906,100 +7033,6 @@ namespace CalamityMod.NPCs
|
||||
else
|
||||
spriteBatch.Draw(TextureAssets.BoneEyes.Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, eyesColor, npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f);
|
||||
}
|
||||
else if (CalamityLists.DestroyerIDs.Contains(npc.type))
|
||||
{
|
||||
Texture2D npcTexture = TextureAssets.Npc[npc.type].Value;
|
||||
int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type];
|
||||
|
||||
Vector2 halfSize = npc.frame.Size() / 2;
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (npc.spriteDirection == 1)
|
||||
spriteEffects = SpriteEffects.FlipHorizontally;
|
||||
|
||||
if (npc.type == NPCID.TheDestroyerBody)
|
||||
{
|
||||
if (npc.ai[2] == 0f)
|
||||
npc.frame.Y = 0;
|
||||
else
|
||||
npc.frame.Y = frameHeight;
|
||||
}
|
||||
|
||||
Color segmentDrawColor = npc.GetAlpha(drawColor);
|
||||
|
||||
// Check if Destroyer is behind tiles and if so, how much of the segment is behind tiles and adjust color accordingly
|
||||
int x = (int)((npc.position.X - 8f) / 16f);
|
||||
int x2 = (int)((npc.position.X + npc.width + 8f) / 16f);
|
||||
int y = (int)((npc.position.Y - 8f) / 16f);
|
||||
int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f);
|
||||
for (int l = x; l <= x2; l++)
|
||||
{
|
||||
for (int m = y; m <= y2; m++)
|
||||
{
|
||||
if (Lighting.Brightness(l, m) == 0f)
|
||||
segmentDrawColor = Color.Black;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw segments
|
||||
spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY),
|
||||
npc.frame, segmentDrawColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f);
|
||||
|
||||
// Draw lights
|
||||
if (npc.ai[2] == 0f && segmentDrawColor != Color.Black)
|
||||
{
|
||||
float destroyerLifeRatio = 1f;
|
||||
if (npc.realLife >= 0)
|
||||
destroyerLifeRatio = Main.npc[npc.realLife].life / (float)Main.npc[npc.realLife].lifeMax;
|
||||
|
||||
float shootProjectile = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 180 : 300;
|
||||
float timer = npc.ai[0] * 30f;
|
||||
float shootProjectileGateValue = timer + shootProjectile;
|
||||
float glowDuration = 120f;
|
||||
float startGlowingGateValue = shootProjectileGateValue - glowDuration;
|
||||
|
||||
if ((newAI[3] >= 900f && destroyerLifeRatio < 0.5f) || (newAI[1] < 600f && newAI[1] > 60f))
|
||||
{
|
||||
Color drawColor2 = new Color(50, 50, 255, 0) * (1f - npc.alpha / 255f);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
spriteBatch.Draw(TextureAssets.Dest[npc.type - NPCID.TheDestroyer].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame,
|
||||
drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f);
|
||||
}
|
||||
|
||||
// Glow telegraph for lasers
|
||||
/*if (newAI[0] > startGlowingGateValue)
|
||||
{
|
||||
Texture2D bloomTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
|
||||
Color bloom = drawColor2;
|
||||
bloom = Main.hslToRgb((Main.rgbToHsl(bloom).X + 0.02f) % 1, Main.rgbToHsl(bloom).Y, Main.rgbToHsl(bloom).Z);
|
||||
float scalingFactor = (newAI[0] - startGlowingGateValue) / glowDuration;
|
||||
float opacity = (float)Math.Sin(MathHelper.PiOver2 + scalingFactor * MathHelper.PiOver2);
|
||||
float properBloomSize = (float)npc.height / (float)bloomTexture.Height;
|
||||
float scale = scalingFactor;
|
||||
spriteBatch.Draw(bloomTexture, npc.Center - Main.screenPosition, null, bloom * opacity * 0.5f, 0, bloomTexture.Size() / 2f, scale * 1f * properBloomSize, SpriteEffects.None, 0);
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
Color drawColor2 = new Color(255, 255, 255, 0) * (1f - npc.alpha / 255f);
|
||||
spriteBatch.Draw(TextureAssets.Dest[npc.type - NPCID.TheDestroyer].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame,
|
||||
drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f);
|
||||
|
||||
// Glow telegraph for lasers
|
||||
/*if (newAI[0] > startGlowingGateValue)
|
||||
{
|
||||
Texture2D bloomTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
|
||||
Color bloom = drawColor2;
|
||||
bloom = Main.hslToRgb((Main.rgbToHsl(bloom).X + 0.02f) % 1, Main.rgbToHsl(bloom).Y, Main.rgbToHsl(bloom).Z);
|
||||
float scalingFactor = (newAI[0] - startGlowingGateValue) / glowDuration;
|
||||
float opacity = (float)Math.Sin(MathHelper.PiOver2 + scalingFactor * MathHelper.PiOver2);
|
||||
float properBloomSize = (float)npc.height / (float)bloomTexture.Height;
|
||||
float scale = scalingFactor;
|
||||
spriteBatch.Draw(bloomTexture, npc.Center - Main.screenPosition, null, bloom * opacity * 0.5f, 0, bloomTexture.Size() / 2f, scale * 1f * properBloomSize, SpriteEffects.None, 0);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
|
||||
public static class DestroyerAI
|
||||
{
|
||||
public const float DRIncraeseTime = 600f;
|
||||
public const float DeathModeLaserBreathGateValue = 600f;
|
||||
public const float LaserTelegraphTime = 120f;
|
||||
|
||||
public static bool BuffedDestroyerAI(NPC npc, Mod mod)
|
||||
{
|
||||
@@ -269,9 +271,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
if (npc.type == NPCID.TheDestroyer)
|
||||
{
|
||||
if (npc.type == NPCID.TheDestroyer)
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
// Spawn segments from head
|
||||
if (npc.ai[0] == 0f)
|
||||
@@ -294,123 +296,42 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
|
||||
index = segment;
|
||||
}
|
||||
}
|
||||
|
||||
// Laser breath in Death Mode
|
||||
if (spitLaserSpreads)
|
||||
{
|
||||
float laserBreathGateValue = 600f;
|
||||
if (calamityGlobalNPC.newAI[0] < laserBreathGateValue)
|
||||
calamityGlobalNPC.newAI[0] += 1f;
|
||||
|
||||
if (npc.SafeDirectionTo(player.Center).AngleBetween((npc.rotation - MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(18f) &&
|
||||
calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f &&
|
||||
Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
|
||||
{
|
||||
if (calamityGlobalNPC.newAI[0] % 30f == 0f)
|
||||
{
|
||||
float velocity = bossRush ? 6f : death ? 5.333f : 5f;
|
||||
int type = phase3 ? ModContent.ProjectileType<DestroyerElectricLaser>() : phase2 ? ModContent.ProjectileType<DestroyerCursedLaser>() : ProjectileID.DeathLaser;
|
||||
int damage = npc.GetProjectileDamage(type);
|
||||
|
||||
// Reduce mech boss projectile damage depending on the new ore progression changes
|
||||
if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive)
|
||||
{
|
||||
double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert;
|
||||
double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert;
|
||||
if (!NPC.downedMechBossAny)
|
||||
damage = (int)(damage * firstMechMultiplier);
|
||||
else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1))
|
||||
damage = (int)(damage * secondMechMultiplier);
|
||||
}
|
||||
|
||||
Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity;
|
||||
int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (masterMode ? 9 : 7) : (masterMode ? 6 : 4);
|
||||
int spread = masterMode ? 75 : 54;
|
||||
float offset = type == ModContent.ProjectileType<DestroyerElectricLaser>() ? 60f : 30f;
|
||||
float rotation = MathHelper.ToRadians(spread);
|
||||
for (int i = 0; i < numProj; i++)
|
||||
{
|
||||
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1)));
|
||||
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * offset, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f);
|
||||
Main.projectile[proj].timeLeft = 900;
|
||||
}
|
||||
}
|
||||
|
||||
calamityGlobalNPC.newAI[0] += 1f;
|
||||
if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f)
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fire lasers
|
||||
if (npc.type == NPCID.TheDestroyerBody)
|
||||
// Laser breath in Death Mode
|
||||
if (spitLaserSpreads)
|
||||
{
|
||||
// Laser rate of fire
|
||||
calamityGlobalNPC.newAI[0] += (float)Main.rand.Next(4);
|
||||
float shootProjectileTime = death ? 270 : 450;
|
||||
float bodySegmentTime = npc.ai[0] * 30f;
|
||||
float shootProjectileGateValue = bodySegmentTime + shootProjectileTime;
|
||||
// Set laser color and type
|
||||
if (calamityGlobalNPC.destroyerLaserColor == -1)
|
||||
calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1;
|
||||
|
||||
// Shoot lasers
|
||||
// 50% chance to shoot harmless scrap if probe has been launched
|
||||
if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue)
|
||||
float laserBreathGateValue = DeathModeLaserBreathGateValue;
|
||||
if (calamityGlobalNPC.newAI[0] < laserBreathGateValue)
|
||||
calamityGlobalNPC.newAI[0] += 1f;
|
||||
|
||||
if (npc.SafeDirectionTo(player.Center).AngleBetween((npc.rotation - MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(18f) &&
|
||||
calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f &&
|
||||
Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
|
||||
{
|
||||
if (!masterMode)
|
||||
if (calamityGlobalNPC.newAI[0] % 30f == 0f)
|
||||
{
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
npc.TargetClosest();
|
||||
}
|
||||
|
||||
if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
|
||||
{
|
||||
if (masterMode)
|
||||
{
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
npc.TargetClosest();
|
||||
}
|
||||
|
||||
// Laser speed
|
||||
float projectileSpeed = 3.5f + Main.rand.NextFloat() * 1.5f;
|
||||
projectileSpeed += enrageScale;
|
||||
|
||||
// Set projectile damage and type
|
||||
int projectileType = ProjectileID.DeathLaser;
|
||||
float laserSpawnDistance = 10f;
|
||||
int random = phase3 ? 4 : phase2 ? 3 : 2;
|
||||
switch (Main.rand.Next(random))
|
||||
float velocity = bossRush ? 6f : death ? 5.333f : 5f;
|
||||
int type = ProjectileID.DeathLaser;
|
||||
switch (calamityGlobalNPC.destroyerLaserColor)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
type = ModContent.ProjectileType<DestroyerCursedLaser>();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
projectileType = ModContent.ProjectileType<DestroyerCursedLaser>();
|
||||
break;
|
||||
case 3:
|
||||
projectileType = ModContent.ProjectileType<DestroyerElectricLaser>();
|
||||
type = ModContent.ProjectileType<DestroyerElectricLaser>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (calamityGlobalNPC.newAI[2] > 0f || bossRush)
|
||||
{
|
||||
projectileType = ModContent.ProjectileType<DestroyerElectricLaser>();
|
||||
laserSpawnDistance = 20f;
|
||||
}
|
||||
|
||||
bool weakLaser = false;
|
||||
if (probeLaunched)
|
||||
{
|
||||
weakLaser = true;
|
||||
projectileType = ProjectileID.EyeLaser;
|
||||
laserSpawnDistance = 0f;
|
||||
}
|
||||
|
||||
// Get target vector
|
||||
Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed;
|
||||
Vector2 projectileSpawn = npc.Center + projectileVelocity * laserSpawnDistance;
|
||||
|
||||
// Shoot projectile
|
||||
int damage = npc.GetProjectileDamage(projectileType);
|
||||
int damage = npc.GetProjectileDamage(type);
|
||||
|
||||
// Reduce mech boss projectile damage depending on the new ore progression changes
|
||||
if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive)
|
||||
@@ -423,11 +344,140 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
|
||||
damage = (int)(damage * secondMechMultiplier);
|
||||
}
|
||||
|
||||
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f);
|
||||
Main.projectile[proj].timeLeft = weakLaser ? 600 : 900;
|
||||
|
||||
npc.netUpdate = true;
|
||||
Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity;
|
||||
int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (masterMode ? 9 : 7) : (masterMode ? 6 : 4);
|
||||
int spread = masterMode ? 75 : 54;
|
||||
float offset = type == ModContent.ProjectileType<DestroyerElectricLaser>() ? 60f : 30f;
|
||||
float rotation = MathHelper.ToRadians(spread);
|
||||
for (int i = 0; i < numProj; i++)
|
||||
{
|
||||
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1)));
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * offset, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f);
|
||||
Main.projectile[proj].timeLeft = 900;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calamityGlobalNPC.newAI[0] += 1f;
|
||||
if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f)
|
||||
{
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
calamityGlobalNPC.destroyerLaserColor = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fire lasers
|
||||
if (npc.type == NPCID.TheDestroyerBody)
|
||||
{
|
||||
// Set laser color and type
|
||||
if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched)
|
||||
{
|
||||
int random = phase3 ? 4 : phase2 ? 3 : 2;
|
||||
switch (Main.rand.Next(random))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
calamityGlobalNPC.destroyerLaserColor = 0;
|
||||
break;
|
||||
case 2:
|
||||
calamityGlobalNPC.destroyerLaserColor = 1;
|
||||
break;
|
||||
case 3:
|
||||
calamityGlobalNPC.destroyerLaserColor = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (calamityGlobalNPC.newAI[2] > 0f || bossRush)
|
||||
calamityGlobalNPC.destroyerLaserColor = 2;
|
||||
}
|
||||
|
||||
if (probeLaunched)
|
||||
calamityGlobalNPC.destroyerLaserColor = -1;
|
||||
|
||||
// Laser rate of fire
|
||||
float shootProjectileTime = death ? 270f : 450f;
|
||||
float bodySegmentTime = npc.ai[0] * 30f;
|
||||
float shootProjectileGateValue = bodySegmentTime + shootProjectileTime;
|
||||
float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : (float)Main.rand.Next(4);
|
||||
calamityGlobalNPC.newAI[0] += laserTimerIncrement;
|
||||
|
||||
// Shoot lasers
|
||||
// 50% chance to shoot harmless scrap if probe has been launched
|
||||
if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue)
|
||||
{
|
||||
if (!masterMode)
|
||||
{
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
npc.TargetClosest();
|
||||
}
|
||||
|
||||
if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
|
||||
{
|
||||
if (masterMode)
|
||||
{
|
||||
calamityGlobalNPC.newAI[0] = 0f;
|
||||
npc.TargetClosest();
|
||||
}
|
||||
|
||||
// Laser speed
|
||||
float projectileSpeed = 3.5f + Main.rand.NextFloat() * 1.5f;
|
||||
projectileSpeed += enrageScale;
|
||||
|
||||
// Set projectile damage and type
|
||||
int projectileType = ProjectileID.DeathLaser;
|
||||
float laserSpawnDistance = 10f;
|
||||
switch (calamityGlobalNPC.destroyerLaserColor)
|
||||
{
|
||||
case -1:
|
||||
projectileType = ProjectileID.SaucerScrap;
|
||||
laserSpawnDistance = 0f;
|
||||
break;
|
||||
|
||||
default:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
projectileType = ModContent.ProjectileType<DestroyerCursedLaser>();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
projectileType = ModContent.ProjectileType<DestroyerElectricLaser>();
|
||||
laserSpawnDistance = 20f;
|
||||
break;
|
||||
}
|
||||
|
||||
// Get target vector
|
||||
Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed;
|
||||
Vector2 projectileSpawn = npc.Center + projectileVelocity * laserSpawnDistance;
|
||||
|
||||
// Shoot projectile
|
||||
int damage = projectileType == ProjectileID.SaucerScrap ? 0 : npc.GetProjectileDamage(projectileType);
|
||||
|
||||
// Reduce mech boss projectile damage depending on the new ore progression changes
|
||||
if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive)
|
||||
{
|
||||
double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert;
|
||||
double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert;
|
||||
if (!NPC.downedMechBossAny)
|
||||
damage = (int)(damage * firstMechMultiplier);
|
||||
else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1))
|
||||
damage = (int)(damage * secondMechMultiplier);
|
||||
}
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f);
|
||||
Main.projectile[proj].timeLeft = projectileType == ProjectileID.SaucerScrap ? 90 : 900;
|
||||
}
|
||||
|
||||
calamityGlobalNPC.destroyerLaserColor = -1;
|
||||
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -514,6 +564,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
|
||||
else
|
||||
npc.localAI[1] = 0f;
|
||||
|
||||
if (npc.type != NPCID.TheDestroyerBody || !probeLaunched)
|
||||
Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), flyAtTarget ? 0.05f : 0.3f, 0.1f, flyAtTarget ? 0.3f : 0.05f);
|
||||
|
||||
// Despawn
|
||||
float segmentVelocity = masterMode ? 20f : 16f;
|
||||
if (player.dead)
|
||||
@@ -931,51 +984,65 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
|
||||
num6 = num5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (npc.type == NPCID.TheDestroyerBody)
|
||||
if (npc.type == NPCID.TheDestroyerBody)
|
||||
{
|
||||
bool probeLaunched = npc.ai[2] == 1f;
|
||||
if (npc.Calamity().destroyerLaserColor == -1 && !probeLaunched)
|
||||
npc.Calamity().destroyerLaserColor = 0;
|
||||
if (probeLaunched)
|
||||
npc.Calamity().destroyerLaserColor = -1;
|
||||
|
||||
int laserGateValue = 1800;
|
||||
if (Main.expertMode)
|
||||
laserGateValue = (int)(laserGateValue * MathHelper.Lerp(Main.masterMode ? 0.5f : 0.7f, 1f, npc.life / (float)npc.lifeMax));
|
||||
|
||||
float laserTimerIncrement = (npc.localAI[0] > laserGateValue - LaserTelegraphTime) ? 1f : (float)Main.rand.Next(4);
|
||||
npc.localAI[0] += laserTimerIncrement;
|
||||
|
||||
if (npc.localAI[0] >= (float)laserGateValue)
|
||||
{
|
||||
npc.localAI[0] += Main.rand.Next(4);
|
||||
int chanceToFire = Main.rand.Next(1400, 26000);
|
||||
if (Main.expertMode)
|
||||
chanceToFire = (int)(chanceToFire * MathHelper.Lerp(Main.masterMode ? 0.5f : 0.7f, 1f, npc.life / (float)npc.lifeMax));
|
||||
|
||||
if (npc.localAI[0] >= (float)chanceToFire)
|
||||
npc.localAI[0] = 0f;
|
||||
npc.TargetClosest();
|
||||
if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
|
||||
{
|
||||
npc.localAI[0] = 0f;
|
||||
npc.TargetClosest();
|
||||
if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
|
||||
float laserVelocity = Main.masterMode ? 9f : Main.expertMode ? 8.5f : 8f;
|
||||
Vector2 vector = npc.Center;
|
||||
float num8 = Main.player[npc.target].Center.X - vector.X + (float)Main.rand.Next(-2, 3);
|
||||
float num9 = Main.player[npc.target].Center.Y - vector.Y + (float)Main.rand.Next(-2, 3);
|
||||
float num10 = (float)Math.Sqrt(num8 * num8 + num9 * num9);
|
||||
num10 = laserVelocity / num10;
|
||||
num8 *= num10;
|
||||
num9 *= num10;
|
||||
num8 += (float)Main.rand.Next(-2, 3) * 0.05f;
|
||||
num9 += (float)Main.rand.Next(-2, 3) * 0.05f;
|
||||
|
||||
int type = npc.Calamity().destroyerLaserColor == -1 ? ProjectileID.SaucerScrap : ProjectileID.DeathLaser;
|
||||
int damage = type == ProjectileID.SaucerScrap ? 0 : npc.GetProjectileDamage(type);
|
||||
|
||||
// Reduce mech boss projectile damage depending on the new ore progression changes
|
||||
if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive)
|
||||
{
|
||||
float laserVelocity = Main.masterMode ? 9f : Main.expertMode ? 8.5f : 8f;
|
||||
Vector2 vector = npc.Center;
|
||||
float num8 = Main.player[npc.target].Center.X - vector.X + (float)Main.rand.Next(-2, 3);
|
||||
float num9 = Main.player[npc.target].Center.Y - vector.Y + (float)Main.rand.Next(-2, 3);
|
||||
float num10 = (float)Math.Sqrt(num8 * num8 + num9 * num9);
|
||||
num10 = laserVelocity / num10;
|
||||
num8 *= num10;
|
||||
num9 *= num10;
|
||||
num8 += (float)Main.rand.Next(-2, 3) * 0.05f;
|
||||
num9 += (float)Main.rand.Next(-2, 3) * 0.05f;
|
||||
|
||||
int type = ProjectileID.DeathLaser;
|
||||
int damage = npc.GetProjectileDamage(type);
|
||||
|
||||
// Reduce mech boss projectile damage depending on the new ore progression changes
|
||||
if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive)
|
||||
{
|
||||
double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic;
|
||||
double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic;
|
||||
if (!NPC.downedMechBossAny)
|
||||
damage = (int)(damage * firstMechMultiplier);
|
||||
else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1))
|
||||
damage = (int)(damage * secondMechMultiplier);
|
||||
}
|
||||
|
||||
vector.X += num8 * 5f;
|
||||
vector.Y += num9 * 5f;
|
||||
int num12 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector.X, vector.Y, num8, num9, type, damage, 0f, Main.myPlayer);
|
||||
Main.projectile[num12].timeLeft = 600;
|
||||
npc.netUpdate = true;
|
||||
double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic;
|
||||
double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic;
|
||||
if (!NPC.downedMechBossAny)
|
||||
damage = (int)(damage * firstMechMultiplier);
|
||||
else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1))
|
||||
damage = (int)(damage * secondMechMultiplier);
|
||||
}
|
||||
|
||||
float offset = type == ProjectileID.SaucerScrap ? 0f : 5f;
|
||||
vector.X += num8 * offset;
|
||||
vector.Y += num9 * offset;
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int num12 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector.X, vector.Y, num8, num9, type, damage, 0f, Main.myPlayer);
|
||||
Main.projectile[num12].timeLeft = type == ProjectileID.SaucerScrap ? 90 : 900;
|
||||
}
|
||||
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1561,6 +1628,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
|
||||
}
|
||||
}
|
||||
|
||||
int x = (int)npc.Center.X / 16;
|
||||
int y = (int)npc.Center.Y / 16;
|
||||
if (WorldGen.InWorld(x, y) && !WorldGen.SolidTile(x, y))
|
||||
Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0.3f, 0.1f, 0.05f);
|
||||
|
||||
if (probeTargetX > 0f)
|
||||
{
|
||||
npc.spriteDirection = 1;
|
||||
|
||||
Reference in new issue
Block a user