Beginnings of spawn animation + Holy Blast visuals

This commit is contained in:
Xhack committed 2024-07-26 16:02:24 -04:00
1 parent aa42856d41
commit 3a5d17f2be
9 files changed
+343 -183

No files matched your search

+1 -1
View File
@@ -43,7 +43,7 @@ namespace CalamityMod.Items.SummonItems
SoundEngine.PlaySound(Providence.SpawnSound, player.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int npc = NPC.NewNPC(new EntitySource_BossSpawn(player), (int)(player.position.X + Main.rand.Next(-500, 501)), (int)(player.position.Y - 250f), ModContent.NPCType<Providence>(), 1);
int npc = NPC.NewNPC(new EntitySource_BossSpawn(player), (int)player.position.X, (int)(player.position.Y - 100f), ModContent.NPCType<Providence>(), 1);
Main.npc[npc].timeLeft *= 20;
CalamityUtils.BossAwakenMessage(npc);
}
+268 -170
View File
@@ -22,6 +22,7 @@ using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Summon;
using CalamityMod.Projectiles.Typeless;
@@ -30,6 +31,7 @@ using CalamityMod.Tiles.Ores;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics.PackedVector;
using ReLogic.Content;
using ReLogic.Utilities;
using Terraria;
@@ -41,6 +43,7 @@ using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using static CalamityMod.Projectiles.Rogue.FinalDawnFlame;
using Filters = Terraria.Graphics.Effects.Filters;
namespace CalamityMod.NPCs.Providence
@@ -80,6 +83,9 @@ namespace CalamityMod.NPCs.Providence
}
public int colorShiftTimer = -1;
Color HighFireColor = new Color(255, 191, 73);
Color LowFireColor = new Color(116, 45, 23);
private bool text = false;
private bool useDefenseFrames = false;
private float bossLife;
@@ -220,6 +226,20 @@ namespace CalamityMod.NPCs.Providence
#endregion
}
public override void ModifyHoverBoundingBox(ref Rectangle boundingBox)
{
// Is in spawning animation
float spawnAnimationTime = 180f;
bool spawnAnimation = NPC.Calamity().newAI[3] < spawnAnimationTime;
if (spawnAnimation)
{
boundingBox = new Rectangle(0, 0, 0, 0);
}
base.ModifyHoverBoundingBox(ref boundingBox);
}
public override void SetDefaults()
{
NPC.npcSlots = 36f;
@@ -322,6 +342,9 @@ namespace CalamityMod.NPCs.Providence
public override void AI()
{
// Local helper variable to get the current boss mode without having to use the magic number version
int currentMode = (int)NPC.localAI[1];
// Set the border drawing to true if it isn't set to true
// Can happen when another mod sets to false for a difficulty and that difficulty is then toggled off.
shouldDrawInfernoBorder = true;
@@ -332,7 +355,7 @@ namespace CalamityMod.NPCs.Providence
CalamityGlobalNPC.holyBoss = NPC.whoAmI;
// Rotation
NPC.rotation = NPC.velocity.X * 0.004f;
NPC.rotation = MathHelper.Lerp(NPC.rotation, NPC.velocity.X * 0.006f, 0.1f);
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
@@ -391,6 +414,11 @@ namespace CalamityMod.NPCs.Providence
float spawnAnimationTime = 180f;
bool spawnAnimation = calamityGlobalNPC.newAI[3] < spawnAnimationTime;
if (!spawnAnimation)
{
NPC.Opacity = 1f;
}
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
@@ -470,6 +498,11 @@ namespace CalamityMod.NPCs.Providence
// Inflict Holy Inferno if target is too far away
float burnIntensity = CalculateBurnIntensity(attackDelayAfterCocoon);
// Color determination
Color hiColor = ProvUtils.GetProjectileColor(currentMode, 0);
Color medColor = ProvUtils.GetProjectileColor(currentMode, 255);
Color loColor = ProvUtils.GetProjectileColor(currentMode, 255, true);
if (!player.dead && player.active && !player.creativeGodMode && !Dying)
{
//The debuff applies
@@ -811,10 +844,7 @@ namespace CalamityMod.NPCs.Providence
if (spawnAnimation)
{
colorShiftTimer++; // Also double the shift speed in the mean time :)
float minSpawnVelocity = 0.4f;
float maxSpawnVelocity = 4f;
float velocityY = maxSpawnVelocity - MathHelper.Lerp(minSpawnVelocity, maxSpawnVelocity, calamityGlobalNPC.newAI[3] / spawnAnimationTime);
NPC.velocity = new Vector2(0f, velocityY);
NPC.velocity = new Vector2(0f, 0f);
}
else
{
@@ -1063,54 +1093,47 @@ namespace CalamityMod.NPCs.Providence
if (spawnAnimation)
{
if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[3] == 0f)
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + new Vector2(0f, -80f), Vector2.Zero, ModContent.ProjectileType<HolyAura>(), 0, 0f, Main.myPlayer, biomeType, 0f);
NPC.dontTakeDamage = true;
if (calamityGlobalNPC.newAI[3] == spawnAnimationTime - 1)
{
NPC.dontTakeDamage = false;
if (calamityGlobalNPC.newAI[3] == 10f)
SoundEngine.PlaySound(HolyRaySound, NPC.Center);
if (calamityGlobalNPC.newAI[3] > 10f && calamityGlobalNPC.newAI[3] < 150f)
{
int dustAmt = (int)MathHelper.Lerp(4f, 8f, calamityGlobalNPC.newAI[3] / spawnAnimationTime);
for (int m = 0; m < dustAmt; m++)
for (int i = 0; i < 30; i++)
{
float fade = MathHelper.Lerp(1.3f, 0.7f, NPC.Opacity) * Utils.GetLerpValue(0f, 120f, calamityGlobalNPC.newAI[3], clamped: true);
Color newColor = Main.hslToRgb(calamityGlobalNPC.newAI[3] / 180f, 1f, 0.5f);
if (!nightAI)
{
newColor.R = 255;
if (biomeType == 2)
newColor.B = 0;
}
else
{
newColor.B = 255;
if (biomeType == 2)
newColor.G = 0;
else
newColor.R = 0;
}
int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.RainbowMk2, 0f, 0f, 0, newColor);
Main.dust[dust].position = NPC.Center + Main.rand.NextVector2Circular(NPC.width * 2f, NPC.height * 2f) + new Vector2(0f, -150f);
Main.dust[dust].velocity *= Main.rand.NextFloat() * 0.8f;
Main.dust[dust].noGravity = true;
Main.dust[dust].fadeIn = 0.6f + Main.rand.NextFloat() * 0.7f * fade;
Main.dust[dust].velocity += Vector2.UnitY * 3f;
Main.dust[dust].scale = 1.2f;
if (dust != 6000)
{
Dust dust2 = Dust.CloneDust(dust);
dust2.scale /= 2f;
dust2.fadeIn *= 0.85f;
dust2.color = new Color(255, 255, 0, 255);
}
Particle p = new FlameParticle(NPC.Center + new Vector2(Main.rand.NextFloat(150), 0).RotatedByRandom(MathHelper.TwoPi), 40, Main.rand.NextFloat(1f, 1.6f), Main.rand.NextFloat(2f, 5f), hiColor, loColor);
p.Velocity = new Vector2(Main.rand.NextFloat(3f, 19f), 0).RotatedByRandom(MathHelper.TwoPi);
GeneralParticleHandler.SpawnParticle(p);
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(NPC.Center, new Vector2(Main.rand.NextFloat(12f, 40f), 0).RotatedByRandom(MathHelper.TwoPi), loColor, 60, Main.rand.NextFloat(2.5f, 5.5f), 2f, Main.rand.NextFloat(-0.05f, 0.05f), true));
}
GeneralParticleHandler.SpawnParticle(new CustomPulse(NPC.Center, Vector2.Zero, medColor, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 1f, 0f, 15));
GeneralParticleHandler.SpawnParticle(new CustomPulse(NPC.Center, Vector2.Zero, loColor, "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.1f, 1.2f, 35));
GeneralParticleHandler.SpawnParticle(new CustomPulse(NPC.Center, Vector2.Zero, medColor, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.1f, 0.65f, 25));
}
NPC.Opacity = MathHelper.Clamp(calamityGlobalNPC.newAI[3] / spawnAnimationTime, 0f, 1f);
float sc = calamityGlobalNPC.newAI[3] / spawnAnimationTime;
if (calamityGlobalNPC.newAI[3] > 10f && calamityGlobalNPC.newAI[3] < spawnAnimationTime)
{
if (calamityGlobalNPC.newAI[3] % 10f == 0)
{
GeneralParticleHandler.SpawnParticle(new CustomPulse(NPC.Center, Vector2.Zero, Color.Lerp(new Color(25, 25, 25, 0), medColor, sc), "CalamityMod/Particles/SoftRoundExplosion", new Vector2(1.5f, 1f), Main.rand.NextBool(2) ? 0f : MathHelper.Pi, sc * 0.5f, sc * 0.1f, 20));
SoundStyle SpawnFlareSound = SoundID.Item74;
SpawnFlareSound.MaxInstances = 10;
SoundEngine.PlaySound(SpawnFlareSound.WithVolumeScale(calamityGlobalNPC.newAI[3] / spawnAnimationTime).WithPitchOffset(-1 + (calamityGlobalNPC.newAI[3] / spawnAnimationTime)), NPC.Center);
}
Vector2 startPos = NPC.Center + (new Vector2(Main.rand.NextFloat(80, 300) * (sc * 1.6f), 0).RotatedByRandom(Main.rand.NextFloat(MathHelper.TwoPi)) * new Vector2(1.5f, 1f));
GeneralParticleHandler.SpawnParticle(new SparkParticle(startPos, startPos.DirectionTo(NPC.Center) * (startPos.Distance(NPC.Center) / 10), false, 10, Main.rand.NextFloat(0.2f, 0.5f) * (sc * 2), medColor));
}
calamityGlobalNPC.newAI[3] += 1f;
@@ -2159,151 +2182,176 @@ namespace CalamityMod.NPCs.Providence
Texture2D textureGlow = offColor ? TextureNight_Glow.Value : Texture_Glow.Value;
Texture2D textureGlow2 = offColor ? TextureNight_Glow_2.Value : Texture_Glow_2.Value;
if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon)
float spawnAnimationTime = 180f;
bool spawnAnimation = NPC.Calamity().newAI[3] < spawnAnimationTime;
if (spawnAnimation)
{
if (!useDefenseFrames)
Asset<Texture2D> orbTex = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle");
Asset<Texture2D> flareTex = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/HolyBlast");
float sc = CalamityUtils.CircInEasing((float)NPC.Calamity().newAI[3] / (float)spawnAnimationTime, 1);
for (int i = 0; i < 3; i++)
{
texture = offColor ? TextureDefenseNight.Value : TextureDefense.Value;
textureGlow = offColor ? TextureDefenseNight_Glow.Value : TextureDefense_Glow.Value;
textureGlow2 = offColor ? TextureDefenseNight_Glow_2.Value : TextureDefense_Glow_2.Value;
int frameY = (int)(NPC.Calamity().newAI[3] / 4) % 4;
float sc1 = MathHelper.Lerp(1, 0, sc);
Main.EntitySpriteDraw(orbTex.Value, NPC.Center - Main.screenPosition + new Vector2(Main.rand.NextFloat(MathHelper.Lerp(0f, 10f, sc)), 0).RotatedByRandom(MathHelper.TwoPi), orbTex.Frame(), ProvUtils.GetProjectileColor((int)NPC.localAI[1], 0, false).MultiplyRGBA(new Color(sc * 45f, sc * 11f, sc * 22f, 0f)), 0f, orbTex.Frame().Center(), (sc * 4.4f) + (float)(Math.Cos((float)NPC.Calamity().newAI[3] / 10) * sc), SpriteEffects.None);
}
}
{
if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon)
{
if (!useDefenseFrames)
{
texture = offColor ? TextureDefenseNight.Value : TextureDefense.Value;
textureGlow = offColor ? TextureDefenseNight_Glow.Value : TextureDefense_Glow.Value;
textureGlow2 = offColor ? TextureDefenseNight_Glow_2.Value : TextureDefense_Glow_2.Value;
}
else
{
texture = offColor ? TextureDefenseAltNight.Value : TextureDefenseAlt.Value;
textureGlow = offColor ? TextureDefenseAltNight_Glow.Value : TextureDefenseAlt_Glow.Value;
textureGlow2 = offColor ? TextureDefenseAltNight_Glow_2.Value : TextureDefenseAlt_Glow_2.Value;
}
}
else
{
texture = offColor ? TextureDefenseAltNight.Value : TextureDefenseAlt.Value;
textureGlow = offColor ? TextureDefenseAltNight_Glow.Value : TextureDefenseAlt_Glow.Value;
textureGlow2 = offColor ? TextureDefenseAltNight_Glow_2.Value : TextureDefenseAlt_Glow_2.Value;
switch (frameUsed)
{
case 1:
texture = offColor ? TextureAltNight.Value : TextureAlt.Value;
textureGlow = offColor ? TextureAltNight_Glow.Value : TextureAlt_Glow.Value;
textureGlow2 = offColor ? TextureAltNight_Glow_2.Value : TextureAlt_Glow_2.Value;
break;
case 2:
texture = offColor ? TextureAttackNight.Value : TextureAttack.Value;
textureGlow = offColor ? TextureAttackNight_Glow.Value : TextureAttack_Glow.Value;
textureGlow2 = offColor ? TextureAttackNight_Glow_2.Value : TextureAttack_Glow_2.Value;
break;
case 3:
texture = offColor ? TextureAttackAltNight.Value : TextureAttackAlt.Value;
textureGlow = offColor ? TextureAttackAltNight_Glow.Value : TextureAttackAlt_Glow.Value;
textureGlow2 = offColor ? TextureAttackAltNight_Glow_2.Value : TextureAttackAlt_Glow_2.Value;
break;
default:
break;
}
}
}
else
{
switch (frameUsed)
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
// Draw the main boss texture + its afterimages
Vector2 RotationCenter = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2);
Color BaseColor = Color.White;
float Brightness = 0.5f; // Ranges from 0 (full vibrance) to 1 (pure white)
int maxAfterimages = 5;
if (CalamityConfig.Instance.Afterimages)
{
case 1:
texture = offColor ? TextureAltNight.Value : TextureAlt.Value;
textureGlow = offColor ? TextureAltNight_Glow.Value : TextureAlt_Glow.Value;
textureGlow2 = offColor ? TextureAltNight_Glow_2.Value : TextureAlt_Glow_2.Value;
break;
for (int i = 1; i < maxAfterimages; i += 2)
{
Color AfterimageColor = drawColor;
AfterimageColor = Color.Lerp(AfterimageColor, BaseColor, Brightness);
AfterimageColor = NPC.GetAlpha(AfterimageColor);
AfterimageColor *= (maxAfterimages - i) / 15f;
if (colorOverride != null)
AfterimageColor = colorOverride.Value;
case 2:
texture = offColor ? TextureAttackNight.Value : TextureAttack.Value;
textureGlow = offColor ? TextureAttackNight_Glow.Value : TextureAttack_Glow.Value;
textureGlow2 = offColor ? TextureAttackNight_Glow_2.Value : TextureAttack_Glow_2.Value;
break;
Vector2 AfterimageBodyPosition = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos;
AfterimageBodyPosition -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f;
AfterimageBodyPosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset;
spriteBatch.Draw(texture, AfterimageBodyPosition, NPC.frame, AfterimageColor.MultiplyRGBA(Lighting.GetColor((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16)), NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
}
}
case 3:
texture = offColor ? TextureAttackAltNight.Value : TextureAttackAlt.Value;
textureGlow = offColor ? TextureAttackAltNight_Glow.Value : TextureAttackAlt_Glow.Value;
textureGlow2 = offColor ? TextureAttackAltNight_Glow_2.Value : TextureAttackAlt_Glow_2.Value;
break;
Vector2 BasePosition = NPC.Center - screenPos;
BasePosition -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f;
BasePosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset;
spriteBatch.Draw(texture, BasePosition, NPC.frame, (colorOverride ?? Lighting.GetColor((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16)) * NPC.Opacity, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
// Draw the glowmask textures + their afterimages
// These are the colors at their strongest point. It'll shift towards white by the brightness value used earlier.
Color WingColor = ProvUtils.GetProjectileColor((int)NPC.localAI[1], 0); //Default to day
Color CrystalColor = Color.Violet;
switch (NPC.localAI[1])
{
case (float)BossMode.Red:
WingColor = Color.Red;
CrystalColor = Color.BlueViolet;
break;
case (float)BossMode.Orange:
WingColor = Color.Orange;
CrystalColor = Color.HotPink;
break;
case (float)BossMode.Yellow: // Same as day
break;
case (float)BossMode.Green:
WingColor = Color.Green;
CrystalColor = Color.Gold;
break;
case (float)BossMode.Blue: // Same as night
case (float)BossMode.Night:
WingColor = Color.Cyan;
CrystalColor = Color.BlueViolet;
break;
case (float)BossMode.Violet:
WingColor = Color.Magenta;
CrystalColor = Color.GreenYellow;
break;
default:
break;
}
}
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
// Draw the main boss texture + its afterimages
Vector2 RotationCenter = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2);
Color BaseColor = Color.White;
float Brightness = 0.5f; // Ranges from 0 (full vibrance) to 1 (pure white)
int maxAfterimages = 5;
if (CalamityConfig.Instance.Afterimages)
{
for (int i = 1; i < maxAfterimages; i += 2)
Color BaseWingColor = Color.Lerp(WingColor, BaseColor, Brightness) * NPC.Opacity;
Color BaseCrystalColor = Color.Lerp(CrystalColor, BaseColor, Brightness) * NPC.Opacity;
if (colorOverride != null)
{
Color AfterimageColor = drawColor;
AfterimageColor = Color.Lerp(AfterimageColor, BaseColor, Brightness);
AfterimageColor = NPC.GetAlpha(AfterimageColor);
AfterimageColor *= (maxAfterimages - i) / 15f;
if (colorOverride != null)
AfterimageColor = colorOverride.Value;
Vector2 AfterimageBodyPosition = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos;
AfterimageBodyPosition -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f;
AfterimageBodyPosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset;
spriteBatch.Draw(texture, AfterimageBodyPosition, NPC.frame, AfterimageColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
BaseWingColor = colorOverride.Value;
BaseCrystalColor = colorOverride.Value;
}
}
Vector2 BasePosition = NPC.Center - screenPos;
BasePosition -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f;
BasePosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset;
spriteBatch.Draw(texture, BasePosition, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
Color GlowWingColor = ProvUtils.GetProjectileColor((int)NPC.localAI[1], NPC.GetAlpha(drawColor), true);
// Draw the glowmask textures + their afterimages
// These are the colors at their strongest point. It'll shift towards white by the brightness value used earlier.
Color WingColor = Color.Yellow; //Default to day
Color CrystalColor = Color.Violet;
switch (NPC.localAI[1])
{
case (float)BossMode.Red:
WingColor = Color.Red;
CrystalColor = Color.BlueViolet;
break;
case (float)BossMode.Orange:
WingColor = Color.Orange;
CrystalColor = Color.HotPink;
break;
case (float)BossMode.Yellow: // Same as day
break;
case (float)BossMode.Green:
WingColor = Color.Green;
CrystalColor = Color.Gold;
break;
case (float)BossMode.Blue: // Same as night
case (float)BossMode.Night:
WingColor = Color.Cyan;
CrystalColor = Color.BlueViolet;
break;
case (float)BossMode.Violet:
WingColor = Color.Magenta;
CrystalColor = Color.GreenYellow;
break;
default:
break;
}
Color BaseWingColor = Color.Lerp(WingColor, BaseColor, Brightness) * NPC.Opacity;
Color BaseCrystalColor = Color.Lerp(CrystalColor, BaseColor, Brightness) * NPC.Opacity;
if (colorOverride != null)
{
BaseWingColor = colorOverride.Value;
BaseCrystalColor = colorOverride.Value;
}
if (CalamityConfig.Instance.Afterimages)
{
for (int j = 1; j < maxAfterimages; j++)
if (CalamityConfig.Instance.Afterimages)
{
Color AfterimageWingColor = BaseWingColor;
AfterimageWingColor = Color.Lerp(AfterimageWingColor, BaseColor, Brightness);
AfterimageWingColor = NPC.GetAlpha(AfterimageWingColor);
AfterimageWingColor *= (maxAfterimages - j) / 15f;
if (colorOverride != null)
AfterimageWingColor = colorOverride.Value;
for (int j = 1; j < maxAfterimages; j++)
{
Color AfterimageWingColor = ProvUtils.GetProjectileColor((int)NPC.localAI[1], 0, true);
AfterimageWingColor = Color.Lerp(AfterimageWingColor, BaseColor, Brightness);
AfterimageWingColor = NPC.GetAlpha(AfterimageWingColor);
AfterimageWingColor *= (maxAfterimages - j) / 15f;
if (colorOverride != null)
AfterimageWingColor = colorOverride.Value;
Vector2 AfterimageGlowPosition = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos;
AfterimageGlowPosition -= new Vector2(textureGlow.Width, textureGlow.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f;
AfterimageGlowPosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset;
spriteBatch.Draw(textureGlow, AfterimageGlowPosition, NPC.frame, AfterimageWingColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
Vector2 AfterimageGlowPosition = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos;
AfterimageGlowPosition -= new Vector2(textureGlow.Width, textureGlow.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f;
AfterimageGlowPosition += RotationCenter * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset;
spriteBatch.Draw(textureGlow, AfterimageGlowPosition, NPC.frame, AfterimageWingColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
Color AfterimageCrystalColor = BaseCrystalColor;
AfterimageCrystalColor = Color.Lerp(AfterimageCrystalColor, BaseColor, Brightness);
AfterimageCrystalColor = NPC.GetAlpha(AfterimageCrystalColor);
AfterimageCrystalColor *= (maxAfterimages - j) / 15f;
if (colorOverride != null)
AfterimageCrystalColor = colorOverride.Value;
spriteBatch.Draw(textureGlow2, AfterimageGlowPosition, NPC.frame, AfterimageCrystalColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
Color AfterimageCrystalColor = BaseCrystalColor;
AfterimageCrystalColor = Color.Lerp(AfterimageCrystalColor, BaseColor, Brightness);
AfterimageCrystalColor = NPC.GetAlpha(AfterimageCrystalColor);
AfterimageCrystalColor *= (maxAfterimages - j) / 15f;
if (colorOverride != null)
AfterimageCrystalColor = colorOverride.Value;
spriteBatch.Draw(textureGlow2, AfterimageGlowPosition, NPC.frame, AfterimageCrystalColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
}
}
NPC.DrawBackglow(GlowWingColor, 4f, SpriteEffects.None, NPC.frame, Main.screenPosition, textureGlow);
spriteBatch.Draw(textureGlow, BasePosition, NPC.frame, BaseWingColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
spriteBatch.Draw(textureGlow2, BasePosition, NPC.frame, BaseCrystalColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
}
spriteBatch.Draw(textureGlow, BasePosition, NPC.frame, BaseWingColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
spriteBatch.Draw(textureGlow2, BasePosition, NPC.frame, BaseCrystalColor, NPC.rotation, RotationCenter, NPC.scale, spriteEffects, 0f);
}
float burnIntensity = Utils.GetLerpValue(0f, 45f, DeathAnimationTimer, true);
@@ -2435,6 +2483,11 @@ namespace CalamityMod.NPCs.Providence
return false;
}
public override Color? GetAlpha(Color drawColor)
{
return ProvUtils.GetProjectileColor((int)NPC.localAI[1], drawColor) * NPC.Opacity;
}
public override void FindFrame(int frameHeight)
{
if (NPC.IsABestiaryIconDummy)
@@ -2658,9 +2711,54 @@ namespace CalamityMod.NPCs.Providence
//These will be used for almost every single one of her projectiles, so it's useful to have.
public static class ProvUtils
{
public static Color GetProjectileColor(int Mode, Color givenLightColor, bool Outline = false)
{
int alpha = 0;
if (!Outline && Mode == (int)Providence.BossMode.Yellow)
{
float colorBrightness = (givenLightColor.R + givenLightColor.G + givenLightColor.B / 3) / 255f;
alpha = (int)MathHelper.Lerp(0f, 155f, colorBrightness);
}
else
{
alpha = 100;
}
Color FinalColor = new Color(255, Outline ? 0 : 255, Outline ? 0 : 255, alpha); //Default to day
switch (Mode)
{
case (int)Providence.BossMode.Red:
FinalColor = new Color(250, 100, Outline ? 200 : 100, alpha);
break;
case (int)Providence.BossMode.Orange:
FinalColor = new Color(250, 150, Outline ? 150 : 100, alpha);
break;
case (int)Providence.BossMode.Yellow: //Same as day
break;
case (int)Providence.BossMode.Green:
FinalColor = new Color(Outline ? 200 : 100, 250, 100, alpha);
break;
case (int)Providence.BossMode.Blue: //Same as night
case (int)Providence.BossMode.Night:
FinalColor = new Color(100, Outline ? 250 : 200, Outline ? 200 : 250, alpha);
break;
case (int)Providence.BossMode.Violet:
FinalColor = new Color(Outline ? 100 : 150, Outline ? 150 : 100, 250, alpha);
break;
default:
break;
}
if (Outline)
FinalColor *= 0.1f;
return FinalColor;
}
public static Color GetProjectileColor(int Mode, int Alpha, bool Outline = false)
{
Color FinalColor = new Color(250, Outline ? 0 : 150, 0, Alpha); //Default to day
Color FinalColor = new Color(255, Outline ? 0 : 155, Outline ? 0 : 25, Alpha); //Default to day
switch (Mode)
{
case (int)Providence.BossMode.Red:
Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 51 KiB

+49 -4
View File
@@ -1,12 +1,18 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs;
using CalamityMod.NPCs.Providence;
using CalamityMod.Particles;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
@@ -14,6 +20,8 @@ namespace CalamityMod.Projectiles.Boss
{
public class HolyBlast : ModProjectile, ILocalizedModType
{
public bool started = false;
public new string LocalizationCategory => "Projectiles.Boss";
public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastShoot");
public static readonly SoundStyle ImpactSound = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastImpact");
@@ -23,6 +31,10 @@ namespace CalamityMod.Projectiles.Boss
Main.projFrames[Projectile.type] = 4;
}
public override void OnSpawn(IEntitySource source)
{
}
public override void SetDefaults()
{
Projectile.Calamity().DealsDefenseDamage = true;
@@ -52,6 +64,7 @@ namespace CalamityMod.Projectiles.Boss
if (Projectile.Hitbox.Intersects(new Rectangle((int)Projectile.ai[0], (int)Projectile.ai[1], Player.defaultWidth, Player.defaultHeight)))
Projectile.tileCollide = true;
Projectile.maxPenetrate = (int)Providence.BossMode.Day;
// Day mode by default but syncs with the boss
if (CalamityGlobalNPC.holyBoss != -1)
{
@@ -80,6 +93,16 @@ namespace CalamityMod.Projectiles.Boss
if (Projectile.frame > 3)
Projectile.frame = 0;
if (!started)
{
for (int i = 0; i < 6; i++)
{
GeneralParticleHandler.SpawnParticle(new PointParticle(Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(-30f, 30f))) * Main.rand.NextFloat(2.4f, 4.2f), false, 30, Main.rand.NextFloat(3f, 6f), ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 255, false)));
GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(-50f, 50f))) * Main.rand.NextFloat(2.4f, 4.2f), false, 30, Main.rand.NextFloat(2f, 5f), ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 255, false)));
}
started = true;
}
if (Projectile.localAI[0] == 0f)
{
int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate);
@@ -97,6 +120,9 @@ namespace CalamityMod.Projectiles.Boss
Projectile.localAI[0] = 1f;
SoundEngine.PlaySound(ShootSound, Projectile.Center);
}
if (Main.rand.NextBool(3))
GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center + Projectile.velocity + new Vector2(Main.rand.NextFloat(-40, 40), 0).RotatedBy(Vector2.Zero.AngleTo(Projectile.velocity.RotatedBy(MathHelper.PiOver2))), Projectile.velocity * Main.rand.NextFloat(-3f, -1f), false, 10, Main.rand.NextFloat(1f, 1.5f), ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 255, false)));
if (Math.Abs(Projectile.velocity.X) > 0.2)
Projectile.spriteDirection = -Projectile.direction;
@@ -109,21 +135,39 @@ namespace CalamityMod.Projectiles.Boss
public override Color? GetAlpha(Color lightColor)
{
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha);
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor);
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D texture = (Projectile.maxPenetrate != (int)Providence.BossMode.Day) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/HolyBlastNight").Value;
Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/HolyBlastNight").Value;
int framing = texture.Height / Main.projFrames[Projectile.type];
int y6 = framing * Projectile.frame;
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha, true), 4f, texture);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0);
Vector2 sc = Vector2.One;
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor, true), 4f, sc, texture);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), sc, SpriteEffects.None, 0);
return false;
}
public override void OnKill(int timeLeft)
{
Color hiColor = ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 255, false);
Color loColor = ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 0, true);
for (int i = 0; i < 30; i++)
{
Particle p = new FlameParticle(Projectile.Center + new Vector2(Main.rand.NextFloat(150), 0).RotatedByRandom(MathHelper.TwoPi), 40, Main.rand.NextFloat(0.5f, 0.75f), Main.rand.NextFloat(1f, 2.5f), hiColor, loColor);
p.Velocity = new Vector2(Main.rand.NextFloat(3f, 19f), 0).RotatedByRandom(MathHelper.TwoPi);
GeneralParticleHandler.SpawnParticle(p);
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(12f, 40f), 0).RotatedByRandom(MathHelper.TwoPi), loColor, 60, Main.rand.NextFloat(0.75f, 1.75f), 1f, Main.rand.NextFloat(-0.05f, 0.05f), true));
}
GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, hiColor, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 1f, 0.1f, 15));
GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, hiColor, "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.05f, 0.25f, 35));
GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, hiColor, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.05f, 0.175f, 25));
if (Projectile.owner == Main.myPlayer)
{
int totalProjectiles = (Projectile.maxPenetrate != (int)Providence.BossMode.Day) ? 8 : 6;
@@ -143,6 +187,7 @@ namespace CalamityMod.Projectiles.Boss
SoundEngine.PlaySound(ImpactSound, Projectile.Center);
int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate);
for (int j = 0; j < 4; j++)
{
+2 -2
View File
@@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Boss
public override Color? GetAlpha(Color lightColor)
{
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha);
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor);
}
public override bool PreDraw(ref Color lightColor)
@@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Boss
Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/HolyBombNight").Value;
int framing = texture.Height / Main.projFrames[Projectile.type];
int y6 = framing * Projectile.frame;
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha, true), 4f, texture);
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor, true), 4f, texture);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0);
return false;
}
+2 -2
View File
@@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Boss
public override Color? GetAlpha(Color lightColor)
{
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha);
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor);
}
public override bool PreDraw(ref Color lightColor)
@@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Boss
Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/HolyFireNight").Value;
int framing = texture.Height / Main.projFrames[Projectile.type];
int y6 = framing * Projectile.frame;
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha, true), 4f, texture);
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor, true), 4f, texture);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0);
return false;
}
+2 -2
View File
@@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Boss
public override Color? GetAlpha(Color lightColor)
{
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha);
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor);
}
public override bool PreDraw(ref Color lightColor)
@@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Boss
Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/HolyFire2Night").Value;
int framing = texture.Height / Main.projFrames[Projectile.type];
int y6 = framing * Projectile.frame;
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha, true), 4f, texture);
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor, true), 4f, texture);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0);
return false;
}
+2 -2
View File
@@ -94,7 +94,7 @@ namespace CalamityMod.Projectiles.Boss
public override Color? GetAlpha(Color lightColor)
{
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha);
return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor);
}
public override bool PreDraw(ref Color lightColor)
@@ -102,7 +102,7 @@ namespace CalamityMod.Projectiles.Boss
Texture2D texture = Projectile.maxPenetrate == (int)Providence.BossMode.Day ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/HolyFlareNight").Value;
int framing = texture.Height / Main.projFrames[Projectile.type];
int y6 = framing * Projectile.frame;
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha, true), 4f, texture);
Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, lightColor, true), 4f, texture);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), Projectile.scale, SpriteEffects.None, 0);
return false;
}
+17
View File
@@ -691,6 +691,23 @@ namespace CalamityMod
}
}
public static void DrawBackglow(this Projectile projectile, Color backglowColor, float backglowArea, Vector2 scale, Texture2D? texture = null, Rectangle? frame = null)
{
texture ??= TextureAssets.Projectile[projectile.type].Value;
// Use a fallback for the frame.
frame ??= texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame);
Vector2 drawPosition = projectile.Center - Main.screenPosition;
Vector2 origin = frame.Value.Size() * 0.5f;
Color backAfterimageColor = backglowColor * projectile.Opacity;
for (int i = 0; i < 10; i++)
{
Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea;
Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, projectile.rotation, origin, scale, 0, 0f);
}
}
public static void DrawProjectileWithBackglow(this Projectile projectile, Color backglowColor, Color lightColor, float backglowArea, Texture2D? texture = null, Rectangle? frame = null)
{
texture ??= TextureAssets.Projectile[projectile.type].Value;