+ File Reorganization
This commit is contained in:
1 parent
5b6a6cd1b8
commit
b98b8d506e
27 files changed
+5276
-5086
No files matched your search
@@ -11,6 +11,7 @@ using CalamityMod.NPCs.PlagueEnemies;
|
||||
using CalamityMod.NPCs.PrimordialWyrm;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies;
|
||||
using CalamityMod.Systems.Collections;
|
||||
@@ -144,7 +145,7 @@ public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC
|
||||
case NPCID.BrainofCthulhu:
|
||||
return new BrainOfCthulhuAI();
|
||||
case NPCID.Creeper:
|
||||
return new BrainOfCthulhuAI.CreeperAI();
|
||||
return new CreeperAI();
|
||||
|
||||
case NPCID.QueenBee:
|
||||
return new QueenBeeAI();
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
|
||||
[AutoloadBossHead]
|
||||
public class BrainIllusion : ModNPC, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "NPCs";
|
||||
public override string Texture => "Terraria/Images/NPC_266";
|
||||
public override string BossHeadTexture => "Terraria/Images/NPC_Head_Boss_23";
|
||||
|
||||
ref float Time => ref NPC.ai[0];
|
||||
|
||||
ref float AttackValue => ref NPC.ai[1];
|
||||
|
||||
ref float Angle => ref NPC.ai[2];
|
||||
|
||||
ref float TeleportDuration => ref NPC.localAI[0];
|
||||
|
||||
ref float TeleportTime => ref NPC.ai[3];
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
this.HideFromBestiary();
|
||||
Main.npcFrameCount[Type] = 8;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
NPC.width = 160;
|
||||
NPC.height = 110;
|
||||
NPC.damage = 20;
|
||||
NPC.lifeMax = 1;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.noGravity = true;
|
||||
NPC.noTileCollide = true;
|
||||
NPC.boss = true;
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.chaseable = false;
|
||||
NPC.npcSlots = 0f;
|
||||
NPC.netAlways = true;
|
||||
Music = MusicID.Boss3;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
TeleportDuration = AttackValue;
|
||||
AttackValue = 0;
|
||||
TeleportTime = Time;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (NPC.crimsonBoss == -1)
|
||||
{
|
||||
NPC.active = false;
|
||||
return;
|
||||
}
|
||||
NPC brain = Main.npc[NPC.crimsonBoss];
|
||||
Player target = Main.player[brain.target];
|
||||
NPC.GivenName = brain.GivenOrTypeName + $": {brain.life}/{brain.lifeMax}";
|
||||
|
||||
#region Attack Start
|
||||
if (Time < 30)
|
||||
{
|
||||
TeleportDuration = 30;
|
||||
|
||||
if (Time == (TeleportDuration / 2f) && AttackValue == 0)
|
||||
{
|
||||
AttackValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
TeleportTime--;
|
||||
}
|
||||
|
||||
NPC.Opacity = 1 - (TeleportTime / (TeleportDuration / 2f));
|
||||
}
|
||||
#endregion
|
||||
else
|
||||
{
|
||||
if (Time == 30)
|
||||
{
|
||||
NPC.oldPos[0] = NPC.Center;
|
||||
TeleportTime = 0;
|
||||
AttackValue = 0;
|
||||
NPC.Opacity = 1f;
|
||||
}
|
||||
if (Time < 60)
|
||||
{
|
||||
float lerp = (Time - 30) / 30f;
|
||||
float circleDist = MathHelper.Lerp(BrainOfCthulhuAI.IllusionDashTeleportDistance, BrainOfCthulhuAI.IllusionDashCloseInDistance, CalamityUtils.SineInOutEasing(lerp, 1));
|
||||
NPC.Center = Vector2.Lerp(NPC.oldPos[0], target.Center + (Angle.ToRotationVector2() * circleDist), lerp);
|
||||
Angle += MathHelper.Lerp(0f, BrainOfCthulhuAI.IllusionDashStartingSpinSpeed, CalamityUtils.SineInEasing(lerp, 1));
|
||||
}
|
||||
else if (Time <= 60f + BrainOfCthulhuAI.IllusionDashSpinDuration)
|
||||
{
|
||||
NPC.Center = target.Center + Angle.ToRotationVector2() * BrainOfCthulhuAI.IllusionDashCloseInDistance;
|
||||
|
||||
Angle += MathHelper.Lerp(BrainOfCthulhuAI.IllusionDashStartingSpinSpeed, 0f, CalamityUtils.SineOutEasing((Time - 60) / (float)BrainOfCthulhuAI.IllusionDashSpinDuration, 1));
|
||||
}
|
||||
else if (Time <= 90 + BrainOfCthulhuAI.IllusionDashSpinDuration)
|
||||
{
|
||||
float reelBackSpeedExponent = 2.6f;
|
||||
float reelBackCompletion = Utils.GetLerpValue(0f, 30, Time - (60 + BrainOfCthulhuAI.IllusionDashSpinDuration), true);
|
||||
float reelBackSpeed = MathHelper.Lerp(4f, 20f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent));
|
||||
Vector2 reelBackVelocity = (Angle + MathHelper.Pi).ToRotationVector2() * -reelBackSpeed;
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f);
|
||||
}
|
||||
else if (Time == 91 + BrainOfCthulhuAI.IllusionDashSpinDuration)
|
||||
NPC.velocity = (Angle + MathHelper.Pi).ToRotationVector2() * BrainOfCthulhuAI.IllusionDashVelocity;
|
||||
else if (Time <= 91 + BrainOfCthulhuAI.IllusionDashSpinDuration + BrainOfCthulhuAI.IllusionDashTeleportDuration)
|
||||
{
|
||||
NPC.Opacity = MathHelper.Lerp(1f, 0.25f, CalamityUtils.SineInEasing((Time - (91 + BrainOfCthulhuAI.IllusionDashSpinDuration)) / (float)BrainOfCthulhuAI.IllusionDashTeleportDuration, 1));
|
||||
if (NPC.Opacity < 0.666f)
|
||||
NPC.damage = 0;
|
||||
}
|
||||
else
|
||||
NPC.active = false;
|
||||
}
|
||||
|
||||
Time++;
|
||||
}
|
||||
|
||||
public override void FindFrame(int frameHeight)
|
||||
{
|
||||
NPC.frameCounter += 1.0;
|
||||
if (NPC.frameCounter > 6.0)
|
||||
{
|
||||
NPC.frameCounter = 0.0;
|
||||
NPC.frame.Y += frameHeight;
|
||||
}
|
||||
|
||||
if (NPC.frame.Y < frameHeight * 4)
|
||||
{
|
||||
NPC.frame.Y = frameHeight * 4;
|
||||
}
|
||||
if (NPC.frame.Y > frameHeight * 7)
|
||||
{
|
||||
NPC.frame.Y = frameHeight * 4;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? CanBeHitByItem(Player player, Item item) => false;
|
||||
public override bool? CanBeHitByProjectile(Projectile projectile) => false;
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
|
||||
{
|
||||
Vector2 drawPos = NPC.Center + (Vector2.UnitY * 16) - Main.screenPosition;
|
||||
Vector2 scale = Vector2.One;
|
||||
|
||||
if (TeleportTime != 0)
|
||||
{
|
||||
//Color glowColor = Color.White * (teleportCounter / 30f);
|
||||
scale = Vector2.Lerp(Vector2.One, new Vector2(0.5f + ((float)Math.Cos(Time / (TeleportDuration / 2f) * MathHelper.TwoPi) / 2f + 0.5f), 0.5f + ((float)Math.Sin(Time / (TeleportDuration / 2f) * MathHelper.TwoPi) / 2f + 0.5f)), CalamityUtils.SineInOutEasing(TeleportTime / (TeleportDuration / 2f), 1));
|
||||
|
||||
spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, drawPos, NPC.frame, Lighting.GetColor(NPC.Center.ToTileCoordinates()) * NPC.Opacity, NPC.rotation, NPC.frame.Size() * 0.5f, scale * NPC.scale, 0, 0);
|
||||
//spriteBatch.Draw(GetBrainGlow(), drawPos, npc.frame, glowColor, npc.rotation, npc.frame.Size() * 0.5f, scale, 0, 0);
|
||||
}
|
||||
else
|
||||
spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, drawPos, NPC.frame, Lighting.GetColor(NPC.Center.ToTileCoordinates()) * NPC.Opacity, NPC.rotation, NPC.frame.Size() * 0.5f, scale * NPC.scale, 0, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,314 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.DataStructures;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
|
||||
public class BrainOfCthulhuSystem : ModSystem
|
||||
{
|
||||
internal static Asset<Texture2D> tendril;
|
||||
private static Texture2D tendrilGlow = null;
|
||||
private static Texture2D brainGlow = null;
|
||||
private static Texture2D creeperGlow = null;
|
||||
|
||||
internal static float ScreenBlurStrength = 0f;
|
||||
|
||||
internal static List<VerletSimulatedSegment>[] VerletTendrils = new List<VerletSimulatedSegment>[BrainOfCthulhuAI.GetBrainOfCthuluCreepersCountRevDeath()];
|
||||
|
||||
private static int previousMusic = -1;
|
||||
public static int PreviousMusic => previousMusic;
|
||||
|
||||
public override void OnModLoad()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
tendril = ModContent.Request<Texture2D>("Terraria/Images/Chain12");
|
||||
}
|
||||
|
||||
On_NPC.SpawnBoss += SpawnBrainNoMessage;
|
||||
On_Player.ItemCheck_UseBossSpawners += BlockRoar;
|
||||
On_Main.UpdateAudio_DecideOnNewMusic += StopBoss3FromStarting;
|
||||
On_Main.UpdateAudio_DecideOnTOWMusic += StopOWBoss1FromStarting;
|
||||
}
|
||||
|
||||
private void StopBoss3FromStarting(On_Main.orig_UpdateAudio_DecideOnNewMusic orig, Main self)
|
||||
{
|
||||
orig(self);
|
||||
|
||||
if (NPC.crimsonBoss == -1 || !CalamityWorld.revenge)
|
||||
return;
|
||||
|
||||
if (previousMusic < 0 || previousMusic >= Main.musicFade.Length)
|
||||
return;
|
||||
|
||||
var brainAI = Main.npc[NPC.crimsonBoss].AIOverride<BrainOfCthulhuAI>();
|
||||
// The last part leaves one frame at the end of the spawn animation where the boss music starts playing, so that it can be instantly maxed out
|
||||
if (brainAI.AIState < 0 && (brainAI.Time - Math.Abs(brainAI.SpawnTime) < 420))
|
||||
{
|
||||
if (Main.newMusic == MusicID.Boss3)
|
||||
Main.newMusic = previousMusic;
|
||||
|
||||
if (Main.curMusic == MusicID.Boss3)
|
||||
Main.curMusic = previousMusic;
|
||||
}
|
||||
}
|
||||
|
||||
private void StopOWBoss1FromStarting(On_Main.orig_UpdateAudio_DecideOnTOWMusic orig, Main self)
|
||||
{
|
||||
orig(self);
|
||||
|
||||
if (NPC.crimsonBoss == -1 || !CalamityWorld.revenge)
|
||||
return;
|
||||
|
||||
if (previousMusic < 0 || previousMusic >= Main.musicFade.Length)
|
||||
return;
|
||||
|
||||
var brainAI = Main.npc[NPC.crimsonBoss].AIOverride<BrainOfCthulhuAI>();
|
||||
// The last part leaves one frame at the end of the spawn animation where the boss music starts playing, so that it can be instantly maxed out
|
||||
if (brainAI.AIState < 0 && (brainAI.Time - Math.Abs(brainAI.SpawnTime) < 420))
|
||||
{
|
||||
if (Main.newMusic == MusicID.OtherworldlyBoss1)
|
||||
Main.newMusic = previousMusic;
|
||||
|
||||
if (Main.curMusic == MusicID.OtherworldlyBoss1)
|
||||
Main.curMusic = previousMusic;
|
||||
}
|
||||
}
|
||||
|
||||
private void BlockRoar(On_Player.orig_ItemCheck_UseBossSpawners orig, Player self, int onWhichPlayer, Item sItem)
|
||||
{
|
||||
if (sItem.type != ItemID.BloodySpine || !CalamityWorld.revenge || !self.ItemTimeIsZero || self.itemAnimation <= 0)
|
||||
{
|
||||
orig(self, onWhichPlayer, sItem);
|
||||
return;
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath1, Main.LocalPlayer.Center);
|
||||
|
||||
if (self.ZoneCrimson)
|
||||
{
|
||||
self.ApplyItemTime(sItem);
|
||||
CalamityUtils.SpawnBossUsingItem(self, NPCID.BrainofCthulhu);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnBrainNoMessage(On_NPC.orig_SpawnBoss orig, int spawnPositionX, int spawnPositionY, int Type, int targetPlayerIndex)
|
||||
{
|
||||
if (Type != NPCID.BrainofCthulhu || !CalamityWorld.revenge)
|
||||
{
|
||||
orig(spawnPositionX, spawnPositionY, Type, targetPlayerIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
int num = NPC.NewNPC(NPC.GetBossSpawnSource(targetPlayerIndex), spawnPositionX, spawnPositionY, Type, 1);
|
||||
|
||||
if (num == 200 || num == -1)
|
||||
return;
|
||||
|
||||
if (Main.player[targetPlayerIndex].HeldItem.type == ItemID.BloodySpine)
|
||||
BrainOfCthulhuAI.SummonedViaItem = true;
|
||||
|
||||
NPC.crimsonBoss = num;
|
||||
Main.npc[num].target = targetPlayerIndex;
|
||||
Main.npc[num].timeLeft *= 20;
|
||||
|
||||
previousMusic = Main.curMusic;
|
||||
|
||||
if (Main.netMode == NetmodeID.Server && num < 200)
|
||||
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num);
|
||||
}
|
||||
|
||||
internal static Texture2D GetTendrilGlow()
|
||||
{
|
||||
if (tendrilGlow == null)
|
||||
{
|
||||
var tex = new Texture2D(Main.graphics.GraphicsDevice, tendril.Value.Width, tendril.Value.Height);
|
||||
|
||||
var BaseArray = new Color[tex.Width * tex.Height];
|
||||
var ColorArray = new Color[tex.Width * tex.Height];
|
||||
tendril.Value.GetData(BaseArray);
|
||||
for (var i = 0; i < BaseArray.Length; i++)
|
||||
{
|
||||
ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f);
|
||||
}
|
||||
tex.SetData(ColorArray);
|
||||
tendrilGlow = tex;
|
||||
}
|
||||
return tendrilGlow;
|
||||
}
|
||||
|
||||
internal static Texture2D GetBrainGlow()
|
||||
{
|
||||
if (brainGlow == null)
|
||||
{
|
||||
var tex = new Texture2D(Main.graphics.GraphicsDevice, TextureAssets.Npc[NPCID.BrainofCthulhu].Value.Width, TextureAssets.Npc[NPCID.BrainofCthulhu].Value.Height);
|
||||
|
||||
var BaseArray = new Color[tex.Width * tex.Height];
|
||||
var ColorArray = new Color[tex.Width * tex.Height];
|
||||
TextureAssets.Npc[NPCID.BrainofCthulhu].Value.GetData(BaseArray);
|
||||
for (var i = 0; i < BaseArray.Length; i++)
|
||||
{
|
||||
ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f);
|
||||
}
|
||||
tex.SetData(ColorArray);
|
||||
brainGlow = tex;
|
||||
}
|
||||
return brainGlow;
|
||||
}
|
||||
|
||||
internal static Texture2D GetCreeperGlow()
|
||||
{
|
||||
if (creeperGlow == null)
|
||||
{
|
||||
var tex = new Texture2D(Main.graphics.GraphicsDevice, TextureAssets.Npc[NPCID.Creeper].Value.Width, TextureAssets.Npc[NPCID.Creeper].Value.Height);
|
||||
|
||||
var BaseArray = new Color[tex.Width * tex.Height];
|
||||
var ColorArray = new Color[tex.Width * tex.Height];
|
||||
TextureAssets.Npc[NPCID.Creeper].Value.GetData(BaseArray);
|
||||
for (var i = 0; i < BaseArray.Length; i++)
|
||||
{
|
||||
ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f);
|
||||
}
|
||||
tex.SetData(ColorArray);
|
||||
creeperGlow = tex;
|
||||
}
|
||||
return creeperGlow;
|
||||
}
|
||||
|
||||
public override void PostUpdateNPCs()
|
||||
{
|
||||
if (!NPC.AnyNPCs(NPCID.BrainofCthulhu))
|
||||
BrainOfCthulhuAI.SummonedViaItem = false;
|
||||
|
||||
if (Main.netMode != NetmodeID.Server)
|
||||
{
|
||||
if (NPC.crimsonBoss != -1 && CalamityWorld.revenge && Main.npc[NPC.crimsonBoss].ai[0] < (float)BrainOfCthulhuAI.BrainAIState.Phase2TransitionClosed)
|
||||
{
|
||||
List<NPC> creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper).ToList();
|
||||
|
||||
foreach (NPC creeper in creepers)
|
||||
{
|
||||
int creeperID = (int)creeper.ai[0];
|
||||
|
||||
Vector2 startPoint = Main.npc[NPC.crimsonBoss].Center + Vector2.UnitY * 32;
|
||||
|
||||
float creeperRatio = creeperID / (float)BrainOfCthulhuAI.GetBrainOfCthuluCreepersCountRevDeath();
|
||||
if (creeperID % 2 == 0)
|
||||
startPoint += new Vector2(MathHelper.Lerp(-24, 0, creeperRatio), 0);
|
||||
else
|
||||
startPoint += new Vector2(MathHelper.Lerp(24, 0, creeperRatio), 0);
|
||||
|
||||
Vector2 endPoint = creeper.Center;
|
||||
|
||||
List<VerletSimulatedSegment> tendril = VerletTendrils[creeperID];
|
||||
if (tendril is null || tendril.Count == 0)
|
||||
continue;
|
||||
|
||||
tendril[0].position = startPoint;
|
||||
tendril[0].locked = true;
|
||||
tendril[^1].position = endPoint;
|
||||
tendril[^1].locked = true;
|
||||
|
||||
VerletSimulatedSegment.SimpleSimulation(tendril, 16, 10, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostDrawTiles()
|
||||
{
|
||||
if (Main.netMode != NetmodeID.Server)
|
||||
{
|
||||
if (NPC.crimsonBoss == -1 || !CalamityWorld.revenge || Main.npc[NPC.crimsonBoss].ai[0] >= (float)BrainOfCthulhuAI.BrainAIState.Phase2TransitionClosed)
|
||||
{
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseOpacity(0);
|
||||
if (Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].IsActive())
|
||||
Filters.Scene.Deactivate("CalamityMod:BrainOfCthulhuForcefield");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].IsActive())
|
||||
Filters.Scene.Activate("CalamityMod:BrainOfCthulhuForcefield");
|
||||
|
||||
NPC target = Main.npc[NPC.crimsonBoss];
|
||||
Vector2 targetPos = target.Center;
|
||||
float shieldOpacity = target.AIOverride<BrainOfCthulhuAI>().ShieldOpacity;
|
||||
float shieldScale = target.AIOverride<BrainOfCthulhuAI>().ShieldScale;
|
||||
targetPos = Vector2.Transform(targetPos - Main.screenPosition, Main.GameViewMatrix.ZoomMatrix) / Main.ScreenSize.ToVector2();
|
||||
|
||||
Texture2D voronoi = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes3").Value;
|
||||
Texture2D depthNoise = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Veins").Value;
|
||||
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().Shader.Parameters["voronoi"].SetValue(voronoi);
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().Shader.Parameters["depthNoise"].SetValue(depthNoise);
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().Shader.Parameters["uScreenResolution"].SetValue(new Vector2(Main.graphics.GraphicsDevice.Viewport.Width, Main.graphics.GraphicsDevice.Viewport.Height));
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseProgress(0.15f * shieldScale);
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseOpacity(shieldOpacity);
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseColor(Color.Red);
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseSecondaryColor(new Color(255, 0, 90)); //Crimson color (R:220,G:20,B:60,A:255). // Magenta color (R:255,G:0,B:255,A:255).
|
||||
Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseDirection(targetPos);
|
||||
}
|
||||
|
||||
if (ScreenBlurStrength == 0f)
|
||||
{
|
||||
Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseIntensity(0);
|
||||
if (Filters.Scene["CalamityMod:RadialBlurShader"].IsActive())
|
||||
Filters.Scene.Deactivate("CalamityMod:RadialBlurShader");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NPC.crimsonBoss == -1)
|
||||
{
|
||||
ScreenBlurStrength = Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().Intensity * 0.9f;
|
||||
Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseIntensity(ScreenBlurStrength);
|
||||
if (ScreenBlurStrength < 0.01f)
|
||||
ScreenBlurStrength = 0f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Filters.Scene["CalamityMod:RadialBlurShader"].IsLoaded)
|
||||
{
|
||||
if (!Filters.Scene["CalamityMod:RadialBlurShader"].IsActive())
|
||||
Filters.Scene.Activate("CalamityMod:RadialBlurShader");
|
||||
NPC boss = Main.npc[NPC.crimsonBoss];
|
||||
float counter = boss.ai[1] - boss.ai[2] - 240;
|
||||
float distSQ = Main.LocalPlayer.DistanceSQ(boss.Center);
|
||||
float distanceScaleFactor = 1;
|
||||
if (distSQ > 592900) //770^2
|
||||
distanceScaleFactor = 1 / (1 + (((float)Math.Sqrt(distSQ) - 770) / 32f));
|
||||
|
||||
Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseIntensity((ScreenBlurStrength + (((float)Math.Cos(counter * MathHelper.TwoPi / 15f) / 2f + 0.5f) * (0.4f * ScreenBlurStrength))) * distanceScaleFactor);
|
||||
Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().Shader.Parameters["uSaturation"].SetValue(20);
|
||||
|
||||
Vector2 targetPos = Vector2.Transform(boss.Center - Main.screenPosition, Main.GameViewMatrix.ZoomMatrix) / Main.ScreenSize.ToVector2();
|
||||
|
||||
Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseDirection(targetPos);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostUpdateEverything()
|
||||
{
|
||||
if (Main.curMusic != MusicID.Boss3 && Main.curMusic != MusicID.OtherworldlyBoss1)
|
||||
previousMusic = Main.curMusic;
|
||||
|
||||
if (previousMusic == -1)
|
||||
previousMusic = MusicID.Crimson;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,696 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.DataStructures;
|
||||
using CalamityMod.Events;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.IO;
|
||||
using static CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu.BrainOfCthulhuAI;
|
||||
|
||||
namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
|
||||
public class CreeperAI : VanillaAIOverride
|
||||
{
|
||||
internal float FlowTime = 0;
|
||||
internal float FlowAmount => MathHelper.Lerp(0.1f, 0.15f, NPC.localAI[3]);
|
||||
|
||||
internal enum CreeperAIState
|
||||
{
|
||||
Idle,
|
||||
Charge
|
||||
}
|
||||
|
||||
internal int CreeperID { get => (int)NPC.ai[0]; set => NPC.ai[0] = value; }
|
||||
internal CreeperAIState AIState { get => (CreeperAIState)NPC.ai[1]; set => NPC.ai[1] = (float)value; }
|
||||
internal int Time = -1;
|
||||
internal ref float AttackAngle => ref NPC.ai[2];
|
||||
internal ref float CachedValue1 => ref NPC.ai[3];
|
||||
internal int CachedValue2 = 0;
|
||||
internal int PartnerIndex = -1;
|
||||
internal Vector2 AttackPosition = Vector2.Zero;
|
||||
internal float ConnectionOpacity = 0f;
|
||||
|
||||
public override bool AI(Mod mod)
|
||||
{
|
||||
#region Despawn
|
||||
if (NPC.crimsonBoss < 0)
|
||||
{
|
||||
NPC.active = false;
|
||||
NPC.netUpdate = true;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Targetting
|
||||
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
|
||||
CalamityUtils.CalamityTargeting(NPC, default);
|
||||
#endregion
|
||||
|
||||
#region Creeper Count Variables
|
||||
int creeperCount = NPC.CountNPCS(NPC.type);
|
||||
if (creeperCount > GetBrainOfCthuluCreepersCountRevDeath())
|
||||
creeperCount = GetBrainOfCthuluCreepersCountRevDeath();
|
||||
int localCreeperID = Main.npc.Where(n => n.active && n.type == NPCID.Creeper).ToList().IndexOf(NPC);
|
||||
float CreeperAmountRatio = creeperCount / (float)GetBrainOfCthuluCreepersCountRevDeath();
|
||||
#endregion
|
||||
|
||||
NPC brain = Main.npc[NPC.crimsonBoss];
|
||||
BrainOfCthulhuAI bocAI = brain.AIOverride<BrainOfCthulhuAI>();
|
||||
|
||||
bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
|
||||
|
||||
float bossCounter = bocAI.Time;
|
||||
|
||||
bool evenID = CreeperID % 2 == 0;
|
||||
|
||||
if (bocAI.AIState < 0)
|
||||
NPC.damage = 0;
|
||||
|
||||
List<BrainAIState> bossAIStatesToUse = [
|
||||
BrainAIState.UndergroundSpawnAnimation,
|
||||
BrainAIState.SurfaceSpawnAnimation,
|
||||
BrainAIState.Stunned,
|
||||
BrainAIState.CreeperSwipes,
|
||||
BrainAIState.CreeperCrush,
|
||||
BrainAIState.CreeperOrbit,
|
||||
BrainAIState.CreeperSpiral,
|
||||
BrainAIState.DesperateOnslaught
|
||||
];
|
||||
bool useBossAIState = bossAIStatesToUse.Contains(bocAI.AIState) && bossCounter >= 0;
|
||||
|
||||
if (bocAI.AIState == BrainAIState.UndergroundSpawnAnimation || bocAI.AIState == BrainAIState.SurfaceSpawnAnimation)
|
||||
NPC.dontTakeDamage = true;
|
||||
else
|
||||
NPC.dontTakeDamage = false;
|
||||
|
||||
if (useBossAIState)
|
||||
switch (bocAI.AIState)
|
||||
{
|
||||
case BrainAIState.UndergroundSpawnAnimation:
|
||||
case BrainAIState.SurfaceSpawnAnimation:
|
||||
float baseRotation = MathHelper.TwoPi / (GetBrainOfCthuluCreepersCountRevDeath() / 2f) * (CreeperID / 2f);
|
||||
Vector2 goalLocation;
|
||||
float speedCap = 8f;
|
||||
float accel = 1f;
|
||||
float acceptableDist = 9216;
|
||||
Player player = Main.player[NPC.target];
|
||||
|
||||
if (bocAI.SpawnTime != 0 && Time >= 0) //Brain has appeared
|
||||
{
|
||||
float brainTime = bossCounter - Math.Abs(bocAI.SpawnTime);
|
||||
|
||||
if (brainTime < 180)
|
||||
{
|
||||
Vector2 baseOffset = new Vector2(evenID ? -360 : 360, 0);
|
||||
Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 120f * (evenID ? -1 : 1))) * 128;
|
||||
goalLocation = player.Center + baseOffset + rotationOffset;
|
||||
}
|
||||
else if (brainTime < 240)
|
||||
{
|
||||
Vector2 baseOffset = new Vector2(evenID ? -200 : 200, 64);
|
||||
Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 60f * (evenID ? -1 : 1))) * 32;
|
||||
goalLocation = brain.Center + baseOffset + rotationOffset;
|
||||
speedCap = 12;
|
||||
accel = 2f;
|
||||
acceptableDist = 4096;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 baseOffset = new Vector2(evenID ? -360 : 360, -64);
|
||||
Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 60f * (evenID ? -1 : 1))) * 128;
|
||||
goalLocation = brain.Center + baseOffset + rotationOffset;
|
||||
speedCap = 12;
|
||||
accel = 2f;
|
||||
acceptableDist = 4096;
|
||||
}
|
||||
Time++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time >= 0) //Has been brought down
|
||||
{
|
||||
Vector2 baseOffset = new Vector2(evenID ? -360 : 360, 0);
|
||||
Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 120f * (evenID ? -1 : 1))) * 128;
|
||||
goalLocation = player.Center + baseOffset + rotationOffset;
|
||||
Time++;
|
||||
}
|
||||
else //Hasnt been brought down
|
||||
{
|
||||
Vector2 baseOffset = new Vector2(evenID ? -256 : 256, 0);
|
||||
Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 120f * (evenID ? -1 : 1))) * 64;
|
||||
goalLocation = brain.Center + baseOffset + rotationOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (NPC.DistanceSQ(goalLocation) > acceptableDist)
|
||||
{
|
||||
NPC.velocity += NPC.DirectionTo(goalLocation) * accel;
|
||||
NPC.velocity = NPC.velocity.ClampMagnitude(0f, speedCap);
|
||||
}
|
||||
|
||||
break;
|
||||
case BrainAIState.DesperateOnslaught:
|
||||
if (Time == 0 || AttackPosition == Vector2.Zero)
|
||||
{
|
||||
Vector2 dir = Vector2.UnitX.RotatedBy(Main.rand.NextFloat(-MathHelper.TwoPi / 3f, MathHelper.TwoPi / 3f)) * (evenID ? -1 : 1);
|
||||
AttackAngle = dir.ToRotation();
|
||||
float rayDist = CalamityUtils.PreciseDistanceToTileCollisionHit(brain.Center, AttackAngle, 800, 4);
|
||||
AttackPosition = (dir * (rayDist - 64));
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
|
||||
if (Time > 0)
|
||||
{
|
||||
goalLocation = brain.Center + AttackPosition;
|
||||
|
||||
if (WorldGen.SolidOrSlopedTile(goalLocation.ToTileCoordinates().X, goalLocation.ToTileCoordinates().Y))
|
||||
{
|
||||
float rayDist = CalamityUtils.PreciseDistanceToTileCollisionHit(brain.Center, AttackAngle, 800, 4);
|
||||
AttackPosition = (AttackAngle.ToRotationVector2() * (rayDist - 64));
|
||||
goalLocation = brain.Center + AttackPosition;
|
||||
}
|
||||
|
||||
if (NPC.DistanceSQ(goalLocation) > 4096)
|
||||
{
|
||||
NPC.velocity += NPC.DirectionTo(goalLocation);
|
||||
NPC.velocity = NPC.velocity.ClampMagnitude(0f, 10f);
|
||||
}
|
||||
else
|
||||
NPC.velocity *= 0.8f;
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f);
|
||||
NPC.damage = 0;
|
||||
}
|
||||
else
|
||||
useBossAIState = false;
|
||||
|
||||
Time++;
|
||||
break;
|
||||
case BrainAIState.Stunned:
|
||||
NPC.velocity *= 0.9f;
|
||||
NPC.damage = 0;
|
||||
break;
|
||||
case BrainAIState.CreeperSwipes:
|
||||
if (bossCounter < 15)
|
||||
{
|
||||
useBossAIState = false;
|
||||
Time = -1;
|
||||
AIState = CreeperAIState.Idle;
|
||||
break;
|
||||
}
|
||||
|
||||
if (brain.AIOverride<BrainOfCthulhuAI>().AttackList.Contains(NPC.whoAmI))
|
||||
{
|
||||
if (Time < 0)
|
||||
Time = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time >= 0)
|
||||
Time = -1;
|
||||
}
|
||||
|
||||
baseRotation = MathHelper.TwoPi / (GetBrainOfCthuluCreepersCountRevDeath() / 2f) * (CreeperID / 2f);
|
||||
bool singleHand = bocAI.AttackFlag;
|
||||
int handSide = bocAI.AttackSign;
|
||||
|
||||
if (Time == -1)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
NPC.knockBackResist = 0.72f;
|
||||
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f);
|
||||
|
||||
if (!singleHand)
|
||||
goalLocation = brain.Center + (Vector2.UnitY * -32f) + (Vector2.UnitX * (evenID ? -256 : 256)) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * (evenID ? -1 : 1))) * new Vector2(32, 96));
|
||||
else
|
||||
goalLocation = brain.Center + (Vector2.UnitY * -32f) + (Vector2.UnitX * 256 * handSide) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * handSide)) * new Vector2(32, 96));
|
||||
|
||||
goalLocation += Main.player[brain.target].velocity * 24f;
|
||||
float distToGoal = NPC.Center.Distance(goalLocation);
|
||||
NPC.velocity = NPC.DirectionTo(goalLocation) * (2f + MathHelper.Clamp(distToGoal / 24f, 0f, 64f));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time == 0)
|
||||
NPC.netUpdate = true;
|
||||
|
||||
NPC.damage = NPC.defDamage;
|
||||
NPC.knockBackResist = 0f;
|
||||
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f);
|
||||
|
||||
accel = 2f;
|
||||
float speed = 12f;
|
||||
|
||||
if (Time < brain.AIOverride<BrainOfCthulhuAI>().SwipeDelay)
|
||||
{
|
||||
if (!singleHand)
|
||||
goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * (evenID ? -300 : 300)) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * (evenID ? -1 : 1))) * new Vector2(32, 96));
|
||||
else
|
||||
goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * 300 * handSide) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * handSide)) * new Vector2(32, 96));
|
||||
|
||||
goalLocation += Main.player[brain.target].velocity * 24f;
|
||||
NPC.velocity += NPC.DirectionTo(goalLocation) * accel;
|
||||
NPC.velocity = NPC.velocity.ClampMagnitude(0f, speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!singleHand)
|
||||
goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * (evenID ? -256 : 256)) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * (evenID ? -1 : 1))) * new Vector2(32, 96));
|
||||
else
|
||||
goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * 256 * handSide) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * handSide)) * new Vector2(32, 96));
|
||||
|
||||
goalLocation.Y += MathHelper.Lerp(0, 420, CalamityUtils.SineInOutEasing(MathHelper.Clamp((Time - brain.AIOverride<BrainOfCthulhuAI>().SwipeDelay) / 20f, 0f, 1f), 1));
|
||||
|
||||
if (!singleHand)
|
||||
goalLocation.X += MathHelper.Lerp(0f, 900f, CalamityUtils.SineInOutEasing(MathHelper.Clamp((Time - (brain.AIOverride<BrainOfCthulhuAI>().SwipeDelay + 5)) / 55f, 0f, 1f), 1)) * (evenID ? 1 : -1);
|
||||
else
|
||||
goalLocation.X += MathHelper.Lerp(0f, 900f, CalamityUtils.SineInOutEasing(MathHelper.Clamp((Time - (brain.AIOverride<BrainOfCthulhuAI>().SwipeDelay + 5)) / 55f, 0f, 1f), 1)) * (handSide == -1 ? 1 : -1);
|
||||
|
||||
NPC.Center = Vector2.Lerp(NPC.Center, goalLocation, MathHelper.Clamp((Time - brain.AIOverride<BrainOfCthulhuAI>().SwipeDelay) / 10f, 0f, 1f));
|
||||
}
|
||||
|
||||
Time++;
|
||||
}
|
||||
|
||||
break;
|
||||
case BrainAIState.CreeperCrush:
|
||||
if (brain.AIOverride<BrainOfCthulhuAI>().AttackList.Contains(NPC.whoAmI))
|
||||
{
|
||||
if (Time < 0)
|
||||
Time = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time >= 0)
|
||||
Time = -1;
|
||||
}
|
||||
|
||||
if (Time < 0)
|
||||
{
|
||||
baseRotation = (brain.Center - Main.player[brain.target].Center).ToRotation();
|
||||
evenID = CreeperID % 2 == 0;
|
||||
goalLocation = brain.Center + Vector2.UnitX.RotatedBy(baseRotation + Math.Sin(bossCounter / 60f + CreeperID) * (evenID ? -1 : 1)) * (evenID ? 175 : 250);
|
||||
if (NPC.DistanceSQ(goalLocation) > 9216)
|
||||
{
|
||||
NPC.velocity += NPC.DirectionTo(goalLocation);
|
||||
NPC.velocity = NPC.velocity.ClampMagnitude(0f, 8f);
|
||||
}
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player sharedTarget = Main.player[brain.target];
|
||||
Vector2 dashDir = AttackAngle.ToRotationVector2();
|
||||
if (!bocAI.OnSecondCreeperPhase) // Swipe Attack
|
||||
{
|
||||
float positioningTime = LightSwipeTravelTime + LightSwipeAttackDelay;
|
||||
|
||||
if (Time <= positioningTime)
|
||||
{
|
||||
if (AttackPosition == Vector2.Zero)
|
||||
AttackPosition = NPC.Center;
|
||||
Vector2 goalPosition = sharedTarget.Center - dashDir * 128;
|
||||
goalPosition += dashDir.RotatedBy(MathHelper.PiOver2) * 16;
|
||||
NPC.Center = Vector2.Lerp(AttackPosition, goalPosition, CalamityUtils.SineOutEasing(MathHelper.Clamp(Time / (float)LightSwipeTravelTime, 0f, 1f), 1));
|
||||
NPC.velocity = Vector2.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
AttackPosition = Vector2.Zero;
|
||||
NPC.damage = NPC.defDamage;
|
||||
NPC.knockBackResist = 0f;
|
||||
int reelbackTime = 22;
|
||||
|
||||
if (Time < (positioningTime + reelbackTime))
|
||||
{
|
||||
float reelBackSpeedExponent = 2.6f;
|
||||
float reelBackCompletion = Utils.GetLerpValue(0f, reelbackTime, Time - positioningTime, true);
|
||||
float reelBackSpeed = MathHelper.Lerp(2.5f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent));
|
||||
Vector2 reelBackVelocity = dashDir * -reelBackSpeed;
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f);
|
||||
|
||||
if (Time == positioningTime + reelbackTime - 5)
|
||||
SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, NPC.Center);
|
||||
}
|
||||
else if (Time == (positioningTime + reelbackTime))
|
||||
NPC.velocity = dashDir * 32;
|
||||
else
|
||||
{
|
||||
NPC.velocity *= 0.9f;
|
||||
if (Time >= positioningTime + reelbackTime + 15)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
Time = -1;
|
||||
brain.AIOverride<BrainOfCthulhuAI>().AttackList.Remove(NPC.whoAmI);
|
||||
AttackPosition = Vector2.Zero;
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Crush Attack
|
||||
{
|
||||
float positioningTime = StrongSwipeTravelTime + StrongSwipeAttackDelay;
|
||||
|
||||
if (Time <= positioningTime)
|
||||
{
|
||||
if (AttackPosition == Vector2.Zero)
|
||||
AttackPosition = NPC.Center;
|
||||
Vector2 goalPosition = sharedTarget.Center - dashDir * 128;
|
||||
NPC.Center = Vector2.Lerp(AttackPosition, goalPosition, CalamityUtils.SineOutEasing(MathHelper.Clamp(Time / (float)StrongSwipeTravelTime, 0f, 1f), 1));
|
||||
NPC.velocity = Vector2.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.damage = NPC.defDamage;
|
||||
NPC.knockBackResist = 0f;
|
||||
int reelbackTime = 18;
|
||||
float swingTime = 10f;
|
||||
|
||||
if (Time <= (positioningTime + reelbackTime))
|
||||
{
|
||||
float reelBackSpeedExponent = 2.6f;
|
||||
float reelBackCompletion = Utils.GetLerpValue(0f, reelbackTime, Time - positioningTime, true);
|
||||
float reelBackSpeed = MathHelper.Lerp(2.5f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent));
|
||||
Vector2 reelBackVelocity = dashDir * -reelBackSpeed;
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f);
|
||||
|
||||
if (Time == positioningTime + reelbackTime - 5)
|
||||
SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, NPC.Center);
|
||||
|
||||
if (Time == (positioningTime + reelbackTime))
|
||||
AttackPosition = NPC.Center;
|
||||
}
|
||||
else if (Time <= (positioningTime + reelbackTime + swingTime))
|
||||
{
|
||||
if (Main.npc[PartnerIndex].active)
|
||||
{
|
||||
float moveDist = 196;
|
||||
NPC.Center = Vector2.Lerp(AttackPosition, AttackPosition + dashDir * moveDist, (Time - (positioningTime + reelbackTime)) / swingTime);
|
||||
NPC.velocity = Vector2.Zero;
|
||||
if (Time == (positioningTime + reelbackTime + swingTime))
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, NPC.Center);
|
||||
SoundEngine.PlaySound(NPC.HitSound, NPC.Center);
|
||||
NPC.velocity = dashDir * -8;
|
||||
Vector2 attackCenter = AttackPosition + dashDir * 200;
|
||||
if (dashDir.X <= 0)
|
||||
{
|
||||
//WaterFoam (0.25 -> 1), SoftRoundExplosion (0.025 -> 0.1), SmokeExplosion(0.05 -> 0.15)
|
||||
CustomPulse splatter = new(attackCenter, Vector2.Zero, Color.Red, "CalamityMod/Particles/SmokeExplosion", Vector2.One, Main.rand.NextFloatDirection(), 0.05f, 0.15f, 24);
|
||||
GeneralParticleHandler.SpawnParticle(splatter);
|
||||
}
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
for (int i = -1; i <= 1; i++)
|
||||
Projectile.NewProjectile(NPC.GetSource_FromThis(), attackCenter, dashDir.RotatedBy(MathHelper.PiOver2 + (MathHelper.Pi / 6f * i)) * 8f, ProjectileID.BloodShot, BloodShotDamage, 0.5f);
|
||||
}
|
||||
}
|
||||
else
|
||||
NPC.velocity = dashDir * 19.6f;
|
||||
}
|
||||
else if (Time < (positioningTime + reelbackTime + swingTime + 30))
|
||||
{
|
||||
NPC.velocity *= 0.96f;
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.damage = 0;
|
||||
Time = -1;
|
||||
brain.AIOverride<BrainOfCthulhuAI>().AttackList.Remove(NPC.whoAmI);
|
||||
AttackPosition = Vector2.Zero;
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0.5f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f);
|
||||
Time++;
|
||||
}
|
||||
break;
|
||||
case BrainAIState.CreeperOrbit:
|
||||
if (bossCounter == 0)
|
||||
{
|
||||
CachedValue1 = MathHelper.TwoPi / creeperCount * localCreeperID;
|
||||
AttackAngle = 0;
|
||||
}
|
||||
float dist = OrbitStandardRadius + ((float)Math.Sin((CachedValue1 * 7) + bossCounter / 20f) * 24);
|
||||
|
||||
if (brain.AIOverride<BrainOfCthulhuAI>().AttackList.Contains(NPC.whoAmI))
|
||||
{
|
||||
if (Time < 0)
|
||||
Time = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time >= 0)
|
||||
Time = -1;
|
||||
}
|
||||
|
||||
if (Time >= 0)
|
||||
{
|
||||
float telegraphPeriod = OrbitAttackInterval * 0.25f;
|
||||
float shiftPeriod = (OrbitAttackInterval - telegraphPeriod) / 2f;
|
||||
if (Time < telegraphPeriod)
|
||||
dist = MathHelper.Lerp(dist, OrbitTelegraphRadius, CalamityUtils.SineOutEasing(Time / telegraphPeriod, 1));
|
||||
else if (Time < shiftPeriod + telegraphPeriod)
|
||||
dist = MathHelper.Lerp(OrbitTelegraphRadius, 16, CalamityUtils.SineInOutEasing((Time - telegraphPeriod) / shiftPeriod, 1));
|
||||
else
|
||||
{
|
||||
dist = MathHelper.Lerp(16, dist, CalamityUtils.SineInOutEasing((Time - telegraphPeriod - shiftPeriod) / shiftPeriod, 1));
|
||||
if (Time > OrbitAttackInterval)
|
||||
{
|
||||
Time = -2;
|
||||
brain.AIOverride<BrainOfCthulhuAI>().AttackList.Remove(NPC.whoAmI);
|
||||
}
|
||||
}
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f, 0.1f);
|
||||
Time++;
|
||||
}
|
||||
else
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f, 0.05f);
|
||||
|
||||
float slowDown = (1 - MathHelper.Clamp((bossCounter - OrbitDuration) / 30f, 0f, 1f));
|
||||
AttackAngle += (BaseRotationSpeed * (MathHelper.Lerp(1f, 0.5f, CreeperAmountRatio) + (bocAI.OnSecondCreeperPhase ? 1f : 0.5f))) * slowDown * bocAI.AttackSign;
|
||||
Vector2 rotation = Vector2.UnitX.RotatedBy(CachedValue1 + AttackAngle) * dist;
|
||||
Player target = Main.player[brain.target];
|
||||
|
||||
if (bossCounter < OrbitSetupDuration)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
|
||||
if (bossCounter == 0)
|
||||
AttackPosition = NPC.Center;
|
||||
goalLocation = target.Center + rotation;
|
||||
if (bossCounter < OrbitSetupDuration)
|
||||
NPC.Center = Vector2.Lerp(AttackPosition, goalLocation, CalamityUtils.SineOutEasing(bossCounter / OrbitSetupDuration, 1));
|
||||
else
|
||||
NPC.Center = goalLocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.damage = NPC.defDamage;
|
||||
|
||||
if (bossCounter <= OrbitSetupDuration + 10)
|
||||
{
|
||||
float lerp = CalamityUtils.SineOutEasing((bossCounter - OrbitSetupDuration) / 10f, 1);
|
||||
AttackPosition = Vector2.Lerp(target.Center, AttackPosition, lerp);
|
||||
}
|
||||
else
|
||||
{
|
||||
float prox = target.Distance(AttackPosition);
|
||||
if (prox > 256)
|
||||
AttackPosition += target.DirectionFrom(AttackPosition) * ((prox - 256) / 16f);
|
||||
}
|
||||
|
||||
goalLocation = AttackPosition + rotation;
|
||||
NPC.Center = goalLocation;
|
||||
}
|
||||
break;
|
||||
case BrainAIState.CreeperSpiral:
|
||||
int tendrilID = (CreeperID % TendrilCount) + 1;
|
||||
|
||||
if (bossCounter == 0)
|
||||
{
|
||||
AttackPosition = Vector2.Zero;
|
||||
List<NPC> myGroup = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && (n.ai[0] % TendrilCount) + 1 == tendrilID).ToList();
|
||||
CachedValue1 = myGroup.IndexOf(NPC);
|
||||
CachedValue2 = myGroup.Count;
|
||||
AttackAngle = 0;
|
||||
}
|
||||
|
||||
int index = (int)CachedValue1;
|
||||
int groupCount = CachedValue2;
|
||||
float placementRatio = (index + 1) / (float)(groupCount + 1);
|
||||
|
||||
float spiralAngle = bocAI.AttackRotation;
|
||||
float goalAngle = spiralAngle + ((MathHelper.TwoPi / TendrilCount) * tendrilID);
|
||||
|
||||
float angularVelocity = (goalAngle - AttackAngle) / (16f + (placementRatio * 16f));
|
||||
|
||||
AttackAngle += angularVelocity;
|
||||
|
||||
float goalRadius = TendrilStartDistance + (TendrilLength * placementRatio);
|
||||
goalRadius += (float)Math.Sin(bossCounter / 20f) * MathHelper.Lerp(MaxCreeperSway, 0, groupCount / (float)(GetBrainOfCthuluCreepersCountRevDeath() / 3)) * (index % 2 == 0 ? -1 : 1);
|
||||
|
||||
Vector2 position = brain.Center + (AttackAngle.ToRotationVector2() * goalRadius);
|
||||
if (bossCounter >= SpiralSetupTime)
|
||||
{
|
||||
NPC.Center = position;
|
||||
|
||||
NPC.damage = NPC.defDamage;
|
||||
NPC.knockBackResist = 0f;
|
||||
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f);
|
||||
}
|
||||
else if (bossCounter < SpiralSetupTime / 10f)
|
||||
NPC.velocity *= 0.66f;
|
||||
else
|
||||
{
|
||||
if (AttackPosition == Vector2.Zero)
|
||||
AttackPosition = NPC.Center;
|
||||
NPC.velocity = Vector2.Zero;
|
||||
float lerp = (bossCounter - (SpiralSetupTime / 10f)) / (float)(SpiralSetupTime * 0.9f);
|
||||
NPC.Center = Vector2.Lerp(AttackPosition, position, CalamityUtils.SineInOutEasing(MathHelper.Clamp(lerp, 0f, 1f), 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
switch (AIState)
|
||||
{
|
||||
case CreeperAIState.Idle:
|
||||
if (Time == 0)
|
||||
{
|
||||
AIState = CreeperAIState.Charge;
|
||||
break;
|
||||
}
|
||||
|
||||
NPC.knockBackResist = 0.72f;
|
||||
NPC.damage = 0;
|
||||
|
||||
float baseRotation = MathHelper.TwoPi / (GetBrainOfCthuluCreepersCountRevDeath() / 2f) * (CreeperID / 2f);
|
||||
Vector2 goalLocation = brain.Center + (Vector2.UnitX * (evenID ? -256 : 256)) + Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 60f * (evenID ? -1 : 1))) * 64;
|
||||
if (NPC.DistanceSQ(goalLocation) > 9216)
|
||||
{
|
||||
NPC.velocity += NPC.DirectionTo(goalLocation);
|
||||
NPC.velocity = NPC.velocity.ClampMagnitude(0f, 8f);
|
||||
}
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f);
|
||||
Time = -1;
|
||||
AttackPosition = Vector2.Zero;
|
||||
break;
|
||||
case CreeperAIState.Charge:
|
||||
Player target = Main.player[NPC.target];
|
||||
|
||||
if (Time < CreeperChargePositioningTime)
|
||||
{
|
||||
goalLocation = target.Center + ((NPC.Center - target.Center).SafeNormalize(-Vector2.UnitY).RotatedBy((evenID ? -MathHelper.PiOver4 : MathHelper.PiOver4)) * 96);
|
||||
if (NPC.DistanceSQ(goalLocation) > 4096)
|
||||
{
|
||||
NPC.velocity += NPC.DirectionTo(goalLocation);
|
||||
NPC.velocity = NPC.velocity.ClampMagnitude(0f, 12f);
|
||||
}
|
||||
ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.damage = NPC.defDamage;
|
||||
NPC.knockBackResist = 0f;
|
||||
|
||||
if (Time < (CreeperChargePositioningTime + CreeperChargeWindUpTime))
|
||||
{
|
||||
float reelBackSpeedExponent = 2.6f;
|
||||
float reelBackCompletion = Utils.GetLerpValue(0f, CreeperChargeWindUpTime, Time - CreeperChargePositioningTime, true);
|
||||
float reelBackSpeed = MathHelper.Lerp(2.5f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent));
|
||||
Vector2 reelBackVelocity = NPC.DirectionTo(Main.player[brain.target].Center) * -reelBackSpeed;
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f);
|
||||
|
||||
if (Time == CreeperChargePositioningTime + CreeperChargeWindUpTime - 5)
|
||||
SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, NPC.Center);
|
||||
}
|
||||
else if (Time == CreeperChargePositioningTime + CreeperChargeWindUpTime)
|
||||
NPC.velocity = NPC.DirectionTo(Main.player[brain.target].Center) * 24;
|
||||
else
|
||||
{
|
||||
NPC.velocity *= 0.975f;
|
||||
if (Time >= CreeperChargePositioningTime + CreeperChargeWindUpTime + 30)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
Time = -10;
|
||||
AIState = CreeperAIState.Idle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Time++;
|
||||
break;
|
||||
}
|
||||
|
||||
FlowTime += 0.01f * (2 * (1 + ConnectionOpacity));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter)
|
||||
{
|
||||
binaryWriter.Write(Time);
|
||||
binaryWriter.Write(CachedValue2);
|
||||
binaryWriter.Write(PartnerIndex);
|
||||
|
||||
binaryWriter.WritePackedVector2(AttackPosition);
|
||||
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BitReader bitReader, BinaryReader binaryReader)
|
||||
{
|
||||
Time = binaryReader.ReadInt32();
|
||||
CachedValue2 = binaryReader.ReadInt32();
|
||||
PartnerIndex = binaryReader.ReadInt32();
|
||||
|
||||
AttackPosition = binaryReader.ReadPackedVector2();
|
||||
}
|
||||
|
||||
public override void HitEffect(Mod mod, NPC.HitInfo hit)
|
||||
{
|
||||
if (NPC.life <= 0)
|
||||
{
|
||||
List<VerletSimulatedSegment> verletTendril = BrainOfCthulhuSystem.VerletTendrils[NPC.AIOverride<CreeperAI>().CreeperID];
|
||||
if (verletTendril is null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < verletTendril.Count; i++)
|
||||
{
|
||||
Vector2 start = verletTendril[i].position;
|
||||
Vector2 end = i == verletTendril.Count - 1 ? NPC.Center : verletTendril[i + 1].position;
|
||||
|
||||
float rotation = (end - start).ToRotation();
|
||||
|
||||
float dist = Vector2.Distance(start, end);
|
||||
Vector2 scale = new(1f, dist / BrainOfCthulhuSystem.tendril.Height());
|
||||
|
||||
BrokenTendril gore = new(start, Vector2.UnitY.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)) * -Main.rand.NextFloat(2f, 4f), rotation, scale, 60);
|
||||
GeneralParticleHandler.SpawnParticle(gore);
|
||||
|
||||
}
|
||||
|
||||
BrainOfCthulhuSystem.VerletTendrils[NPC.AIOverride<CreeperAI>().CreeperID] = [];
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) => false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
|
||||
[AutoloadBossHead]
|
||||
public class FalseBrain : ModNPC, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "NPCs";
|
||||
public override string BossHeadTexture => "Terraria/Images/NPC_Head_Boss_23";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
this.HideFromBestiary();
|
||||
Main.npcFrameCount[Type] = 4;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
NPC.width = 160;
|
||||
NPC.height = 110;
|
||||
NPC.damage = 0;
|
||||
NPC.lifeMax = 1;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.noGravity = true;
|
||||
NPC.noTileCollide = true;
|
||||
NPC.boss = true;
|
||||
NPC.immortal = true;
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.chaseable = false;
|
||||
NPC.npcSlots = 0f;
|
||||
NPC.netAlways = true;
|
||||
NPC.ShowNameOnHover = false;
|
||||
Music = MusicID.Boss3;
|
||||
|
||||
NPC.localAI[0] = Main.rand.Next(5);
|
||||
NPC.localAI[1] = 1 + Main.rand.NextFloat(-0.5f, 0.5f);
|
||||
}
|
||||
private int Variant => (int)NPC.localAI[0];
|
||||
private float Angle => NPC.ai[0];
|
||||
private ref float Time => ref NPC.ai[1];
|
||||
internal bool BeenHit = false;
|
||||
int AttackTime = 0;
|
||||
int SpawnTime = 60;
|
||||
|
||||
internal static float TimeDivisor => 360f;
|
||||
internal float DrawPriority => (float)Math.Cos(-Time * MathHelper.TwoPi / TimeDivisor);
|
||||
internal static List<int> blackListedProjectiles = [];
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (NPC.crimsonBoss == -1)
|
||||
{
|
||||
NPC.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
NPC brain = Main.npc[NPC.crimsonBoss];
|
||||
NPC.GivenName = brain.GivenOrTypeName + $": {brain.life}/{brain.lifeMax}";
|
||||
|
||||
if (BeenHit)
|
||||
{
|
||||
NPC.dontTakeDamage = true;
|
||||
|
||||
if (AttackTime == 60)
|
||||
NPC.active = false;
|
||||
|
||||
AttackTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
float lerp = CalamityUtils.SineInOutEasing(MathHelper.Clamp(SpawnTime / -30f, 0f, 1f), 1);
|
||||
float baseDist = 240;
|
||||
float circleDist = 480;
|
||||
if (SpawnTime != -30)
|
||||
{
|
||||
baseDist = MathHelper.Lerp(480, 240, lerp);
|
||||
circleDist = MathHelper.Lerp(240, 480, lerp);
|
||||
}
|
||||
NPC.Center = brain.AIOverride<BrainOfCthulhuAI>().AttackPosition + Vector2.UnitX.RotatedBy(Angle) * (baseDist + (circleDist * ((float)Math.Sin(-Time * MathHelper.TwoPi / TimeDivisor) / 2f + 0.5f)));
|
||||
NPC.Center += Vector2.UnitX.RotatedBy(Angle + MathHelper.PiOver2) * (90 * (float)Math.Cos(Time * MathHelper.TwoPi / TimeDivisor));
|
||||
}
|
||||
|
||||
if (SpawnTime > 0)
|
||||
{
|
||||
if (--SpawnTime == 0)
|
||||
NPC.dontTakeDamage = false;
|
||||
}
|
||||
else if (SpawnTime > -30)
|
||||
Time += --SpawnTime / -30f;
|
||||
else
|
||||
Time++;
|
||||
}
|
||||
|
||||
public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
SmiteFool(player);
|
||||
}
|
||||
|
||||
public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
if (!projectile.Calamity().IgnoreBoCIllusions && projectile.owner != -1)
|
||||
SmiteFool(Main.player[projectile.owner]);
|
||||
}
|
||||
|
||||
private void SmiteFool(Player fool)
|
||||
{
|
||||
if (!BeenHit)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Vector2 dir = fool.Center - NPC.Center;
|
||||
int lifeTime = 24;
|
||||
dir /= lifeTime / 2f * 5f;
|
||||
dir *= i;
|
||||
DirectionalPulseRing pulse = new(NPC.Center, dir, i % 2 == 0 ? Color.Red : Color.Orange, new Vector2(0.5f, 1), dir.ToRotation(), 0f, i / 5f, lifeTime + 8);
|
||||
GeneralParticleHandler.SpawnParticle(pulse);
|
||||
}
|
||||
|
||||
BeenHit = true;
|
||||
SoundEngine.PlaySound(SoundID.Zombie105, NPC.Center); //LC Laugh
|
||||
fool.AddBuff(BuffID.Darkness, 900);
|
||||
fool.AddBuff(BuffID.Bleeding, 900);
|
||||
fool.AddBuff(BuffID.Confused, 60);
|
||||
int timeToAdd = 600;
|
||||
int bbIndex = fool.buffType.ToList().IndexOf(ModContent.BuffType<BurningBlood>());
|
||||
if (bbIndex != -1)
|
||||
{
|
||||
timeToAdd /= 2;
|
||||
timeToAdd += fool.buffTime[bbIndex];
|
||||
}
|
||||
fool.AddBuff(ModContent.BuffType<BurningBlood>(), timeToAdd);
|
||||
|
||||
fool.Calamity().adrenaline = 0;
|
||||
|
||||
NPC.dontTakeDamage = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void FindFrame(int frameHeight)
|
||||
{
|
||||
NPC.frameCounter += 0.2f * NPC.localAI[1];
|
||||
if ((int)NPC.frameCounter > 3)
|
||||
NPC.frameCounter = 0;
|
||||
}
|
||||
|
||||
internal void DrawSelf(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
|
||||
{
|
||||
Texture2D tex = TextureAssets.Npc[Type].Value;
|
||||
|
||||
Rectangle frame = tex.Frame(5, 4, Variant, (int)NPC.frameCounter);
|
||||
|
||||
Vector2 scaleDistort = new Vector2((float)Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f);
|
||||
|
||||
float endLerp = AttackTime / 60f;
|
||||
float startLerp = SpawnTime / 60f;
|
||||
|
||||
if (SpawnTime > 0)
|
||||
{
|
||||
drawColor *= (1 - startLerp);
|
||||
scaleDistort *= startLerp;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawColor = Color.Lerp(drawColor, Color.Red, endLerp) * (1 - endLerp);
|
||||
scaleDistort *= endLerp;
|
||||
}
|
||||
|
||||
spriteBatch.Draw(tex, NPC.Center + (Vector2.UnitY * 16) - screenPos, frame, drawColor, NPC.rotation, frame.Size() * 0.5f, (Vector2.One + scaleDistort) * NPC.scale, 0, 0);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) => false;
|
||||
}
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 196 KiB |
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Particles;
|
||||
|
||||
public class BossRoar : Particle
|
||||
{
|
||||
public override string Texture => "CalamityMod/Particles/RoarPulse";
|
||||
public override bool SetLifetime => true;
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
private float OriginalScale;
|
||||
private float FinalScale;
|
||||
private float BaseOpacity;
|
||||
private float opacity;
|
||||
private Color BaseColor;
|
||||
|
||||
public BossRoar(Vector2 position, Color color, float rotation, float originalScale, float finalScale, int lifeTime, float baseOpacity = 1f)
|
||||
{
|
||||
Position = position;
|
||||
BaseColor = color;
|
||||
OriginalScale = originalScale;
|
||||
FinalScale = finalScale;
|
||||
Scale = originalScale;
|
||||
Lifetime = lifeTime;
|
||||
BaseOpacity = baseOpacity;
|
||||
Rotation = rotation;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Scale = MathHelper.Lerp(OriginalScale, FinalScale, LifetimeCompletion);
|
||||
|
||||
opacity = 1f;
|
||||
if (LifetimeCompletion < 0.1f)
|
||||
opacity = MathHelper.Lerp(0f, 1f, LifetimeCompletion * 10);
|
||||
|
||||
Color = BaseColor * opacity;
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
|
||||
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * BaseOpacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.DataStructures;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Particles;
|
||||
|
||||
public class BrainOfCthulhuAfterImage : Particle
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override bool UseCustomDraw => false;
|
||||
|
||||
public override bool SetLifetime => true;
|
||||
|
||||
public override bool Important => true;
|
||||
|
||||
private float StartFade;
|
||||
private float Opacity = 1f;
|
||||
List<Vector2> Path;
|
||||
private Vector2 MyScale = Vector2.One;
|
||||
private Rectangle Frame;
|
||||
|
||||
public BrainOfCthulhuAfterImage(BezierCurve path, float rotation, Vector2 scale, int lifeTime, Rectangle frame, float startFadeRatio = 0f)
|
||||
{
|
||||
Path = path.GetPoints(lifeTime);
|
||||
Position = Path[0];
|
||||
Rotation = rotation;
|
||||
StartFade = startFadeRatio;
|
||||
MyScale = scale;
|
||||
Frame = frame;
|
||||
Lifetime = lifeTime + 1;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
float timeRatio = Time / (float)Lifetime;
|
||||
Opacity = timeRatio;
|
||||
if (StartFade != 0f)
|
||||
Opacity = Utils.GetLerpValue(StartFade, 1f, timeRatio, true);
|
||||
|
||||
Opacity = 1 - CalamityUtils.SineInEasing(Opacity, 1);
|
||||
|
||||
List<Vector2> pathPosition = Path;
|
||||
|
||||
if (Time >= pathPosition.Count)
|
||||
{
|
||||
Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
Position = pathPosition[Time];
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
float timeRatio = Time / (float)Lifetime;
|
||||
spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, Position - Main.screenPosition, Frame, Lighting.GetColor(Position.ToTileCoordinates()) * Opacity * 0.5f, Rotation, Frame.Size() * 0.5f, MyScale, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Particles;
|
||||
|
||||
public class BrokenTendril : Particle
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override bool UseCustomDraw => true;
|
||||
|
||||
private int TimeLeft;
|
||||
private float Opacity = 1f;
|
||||
private Vector2 InitalScale = Vector2.One;
|
||||
|
||||
public BrokenTendril(Vector2 position, Vector2 velocity, float rotation, Vector2 scale, int lifeTime)
|
||||
{
|
||||
Position = position;
|
||||
Velocity = velocity;
|
||||
Scale = 1f;
|
||||
Rotation = rotation;
|
||||
TimeLeft = lifeTime;
|
||||
InitalScale = scale - Vector2.One;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (InitalScale != Vector2.Zero)
|
||||
{
|
||||
InitalScale *= 0.98f;
|
||||
if (InitalScale.X < 0.05f)
|
||||
InitalScale.X = 0;
|
||||
if (InitalScale.Y < 0.05f)
|
||||
InitalScale.Y = 0;
|
||||
}
|
||||
|
||||
Point tilePos = Position.ToTileCoordinates();
|
||||
if (!WorldGen.InWorld(tilePos.X, tilePos.Y))
|
||||
{
|
||||
Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Main.tile[tilePos].IsTileSolid() || TileID.Sets.Platforms[Main.tile[tilePos].TileType])
|
||||
{
|
||||
Velocity.Y = 0;
|
||||
if (Velocity.X > 0.05f)
|
||||
Velocity.X *= 0.9f;
|
||||
else
|
||||
Velocity.X = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Velocity.Y += 0.25f;
|
||||
Velocity.X *= 0.975f;
|
||||
}
|
||||
|
||||
Rotation += Velocity.X * 0.025f;
|
||||
|
||||
if (Velocity == Vector2.Zero)
|
||||
{
|
||||
if (TimeLeft < 30)
|
||||
{
|
||||
Opacity = TimeLeft / 30f;
|
||||
if (TimeLeft <= 0)
|
||||
Kill();
|
||||
}
|
||||
TimeLeft--;
|
||||
}
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Texture2D tex = BrainOfCthulhuSystem.tendril.Value;
|
||||
float rot = Rotation - MathHelper.PiOver2;
|
||||
Vector2 center = Position + rot.ToRotationVector2() * tex.Size().Y * InitalScale.Y * 0.5f;
|
||||
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Lighting.GetColor(center.ToTileCoordinates()) * Opacity, rot, tex.Size() * Vector2.UnitX * 0.5f, Vector2.One + InitalScale, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu;
|
||||
|
||||
public class BloodScythe : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Boss";
|
||||
public override string Texture => "CalamityMod/Particles/VerticalSmearRagged";
|
||||
|
||||
private Vector2 InitialVelocity = Vector2.Zero;
|
||||
private Vector2 AcceleratingVelocity = Vector2.Zero;
|
||||
private static float RotationSpeed => MathHelper.Pi / 8f;
|
||||
private static float Acceleration => 0.175f;
|
||||
private static int Lifetime => 240;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 16;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 300;
|
||||
Projectile.height = 300;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = Lifetime;
|
||||
Projectile.damage = 10;
|
||||
Projectile.scale = 0.1f;
|
||||
Projectile.hostile = true;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
InitialVelocity = Projectile.velocity;
|
||||
Projectile.rotation = Projectile.velocity.ToRotation();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
BloodParticle p = new(Projectile.Center, Projectile.velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.5f, 1f), 32, 1f, Color.Red);
|
||||
GeneralParticleHandler.SpawnParticle(p);
|
||||
}
|
||||
BloodParticle2 p2 = new(Projectile.Center, Projectile.velocity * 0.75f, 16, 0.5f, Color.Red);
|
||||
GeneralParticleHandler.SpawnParticle(p2);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
int UpTime = Lifetime - Projectile.timeLeft;
|
||||
InitialVelocity *= 0.925f;
|
||||
if (UpTime > 15)
|
||||
{
|
||||
AcceleratingVelocity += Projectile.velocity.SafeNormalize(InitialVelocity.SafeNormalize(Vector2.UnitX)) * Acceleration;
|
||||
if (Main.rand.NextBool(1 + Projectile.timeLeft / 32))
|
||||
{
|
||||
BloodParticle p = new(Projectile.Center + Main.rand.NextVector2CircularEdge(32, 32), (-Projectile.velocity).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.25f, 0.75f), Main.rand.Next(10, 17), 1f, Color.Red);
|
||||
GeneralParticleHandler.SpawnParticle(p);
|
||||
}
|
||||
}
|
||||
Projectile.velocity = InitialVelocity + AcceleratingVelocity;
|
||||
Projectile.rotation += RotationSpeed;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.WritePackedVector2(InitialVelocity);
|
||||
writer.WritePackedVector2(AcceleratingVelocity);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
InitialVelocity = reader.ReadPackedVector2();
|
||||
AcceleratingVelocity = reader.ReadPackedVector2();
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Main.spriteBatch.SetBlendState(BlendState.Additive);
|
||||
Texture2D tex = TextureAssets.Projectile[Type].Value;
|
||||
Vector2 drawPos = Projectile.Center - Main.screenPosition;
|
||||
Color drawColor = Color.Red;
|
||||
if (!ChildSafety.Disabled)
|
||||
drawColor = Main.DiscoColor;
|
||||
|
||||
if (CalamityClientConfig.Instance.Afterimages)
|
||||
{
|
||||
for (int i = 0; i < Projectile.oldPos.Length; ++i)
|
||||
{
|
||||
float afterimageRot = Projectile.oldRot[i];
|
||||
drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
|
||||
if (i != 0)
|
||||
drawColor *= 0.9f;
|
||||
|
||||
// DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES.
|
||||
float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length);
|
||||
Main.spriteBatch.Draw(tex, drawPos, null, drawColor, afterimageRot, tex.Size() * 0.5f, Projectile.scale * interpolant, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
//else
|
||||
// Main.EntitySpriteDraw(tex, drawPos, tex.Frame(), drawColor, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0);
|
||||
|
||||
Main.spriteBatch.SetBlendState(BlendState.AlphaBlend);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class CirclingBloodScythe : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Boss";
|
||||
public override string Texture => "CalamityMod/Particles/VerticalSmearRagged";
|
||||
|
||||
private static float RotationSpeed => MathHelper.Pi / 8f;
|
||||
private static int Lifetime => BrainOfCthulhuAI.CrimsonEyeAttackDuration;
|
||||
private static float MaxCircleSpeed => MathHelper.Pi / 30f; //1 rev per second
|
||||
|
||||
ref float CircleAngle => ref Projectile.ai[0];
|
||||
ref float CircleRadius => ref Projectile.ai[1];
|
||||
ref float CircleRadiusVelocity => ref Projectile.ai[2];
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 16;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 300;
|
||||
Projectile.height = 300;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = Lifetime;
|
||||
Projectile.damage = 10;
|
||||
Projectile.scale = 0.1f;
|
||||
Projectile.hostile = true;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
Projectile.rotation = CircleAngle;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
BloodParticle p = new(Projectile.Center, Projectile.velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.5f, 1f), 32, 1f, Color.Red);
|
||||
GeneralParticleHandler.SpawnParticle(p);
|
||||
}
|
||||
BloodParticle2 p2 = new(Projectile.Center, Projectile.velocity * 0.75f, 16, 0.5f, Color.Red);
|
||||
GeneralParticleHandler.SpawnParticle(p2);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (NPC.crimsonBoss == -1)
|
||||
{
|
||||
Projectile.active = false;
|
||||
return;
|
||||
}
|
||||
int UpTime = Lifetime - Projectile.timeLeft;
|
||||
|
||||
if (UpTime < 30f)
|
||||
CircleRadius = MathHelper.Lerp(0f, 128f, CalamityUtils.CircOutEasing(UpTime / 30f, 1));
|
||||
else if (UpTime < Lifetime - 180)
|
||||
CircleRadius = 128f;
|
||||
else
|
||||
{
|
||||
if (UpTime == Lifetime - 180)
|
||||
CircleRadiusVelocity = -3f;
|
||||
CircleRadius += CircleRadiusVelocity;
|
||||
CircleRadiusVelocity += 0.1f;
|
||||
}
|
||||
|
||||
if (UpTime >= 15f)
|
||||
{
|
||||
if (UpTime < 30f)
|
||||
CircleAngle += MathHelper.Lerp(0f, MaxCircleSpeed, CalamityUtils.SineInEasing((UpTime - 15) / 15f, 1));
|
||||
else if (UpTime < 870)
|
||||
CircleAngle += MaxCircleSpeed;
|
||||
else if (UpTime < 900)
|
||||
CircleAngle += MathHelper.Lerp(MaxCircleSpeed, MaxCircleSpeed / 3f, CalamityUtils.SineOutEasing((UpTime - 870) / 30f, 1));
|
||||
else
|
||||
CircleAngle += MaxCircleSpeed / 3f;
|
||||
|
||||
if (Main.rand.NextBool(6))
|
||||
{
|
||||
BloodParticle p = new(Projectile.Center + Main.rand.NextVector2CircularEdge(32, 32), (Projectile.DirectionTo(Main.npc[NPC.crimsonBoss].Center).RotatedBy(MathHelper.PiOver2) * 16f).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.25f, 0.75f), Main.rand.Next(10, 17), 1f, Color.Red);
|
||||
GeneralParticleHandler.SpawnParticle(p);
|
||||
}
|
||||
}
|
||||
|
||||
NPC boss = Main.npc[NPC.crimsonBoss];
|
||||
|
||||
Projectile.Center = boss.Center + (CircleAngle.ToRotationVector2() * CircleRadius);
|
||||
Projectile.rotation += RotationSpeed;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Main.spriteBatch.SetBlendState(BlendState.Additive);
|
||||
Texture2D tex = TextureAssets.Projectile[Type].Value;
|
||||
Vector2 drawPos = Projectile.Center - Main.screenPosition;
|
||||
Color drawColor = Color.Red;
|
||||
if (!ChildSafety.Disabled)
|
||||
drawColor = Main.DiscoColor;
|
||||
|
||||
if (CalamityClientConfig.Instance.Afterimages)
|
||||
{
|
||||
for (int i = 0; i < Projectile.oldPos.Length; ++i)
|
||||
{
|
||||
float afterimageRot = Projectile.oldRot[i];
|
||||
drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
|
||||
if (i != 0)
|
||||
drawColor *= 0.9f;
|
||||
// DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES.
|
||||
float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length);
|
||||
Main.spriteBatch.Draw(tex, drawPos, null, drawColor, afterimageRot, tex.Size() * 0.5f, Projectile.scale * interpolant, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
Main.EntitySpriteDraw(tex, drawPos, tex.Frame(), drawColor, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0);
|
||||
|
||||
Main.spriteBatch.SetBlendState(BlendState.AlphaBlend);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu;
|
||||
|
||||
public class CrimsonEye : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Boss";
|
||||
|
||||
private ref float Time => ref Projectile.ai[0];
|
||||
private ref float DistanceRatio => ref Projectile.ai[1];
|
||||
private ref float ExplosionTime => ref Projectile.ai[2];
|
||||
|
||||
private static float TimeToExplode => 30f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.DontAttachHideToAlpha[Type] = true;
|
||||
Main.projFrames[Type] = 5;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 100;
|
||||
Projectile.height = 36;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.scale = 1;
|
||||
Projectile.hostile = false;
|
||||
Projectile.hide = true;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Crimstone);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Time > 45)
|
||||
{
|
||||
Player closest = Main.player[Player.FindClosest(Projectile.position, Projectile.width, Projectile.height)];
|
||||
DistanceRatio = 1 - MathHelper.Clamp((Projectile.Center.Distance(closest.Center) - 128) / 120f, 0f, 1f);
|
||||
|
||||
if (DistanceRatio >= 1 && Projectile.frame == 4)
|
||||
{
|
||||
if (Projectile.timeLeft < 120)
|
||||
Projectile.timeLeft = 120;
|
||||
|
||||
if (ExplosionTime == TimeToExplode)
|
||||
{
|
||||
Projectile.hostile = true;
|
||||
DetailedExplosion explosion = new(Projectile.Center, Vector2.Zero, Color.Orange, Vector2.One, Main.rand.NextFloatDirection(), 0.3f, 0.9f, 24);
|
||||
GeneralParticleHandler.SpawnParticle(explosion);
|
||||
|
||||
Projectile.Resize(256, 256);
|
||||
}
|
||||
else if (Projectile.width == 256)
|
||||
Projectile.active = false;
|
||||
|
||||
ExplosionTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ExplosionTime > 0)
|
||||
ExplosionTime--;
|
||||
|
||||
if (Projectile.width == 256)
|
||||
Projectile.active = false;
|
||||
}
|
||||
|
||||
if (Time > 65)
|
||||
{
|
||||
if (Projectile.timeLeft <= 20)
|
||||
Projectile.frame = (Projectile.timeLeft - 5) / 5;
|
||||
else
|
||||
Projectile.frame = 4;
|
||||
}
|
||||
else if (Time % 5 == 0)
|
||||
Projectile.frame++;
|
||||
}
|
||||
Time++;
|
||||
}
|
||||
|
||||
public override void DrawBehind(int index, List<int> behindNPCsAndTiles, List<int> behindNPCs, List<int> behindProjectiles, List<int> overPlayers, List<int> overWiresUI)
|
||||
{
|
||||
behindNPCsAndTiles.Add(index);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (ExplosionTime >= TimeToExplode)
|
||||
return false;
|
||||
|
||||
if (ExplosionTime > 0)
|
||||
{
|
||||
float ratio = ExplosionTime / TimeToExplode;
|
||||
|
||||
Vector3 lightLevels = lightColor.ToVector3();
|
||||
float lightLevel = (lightLevels.X + lightLevels.Y + lightLevels.Z) / 3f;
|
||||
lightColor = Color.Lerp(lightColor, Color.Lerp(Color.Red, Color.Gold, (float)Math.Sin(ExplosionTime / 4f) / 2f + 0.5f) * lightLevel, ratio);
|
||||
lightColor.A = 255;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PostDraw(Color lightColor)
|
||||
{
|
||||
if (ExplosionTime >= TimeToExplode)
|
||||
return;
|
||||
|
||||
float ratio = CalamityUtils.SineOutEasing(ExplosionTime / TimeToExplode, 1);
|
||||
|
||||
if (Projectile.frame == 4)
|
||||
{
|
||||
Texture2D tex = ModContent.Request<Texture2D>(Texture + "Pupil").Value;
|
||||
Vector2 rangeScale = new Vector2(2.25f, 0.75f);
|
||||
Vector2 dir = Projectile.DirectionTo(Main.LocalPlayer.Center);
|
||||
if (ExplosionTime > 0)
|
||||
{
|
||||
if (ratio < 0.25f)
|
||||
dir = Vector2.Lerp(dir, Vector2.Zero, ratio * 4f);
|
||||
else
|
||||
dir = Main.rand.NextVector2CircularEdge(1, 1);
|
||||
}
|
||||
|
||||
if (Projectile.timeLeft <= 50)
|
||||
dir *= (Projectile.timeLeft - 20) / 30f;
|
||||
|
||||
float range = 6f;
|
||||
if (ratio > 0.25f)
|
||||
{
|
||||
range = MathHelper.Lerp(0f, 6f, (ratio - 0.25f) * 0.75f);
|
||||
}
|
||||
else if (Time < 85)
|
||||
{
|
||||
float lerp = CalamityUtils.SineOutEasing((Time - 65) / 20f, 1);
|
||||
range = MathHelper.Lerp(0f, range, lerp);
|
||||
}
|
||||
|
||||
Main.EntitySpriteDraw(tex, Projectile.Center + (dir * rangeScale * range) - Main.screenPosition, null, lightColor, 0, tex.Size() * 0.5f, 1f, 0);
|
||||
}
|
||||
|
||||
if (DistanceRatio > 0)
|
||||
{
|
||||
/*
|
||||
Main.spriteBatch.SetBlendState(BlendState.Additive);
|
||||
|
||||
Texture2D tex = ModContent.Request<Texture2D>("CalamityMod/Particles/HollowCircleHardEdge").Value;
|
||||
Color color = Color.Red * DistanceRatio;
|
||||
if (Time <= 65)
|
||||
color *= (Time - 45) / 20f;
|
||||
|
||||
if (Projectile.timeLeft <= 20)
|
||||
color *= Projectile.timeLeft / 20f;
|
||||
|
||||
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, color, 0f, tex.Size() * 0.5f, 1.75f, 0);
|
||||
|
||||
Main.spriteBatch.SetBlendState(BlendState.AlphaBlend);
|
||||
*/
|
||||
|
||||
float opacity = DistanceRatio;
|
||||
if (Time <= 65)
|
||||
opacity *= (Time - 45) / 20f;
|
||||
|
||||
if (Projectile.timeLeft <= 20)
|
||||
opacity *= Projectile.timeLeft / 20f;
|
||||
|
||||
Main.spriteBatch.EnterShaderRegion();
|
||||
Texture2D telegraphBase = ModContent.Request<Texture2D>("CalamityMod/Projectiles/InvisibleProj").Value;
|
||||
|
||||
GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseOpacity(opacity);
|
||||
GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseColor(Color.Lerp(Color.Red, Color.OrangeRed, 0.7f * (float)Math.Pow(0.5 + 0.5 * Math.Sin(Main.GlobalTimeWrappedHourly), 3)));
|
||||
GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSecondaryColor(Color.Lerp(Color.Yellow, Color.White, 0.5f));
|
||||
GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSaturation(ratio * 0.5f + 0.5f);
|
||||
|
||||
GameShaders.Misc["CalamityMod:CircularAoETelegraph"].Apply();
|
||||
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
Main.EntitySpriteDraw(telegraphBase, drawPosition, null, lightColor, 0, telegraphBase.Size() / 2f, 248f, 0, 0);
|
||||
Main.spriteBatch.ExitShaderRegion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
File renamed without changes.
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu;
|
||||
|
||||
public class IchorShower : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Boss";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 8;
|
||||
Projectile.height = 8;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = 480;
|
||||
Projectile.damage = 10;
|
||||
Projectile.scale = 1;
|
||||
Projectile.hostile = true;
|
||||
Projectile.extraUpdates = 1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), DustID.Ichor, Vector2.Zero).noGravity = true;
|
||||
if (Main.rand.NextBool(8))
|
||||
Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), DustID.GoldFlame, Vector2.UnitX * Projectile.velocity / 10f, Scale: 0.75f);
|
||||
Projectile.velocity.Y += 0.075f;
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
||||
{
|
||||
target.AddBuff(BuffID.Ichor, 600);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu;
|
||||
|
||||
public class TelekineticBlast : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Boss";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 1;
|
||||
Projectile.height = 1;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = 1;
|
||||
Projectile.damage = 0;
|
||||
Projectile.scale = 1;
|
||||
Projectile.hostile = true;
|
||||
}
|
||||
|
||||
Player target => Main.player[(int)Projectile.ai[0]];
|
||||
float debuffMultiplier => Projectile.ai[1];
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Vector2 dir = target.Center - Projectile.Center;
|
||||
int lifeTime = 24;
|
||||
dir /= lifeTime / 2f * 5f;
|
||||
dir *= i;
|
||||
DirectionalPulseRing pulse = new(Projectile.Center, dir, i % 2 == 0 ? Color.Red : Color.Orange, new Vector2(0.5f, 1), dir.ToRotation(), 0f, i / 5f, lifeTime + 8);
|
||||
GeneralParticleHandler.SpawnParticle(pulse);
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Zombie105, Projectile.Center); //LC Laugh
|
||||
target.AddBuff(BuffID.Darkness, (int)Math.Round(900 * debuffMultiplier));
|
||||
target.AddBuff(BuffID.Bleeding, (int)Math.Round(900 * debuffMultiplier));
|
||||
target.AddBuff(BuffID.Confused, (int)Math.Round(60 * debuffMultiplier));
|
||||
int timeToAdd = (int)Math.Round(600 * debuffMultiplier);
|
||||
int bbIndex = target.buffType.ToList().IndexOf(ModContent.BuffType<BurningBlood>());
|
||||
if (bbIndex != -1)
|
||||
timeToAdd += target.buffTime[bbIndex];
|
||||
target.AddBuff(ModContent.BuffType<BurningBlood>(), timeToAdd);
|
||||
|
||||
target.Calamity().adrenaline = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CalamityMod.DataStructures;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu;
|
||||
|
||||
public class TelekineticEnemyGrab : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Boss";
|
||||
public override string Texture => "CalamityMod/Particles/BloomRing";
|
||||
|
||||
BezierCurve curve;
|
||||
int throwSign = 0;
|
||||
Vector2 throwPos = Vector2.Zero;
|
||||
Vector2 holdPos;
|
||||
|
||||
ref float Time => ref Projectile.ai[0];
|
||||
ref float StunTime => ref Projectile.ai[1];
|
||||
|
||||
private static Dictionary<int, Texture2D> EnemyGlowTextures = [];
|
||||
int enemyID { get => (int)Projectile.ai[2]; set => Projectile.ai[2] = (float)value; }
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 48;
|
||||
Projectile.height = 48;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = 1200;
|
||||
Projectile.damage = 10;
|
||||
Projectile.hostile = true;
|
||||
}
|
||||
|
||||
public override void OnSpawn(IEntitySource source)
|
||||
{
|
||||
holdPos = new Vector2(Projectile.Center.X, Main.npc[NPC.crimsonBoss].Center.Y - 128) - Main.npc[NPC.crimsonBoss].Center;
|
||||
|
||||
Projectile.rotation = Main.rand.NextFloat(0, MathHelper.TwoPi);
|
||||
|
||||
StunTime = -1;
|
||||
|
||||
enemyID = Main.rand.Next(0, 3);
|
||||
int[] enemyIDs = [NPCID.FaceMonster, NPCID.Crimera, NPCID.BloodCrawler];
|
||||
enemyID = enemyIDs[enemyID];
|
||||
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (NPC.crimsonBoss == -1)
|
||||
{
|
||||
Projectile.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time <= 90)
|
||||
Projectile.hostile = false;
|
||||
else
|
||||
Projectile.hostile = true;
|
||||
|
||||
bool throwing = Time > 180;
|
||||
float throwTime = Time - 180;
|
||||
if (throwing)
|
||||
{
|
||||
if (throwSign == 0)
|
||||
throwSign = Math.Sign(Projectile.Center.X - Main.npc[NPC.crimsonBoss].Center.X) * -Math.Sign(Main.player[Main.npc[NPC.crimsonBoss].target].Center.Y - Main.npc[NPC.crimsonBoss].Center.Y);
|
||||
}
|
||||
bool thrown = throwTime > 90;
|
||||
|
||||
if (!thrown)
|
||||
{
|
||||
Vector2 startPoint = Main.npc[NPC.crimsonBoss].Center;// Main.npc[NPC.crimsonBoss].Center;
|
||||
Vector2 endPoint = Projectile.Center;
|
||||
|
||||
if (StunTime == -1)
|
||||
{
|
||||
if (!throwing)
|
||||
{
|
||||
if (Time >= 150)
|
||||
Projectile.velocity = ((holdPos + Main.npc[NPC.crimsonBoss].Center) - Projectile.Center) / 30f;
|
||||
else if (Time != 0)
|
||||
{
|
||||
|
||||
if (Time <= 90)
|
||||
{
|
||||
if (Time == 90)
|
||||
Projectile.velocity = Vector2.UnitY * -24f;
|
||||
if (Time % 30 == 0)
|
||||
Projectile.velocity = Vector2.UnitY * -16f;
|
||||
else
|
||||
Projectile.velocity *= 0.33f;
|
||||
}
|
||||
else
|
||||
Projectile.velocity *= 0.966f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (throwTime <= 30)
|
||||
throwPos = (Projectile.Center + Projectile.velocity) - (Main.npc[NPC.crimsonBoss].Center + Main.npc[NPC.crimsonBoss].velocity);
|
||||
Vector2 target = Main.player[Main.npc[NPC.crimsonBoss].target].Center;
|
||||
Vector2 throwDir = (target - (throwPos + (Main.npc[NPC.crimsonBoss].Center + Main.npc[NPC.crimsonBoss].velocity))).SafeNormalize(Vector2.UnitY);
|
||||
|
||||
if (throwTime >= 30 && throwTime <= 90)
|
||||
{
|
||||
if (throwTime <= 60f)
|
||||
{
|
||||
Projectile.Center = Vector2.Lerp(throwPos, throwPos - throwDir * 56f, CalamityUtils.SineInOutEasing((throwTime - 30) / 30f, 1)) + (Main.npc[NPC.crimsonBoss].Center + Main.npc[NPC.crimsonBoss].velocity);
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.velocity += throwDir * 0.9f;
|
||||
if (throwTime == 90)
|
||||
{
|
||||
float dist = Projectile.Center.Distance(target) / 2f;
|
||||
dist /= Projectile.velocity.Length();
|
||||
Projectile.velocity.Y -= dist * 0.6f;
|
||||
Projectile.tileCollide = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 direction = endPoint - startPoint;
|
||||
float distance = Vector2.Distance(startPoint, endPoint);
|
||||
|
||||
float lerp = CalamityUtils.SineInOutEasing(MathHelper.Clamp((throwTime) / 60f, 0f, 1f), 1);
|
||||
float xMult = MathHelper.Lerp(-Math.Clamp(direction.X / 256f, -1, 1), throwSign, lerp);
|
||||
float yMult = Math.Clamp(direction.Y / 256f, -1, 1);
|
||||
float curveIntensity = Math.Clamp(distance / 420f, 0f, 0.66f) * xMult * yMult;
|
||||
//Main.NewText("Completion: " + lerp + ", Intensity: " + curveIntensity);
|
||||
Vector2 perpindicular = direction.RotatedBy(MathHelper.PiOver2);
|
||||
|
||||
Vector2 controlPoint1 = startPoint + (direction * 0.25f) + (perpindicular * curveIntensity);
|
||||
Vector2 controlPoint2 = startPoint + (direction * 0.75f) + (perpindicular * curveIntensity);
|
||||
|
||||
curve = new BezierCurve(startPoint, controlPoint1, controlPoint2, endPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.velocity.Y += 0.6f;
|
||||
}
|
||||
|
||||
if (StunTime >= 0)
|
||||
{
|
||||
if (StunTime < 30f)
|
||||
StunTime++;
|
||||
else
|
||||
{
|
||||
Projectile.velocity.Y += 0.6f;
|
||||
Projectile.tileCollide = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time > 90)
|
||||
Projectile.rotation += (Projectile.velocity.X / 100f) - (Math.Sign(Main.npc[NPC.crimsonBoss].Center.X - Projectile.Center.X) * 0.025f);
|
||||
Time++;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(throwSign);
|
||||
|
||||
writer.WritePackedVector2(throwPos);
|
||||
|
||||
writer.WritePackedVector2(holdPos);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
throwSign = reader.ReadInt32();
|
||||
|
||||
throwPos = reader.ReadPackedVector2();
|
||||
|
||||
holdPos = reader.ReadPackedVector2();
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
Vector2 velocity = Projectile.velocity.RotatedBy(MathHelper.Pi) / 8f;
|
||||
Vector2 pos = Projectile.Center;
|
||||
|
||||
switch (enemyID)
|
||||
{
|
||||
case NPCID.FaceMonster:
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 237);
|
||||
|
||||
for (int i = 0; i < 24; i++)
|
||||
Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(16, 32), DustID.Blood, Scale: Main.rand.NextFloat(1, 2));
|
||||
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath1 with { Volume = 0.25f }, pos);
|
||||
break;
|
||||
case NPCID.Crimera:
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 223);
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 224);
|
||||
|
||||
for (int i = 0; i < 24; i++)
|
||||
Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(16, 32), DustID.Blood, Scale: Main.rand.NextFloat(1, 2));
|
||||
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath1 with { Volume = 0.25f }, pos);
|
||||
break;
|
||||
case NPCID.BloodCrawler:
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 351);
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 352);
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 353);
|
||||
|
||||
for (int i = 0; i < 24; i++)
|
||||
Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(16, 32), DustID.Blood, Scale: Main.rand.NextFloat(1, 2));
|
||||
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath1 with { Volume = 0.25f }, pos);
|
||||
break;
|
||||
default:
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 42);
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 43);
|
||||
Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 44);
|
||||
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath2 with { Volume = 0.175f }, pos);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool evenRed = false;
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
//Handles getting the glow textures
|
||||
if (EnemyGlowTextures.Count == 0 || !EnemyGlowTextures.ContainsKey(enemyID))
|
||||
{
|
||||
EnemyGlowTextures.Clear();
|
||||
int[] enemyIDs = [NPCID.FaceMonster, NPCID.Crimera, NPCID.BloodCrawler];
|
||||
foreach (int id in enemyIDs)
|
||||
{
|
||||
var baseTex = TextureAssets.Npc[id];
|
||||
var glow = new Texture2D(Main.graphics.GraphicsDevice, baseTex.Value.Width, baseTex.Value.Height);
|
||||
|
||||
var BaseArray = new Color[glow.Width * glow.Height];
|
||||
var ColorArray = new Color[glow.Width * glow.Height];
|
||||
baseTex.Value.GetData(BaseArray);
|
||||
for (var i = 0; i < BaseArray.Length; i++)
|
||||
{
|
||||
if (BaseArray[i].A != 0)
|
||||
ColorArray[i] = new Color(255, 255, 255);
|
||||
}
|
||||
glow.SetData(ColorArray);
|
||||
|
||||
EnemyGlowTextures.Add(id, glow);
|
||||
}
|
||||
}
|
||||
|
||||
int type = enemyID;
|
||||
int frameCount;
|
||||
int wrapFrame = -1;
|
||||
int startFrame = 0;
|
||||
float mult = 0.75f;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case NPCID.FaceMonster:
|
||||
frameCount = 16;
|
||||
startFrame = 2;
|
||||
wrapFrame = 16;
|
||||
break;
|
||||
case NPCID.Crimera:
|
||||
frameCount = 2;
|
||||
mult = 0.25f;
|
||||
break;
|
||||
case NPCID.BloodCrawler:
|
||||
frameCount = 5;
|
||||
mult = 0.25f;
|
||||
break;
|
||||
default:
|
||||
frameCount = 15;
|
||||
type = NPCID.Skeleton;
|
||||
startFrame = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (wrapFrame == -1)
|
||||
wrapFrame = frameCount;
|
||||
|
||||
Texture2D tex = TextureAssets.Npc[type].Value;
|
||||
|
||||
int currentFrame = ((int)((1200 - Projectile.timeLeft) * mult)) % (wrapFrame - startFrame);
|
||||
|
||||
Rectangle frame = tex.Frame(1, frameCount, 0, startFrame + currentFrame);
|
||||
|
||||
float throwTime = Time - 180;
|
||||
|
||||
float opacity = 1f;
|
||||
if (Time < 10)
|
||||
opacity = Time / 10f;
|
||||
|
||||
if (throwTime <= 90)
|
||||
{
|
||||
int pCount = 12;
|
||||
|
||||
float wrapTime = 60;
|
||||
float wrappedTime = MathHelper.Clamp((Time % (wrapTime + 1)) / wrapTime, 0f, 1f);
|
||||
if (wrappedTime == 0)
|
||||
evenRed = !evenRed;
|
||||
|
||||
float glowOpacity = MathHelper.Clamp(1 - ((throwTime - 75) / 15f), 0f, 1f);
|
||||
if (StunTime >= 0)
|
||||
glowOpacity = 1 - (StunTime / 30f);
|
||||
if (Time < 15)
|
||||
glowOpacity = Time / 15f;
|
||||
|
||||
Main.spriteBatch.End(out var snapshot);
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
Texture2D ring = TextureAssets.Projectile[Type].Value;
|
||||
|
||||
List<Vector2> points = curve.GetPoints(pCount);
|
||||
for (int i = 1; i < pCount; i++)
|
||||
{
|
||||
float scale1 = MathHelper.Lerp(0.1f, 1f, i / (float)(pCount - 1));
|
||||
float scale2 = MathHelper.Lerp(0.1f, 1f, (i + 1) / (float)(pCount - 1));
|
||||
float scale = MathHelper.Lerp(scale1, scale2, wrappedTime);
|
||||
|
||||
float rot1 = (points[i] - points[i - 1]).ToRotation();
|
||||
|
||||
float rot2;
|
||||
if (i == pCount - 1)
|
||||
rot2 = points[i].ToRotation();
|
||||
else
|
||||
rot2 = (points[i + 1] - points[i]).ToRotation();
|
||||
|
||||
float rot;
|
||||
if (i == pCount - 1)
|
||||
rot = rot1;
|
||||
else
|
||||
rot = rot1.AngleLerp(rot2, wrappedTime);
|
||||
|
||||
Vector2 pos;
|
||||
if (i == pCount - 1)
|
||||
pos = Vector2.Lerp(points[i], points[i] + rot.ToRotationVector2() * Vector2.Distance(points[^1], points[^2]), wrappedTime);
|
||||
else
|
||||
pos = Vector2.Lerp(points[i], points[i + 1], wrappedTime);
|
||||
|
||||
Color color;
|
||||
if (evenRed)
|
||||
color = (i % 2 == 0 ? Color.Red : Color.Magenta) * 0.666f;
|
||||
else
|
||||
color = (i % 2 == 0 ? Color.Magenta : Color.Red) * 0.666f;
|
||||
|
||||
if (i == pCount - 1)
|
||||
color *= 1 - wrappedTime;
|
||||
else if (i == 1)
|
||||
color *= wrappedTime;
|
||||
|
||||
Main.spriteBatch.Draw(ring, pos + Projectile.velocity - Main.screenPosition, null, color * glowOpacity, rot, ring.Size() * 0.5f, new Vector2(0.5f, 1f) * scale, 0, 0);
|
||||
}
|
||||
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(snapshot);
|
||||
|
||||
Vector2[] offsets = [Vector2.UnitX * 2, Vector2.UnitX * -2, Vector2.UnitY * 2, Vector2.UnitY * -2];
|
||||
for (int i = 0; i < 4; i++)
|
||||
Main.EntitySpriteDraw(EnemyGlowTextures[enemyID], Projectile.Center - Main.screenPosition + offsets[i].RotatedBy(Projectile.rotation), frame, Color.Lerp(Color.Red, Color.Magenta, ((float)Math.Sin((Main.GlobalTimeWrappedHourly * 5f)) / 2f + 0.5f)) * glowOpacity, Projectile.rotation, frame.Size() * 0.5f, 1f, 0);
|
||||
}
|
||||
|
||||
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, lightColor * opacity, Projectile.rotation, frame.Size() * 0.5f, 1f, 0);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
using CalamityMod.World;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -56,7 +56,7 @@ namespace CalamityMod.Scenes.MusicScenes
|
||||
return revBrain.SpawnTime != 0 && (revBrain.Time - Math.Abs(revBrain.SpawnTime) < 420);
|
||||
}
|
||||
|
||||
public override int Music => RevBoCSystem.PreviousMusic >= 0 ? RevBoCSystem.PreviousMusic : MusicID.Crimson; //Keeps the music that was playing prior to BoC being spawned
|
||||
public override int Music => BrainOfCthulhuSystem.PreviousMusic >= 0 ? BrainOfCthulhuSystem.PreviousMusic : MusicID.Crimson; //Keeps the music that was playing prior to BoC being spawned
|
||||
|
||||
public override SceneEffectPriority Priority => SceneEffectPriority.BossMedium;
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses;
|
||||
using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
|
||||
Reference in new issue
Block a user