Merge branch '1.4.4' into MegalodonLine

This commit is contained in:
sunny-raindrops committed 2025-06-12 11:18:17 -07:00
commit 6889a28263
254 files changed
+10757 -12356

No files matched your search

+1 -1
View File
@@ -885,7 +885,7 @@ namespace CalamityMod.CalPlayer
contactDamageReduction *= (double)Crumbling.MultiplicativeDamageReductionPlayer;
// Contact damage reduction is reduced by DR Damage, which itself is proportional to defense damage
// In GFB, as defense damage is uncapped, DR damage is also uncapped.
// In FTW, as defense damage is uncapped, DR damage is also uncapped.
int currentDefense = Player.GetCurrentDefense(false);
if (totalDefenseDamage > 0 && currentDefense > 0)
{
+1 -1
View File
@@ -3117,7 +3117,7 @@ namespace CalamityMod.CalPlayer
abyssDeath = false;
// Signus headcrab darkness
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
{
if (CalamityGlobalNPC.signus != -1)
{
+5 -25
View File
@@ -200,7 +200,6 @@ namespace CalamityMod
{ NPCID.Spazmatism, 0.85 },
{ NPCID.Retinazer, 0.85 },
{ ModContent.NPCType<Foveanator>(), 0.85 },
{ ModContent.NPCType<AquaticScourgeHead>(), 1.1 },
{ ModContent.NPCType<AquaticScourgeBody>(), 0.8 },
@@ -214,7 +213,6 @@ namespace CalamityMod
{ ModContent.NPCType<BrimstoneElemental>(), 0.8 },
{ NPCID.SkeletronPrime, 0.85 },
{ ModContent.NPCType<SkeletronPrime2>(), 0.85 },
{ NPCID.PrimeCannon, 0.85 },
{ NPCID.PrimeLaser, 0.85 },
{ NPCID.PrimeSaw, 0.85 },
@@ -261,7 +259,7 @@ namespace CalamityMod
{ ModContent.NPCType<ProfanedGuardianCommander>(), 0.8 },
{ ModContent.NPCType<Bumblefuck>(), 0.8 },
{ ModContent.NPCType<Dragonfolly>(), 0.8 },
{ ModContent.NPCType<StormWeaverBody>(), 0.8 },
{ ModContent.NPCType<StormWeaverTail>(), 0.8 },
@@ -399,12 +397,6 @@ namespace CalamityMod
102, // 153 in phase 2
119, // 178 in phase 2
153 } }, // 229 in phase 2
{ ModContent.NPCType<Foveanator>(), new int[] {
62, // 93 in phase 2
94, // 141 in phase 2
110, // 165 in phase 2
128, // 192 in phase 2
178 } }, // 267 in phase 2
{ ModContent.NPCType<AquaticScourgeHead>(), new int[] { 110, 176, 187, 198, 330 } },
{ ModContent.NPCType<AquaticScourgeBody>(), new int[] { 75, 112, 136, 160, 240 } },
@@ -423,12 +415,6 @@ namespace CalamityMod
102, // 204 while spinning
119, // 238 while spinning
153 } }, // 306 while spinning
{ ModContent.NPCType<SkeletronPrime2>(), new int[] {
50, // 100 while spinning
85, // 170 while spinning
102, // 204 while spinning
119, // 238 while spinning
153 } }, // 306 while spinning
{ NPCID.PrimeVice, new int[] { 70, 102, 136, 170, 255 } },
{ NPCID.PrimeSaw, new int[] { 70, 102, 136, 170, 255 } },
{ NPCID.PrimeCannon, new int[] { 30, 51, 68, 85, 102 } },
@@ -510,8 +496,8 @@ namespace CalamityMod
{ ModContent.NPCType<ProfanedGuardianHealer>(), new int[] { 100, 200, 220, 240, 300 } },
{ ModContent.NPCType<ProfanedRocks>(), new int[] { 100, 200, 220, 232, 300 } },
{ ModContent.NPCType<Bumblefuck>(), new int[] { 170, 256, 288, 320, 504 } },
{ ModContent.NPCType<Bumblefuck2>(), new int[] { 145, 220, 242, 264, 435 } },
{ ModContent.NPCType<Dragonfolly>(), new int[] { 170, 256, 288, 320, 504 } },
{ ModContent.NPCType<DraconicSwarmer>(), new int[] { 145, 220, 242, 264, 435 } },
{ ModContent.NPCType<CeaselessVoid>(), new int[] { 240, 360, 396, 432, 720 } },
{ ModContent.NPCType<DarkEnergy>(), new int[] { 175, 260, 288, 316, 525 } },
@@ -649,9 +635,6 @@ namespace CalamityMod
{ new Tuple<int, int>(NPCID.Spazmatism, ModContent.ProjectileType<CursedFire>()), new int[] { 60, 120, 148, 176, 264 } },
{ new Tuple<int, int>(NPCID.Spazmatism, ModContent.ProjectileType<Shadowflamethrower>()), new int[] { 70, 120, 148, 176, 264 } },
{ new Tuple<int, int>(NPCID.Spazmatism, ModContent.ProjectileType<ShadowflameFireball>()), new int[] { 60, 100, 128, 156, 234 } },
{ new Tuple<int, int>(ModContent.NPCType<Foveanator>(), ModContent.ProjectileType<FoveanatorLaser>()), new int[] { 50, 108, 132, 156, 234 } },
{ new Tuple<int, int>(ModContent.NPCType<Foveanator>(), ModContent.ProjectileType<FoveanatorEnergyBomb>()), new int[] { 70, 120, 148, 176, 264 } },
{ new Tuple<int, int>(ModContent.NPCType<Foveanator>(), ModContent.ProjectileType<FoveanatorFlamethrower>()), new int[] { 70, 120, 148, 176, 264 } },
{ new Tuple<int, int>(ModContent.NPCType<AquaticScourgeHead>(), ModContent.ProjectileType<SulphuricAcidMist>()), new int[] { 60, 100, 120, 140, 210 } },
{ new Tuple<int, int>(ModContent.NPCType<AquaticScourgeHead>(), ModContent.ProjectileType<SandPoisonCloud>()), new int[] { 70, 120, 136, 152, 228 } },
@@ -676,9 +659,6 @@ namespace CalamityMod
{ new Tuple<int, int>(NPCID.SkeletronPrime, ProjectileID.Skull), new int[] { 50, 108, 124, 140, 210 } },
{ new Tuple<int, int>(NPCID.SkeletronPrime, ProjectileID.DeathLaser), new int[] { 50, 108, 124, 140, 210 } },
{ new Tuple<int, int>(NPCID.SkeletronPrime, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 176, 264 } },
{ new Tuple<int, int>(ModContent.NPCType<SkeletronPrime2>(), ProjectileID.Skull), new int[] { 50, 108, 124, 140, 210 } },
{ new Tuple<int, int>(ModContent.NPCType<SkeletronPrime2>(), ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 180, 200, 300 } },
{ new Tuple<int, int>(ModContent.NPCType<SkeletronPrime2>(), ProjectileID.FrostBeam), new int[] { 50, 108, 124, 140, 210 } },
{ new Tuple<int, int>(NPCID.PrimeCannon, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 176, 264 } },
{ new Tuple<int, int>(NPCID.PrimeCannon, ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 0, 0, 300 } },
{ new Tuple<int, int>(NPCID.PrimeLaser, ProjectileID.DeathLaser), new int[] { 50, 108, 124, 140, 210 } },
@@ -769,8 +749,8 @@ namespace CalamityMod
{ new Tuple<int, int>(ModContent.NPCType<ProfanedGuardianHealer>(), ModContent.ProjectileType<HolyBurnOrb>()), new int[] { 120, 192, 220, 248, 360 } },
{ new Tuple<int, int>(ModContent.NPCType<ProfanedGuardianHealer>(), ModContent.ProjectileType<HolyLight>()), new int[] { 35, 50, 50, 0, 0 } },
{ new Tuple<int, int>(ModContent.NPCType<Bumblefuck>(), ModContent.ProjectileType<RedLightningFeather>()), new int[] { 140, 220, 244, 268, 420 } },
{ new Tuple<int, int>(ModContent.NPCType<Bumblefuck>(), ModContent.ProjectileType<BirbAuraFlare>()), new int[] { 200, 300, 332, 364, 600 } },
{ new Tuple<int, int>(ModContent.NPCType<Dragonfolly>(), ModContent.ProjectileType<RedLightningFeather>()), new int[] { 140, 220, 244, 268, 420 } },
{ new Tuple<int, int>(ModContent.NPCType<Dragonfolly>(), ModContent.ProjectileType<BirbAuraFlare>()), new int[] { 200, 300, 332, 364, 600 } },
{ new Tuple<int, int>(ModContent.NPCType<Providence>(), ModContent.ProjectileType<HolyBlast>()), new int[] { 150, 264, 288, 312, 450 } }, // Split holy fire does: 113, 198, 216, 234, 338
{ new Tuple<int, int>(ModContent.NPCType<Providence>(), ModContent.ProjectileType<HolyFire>()), new int[] { 120, 192, 220, 248, 360 } },
+3 -4
View File
@@ -213,8 +213,7 @@ namespace CalamityMod.Events
{
NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, NPCID.Spazmatism);
NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, NPCID.Retinazer);
NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, ModContent.NPCType<Foveanator>());
}, permittedNPCs: new int[] { NPCID.Retinazer, ModContent.NPCType<Foveanator>() }),
}, permittedNPCs: new int[] { NPCID.Retinazer }),
new Boss(ModContent.NPCType<AquaticScourgeHead>(), TimeChangeContext.Day, permittedNPCs: new int[] { ModContent.NPCType<AquaticScourgeBody>(), ModContent.NPCType<AquaticScourgeBodyAlt>(), ModContent.NPCType<AquaticScourgeTail>() }),
@@ -222,7 +221,7 @@ namespace CalamityMod.Events
new Boss(ModContent.NPCType<BrimstoneElemental>(), TimeChangeContext.Day, permittedNPCs: ModContent.NPCType<Brimling>()),
new Boss(NPCID.SkeletronPrime, TimeChangeContext.Night, permittedNPCs: new int[] { ModContent.NPCType<SkeletronPrime2>(), NPCID.PrimeCannon, NPCID.PrimeSaw, NPCID.PrimeVice, NPCID.PrimeLaser, NPCID.Probe }),
new Boss(NPCID.SkeletronPrime, TimeChangeContext.Night, permittedNPCs: new int[] { NPCID.PrimeCannon, NPCID.PrimeSaw, NPCID.PrimeVice, NPCID.PrimeLaser }),
new Boss(ModContent.NPCType<CalamitasClone>(), TimeChangeContext.Night, permittedNPCs: new int[] { ModContent.NPCType<Cataclysm>(), ModContent.NPCType<Catastrophe>(),
ModContent.NPCType<SoulSeeker>() }),
@@ -309,7 +308,7 @@ namespace CalamityMod.Events
NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, type);
}, permittedNPCs: new int[] { ModContent.NPCType<ProfanedGuardianDefender>(), ModContent.NPCType<ProfanedGuardianHealer>(), ModContent.NPCType<ProfanedRocks>() }),
new Boss(ModContent.NPCType<Bumblefuck>(), permittedNPCs: new int[] { ModContent.NPCType<Bumblefuck2>() }),
new Boss(ModContent.NPCType<Dragonfolly>(), permittedNPCs: new int[] { ModContent.NPCType<DraconicSwarmer>() }),
new Boss(ModContent.NPCType<Providence>(), TimeChangeContext.Day, type =>
{
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 B

-17
View File
@@ -20,10 +20,6 @@ namespace CalamityMod.ExtraTextures
public static Asset<Texture2D> DestroyerBodyGlowmask;
public static Asset<Texture2D> DestroyerTailGlowmask;
// Master Rev+ Skeletron Prime
public static Asset<Texture2D> ChadPrime;
public static Asset<Texture2D> ChadPrimeEyeGlowmask;
// WoF, These are not "exactly" the ExtraTextures. But
public static Asset<Texture2D> WallOfFleshEyeGlowmask;
public static Asset<Texture2D> WallOfFleshDemonSickleTexture;
@@ -43,16 +39,6 @@ namespace CalamityMod.ExtraTextures
public static Asset<Texture2D> CircularSmearFire2;
public static Asset<Texture2D> CircularSmearFire3;
// Boss Heads
// I know it's not exactly a Texture2D but it belongs to ExtraTextures.
public static int BossHeadIndex_ChadPrime;
public override void Load()
{
string chadPrimeIconPath = "CalamityMod/ExtraTextures/ChadPrime_Head_Boss";
BossHeadIndex_ChadPrime = CalamityMod.Instance.AddBossHeadTexture(chadPrimeIconPath, -1);
}
// TODO: - Every other ExtraTextures Reference could be move in here
public override void OnModLoad()
@@ -61,9 +47,6 @@ namespace CalamityMod.ExtraTextures
DestroyerBodyGlowmask = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/VanillaBossGlowmasks/DestroyerBodyGlow", AssetRequestMode.AsyncLoad);
DestroyerTailGlowmask = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/VanillaBossGlowmasks/DestroyerTailGlow", AssetRequestMode.AsyncLoad);
ChadPrime = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/ChadPrime", AssetRequestMode.AsyncLoad);
ChadPrimeEyeGlowmask = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/ChadPrimeHeadGlow", AssetRequestMode.AsyncLoad);
WallOfFleshEyeGlowmask = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/VanillaBossGlowmasks/WallOfFleshEyeTelegraphGlow", AssetRequestMode.AsyncLoad);
WallOfFleshDemonSickleTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Melee/ForbiddenOathbladeProjectile", AssetRequestMode.AsyncLoad);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B

+16 -77
View File
@@ -241,18 +241,7 @@ namespace CalamityMod.ILEditing
}
cursor.Next.Operand = BalancingConstants.SoaringInsigniaRunAccelerationMultiplier;
// Second: Magiluminescence. Find the check for whether it's equipped for run speeds.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Player>("hasMagiluminescence")))
{
LogFailure("Run Acceleration Nerfs", "Could not locate the Magiluminescence bool.");
return;
}
//
// Don't actually do anything. Magiluminescence is not intended to be nerfed by Calamity.
//
// Third: Shadow Armor. Find the check for whether it's equipped for run speeds.
// Second: Shadow Armor. Find the check for whether it's equipped for run speeds.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Player>("shadowArmor")))
{
LogFailure("Run Acceleration Nerfs", "Could not locate the Shadow Armor bool.");
@@ -396,75 +385,27 @@ namespace CalamityMod.ILEditing
private static void PrefixChanges(On_Player.orig_GrantPrefixBenefits orig, Player self, Item item)
{
orig(self, item);
// Defense accessory prefixes have slightly scaling defense boosts through progression
if (item.prefix >= PrefixID.Hard && item.prefix <= PrefixID.Warding)
{
if (DownedBossSystem.downedDoG)
self.statDefense += 3;
else if (NPC.downedMoonlord)
self.statDefense += 2;
else if (Main.hardMode)
self.statDefense += 1;
}
// Hard / Guarding / Armored / Warding give 0.25% / 0.5% / 0.75% / 1% DR
if (item.prefix == PrefixID.Hard)
{
/* Prehardmode = 1
* Hardmode = 2
* Post-Moon Lord = 3
* Post-DoG = 4
*/
if (DownedBossSystem.downedDoG)
self.statDefense += 3;
else if (NPC.downedMoonlord)
self.statDefense += 2;
else if (Main.hardMode)
self.statDefense += 1;
self.endurance += 0.0025f;
}
if (item.prefix == PrefixID.Guarding)
{
/* Prehardmode = 2
* Hardmode = 3
* Post-Moon Lord = 4
* Post-DoG = 5
*/
if (DownedBossSystem.downedDoG)
self.statDefense += 3;
else if (NPC.downedMoonlord)
self.statDefense += 2;
else if (Main.hardMode)
self.statDefense += 1;
self.endurance += 0.005f;
}
if (item.prefix == PrefixID.Armored)
{
/* Prehardmode = 3
* Hardmode = 4
* Post-Moon Lord = 5
* Post-DoG = 6
*/
if (DownedBossSystem.downedDoG)
self.statDefense += 3;
else if (NPC.downedMoonlord)
self.statDefense += 2;
else if (Main.hardMode)
self.statDefense += 1;
self.endurance += 0.0075f;
}
if (item.prefix == PrefixID.Warding)
{
/* Prehardmode = 4
* Hardmode = 5
* Post-Moon Lord = 6
* Post-DoG = 7
*/
if (DownedBossSystem.downedDoG)
self.statDefense += 3;
else if (NPC.downedMoonlord)
self.statDefense += 2;
else if (Main.hardMode)
self.statDefense += 1;
self.endurance += 0.01f;
}
// Lucky prefix increases luck
if (item.prefix == PrefixID.Lucky)
self.Calamity().calamityBonusLuck += 0.05f;
}
@@ -501,7 +442,7 @@ namespace CalamityMod.ILEditing
private static void VanillaBossResistChanges(ILContext il)
{
// This IL edit accomplishes two things:
// 1. Reduces Expert+ Eater of Worlds' resist to explosives from 80% to 60%.
// 1. Reduces Expert+ Eater of Worlds' resist to explosives from 80% to 66%.
// 2. Effectively removes Lunatic Cultist's resistance to homing projectiles.
var cursor = new ILCursor(il);
@@ -514,17 +455,15 @@ namespace CalamityMod.ILEditing
return;
}
}
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchDiv()))
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdcR4(5f)))
{
LogFailure("Reduce EoW Grenade Resist", "Could not move to the resist factor.");
return;
}
// Remove the division instruction, then pop the 5 off the stack to destroy it. Replace it with loading a 0.4 and then multiplying by it.
cursor.Remove();
// Pop the 5 off the stack, and replace it with a 3.
cursor.EmitPop();
cursor.EmitLdcR4(0.4f);
cursor.EmitMul();
cursor.EmitLdcR4(3f);
// Now, move to the Cultist resist which is right below it.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdsfld(typeof(ProjectileID.Sets), "CultistIsResistantTo")))
+1 -3
View File
@@ -91,9 +91,6 @@ namespace CalamityMod.ILEditing
On_AWorldListItem.GetDifficulty += GetDifficultyOverride;
On_Item.GetShimmered += ShimmerEffectEdits;
On_Player.Teleport += TPOverride;
On_NPC.SpawnBoss += TripletsSpawnTextOverride;
On_NPC.DoDeathEvents_BeforeLoot += PreventFoveanatorDefeatMessageIfNotKilledLast;
On_NPC.DoDeathEvents_CelebrateBossDeath += TripletsDefeatTextOverride;
On_TileDrawing.DrawSingleTile += GlowMaskTileRender;
On_Main.DoUpdate_HandleChat += SpawnPunchCard;
On_Player.PlaceThing_CannonBall += AllowCannonJellyfishUse;
@@ -192,6 +189,7 @@ namespace CalamityMod.ILEditing
// Removal of vanilla stupidity
IL_Player.StatusFromNPC += RemoveExpertBrainRandomDebuffs;
IL_NPC.StrikeNPC_HitInfo_bool_bool += LetDetonatingBubblesTakeDamage;
IL_Player.ItemCheck_EmitUseVisuals += MakeMagmaStoneFireGauntletDustToggleable;
IL_Projectile.EmitEnchantmentVisualsAt += MakeMagmaStoneFireGauntletProjectileDustToggleable;
IL_Sandstorm.HasSufficientWind += DecreaseSandstormWindSpeedRequirement;
+27 -88
View File
@@ -79,7 +79,7 @@ namespace CalamityMod.ILEditing
//private static readonly MethodInfo textureGetValueMethod = typeof(Asset<Texture2D>).GetMethod("get_Value", BindingFlags.Public | BindingFlags.Instance);
#region Punch Card Spawning Command
private static void SpawnPunchCard(Terraria.On_Main.orig_DoUpdate_HandleChat orig)
private static void SpawnPunchCard(On_Main.orig_DoUpdate_HandleChat orig)
{
// Any of these conditions should result in normal behaviour
if (!Main.drawingPlayerChat || Main.CurrentInputTextTakerOverride != null || Main.editSign || PlayerInput.UsingGamepad)
@@ -282,7 +282,7 @@ namespace CalamityMod.ILEditing
cursor.Emit(OpCodes.Ldc_I4, 10 - BalancingConstants.ShieldOfCthulhuBonkNoCollideFrames);
}
private static void ApplyDashKeybind(Terraria.On_Player.orig_DoCommonDashHandle orig, Player self, out int dir, out bool dashing, Player.DashStartAction dashStartAction)
private static void ApplyDashKeybind(On_Player.orig_DoCommonDashHandle orig, Player self, out int dir, out bool dashing, Player.DashStartAction dashStartAction)
{
// we feasting multiplayer bugs
if (self.whoAmI != Main.myPlayer)
@@ -334,7 +334,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Allow Empress to Enrage in Boss Rush
private static bool AllowEmpressToEnrageInBossRush(Terraria.On_NPC.orig_ShouldEmpressBeEnraged orig)
private static bool AllowEmpressToEnrageInBossRush(On_NPC.orig_ShouldEmpressBeEnraged orig)
{
if (BossRushEvent.BossRushActive)
return true;
@@ -356,11 +356,11 @@ namespace CalamityMod.ILEditing
orig(self, closestPlayer);
}
#endregion Prevent Vanilla Bosses From Being Marked as Defeated in Boss Rush
#endregion
#region Enabling of Triggered NPC Platform Fallthrough
// Why this isn't a mechanism provided by TML itself or vanilla itself is beyond me.
private static void AllowTriggeredFallthrough(Terraria.On_NPC.orig_ApplyTileCollision orig, NPC self, bool fall, Vector2 cPosition, int cWidth, int cHeight)
private static void AllowTriggeredFallthrough(On_NPC.orig_ApplyTileCollision orig, NPC self, bool fall, Vector2 cPosition, int cWidth, int cHeight)
{
if (self.active && self.type == ModContent.NPCType<FusionFeeder>())
{
@@ -398,7 +398,7 @@ namespace CalamityMod.ILEditing
cursor.Emit(OpCodes.Ret);
}
private static void AlterTownNPCSpawnRate(Terraria.On_Main.orig_UpdateTime_SpawnTownNPCs orig)
private static void AlterTownNPCSpawnRate(On_Main.orig_UpdateTime_SpawnTownNPCs orig)
{
double oldWorldRate = Main.desiredWorldTilesUpdateRate;
Main.desiredWorldTilesUpdateRate *= CalamityServerConfig.Instance.TownNPCSpawnRateMultiplier;
@@ -483,7 +483,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Custom Gate Door Logic
private static bool OpenDoor_LabDoorOverride(Terraria.On_WorldGen.orig_OpenDoor orig, int i, int j, int direction)
private static bool OpenDoor_LabDoorOverride(On_WorldGen.orig_OpenDoor orig, int i, int j, int direction)
{
Tile tile = Main.tile[i, j];
@@ -499,7 +499,7 @@ namespace CalamityMod.ILEditing
return orig(i, j, direction);
}
private static bool CloseDoor_LabDoorOverride(Terraria.On_WorldGen.orig_CloseDoor orig, int i, int j, bool forced)
private static bool CloseDoor_LabDoorOverride(On_WorldGen.orig_CloseDoor orig, int i, int j, bool forced)
{
Tile tile = Main.tile[i, j];
@@ -517,7 +517,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Platform Collision Checks for Grounded Bosses
private static bool EnableCalamityBossPlatformCollision(Terraria.On_NPC.orig_Collision_DecideFallThroughPlatforms orig, NPC self)
private static bool EnableCalamityBossPlatformCollision(On_NPC.orig_Collision_DecideFallThroughPlatforms orig, NPC self)
{
if ((self.type == ModContent.NPCType<AstrumAureus>() || self.type == ModContent.NPCType<Crabulon>() || self.type == ModContent.NPCType<RavagerBody>() ||
self.type == ModContent.NPCType<RockPillar>() || self.type == ModContent.NPCType<FlamePillar>()) &&
@@ -529,7 +529,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Incorporate Enchantments in Item Names
private static string IncorporateEnchantmentInAffix(Terraria.On_Item.orig_AffixName orig, Item self)
private static string IncorporateEnchantmentInAffix(On_Item.orig_AffixName orig, Item self)
{
string result = orig(self);
@@ -545,7 +545,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Apply Projectile Variables Upon Creation
private static int IncorporateExtraProjectileVariables(Terraria.On_Projectile.orig_NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float_float orig, IEntitySource spawnSource, float x, float y, float xSpeed, float ySpeed, int type, int damage, float knockback, int owner, float ai0, float ai1, float ai2)
private static int IncorporateExtraProjectileVariables(On_Projectile.orig_NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float_float orig, IEntitySource spawnSource, float x, float y, float xSpeed, float ySpeed, int type, int damage, float knockback, int owner, float ai0, float ai1, float ai2)
{
// This is unfortunately not something that can be done via SetDefaults since owner is set
// after that method is called. Doing it directly when the projectile is spawned appears to be the only reasonable way.
@@ -613,7 +613,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Apply Old Fashioned Damage to Miscellanous Hits
private static void ApplyOldFashionedDamageToMiscHits(Terraria.On_Player.orig_ApplyDamageToNPC orig, Player self, NPC npc, int damage, float knockback, int direction, bool crit = false, DamageClass? damageType = null, bool damageVariation = false)
private static void ApplyOldFashionedDamageToMiscHits(On_Player.orig_ApplyDamageToNPC orig, Player self, NPC npc, int damage, float knockback, int direction, bool crit = false, DamageClass? damageType = null, bool damageVariation = false)
{
if (self.Calamity().oldFashioned)
damage = (int)(damage * OldFashioned.DamageBoostMultiplier);
@@ -699,7 +699,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Fire Cursor Effect for the Calamity Accessory
private static void UseCoolFireCursorEffect(Terraria.On_Main.orig_DrawCursor orig, Vector2 bonus, bool smart)
private static void UseCoolFireCursorEffect(On_Main.orig_DrawCursor orig, Vector2 bonus, bool smart)
{
Player player = Main.LocalPlayer;
@@ -911,7 +911,7 @@ namespace CalamityMod.ILEditing
#endregion
#region General Particle Rendering
private static void DrawFusableParticles(Terraria.On_Main.orig_SortDrawCacheWorms orig, Main self)
private static void DrawFusableParticles(On_Main.orig_SortDrawCacheWorms orig, Main self)
{
DeathAshParticle.DrawAll();
@@ -921,7 +921,7 @@ namespace CalamityMod.ILEditing
orig(self);
}
private static void DrawForegroundParticles(Terraria.On_Main.orig_DrawInfernoRings orig, Main self)
private static void DrawForegroundParticles(On_Main.orig_DrawInfernoRings orig, Main self)
{
GeneralParticleHandler.DrawAllParticles(Main.spriteBatch);
orig(self);
@@ -1624,7 +1624,7 @@ namespace CalamityMod.ILEditing
/// <summary>
/// Determines if the custom grapple movement should take place or not. Useful for hooks that only do movement tricks in some cases
/// </summary>
private static void CustomGrappleMovementCheck(Terraria.On_Player.orig_GrappleMovement orig, Player self)
private static void CustomGrappleMovementCheck(On_Player.orig_GrappleMovement orig, Player self)
{
WulfrumPackPlayer mp = self.GetModPlayer<WulfrumPackPlayer>();
@@ -1637,7 +1637,7 @@ namespace CalamityMod.ILEditing
/// <summary>
/// This is called right before the game decides wether or not to update the players velocity based on "real" physics (aka not tongued or hooked or with a pulley)
/// </summary>
private static void CustomGrapplePreDefaultMovement(Terraria.On_Player.orig_UpdatePettingAnimal orig, Player self)
private static void CustomGrapplePreDefaultMovement(On_Player.orig_UpdatePettingAnimal orig, Player self)
{
orig(self);
@@ -1661,7 +1661,7 @@ namespace CalamityMod.ILEditing
/// Used before the player steps up a half tile. If we don't do that, players that are grappled but don't use hook movement won't be able to go over tiles.
/// The hook cache is reset in PreUpdateMovement
/// </summary>
private static void CustomGrapplePreStepUp(Terraria.On_Player.orig_SlopeDownMovement orig, Player self)
private static void CustomGrapplePreStepUp(On_Player.orig_SlopeDownMovement orig, Player self)
{
orig(self);
@@ -1675,9 +1675,9 @@ namespace CalamityMod.ILEditing
}
/// <summary>
/// This is done to put the hook if it was cacehd during the frame instruction.
/// This is done to put the hook if it was cached during the frame instruction.
/// </summary>
private static void CustomGrapplePostFrame(Terraria.On_Player.orig_PlayerFrame orig, Player self)
private static void CustomGrapplePostFrame(On_Player.orig_PlayerFrame orig, Player self)
{
orig(self);
WulfrumPackPlayer mp = self.GetModPlayer<WulfrumPackPlayer>();
@@ -1694,7 +1694,7 @@ namespace CalamityMod.ILEditing
#region Find Calamity Item Dye Shader
internal static void FindCalamityItemDyeShader(Terraria.On_Player.orig_UpdateItemDye orig, Player self, bool isNotInVanitySlot, bool isSetToHidden, Item armorItem, Item dyeItem)
internal static void FindCalamityItemDyeShader(On_Player.orig_UpdateItemDye orig, Player self, bool isNotInVanitySlot, bool isSetToHidden, Item armorItem, Item dyeItem)
{
orig(self, isNotInVanitySlot, isSetToHidden, armorItem, dyeItem);
if (armorItem.type == ModContent.ItemType<Calamity>())
@@ -1727,7 +1727,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Custom world selection difficulties
internal static void GetDifficultyOverride(Terraria.GameContent.UI.Elements.On_AWorldListItem.orig_GetDifficulty orig, AWorldListItem self, out string expertText, out Color gameModeColor)
internal static void GetDifficultyOverride(On_AWorldListItem.orig_GetDifficulty orig, AWorldListItem self, out string expertText, out Color gameModeColor)
{
// Run the original code and pull out the original text and text color
orig(self, out expertText, out gameModeColor);
@@ -1762,7 +1762,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Shimmer effect edits
public static void ShimmerEffectEdits(Terraria.On_Item.orig_GetShimmered orig, Item self)
public static void ShimmerEffectEdits(On_Item.orig_GetShimmered orig, Item self)
{
// Make Plagued Containment Bricks turn into Plagued Nanodroids if shimmered before defeating Golem
if (self.type == ModContent.ItemType<PlaguedContainmentBrick>())
@@ -1805,7 +1805,7 @@ namespace CalamityMod.ILEditing
#region Block Abyss from Teleportation Potions
public static void TPOverride(Terraria.On_Player.orig_Teleport orig, Player self, Vector2 newPos, int Style = 0, int extraInfo = 0)
public static void TPOverride(On_Player.orig_Teleport orig, Player self, Vector2 newPos, int Style = 0, int extraInfo = 0)
{
// Grab the tile from where the potion wants to teleport
Tile t = CalamityUtils.ParanoidTileRetrieval(newPos.ToTileCoordinates().X, newPos.ToTileCoordinates().Y);
@@ -1849,67 +1849,6 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Revengeance Master Mode Twins Shenanigans
public static void TripletsSpawnTextOverride(Terraria.On_NPC.orig_SpawnBoss orig, int x, int y, int type, int targetPlayerIndex)
{
if (CalamityWorld.death && type == NPCID.Retinazer)
{
int retinazerIndex = NPC.NewNPC(NPC.GetBossSpawnSource(targetPlayerIndex), x, y, type, 1);
if (retinazerIndex == 200)
{
return;
}
Main.npc[retinazerIndex].target = targetPlayerIndex;
Main.npc[retinazerIndex].timeLeft *= 20;
if (Main.dedServ && retinazerIndex < 200)
{
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, retinazerIndex);
}
AchievementsHelper.CheckMechaMayhem();
CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.TripletsBossText", new Color(175, 75, 255));
return;
}
else
{
orig(x, y, type, targetPlayerIndex);
}
}
public static void PreventFoveanatorDefeatMessageIfNotKilledLast(On_NPC.orig_DoDeathEvents_BeforeLoot orig, NPC self, Player closestPlayer)
{
if (CalamityWorld.death && self.type == ModContent.NPCType<Foveanator>() && (NPC.AnyNPCs(NPCID.Spazmatism) || NPC.AnyNPCs(NPCID.Retinazer)))
{
self.value = 0f;
self.boss = false;
return;
}
else
{
orig(self, closestPlayer);
}
}
public static void TripletsDefeatTextOverride(On_NPC.orig_DoDeathEvents_CelebrateBossDeath orig, NPC self, string typeName)
{
bool correctNPCType = self.type == NPCID.Retinazer || self.type == NPCID.Spazmatism || self.type == ModContent.NPCType<Foveanator>();
if (CalamityWorld.death && correctNPCType)
{
if (Main.netMode == NetmodeID.SinglePlayer)
Main.NewText(Language.GetTextValue("Announcement.HasBeenDefeated_Plural", CalamityUtils.GetTextValue("Status.Boss.TripletsDefeatName")), 175, 75, 255);
else if (Main.dedServ)
ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasBeenDefeated_Plural", NetworkText.FromKey("Mods.CalamityMod.Status.Boss.TripletsDefeatName")), new Color(175, 75, 255));
return;
}
else
{
orig(self, typeName);
}
}
#endregion
#region Optimized GlowMask Rendering on Tile
private static void GlowMaskTileRender(On_TileDrawing.orig_DrawSingleTile orig, TileDrawing self, TileDrawInfo drawData, bool solidLayer, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY)
{
@@ -1974,7 +1913,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Allow Cannons to use jellyfish
public static void AllowCannonJellyfishUse(Terraria.On_Player.orig_PlaceThing_CannonBall orig, Player self)
public static void AllowCannonJellyfishUse(On_Player.orig_PlaceThing_CannonBall orig, Player self)
{
// Check if the player is holding a jelly
if (self.HeldItem.type == ModContent.ItemType<BabyCannonballJellyfishItem>())
@@ -2085,7 +2024,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Add Stohne to the Jungle
public static void AddStohne(Terraria.GameContent.Biomes.On_JunglePass.orig_GenerateFinishingTouches orig, JunglePass self, GenerationProgress progress, int oldX, int oldY)
public static void AddStohne(On_JunglePass.orig_GenerateFinishingTouches orig, JunglePass self, GenerationProgress progress, int oldX, int oldY)
{
int anchorX = oldX;
int anchorY = oldY;
@@ -2629,7 +2568,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Make Celestial Onion give the Master Mode slot
public static bool MasterModeCelestialOnionCheck(Terraria.On_Player.orig_IsItemSlotUnlockedAndUsable orig, Player self, int slot)
public static bool MasterModeCelestialOnionCheck(On_Player.orig_IsItemSlotUnlockedAndUsable orig, Player self, int slot)
{
if ((slot == 9 || slot == 19) && self.Calamity().extraAccessoryML && !Main.gameMenu)
{
+49 -15
View File
@@ -9,6 +9,7 @@ using CalamityMod.NPCs.AcidRain;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.NPCs.TownNPCs;
using CalamityMod.Walls;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Mono.Cecil.Cil;
using MonoMod.Cil;
@@ -17,7 +18,7 @@ using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.GameContent.Drawing;
using Terraria.GameContent.Personalities;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Graphics.Effects;
@@ -153,7 +154,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Prevention of Slime Rain Spawns When Near Bosses
private static void PreventBossSlimeRainSpawns(Terraria.On_NPC.orig_SlimeRainSpawns orig, int plr)
private static void PreventBossSlimeRainSpawns(On_NPC.orig_SlimeRainSpawns orig, int plr)
{
if (!Main.player[plr].Calamity().isNearbyBoss && CalamityServerConfig.Instance.BossZen)
orig(plr);
@@ -174,12 +175,47 @@ namespace CalamityMod.ILEditing
}
// Remove the Expert Mode check, and in its place put a check for the Zenith seed (Get fixed boi).
// Note from CIT: I originally removed these entirely;
cursor.Emit(OpCodes.Pop);
cursor.Emit(OpCodes.Ldsfld, typeof(Main).GetField("zenithWorld"));
}
#endregion
#region Disable Detonating Bubble StrikeNPC Hardcoded Override
private static void LetDetonatingBubblesTakeDamage(ILContext il)
{
// In vanilla's StrikeNPC function, Detonating Bubbles have a hardcoded type check which sets the damage of the strike to 0.
// This IL edit disables that type check in Death Mode.
var cursor = new ILCursor(il);
// Go to the point after the check for the Detonating Bubble NPC ID.
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdcR8(0.0)))
{
LogFailure("Let Detonating Bubbles Take Damage in Death", "Could not move after the NPC type check.");
return;
}
// Define the label.
var label = il.DefineLabel();
// Add a branch if it is Death Mode.
cursor.Emit(OpCodes.Ldsfld, typeof(CalamityWorld).GetField("death"));
cursor.Emit(OpCodes.Brtrue, label);
// Move to the point after Detonating Bubble changes are implemented to place the branch label.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStfld<NPC>("dontTakeDamage")))
{
LogFailure("Let Detonating Bubbles Take Damage in Death", "Could not move to after the Detonating Bubble logic.");
return;
}
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdarg0()))
{
LogFailure("Let Detonating Bubbles Take Damage in Death", "Could not move to after the Detonating Bubble logic.");
return;
}
cursor.MarkLabel(label);
}
#endregion
#region Make Meteorite Explodable
private static void MakeMeteoriteExplodable(ILContext il)
{
@@ -271,13 +307,15 @@ namespace CalamityMod.ILEditing
LogFailure("Prevent Fossil Shattering", "Could not locate the Desert Fossil Tile ID variable.");
return;
}
// Remove this value and replace it with a large number that will never be a valid tile ID.
cursor.Remove();
cursor.Emit(OpCodes.Ldc_I4, TileID.PixelBox); // Change to Pixel Box because it cannot be obtained in-game without cheating.
cursor.Emit(OpCodes.Ldc_I4, 40000);
}
#endregion
#region Remove Hellforge Pickaxe Requirement
private static int RemoveHellforgePickaxeRequirement(Terraria.On_Player.orig_GetPickaxeDamage orig, Player self, int x, int y, int pickPower, int hitBufferIndex, Tile tileTarget)
private static int RemoveHellforgePickaxeRequirement(On_Player.orig_GetPickaxeDamage orig, Player self, int x, int y, int pickPower, int hitBufferIndex, Tile tileTarget)
{
if (tileTarget.TileType == TileID.Hellforge)
pickPower = 65;
@@ -295,10 +333,6 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Fix Chlorophyte Crystal Attacking Where it Shouldn't
// TODO -- Finish this
#endregion Fix Chlorophyte Crystal Attacking Where it Shouldn't
#region Prevent UFO Mount from Dismounting in Water
private static void PreventUFODismountInWater(ILContext il)
{
@@ -331,7 +365,7 @@ namespace CalamityMod.ILEditing
#endregion Prevent UFO Mount from Dismounting in Water
#region Color Blighted Gel
private static void ColorBlightedGel(Terraria.GameContent.ItemDropRules.On_CommonCode.orig_ModifyItemDropFromNPC orig, NPC npc, int itemIndex)
private static void ColorBlightedGel(On_CommonCode.orig_ModifyItemDropFromNPC orig, NPC npc, int itemIndex)
{
orig(npc, itemIndex);
@@ -357,7 +391,7 @@ namespace CalamityMod.ILEditing
#endregion Color Blighted Gel
#region Improve Angler Quest Rewards
private static void ImproveAnglerRewards(Terraria.On_Player.orig_GetAnglerReward orig, Player self, NPC angler, int questItemType)
private static void ImproveAnglerRewards(On_Player.orig_GetAnglerReward orig, Player self, NPC angler, int questItemType)
{
orig(self, angler, questItemType);
@@ -1046,7 +1080,7 @@ namespace CalamityMod.ILEditing
var cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Player>("magmaStone"))) // Flag for if Magma Stone is equipped. Fire Gauntlet also uses this.
{
LogFailure("Make Magma Stone & Fire Gauntlet Dust Toggleable", "Could not locate the magma stone variable.");
LogFailure("Make Magma Stone & Fire Gauntlet Dust Toggleable", "Could not locate the Magma Stone variable.");
return;
}
// Load the player itself onto the stack so that it becomes an argument for the following delegate.
@@ -1091,7 +1125,7 @@ namespace CalamityMod.ILEditing
}
// Remove the instruction and replace with 1 (true). This effectively removes the requirement for defeating Plantera.
// The only requirements for summoning Golems with Power Cells are now: 1) Golem is not alive, and 2) The world is in Hardmode.
// The only requirements for summoning Golem with Power Cells are now: 1) Golem is not alive, and 2) The world is in Hardmode.
cursor.EmitPop();
cursor.Emit(OpCodes.Ldc_I4_1);
}
@@ -1144,7 +1178,7 @@ namespace CalamityMod.ILEditing
return;
}
// branch is used for exit condition. So setting ble.s opcode to nop will remove the condition
// Branch is used for exit condition. So setting ble.s opcode to nop will remove the condition
cursor.Prev.OpCode = OpCodes.Nop;
// After that we pop NPC.damage and 0 from stack
@@ -1188,7 +1222,7 @@ namespace CalamityMod.ILEditing
}*/
#endregion
#region Allow disabling gravity swap visual && allow gravity keybind
#region Allow Disabling Gravity Swap Visual and Allow Gravity Keybind
private static void DelayGravity(On_Player.orig_UpdateControlHolds orig, Player Player)
{
var cplay = Player.Calamity();
+4 -7
View File
@@ -8,6 +8,7 @@ using MonoMod.Cil;
using Terraria;
using Terraria.GameContent.UI.States;
using Terraria.ID;
using Terraria.IO;
using Terraria.WorldBuilding;
namespace CalamityMod.ILEditing
@@ -66,7 +67,7 @@ namespace CalamityMod.ILEditing
#endregion Fixing of Living Tree/Sulphurous Sea Interactions
#region Removal of Hardmode Ore Generation from Evil Altars
private static void PreventSmashAltarCode(Terraria.On_WorldGen.orig_SmashAltar orig, int i, int j)
private static void PreventSmashAltarCode(On_WorldGen.orig_SmashAltar orig, int i, int j)
{
if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework)
return;
@@ -135,10 +136,8 @@ namespace CalamityMod.ILEditing
return;
}
// Pop original value off.
// Pop original value off. Push '2' to the stack.
c.Emit(OpCodes.Pop);
// Push '2' to the stack.
c.Emit(OpCodes.Ldc_I4_2);
// OBJECTIVE 2
@@ -181,13 +180,11 @@ namespace CalamityMod.ILEditing
// Emit our new string "Mods.CalamityMod.UI.SmallWorldWarning".
c.Emit(OpCodes.Ldstr, "Mods.CalamityMod.UI.SmallWorldWarning");
}
#endregion
#region Clear temporary modded tiles
private static void ClearModdedTempTiles(Terraria.IO.On_WorldFile.orig_ClearTempTiles orig)
private static void ClearModdedTempTiles(On_WorldFile.orig_ClearTempTiles orig)
{
orig();
+3 -1
View File
@@ -73,8 +73,10 @@ namespace CalamityMod.Items.Accessories
continue;
// Inflict Riptide on empowered parries.
//Doze - I gave all parry accessories long debuff infliction times due to the lack of weapons that inflict debuffs for a decent time, and the scarcity of using the parry
//Most common vanilla debuffs have a way to inflict them for 15, 20, or even 30 seconds
if (empowered)
npc.AddBuff(ModContent.BuffType<RiptideDebuff>(), 300);
npc.AddBuff(ModContent.BuffType<RiptideDebuff>(), CalamityUtils.SecondsToFrames(15));
// If the NPC can be moved, violently shove them away. Make them susceptible to fall damage on empowered parries.
// Otherwise, simply deal a large amount of damage to them if empowered.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 3.1 KiB

@@ -64,7 +64,7 @@ namespace CalamityMod.Items.DraedonMisc
rangedDisplay.OverrideColor = new Color(149, 243, 43);
list.Insert(insertIndex + 2, rangedDisplay);
int mageItem = ModContent.ItemType<GaussPistol>();
int mageItem = ModContent.ItemType<Vulcan>();
TooltipLine mageDisplay = new TooltipLine(this.Mod, "CalamityMod:MageDisplay", $"[i:{mageItem}] {CalamityUtils.GetItemName(mageItem)}");
mageDisplay.OverrideColor = new Color(236, 255, 31);
list.Insert(insertIndex + 3, mageDisplay);
+2 -2
View File
@@ -34,12 +34,12 @@ namespace CalamityMod.Items.SummonItems
public override bool CanUseItem(Player player)
{
return player.ZoneJungle && !NPC.AnyNPCs(ModContent.NPCType<Bumblefuck>()) && !BossRushEvent.BossRushActive;
return player.ZoneJungle && !NPC.AnyNPCs(ModContent.NPCType<Dragonfolly>()) && !BossRushEvent.BossRushActive;
}
public override bool? UseItem(Player player)
{
CalamityUtils.SpawnBossUsingItem<Bumblefuck>(player, SoundID.Roar);
CalamityUtils.SpawnBossUsingItem<Dragonfolly>(player, SoundID.Roar);
return true;
}
+1 -1
View File
@@ -57,7 +57,7 @@ namespace CalamityMod.Items.TreasureBags
public override void ModifyItemLoot(ItemLoot itemLoot)
{
// Money
itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType<Bumblefuck>()));
itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType<Dragonfolly>()));
// Materials
itemLoot.Add(ModContent.ItemType<EffulgentFeather>(), 1, 30, 35);
@@ -1,58 +0,0 @@
using System;
using System.Collections.Generic;
using CalamityMod.CustomRecipes;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.DraedonsArsenal;
using CalamityMod.Sounds;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.DraedonsArsenal
{
public class GaussPistol : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal";
public override void SetDefaults()
{
CalamityGlobalItem modItem = Item.Calamity();
Item.width = 40;
Item.height = 22;
Item.DamageType = DamageClass.Magic;
Item.mana = 6;
Item.damage = 150;
Item.knockBack = 11f;
Item.useAnimation = Item.useTime = 20;
Item.autoReuse = true;
Item.useStyle = ItemUseStyleID.Shoot;
Item.UseSound = CommonCalamitySounds.GaussWeaponFire;
Item.noMelee = true;
Item.value = CalamityGlobalItem.RarityPinkBuyPrice;
Item.rare = ItemRarityID.Pink;
Item.shoot = ModContent.ProjectileType<GaussPistolShot>();
Item.shootSpeed = 14f;
modItem.MaxCharge = 85f;
modItem.UsesCharge = true;
modItem.ChargePerUse = 0.05f;
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2);
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<MysteriousCircuitry>(12).
AddIngredient<DubiousPlating>(8).
AddRecipeGroup("AnyMythrilBar", 10).
AddIngredient(ItemID.SoulofMight, 20).
AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func<bool> condition), condition).
AddTile(TileID.MythrilAnvil).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

+77
View File
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using CalamityMod.CustomRecipes;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.DraedonsArsenal;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.DraedonsArsenal
{
[LegacyName("GaussPistol")]
public class Vulcan : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal";
public override void SetDefaults()
{
Item.width = 28;
Item.height = 34;
Item.DamageType = DamageClass.Magic;
Item.mana = 11;
Item.damage = 40;
Item.knockBack = 11f;
Item.useAnimation = Item.useTime = 11;
Item.autoReuse = true;
Item.useStyle = ItemUseStyleID.Shoot;
Item.noMelee = true;
Item.channel = true;
Item.noUseGraphic = true;
Item.value = CalamityGlobalItem.RarityPinkBuyPrice;
Item.rare = ItemRarityID.Pink;
Item.shoot = ModContent.ProjectileType<VulcanHoldout>();
Item.shootSpeed = 14f;
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2);
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
public override bool AltFunctionUse(Player player) => true;
public override void HoldItem(Player player)
{
if (Main.myPlayer == player.whoAmI)
player.Calamity().rightClickListener = true;
player.Calamity().mouseWorldListener = true;
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/DraedonsArsenal/VulcanGlow").Value);
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
float gunType = 0;
if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0)
gunType = 5;
Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, gunType);
holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
return false;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<MysteriousCircuitry>(12).
AddIngredient<DubiousPlating>(8).
AddRecipeGroup("AnyMythrilBar", 10).
AddIngredient(ItemID.SoulofMight, 20).
AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func<bool> condition), condition).
AddTile(TileID.MythrilAnvil).
Register();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

+37 -71
View File
@@ -36,51 +36,34 @@ namespace CalamityMod.Items.Weapons.Melee
public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(BuffID.OnFire3, 360);
SoundEngine.PlaySound(SoundID.Item14, target.Center);
int onHitDamage = player.CalcIntDamage<MeleeDamageClass>(Item.damage);
Projectile blast = Projectile.NewProjectileDirect(Item.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), onHitDamage, 0f, player.whoAmI, target.whoAmI);
blast.DamageType = Item.DamageType;
float firstDustScale = 1.7f;
float secondDustScale = 0.8f;
float thirdDustScale = 2f;
Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2();
Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2();
Vector2 dustVelocity = dustRotation * target.velocity.Length();
SoundEngine.PlaySound(SoundID.Item14, target.Center);
int increment;
for (int i = 0; i < 40; i = increment + 1)
for (int i = 0; i < 40; i++)
{
int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 200, default, firstDustScale);
Dust dust = Main.dust[swingDust];
dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f;
dust.noGravity = true;
dust.velocity.Y -= 6f;
dust.velocity *= 3f;
dust.velocity += dustVelocity * Main.rand.NextFloat();
swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 100, default, secondDustScale);
dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f;
dust.velocity.Y -= 6f;
dust.velocity *= 2f;
dust.noGravity = true;
dust.fadeIn = 1f;
dust.color = Color.Crimson * 0.5f;
dust.velocity += dustVelocity * Main.rand.NextFloat();
increment = i;
Vector2 mainDustPos = target.Center + Main.rand.NextVector2Circular(target.width / 2, target.width / 2);
Dust swingDust = Dust.NewDustPerfect(mainDustPos, DustID.InfernoFork, dustVelocity * Main.rand.NextFloat() - Vector2.UnitY * 18f, 200, Scale: 1.7f);
swingDust.noGravity = true;
Dust swingDust2 = Dust.NewDustPerfect(mainDustPos, DustID.InfernoFork, dustVelocity * Main.rand.NextFloat() - Vector2.UnitY * 12f, 100, Color.Crimson * 0.5f, 0.8f);
swingDust2.noGravity = true;
swingDust2.fadeIn = 1f;
}
for (int j = 0; j < 20; j = increment + 1)
for (int j = 0; j < 20; j++)
{
int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 0, default, thirdDustScale);
Dust dust = Main.dust[swingDust2];
dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f;
dust.noGravity = true;
dust.velocity.Y -= 6f;
dust.velocity *= 0.5f;
dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat());
increment = j;
Vector2 dustPos = target.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(target.velocity.ToRotation()) * (target.width / 3f);
Dust moreDust = Dust.NewDustPerfect(dustPos, DustID.InfernoFork, dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()) - Vector2.UnitY * 3f, Scale: 2f);
moreDust.noGravity = true;
}
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
if (player.whoAmI == Main.myPlayer)
if (player.whoAmI == Main.myPlayer && !player.Calamity().bladeArmEnchant)
{
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1) ||
player.itemAnimation == (int)(player.itemAnimationMax * 0.3) ||
@@ -88,65 +71,48 @@ namespace CalamityMod.Items.Weapons.Melee
player.itemAnimation == (int)(player.itemAnimationMax * 0.7) ||
player.itemAnimation == (int)(player.itemAnimationMax * 0.9))
{
float sparkYVel = 0f;
float sparkXVel = 0f;
float sparkYSpawn = 0f;
float sparkYVel = 0f;
float sparkXSpawn = 0f;
float sparkYSpawn = 0f;
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9))
{
sparkYVel = -7f;
sparkYVel = -10.5f;
if (player.direction == -1)
sparkXSpawn = -8f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7))
{
sparkYVel = -6f;
sparkXVel = 2f;
sparkYVel = -9f;
sparkXVel = 3f;
sparkXSpawn = player.direction == -1 ? 20f : 26f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5))
{
sparkYVel = -4f;
sparkXVel = 4f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3))
{
sparkYVel = -2f;
sparkYVel = -6f;
sparkXVel = 6f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1))
{
sparkXVel = 7f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7))
{
sparkXSpawn = 26f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3))
{
sparkXSpawn -= 4f;
sparkYSpawn -= 20f;
sparkXVel = 9f;
sparkYVel = -3f;
sparkXSpawn = -4f;
sparkYSpawn = -20f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1))
{
sparkYSpawn += 6f;
sparkXVel = 10.5f;
sparkYSpawn = 6f;
}
if (player.direction == -1)
{
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9))
{
sparkXSpawn -= 8f;
}
if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7))
{
sparkXSpawn -= 6f;
}
}
sparkYVel *= 1.5f;
sparkXVel *= 1.5f;
sparkXSpawn *= (float)player.direction;
sparkXVel *= player.direction;
sparkYVel *= player.gravDir;
sparkXSpawn *= player.direction;
sparkYSpawn *= player.gravDir;
var source = player.GetSource_ItemUse(Item);
int damage = (int)player.GetTotalDamage<MeleeDamageClass>().ApplyTo(Item.damage * 0.1f);
Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + sparkXSpawn, (float)(hitbox.Y + hitbox.Height / 2) + sparkYSpawn,
(float)player.direction * sparkXVel, sparkYVel * player.gravDir, ModContent.ProjectileType<UltimusCleaverDust>(), damage, 0f, player.whoAmI, 0f, 0f);
Projectile.NewProjectile(source, hitbox.X + hitbox.Width / 2 + sparkXSpawn, hitbox.Y + hitbox.Height / 2 + sparkYSpawn, sparkXVel, sparkYVel, ModContent.ProjectileType<UltimusCleaverDust>(), damage, 0f, player.whoAmI);
}
}
}
+8 -5
View File
@@ -44,7 +44,6 @@ namespace CalamityMod.Items.Weapons.Ranged
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
int bulletAmt = 4;
for (int index = 0; index < bulletAmt; ++index)
{
@@ -87,10 +86,12 @@ namespace CalamityMod.Items.Weapons.Ranged
targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201);
targetPosition.Y -= 100 * j;
Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[j]].Center - targetPosition) * Item.shootSpeed;
// Create a dummy projectile to grab the number of max updates the bullet has for predictive aim use
Projectile dummy = new Projectile();
dummy.SetDefaults(type);
Vector2 extraBulletVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(targetPosition, Main.npc[targets[j]], Item.shootSpeed, dummy.MaxUpdates);
int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI);
Main.projectile[proj].extraUpdates += 14;
Main.projectile[proj].tileCollide = false;
Main.projectile[proj].timeLeft /= 2;
}
@@ -107,10 +108,12 @@ namespace CalamityMod.Items.Weapons.Ranged
targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201);
targetPosition.Y -= 100 * randomTarget;
Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed;
// Create a dummy projectile to grab the number of max updates the bullet has for predictive aim use
Projectile dummy = new Projectile();
dummy.SetDefaults(type);
Vector2 extraBulletVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(targetPosition, Main.npc[targets[randomTarget]], Item.shootSpeed, dummy.MaxUpdates);
int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI);
Main.projectile[proj].extraUpdates += 14;
Main.projectile[proj].tileCollide = false;
Main.projectile[proj].timeLeft /= 2;
}
@@ -39,16 +39,6 @@ GaussDagger: {
'''
}
GaussPistol: {
DisplayName: Gauss Pistol
Tooltip:
'''
Fires a devastating high-velocity blast with extreme knockback
[c/1FFBFF:'Though this arcane pistol may seem mundane, it is deceivingly powerful.]
[c/1FFBFF:One of the many advantages of magical firearms is that size does not equal power.']
'''
}
HolofiberImmolator: {
DisplayName: R-PMA: Holofiber Immolator
Tooltip:
@@ -265,3 +255,16 @@ WavePounder: {
Stealth strikes emit absurdly powerful shockwaves
'''
}
Vulcan: {
DisplayName: R-GSS: Vulcan
Tooltip:
'''
A mana-fueled Gatling cannon that fires in bursts
Press <right> to launch a magnetic harpoon which attracts your shots
Launching a harpoon makes burst fire mode last longer
When a harpoon expires, all magnetized shots launch at nearby enemies with increased damage
[c/1FFBFF:'Originally a ceiling mounted mining beam, the removal of its battery reduced its heft only marginally.]
[c/1FFBFF:It saw little use and many complaints from the battlemage corps.']
'''
}
@@ -168,7 +168,6 @@ CryoSlime.DisplayName: Cryo Slime
EbonianBlightSlime.DisplayName: Ebonian Blight Slime
Eidolist.DisplayName: Eidolist
FearlessGoldfishWarrior.DisplayName: Fearless Goldfish Warrior
Foveanator.DisplayName: Foveanator
Frogfish.DisplayName: Frogfish
Horse.DisplayName: Earth Elemental
IceClasper.DisplayName: Ice Clasper
@@ -189,7 +188,6 @@ Rotdog.DisplayName: Rotdog
ScornEater.DisplayName: Scorn Eater
ShockstormShuttle.DisplayName: Shockstorm Shuttle
Shroomble.DisplayName: Shroomble
SkeletronPrime2.DisplayName: Skeletron Prime
Stormlion.DisplayName: Stormlion
StormlionSentry.DisplayName: Stormlion Sentry
Sunskater.DisplayName: Sunskater
@@ -563,3 +561,7 @@ SeaKing: {
Princess_LovesNPC: "{NPCName} always smiles when I'm nearby, I like being around him just for that!"
}
}
WildBumblebirb.DisplayName: Wild Bumblebirb
DraconicSwarmer.DisplayName: Draconic Swarmer
Dragonfolly.DisplayName: Dragonfolly
@@ -46,6 +46,8 @@ SystemBaneProjectile.DisplayName: System Bane
TeslaCannonShot.DisplayName: Tesla Beam
UnstableMatter.DisplayName: Unstable Matter
VoltageStream.DisplayName: Voltage Stream
VulcanProjectile.DisplayName: Vulcan Shot
VulcanSpear.DisplayName: Vulcanite Lance
WavePounderBoom.DisplayName: Explosion
WavePounderProjectile.DisplayName: Wave Pounder
// Environmental
+1 -1
View File
@@ -741,7 +741,7 @@ namespace CalamityMod
{
string entryName = "Dragonfolly";
BossChecklistProgressionValues.TryGetValue(entryName, out float order);
int type = NPCType<Bumblefuck>();
int type = NPCType<Dragonfolly>();
List<int> collection = new List<int>() { ItemType<DragonfollyRelic>(), ItemType<DragonfollyTrophy>(), ItemType<BumblefuckMask>(), ItemType<LoreDragonfolly>(), ItemType<ThankYouPainting>() };
AddBoss(bossChecklist, calamity, entryName, order, DownedDragonfolly, type, new Dictionary<string, object>()
{
+1 -1
View File
@@ -2,7 +2,7 @@
using CalamityMod.BiomeManagers;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs;
using CalamityMod.NPCs.NormalNPCs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
+1 -1
View File
@@ -2,7 +2,7 @@
using CalamityMod.BiomeManagers;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs;
using CalamityMod.NPCs.NormalNPCs;
using Terraria;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
+1 -1
View File
@@ -3,7 +3,7 @@ using System.IO;
using CalamityMod.BiomeManagers;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.Projectiles.Enemy;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
+1 -1
View File
@@ -4,7 +4,7 @@ using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs;
using CalamityMod.NPCs.NormalNPCs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
+249 -4
View File
@@ -1,15 +1,19 @@
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Events;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using CalamityMod.Systems.Collections;
namespace CalamityMod.NPCs.AquaticScourge
{
@@ -36,7 +40,7 @@ namespace CalamityMod.NPCs.AquaticScourge
NPC.knockBackResist = 0f;
NPC.alpha = 255;
NPC.LifeMaxNERB(80000, 96000, 1000000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 2;
NPC.behindTiles = true;
NPC.noGravity = true;
@@ -56,7 +60,7 @@ namespace CalamityMod.NPCs.AquaticScourge
else if (Main.expertMode)
NPC.scale *= 1.1f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.25f;
NPC.Calamity().VulnerableToHeat = false;
@@ -89,7 +93,248 @@ namespace CalamityMod.NPCs.AquaticScourge
public override void AI()
{
AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, false);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
bool getFuckedAI = Main.zenithWorld;
// Adjust hostility and stats
bool nonHostile = calamityGlobalNPC.newAI[0] == 0f;
if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || bossRush || CalamityWorld.LegendaryMode)
{
if (nonHostile)
{
// Kiss my motherfucking ass you piece of shit game
NPC.timeLeft *= 20;
NPC.npcSlots = 16f;
CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime);
calamityGlobalNPC.KillTime = revKillTime;
calamityGlobalNPC.newAI[0] = 1f;
nonHostile = false;
NPC.chaseable = true;
NPC.netUpdate = true;
}
}
else
NPC.damage = 0;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < 0.75f;
bool phase3 = lifeRatio < 0.5f;
bool phase4 = lifeRatio < 0.25f;
// Set worm variable
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
if (NPC.life > Main.npc[(int)NPC.ai[1]].life)
NPC.life = Main.npc[(int)NPC.ai[1]].life;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool notOcean = player.position.Y < 300f ||
player.position.Y > Main.worldSurface * 16.0 ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
// Check for the flipped Abyss
if (Main.remixWorld)
{
notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
}
bool biomeEnraged = NPC.localAI[2] <= 0f || bossRush;
float enrageScale = bossRush ? 1f : 0f;
if (biomeEnraged)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
// Adjust slowing debuff immunity
bool immuneToSlowingDebuffs = getFuckedAI;
NPC.buffImmune[ModContent.BuffType<GlacialState>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TemporalSadness>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Eutrophication>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TimeDistortion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<GalvanicCorrosion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Vaporfied>()] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs;
// Fire teeth
if (calamityGlobalNPC.newAI[0] == 1f && (!phase3 || phase4))
{
NPC.localAI[0] += 1f;
float shootProjectile = 300;
float timer = NPC.ai[0] + 15f;
float divisor = timer + shootProjectile;
if (NPC.localAI[0] % divisor == 0f && (NPC.ai[0] % 3f == 0f || getFuckedAI || !death))
{
NPC.TargetClosest();
if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height))
{
SoundEngine.PlaySound(SoundID.Item17, NPC.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float toothVelocity = death ? 9f : 8f;
Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY);
int type = ModContent.ProjectileType<SandTooth>();
int damage = NPC.GetProjectileDamage(type);
float accelerate = phase4 ? 1f : 0f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity * 5f, projectileVelocity * toothVelocity, type, damage, 0f, Main.myPlayer, accelerate, 0f);
}
NPC.netUpdate = true;
}
}
}
// Kill body and tail
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<AquaticScourgeHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f;
if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged))
{
calamityGlobalNPC.newAI[1] = 1f;
NPC.TargetClosest(false);
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
{
for (int a = 0; a < Main.npc.Length; a++)
{
int type = Main.npc[a].type;
if (AquaticScourgeIDList.Includes(type))
Main.npc[a].active = false;
}
}
}
else
calamityGlobalNPC.newAI[1] = 0f;
// Change direction
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
// Alpha changes
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 scourgePosition = NPC.Center;
Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[NPC.target].velocity * 20f : Vector2.Zero;
float scourgeTargetX = player.Center.X + predictionVector.X;
float scourgeTargetY = player.Center.Y + predictionVector.Y;
// Velocity and movement
float scourgeMaxSpeed = 5f;
if (calamityGlobalNPC.newAI[0] == 1f)
{
scourgeMaxSpeed = revenge ? 14.4f : 12f;
if (expertMode)
scourgeMaxSpeed += 2.4f * (1f - lifeRatio);
scourgeMaxSpeed += 3f * enrageScale;
if (death || getFuckedAI)
{
scourgeMaxSpeed += 5f;
scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f;
}
if (CalamityWorld.LegendaryMode)
scourgeMaxSpeed *= 1.15f;
}
scourgeTargetX = (int)(scourgeTargetX / 16f) * 16;
scourgeTargetY = (int)(scourgeTargetY / 16f) * 16;
scourgePosition.X = (int)(scourgePosition.X / 16f) * 16;
scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16;
scourgeTargetX -= scourgePosition.X;
scourgeTargetY -= scourgePosition.Y;
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
scourgePosition = NPC.Center;
scourgeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - scourgePosition.X;
scourgeTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - scourgePosition.Y;
}
catch
{
}
NPC.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2;
float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY);
int scourgeWidth = NPC.width;
scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist;
scourgeTargetX *= scourgeTargetDist;
scourgeTargetY *= scourgeTargetDist;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + scourgeTargetX;
NPC.position.Y = NPC.position.Y + scourgeTargetY;
if (scourgeTargetX < 0f)
NPC.spriteDirection = -1;
else if (scourgeTargetX > 0f)
NPC.spriteDirection = 1;
}
// Calculate contact damage based on velocity
if (!nonHostile)
{
float minimalContactDamageVelocity = scourgeMaxSpeed * 0.25f;
float minimalDamageVelocity = scourgeMaxSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
NPC.damage = 0;
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+220 -5
View File
@@ -1,11 +1,15 @@
using System.IO;
using System;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Events;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Systems.Collections;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.Localization;
@@ -35,7 +39,7 @@ namespace CalamityMod.NPCs.AquaticScourge
NPC.knockBackResist = 0f;
NPC.alpha = 255;
NPC.LifeMaxNERB(80000, 96000, 1000000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 2;
NPC.behindTiles = true;
NPC.noGravity = true;
@@ -55,7 +59,7 @@ namespace CalamityMod.NPCs.AquaticScourge
else if (Main.expertMode)
NPC.scale *= 1.1f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.25f;
NPC.Calamity().VulnerableToHeat = false;
@@ -88,7 +92,218 @@ namespace CalamityMod.NPCs.AquaticScourge
public override void AI()
{
AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, false);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
bool getFuckedAI = Main.zenithWorld;
// Adjust hostility and stats
bool nonHostile = calamityGlobalNPC.newAI[0] == 0f;
if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || bossRush || CalamityWorld.LegendaryMode)
{
if (nonHostile)
{
// Kiss my motherfucking ass you piece of shit game
NPC.timeLeft *= 20;
NPC.npcSlots = 16f;
CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime);
calamityGlobalNPC.KillTime = revKillTime;
calamityGlobalNPC.newAI[0] = 1f;
nonHostile = false;
NPC.chaseable = true;
NPC.netUpdate = true;
}
}
else
NPC.damage = 0;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < 0.75f;
bool phase3 = lifeRatio < 0.5f;
bool phase4 = lifeRatio < 0.25f;
// Set worm variable
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
if (NPC.life > Main.npc[(int)NPC.ai[1]].life)
NPC.life = Main.npc[(int)NPC.ai[1]].life;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool notOcean = player.position.Y < 300f ||
player.position.Y > Main.worldSurface * 16.0 ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
// Check for the flipped Abyss
if (Main.remixWorld)
{
notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
}
bool biomeEnraged = NPC.localAI[2] <= 0f || bossRush;
float enrageScale = bossRush ? 1f : 0f;
if (biomeEnraged)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
// Adjust slowing debuff immunity
bool immuneToSlowingDebuffs = getFuckedAI;
NPC.buffImmune[ModContent.BuffType<GlacialState>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TemporalSadness>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Eutrophication>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TimeDistortion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<GalvanicCorrosion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Vaporfied>()] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs;
// Kill body and tail
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<AquaticScourgeHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f;
if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged))
{
calamityGlobalNPC.newAI[1] = 1f;
NPC.TargetClosest(false);
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
{
for (int a = 0; a < Main.npc.Length; a++)
{
int type = Main.npc[a].type;
if (AquaticScourgeIDList.Includes(type))
Main.npc[a].active = false;
}
}
}
else
calamityGlobalNPC.newAI[1] = 0f;
// Change direction
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
// Alpha changes
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 scourgePosition = NPC.Center;
Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[NPC.target].velocity * 20f : Vector2.Zero;
float scourgeTargetX = player.Center.X + predictionVector.X;
float scourgeTargetY = player.Center.Y + predictionVector.Y;
// Velocity and movement
float scourgeMaxSpeed = 5f;
if (calamityGlobalNPC.newAI[0] == 1f)
{
scourgeMaxSpeed = revenge ? 14.4f : 12f;
if (expertMode)
scourgeMaxSpeed += 2.4f * (1f - lifeRatio);
scourgeMaxSpeed += 3f * enrageScale;
if (death || getFuckedAI)
{
scourgeMaxSpeed += 5f;
scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f;
}
if (CalamityWorld.LegendaryMode)
scourgeMaxSpeed *= 1.15f;
}
scourgeTargetX = (int)(scourgeTargetX / 16f) * 16;
scourgeTargetY = (int)(scourgeTargetY / 16f) * 16;
scourgePosition.X = (int)(scourgePosition.X / 16f) * 16;
scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16;
scourgeTargetX -= scourgePosition.X;
scourgeTargetY -= scourgePosition.Y;
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
scourgePosition = NPC.Center;
scourgeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - scourgePosition.X;
scourgeTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - scourgePosition.Y;
}
catch
{
}
NPC.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2;
float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY);
int scourgeWidth = NPC.width;
scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist;
scourgeTargetX *= scourgeTargetDist;
scourgeTargetY *= scourgeTargetDist;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + scourgeTargetX;
NPC.position.Y = NPC.position.Y + scourgeTargetY;
if (scourgeTargetX < 0f)
NPC.spriteDirection = -1;
else if (scourgeTargetX > 0f)
NPC.spriteDirection = 1;
}
// Calculate contact damage based on velocity
if (!nonHostile)
{
float minimalContactDamageVelocity = scourgeMaxSpeed * 0.25f;
float minimalDamageVelocity = scourgeMaxSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
NPC.damage = 0;
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+467 -7
View File
@@ -1,5 +1,6 @@
using System.IO;
using CalamityMod.BiomeManagers;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Events;
using CalamityMod.Items.Accessories;
@@ -16,13 +17,13 @@ using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.AcidRain;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.NPCs.TownNPCs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Enemy;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
@@ -30,6 +31,7 @@ using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Systems.Collections;
namespace CalamityMod.NPCs.AquaticScourge
{
@@ -63,7 +65,7 @@ namespace CalamityMod.NPCs.AquaticScourge
NPC.aiStyle = -1;
AIType = -1;
NPC.LifeMaxNERB(80000, 96000, 1000000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 2;
NPC.knockBackResist = 0f;
NPC.value = Item.buyPrice(0, 16, 0, 0);
@@ -84,7 +86,7 @@ namespace CalamityMod.NPCs.AquaticScourge
else if (Main.expertMode)
NPC.scale *= 1.1f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.25f;
NPC.Calamity().VulnerableToHeat = false;
@@ -131,7 +133,465 @@ namespace CalamityMod.NPCs.AquaticScourge
public override void AI()
{
AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, true);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
bool getFuckedAI = Main.zenithWorld;
CalamityGlobalNPC.aquaticScourge = NPC.whoAmI;
// Adjust hostility and stats
bool nonHostile = calamityGlobalNPC.newAI[0] == 0f;
if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || bossRush || CalamityWorld.LegendaryMode)
{
if (nonHostile)
{
// Kiss my motherfucking ass you piece of shit game
NPC.timeLeft *= 20;
NPC.npcSlots = 16f;
CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime);
calamityGlobalNPC.KillTime = revKillTime;
calamityGlobalNPC.newAI[0] = 1f;
nonHostile = false;
NPC.boss = true;
NPC.chaseable = true;
NPC.netUpdate = true;
}
}
else
NPC.damage = 0;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < 0.75f;
bool phase3 = lifeRatio < 0.5f;
bool phase4 = lifeRatio < 0.25f;
// Set worm variable
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool notOcean = player.position.Y < 300f ||
player.position.Y > Main.worldSurface * 16.0 ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
// Check for the flipped Abyss
if (Main.remixWorld)
{
notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
}
// Enrage
if (notOcean && !player.Calamity().ZoneSulphur && !bossRush)
{
if (NPC.localAI[2] > 0f)
NPC.localAI[2] -= 1f;
}
else
NPC.localAI[2] = CalamityGlobalNPC.biomeEnrageTimerMax;
bool biomeEnraged = NPC.localAI[2] <= 0f || bossRush;
float enrageScale = bossRush ? 1f : 0f;
if (biomeEnraged)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
// Circular movement
float colorFadeTimeAfterSpiral = 90f;
float spiralGateValue = 480f;
bool doSpiral = false;
if (calamityGlobalNPC.newAI[0] == 1f && calamityGlobalNPC.newAI[2] == 1f && (revenge || getFuckedAI))
{
doSpiral = calamityGlobalNPC.newAI[1] == 0f && calamityGlobalNPC.newAI[3] >= spiralGateValue;
if (Vector2.Distance(NPC.Center, player.Center) < (getFuckedAI ? 1600f : 1000f) || doSpiral)
calamityGlobalNPC.newAI[3] += 1f;
if (doSpiral)
{
NPC.localAI[3] = colorFadeTimeAfterSpiral;
// Vomit acid mist
float acidMistBarfDivisor = getFuckedAI ? 2f : ((float)Math.Floor(bossRush ? 4f : death ? 5f : 6f) * (phase3 ? 1.5f : 1f));
if (calamityGlobalNPC.newAI[3] % acidMistBarfDivisor == 0f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float mistVelocity = death ? 10f : 8f;
Vector2 projectileVelocity = (NPC.Center + NPC.velocity * 10f - NPC.Center).SafeNormalize(Vector2.UnitY);
int type = ModContent.ProjectileType<SulphuricAcidMist>();
int damage = NPC.GetProjectileDamage(type);
int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity * 5f, projectileVelocity * mistVelocity, type, damage, 0f, Main.myPlayer);
Main.projectile[proj].tileCollide = false;
Main.projectile[proj].timeLeft = getFuckedAI ? 240 : 600;
}
}
// Vomit circular spreads of acid clouds while in phase 3
float toxicCloudBarfDivisor = bossRush ? 20f : death ? 30f : 40f;
if (calamityGlobalNPC.newAI[3] % toxicCloudBarfDivisor == 0f && phase3)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<ToxicCloud>();
int damage = NPC.GetProjectileDamage(type);
int totalProjectiles = (phase4 ? 6 : 9) + (getFuckedAI ? Main.rand.Next(-2, 3) : (int)((calamityGlobalNPC.newAI[3] - spiralGateValue) / toxicCloudBarfDivisor) * (phase4 ? 2 : 3));
float radians = MathHelper.TwoPi / totalProjectiles;
float cloudVelocity = 1f + enrageScale;
Vector2 spinningPoint = new Vector2(0f, -cloudVelocity);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 vector255 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer);
}
}
}
// Velocity boost
if (calamityGlobalNPC.newAI[3] == spiralGateValue)
{
NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY);
NPC.velocity *= 24f;
}
// Spin velocity
float velocity = (float)(MathHelper.Pi * 2D) / 120f;
// In GFB, contracts the radius as the fight progresses
if (getFuckedAI)
velocity *= phase3 ? 1.5f : phase2 ? 1.25f : 1f;
NPC.velocity = NPC.velocity.RotatedBy(-(double)velocity * NPC.localAI[1]);
// Speed up even more in GFB for more radius
if (getFuckedAI && NPC.velocity.Length() <= 32f)
NPC.velocity *= 1.1f;
NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2;
// Reset and charge at target
// Don't reset in GFB
if (!getFuckedAI && calamityGlobalNPC.newAI[3] >= spiralGateValue + 120f)
{
calamityGlobalNPC.newAI[3] = 0f;
NPC.TargetClosest();
}
}
else
{
if (!Collision.CanHit(NPC.Center, 1, 1, player.position, player.width, player.height) && calamityGlobalNPC.newAI[3] > 300f)
calamityGlobalNPC.newAI[3] -= 2f;
if (NPC.localAI[3] > 0f)
NPC.localAI[3] -= 1f;
NPC.localAI[1] = NPC.Center.X - player.Center.X < 0 ? 1f : -1f;
}
}
// Adjust slowing debuff immunity
bool immuneToSlowingDebuffs = doSpiral || getFuckedAI;
NPC.buffImmune[ModContent.BuffType<GlacialState>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TemporalSadness>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Eutrophication>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TimeDistortion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<GalvanicCorrosion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Vaporfied>()] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs;
// Spawn segments
if (calamityGlobalNPC.newAI[2] == 0f && NPC.ai[0] == 0f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int maxLength = getFuckedAI ? 24 : death ? 80 : revenge ? 40 : expertMode ? 35 : 30;
int Previous = NPC.whoAmI;
for (int segments = 0; segments < maxLength; segments++)
{
int lol;
if (segments >= 0 && segments < maxLength - 1)
{
if (segments % 2 == 0)
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<AquaticScourgeBodyAlt>(), NPC.whoAmI);
else
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<AquaticScourgeBody>(), NPC.whoAmI);
}
else
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<AquaticScourgeTail>(), NPC.whoAmI);
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = NPC.whoAmI;
Main.npc[lol].ai[1] = Previous;
Main.npc[Previous].ai[0] = lol;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol);
Previous = lol;
}
}
calamityGlobalNPC.newAI[2] = 1f;
}
// Big barf attack
if (calamityGlobalNPC.newAI[0] == 1f && (!doSpiral && phase2) || (getFuckedAI && !phase3))
{
NPC.localAI[0] += 1f;
if (NPC.localAI[0] >= (revenge ? 360f : 420f))
{
if (Vector2.Distance(player.Center, NPC.Center) > 320f)
{
NPC.localAI[0] = 0f;
NPC.netUpdate = true;
SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int totalProjectiles = bossRush ? 10 : expertMode ? 8 : 6;
if (phase3)
totalProjectiles *= 2;
int type = ModContent.ProjectileType<SandPoisonCloud>();
int damage = NPC.GetProjectileDamage(type);
for (int i = 0; i < totalProjectiles; i++)
{
Vector2 velocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
velocity = velocity.SafeNormalize(Vector2.UnitY);
velocity *= Main.rand.Next(phase3 ? 300 : 100, 401) * 0.01f;
float maximumVelocityMult = death ? 0.75f : 0.5f;
if (expertMode)
velocity *= 1f + (maximumVelocityMult * (0.5f - lifeRatio));
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + velocity.SafeNormalize(Vector2.UnitY) * 5f, velocity, type, damage, 0f, Main.myPlayer);
}
}
}
}
}
if (NPC.life > Main.npc[(int)NPC.ai[0]].life)
NPC.life = Main.npc[(int)NPC.ai[0]].life;
float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f;
if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged))
{
calamityGlobalNPC.newAI[1] = 1f;
NPC.TargetClosest(false);
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
{
for (int a = 0; a < Main.npc.Length; a++)
{
int type = Main.npc[a].type;
if (AquaticScourgeIDList.Includes(type))
Main.npc[a].active = false;
}
}
}
else
calamityGlobalNPC.newAI[1] = 0f;
// Change direction
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
// Alpha changes
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
Vector2 scourgePosition = NPC.Center;
Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[NPC.target].velocity * 20f : Vector2.Zero;
float scourgeTargetX = player.Center.X + predictionVector.X;
float scourgeTargetY = player.Center.Y + predictionVector.Y;
// Velocity and movement
float scourgeMaxSpeed = 5f;
float scourgeAcceleration = 0.08f;
if (calamityGlobalNPC.newAI[0] == 1f)
{
scourgeMaxSpeed = revenge ? 14.4f : 12f;
scourgeAcceleration = revenge ? 0.18f : 0.15f;
if (expertMode)
{
scourgeMaxSpeed += 2.4f * (1f - lifeRatio);
scourgeAcceleration += 0.03f * (1f - lifeRatio);
}
scourgeMaxSpeed += 3f * enrageScale;
scourgeAcceleration += 0.06f * enrageScale;
if (death || getFuckedAI)
{
scourgeMaxSpeed += 5f;
scourgeAcceleration -= getFuckedAI ? 0f : 0.03f;
scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f;
scourgeAcceleration += Vector2.Distance(player.Center, NPC.Center) * 0.000045f;
}
// Increase acceleration after spiral attack
if (NPC.localAI[3] > 0f)
{
float accelerationMultiplier = MathHelper.Lerp(1f, 2f, NPC.localAI[3] / colorFadeTimeAfterSpiral);
scourgeAcceleration *= accelerationMultiplier;
}
if (CalamityWorld.LegendaryMode)
{
scourgeMaxSpeed *= 1.15f;
scourgeAcceleration *= 1.15f;
}
}
if (!doSpiral)
{
if (calamityGlobalNPC.newAI[0] != 1f)
{
scourgeTargetY += 400;
if (Math.Abs(NPC.Center.X - player.Center.X) < 500f)
{
if (NPC.velocity.X > 0f)
scourgeTargetX = player.Center.X + 600f;
else
scourgeTargetX = player.Center.X - 600f;
}
}
float scourgeHigherSpeed = scourgeMaxSpeed * 1.3f;
float scourgeLowerSpeed = scourgeMaxSpeed * 0.7f;
float scourgeSpeed = NPC.velocity.Length();
if (scourgeSpeed > 0f)
{
if (scourgeSpeed > scourgeHigherSpeed)
{
NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY);
NPC.velocity *= scourgeHigherSpeed;
}
else if (scourgeSpeed < scourgeLowerSpeed)
{
NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY);
NPC.velocity *= scourgeLowerSpeed;
}
}
}
scourgeTargetX = (int)(scourgeTargetX / 16f) * 16;
scourgeTargetY = (int)(scourgeTargetY / 16f) * 16;
scourgePosition.X = (int)(scourgePosition.X / 16f) * 16;
scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16;
scourgeTargetX -= scourgePosition.X;
scourgeTargetY -= scourgePosition.Y;
float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY);
if (!doSpiral)
{
float scourgeAbsoluteTargetX = Math.Abs(scourgeTargetX);
float scourgeAbsoluteTargetY = Math.Abs(scourgeTargetY);
float scourgeTimeToReachTarget = scourgeMaxSpeed / scourgeTargetDist;
scourgeTargetX *= scourgeTimeToReachTarget;
scourgeTargetY *= scourgeTimeToReachTarget;
if ((NPC.velocity.X > 0f && scourgeTargetX > 0f) || (NPC.velocity.X < 0f && scourgeTargetX < 0f) || (NPC.velocity.Y > 0f && scourgeTargetY > 0f) || (NPC.velocity.Y < 0f && scourgeTargetY < 0f))
{
if (NPC.velocity.X < scourgeTargetX)
{
NPC.velocity.X += scourgeAcceleration;
}
else
{
if (NPC.velocity.X > scourgeTargetX)
NPC.velocity.X -= scourgeAcceleration;
}
if (NPC.velocity.Y < scourgeTargetY)
{
NPC.velocity.Y += scourgeAcceleration;
}
else
{
if (NPC.velocity.Y > scourgeTargetY)
NPC.velocity.Y -= scourgeAcceleration;
}
if (Math.Abs(scourgeTargetY) < scourgeMaxSpeed * 0.2 && ((NPC.velocity.X > 0f && scourgeTargetX < 0f) || (NPC.velocity.X < 0f && scourgeTargetX > 0f)))
{
if (NPC.velocity.Y > 0f)
NPC.velocity.Y += scourgeAcceleration * 2f;
else
NPC.velocity.Y -= scourgeAcceleration * 2f;
}
if (Math.Abs(scourgeTargetX) < scourgeMaxSpeed * 0.2 && ((NPC.velocity.Y > 0f && scourgeTargetY < 0f) || (NPC.velocity.Y < 0f && scourgeTargetY > 0f)))
{
if (NPC.velocity.X > 0f)
NPC.velocity.X += scourgeAcceleration * 2f;
else
NPC.velocity.X -= scourgeAcceleration * 2f;
}
}
else
{
if (scourgeAbsoluteTargetX > scourgeAbsoluteTargetY)
{
if (NPC.velocity.X < scourgeTargetX)
NPC.velocity.X += scourgeAcceleration * 1.1f;
else if (NPC.velocity.X > scourgeTargetX)
NPC.velocity.X -= scourgeAcceleration * 1.1f;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < scourgeMaxSpeed * 0.5)
{
if (NPC.velocity.Y > 0f)
NPC.velocity.Y += scourgeAcceleration;
else
NPC.velocity.Y -= scourgeAcceleration;
}
}
else
{
if (NPC.velocity.Y < scourgeTargetY)
NPC.velocity.Y += scourgeAcceleration * 1.1f;
else if (NPC.velocity.Y > scourgeTargetY)
NPC.velocity.Y -= scourgeAcceleration * 1.1f;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < scourgeMaxSpeed * 0.5)
{
if (NPC.velocity.X > 0f)
NPC.velocity.X += scourgeAcceleration;
else
NPC.velocity.X -= scourgeAcceleration;
}
}
}
NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2;
}
// Calculate contact damage based on velocity
if (!nonHostile)
{
float minimalContactDamageVelocity = scourgeMaxSpeed * 0.25f;
float minimalDamageVelocity = scourgeMaxSpeed * 0.5f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
NPC.damage = (int)Math.Round(NPC.defDamage * 0.5);
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
@@ -205,7 +665,7 @@ namespace CalamityMod.NPCs.AquaticScourge
if (spawnInfo.Player.Calamity().ZoneSulphur && spawnInfo.Water)
{
if (!NPC.AnyNPCs(ModContent.NPCType<AquaticScourgeHead>()))
return (Main.getGoodWorld ? 0.05f : 0.01f);
return (CalamityWorld.LegendaryMode ? 0.05f : 0.01f);
}
return 0f;
+218 -5
View File
@@ -1,7 +1,9 @@
using System.IO;
using System;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Events;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Systems.Collections;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -35,7 +37,7 @@ namespace CalamityMod.NPCs.AquaticScourge
NPC.knockBackResist = 0f;
NPC.alpha = 255;
NPC.LifeMaxNERB(80000, 96000, 1000000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 2;
NPC.behindTiles = true;
NPC.noGravity = true;
@@ -55,7 +57,7 @@ namespace CalamityMod.NPCs.AquaticScourge
else if (Main.expertMode)
NPC.scale *= 1.1f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.25f;
NPC.Calamity().VulnerableToHeat = false;
@@ -88,7 +90,218 @@ namespace CalamityMod.NPCs.AquaticScourge
public override void AI()
{
AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, false);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
bool getFuckedAI = Main.zenithWorld;
// Adjust hostility and stats
bool nonHostile = calamityGlobalNPC.newAI[0] == 0f;
if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || bossRush || CalamityWorld.LegendaryMode)
{
if (nonHostile)
{
// Kiss my motherfucking ass you piece of shit game
NPC.timeLeft *= 20;
NPC.npcSlots = 16f;
CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime);
calamityGlobalNPC.KillTime = revKillTime;
calamityGlobalNPC.newAI[0] = 1f;
nonHostile = false;
NPC.chaseable = true;
NPC.netUpdate = true;
}
}
else
NPC.damage = 0;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < 0.75f;
bool phase3 = lifeRatio < 0.5f;
bool phase4 = lifeRatio < 0.25f;
// Set worm variable
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
if (NPC.life > Main.npc[(int)NPC.ai[1]].life)
NPC.life = Main.npc[(int)NPC.ai[1]].life;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool notOcean = player.position.Y < 300f ||
player.position.Y > Main.worldSurface * 16.0 ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
// Check for the flipped Abyss
if (Main.remixWorld)
{
notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
}
bool biomeEnraged = NPC.localAI[2] <= 0f || bossRush;
float enrageScale = bossRush ? 1f : 0f;
if (biomeEnraged)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
// Adjust slowing debuff immunity
bool immuneToSlowingDebuffs = getFuckedAI;
NPC.buffImmune[ModContent.BuffType<GlacialState>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TemporalSadness>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Eutrophication>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<TimeDistortion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<GalvanicCorrosion>()] = immuneToSlowingDebuffs;
NPC.buffImmune[ModContent.BuffType<Vaporfied>()] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs;
NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs;
// Kill body and tail
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<AquaticScourgeHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f;
if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged))
{
calamityGlobalNPC.newAI[1] = 1f;
NPC.TargetClosest(false);
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
NPC.velocity.Y += 2f;
if (NPC.position.Y > Main.worldSurface * 16D)
{
for (int a = 0; a < Main.npc.Length; a++)
{
int type = Main.npc[a].type;
if (AquaticScourgeIDList.Includes(type))
Main.npc[a].active = false;
}
}
}
else
calamityGlobalNPC.newAI[1] = 0f;
// Change direction
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
// Alpha changes
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 scourgePosition = NPC.Center;
Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[NPC.target].velocity * 20f : Vector2.Zero;
float scourgeTargetX = player.Center.X + predictionVector.X;
float scourgeTargetY = player.Center.Y + predictionVector.Y;
// Velocity and movement
float scourgeMaxSpeed = 5f;
if (calamityGlobalNPC.newAI[0] == 1f)
{
scourgeMaxSpeed = revenge ? 14.4f : 12f;
if (expertMode)
scourgeMaxSpeed += 2.4f * (1f - lifeRatio);
scourgeMaxSpeed += 3f * enrageScale;
if (death || getFuckedAI)
{
scourgeMaxSpeed += 5f;
scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f;
}
if (CalamityWorld.LegendaryMode)
scourgeMaxSpeed *= 1.15f;
}
scourgeTargetX = (int)(scourgeTargetX / 16f) * 16;
scourgeTargetY = (int)(scourgeTargetY / 16f) * 16;
scourgePosition.X = (int)(scourgePosition.X / 16f) * 16;
scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16;
scourgeTargetX -= scourgePosition.X;
scourgeTargetY -= scourgePosition.Y;
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
scourgePosition = NPC.Center;
scourgeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - scourgePosition.X;
scourgeTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - scourgePosition.Y;
}
catch
{
}
NPC.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2;
float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY);
int scourgeWidth = NPC.width;
scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist;
scourgeTargetX *= scourgeTargetDist;
scourgeTargetY *= scourgeTargetDist;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + scourgeTargetX;
NPC.position.Y = NPC.position.Y + scourgeTargetY;
if (scourgeTargetX < 0f)
NPC.spriteDirection = -1;
else if (scourgeTargetX > 0f)
NPC.spriteDirection = 1;
}
// Calculate contact damage based on velocity
if (!nonHostile)
{
float minimalContactDamageVelocity = scourgeMaxSpeed * 0.25f;
float minimalDamageVelocity = scourgeMaxSpeed * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
NPC.damage = 0;
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+932 -4
View File
@@ -19,12 +19,13 @@ using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.NPCs.TownNPCs;
using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
@@ -109,7 +110,7 @@ namespace CalamityMod.NPCs.AstrumAureus
NPC.Calamity().VulnerableToSickness = false;
SpawnModBiomes = new int[1] { ModContent.GetInstance<BiomeManagers.AstralInfectionBiome>().Type };
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.8f;
if (Main.zenithWorld)
NPC.scale *= 1.5f;
@@ -153,7 +154,934 @@ namespace CalamityMod.NPCs.AstrumAureus
public override void AI()
{
AstrumAureusAI.VanillaAstrumAureusAI(NPC, Mod);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
CalamityGlobalNPC.astrumAureus = NPC.whoAmI;
// Variables
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < (revenge ? 0.85f : expertMode ? 0.8f : 0.75f);
bool phase3 = lifeRatio < (revenge ? 0.7f : expertMode ? 0.6f : 0.5f);
bool phase4 = lifeRatio < (revenge ? 0.5f : 0.4f) && expertMode;
bool phase5 = lifeRatio < 0.3f && revenge;
// Exhaustion
bool exhausted = NPC.ai[2] >= (phase3 ? 2f : 1f);
calamityGlobalNPC.DR = exhausted ? 0.2f : 0.4f;
NPC.defense = exhausted ? NPC.defDefense / 2 : NPC.defDefense;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
// Despawn safety, make sure to target another player if the current player target is too far away
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
// Don't fire projectiles and don't increment phase timers for 4 seconds after the teleport phase to avoid cheap bullshit
float noProjectileOrPhaseIncrementTime = 240f;
bool dontAttack = NPC.localAI[3] > 0f;
if (dontAttack)
{
NPC.localAI[3] -= 1f;
if (NPC.Distance(player.Center) < 240f)
NPC.localAI[3] -= death ? 4f : expertMode ? 2f : 1f;
}
float enrageScale = bossRush ? 1f : 0f;
if ((Main.IsItDay() && !player.Calamity().ZoneAstral) || bossRush)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1f;
}
float astralFlameBarrageTimerIncrement = 1f;
if (expertMode)
astralFlameBarrageTimerIncrement += death ? (float)Math.Round(3f * (1f - lifeRatio)) : (float)Math.Round(2f * (1f - lifeRatio));
float walkingVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 6f : 5f;
walkingVelocity += 3f * enrageScale;
if (phase5)
walkingVelocity += 2f;
if (expertMode)
walkingVelocity += 1.5f * (1f - lifeRatio);
if (revenge)
walkingVelocity += Math.Abs(NPC.Center.X - player.Center.X) * 0.0025f;
if (CalamityWorld.LegendaryMode)
walkingVelocity *= 1.15f;
float walkingProjectileVelocity = walkingVelocity * 0.8f;
// Direction
NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1;
// Used to reduce Aureus' fall speed
bool reduceFallSpeed = NPC.velocity.Y > 0f && Collision.SolidCollision(NPC.position + Vector2.UnitY * 1.1f * NPC.velocity.Y, NPC.width, NPC.height) && NPC.ai[0] == 4f;
// Despawn
bool despawnDistance = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
if (!player.active || player.dead || despawnDistance)
{
NPC.TargetClosest(false);
player = Main.player[NPC.target];
if (!player.active || player.dead || despawnDistance)
{
NPC.noTileCollide = true;
if (NPC.velocity.Y < -3f)
NPC.velocity.Y = -3f;
NPC.velocity.Y += 0.1f;
if (NPC.velocity.Y > 12f)
NPC.velocity.Y = 12f;
if (NPC.timeLeft > 60)
NPC.timeLeft = 60;
if (NPC.ai[0] != 0f)
{
NPC.ai[0] = 0f;
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
NPC.localAI[2] = 0f;
NPC.localAI[3] = 0f;
calamityGlobalNPC.newAI[0] = 0f;
calamityGlobalNPC.newAI[1] = 0f;
NPC.netUpdate = true;
}
return;
}
}
else if (NPC.timeLeft < 1800)
NPC.timeLeft = 1800;
bool geldonPhase1 = lifeRatio > 0.6f && lifeRatio <= 0.7f;
bool geldonPhase2 = lifeRatio <= 0.1f;
if (Main.zenithWorld && (geldonPhase1 || geldonPhase2))
{
slimeProjCounter++;
if (slimeProjCounter % 180 == 0)
{
SoundEngine.PlaySound(SoundID.Item33, NPC.Center); // Intentionally keeping the old laser sound in GFB
if (slimePhase == 1)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<AstralFlame>();
int damage = NPC.GetProjectileDamage(type);
int totalProjectiles = bossRush ? 14 : death ? 12 : revenge ? 10 : expertMode ? 8 : 6;
float radians = MathHelper.TwoPi / totalProjectiles;
float velocity = 10f;
Vector2 spinningPoint = new Vector2(0f, -velocity);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f);
}
}
slimePhase = 0;
}
else
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<AstralLaser>();
int damage = NPC.GetProjectileDamage(type);
float aureusLaserSpeed = 7f;
float aureusLaserTargetX = player.Center.X - NPC.Center.X;
float aureusLaserTargetY = player.Center.Y - NPC.Center.Y;
float aureusLaserTargetDist = (float)Math.Sqrt(aureusLaserTargetX * aureusLaserTargetX + aureusLaserTargetY * aureusLaserTargetY);
aureusLaserTargetDist = aureusLaserSpeed / aureusLaserTargetDist;
aureusLaserTargetX *= aureusLaserTargetDist;
aureusLaserTargetY *= aureusLaserTargetDist;
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, aureusLaserTargetX, aureusLaserTargetY, type, damage, 0f, Main.myPlayer);
for (int i = 0; i < 4; i++)
{
Vector2 offset = new Vector2(Main.rand.Next(-6, 7), Main.rand.Next(-6, 7));
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, aureusLaserTargetX + offset.X, aureusLaserTargetY + offset.Y, type, damage, 0f, Main.myPlayer);
}
}
slimePhase = 1;
}
}
RevengeanceAndDeathAI.BuffedMimicAI(NPC, Mod);
NPC.noGravity = false;
NPC.noTileCollide = false;
return;
}
else
{
NPC.noGravity = true;
}
// Emit light when not Idle
if (NPC.ai[0] != 1f)
Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1.3f, 0.5f, 0f);
// Fire projectiles while walking, teleporting, or falling
if (NPC.ai[0] == 2f || NPC.ai[0] >= 5f)
{
if (!dontAttack)
NPC.localAI[0] += NPC.ai[0] == 2f ? 1f : astralFlameBarrageTimerIncrement;
float astralFlameBarrageGateValue = phase4 ? 30f : 60f;
if (NPC.localAI[0] >= astralFlameBarrageGateValue)
{
// Fire astral flames while teleporting
if (NPC.ai[0] >= 5f && NPC.ai[0] != 7)
{
NPC.localAI[0] = 0f;
SoundEngine.PlaySound(FlameCrystalSound, NPC.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float velocity = death ? (8f + NPC.localAI[2] * 0.025f) : 7f;
int type = ModContent.ProjectileType<AstralFlame>();
int damage = NPC.GetProjectileDamage(type);
float spreadLimit = (phase4 ? 100f : 50f) + enrageScale * 50f;
float randomSpread = (Main.rand.NextFloat() - 0.5f) * spreadLimit;
Vector2 spawnVector = new Vector2(NPC.Center.X, NPC.Center.Y - 80f * NPC.scale);
Vector2 destination = new Vector2(spawnVector.X + randomSpread, spawnVector.Y - 100f * NPC.scale);
Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, Vector2.Normalize(destination - spawnVector) * velocity, type, damage, 0f, Main.myPlayer);
}
}
}
float laserBarrageGateValue = phase5 ? 160f : phase3 ? 120f : phase2 ? 80f : 60f;
if (NPC.localAI[0] >= laserBarrageGateValue)
{
// Fire astral lasers while walking
if (NPC.ai[0] == 2f)
{
NPC.localAI[0] = 0f;
SoundEngine.PlaySound(LaserSound, NPC.Center);
if (calamityGlobalNPC.newAI[2] == 0f)
{
calamityGlobalNPC.newAI[2] = 1f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int maxProjectiles = !phase2 ? (bossRush ? 5 : 3) : (bossRush ? 7 : 5);
int spread = !phase2 ? (bossRush ? 11 : 8) : (bossRush ? 12 : 10);
int type = ModContent.ProjectileType<AstralLaser>();
int damage = NPC.GetProjectileDamage(type);
Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * walkingProjectileVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f);
}
if (phase3)
{
float flameVelocity = walkingProjectileVelocity;
maxProjectiles = 2;
spread = 45;
type = ModContent.ProjectileType<AstralFlame>();
damage = NPC.GetProjectileDamage(type);
projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * flameVelocity;
rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer);
}
}
}
}
else
{
calamityGlobalNPC.newAI[2] = 0f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 19 : death ? 17 : 15);
int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20);
int type = ModContent.ProjectileType<AstralLaser>();
int damage = NPC.GetProjectileDamage(type);
int centralLaser = maxProjectiles / 2;
int[] lasersToNotFire = new int[6] { centralLaser - 3, centralLaser - 2, centralLaser - 1, centralLaser + 1, centralLaser + 2, centralLaser + 3 };
Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * walkingProjectileVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3] && i != lasersToNotFire[4] && i != lasersToNotFire[5])
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f);
}
}
}
}
}
}
}
else
NPC.localAI[0] = 0f;
// Start up
if (NPC.ai[0] == 0f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.ai[0] = 1f;
NPC.netUpdate = true;
CustomGravity();
}
// Idle
else if (NPC.ai[0] == 1f)
{
// Avoid cheap bullshit
NPC.damage = 0;
// Slow down
NPC.velocity.X *= 0.8f;
// Stay vulnerable for 3 seconds
NPC.ai[1] += 1f;
if (NPC.Distance(player.Center) < 240f)
NPC.ai[1] += death ? 4f : expertMode ? 2f : 1f;
if (NPC.ai[1] >= 180f || bossRush)
{
// Set AI to random state and reset other AI arrays
NPC.TargetClosest();
switch (Main.rand.Next(phase3 ? 3 : 2))
{
case 0:
NPC.ai[0] = 2f;
break;
case 1:
NPC.ai[0] = 3f;
break;
case 2:
NPC.ai[0] = 5f;
break;
default:
break;
}
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
// Stop colliding with tiles if entering walking phase
NPC.noTileCollide = NPC.ai[0] == 2f;
NPC.netUpdate = true;
}
else
CustomGravity();
}
// Walk
else if (NPC.ai[0] == 2f)
{
// Avoid cheap bullshit
NPC.damage = 0;
// Set walking direction
if (Math.Abs(NPC.Center.X - player.Center.X) < 200f * NPC.scale)
{
NPC.velocity.X *= 0.8f;
if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1)
NPC.velocity.X = 0f;
}
else
{
float playerLocation = NPC.Center.X - player.Center.X;
NPC.direction = playerLocation < 0 ? 1 : -1;
if (NPC.direction > 0)
NPC.velocity.X = (NPC.velocity.X * 20f + walkingVelocity) / 21f;
if (NPC.direction < 0)
NPC.velocity.X = (NPC.velocity.X * 20f - walkingVelocity) / 21f;
}
if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && player.position.Y <= NPC.position.Y + NPC.height && !NPC.collideX)
{
CustomGravity();
NPC.noTileCollide = false;
}
else
{
NPC.noTileCollide = true;
// Walk through tiles if colliding with tiles and player is out of reach
int aureusHitboxWidth = 80;
int aureusHitboxHeight = 20;
Vector2 aureusHitboxTileCollideSize = new Vector2(NPC.Center.X - (aureusHitboxWidth / 2), NPC.position.Y + NPC.height - aureusHitboxHeight);
bool nearPlayerWalkingThroughTiles = false;
if (NPC.position.X < player.position.X && NPC.position.X + NPC.width > player.position.X + player.width && NPC.position.Y + NPC.height < player.position.Y + player.height - 16f)
nearPlayerWalkingThroughTiles = true;
if (nearPlayerWalkingThroughTiles)
{
NPC.velocity.Y += 0.5f;
}
else if (Collision.SolidCollision(aureusHitboxTileCollideSize, aureusHitboxWidth, aureusHitboxHeight))
{
if (NPC.velocity.Y > 0f)
NPC.velocity.Y = 0f;
if (NPC.velocity.Y > -0.2)
NPC.velocity.Y -= 0.025f;
else
NPC.velocity.Y -= 0.2f;
if (NPC.velocity.Y < -4f)
NPC.velocity.Y = -4f;
}
else
{
if (NPC.velocity.Y < 0f)
NPC.velocity.Y = 0f;
if (NPC.velocity.Y < 0.1)
NPC.velocity.Y += 0.025f;
else
NPC.velocity.Y += 0.5f;
}
}
// Walk for a maximum of 6 seconds
if (!dontAttack)
{
NPC.ai[1] += 1f;
if (NPC.Distance(player.Center) < 240f)
NPC.ai[1] += death ? 4f : expertMode ? 2f : 1f;
}
if (NPC.ai[1] >= ((bossRush ? 270f : 360f) - (death ? 90f * (1f - lifeRatio) : 0f)))
{
// Collide with tiles again
NPC.noTileCollide = false;
// Set AI to next phase (Jump) and reset other AI
NPC.TargetClosest();
NPC.ai[0] = exhausted ? 1f : 3f;
NPC.ai[1] = 0f;
NPC.ai[2] += 1f;
NPC.netUpdate = true;
}
// Limit downward velocity
if (NPC.velocity.Y > 10f)
NPC.velocity.Y = 10f;
}
// Jump
else if (NPC.ai[0] == 3f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.noTileCollide = false;
if (NPC.velocity.Y == 0f)
{
// Slow down
NPC.velocity.X *= 0.8f;
// Half second delay before jumping
if (!dontAttack)
NPC.ai[1] += 1f;
if (NPC.ai[1] >= 30f)
{
NPC.ai[1] = -20f;
}
else if (NPC.ai[1] == -1f)
{
// Set damage
NPC.damage = NPC.defDamage;
// Set jump velocity, reset and set AI to next phase (Stomp)
float distanceFromPlayerOnXAxis = NPC.Center.X - player.Center.X;
NPC.direction = distanceFromPlayerOnXAxis < 0 ? 1 : -1;
calamityGlobalNPC.newAI[3] = NPC.direction;
// The limit for how much Aureus can multiply its jump velocity
float speedMultLimit = 1f;
// Maxes out when the player is a full 2000 pixels away from or above Aureus
float multiplier = 1f / 2000f;
// Increase Aureus jump velocity X if it's far enough away from the player
float distanceAwayFromTarget = Math.Abs(distanceFromPlayerOnXAxis);
float distanceGateValue = 400f;
bool increaseJumpVelocityX = distanceAwayFromTarget > distanceGateValue && expertMode;
if (increaseJumpVelocityX)
{
calamityGlobalNPC.newAI[0] = (distanceAwayFromTarget - distanceGateValue) * multiplier;
if (calamityGlobalNPC.newAI[0] > speedMultLimit)
calamityGlobalNPC.newAI[0] = speedMultLimit;
}
// Increase Aureus jump velocity Y if it's far enough above the player
float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f);
bool increaseJumpVelocityY = distanceBelowTarget > 0f && revenge;
if (increaseJumpVelocityY)
{
calamityGlobalNPC.newAI[1] = distanceBelowTarget * multiplier;
if (calamityGlobalNPC.newAI[1] > speedMultLimit)
calamityGlobalNPC.newAI[1] = speedMultLimit;
}
float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 27f : 20f;
velocity += 6f * enrageScale;
if (expertMode)
velocity += death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio);
if (CalamityWorld.LegendaryMode)
velocity *= 1.15f;
NPC.velocity = (new Vector2(player.Center.X, player.Center.Y - 500f) - NPC.Center).SafeNormalize(Vector2.Zero) * velocity;
NPC.velocity *= new Vector2(calamityGlobalNPC.newAI[0] + 1f, calamityGlobalNPC.newAI[1] + 1f);
NPC.noTileCollide = true;
NPC.ai[0] = 4f;
NPC.ai[1] = 0f;
SoundEngine.PlaySound(JumpSound, NPC.Center);
NPC.netUpdate = true;
}
}
// Don't run custom gravity when starting a jump
if (NPC.ai[0] != 4f)
CustomGravity();
}
// Stomp
else if (NPC.ai[0] == 4f)
{
if (NPC.velocity.Y == 0f)
{
// Avoid cheap bullshit
NPC.damage = 0;
// Play stomp sound. Gotta specify the filepath to avoid confusion between the namespace and NPC
SoundStyle soundToPlay = Main.zenithWorld ? ExoMechs.Ares.AresGaussNuke.NukeExplosionSound : StompSound;
SoundEngine.PlaySound(soundToPlay, NPC.Center);
if (Main.zenithWorld)
{
float screenShakePower = 16 * Utils.GetLerpValue(1300f, 0f, NPC.Distance(Main.LocalPlayer.Center), true);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower)
Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower;
}
// Stomp and jump again, if stomped twice then reset and set AI to next phase (Teleport or Idle)
NPC.TargetClosest();
NPC.localAI[1] += 1f;
float maxStompAmt = phase5 ? 5f : phase3 ? 2f : 3f;
if (NPC.localAI[1] >= maxStompAmt)
{
NPC.ai[0] = exhausted ? 1f : (phase3 ? 5f : 2f);
NPC.localAI[1] = 0f;
NPC.ai[2] += 1f;
NPC.ai[3] = 0f;
NPC.noTileCollide = false;
NPC.netUpdate = true;
}
else
{
float playerLocation = NPC.Center.X - player.Center.X;
NPC.direction = playerLocation < 0 ? 1 : -1;
NPC.ai[0] = 3f;
NPC.ai[3] = 0f;
NPC.netUpdate = true;
}
calamityGlobalNPC.newAI[0] = 0f;
calamityGlobalNPC.newAI[1] = 0f;
calamityGlobalNPC.newAI[3] = 0f;
// Spawn dust for visual effect
for (int i = (int)NPC.position.X - 20; i < (int)NPC.position.X + NPC.width + 40; i += 20)
{
for (int j = 0; j < 4; j++)
{
int stompDust = Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y + NPC.height), NPC.width + 20, 4, ModContent.DustType<AstralOrange>(), 0f, 0f, 100, default, 1.5f);
Main.dust[stompDust].velocity *= 0.2f;
}
}
// Fire lasers or flames on stomp
SoundEngine.PlaySound(LaserSound, NPC.Center);
if (Main.zenithWorld)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = Main.rand.NextBool() ? ModContent.ProjectileType<AstralLaser>() : ModContent.ProjectileType<AstralFlame>();
int damage = NPC.GetProjectileDamage(type);
int totalProjectiles = bossRush ? 14 : death ? 12 : revenge ? 10 : expertMode ? 8 : 6;
float radians = MathHelper.TwoPi / totalProjectiles;
float velocity = 10f;
Vector2 spinningPoint = new Vector2(0f, -velocity);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f);
}
}
}
else if (calamityGlobalNPC.newAI[2] == 0f && phase2)
{
calamityGlobalNPC.newAI[2] = 1f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float flameVelocity = 6f;
int maxProjectiles = bossRush ? 4 : death ? 3 : 2;
int spread = bossRush ? 36 : death ? 28 : 20;
int type = ModContent.ProjectileType<AstralFlame>();
int damage = NPC.GetProjectileDamage(type);
Vector2 spawnVector = new Vector2(NPC.Center.X, NPC.Center.Y - 80f * NPC.scale);
Vector2 destination = new Vector2(spawnVector.X, spawnVector.Y + 100f * NPC.scale);
Vector2 projectileVelocity = Vector2.Normalize(destination - spawnVector) * flameVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector + Vector2.Normalize(perturbedSpeed) * 100f, perturbedSpeed, type, damage, 0f, Main.myPlayer);
}
}
}
else
{
calamityGlobalNPC.newAI[2] = 0f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float laserVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 7f : death ? 6f : 5f;
int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 17 : death ? 15 : 13);
int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20);
int type = ModContent.ProjectileType<AstralLaser>();
int damage = NPC.GetProjectileDamage(type);
int[] lasersToNotFire = new int[4] { 1, 3, maxProjectiles - 2, maxProjectiles - 4 };
Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * laserVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3])
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, laserVelocity * 2f);
}
}
}
}
}
else
{
// Set damage
NPC.damage = NPC.defDamage;
// Set velocities while falling, this happens before the stomp
// Fall through
if (!player.dead)
{
if ((player.position.Y > NPC.Bottom.Y && NPC.velocity.Y > 0f) || (player.position.Y < NPC.Bottom.Y && NPC.velocity.Y < 0f))
NPC.noTileCollide = true;
else if ((NPC.velocity.Y > 0f && NPC.Bottom.Y > Main.player[NPC.target].Top.Y) || (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)))
NPC.noTileCollide = false;
}
if (NPC.position.X < player.position.X && NPC.position.X + NPC.width > player.position.X + player.width)
{
// Make sure Aureus falls quickly when directly on top of or below the player
if (NPC.ai[3] < 30f)
NPC.ai[3] = 30f;
NPC.velocity.X *= 0.8f;
if (NPC.Bottom.Y < player.position.Y)
{
// Make sure Aureus falls rather quickly
if (NPC.velocity.Y < -3f)
NPC.velocity.Y = -3f;
float fallSpeed = 1.2f;
fallSpeed += 0.36f * enrageScale;
if (expertMode)
fallSpeed += death ? 0.36f * (1f - lifeRatio) : 0.24f * (1f - lifeRatio);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
fallSpeed += 0.5f;
if (calamityGlobalNPC.newAI[1] > 0f)
fallSpeed *= calamityGlobalNPC.newAI[1] + 1f;
NPC.velocity.Y += fallSpeed;
}
}
else
{
// Push Aureus towards the player on the X axis if he's not directly on top of or below the player
float velocityXChange = 0.2f + Math.Abs(NPC.Center.X - player.Center.X) * 0.0001f;
velocityXChange += 0.1f * enrageScale;
if (calamityGlobalNPC.newAI[0] > 0f)
velocityXChange *= calamityGlobalNPC.newAI[0] + 1f;
if (NPC.direction < 0)
NPC.velocity.X -= velocityXChange;
else if (NPC.direction > 0)
NPC.velocity.X += velocityXChange;
float velocityXCap = 12f;
velocityXCap += 3.6f * enrageScale;
if (expertMode)
velocityXCap += death ? 3.6f * (1f - lifeRatio) : 2.4f * (1f - lifeRatio);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
velocityXCap += 5f;
if (calamityGlobalNPC.newAI[0] > 0f)
velocityXCap *= calamityGlobalNPC.newAI[0] + 1f;
float playerLocation = NPC.Center.X - player.Center.X;
int directionRelativeToTarget = playerLocation < 0 ? 1 : -1;
bool slowDown = directionRelativeToTarget != calamityGlobalNPC.newAI[3];
if (slowDown)
velocityXCap *= 0.333f;
if (NPC.velocity.X < -velocityXCap)
NPC.velocity.X = -velocityXCap;
if (NPC.velocity.X > velocityXCap)
NPC.velocity.X = velocityXCap;
}
// Don't start falling quickly until half a second has passed
NPC.ai[3] += 1f;
if (NPC.ai[3] > 30f)
CustomGravity();
}
}
// Teleport
else if (NPC.ai[0] == 5f)
{
// Avoid cheap bullshit
NPC.damage = 0;
// Slow down
NPC.velocity.X *= 0.8f;
// Start teleport
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.localAI[1] += 1f;
if (death)
NPC.localAI[2] += 1.25f;
if (phase4)
{
NPC.localAI[1] += 1f;
if (death)
NPC.localAI[2] += 1.25f;
}
if (NPC.localAI[1] >= (bossRush ? 60f : death ? 180f : 240f))
{
// Reset localAI and find a teleport destination
NPC.TargetClosest();
NPC.localAI[1] = 0f;
Vector2 vectorAimedAheadOfTarget = Main.player[NPC.target].Center + new Vector2((float)Math.Round(Main.player[NPC.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1000f;
Point point4 = vectorAimedAheadOfTarget.ToTileCoordinates();
int teleportTries = 0;
while (teleportTries < 100)
{
teleportTries++;
int teleportTileX = Main.rand.Next(point4.X - 5, point4.X + 6);
int teleportTileY = Main.rand.Next(point4.Y - 5, point4.Y);
if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile)
{
NPC.ai[1] = teleportTileX * 16 + 8;
NPC.ai[3] = teleportTileY * 16 + 16;
break;
}
}
// Default teleport if the above conditions aren't met in 100 iterations
if (teleportTries >= 100)
{
Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom;
NPC.ai[1] = bottom.X;
NPC.ai[3] = bottom.Y;
}
// Set AI to next phase (Mid-teleport)
NPC.ai[0] = 6f;
NPC.netUpdate = true;
}
}
CustomGravity();
}
// Mid-teleport
else if (NPC.ai[0] == 6f)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (death)
NPC.localAI[2] += 1.25f;
if (phase4)
{
if (death)
NPC.localAI[2] += 1.25f;
}
// Turn invisible
NPC.alpha += 10;
if (NPC.alpha >= 255)
{
// Set position to teleport destination
NPC.Bottom = new Vector2(NPC.ai[1], NPC.ai[3]);
// Reset alpha and set AI to next phase (End of teleport)
NPC.alpha = 255;
NPC.ai[0] = 7f;
NPC.localAI[2] = 0f;
NPC.netUpdate = true;
}
// Play sound for cool effect
if (NPC.soundDelay == 0)
{
NPC.soundDelay = 15;
SoundEngine.PlaySound(TeleportSound, NPC.Center);
}
// Emit dust to make the teleport pretty
for (int i = 0; i < 10; i++)
{
int teleportDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, ModContent.DustType<AstralOrange>(), NPC.velocity.X, NPC.velocity.Y, 255, default, 2f);
Main.dust[teleportDust].noGravity = true;
Main.dust[teleportDust].velocity *= 0.5f;
}
CustomGravity();
}
// End of teleport
else if (NPC.ai[0] == 7f)
{
// Avoid cheap bullshit
NPC.damage = 0;
// Turn visible
NPC.alpha -= 10;
if (NPC.alpha <= 0)
{
// Spawn Aureus Spawns
bool spawnFlag = expertMode;
if (NPC.CountNPCS(ModContent.NPCType<AureusSpawn>()) >= 2)
spawnFlag = false;
if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient)
{
int aureusSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y - 25f * NPC.scale), ModContent.NPCType<AureusSpawn>());
Main.npc[aureusSpawn].velocity.Y = -10f;
Main.npc[aureusSpawn].netUpdate = true;
if (revenge)
{
aureusSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y - 25f * NPC.scale), ModContent.NPCType<AureusSpawn>());
Main.npc[aureusSpawn].velocity.Y = -15f;
Main.npc[aureusSpawn].netUpdate = true;
}
if (death)
{
int damageAmt = NPC.lifeMax / 50;
NPC.life -= damageAmt;
if (NPC.life < 1)
NPC.life = 1;
NPC.DamageEffect(damageAmt);
}
}
// Reset alpha and set AI to next phase (Idle)
NPC.alpha = 0;
NPC.ai[0] = exhausted ? 1f : 2f;
NPC.ai[1] = 0f;
NPC.ai[2] += 1f;
NPC.localAI[3] = noProjectileOrPhaseIncrementTime;
// Stop colliding with tiles if entering walking phase
NPC.noTileCollide = NPC.ai[0] == 2f;
NPC.netUpdate = true;
}
// Play sound at teleport destination for cool effect
if (NPC.soundDelay == 0)
{
NPC.soundDelay = 15;
SoundEngine.PlaySound(SoundID.Item109, NPC.Center);
}
// Emit dust to make the teleport pretty
for (int i = 0; i < 10; i++)
{
int teleportDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, ModContent.DustType<AstralOrange>(), NPC.velocity.X, NPC.velocity.Y, 255, default, 2f);
Main.dust[teleportDust].noGravity = true;
Main.dust[teleportDust].velocity *= 0.5f;
}
CustomGravity();
}
void CustomGravity()
{
float gravity = 0.36f + 0.12f * enrageScale;
float maxFallSpeed = reduceFallSpeed ? 12f : 12f + 4f * enrageScale;
if (calamityGlobalNPC.newAI[1] > 0f && !reduceFallSpeed)
maxFallSpeed *= calamityGlobalNPC.newAI[1] + 1f;
if (CalamityWorld.LegendaryMode && !reduceFallSpeed)
{
gravity *= 1.15f;
maxFallSpeed *= 1.15f;
}
NPC.velocity.Y += gravity;
if (NPC.velocity.Y > maxFallSpeed)
NPC.velocity.Y = maxFallSpeed;
}
}
public override void FindFrame(int frameHeight)
+2 -2
View File
@@ -308,11 +308,11 @@ namespace CalamityMod.NPCs.AstrumAureus
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int totalProjectiles = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 36 : (3 + (int)((NPC.scale - 1f) * 3));
int totalProjectiles = CalamityWorld.LegendaryMode ? 36 : (3 + (int)((NPC.scale - 1f) * 3));
double radians = MathHelper.TwoPi / totalProjectiles;
int type = ModContent.ProjectileType<AstralLaser>();
int damage2 = NPC.GetProjectileDamage(type);
float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : 6f;
float velocity = CalamityWorld.LegendaryMode ? 10f : 6f;
double angleA = radians * 0.5;
double angleB = MathHelper.ToRadians(90f) - angleA;
float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB));
+331 -4
View File
@@ -1,13 +1,16 @@
using System.IO;
using System;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
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.ID;
using Terraria.Localization;
@@ -112,7 +115,331 @@ namespace CalamityMod.NPCs.AstrumDeus
public override void AI()
{
AstrumDeusAI.VanillaAstrumDeusAI(NPC, Mod, false);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
// Difficulty variables
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
float enrageScale = bossRush ? 0.5f : 0f;
if (Main.IsItDay() || bossRush)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1.5f;
}
// Deus cannot hit for 3 seconds or while invulnerable
bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || NPC.dontTakeDamage;
if (doNotDealDamage)
NPC.damage = 0;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool increaseSpeed = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles;
bool increaseSpeedMore = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
// Inflict Extreme Gravity to nearby players
if (revenge)
{
if (!Main.dedServ)
{
if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles)
Main.LocalPlayer.AddBuff(ModContent.BuffType<DoGExtremeGravity>(), 2);
}
}
// Life
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases based on life percentage
bool halfHealth = lifeRatio < 0.5f;
bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f;
bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase;
bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode;
bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode;
bool splittingMines = lifeRatio < 0.7f;
bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode;
bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f;
bool deathModeEnragePhase_BodyAndTail = false;
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
float resistanceTime = doubleWormPhase ? 300f : 600f;
calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime;
// Flight timer
float aiSwitchTimer = doubleWormPhase ? (CalamityWorld.LegendaryMode ? 600f : 1200f) : (CalamityWorld.LegendaryMode ? 900f : 1800f);
calamityGlobalNPC.newAI[3] += 1f;
if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer)
calamityGlobalNPC.newAI[3] = 0f;
// Sound effect for swapping between attack behaviors in phase 2
if (doubleWormPhase && calamityGlobalNPC.newAI[3] % aiSwitchTimer == 0f && !(deathModeEnragePhase_Head || deathModeEnragePhase_BodyAndTail))
SoundEngine.PlaySound(AstrumDeusHead.SplitSound with { Pitch = -0.2f, Volume = 0.9f }, player.Center);
// Phase for flying at the player
bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase;
// Length of worms
int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50;
int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25;
int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5;
int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length;
// Become gradually more pissed as more worms are killed
int gfbMaxWormCount = 10;
int gfbWormCount = 0;
if (CalamityWorld.LegendaryMode && revenge)
gfbWormCount = NPC.CountNPCS(ModContent.NPCType<AstrumDeusHead>());
if (gfbWormCount > gfbMaxWormCount)
gfbWormCount = gfbMaxWormCount;
if (gfbWormCount > 0)
enrageScale += (gfbMaxWormCount - gfbWormCount) * 0.111f;
// Copy dontTakeDamage and Opacity from head
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity;
deathModeEnragePhase_BodyAndTail = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f;
if (deathModeEnragePhase_BodyAndTail)
{
NPC.defense = 25;
calamityGlobalNPC.DR = 0.15f;
}
// Set worm variable
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Alpha effects
if (Main.npc[(int)NPC.ai[1]].alpha < 128 && !NPC.dontTakeDamage)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
int headType = ModContent.NPCType<AstrumDeusHead>();
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].type != headType || !Main.npc[i].active)
continue;
shouldDespawn = false;
break;
}
if (shouldDespawn)
{
if (Main.npc.IndexInRange((int)NPC.ai[1]) && Main.npc[(int)NPC.ai[1]].active && Main.npc[(int)NPC.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
NPC.ForceNetUpdate(false);
}
// Direction
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
if (NPC.life > Main.npc[(int)NPC.ai[1]].life)
NPC.life = Main.npc[(int)NPC.ai[1]].life;
bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning
float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f;
float segmentVelocityBoost = 5f * (1f - lifeRatio);
segmentVelocity += segmentVelocityBoost;
segmentVelocity += 4f * enrageScale;
if (revenge)
{
float revMultiplier = 1.1f;
segmentVelocity *= revMultiplier;
}
// Shoot lasers
NPC.localAI[0] += 1f;
int shootTime = (doubleWormPhase && expertMode) ? 2 : 1;
float shootProjectile = (doubleWormPhase && expertMode) ? 200 : 400;
float timer = NPC.ai[0] + 15f;
float divisor = timer + shootProjectile;
bool canFireProjectiles = NPC.Opacity >= 1f;
bool shootGodRays = phase2 || deathModeEnragePhase_BodyAndTail;
if (canFireProjectiles)
{
if (!flyAtTarget || deathModeEnragePhase_BodyAndTail)
{
float laserDivisor = (phase2 && !deathModeEnragePhase_BodyAndTail) ? 4f : 2f;
if (NPC.localAI[0] % divisor == 0f && NPC.ai[0] % laserDivisor == 0f)
{
NPC.TargetClosest();
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (deathModeEnragePhase_BodyAndTail)
{
Vector2 velocity = Vector2.Zero;
if (movingMines)
{
Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
randomMineMovement.Normalize();
randomMineMovement *= Main.rand.Next(90, 121) * 0.01f;
velocity = randomMineMovement;
}
int type = ModContent.ProjectileType<DeusMine>();
int damage = NPC.GetProjectileDamage(type);
float split = (splittingMines && NPC.ai[0] % 3f == 0f) ? 1f : 0f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f);
}
}
if (Vector2.Distance(player.Center, NPC.Center) > 80f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float deusLaserSpeed = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f;
Vector2 deusLaserCenter = NPC.Center;
float deusLaserTargetX = player.Center.X - deusLaserCenter.X;
float deusLaserTargetY = player.Center.Y - deusLaserCenter.Y;
float deusLaserTargetDist = (float)Math.Sqrt(deusLaserTargetX * deusLaserTargetX + deusLaserTargetY * deusLaserTargetY);
deusLaserTargetDist = deusLaserSpeed / deusLaserTargetDist;
deusLaserTargetX *= deusLaserTargetDist;
deusLaserTargetY *= deusLaserTargetDist;
deusLaserCenter.X += deusLaserTargetX * 5f;
deusLaserCenter.Y += deusLaserTargetY * 5f;
Vector2 shootDirection = new Vector2(deusLaserTargetX, deusLaserTargetY).SafeNormalize(Vector2.UnitY);
Vector2 laserVelocity = shootDirection * deusLaserSpeed;
int type = shootGodRays ? ModContent.ProjectileType<AstralGodRay>() : ModContent.ProjectileType<AstralShot2>();
int damage = NPC.GetProjectileDamage(type);
if (shootGodRays)
{
SoundEngine.PlaySound(AstrumDeusHead.GodRaySound, NPC.Center);
// Waving beams need to start offset so they cross each other neatly.
float waveSideOffset = Main.rand.NextFloat(9f, 14f);
Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset;
for (int i = -1; i <= 1; i += 2)
{
Vector2 laserStartPos = deusLaserCenter + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f);
Projectile godRay = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), laserStartPos, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y);
// Tell this Phased God Ray exactly which way it should be waving.
godRay.localAI[1] = i * 0.5f;
}
}
else
{
SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center);
Projectile.NewProjectile(NPC.GetSource_FromAI(), deusLaserCenter, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y);
}
}
}
}
}
else
{
if (NPC.localAI[0] % divisor == 0f && NPC.ai[0] % 2f == 0f)
{
Vector2 velocity = Vector2.Zero;
if (movingMines)
{
Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
randomMineMovement.Normalize();
randomMineMovement *= Main.rand.Next(30, 121) * 0.01f;
velocity = randomMineMovement;
}
int type = ModContent.ProjectileType<DeusMine>();
int damage = NPC.GetProjectileDamage(type);
float split = (splittingMines && NPC.ai[0] % 3f == 0f) ? 1f : 0f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f);
}
}
}
// Follow the head
Vector2 segmentCenter = NPC.Center;
float segmentTargetX = player.Center.X;
float segmentTargetY = player.Center.Y;
segmentTargetX = (int)(segmentTargetX / 16f) * 16;
segmentTargetY = (int)(segmentTargetY / 16f) * 16;
segmentCenter.X = (int)(segmentCenter.X / 16f) * 16;
segmentCenter.Y = (int)(segmentCenter.Y / 16f) * 16;
segmentTargetX -= segmentCenter.X;
segmentTargetY -= segmentCenter.Y;
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
segmentCenter = NPC.Center;
segmentTargetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentCenter.X;
segmentTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentCenter.Y;
}
catch
{
}
NPC.rotation = (float)Math.Atan2(segmentTargetY, segmentTargetX) + MathHelper.PiOver2;
float segmentTargetDist = (float)Math.Sqrt(segmentTargetX * segmentTargetX + segmentTargetY * segmentTargetY);
int segmentWidth = NPC.width;
segmentTargetDist = (segmentTargetDist - segmentWidth) / segmentTargetDist;
segmentTargetX *= segmentTargetDist;
segmentTargetY *= segmentTargetDist;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + segmentTargetX;
NPC.position.Y = NPC.position.Y + segmentTargetY;
if (segmentTargetX < 0f)
NPC.spriteDirection = -1;
else if (segmentTargetX > 0f)
NPC.spriteDirection = 1;
}
// Play spawn sound on Deus on the first frame because otherwise the sound wouldn't play properly in multiplayer
if (calamityGlobalNPC.newAI[1] == 0f && !doubleWormPhase)
{
SoundEngine.PlaySound(AstrumDeusHead.SpawnSound, NPC.Center);
calamityGlobalNPC.newAI[1] = 1f;
}
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
if (calamityGlobalNPC.newAI[1] < resistanceTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 1f))
calamityGlobalNPC.newAI[1] += 1f;
// Calculate contact damage based on velocity
if (!doNotDealDamage)
{
float minimalContactDamageVelocity = segmentVelocity * 0.25f;
float minimalDamageVelocity = segmentVelocity * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
NPC.damage = 0;
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
@@ -130,7 +457,7 @@ namespace CalamityMod.NPCs.AstrumDeus
// Need segment amount to get a smooth transition down the worm based on length
int segmentAmt = Main.zenithWorld ? (CalamityWorld.death ? 8 : CalamityWorld.revenge ? 7 : Main.expertMode ? 6 : 5) : (CalamityWorld.death ? 40 : CalamityWorld.revenge ? 35 : Main.expertMode ? 30 : 25);
float cyanThreshold = Main.getGoodWorld ? 300f : 600f;
float cyanThreshold = CalamityWorld.LegendaryMode ? 300f : 600f;
float transitionStart = MathHelper.Lerp(cyanThreshold * 0.75f, cyanThreshold * 0.95f, 1f - (NPC.ai[3] / (float)segmentAmt));
float transitionEnd = MathHelper.Lerp(cyanThreshold * 0.8f, cyanThreshold, 1f - (NPC.ai[3] / (float)segmentAmt));
bool drawCyan = NPC.Calamity().newAI[3] >= transitionEnd && NPC.Calamity().newAI[3] <= cyanThreshold + transitionEnd;
+652 -7
View File
@@ -1,6 +1,7 @@
using System.IO;
using CalamityMod.BiomeManagers;
using System;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.Items.Accessories;
@@ -17,8 +18,7 @@ using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Packets;
using CalamityMod.UI.VanillaBossBars;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -149,7 +149,652 @@ namespace CalamityMod.NPCs.AstrumDeus
public override void AI()
{
AstrumDeusAI.VanillaAstrumDeusAI(NPC, Mod, true);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
// Difficulty variables
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
float enrageScale = bossRush ? 0.5f : 0f;
if (Main.IsItDay() || bossRush)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1.5f;
}
// Deus cannot hit for 3 seconds or while invulnerable
bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || NPC.dontTakeDamage;
if (doNotDealDamage)
NPC.damage = 0;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool increaseSpeed = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles;
bool increaseSpeedMore = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
// Despawn safety, make sure to target another player if the current player target is too far away
if (increaseSpeedMore)
NPC.TargetClosest();
// Inflict Extreme Gravity to nearby players
if (revenge)
{
if (!Main.dedServ)
{
if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles)
Main.LocalPlayer.AddBuff(ModContent.BuffType<DoGExtremeGravity>(), 2);
}
}
// Life
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases based on life percentage
bool halfHealth = lifeRatio < 0.5f;
bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f;
bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase;
bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode;
bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode;
bool splittingMines = lifeRatio < 0.7f;
bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode;
bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f;
bool deathModeEnragePhase_BodyAndTail = false;
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
float resistanceTime = doubleWormPhase ? 300f : 600f;
calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime;
// Flight timer
float aiSwitchTimer = doubleWormPhase ? (CalamityWorld.LegendaryMode ? 600f : 1200f) : (CalamityWorld.LegendaryMode ? 900f : 1800f);
calamityGlobalNPC.newAI[3] += 1f;
if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer)
calamityGlobalNPC.newAI[3] = 0f;
// Sound effect for swapping between attack behaviors in phase 2
if (doubleWormPhase && calamityGlobalNPC.newAI[3] % aiSwitchTimer == 0f && !(deathModeEnragePhase_Head || deathModeEnragePhase_BodyAndTail))
SoundEngine.PlaySound(SplitSound with { Pitch = -0.2f, Volume = 0.9f }, player.Center);
// Phase for flying at the player
bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase;
// Length of worms
int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50;
int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25;
int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5;
int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length;
// Become gradually more pissed as more worms are killed
int gfbMaxWormCount = 10;
int gfbWormCount = 0;
if (CalamityWorld.LegendaryMode && revenge)
gfbWormCount = NPC.CountNPCS(ModContent.NPCType<AstrumDeusHead>());
if (gfbWormCount > gfbMaxWormCount)
gfbWormCount = gfbMaxWormCount;
if (gfbWormCount > 0)
enrageScale += (gfbMaxWormCount - gfbWormCount) * 0.111f;
// Split into two worms
float splitAnimationTime = 180f;
bool oneWormAlive = NPC.CountNPCS(ModContent.NPCType<AstrumDeusHead>()) < 2;
bool deathModeFinalWormEnrage = death && doubleWormPhase && oneWormAlive && calamityGlobalNPC.newAI[1] >= resistanceTime;
if (deathModeFinalWormEnrage)
{
if (calamityGlobalNPC.newAI[0] != 3f)
{
SoundEngine.PlaySound(SplitSound, player.Center);
calamityGlobalNPC.newAI[0] = 3f;
NPC.defense = 12;
calamityGlobalNPC.DR = 0.075f;
// Despawns the other deus worm segments
int bodyID = ModContent.NPCType<AstrumDeusBody>();
int tailID = ModContent.NPCType<AstrumDeusTail>();
for (int i = 0; i < Main.maxNPCs; i++)
{
NPC wormseg = Main.npc[i];
if (!wormseg.active)
continue;
if ((wormseg.type == bodyID || wormseg.type == tailID) && Main.npc[(int)wormseg.ai[2]].Calamity().newAI[0] != 3f)
{
wormseg.life = 0;
wormseg.active = false;
}
}
}
calamityGlobalNPC.newAI[2] += 10f;
if (calamityGlobalNPC.newAI[2] > 162f)
calamityGlobalNPC.newAI[2] = 162f;
NPC.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f);
}
bool despawnRemainingWorm = doubleWormPhase && oneWormAlive && !death;
if ((halfHealth && calamityGlobalNPC.newAI[0] == 0f) || despawnRemainingWorm)
{
NPC.dontTakeDamage = true;
calamityGlobalNPC.newAI[2] += despawnRemainingWorm ? 10f : 1f;
NPC.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f);
bool despawning = calamityGlobalNPC.newAI[2] == splitAnimationTime;
//
// CODE TWEAKED BY: OZZATRON
// September 20th, 2020
// reason: fixing Astrum Deus death mode NPC cap bug
//
// Despawn the unsplit Astrum Deus and spawn two half-size Astrum Deus worms.
if (despawning)
{
// If this is already a split worm (newAI[0] != 0f) then don't do anything. At all.
if (doubleWormPhase)
return;
// Mark all existing body and tail segments as inactive. This instantly frees up their NPC slots for the freshly spawned worms.
int bodyID = ModContent.NPCType<AstrumDeusBody>();
int tailID = ModContent.NPCType<AstrumDeusTail>();
for (int i = 0; i < Main.maxNPCs; i++)
{
NPC wormseg = Main.npc[i];
if (!wormseg.active)
continue;
if (wormseg.type == bodyID || wormseg.type == tailID)
{
wormseg.life = 0;
wormseg.active = false;
}
}
// The unsplit Astrum Deus worm head will die next frame.
NPC.life = 0;
// Do not spawn worms client side. The server handles this.
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int wormamt = Main.zenithWorld ? 5 : 1;
for (int i = 0; i < wormamt; i++)
{
// Now that the original worm doesn't exist, startCount can be zero.
// int startCount = NPC.whoAmI + phase1Length + 1;
int startIndexHeadOne = 1;
int headOneID = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPC.type, startIndexHeadOne);
Main.npc[headOneID].Calamity().newAI[0] = 1f;
Main.npc[headOneID].velocity = Vector2.Normalize(player.Center - Main.npc[headOneID].Center) * 16f;
Main.npc[headOneID].timeLeft *= 20;
Main.npc[headOneID].ForceNetUpdate();
// On server, immediately send the correct extra AI of this head to clients.
if (Main.dedServ)
{
SyncCalamityNPCAIArrayPacket.Send(Main.npc[headOneID]);
}
// Make sure the second split worm is also contiguous.
int startIndexHeadTwo = startIndexHeadOne + phase2Length + 1;
int headTwoID = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPC.type, startIndexHeadTwo);
Main.npc[headTwoID].Calamity().newAI[0] = 2f;
Main.npc[headTwoID].Calamity().newAI[3] = CalamityWorld.LegendaryMode ? 300f : 600f;
Main.npc[headTwoID].velocity = Vector2.Normalize(player.Center - Main.npc[headTwoID].Center) * 16f;
Main.npc[headTwoID].timeLeft *= 20;
Main.npc[headTwoID].ForceNetUpdate();
// On server, immediately send the correct extra AI of this head to clients.
if (Main.dedServ)
{
SyncCalamityNPCAIArrayPacket.Send(Main.npc[headTwoID]);
}
}
SoundEngine.PlaySound(AstrumDeusHead.SplitSound, player.Center);
}
return;
}
}
if (Main.zenithWorld && calamityGlobalNPC.newAI[1] < 10f) // desync the deuses
{
float pushForce = 0.25f;
for (int k = 0; k < Main.maxNPCs; k++)
{
NPC otherDeus = Main.npc[k];
// Short circuits to make the loop as fast as possible
if (!otherDeus.active || k == NPC.whoAmI)
continue;
// If the other projectile is indeed the same owned by the same player and they're too close, nudge them away.
bool sameProjType = otherDeus.type == NPC.type;
float taxicabDist = Vector2.Distance(NPC.Center, otherDeus.Center);
float distancegate = 320f;
if (sameProjType && taxicabDist < distancegate)
{
if (NPC.position.X < otherDeus.position.X)
NPC.velocity.X -= pushForce;
else
NPC.velocity.X += pushForce;
if (NPC.position.Y < otherDeus.position.Y)
NPC.velocity.Y -= pushForce;
else
NPC.velocity.Y += pushForce;
}
}
}
// Set worm variable
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Alpha effects
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
// Direction
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (NPC.ai[0] == 0f)
{
int Previous = NPC.whoAmI;
int bodyType = ModContent.NPCType<AstrumDeusBody>();
int tailType = ModContent.NPCType<AstrumDeusTail>();
for (int segments = 0; segments < maxLength; segments++)
{
int lol;
if (segments >= 0 && segments < maxLength - 1)
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, bodyType, NPC.whoAmI);
else
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, tailType, NPC.whoAmI);
if (segments % 2 == 0)
Main.npc[lol].localAI[3] = 1f;
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].Calamity().newAI[0] = Main.npc[Previous].Calamity().newAI[0];
Main.npc[lol].Calamity().newAI[3] = Main.npc[Previous].Calamity().newAI[3];
if (Main.dedServ)
{
SyncCalamityNPCAIArrayPacket.Send(Main.npc[lol]);
}
Main.npc[lol].ai[3] = segments + 1;
Main.npc[lol].ai[2] = NPC.whoAmI;
Main.npc[lol].ai[1] = Previous;
Main.npc[Previous].ai[0] = lol;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol);
Previous = lol;
}
}
}
if (NPC.life > Main.npc[(int)NPC.ai[0]].life)
NPC.life = Main.npc[(int)NPC.ai[0]].life;
bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning
float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f;
float segmentVelocityBoost = 5f * (1f - lifeRatio);
segmentVelocity += segmentVelocityBoost;
segmentVelocity += 4f * enrageScale;
if (revenge)
{
float revMultiplier = 1.1f;
segmentVelocity *= revMultiplier;
}
int headTilePositionX = (int)(NPC.position.X / 16f) - 1;
int headTileWidthPosX = (int)((NPC.position.X + NPC.width) / 16f) + 2;
int headTilePositionY = (int)(NPC.position.Y / 16f) - 1;
int headTileWidthPosY = (int)((NPC.position.Y + NPC.height) / 16f) + 2;
if (headTilePositionX < 0)
headTilePositionX = 0;
if (headTileWidthPosX > Main.maxTilesX)
headTileWidthPosX = Main.maxTilesX;
if (headTilePositionY < 0)
headTilePositionY = 0;
if (headTileWidthPosY > Main.maxTilesY)
headTileWidthPosY = Main.maxTilesY;
// Fly or not
bool shouldFly = flyAtTarget;
if (!shouldFly)
{
for (int k = headTilePositionX; k < headTileWidthPosX; k++)
{
for (int l = headTilePositionY; l < headTileWidthPosY; l++)
{
if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[Main.tile[k, l].TileType] || (Main.tileSolidTop[Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64))
{
Vector2 vector2;
vector2.X = k * 16f;
vector2.Y = l * 16f;
if (NPC.position.X + NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f)
{
shouldFly = true;
break;
}
}
}
}
}
// Start flying if target is not within a certain distance
if (!shouldFly)
{
NPC.localAI[1] = 1f;
Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height);
int noFlyZone = 200;
int heightReduction = death ? 130 : (int)(130f * (1f - lifeRatio));
int height = 400 - heightReduction;
bool outsideNoFlyZone = true;
if (NPC.position.Y > player.position.Y)
{
for (int m = 0; m < Main.maxPlayers; m++)
{
if (Main.player[m].active)
{
Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, height);
if (rectangle.Intersects(rectangle2))
{
outsideNoFlyZone = false;
break;
}
}
}
if (outsideNoFlyZone)
shouldFly = true;
}
}
else
NPC.localAI[1] = 0f;
// Despawn
if (player.dead)
{
shouldFly = false;
float velocity = 2f;
NPC.velocity.Y -= velocity;
if ((double)NPC.position.Y < Main.topWorld + 16f)
{
segmentVelocity *= 2f;
NPC.velocity.Y -= velocity;
}
int headType = ModContent.NPCType<AstrumDeusHead>();
int bodyType = ModContent.NPCType<AstrumDeusBody>();
int tailType = ModContent.NPCType<AstrumDeusBody>();
if ((double)NPC.position.Y < Main.topWorld + 16f)
{
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].type == headType || Main.npc[i].type == bodyType || Main.npc[i].type == tailType)
{
Main.npc[i].active = false;
Main.npc[i].ForceNetUpdate(false);
}
}
}
}
// Speed and movement
float speedBoost = death ? (0.1f * (1f - lifeRatio)) : (0.13f * (1f - lifeRatio));
float turnSpeedBoost = death ? (0.18f * (1f - lifeRatio)) : (0.2f * (1f - lifeRatio));
float speed = (hasJustSpawned ? 0.26f : deathModeEnragePhase_Head ? 0.2f : death ? 0.18f : 0.13f) + speedBoost;
float turnSpeed = (hasJustSpawned ? 0.3f : deathModeEnragePhase_Head ? 0.27f : death ? 0.25f : 0.2f) + turnSpeedBoost;
speed += 0.05f * enrageScale;
turnSpeed += 0.08f * enrageScale;
if (flyAtTarget)
{
float speedMultiplier = deathModeEnragePhase_Head ? 1.25f : doubleWormPhase ? (phase3 ? 1.25f : phase2 ? 1.2f : 1.15f) : 1f;
speed *= speedMultiplier;
}
if (revenge)
{
float revMultiplier = 1.1f;
speed *= revMultiplier;
turnSpeed *= revMultiplier;
}
speed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f;
turnSpeed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f;
if (CalamityWorld.LegendaryMode)
{
speed *= 1.15f;
turnSpeed *= 1.15f;
}
Vector2 deusCenter = NPC.Center;
float deusTargetX = player.Center.X;
float deusTargetY = player.Center.Y;
deusTargetX = (int)(deusTargetX / 16f) * 16;
deusTargetY = (int)(deusTargetY / 16f) * 16;
deusCenter.X = (int)(deusCenter.X / 16f) * 16;
deusCenter.Y = (int)(deusCenter.Y / 16f) * 16;
deusTargetX -= deusCenter.X;
deusTargetY -= deusCenter.Y;
if (!shouldFly)
{
NPC.velocity.Y += 0.15f;
if (NPC.velocity.Y > segmentVelocity)
NPC.velocity.Y = segmentVelocity;
// This bool exists to stop the strange wiggle behavior when worms are falling down
bool slowXVelocity = Math.Abs(NPC.velocity.X) > speed;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.4)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X -= speed * 1.1f;
else
NPC.velocity.X += speed * 1.1f;
}
else if (NPC.velocity.Y == segmentVelocity)
{
if (slowXVelocity)
{
if (NPC.velocity.X < deusTargetX)
NPC.velocity.X += speed;
else if (NPC.velocity.X > deusTargetX)
NPC.velocity.X -= speed;
}
else
NPC.velocity.X = 0f;
}
else if (NPC.velocity.Y > 4f)
{
if (slowXVelocity)
{
if (NPC.velocity.X < 0f)
NPC.velocity.X += speed * 0.9f;
else
NPC.velocity.X -= speed * 0.9f;
}
else
NPC.velocity.X = 0f;
}
}
else
{
float deusTargetDist = (float)Math.Sqrt(deusTargetX * deusTargetX + deusTargetY * deusTargetY);
float deusAbsoluteTargetX = Math.Abs(deusTargetX);
float deusAbsoluteTargetY = Math.Abs(deusTargetY);
float deusTimeToReachTarget = segmentVelocity / deusTargetDist;
deusTargetX *= deusTimeToReachTarget;
deusTargetY *= deusTimeToReachTarget;
bool speedUpWhileFlying = false;
if (flyAtTarget)
{
if (((NPC.velocity.X > 0f && deusTargetX < 0f) || (NPC.velocity.X < 0f && deusTargetX > 0f) || (NPC.velocity.Y > 0f && deusTargetY < 0f) || (NPC.velocity.Y < 0f && deusTargetY > 0f)) && Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) > speed / 2f && deusTargetDist < 400f)
{
speedUpWhileFlying = true;
if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < segmentVelocity)
NPC.velocity *= 1.1f;
}
if (NPC.position.Y > player.position.Y)
{
speedUpWhileFlying = true;
if (Math.Abs(NPC.velocity.X) < segmentVelocity / 2f)
{
if (NPC.velocity.X == 0f)
NPC.velocity.X -= NPC.direction;
NPC.velocity.X *= 1.1f;
}
else if (NPC.velocity.Y > -segmentVelocity)
NPC.velocity.Y -= speed;
}
}
if (!speedUpWhileFlying)
{
if (!flyAtTarget)
{
if (((NPC.velocity.X > 0f && deusTargetX > 0f) || (NPC.velocity.X < 0f && deusTargetX < 0f)) && ((NPC.velocity.Y > 0f && deusTargetY > 0f) || (NPC.velocity.Y < 0f && deusTargetY < 0f)))
{
if (NPC.velocity.X < deusTargetX)
NPC.velocity.X += turnSpeed;
else if (NPC.velocity.X > deusTargetX)
NPC.velocity.X -= turnSpeed;
if (NPC.velocity.Y < deusTargetY)
NPC.velocity.Y += turnSpeed;
else if (NPC.velocity.Y > deusTargetY)
NPC.velocity.Y -= turnSpeed;
}
}
if ((NPC.velocity.X > 0f && deusTargetX > 0f) || (NPC.velocity.X < 0f && deusTargetX < 0f) || (NPC.velocity.Y > 0f && deusTargetY > 0f) || (NPC.velocity.Y < 0f && deusTargetY < 0f))
{
if (NPC.velocity.X < deusTargetX)
NPC.velocity.X += speed;
else if (NPC.velocity.X > deusTargetX)
NPC.velocity.X -= speed;
if (NPC.velocity.Y < deusTargetY)
NPC.velocity.Y += speed;
else if (NPC.velocity.Y > deusTargetY)
NPC.velocity.Y -= speed;
if (Math.Abs(deusTargetY) < segmentVelocity * 0.2 && ((NPC.velocity.X > 0f && deusTargetX < 0f) || (NPC.velocity.X < 0f && deusTargetX > 0f)))
{
if (NPC.velocity.Y > 0f)
NPC.velocity.Y += speed * 2f;
else
NPC.velocity.Y -= speed * 2f;
}
if (Math.Abs(deusTargetX) < segmentVelocity * 0.2 && ((NPC.velocity.Y > 0f && deusTargetY < 0f) || (NPC.velocity.Y < 0f && deusTargetY > 0f)))
{
if (NPC.velocity.X > 0f)
NPC.velocity.X += speed * 2f;
else
NPC.velocity.X -= speed * 2f;
}
}
else if (deusAbsoluteTargetX > deusAbsoluteTargetY)
{
if (NPC.velocity.X < deusTargetX)
NPC.velocity.X += speed * 1.1f;
else if (NPC.velocity.X > deusTargetX)
NPC.velocity.X -= speed * 1.1f;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5)
{
if (NPC.velocity.Y > 0f)
NPC.velocity.Y += speed;
else
NPC.velocity.Y -= speed;
}
}
else
{
if (NPC.velocity.Y < deusTargetY)
NPC.velocity.Y += speed * 1.1f;
else if (NPC.velocity.Y > deusTargetY)
NPC.velocity.Y -= speed * 1.1f;
if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5)
{
if (NPC.velocity.X > 0f)
NPC.velocity.X += speed;
else
NPC.velocity.X -= speed;
}
}
}
}
if (shouldFly)
{
if (NPC.localAI[0] != 1f)
NPC.ForceNetUpdate(false);
NPC.localAI[0] = 1f;
}
else
{
if (NPC.localAI[0] != 0f)
NPC.ForceNetUpdate(false);
NPC.localAI[0] = 0f;
}
if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit)
NPC.ForceNetUpdate(false);
NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2;
// Play spawn sound on Deus on the first frame because otherwise the sound wouldn't play properly in multiplayer
if (calamityGlobalNPC.newAI[1] == 0f && !doubleWormPhase)
{
SoundEngine.PlaySound(SpawnSound, NPC.Center);
calamityGlobalNPC.newAI[1] = 1f;
}
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
if (calamityGlobalNPC.newAI[1] < resistanceTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 1f))
calamityGlobalNPC.newAI[1] += 1f;
// Calculate contact damage based on velocity
if (!doNotDealDamage)
{
float minimalContactDamageVelocity = segmentVelocity * 0.25f;
float minimalDamageVelocity = segmentVelocity * 0.5f;
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
NPC.damage = (int)Math.Round(NPC.defDamage * 0.5);
else
{
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar);
}
}
}
public override bool CheckActive()
@@ -172,7 +817,7 @@ namespace CalamityMod.NPCs.AstrumDeus
bool deathModeEnragePhase = NPC.Calamity().newAI[0] == 3f;
bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase;
float cyanThreshold = Main.getGoodWorld ? 300f : 600f;
float cyanThreshold = CalamityWorld.LegendaryMode ? 300f : 600f;
// Head is always the last segment to visually transition
float transitionStart = cyanThreshold * 0.95f;
bool drawCyan = NPC.Calamity().newAI[3] >= cyanThreshold;
@@ -274,7 +919,7 @@ namespace CalamityMod.NPCs.AstrumDeus
public override void BossLoot(ref string name, ref int potionType) => potionType = ModContent.ItemType<StarblightSoot>();
public static bool ShouldNotDropThings(NPC npc) => npc.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && npc.Calamity().newAI[0] != 3f);
public static bool ShouldNotDropThings(NPC NPC) => NPC.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.Calamity().newAI[0] != 3f);
public override bool SpecialOnKill()
{
+224 -4
View File
@@ -1,13 +1,15 @@
using System.IO;
using System;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
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.ID;
using Terraria.Localization;
@@ -96,7 +98,225 @@ namespace CalamityMod.NPCs.AstrumDeus
public override void AI()
{
AstrumDeusAI.VanillaAstrumDeusAI(NPC, Mod, false);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
// Difficulty variables
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
float enrageScale = bossRush ? 0.5f : 0f;
if (Main.IsItDay() || bossRush)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1.5f;
}
// Deus cannot hit for 3 seconds or while invulnerable
bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || NPC.dontTakeDamage;
if (doNotDealDamage)
NPC.damage = 0;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool increaseSpeed = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles;
bool increaseSpeedMore = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
// Inflict Extreme Gravity to nearby players
if (revenge)
{
if (!Main.dedServ)
{
if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles)
Main.LocalPlayer.AddBuff(ModContent.BuffType<DoGExtremeGravity>(), 2);
}
}
// Life
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases based on life percentage
bool halfHealth = lifeRatio < 0.5f;
bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f;
bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase;
bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode;
bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode;
bool splittingMines = lifeRatio < 0.7f;
bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode;
bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f;
bool deathModeEnragePhase_BodyAndTail = false;
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
float resistanceTime = doubleWormPhase ? 300f : 600f;
calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime;
// Flight timer
float aiSwitchTimer = doubleWormPhase ? (CalamityWorld.LegendaryMode ? 600f : 1200f) : (CalamityWorld.LegendaryMode ? 900f : 1800f);
calamityGlobalNPC.newAI[3] += 1f;
if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer)
calamityGlobalNPC.newAI[3] = 0f;
// Sound effect for swapping between attack behaviors in phase 2
if (doubleWormPhase && calamityGlobalNPC.newAI[3] % aiSwitchTimer == 0f && !(deathModeEnragePhase_Head || deathModeEnragePhase_BodyAndTail))
SoundEngine.PlaySound(AstrumDeusHead.SplitSound with { Pitch = -0.2f, Volume = 0.9f }, player.Center);
// Phase for flying at the player
bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase;
// Length of worms
int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50;
int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25;
int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5;
int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length;
// Become gradually more pissed as more worms are killed
int gfbMaxWormCount = 10;
int gfbWormCount = 0;
if (CalamityWorld.LegendaryMode && revenge)
gfbWormCount = NPC.CountNPCS(ModContent.NPCType<AstrumDeusHead>());
if (gfbWormCount > gfbMaxWormCount)
gfbWormCount = gfbMaxWormCount;
if (gfbWormCount > 0)
enrageScale += (gfbMaxWormCount - gfbWormCount) * 0.111f;
// Copy dontTakeDamage and Opacity from head
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity;
deathModeEnragePhase_BodyAndTail = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f;
if (deathModeEnragePhase_BodyAndTail)
{
NPC.defense = 25;
calamityGlobalNPC.DR = 0.15f;
}
// Set worm variable
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Alpha effects
if (Main.npc[(int)NPC.ai[1]].alpha < 128 && !NPC.dontTakeDamage)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
int headType = ModContent.NPCType<AstrumDeusHead>();
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].type != headType || !Main.npc[i].active)
continue;
shouldDespawn = false;
break;
}
if (shouldDespawn)
{
if (Main.npc.IndexInRange((int)NPC.ai[1]) && Main.npc[(int)NPC.ai[1]].active && Main.npc[(int)NPC.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
NPC.ForceNetUpdate(false);
}
// Direction
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
if (NPC.life > Main.npc[(int)NPC.ai[1]].life)
NPC.life = Main.npc[(int)NPC.ai[1]].life;
bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning
float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f;
float segmentVelocityBoost = 5f * (1f - lifeRatio);
segmentVelocity += segmentVelocityBoost;
segmentVelocity += 4f * enrageScale;
if (revenge)
{
float revMultiplier = 1.1f;
segmentVelocity *= revMultiplier;
}
// Follow the head
Vector2 segmentCenter = NPC.Center;
float segmentTargetX = player.Center.X;
float segmentTargetY = player.Center.Y;
segmentTargetX = (int)(segmentTargetX / 16f) * 16;
segmentTargetY = (int)(segmentTargetY / 16f) * 16;
segmentCenter.X = (int)(segmentCenter.X / 16f) * 16;
segmentCenter.Y = (int)(segmentCenter.Y / 16f) * 16;
segmentTargetX -= segmentCenter.X;
segmentTargetY -= segmentCenter.Y;
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
segmentCenter = NPC.Center;
segmentTargetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentCenter.X;
segmentTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentCenter.Y;
}
catch
{
}
NPC.rotation = (float)Math.Atan2(segmentTargetY, segmentTargetX) + MathHelper.PiOver2;
float segmentTargetDist = (float)Math.Sqrt(segmentTargetX * segmentTargetX + segmentTargetY * segmentTargetY);
int segmentWidth = NPC.width;
segmentTargetDist = (segmentTargetDist - segmentWidth) / segmentTargetDist;
segmentTargetX *= segmentTargetDist;
segmentTargetY *= segmentTargetDist;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + segmentTargetX;
NPC.position.Y = NPC.position.Y + segmentTargetY;
if (segmentTargetX < 0f)
NPC.spriteDirection = -1;
else if (segmentTargetX > 0f)
NPC.spriteDirection = 1;
}
// Play spawn sound on Deus on the first frame because otherwise the sound wouldn't play properly in multiplayer
if (calamityGlobalNPC.newAI[1] == 0f && !doubleWormPhase)
{
SoundEngine.PlaySound(AstrumDeusHead.SpawnSound, NPC.Center);
calamityGlobalNPC.newAI[1] = 1f;
}
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
if (calamityGlobalNPC.newAI[1] < resistanceTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 1f))
calamityGlobalNPC.newAI[1] += 1f;
// Calculate contact damage based on velocity
if (!doNotDealDamage)
{
float minimalContactDamageVelocity = segmentVelocity * 0.25f;
float minimalDamageVelocity = segmentVelocity * 0.5f;
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
NPC.damage = 0;
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
@@ -111,7 +331,7 @@ namespace CalamityMod.NPCs.AstrumDeus
bool deathModeEnragePhase = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f;
bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase;
float cyanThreshold = Main.getGoodWorld ? 300f : 600f;
float cyanThreshold = CalamityWorld.LegendaryMode ? 300f : 600f;
// Tail is always the first segment to visually transition
float transitionStart = cyanThreshold * 0.75f;
float transitionEnd = cyanThreshold * 0.8f;
+705 -2
View File
@@ -15,10 +15,12 @@ using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Enemy;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
@@ -123,7 +125,708 @@ namespace CalamityMod.NPCs.BrimstoneElemental
public override void AI()
{
BrimstoneElementalAI.VanillaBrimstoneElementalAI(NPC, Mod);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
// Used for Brimling AI states
CalamityGlobalNPC.brimstoneElemental = NPC.whoAmI;
// Emit light
Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1.2f, 0f, 0f);
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
bool despawnDistance = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
if (!player.active || player.dead || despawnDistance)
{
NPC.TargetClosest(false);
player = Main.player[NPC.target];
if (!player.active || player.dead || despawnDistance)
{
NPC.rotation = NPC.velocity.X * 0.04f;
if (NPC.velocity.Y > 3f)
NPC.velocity.Y = 3f;
NPC.velocity.Y -= 0.1f;
if (NPC.velocity.Y < -12f)
NPC.velocity.Y = -12f;
if (NPC.timeLeft > 60)
NPC.timeLeft = 60;
if (NPC.ai[0] != 0f)
{
NPC.ai[0] = 0f;
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
NPC.localAI[0] = 0f;
NPC.localAI[1] = 0f;
NPC.netUpdate = true;
}
return;
}
}
else if (NPC.timeLeft < 1800)
NPC.timeLeft = 1800;
// Reset defense
NPC.defense = NPC.defDefense;
calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = NPC.ai[0] == 4f;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Variables for buffing the AI
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
bool phase2 = lifeRatio < 0.5f && revenge;
bool phase3 = lifeRatio < 0.33f;
// Enrage
if ((!player.ZoneUnderworldHeight || !player.Calamity().ZoneCalamity) && !bossRush)
{
if (calamityGlobalNPC.newAI[3] > 0f)
calamityGlobalNPC.newAI[3] -= 1f;
}
else
calamityGlobalNPC.newAI[3] = CalamityGlobalNPC.biomeEnrageTimerMax;
bool biomeEnraged = calamityGlobalNPC.newAI[3] <= 0f || bossRush;
float enrageScale = bossRush ? 0.5f : 0f;
if (biomeEnraged && (!player.ZoneUnderworldHeight || bossRush))
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 0.5f;
}
if (biomeEnraged && (!player.Calamity().ZoneCalamity || bossRush))
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1f;
}
NPC.Calamity().DR = NPC.ai[0] == 4f ? 0.6f : 0.2f;
// Emit dust
int dustAmt = (NPC.ai[0] == 2f) ? 2 : 1;
int size = (NPC.ai[0] == 2f) ? 50 : 35;
if (NPC.ai[0] != 1f)
{
for (int i = 0; i < 2; i++)
{
if (Main.rand.Next(3) < dustAmt)
{
int dust = Dust.NewDust(NPC.Center - new Vector2(size), size * 2, size * 2, DustID.LifeDrain, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 1.5f);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 0.2f;
Main.dust[dust].fadeIn = 1f;
}
}
}
// Distance from destination where Brimmy stops moving
float movementDistanceGateValue = 100f;
// How fast Brimmy moves to the destination
float baseVelocity = (death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f) * (NPC.ai[0] == 5f ? 0.05f : NPC.ai[0] == 3f ? 1.5f : 1f);
baseVelocity += 3f * enrageScale;
if (expertMode)
baseVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio);
float baseAcceleration = (death ? 0.12f : 0.1f) * (NPC.ai[0] == 5f ? 0.5f : NPC.ai[0] == 3f ? 1.5f : 1f);
baseAcceleration += 0.06f * enrageScale;
if (expertMode)
baseAcceleration += 0.03f * (1f - lifeRatio);
// This is where Brimmy should be
Vector2 destination = NPC.ai[0] != 3f ? player.Center : new Vector2(player.Center.X, player.Center.Y - 300f);
// How far Brimmy is from where she's supposed to be
Vector2 distanceFromDestination = destination - NPC.Center;
// Movement
if (NPC.ai[0] != 4f)
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, baseAcceleration, true);
// Rotation and direction
if (NPC.ai[0] <= 2f || NPC.ai[0] == 5f)
{
NPC.rotation = NPC.velocity.X * 0.04f;
if (NPC.ai[0] != 5 || (NPC.ai[1] < 180f && NPC.ai[0] == 5f))
{
float playerLocation = NPC.Center.X - player.Center.X;
NPC.direction = playerLocation < 0f ? 1 : -1;
NPC.spriteDirection = NPC.direction;
}
}
if (Main.zenithWorld) // in gfb, Brimmy channels the power of the other elementals.
{
int newMode;
if (lifeRatio <= 0.8f && lifeRatio > 0.6f)
{
newMode = 1; // Sand
}
else if (lifeRatio <= 0.6f && lifeRatio > 0.4f)
{
newMode = 2; // Rare Sand
}
else if (lifeRatio <= 0.4f && lifeRatio > 0.2f)
{
newMode = 3; // Cloud
}
else if (lifeRatio <= 0.2f)
{
newMode = 4; // Water
}
else
{
newMode = 0; // Brimstone, default
}
if (newMode != currentMode)
{
SoundEngine.PlaySound(SoundID.Item29, NPC.Center);
}
currentMode = newMode;
}
if (NPC.ai[0] == -1f)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int phase;
int random = phase2 ? 6 : 5;
do phase = Main.rand.Next(random);
while (phase == NPC.ai[1] || (phase == 0 && phase3 && revenge) || phase == 1 || phase == 2 || (phase == 4 && NPC.localAI[3] != 0f));
NPC.ai[0] = phase;
NPC.ai[1] = 0f;
// Cocoon phase cooldown
if (NPC.localAI[3] > 0f)
NPC.localAI[3] -= 1f;
else if (phase == 4)
{
NPC.localAI[3] = 3f;
SoundEngine.PlaySound(HideInShellSound, player.Center);
}
// Prevent netUpdate from being blocked by the spam counter.
// A phase switch sync is a critical operation that must be synced.
NPC.ForceNetUpdate(false);
}
}
// Pick a location to teleport to
else if (NPC.ai[0] == 0f)
{
// Set damage
NPC.damage = NPC.defDamage;
NPC.chaseable = true;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.localAI[1] += 1f;
if (NPC.localAI[1] >= (bossRush ? 90f : death ? 120f : 180f))
{
NPC.TargetClosest();
NPC.localAI[1] = 0f;
int timer = 0;
int playerPosX;
int playerPosY;
while (true)
{
timer++;
playerPosX = (int)player.Center.X / 16;
playerPosY = (int)player.Center.Y / 16;
int min = 12;
int max = 16;
if (Main.rand.NextBool())
playerPosX += Main.rand.Next(min, max);
else
playerPosX -= Main.rand.Next(min, max);
if (Main.rand.NextBool())
playerPosY += Main.rand.Next(min, max);
else
playerPosY -= Main.rand.Next(min, max);
if (!WorldGen.SolidTile(playerPosX, playerPosY))
break;
if (timer > 100)
return;
}
NPC.ai[0] = 1f;
NPC.ai[1] = playerPosX;
NPC.ai[2] = playerPosY;
NPC.netUpdate = true;
}
}
}
// Teleport to location
else if (NPC.ai[0] == 1f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.chaseable = true;
Vector2 position = new Vector2(NPC.ai[1] * 16f - (NPC.width / 2), NPC.ai[2] * 16f - (NPC.height / 2));
for (int m = 0; m < 5; m++)
{
int dust = Dust.NewDust(position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, 2f);
Main.dust[dust].noGravity = true;
Main.dust[dust].fadeIn = 1f;
}
NPC.alpha += bossRush ? 8 : death ? 5 : revenge ? 4 : expertMode ? 3 : 2;
if (NPC.alpha >= 255)
{
int spawnType = currentMode == 3 ? NPCID.AngryNimbus : ModContent.NPCType<Brimling>();
int enemyCount = currentMode == 3 ? 3 : 1; // 3 angry nimbi if cloud, otherwise 1 brimling
if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(spawnType) < (death ? 1 : 2) && revenge && currentMode != 2) // dont spawn anything if gfb rare sand
{
for (int i = 0; i < enemyCount; i++)
NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, spawnType);
}
SoundEngine.PlaySound(TeleportSound, NPC.Center);
NPC.alpha = 255;
NPC.position = position;
for (int n = 0; n < 15; n++)
{
int warpDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, 3f);
Main.dust[warpDust].noGravity = true;
}
NPC.ai[0] = 2f;
NPC.netUpdate = true;
}
}
// Either teleport again or go to next AI state
else if (NPC.ai[0] == 2f)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (NPC.alpha >= 255)
{
if (Main.zenithWorld)
{
SoundEngine.PlaySound(SoundID.Item68, NPC.Center);
int type = ModContent.ProjectileType<BrimstoneRay>();
int damage = NPC.GetProjectileDamage(type);
Vector2 pos = NPC.Center;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), pos, new Vector2(0, 1), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
Projectile.NewProjectile(NPC.GetSource_FromAI(), pos, new Vector2(0, -1), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
Projectile.NewProjectile(NPC.GetSource_FromAI(), pos, new Vector2(1, 0), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
Projectile.NewProjectile(NPC.GetSource_FromAI(), pos, new Vector2(-1, 0), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
}
if (currentMode >= 1 && currentMode <= 3)
{
int tornadoType = currentMode == 3 ? ModContent.ProjectileType<StormMarkHostile>() : ProjectileID.SandnadoHostileMark;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), pos, Vector2.Zero, tornadoType, damage, 0f, Main.myPlayer, 0f, 0f);
}
}
if (currentMode == 2)
{
int healAmt = NPC.lifeMax / 25;
if (healAmt > 0)
{
NPC.life += healAmt;
NPC.HealEffect(healAmt, true);
NPC.netUpdate = true;
}
}
}
}
NPC.alpha -= 50;
if (NPC.alpha <= 0)
{
NPC.chaseable = true;
NPC.ai[3] += 1f;
NPC.alpha = 0;
if (NPC.ai[3] >= 2f || phase2 || CalamityWorld.LegendaryMode)
{
NPC.ai[0] = -1f;
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
}
else
{
NPC.ai[0] = 0f;
}
NPC.netUpdate = true;
}
}
// Float above target and fire projectiles
else if (NPC.ai[0] == 3f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.chaseable = true;
NPC.rotation = NPC.velocity.X * 0.04f;
float playerLocation = NPC.Center.X - player.Center.X;
NPC.direction = playerLocation < 0f ? 1 : -1;
NPC.spriteDirection = NPC.direction;
NPC.ai[1] += 1f;
float divisor = expertMode ? (death ? 80f : revenge ? 45f : 50f) - (float)Math.Ceiling(10f * (1f - lifeRatio)) : 50f;
divisor -= 3f * enrageScale;
float divisor2 = divisor * 2f;
if (NPC.ai[1] % divisor == divisor - 1f)
{
float velocity = (death ? 7f : revenge ? 6f : 5f) + (2f * enrageScale) + (expertMode ? 3f * (1f - lifeRatio) : 0f);
int type = ModContent.ProjectileType<BrimstoneHellfireball>();
int damage = NPC.GetProjectileDamage(type);
if (currentMode == 4)
{
type = ModContent.ProjectileType<FrostMist>();
SoundEngine.PlaySound(SoundID.Item30, player.Center);
}
else
{
SoundEngine.PlaySound(HellfireballSound, player.Center);
}
Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 5f, projectileVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y);
Main.projectile[proj].timeLeft = 240;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
if (NPC.ai[1] % divisor2 == divisor2 - 1f)
{
velocity = (death ? 5f : 4f) + 2f * enrageScale;
type = ModContent.ProjectileType<BrimstoneBarrage>();
damage = NPC.GetProjectileDamage(type);
if (currentMode == 4)
{
type = ModContent.ProjectileType<WaterSpear>();
SoundEngine.PlaySound(SoundID.Item21, player.Center);
}
else
{
SoundEngine.PlaySound(DartSound, player.Center);
}
projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity;
int numProj = death ? 8 : 4;
int spread = death ? 90 : 45;
if (CalamityWorld.LegendaryMode)
{
numProj *= 3;
spread *= 2;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float rotation = MathHelper.ToRadians(spread);
float projectileVelocityToPass = velocity * 3f;
for (int i = 0; i < numProj; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1)));
int proj2 = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj2].extraUpdates += 1;
}
}
}
}
if (NPC.ai[1] >= divisor * (death ? 5f : 10f))
{
NPC.TargetClosest();
NPC.ai[0] = -1f;
NPC.ai[1] = 3f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
NPC.netUpdate = true;
}
}
// Cocoon bullet hell
else if (NPC.ai[0] == 4f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.defense = NPC.defDefense * 4;
NPC.chaseable = false;
NPC.localAI[0] += 1f;
if (CalamityWorld.LegendaryMode)
NPC.localAI[0] += 2f;
if (expertMode)
NPC.localAI[0] += 1f - lifeRatio;
NPC.localAI[0] += enrageScale;
if (NPC.localAI[0] >= 120f)
{
NPC.localAI[0] = 0f;
float projectileSpeed = death ? 9f : revenge ? 8f : 6f;
projectileSpeed += 2f * enrageScale;
Vector2 projectileVelocity = player.Center - NPC.Center;
float radialOffset = 0.2f;
float diameter = 80f;
projectileVelocity = projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileSpeed;
Vector2 velocity = projectileVelocity;
velocity = velocity.SafeNormalize(Vector2.UnitY);
velocity *= diameter;
int totalProjectiles = 6;
float offsetAngle = MathHelper.Pi * radialOffset;
int type = ModContent.ProjectileType<BrimstoneHellblast>();
int damage = NPC.GetProjectileDamage(type);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
for (int j = 0; j < totalProjectiles; j++)
{
float radians = j - (totalProjectiles - 1f) / 2f;
Vector2 offset = velocity.RotatedBy(offsetAngle * radians);
int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, projectileVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f);
Main.projectile[proj].timeLeft = 300;
Main.projectile[proj].tileCollide = false;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
}
totalProjectiles = 12;
float radians2 = MathHelper.TwoPi / totalProjectiles;
type = ModContent.ProjectileType<BrimstoneBarrage>();
damage = NPC.GetProjectileDamage(type);
if (currentMode == 4)
{
type = ModContent.ProjectileType<SirenSong>();
SoundEngine.PlaySound(SoundID.Item26, player.Center);
}
else
{
SoundEngine.PlaySound(ShellFireSound, player.Center);
}
double angleA = radians2 * 0.5;
double angleB = MathHelper.ToRadians(90f) - angleA;
float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB));
Vector2 spinningPoint = NPC.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float projectileVelocityToPass = projectileSpeed * 3f;
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k);
int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
if (death)
{
spinningPoint = NPC.localAI[2] % 2f == 0f ? new Vector2(-velocityX, -projectileSpeed) : new Vector2(0f, -projectileSpeed);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k);
int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255 * 0.75f, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
}
}
NPC.localAI[2] += 1f;
}
NPC.velocity *= 0.95f;
NPC.rotation = NPC.velocity.X * 0.04f;
float playerLocation = NPC.Center.X - player.Center.X;
NPC.direction = playerLocation < 0f ? 1 : -1;
NPC.spriteDirection = NPC.direction;
NPC.ai[1] += 1f;
if (NPC.ai[1] >= (death ? 240f : 300f))
{
NPC.TargetClosest();
NPC.ai[0] = -1f;
NPC.ai[1] = 4f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
NPC.localAI[0] = 0f;
NPC.netUpdate = true;
}
}
// Laser beam attack
else if (NPC.ai[0] == 5f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.chaseable = true;
NPC.defense = NPC.defDefense * 2;
Vector2 source = new Vector2(NPC.Center.X + (NPC.spriteDirection > 0 ? 34f : -34f), NPC.Center.Y - 74f);
Vector2 aimAt = player.Center + player.velocity * 20f;
float aimResponsiveness = bossRush ? 0.05f : (NPC.ai[2] == 1f || death) ? 0.1f : 0.25f;
Vector2 aimVector = (aimAt - source).SafeNormalize(Vector2.UnitY);
if (aimVector.HasNaNs())
aimVector = -Vector2.UnitY;
aimVector = Vector2.Lerp(aimVector, NPC.velocity.SafeNormalize(Vector2.UnitY), aimResponsiveness).SafeNormalize(Vector2.UnitY);
aimVector *= 6f;
Vector2 laserVelocity = aimVector.SafeNormalize(Vector2.UnitY);
if (laserVelocity.HasNaNs())
laserVelocity = -Vector2.UnitY;
calamityGlobalNPC.newAI[1] = laserVelocity.X;
calamityGlobalNPC.newAI[2] = laserVelocity.Y;
// Rev = 190 + 165 = 355
// Death = 165
NPC.ai[1] += 1f;
if (NPC.ai[1] >= 240f)
{
NPC.TargetClosest();
NPC.ai[2] += 1f;
NPC.localAI[0] = 0f;
NPC.localAI[1] = 0f;
if (NPC.ai[2] >= (death ? 1f : 2f))
{
NPC.ai[0] = -1f;
NPC.ai[1] = 5f;
NPC.ai[2] = 0f;
calamityGlobalNPC.newAI[0] = 0f;
}
else
{
NPC.ai[1] = 0f;
calamityGlobalNPC.newAI[0] = 0f;
}
}
else if (NPC.ai[1] >= 180f)
{
NPC.velocity *= 0.95f;
if (NPC.ai[1] == 180f)
{
SoundEngine.PlaySound(SoundID.Item68, source);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Vector2 laserVelocity2 = new Vector2(NPC.localAI[0], NPC.localAI[1]);
laserVelocity2 = laserVelocity2.SafeNormalize(Vector2.UnitY);
int type = ModContent.ProjectileType<BrimstoneRay>();
int damage = NPC.GetProjectileDamage(type);
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
if (CalamityWorld.LegendaryMode)
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, -laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
if (Main.zenithWorld)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(-laserVelocity2.X, laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(laserVelocity2.X, -laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI);
}
}
}
}
else
{
float playSoundTimer = 30f;
if (NPC.ai[1] < 150f)
{
switch ((int)NPC.ai[2])
{
case 0:
NPC.ai[1] += 0.5f;
break;
case 1:
NPC.ai[1] += 1f;
playSoundTimer = 40f;
break;
}
if (death)
{
NPC.ai[1] += 0.5f;
playSoundTimer += 10f;
}
}
if (NPC.ai[1] % playSoundTimer == 0f)
SoundEngine.PlaySound(SoundID.Item20, NPC.Center);
if (NPC.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, laserVelocity, ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI);
if (CalamityWorld.LegendaryMode)
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, -laserVelocity, ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI);
if (Main.zenithWorld)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(-laserVelocity.X, laserVelocity.Y), ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI);
Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(laserVelocity.X, -laserVelocity.Y), ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI);
}
}
calamityGlobalNPC.newAI[0] = 1f;
}
else
{
if (NPC.ai[1] == 150f)
{
NPC.localAI[0] = laserVelocity.X;
NPC.localAI[1] = laserVelocity.Y;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, NPC.localAI[0], NPC.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI);
if (CalamityWorld.LegendaryMode)
Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, -NPC.localAI[0], -NPC.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI);
if (Main.zenithWorld)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, -NPC.localAI[0], NPC.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI);
Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, NPC.localAI[0], -NPC.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI);
}
}
}
}
}
}
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
-539
View File
@@ -1,539 +0,0 @@
using System;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Events;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Vanity;
using CalamityMod.Items.LoreItems;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Mounts;
using CalamityMod.Items.Placeables.Furniture.BossRelics;
using CalamityMod.Items.Placeables.Furniture.DevPaintings;
using CalamityMod.Items.Placeables.Furniture.Trophies;
using CalamityMod.Items.Potions;
using CalamityMod.Items.TreasureBags;
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Sounds;
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.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.Bumblebirb
{
[AutoloadBossHead]
public class Bumblefuck : ModNPC
{
public static Asset<Texture2D> GlowTexture;
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 6;
NPCID.Sets.TrailingMode[Type] = 1;
NPCID.Sets.BossBestiaryPriority.Add(Type);
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers()
{
Scale = 0.5f,
PortraitScale = 0.85f,
PortraitPositionYOverride = 14f
};
value.Position.X += 20f;
value.Position.Y += 8f;
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
NPCID.Sets.MPAllowedEnemies[Type] = true;
if (!Main.dedServ)
{
GlowTexture = ModContent.Request<Texture2D>("CalamityMod/NPCs/Bumblebirb/BirbGlow", AssetRequestMode.AsyncLoad);
}
}
public override string Texture => "CalamityMod/NPCs/Bumblebirb/Birb";
public override string BossHeadTexture => "CalamityMod/NPCs/Bumblebirb/Birb_Head_Boss";
public override void SetDefaults()
{
NPC.Calamity().canBreakPlayerDefense = true;
NPC.npcSlots = 32f;
NPC.aiStyle = -1;
AIType = -1;
NPC.GetNPCDamage();
NPC.width = 130;
NPC.height = 100;
NPC.defense = 40;
NPC.DR_NERD(0.1f);
NPC.LifeMaxNERB(187500, 225000, 300000); // Old HP - 227500, 252500
NPC.knockBackResist = 0f;
NPC.boss = true;
NPC.noTileCollide = true;
NPC.lavaImmune = true;
NPC.noGravity = true;
NPC.value = Item.buyPrice(1, 0, 0, 0);
NPC.HitSound = SoundID.NPCHit51;
NPC.DeathSound = SoundID.NPCDeath46;
NPC.Calamity().VulnerableToHeat = true;
NPC.Calamity().VulnerableToCold = true;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = false;
// Scale HP in Master
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true);
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle,
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Bumblefuck")
});
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(NPC.localAI[0]);
writer.Write(NPC.localAI[1]);
writer.Write(NPC.localAI[2]);
writer.Write(NPC.localAI[3]);
for (int i = 0; i < 4; i++)
writer.Write(NPC.Calamity().newAI[i]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
NPC.localAI[0] = reader.ReadSingle();
NPC.localAI[1] = reader.ReadSingle();
NPC.localAI[2] = reader.ReadSingle();
NPC.localAI[3] = reader.ReadSingle();
for (int i = 0; i < 4; i++)
NPC.Calamity().newAI[i] = reader.ReadSingle();
}
public override void AI()
{
BumblebirbAI.VanillaBumblebirbAI(NPC, Mod);
}
public override void FindFrame(int frameHeight)
{
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive;
bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death;
bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f);
bool birbSpawn = NPC.ai[0] == 4f && NPC.ai[1] > 0f;
// Animation goes nyoom
if (Main.zenithWorld)
{
NPC.frameCounter += 4;
}
float newPhaseTimer = 180f;
bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) ||
(phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f);
if (phaseSwitchPhase || birbSpawn)
{
float frameGateValue = birbSpawn ? NPC.ai[1] : phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0];
int frameTimer = 180;
if (frameGateValue < (frameTimer - 60) || frameGateValue > (frameTimer - 20))
{
NPC.frameCounter += 1D;
if (NPC.frameCounter > 5D)
{
NPC.frameCounter = 0D;
NPC.frame.Y += frameHeight;
}
if (NPC.frame.Y >= frameHeight * 5)
{
NPC.frame.Y = 0;
}
}
else
{
NPC.frame.Y = frameHeight * 4;
if (frameGateValue > (frameTimer - 50) && frameGateValue < (frameTimer - 25))
{
NPC.frame.Y = frameHeight * 5;
}
}
}
else if (NPC.ai[0] == 5f)
{
int otherFrameTimer = 120;
if (NPC.ai[1] < (otherFrameTimer - 50) || NPC.ai[1] > (otherFrameTimer - 10))
{
NPC.frameCounter += 1D;
if (NPC.frameCounter > 5D)
{
NPC.frameCounter = 0D;
NPC.frame.Y += frameHeight;
}
if (NPC.frame.Y >= frameHeight * 5)
{
NPC.frame.Y = 0;
}
}
else
{
NPC.frame.Y = frameHeight * 4;
if (NPC.ai[1] > (otherFrameTimer - 40) && NPC.ai[1] < (otherFrameTimer - 15))
{
NPC.frame.Y = frameHeight * 5;
}
}
}
else
{
NPC.frameCounter += (NPC.ai[0] == 3.2f ? 1.5 : 1D);
if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base
{
NPC.frameCounter = 0D;
NPC.frame.Y += frameHeight;
}
if (NPC.frame.Y >= frameHeight * 5)
{
NPC.frame.Y = 0;
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive;
bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death;
bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f);
float newPhaseTimer = 180f;
bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) ||
(phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f);
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
Texture2D texture2D15 = TextureAssets.Npc[Type].Value;
Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2));
Color color = drawColor;
Color altColor = Color.White;
float lerpDrawTransition = 0f;
int newAITracker = 120;
int buffColorDampener = 60;
if (phase3 && calamityGlobalNPC.newAI[3] == 1f)
{
color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.6f, 0.2f, 1f);
}
else if (phase2 && calamityGlobalNPC.newAI[2] == 1f)
{
color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.3f, 1f);
}
else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker)
{
float phase2TranBuff = calamityGlobalNPC.newAI[0] - (float)newAITracker;
phase2TranBuff /= (float)buffColorDampener;
color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * phase2TranBuff, 1f - 0.3f * phase2TranBuff, 1f - 0.7f * phase2TranBuff, 1f);
}
int afterimageAmt = 10;
int afterimageIncrement = 2;
if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f)
{
afterimageAmt = 4;
}
if (NPC.ai[0] == 1f || NPC.ai[0] == 3f || NPC.ai[0] == 4.1f)
{
afterimageAmt = 7;
}
if (NPC.ai[0] == 2f || NPC.ai[0] == 3.2f || (phase2 && calamityGlobalNPC.newAI[2] == 1f))
{
altColor = Color.Yellow;
lerpDrawTransition = 0.5f;
}
else
{
color = altColor;
}
if (CalamityClientConfig.Instance.Afterimages)
{
for (int i = 1; i < afterimageAmt; i += afterimageIncrement)
{
Color afterimageColor = color;
afterimageColor = Color.Lerp(afterimageColor, altColor, lerpDrawTransition);
afterimageColor = NPC.GetAlpha(afterimageColor);
afterimageColor *= (float)(afterimageAmt - i) / 15f;
Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos;
afterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f;
afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
}
}
int extraAfterimageAmt = 0;
float extraAfterimageDampener = 0f;
float afterimageScaler = 0f;
if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f)
{
extraAfterimageAmt = 4;
}
if (NPC.ai[0] == 5f)
{
if (NPC.ai[1] > 60f)
{
extraAfterimageAmt = 6;
extraAfterimageDampener = 1f - (float)Math.Cos((double)((NPC.ai[1] - 60f) / 30f * MathHelper.TwoPi));
extraAfterimageDampener /= 3f;
afterimageScaler = 40f;
}
}
if (phaseSwitchPhase)
{
if (phase3 && calamityGlobalNPC.newAI[1] > (float)newAITracker)
{
extraAfterimageAmt = 6;
extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[1] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi));
extraAfterimageDampener /= 3f;
afterimageScaler = 60f;
}
else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker)
{
extraAfterimageAmt = 6;
extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[0] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi));
extraAfterimageDampener /= 3f;
afterimageScaler = 60f;
}
}
if (CalamityClientConfig.Instance.Afterimages)
{
for (int j = 0; j < extraAfterimageAmt; j++)
{
Color extraAfterimageColor = altColor;
extraAfterimageColor = Color.Lerp(extraAfterimageColor, altColor, lerpDrawTransition);
extraAfterimageColor = NPC.GetAlpha(extraAfterimageColor);
extraAfterimageColor *= 1f - extraAfterimageDampener;
Vector2 extraAfterimageDrawPos = NPC.Center + ((float)j / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos;
extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f;
extraAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, extraAfterimageDrawPos, NPC.frame, extraAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
}
}
Color mainDrawingColor = altColor;
mainDrawingColor = Color.Lerp(mainDrawingColor, altColor, lerpDrawTransition);
mainDrawingColor = NPC.GetAlpha(mainDrawingColor);
Vector2 drawLocation = NPC.Center - screenPos;
drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f;
drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, (phase3 && calamityGlobalNPC.newAI[3] == 1f ? mainDrawingColor : NPC.GetAlpha(altColor)), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
if (phase2)
{
texture2D15 = GlowTexture.Value;
Color glowmaskColor = Color.Lerp(Color.White, Color.Red, 0.5f);
altColor = Color.Red;
lerpDrawTransition = 1f;
extraAfterimageDampener = 0.5f;
afterimageScaler = 10f;
afterimageIncrement = 1;
if (phaseSwitchPhase)
{
float glowmaskDampener = (phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]) - (float)newAITracker;
glowmaskDampener /= (float)buffColorDampener;
altColor *= glowmaskDampener;
glowmaskColor *= glowmaskDampener;
}
if (CalamityClientConfig.Instance.Afterimages)
{
for (int k = 1; k < afterimageAmt; k += afterimageIncrement)
{
Color glowmaskAfterimageColor = glowmaskColor;
glowmaskAfterimageColor = Color.Lerp(glowmaskAfterimageColor, altColor, lerpDrawTransition);
glowmaskAfterimageColor *= (float)(afterimageAmt - k) / 15f;
Vector2 glowmaskAfterimageDrawPos = NPC.oldPos[k] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos;
glowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f;
glowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, glowmaskAfterimageDrawPos, NPC.frame, glowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
}
for (int l = 1; l < extraAfterimageAmt; l++)
{
Color extraGlowmaskAfterimageColor = glowmaskColor;
extraGlowmaskAfterimageColor = Color.Lerp(extraGlowmaskAfterimageColor, altColor, lerpDrawTransition);
extraGlowmaskAfterimageColor = NPC.GetAlpha(extraGlowmaskAfterimageColor);
extraGlowmaskAfterimageColor *= 1f - extraAfterimageDampener;
Vector2 extraGlowmaskAfterimageDrawPos = NPC.Center + ((float)l / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos;
extraGlowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f;
extraGlowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, extraGlowmaskAfterimageDrawPos, NPC.frame, extraGlowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
}
}
spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
}
return false;
}
private static Color buffColor(Color newColor, float R, float G, float B, float A)
{
newColor.R = (byte)((float)newColor.R * R);
newColor.G = (byte)((float)newColor.G * G);
newColor.B = (byte)((float)newColor.B * B);
newColor.A = (byte)((float)newColor.A * A);
return newColor;
}
public override void BossLoot(ref string name, ref int potionType) => potionType = ItemID.SuperHealingPotion;
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType<DragonfollyBag>()));
// Normal drops: Everything that would otherwise be in the bag
var normalOnly = npcLoot.DefineNormalOnlyDropSet();
{
// Weapons
int[] items = new int[]
{
ModContent.ItemType<GildedProboscis>(),
ModContent.ItemType<GoldenEagle>(),
ModContent.ItemType<RougeSlash>()
};
normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, items));
normalOnly.Add(ModContent.ItemType<Swordsplosion>(), 10);
// Materials
normalOnly.Add(ModContent.ItemType<EffulgentFeather>(), 1, 25, 30);
// Equipment
normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType<DynamoStemCells>()));
normalOnly.Add(ModContent.ItemType<FollyFeed>(), DropHelper.NormalWeaponDropRateFraction);
// Vanity
normalOnly.Add(ModContent.ItemType<BumblefuckMask>(), 7);
normalOnly.Add(ModContent.ItemType<ThankYouPainting>(), ThankYouPainting.DropInt);
}
npcLoot.Add(ModContent.ItemType<DragonfollyTrophy>(), 10);
// Relic
npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType<DragonfollyRelic>());
// GFB Omega Healing Potion drop
npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType<OmegaHealingPotion>(), 1, 50, 100), true);
// Lore
npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedDragonfolly, ModContent.ItemType<LoreDragonfolly>(), desc: DropHelper.FirstKillText);
}
public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
{
if (hurtInfo.Damage > 0)
target.AddBuff(ModContent.BuffType<VermillionFlux>(), Main.zenithWorld ? 360 : 180);
}
public override void OnKill()
{
// Don't bother running any of this in Boss Rush.
if (BossRushEvent.BossRushActive)
return;
CalamityGlobalNPC.SetNewBossJustDowned(NPC);
// Mark The Dragonfolly as dead
DownedBossSystem.downedDragonfolly = true;
CalamityNetcode.SyncWorld();
if (Main.zenithWorld)
{
int spacing = 40;
int amt = 7;
SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
for (int i = 0; i < amt; i++)
{
Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f);
Vector2 ai0 = NPC.Center - fireFrom;
float ai = Main.rand.Next(100);
Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType<RedLightning>(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai);
}
}
}
}
public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment)
{
NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment);
NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier());
}
public override void ModifyTypeName(ref string typeName)
{
if (Main.zenithWorld)
{
typeName = CalamityUtils.GetTextValue("NPCs.Bumblebirb");
}
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 50; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f);
}
if (!Main.dedServ)
{
for (int i = 0; i < 6; i++) // 1 head, 1 wing, 4 legs = 6. one wing due to them being chonky boyes now
{
string gore = "Bumble";
float randomSpread = Main.rand.Next(-200, 201) / 100f;
gore += i == 0 ? "Head" : i > 1 ? "Leg" : "Wing";
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find<ModGore>(gore).Type, 1f);
}
}
}
}
}
}
-153
View File
@@ -1,153 +0,0 @@
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Sounds;
using CalamityMod.World;
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.Bumblebirb
{
public class Bumblefuck2 : ModNPC
{
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 5;
NPCID.Sets.TrailingMode[Type] = 1;
this.HideFromBestiary();
}
public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly";
public override void SetDefaults()
{
NPC.npcSlots = 1f;
NPC.aiStyle = -1;
AIType = -1;
NPC.GetNPCDamage();
NPC.width = 120;
NPC.height = 80;
NPC.defense = 20;
NPC.LifeMaxNERB(9375, 11250, 5000);
NPC.knockBackResist = 0.15f;
NPC.lavaImmune = true;
NPC.noTileCollide = true;
NPC.noGravity = true;
NPC.HitSound = SoundID.NPCHit51;
NPC.DeathSound = SoundID.NPCDeath46;
NPC.Calamity().VulnerableToHeat = true;
NPC.Calamity().VulnerableToCold = true;
NPC.Calamity().VulnerableToSickness = true;
// Scale stats in Expert and Master
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
}
public override void AI()
{
BumblebirbAI.VanillaBumblebirb2AI(NPC, Mod, true);
}
public override void OnKill()
{
int closestPlayer = Player.FindClosest(NPC.Center, 1, 1);
if (Main.rand.NextBool(4) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2)
Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart);
if (Main.zenithWorld)
{
SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
for (int i = 0; i < 5; i++)
{
Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f);
Vector2 ai0 = NPC.Center - fireFrom;
float ai = Main.rand.Next(100);
Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType<RedLightning>(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai);
}
}
}
}
public override void FindFrame(int frameHeight)
{
NPC.frameCounter += NPC.ai[0] == 2.1f ? 1.5 : 1D;
if (Main.zenithWorld)
{
NPC.frameCounter += 2D;
}
if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base
{
NPC.frameCounter = 0D;
NPC.frame.Y += frameHeight;
}
if (NPC.frame.Y >= frameHeight * 4)
{
NPC.frame.Y = 0;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
Texture2D texture2D15 = TextureAssets.Npc[Type].Value;
Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2);
int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0;
if (CalamityClientConfig.Instance.Afterimages)
{
for (int i = 1; i < afterimageAmt; i += 2)
{
Color afterimageColor = drawColor;
afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f);
afterimageColor = NPC.GetAlpha(afterimageColor);
afterimageColor *= (afterimageAmt - i) / 15f;
Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos;
afterimageDrawPos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f;
afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
}
}
Vector2 drawLocation = NPC.Center - screenPos;
drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f;
drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
return false;
}
public override void ModifyTypeName(ref string typeName)
{
if (Main.zenithWorld)
{
typeName = CalamityUtils.GetTextValue("NPCs.Bumblebirb");
}
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 50; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f);
}
}
}
}
}
+368
View File
@@ -0,0 +1,368 @@
using CalamityMod.Projectiles.Boss;
using CalamityMod.Sounds;
using CalamityMod.World;
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.Bumblebirb
{
public class DraconicSwarmer : ModNPC
{
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 5;
NPCID.Sets.TrailingMode[Type] = 1;
this.HideFromBestiary();
}
public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly";
public override void SetDefaults()
{
NPC.npcSlots = 1f;
NPC.aiStyle = -1;
AIType = -1;
NPC.GetNPCDamage();
NPC.width = 120;
NPC.height = 80;
NPC.defense = 20;
NPC.LifeMaxNERB(9375, 11250, 5000);
NPC.knockBackResist = 0.15f;
NPC.lavaImmune = true;
NPC.noTileCollide = true;
NPC.noGravity = true;
NPC.HitSound = SoundID.NPCHit51;
NPC.DeathSound = SoundID.NPCDeath46;
NPC.Calamity().VulnerableToHeat = true;
NPC.Calamity().VulnerableToCold = true;
NPC.Calamity().VulnerableToSickness = true;
// Scale stats in Expert and Master
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
}
public override void AI()
{
Player player = Main.player[NPC.target];
float rotationMult = 4f;
float rotationAmt = 0.04f;
if (Vector2.Distance(player.Center, NPC.Center) > 5600f)
{
if (NPC.timeLeft > 5)
NPC.timeLeft = 5;
}
NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt * 1.25f) / 10f;
if (NPC.ai[0] == 0f || NPC.ai[0] == 1f)
{
for (int i = 0; i < Main.maxNPCs; i++)
{
if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type)
{
Vector2 otherSwarmerDirection = Main.npc[i].Center - NPC.Center;
if (otherSwarmerDirection.Length() < (NPC.width + NPC.height))
{
otherSwarmerDirection.Normalize();
otherSwarmerDirection *= -0.1f;
NPC.velocity += otherSwarmerDirection;
NPC nPC6 = Main.npc[i];
nPC6.velocity -= otherSwarmerDirection;
}
}
}
}
if (NPC.target < 0 || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
{
NPC.TargetClosest(true);
Vector2 swarmerTargetDist = Main.player[NPC.target].Center - NPC.Center;
if (Main.player[NPC.target].dead || swarmerTargetDist.Length() > 5600f)
NPC.ai[0] = -1f;
}
else
{
Vector2 swarmerCatchUpTargetDist = Main.player[NPC.target].Center - NPC.Center;
if (NPC.ai[0] > 1f && swarmerCatchUpTargetDist.Length() > 3600f)
NPC.ai[0] = 1f;
}
if (NPC.ai[0] == -1f)
{
// Avoid cheap bullshit
NPC.damage = 0;
Vector2 swarmerDespawnVelMult = new Vector2(0f, -8f);
NPC.velocity = (NPC.velocity * 21f + swarmerDespawnVelMult) / 10f;
return;
}
if (NPC.ai[0] == 0f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.TargetClosest(true);
NPC.spriteDirection = NPC.direction;
Vector2 swarmerIdleTargetDist = Main.player[NPC.target].Center - NPC.Center;
if (swarmerIdleTargetDist.Length() > 2800f)
{
NPC.ai[0] = 1f;
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
}
else if (swarmerIdleTargetDist.Length() > 400f)
{
float swarmerIdleSpeed = 9f + swarmerIdleTargetDist.Length() / 100f + NPC.ai[1] / 15f;
swarmerIdleTargetDist.Normalize();
swarmerIdleTargetDist *= swarmerIdleSpeed;
NPC.velocity = (NPC.velocity * 29f + swarmerIdleTargetDist) / 30f;
if (CalamityWorld.LegendaryMode && !Main.zenithWorld)
NPC.velocity *= 1.15f;
}
else if (NPC.velocity.Length() > 2f)
NPC.velocity *= 0.95f;
else if (NPC.velocity.Length() < 1f)
NPC.velocity *= 1.05f;
NPC.ai[1] += 1f;
if (NPC.ai[1] >= 90f)
{
NPC.ai[1] = 0f;
NPC.ai[0] = 2f;
}
}
else
{
if (NPC.ai[0] == 1f)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (NPC.target < 0 || !Main.player[NPC.target].active || Main.player[NPC.target].dead)
NPC.TargetClosest(true);
if (NPC.velocity.X < 0f)
NPC.direction = -1;
else if (NPC.velocity.X > 0f)
NPC.direction = 1;
NPC.spriteDirection = NPC.direction;
NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt) / 10f;
Vector2 swarmerChargeTargetDist = Main.player[NPC.target].Center - NPC.Center;
if (swarmerChargeTargetDist.Length() < 800f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height))
{
NPC.ai[0] = 0f;
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
}
NPC.ai[2] += 0.0166666675f;
float swarmerChargeSpeed = 12f + NPC.ai[2] + swarmerChargeTargetDist.Length() / 150f;
float swarmerChargeVelMult = 25f;
swarmerChargeTargetDist.Normalize();
swarmerChargeTargetDist *= swarmerChargeSpeed;
NPC.velocity = (NPC.velocity * (swarmerChargeVelMult - 1f) + swarmerChargeTargetDist) / swarmerChargeVelMult;
if (CalamityWorld.LegendaryMode && !Main.zenithWorld)
NPC.velocity *= 1.15f;
NPC.ForceNetUpdate();
return;
}
if (NPC.ai[0] == 2f)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (NPC.velocity.X < 0f)
NPC.direction = -1;
else if (NPC.velocity.X > 0f)
NPC.direction = 1;
NPC.spriteDirection = NPC.direction;
NPC.rotation = (NPC.rotation * rotationMult * 0.75f + NPC.velocity.X * rotationAmt * 1.25f) / 8f;
Vector2 swarmerDecelerateTargetDist = Main.player[NPC.target].Center - NPC.Center;
swarmerDecelerateTargetDist.Y -= 8f;
float swarmerDecelerateSpeed = 18f;
float swarmerDecelerateVelMult = 8f;
swarmerDecelerateTargetDist.Normalize();
swarmerDecelerateTargetDist *= swarmerDecelerateSpeed;
NPC.velocity = (NPC.velocity * (swarmerDecelerateVelMult - 1f) + swarmerDecelerateTargetDist) / swarmerDecelerateVelMult;
if (CalamityWorld.LegendaryMode && !Main.zenithWorld)
NPC.velocity *= 1.15f;
if (NPC.velocity.X < 0f)
NPC.direction = -1;
else
NPC.direction = 1;
NPC.spriteDirection = NPC.direction;
NPC.ai[1] += 1f;
if (NPC.ai[1] > 10f)
{
// Set damage
NPC.damage = NPC.defDamage;
NPC.velocity = swarmerDecelerateTargetDist;
if (CalamityWorld.LegendaryMode && !Main.zenithWorld)
NPC.velocity *= 1.15f;
if (NPC.velocity.X < 0f)
NPC.direction = -1;
else
NPC.direction = 1;
NPC.ai[0] = 2.1f;
NPC.ai[1] = 0f;
}
}
else if (NPC.ai[0] == 2.1f)
{
// Set damage
NPC.damage = NPC.defDamage;
if (NPC.velocity.X < 0f)
NPC.direction = -1;
else if (NPC.velocity.X > 0f)
NPC.direction = 1;
NPC.spriteDirection = NPC.direction;
NPC.velocity *= 1.01f;
NPC.ai[1] += 1f;
if (NPC.ai[1] > 30f)
{
if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height))
{
NPC.ai[0] = 0f;
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
return;
}
if (NPC.ai[1] > 60f)
{
NPC.ai[0] = 1f;
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
}
}
}
}
}
public override void OnKill()
{
int closestPlayer = Player.FindClosest(NPC.Center, 1, 1);
if (Main.rand.NextBool(4) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2)
Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart);
if (Main.zenithWorld)
{
SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
for (int i = 0; i < 5; i++)
{
Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f);
Vector2 ai0 = NPC.Center - fireFrom;
float ai = Main.rand.Next(100);
Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType<RedLightning>(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai);
}
}
}
}
public override void FindFrame(int frameHeight)
{
NPC.frameCounter += NPC.ai[0] == 2.1f ? 1.5 : 1D;
if (Main.zenithWorld)
{
NPC.frameCounter += 2D;
}
if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base
{
NPC.frameCounter = 0D;
NPC.frame.Y += frameHeight;
}
if (NPC.frame.Y >= frameHeight * 4)
{
NPC.frame.Y = 0;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
Texture2D texture2D15 = TextureAssets.Npc[Type].Value;
Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2);
int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0;
if (CalamityClientConfig.Instance.Afterimages)
{
for (int i = 1; i < afterimageAmt; i += 2)
{
Color afterimageColor = drawColor;
afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f);
afterimageColor = NPC.GetAlpha(afterimageColor);
afterimageColor *= (afterimageAmt - i) / 15f;
Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos;
afterimageDrawPos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f;
afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
}
}
Vector2 drawLocation = NPC.Center - screenPos;
drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f;
drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY);
spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
return false;
}
public override void ModifyTypeName(ref string typeName)
{
if (Main.zenithWorld)
{
typeName = CalamityUtils.GetTextValue("NPCs.Bumblebirb");
}
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 50; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f);
}
}
}
}
}
File diff suppressed because it is too large. Load diff
+715 -3
View File
@@ -14,14 +14,14 @@ using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.NPCs.TownNPCs;
using CalamityMod.Sounds;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using ReLogic.Utilities;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
@@ -134,7 +134,719 @@ namespace CalamityMod.NPCs.CalClone
public override void AI()
{
CalamitasCloneAI.VanillaCalamitasCloneAI(NPC, BulletHellWarnSlot);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
// Emit light
Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1f, 0f, 0f);
// Variables for increasing difficulty
bool bossRush = BossRushEvent.BossRushActive;
bool death = CalamityWorld.death || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool expertMode = Main.expertMode || bossRush;
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
// Phases
bool phase2 = lifeRatio < 0.7f || death;
bool phase3 = lifeRatio < 0.35f;
bool phase4 = lifeRatio <= 0.1f && death;
// Don't take damage during bullet hells
NPC.dontTakeDamage = calamityGlobalNPC.newAI[2] > 0f;
// Variable for live brothers
bool brotherAlive = false;
// For seekers
CalamityGlobalNPC.calamitas = NPC.whoAmI;
// Seeker ring
if (calamityGlobalNPC.newAI[1] == 0f && phase3 && expertMode)
{
SoundEngine.PlaySound(SoundID.Item72, NPC.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int seekerAmt = death ? 10 : 5;
int seekerSpread = 360 / seekerAmt;
int seekerDistance = death ? 180 : 150;
for (int i = 0; i < seekerAmt; i++)
{
int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + (Math.Sin(i * seekerSpread) * seekerDistance)), (int)(NPC.Center.Y + (Math.Cos(i * seekerSpread) * seekerDistance)), ModContent.NPCType<SoulSeeker>(), NPC.whoAmI, 0, 0, 0, -1);
Main.npc[spawn].ai[0] = i * seekerSpread;
}
}
string key = "Mods.CalamityMod.Status.Boss.CalamitasBossText3";
Color messageColor = Color.Orange;
CalamityUtils.DisplayLocalizedText(key, messageColor);
calamityGlobalNPC.newAI[1] = 1f;
}
// CIT 14SEP2024: Fixed bug where her phases would get offset by dealing a large amount of damage in a single hit to take her into a new phase.
// newAI[0] now starts at 1 and has 0.3 subtracted from it for each phase, instead of it storing her current health when she enters a new phase.
// Do bullet hell or spawn brothers
if (calamityGlobalNPC.newAI[0] == 0f && NPC.life > 0)
calamityGlobalNPC.newAI[0] = 1f;
// Bullet hells at 70% and 10%, brothers at 40%
if (NPC.life > 0)
{
int calClonePhaseThreshold = (int)(NPC.lifeMax * 0.3);
if (((NPC.life + calClonePhaseThreshold) / (float)NPC.lifeMax) < calamityGlobalNPC.newAI[0])
{
calamityGlobalNPC.newAI[0] -= 0.3f;
if (calamityGlobalNPC.newAI[0] <= 0.1f)
{
SoundEngine.PlaySound(SoundID.Item109, NPC.Center);
calamityGlobalNPC.newAI[2] = 2f;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
calamityGlobalNPC.newAI[3] = 0f;
SpawnDust();
}
else if (calamityGlobalNPC.newAI[0] <= 0.4f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.position.Y + NPC.height, ModContent.NPCType<Cataclysm>(), NPC.whoAmI);
NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.position.Y + NPC.height, ModContent.NPCType<Catastrophe>(), NPC.whoAmI);
}
string key = "Mods.CalamityMod.Status.Boss.CalamitasBossText2";
Color messageColor = Color.Orange;
CalamityUtils.DisplayLocalizedText(key, messageColor);
SpawnDust();
}
else
{
SoundEngine.PlaySound(SoundID.Item109, NPC.Center);
calamityGlobalNPC.newAI[2] = 1f;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
calamityGlobalNPC.newAI[3] = 0f;
SpawnDust();
}
}
}
// Immunity if brothers are alive
if (CalamityGlobalNPC.cataclysm != -1)
{
if (Main.npc[CalamityGlobalNPC.cataclysm].active)
brotherAlive = true;
}
if (CalamityGlobalNPC.catastrophe != -1)
{
if (Main.npc[CalamityGlobalNPC.catastrophe].active)
brotherAlive = true;
}
if (brotherAlive)
NPC.dontTakeDamage = true;
void SpawnDust()
{
int dustAmt = 50;
int random = 3;
for (int j = 0; j < 10; j++)
{
random += j;
int dustAmtSpawned = 0;
int scale = random * 6;
float dustPositionX = NPC.Center.X - (scale / 2);
float dustPositionY = NPC.Center.Y - (scale / 2);
while (dustAmtSpawned < dustAmt)
{
float dustVelocityX = Main.rand.Next(-random, random);
float dustVelocityY = Main.rand.Next(-random, random);
float dustVelocityScalar = random * 2f;
float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY);
dustVelocity = dustVelocityScalar / dustVelocity;
dustVelocityX *= dustVelocity;
dustVelocityY *= dustVelocity;
int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f);
Main.dust[dust].noGravity = true;
Main.dust[dust].position.X = NPC.Center.X;
Main.dust[dust].position.Y = NPC.Center.Y;
Main.dust[dust].position.X += Main.rand.Next(-10, 11);
Main.dust[dust].position.Y += Main.rand.Next(-10, 11);
Main.dust[dust].velocity.X = dustVelocityX;
Main.dust[dust].velocity.Y = dustVelocityY;
dustAmtSpawned++;
}
}
}
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
// Target variable
Player player = Main.player[NPC.target];
float enrageScale = bossRush ? 1f : 0f;
if (Main.IsItDay() || bossRush)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
// Rotation
Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.position.Y + NPC.height - 59f);
Vector2 lookAt = new Vector2(player.position.X - (player.width / 2), player.position.Y - (player.height / 2));
Vector2 rotationVector = npcCenter - lookAt;
// Boss Rush predictive charge rotation
if (NPC.ai[1] == 4f && phase4 && bossRush)
{
// Velocity
float chargeVelocity = 30f;
chargeVelocity += 5f * enrageScale;
lookAt += Main.player[NPC.target].velocity * 20f;
rotationVector = Vector2.Normalize(npcCenter - lookAt) * chargeVelocity;
}
float rotation = (float)Math.Atan2(rotationVector.Y, rotationVector.X) + MathHelper.PiOver2;
if (rotation < 0f)
rotation += MathHelper.TwoPi;
else if (rotation > MathHelper.TwoPi)
rotation -= MathHelper.TwoPi;
float rotationAmt = 0.1f;
if (NPC.rotation < rotation)
{
if ((rotation - NPC.rotation) > MathHelper.Pi)
NPC.rotation -= rotationAmt;
else
NPC.rotation += rotationAmt;
}
else if (NPC.rotation > rotation)
{
if ((NPC.rotation - rotation) > MathHelper.Pi)
NPC.rotation += rotationAmt;
else
NPC.rotation -= rotationAmt;
}
if (NPC.rotation > rotation - rotationAmt && NPC.rotation < rotation + rotationAmt)
NPC.rotation = rotation;
if (NPC.rotation < 0f)
NPC.rotation += MathHelper.TwoPi;
else if (NPC.rotation > MathHelper.TwoPi)
NPC.rotation -= MathHelper.TwoPi;
if (NPC.rotation > rotation - rotationAmt && NPC.rotation < rotation + rotationAmt)
NPC.rotation = rotation;
// Despawn
if (!player.active || player.dead)
{
NPC.TargetClosest(false);
player = Main.player[NPC.target];
if (!player.active || player.dead)
{
if (SoundEngine.TryGetActiveSound(BulletHellWarnSlot, out var warningSound) && warningSound.IsPlaying)
warningSound.Stop();
if (NPC.velocity.Y > 3f)
NPC.velocity.Y = 3f;
NPC.velocity.Y -= 0.1f;
if (NPC.velocity.Y < -12f)
NPC.velocity.Y = -12f;
if (NPC.timeLeft > 60)
NPC.timeLeft = 60;
if (NPC.ai[1] != 0f)
{
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
calamityGlobalNPC.newAI[2] = 0f;
calamityGlobalNPC.newAI[3] = 0f;
NPC.alpha = 0;
NPC.netUpdate = true;
}
return;
}
}
else if (NPC.timeLeft < 1800)
NPC.timeLeft = 1800;
// Distance from destination where Cal Clone stops moving
float movementDistanceGateValue = 100f;
// How fast Cal Clone moves to the destination
float baseVelocity = (expertMode ? 10f : 8.5f) * (NPC.ai[1] == 4f ? 1.4f : 1f);
float baseAcceleration = (expertMode ? 0.18f : 0.155f) * (NPC.ai[1] == 4f ? 1.4f : 1f);
baseVelocity += 4f * enrageScale;
baseAcceleration += 0.1f * enrageScale;
if (revenge)
{
baseVelocity += 1.5f * (1f - lifeRatio);
baseAcceleration += 0.03f * (1f - lifeRatio);
}
if (death)
{
baseVelocity += 1.5f * (1f - lifeRatio);
baseAcceleration += 0.03f * (1f - lifeRatio);
}
if (CalamityWorld.LegendaryMode)
{
baseVelocity *= 1.15f;
baseAcceleration *= 1.15f;
}
// What side Cal Clone should be on, relative to the target
int xPos = 1;
if (NPC.Center.X < player.Center.X)
xPos = -1;
// How far Cal Clone should be from the target
float averageDistance = 500f;
float chargeDistance = phase4 ? 300f : 400f;
// This is where Cal Clone should be
Vector2 destination = (calamityGlobalNPC.newAI[2] > 0f || NPC.ai[1] == 0f) ? new Vector2(player.Center.X, player.Center.Y - averageDistance) :
NPC.ai[1] == 1f ? new Vector2(player.Center.X + averageDistance * xPos, player.Center.Y) :
new Vector2(player.Center.X + chargeDistance * xPos, player.Center.Y);
// Add some random distance to the destination after certain attacks
if (NPC.localAI[0] == 1f)
{
NPC.localAI[0] = 0f;
NPC.localAI[2] = Main.rand.Next(-50, 51);
NPC.localAI[3] = Main.rand.Next(-300, 301);
NPC.netUpdate = true;
}
// Add a bit of randomness to the destination
if (death)
{
destination.X += NPC.ai[1] == 0f ? NPC.localAI[3] : NPC.localAI[2];
destination.Y += NPC.ai[1] == 0f ? NPC.localAI[2] : NPC.localAI[3];
}
// How far Cal Clone is from where she's supposed to be
Vector2 distanceFromDestination = destination - NPC.Center;
// Movement
if (NPC.ai[1] == 0f || NPC.ai[1] == 1f || NPC.ai[1] == 4f || calamityGlobalNPC.newAI[2] > 0f)
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, baseAcceleration, true);
// Bullet hell phase
if (calamityGlobalNPC.newAI[2] > 0f)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (calamityGlobalNPC.newAI[3] < 900f)
{
calamityGlobalNPC.newAI[3] += 1f;
NPC.dontTakeDamage = true;
NPC.alpha = 255;
float rotX = player.Center.X - NPC.Center.X;
float rotY = player.Center.Y - NPC.Center.Y;
NPC.rotation = (float)Math.Atan2(rotY, rotX) - MathHelper.PiOver2;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (calamityGlobalNPC.newAI[2] == 2f)
{
int type = ModContent.ProjectileType<SCalBrimstoneFireblast>();
int damage = NPC.GetProjectileDamage(type);
if (Main.zenithWorld)
type = ModContent.ProjectileType<SCalBrimstoneGigablast>();
float gigaBlastFrequency = (CalamityWorld.LegendaryMode ? 120f : expertMode ? 180f : 240f) - enrageScale * 15f;
float projSpeed = bossRush ? 6.25f : 5f;
if (calamityGlobalNPC.newAI[3] <= 300f)
{
if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer);
}
else if (calamityGlobalNPC.newAI[3] <= 600f && calamityGlobalNPC.newAI[3] > 300f)
{
if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from right
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -projSpeed, 0f, type, damage, 0f, Main.myPlayer);
}
else if (calamityGlobalNPC.newAI[3] > 600f)
{
if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer);
}
}
}
NPC.ai[0] += 1f;
float hellblastGateValue = (expertMode ? 12f : 16f) - enrageScale;
if (NPC.ai[0] >= hellblastGateValue)
{
NPC.ai[0] = 0f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<BrimstoneHellblast2>();
int damage = NPC.GetProjectileDamage(type);
float projSpeed = bossRush ? 4.5f : 4f;
// Blasts aimed directly at the player's horizontal position, does not spawn during the second bullet hell
if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f && calamityGlobalNPC.newAI[2] != 2f)
{
float distance = Main.rand.NextBool() ? -1000f : 1000f;
float velocity = distance == -1000f ? projSpeed : -projSpeed;
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
else // Blasts from above, left, and right
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
}
}
if (calamityGlobalNPC.newAI[3] == 900f - 360f)
BulletHellWarnSlot = SoundEngine.PlaySound(CalamitasClone.BulletHellWarning, player.Center);
if (calamityGlobalNPC.newAI[3] > 900f - 360f)
{
if (SoundEngine.TryGetActiveSound(BulletHellWarnSlot, out var warningSound) && warningSound.IsPlaying)
warningSound.Position = player.Center;
}
}
else
{
NPC.ai[0] = 0f;
NPC.ai[3] = 0f;
NPC.localAI[1] = 0f;
calamityGlobalNPC.newAI[2] = 0f;
calamityGlobalNPC.newAI[3] = 0f;
SoundEngine.PlaySound(CalamitasClone.BulletHellEnd, player.Center);
// Prevent bullshit charge hits when second bullet hell ends.
if (phase4)
{
NPC.ai[1] = 4f;
NPC.ai[2] = -105f;
NPC.TargetClosest();
}
else
{
if (death)
{
int AIState = Main.rand.Next(3);
switch (AIState)
{
case 0:
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
break;
case 1:
NPC.ai[1] = 1f;
NPC.ai[2] = 0f;
break;
case 2:
NPC.ai[1] = 4f;
NPC.ai[2] = -105f;
NPC.TargetClosest();
break;
}
}
else
{
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
}
if (death)
NPC.localAI[0] = 1f;
}
NPC.netUpdate = true;
for (int x = 0; x < Main.maxProjectiles; x++)
{
Projectile projectile = Main.projectile[x];
if (projectile.active)
{
if (projectile.type == ModContent.ProjectileType<BrimstoneHellblast2>() || projectile.type == ModContent.ProjectileType<BrimstoneBarrage>())
{
if (projectile.timeLeft > 60)
projectile.timeLeft = 60;
}
else if (projectile.type == ModContent.ProjectileType<SCalBrimstoneFireblast>())
{
projectile.ai[2] = 1f;
if (projectile.timeLeft > 60)
projectile.timeLeft = 60;
}
}
}
}
return;
}
else if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
{
if (calamityGlobalNPC.newAI[3] < 900f)
calamityGlobalNPC.newAI[3] += 1f;
else
calamityGlobalNPC.newAI[3] = 0f;
NPC.ai[0] += 1f;
float hellblastGateValue = 30f - enrageScale;
if (NPC.ai[0] >= hellblastGateValue)
{
NPC.ai[0] = 0f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<BrimstoneHellblast2>();
int damage = NPC.GetProjectileDamage(type);
float projSpeed = bossRush ? 5f : 4f;
if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f)
{
float distance = Main.rand.NextBool() ? -1000f : 1000f;
float velocity = distance == -1000f ? projSpeed : -projSpeed;
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
else // Blasts from above, left, and right
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f);
}
}
}
}
NPC.alpha = NPC.dontTakeDamage ? 255 : 0;
// Float above target and fire hellfireballs
if (NPC.ai[1] == 0f)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.ai[2] += 1f;
float phaseTimer = 400f - (death ? 120f * (1f - lifeRatio) : 0f);
if (NPC.ai[2] >= phaseTimer || phase4)
{
if (death && !phase4 && Main.rand.NextBool() && !brotherAlive)
NPC.ai[1] = 4f;
else
NPC.ai[1] = 1f;
NPC.ai[2] = 0f;
if (death)
NPC.localAI[0] = 1f;
NPC.netUpdate = true;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.localAI[1] += 1f;
if (!brotherAlive)
{
if (expertMode)
NPC.localAI[1] += death ? 2f * (1f - lifeRatio) : 1f - lifeRatio;
if (revenge)
NPC.localAI[1] += 0.5f;
}
if (NPC.localAI[1] >= (brotherAlive ? 180f : 120f))
{
NPC.localAI[1] = 0f;
SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HellfireballSound, NPC.Center);
float projectileVelocity = expertMode ? 14f : 12.5f;
projectileVelocity += 3f * enrageScale;
int type = ModContent.ProjectileType<BrimstoneHellfireball>();
int damage = NPC.GetProjectileDamage(type);
bool shootPredictiveShot = CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool();
Vector2 predictionVector = shootPredictiveShot ? player.velocity * 20f : Vector2.Zero;
Vector2 fireballVelocity = Vector2.Normalize(player.Center + predictionVector - NPC.Center) * projectileVelocity;
Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f;
int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, fireballVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y);
Main.projectile[proj].netUpdate = true;
}
}
}
// Float to the side of the target and fire
else if (NPC.ai[1] == 1f)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.localAI[1] += 1f;
if (!brotherAlive)
{
if (revenge)
NPC.localAI[1] += 0.5f;
if (expertMode)
NPC.localAI[1] += 0.5f;
}
if (NPC.localAI[1] >= (brotherAlive ? 75f : 50f) && Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height))
{
NPC.localAI[1] = 0f;
float projectileVelocity = expertMode ? 12.5f : 11f;
projectileVelocity += 3f * enrageScale;
int type = brotherAlive ? ModContent.ProjectileType<BrimstoneHellfireball>() : ModContent.ProjectileType<BrimstoneHellblast>();
int damage = NPC.GetProjectileDamage(type);
Vector2 fireballVelocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity;
Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f;
if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height))
{
type = ModContent.ProjectileType<BrimstoneHellfireball>();
damage = NPC.GetProjectileDamage(type);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, fireballVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y);
}
else
{
float ai0 = type == ModContent.ProjectileType<BrimstoneHellblast>() ? 1f : player.position.X;
float ai1 = type == ModContent.ProjectileType<BrimstoneHellblast>() ? 0f : player.position.Y;
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, fireballVelocity, type, damage, 0f, Main.myPlayer, ai0, ai1);
}
}
}
NPC.ai[2] += 1f;
float phaseTimer = 240f - (death ? 60f * (1f - lifeRatio) : 0f);
if (NPC.ai[2] >= phaseTimer || phase4)
{
if (death && !phase4 && Main.rand.NextBool() && !brotherAlive)
NPC.ai[1] = 0f;
else
NPC.ai[1] = !brotherAlive && phase2 && revenge ? 4f : 0f;
NPC.ai[2] = 0f;
if (death)
NPC.localAI[0] = 1f;
NPC.netUpdate = true;
}
}
else if (NPC.ai[1] == 2f)
{
// Set damage
NPC.damage = NPC.defDamage;
SoundEngine.PlaySound(CalamitasClone.ChargeSound, NPC.Center);
NPC.rotation = rotation;
float chargeVelocity = phase4 ? 30f : death ? 28f : 25f;
chargeVelocity += 5f * enrageScale;
Vector2 vector = Vector2.Normalize(player.Center + (phase4 && bossRush ? player.velocity * 20f : Vector2.Zero) - NPC.Center);
NPC.velocity = vector * chargeVelocity;
NPC.ai[1] = 3f;
NPC.netUpdate = true;
}
else if (NPC.ai[1] == 3f)
{
// Set damage
NPC.damage = NPC.defDamage;
NPC.ai[2] += 1f;
float chargeTime = phase4 ? 35f : death ? 40f : 45f;
if (NPC.ai[2] >= chargeTime)
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.velocity *= 0.9f;
if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1)
NPC.velocity.X = 0f;
if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1)
NPC.velocity.Y = 0f;
}
else
{
NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) - MathHelper.PiOver2;
// Leave behind slow hellblasts in Death Mode
if (Main.netMode != NetmodeID.MultiplayerClient && death && phase3 && NPC.ai[2] % (phase4 ? 6f : 10f) == 0f)
{
int type = ModContent.ProjectileType<BrimstoneHellblast>();
int damage = NPC.GetProjectileDamage(type);
Vector2 fireballVelocity = CalamityWorld.LegendaryMode ? Main.rand.NextVector2CircularEdge(0.02f, 0.02f) : NPC.velocity * 0.01f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, fireballVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f);
}
}
if (NPC.ai[2] >= chargeTime + 10f)
{
if (!phase4)
NPC.ai[3] += 1f;
NPC.ai[2] = 0f;
NPC.rotation = rotation;
NPC.netUpdate = true;
if (NPC.ai[3] >= 2f)
{
NPC.TargetClosest();
NPC.ai[1] = 0f;
NPC.ai[3] = 0f;
return;
}
NPC.ai[1] = 4f;
}
}
else
{
// Avoid cheap bullshit
NPC.damage = 0;
NPC.ai[2] += 1f;
if (NPC.ai[2] >= (phase4 ? 15f : 30f))
{
NPC.ai[1] = 2f;
NPC.ai[2] = 0f;
if (death)
NPC.localAI[0] = 1f;
NPC.netUpdate = true;
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+333 -2
View File
@@ -4,11 +4,12 @@ using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.Items.Placeables.Furniture.Trophies;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
@@ -109,7 +110,337 @@ namespace CalamityMod.NPCs.CalClone
public override void AI()
{
CalamitasCloneAI.VanillaCataclysmAI(NPC, Mod);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active)
{
if (NPC.alpha < 255)
{
NPC.velocity *= 0.9f;
NPC.alpha += 2;
if (NPC.alpha > 255)
NPC.alpha = 255;
int dustAmount = (int)Math.Round(MathHelper.Lerp(1f, 5f, (255 - NPC.alpha) / 255f));
for (int i = 0; i < dustAmount; i++)
{
int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, Main.rand.NextFloat(0.5f, 2f));
Main.dust[dust].noGravity = true;
Main.dust[dust].fadeIn = 1f;
}
}
else
NPC.active = false;
NPC.active = false;
return;
}
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
CalamityGlobalNPC.cataclysm = NPC.whoAmI;
// Emit light
Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1f, 0f, 0f);
bool bossRush = BossRushEvent.BossRushActive;
bool death = CalamityWorld.death || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool expertMode = Main.expertMode || bossRush;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
float enrageScale = bossRush ? 1f : 0f;
if (Main.IsItDay() || bossRush)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
float calCloneBroPlayerXDist = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2);
float calCloneBroPlayerYDist = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2);
float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2;
if (calCloneBroRotation < 0f)
calCloneBroRotation += MathHelper.TwoPi;
else if (calCloneBroRotation > MathHelper.TwoPi)
calCloneBroRotation -= MathHelper.TwoPi;
float calCloneBroRotationSpeed = 0.15f;
if (NPC.rotation < calCloneBroRotation)
{
if ((calCloneBroRotation - NPC.rotation) > MathHelper.Pi)
NPC.rotation -= calCloneBroRotationSpeed;
else
NPC.rotation += calCloneBroRotationSpeed;
}
else if (NPC.rotation > calCloneBroRotation)
{
if ((NPC.rotation - calCloneBroRotation) > MathHelper.Pi)
NPC.rotation += calCloneBroRotationSpeed;
else
NPC.rotation -= calCloneBroRotationSpeed;
}
if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed)
NPC.rotation = calCloneBroRotation;
if (NPC.rotation < 0f)
NPC.rotation += MathHelper.TwoPi;
else if (NPC.rotation > MathHelper.TwoPi)
NPC.rotation -= MathHelper.TwoPi;
if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed)
NPC.rotation = calCloneBroRotation;
if (!player.active || player.dead)
{
NPC.TargetClosest(false);
player = Main.player[NPC.target];
if (!player.active || player.dead)
{
if (NPC.velocity.Y > 3f)
NPC.velocity.Y = 3f;
NPC.velocity.Y -= 0.1f;
if (NPC.velocity.Y < -12f)
NPC.velocity.Y = -12f;
if (NPC.timeLeft > 60)
NPC.timeLeft = 60;
if (NPC.ai[1] != 0f)
{
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
NPC.netUpdate = true;
}
return;
}
}
if (NPC.ai[1] == 0f)
{
// Avoid cheap bullshit
NPC.damage = (int)Math.Round(NPC.defDamage * 0.5);
float calCloneBroProjAttackMaxSpeed = 5f;
float calCloneBroProjAttackAccel = 0.1f;
calCloneBroProjAttackMaxSpeed += 2f * enrageScale;
calCloneBroProjAttackAccel += 0.06f * enrageScale;
if (CalamityWorld.LegendaryMode)
{
calCloneBroProjAttackMaxSpeed *= 1.15f;
calCloneBroProjAttackAccel *= 1.15f;
}
int calCloneBroProjAttackDirection = 1;
if (NPC.position.X + (NPC.width / 2) < player.position.X + player.width)
calCloneBroProjAttackDirection = -1;
Vector2 calCloneBroProjLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
float calCloneBroProjTargetX = player.position.X + (player.width / 2) + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X;
float calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y;
float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY);
if (expertMode)
{
if (calCloneBroProjTargetDist > 300f)
calCloneBroProjAttackMaxSpeed += 0.5f;
if (calCloneBroProjTargetDist > 400f)
calCloneBroProjAttackMaxSpeed += 0.5f;
if (calCloneBroProjTargetDist > 500f)
calCloneBroProjAttackMaxSpeed += 0.55f;
if (calCloneBroProjTargetDist > 600f)
calCloneBroProjAttackMaxSpeed += 0.55f;
if (calCloneBroProjTargetDist > 700f)
calCloneBroProjAttackMaxSpeed += 0.6f;
if (calCloneBroProjTargetDist > 800f)
calCloneBroProjAttackMaxSpeed += 0.6f;
}
calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist;
calCloneBroProjTargetX *= calCloneBroProjTargetDist;
calCloneBroProjTargetY *= calCloneBroProjTargetDist;
if (NPC.velocity.X < calCloneBroProjTargetX)
{
NPC.velocity.X += calCloneBroProjAttackAccel;
if (NPC.velocity.X < 0f && calCloneBroProjTargetX > 0f)
NPC.velocity.X += calCloneBroProjAttackAccel;
}
else if (NPC.velocity.X > calCloneBroProjTargetX)
{
NPC.velocity.X -= calCloneBroProjAttackAccel;
if (NPC.velocity.X > 0f && calCloneBroProjTargetX < 0f)
NPC.velocity.X -= calCloneBroProjAttackAccel;
}
if (NPC.velocity.Y < calCloneBroProjTargetY)
{
NPC.velocity.Y += calCloneBroProjAttackAccel;
if (NPC.velocity.Y < 0f && calCloneBroProjTargetY > 0f)
NPC.velocity.Y += calCloneBroProjAttackAccel;
}
else if (NPC.velocity.Y > calCloneBroProjTargetY)
{
NPC.velocity.Y -= calCloneBroProjAttackAccel;
if (NPC.velocity.Y > 0f && calCloneBroProjTargetY < 0f)
NPC.velocity.Y -= calCloneBroProjAttackAccel;
}
NPC.ai[2] += 1f;
if (NPC.ai[2] >= (240f - (death ? 120f * (1f - lifeRatio) : 0f)))
{
NPC.ai[1] = 1f;
NPC.ai[2] = 0f;
NPC.target = 255;
NPC.netUpdate = true;
}
bool fireDelay = NPC.ai[2] > 120f || NPC.life < NPC.lifeMax * 0.9;
if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height) && fireDelay)
{
if (NPC.localAI[2] == 0f)
SoundEngine.PlaySound(Cataclysm.FlamethrowerStart, NPC.Center);
NPC.localAI[2] += 1f;
if (NPC.localAI[2] > 30f)
{
NPC.localAI[2] = 1f;
SoundEngine.PlaySound(Cataclysm.FlamethrowerLoop, NPC.Center);
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.localAI[1] += 3f;
if (revenge)
NPC.localAI[1] += 1f;
if (NPC.localAI[1] > 12f)
{
NPC.localAI[1] = 0f;
float calCloneBroProjSpeed = NPC.AnyNPCs(ModContent.NPCType<Catastrophe>()) ? 4f : 6f;
calCloneBroProjSpeed += enrageScale;
int type = ModContent.ProjectileType<BrimstoneFire>();
int damage = NPC.GetProjectileDamage(type);
calCloneBroProjLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X;
calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y;
calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY);
calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist;
calCloneBroProjTargetX *= calCloneBroProjTargetDist;
calCloneBroProjTargetY *= calCloneBroProjTargetDist;
calCloneBroProjTargetY += NPC.velocity.Y * 0.5f;
calCloneBroProjTargetX += NPC.velocity.X * 0.5f;
calCloneBroProjLocation.X -= calCloneBroProjTargetX;
calCloneBroProjLocation.Y -= calCloneBroProjTargetY;
Projectile.NewProjectile(NPC.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f);
}
}
}
}
else
{
if (NPC.ai[1] == 1f)
{
// Set damage
NPC.damage = NPC.defDamage;
SoundEngine.PlaySound(SoundID.Roar, NPC.Center);
NPC.rotation = calCloneBroRotation;
float calCloneBroChargeSpeed = 14f + (death ? 4f * (1f - lifeRatio) : 0f);
calCloneBroChargeSpeed += 3f * enrageScale;
if (expertMode)
calCloneBroChargeSpeed += 2f;
if (revenge)
calCloneBroChargeSpeed += 2f;
if (CalamityWorld.LegendaryMode)
calCloneBroChargeSpeed *= 1.25f;
Vector2 calCloneBroChargeCenter = NPC.Center;
float calCloneBroChargeTargetXDist = player.Center.X - calCloneBroChargeCenter.X;
float calCloneBroChargeTargetYDist = player.Center.Y - calCloneBroChargeCenter.Y;
float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist);
calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance;
NPC.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance;
NPC.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance;
NPC.ai[1] = 2f;
if (Main.zenithWorld)
{
SoundEngine.PlaySound(SupremeCalamitas.SupremeCalamitas.BrimstoneShotSound, NPC.Center);
int type = ModContent.ProjectileType<BrimstoneBarrage>();
int damage = NPC.GetProjectileDamage(ModContent.ProjectileType<BrimstoneFire>());
if (bossRush)
damage /= 2;
int totalProjectiles = bossRush ? 12 : death ? 10 : revenge ? 8 : expertMode ? 6 : 4;
float radians = MathHelper.TwoPi / totalProjectiles;
float velocity = 5f;
Vector2 spinningPoint = new Vector2(0f, -velocity);
float projectileVelocityToPass = velocity * 3f;
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass);
}
for (int i = 0; i < 6; i++)
Dust.NewDust(NPC.position + NPC.velocity, NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f);
}
return;
}
if (NPC.ai[1] == 2f)
{
// Set damage
NPC.damage = NPC.defDamage;
NPC.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f);
if (expertMode)
NPC.ai[2] += 0.25f;
if (revenge)
NPC.ai[2] += 0.25f;
if (NPC.ai[2] >= 75f)
{
// Avoid cheap bullshit
NPC.damage = (int)Math.Round(NPC.defDamage * 0.5);
NPC.velocity.X *= 0.93f;
NPC.velocity.Y *= 0.93f;
if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1)
NPC.velocity.X = 0f;
if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1)
NPC.velocity.Y = 0f;
}
else
NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) - MathHelper.PiOver2;
if (NPC.ai[2] >= 105f)
{
NPC.ai[3] += 1f;
NPC.ai[2] = 0f;
NPC.target = 255;
NPC.rotation = calCloneBroRotation;
if (NPC.ai[3] >= 3f)
{
NPC.ai[1] = 0f;
NPC.ai[3] = 0f;
return;
}
NPC.ai[1] = 1f;
}
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+329 -2
View File
@@ -4,12 +4,14 @@ using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.Items.Placeables.Furniture.Trophies;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
@@ -103,7 +105,332 @@ namespace CalamityMod.NPCs.CalClone
public override void AI()
{
CalamitasCloneAI.VanillaCatastropheAI(NPC, Mod);
CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity();
if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active)
{
if (NPC.alpha < 255)
{
NPC.velocity *= 0.9f;
NPC.alpha += 2;
if (NPC.alpha > 255)
NPC.alpha = 255;
int dustAmount = (int)Math.Round(MathHelper.Lerp(1f, 5f, (255 - NPC.alpha) / 255f));
for (int i = 0; i < dustAmount; i++)
{
int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, Main.rand.NextFloat(0.5f, 2f));
Main.dust[dust].noGravity = true;
Main.dust[dust].fadeIn = 1f;
}
}
else
NPC.active = false;
return;
}
// Percent life remaining
float lifeRatio = NPC.life / (float)NPC.lifeMax;
CalamityGlobalNPC.catastrophe = NPC.whoAmI;
// Emit light
Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1f, 0f, 0f);
bool bossRush = BossRushEvent.BossRushActive;
bool death = CalamityWorld.death || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool expertMode = Main.expertMode || bossRush;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
Player player = Main.player[NPC.target];
float enrageScale = bossRush ? 1f : 0f;
if (Main.IsItDay() || bossRush)
{
NPC.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
float calCloneBroPlayerXDist = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2);
float calCloneBroPlayerYDist = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2);
float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2;
if (calCloneBroRotation < 0f)
calCloneBroRotation += MathHelper.TwoPi;
else if (calCloneBroRotation > MathHelper.TwoPi)
calCloneBroRotation -= MathHelper.TwoPi;
float calCloneBroRotationSpeed = 0.15f;
if (NPC.rotation < calCloneBroRotation)
{
if ((calCloneBroRotation - NPC.rotation) > MathHelper.Pi)
NPC.rotation -= calCloneBroRotationSpeed;
else
NPC.rotation += calCloneBroRotationSpeed;
}
else if (NPC.rotation > calCloneBroRotation)
{
if ((NPC.rotation - calCloneBroRotation) > MathHelper.Pi)
NPC.rotation += calCloneBroRotationSpeed;
else
NPC.rotation -= calCloneBroRotationSpeed;
}
if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed)
NPC.rotation = calCloneBroRotation;
if (NPC.rotation < 0f)
NPC.rotation += MathHelper.TwoPi;
else if (NPC.rotation > MathHelper.TwoPi)
NPC.rotation -= MathHelper.TwoPi;
if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed)
NPC.rotation = calCloneBroRotation;
if (!player.active || player.dead)
{
NPC.TargetClosest(false);
player = Main.player[NPC.target];
if (!player.active || player.dead)
{
if (NPC.velocity.Y > 3f)
NPC.velocity.Y = 3f;
NPC.velocity.Y -= 0.1f;
if (NPC.velocity.Y < -12f)
NPC.velocity.Y = -12f;
if (NPC.timeLeft > 60)
NPC.timeLeft = 60;
if (NPC.ai[1] != 0f)
{
NPC.ai[1] = 0f;
NPC.ai[2] = 0f;
NPC.ai[3] = 0f;
NPC.netUpdate = true;
}
return;
}
}
if (NPC.ai[1] == 0f)
{
// Avoid cheap bullshit
NPC.damage = (int)Math.Round(NPC.defDamage * 0.5);
float calCloneBroProjAttackMaxSpeed = 4.5f;
float calCloneBroProjAttackAccel = 0.2f;
calCloneBroProjAttackMaxSpeed += 2f * enrageScale;
calCloneBroProjAttackAccel += 0.1f * enrageScale;
if (CalamityWorld.LegendaryMode)
{
calCloneBroProjAttackMaxSpeed *= 1.15f;
calCloneBroProjAttackAccel *= 1.15f;
}
int calCloneBroProjAttackDirection = 1;
if (NPC.Center.X < player.Center.X)
calCloneBroProjAttackDirection = -1;
Vector2 calCloneBroProjLocation = NPC.Center;
float calCloneBroProjTargetX = player.Center.X + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X;
float calCloneBroProjTargetY = player.Center.Y - calCloneBroProjLocation.Y;
float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY);
if (expertMode)
{
if (calCloneBroProjTargetDist > 300f)
calCloneBroProjAttackMaxSpeed += 0.5f;
if (calCloneBroProjTargetDist > 400f)
calCloneBroProjAttackMaxSpeed += 0.5f;
if (calCloneBroProjTargetDist > 500f)
calCloneBroProjAttackMaxSpeed += 0.55f;
if (calCloneBroProjTargetDist > 600f)
calCloneBroProjAttackMaxSpeed += 0.55f;
if (calCloneBroProjTargetDist > 700f)
calCloneBroProjAttackMaxSpeed += 0.6f;
if (calCloneBroProjTargetDist > 800f)
calCloneBroProjAttackMaxSpeed += 0.6f;
}
calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist;
calCloneBroProjTargetX *= calCloneBroProjTargetDist;
calCloneBroProjTargetY *= calCloneBroProjTargetDist;
if (NPC.velocity.X < calCloneBroProjTargetX)
{
NPC.velocity.X += calCloneBroProjAttackAccel;
if (NPC.velocity.X < 0f && calCloneBroProjTargetX > 0f)
NPC.velocity.X += calCloneBroProjAttackAccel;
}
else if (NPC.velocity.X > calCloneBroProjTargetX)
{
NPC.velocity.X -= calCloneBroProjAttackAccel;
if (NPC.velocity.X > 0f && calCloneBroProjTargetX < 0f)
NPC.velocity.X -= calCloneBroProjAttackAccel;
}
if (NPC.velocity.Y < calCloneBroProjTargetY)
{
NPC.velocity.Y += calCloneBroProjAttackAccel;
if (NPC.velocity.Y < 0f && calCloneBroProjTargetY > 0f)
NPC.velocity.Y += calCloneBroProjAttackAccel;
}
else if (NPC.velocity.Y > calCloneBroProjTargetY)
{
NPC.velocity.Y -= calCloneBroProjAttackAccel;
if (NPC.velocity.Y > 0f && calCloneBroProjTargetY < 0f)
NPC.velocity.Y -= calCloneBroProjAttackAccel;
}
NPC.ai[2] += 1f;
if (NPC.ai[2] >= (180f - (death ? 90f * (1f - lifeRatio) : 0f)))
{
NPC.ai[1] = 1f;
NPC.ai[2] = 0f;
NPC.target = 255;
NPC.netUpdate = true;
}
bool fireDelay = NPC.ai[2] > 120f || lifeRatio < 0.9f;
if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height) && fireDelay)
{
NPC.localAI[2] += 1f;
if (NPC.localAI[2] > 36f)
{
NPC.localAI[2] = 0f;
SoundEngine.PlaySound(SoundID.Item34, NPC.Center);
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.localAI[1] += 1f;
if (revenge)
NPC.localAI[1] += 0.5f;
if (NPC.localAI[1] > 50f)
{
NPC.localAI[1] = 0f;
float calCloneBroProjSpeed = death ? 14f : 12f;
calCloneBroProjSpeed += 3f * enrageScale;
int type = ModContent.ProjectileType<BrimstoneBall>();
int damage = NPC.GetProjectileDamage(type);
calCloneBroProjLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X;
calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y;
calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY);
calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist;
calCloneBroProjTargetX *= calCloneBroProjTargetDist;
calCloneBroProjTargetY *= calCloneBroProjTargetDist;
calCloneBroProjTargetY += NPC.velocity.Y * 0.5f;
calCloneBroProjTargetX += NPC.velocity.X * 0.5f;
calCloneBroProjLocation.X -= calCloneBroProjTargetX;
calCloneBroProjLocation.Y -= calCloneBroProjTargetY;
Projectile.NewProjectile(NPC.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f);
}
}
}
}
else
{
if (NPC.ai[1] == 1f)
{
// Set damage
NPC.damage = NPC.defDamage;
SoundEngine.PlaySound(SoundID.Roar, NPC.Center);
NPC.rotation = calCloneBroRotation;
float calCloneBroChargeSpeed = (NPC.AnyNPCs(ModContent.NPCType<Cataclysm>()) ? 12f : 16f) + (death ? 4f * (1f - lifeRatio) : 0f);
calCloneBroChargeSpeed += 4f * enrageScale;
if (expertMode)
calCloneBroChargeSpeed += 2f;
if (revenge)
calCloneBroChargeSpeed += 2f;
if (CalamityWorld.LegendaryMode)
calCloneBroChargeSpeed *= 1.25f;
Vector2 calCloneBroChargeCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
float calCloneBroChargeTargetXDist = player.position.X + (player.width / 2) - calCloneBroChargeCenter.X;
float calCloneBroChargeTargetYDist = player.position.Y + (player.height / 2) - calCloneBroChargeCenter.Y;
float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist);
calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance;
NPC.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance;
NPC.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance;
NPC.ai[1] = 2f;
if (Main.zenithWorld)
{
SoundEngine.PlaySound(SupremeCalamitas.SupremeCalamitas.BrimstoneShotSound, NPC.Center);
int type = ModContent.ProjectileType<BrimstoneBarrage>();
int damage = NPC.GetProjectileDamage(ModContent.ProjectileType<BrimstoneBall>());
if (bossRush)
damage /= 2;
int totalProjectiles = bossRush ? 12 : death ? 10 : revenge ? 8 : expertMode ? 6 : 4;
float radians = MathHelper.TwoPi / totalProjectiles;
float velocity = 5f;
Vector2 spinningPoint = new Vector2(0f, -velocity);
float projectileVelocityToPass = velocity * 3f;
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass);
}
for (int i = 0; i < 6; i++)
Dust.NewDust(NPC.position + NPC.velocity, NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f);
}
return;
}
if (NPC.ai[1] == 2f)
{
// Set damage
NPC.damage = NPC.defDamage;
NPC.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f);
if (expertMode)
NPC.ai[2] += 0.25f;
if (revenge)
NPC.ai[2] += 0.25f;
if (NPC.ai[2] >= 60f) //50
{
// Avoid cheap bullshit
NPC.damage = (int)Math.Round(NPC.defDamage * 0.5);
NPC.velocity.X *= 0.93f;
NPC.velocity.Y *= 0.93f;
if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1)
NPC.velocity.X = 0f;
if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1)
NPC.velocity.Y = 0f;
}
else
NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) - MathHelper.PiOver2;
if (NPC.ai[2] >= 90f) //80
{
NPC.ai[3] += 1f;
NPC.ai[2] = 0f;
NPC.rotation = calCloneBroRotation;
if (NPC.ai[3] >= 4f)
{
NPC.ai[1] = 0f;
NPC.ai[3] = 0f;
return;
}
NPC.ai[1] = 1f;
}
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
@@ -1,628 +0,0 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.AstrumAureus;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.NPCs.Bumblebirb;
using CalamityMod.NPCs.CalClone;
using CalamityMod.NPCs.CeaselessVoid;
using CalamityMod.NPCs.Crags;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.NPCs.OldDuke;
using CalamityMod.NPCs.SulphurousSea;
using CalamityMod.NPCs.SunkenSea;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Enemy;
using CalamityMod.Sounds;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs
{
public static class AquaticScourgeAI
{
public static void VanillaAquaticScourgeAI(NPC npc, Mod mod, bool head)
{
CalamityGlobalNPC calamityGlobalNPC = npc.Calamity();
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
bool getFuckedAI = Main.zenithWorld;
if (head)
CalamityGlobalNPC.aquaticScourge = npc.whoAmI;
// Adjust hostility and stats
bool nonHostile = calamityGlobalNPC.newAI[0] == 0f;
if (npc.justHit || npc.life <= npc.lifeMax * 0.999 || bossRush || Main.getGoodWorld)
{
if (nonHostile)
{
// Kiss my motherfucking ass you piece of shit game
npc.timeLeft *= 20;
npc.npcSlots = 16f;
CalamityGlobalNPC.BossKillTimes.TryGetValue(npc.type, out int revKillTime);
calamityGlobalNPC.KillTime = revKillTime;
calamityGlobalNPC.newAI[0] = 1f;
nonHostile = false;
npc.boss = head;
npc.chaseable = true;
npc.netUpdate = true;
}
}
else
npc.damage = 0;
// Percent life remaining
float lifeRatio = npc.life / (float)npc.lifeMax;
// Phases
bool phase2 = lifeRatio < 0.75f;
bool phase3 = lifeRatio < 0.5f;
bool phase4 = lifeRatio < 0.25f;
// Set worm variable
if (npc.ai[2] > 0f)
npc.realLife = (int)npc.ai[2];
if (!head)
{
if (npc.life > Main.npc[(int)npc.ai[1]].life)
npc.life = Main.npc[(int)npc.ai[1]].life;
}
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest();
Player player = Main.player[npc.target];
bool notOcean = player.position.Y < 300f ||
player.position.Y > Main.worldSurface * 16.0 ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
// Check for the flipped Abyss
if (Main.remixWorld)
{
notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer ||
(player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680));
}
// Enrage
if (head)
{
if (notOcean && !player.Calamity().ZoneSulphur && !bossRush)
{
if (npc.localAI[2] > 0f)
npc.localAI[2] -= 1f;
}
else
npc.localAI[2] = CalamityGlobalNPC.biomeEnrageTimerMax;
}
bool biomeEnraged = npc.localAI[2] <= 0f || bossRush;
float enrageScale = bossRush ? 1f : 0f;
if (biomeEnraged)
{
npc.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 2f;
}
// Circular movement
float colorFadeTimeAfterSpiral = 90f;
float spiralGateValue = 480f;
bool doSpiral = false;
if (head && calamityGlobalNPC.newAI[0] == 1f && calamityGlobalNPC.newAI[2] == 1f && (revenge || getFuckedAI))
{
doSpiral = calamityGlobalNPC.newAI[1] == 0f && calamityGlobalNPC.newAI[3] >= spiralGateValue;
if (Vector2.Distance(npc.Center, player.Center) < (getFuckedAI ? 1600f : 1000f) || doSpiral)
calamityGlobalNPC.newAI[3] += 1f;
if (doSpiral)
{
npc.localAI[3] = colorFadeTimeAfterSpiral;
// Vomit acid mist
float acidMistBarfDivisor = getFuckedAI ? 2f : ((float)Math.Floor(bossRush ? 4f : death ? 5f : 6f) * (phase3 ? 1.5f : 1f));
if (calamityGlobalNPC.newAI[3] % acidMistBarfDivisor == 0f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float mistVelocity = death ? 10f : 8f;
Vector2 projectileVelocity = (npc.Center + npc.velocity * 10f - npc.Center).SafeNormalize(Vector2.UnitY);
int type = ModContent.ProjectileType<SulphuricAcidMist>();
int damage = npc.GetProjectileDamage(type);
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity * 5f, projectileVelocity * mistVelocity, type, damage, 0f, Main.myPlayer);
Main.projectile[proj].tileCollide = false;
Main.projectile[proj].timeLeft = getFuckedAI ? 240 : 600;
}
}
// Vomit circular spreads of acid clouds while in phase 3
float toxicCloudBarfDivisor = bossRush ? 20f : death ? 30f : 40f;
if (calamityGlobalNPC.newAI[3] % toxicCloudBarfDivisor == 0f && phase3)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<ToxicCloud>();
int damage = npc.GetProjectileDamage(type);
int totalProjectiles = (phase4 ? 6 : 9) + (getFuckedAI ? Main.rand.Next(-2, 3) : (int)((calamityGlobalNPC.newAI[3] - spiralGateValue) / toxicCloudBarfDivisor) * (phase4 ? 2 : 3));
float radians = MathHelper.TwoPi / totalProjectiles;
float cloudVelocity = 1f + enrageScale;
Vector2 spinningPoint = new Vector2(0f, -cloudVelocity);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 vector255 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer);
}
}
}
// Velocity boost
if (calamityGlobalNPC.newAI[3] == spiralGateValue)
{
npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY);
npc.velocity *= 24f;
}
// Spin velocity
float velocity = (float)(Math.PI * 2D) / 120f;
// In GFB, contracts the radius as the fight progresses
if (getFuckedAI)
velocity *= phase3 ? 1.5f : phase2 ? 1.25f : 1f;
npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.localAI[1]);
// Speed up even more in GFB for more radius
if (getFuckedAI && npc.velocity.Length() <= 32f)
npc.velocity *= 1.1f;
npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2;
// Reset and charge at target
// Don't reset in GFB
if (!getFuckedAI && calamityGlobalNPC.newAI[3] >= spiralGateValue + 120f)
{
calamityGlobalNPC.newAI[3] = 0f;
npc.TargetClosest();
}
}
else
{
if (!Collision.CanHit(npc.Center, 1, 1, player.position, player.width, player.height) && calamityGlobalNPC.newAI[3] > 300f)
calamityGlobalNPC.newAI[3] -= 2f;
if (npc.localAI[3] > 0f)
npc.localAI[3] -= 1f;
npc.localAI[1] = npc.Center.X - player.Center.X < 0 ? 1f : -1f;
}
}
// Adjust slowing debuff immunity
bool immuneToSlowingDebuffs = doSpiral || getFuckedAI;
npc.buffImmune[ModContent.BuffType<GlacialState>()] = immuneToSlowingDebuffs;
npc.buffImmune[ModContent.BuffType<TemporalSadness>()] = immuneToSlowingDebuffs;
npc.buffImmune[ModContent.BuffType<Eutrophication>()] = immuneToSlowingDebuffs;
npc.buffImmune[ModContent.BuffType<TimeDistortion>()] = immuneToSlowingDebuffs;
npc.buffImmune[ModContent.BuffType<GalvanicCorrosion>()] = immuneToSlowingDebuffs;
npc.buffImmune[ModContent.BuffType<Vaporfied>()] = immuneToSlowingDebuffs;
npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs;
npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs;
if (head)
{
// Spawn segments
if (calamityGlobalNPC.newAI[2] == 0f && npc.ai[0] == 0f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int maxLength = getFuckedAI ? 24 : death ? 80 : revenge ? 40 : expertMode ? 35 : 30;
int Previous = npc.whoAmI;
for (int segments = 0; segments < maxLength; segments++)
{
int lol;
if (segments >= 0 && segments < maxLength - 1)
{
if (segments % 2 == 0)
lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType<AquaticScourgeBodyAlt>(), npc.whoAmI);
else
lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType<AquaticScourgeBody>(), npc.whoAmI);
}
else
lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType<AquaticScourgeTail>(), npc.whoAmI);
Main.npc[lol].realLife = npc.whoAmI;
Main.npc[lol].ai[2] = npc.whoAmI;
Main.npc[lol].ai[1] = Previous;
Main.npc[Previous].ai[0] = lol;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol);
Previous = lol;
}
}
calamityGlobalNPC.newAI[2] = 1f;
}
// Big barf attack
if (calamityGlobalNPC.newAI[0] == 1f && (!doSpiral && phase2) || (getFuckedAI && !phase3))
{
npc.localAI[0] += 1f;
if (npc.localAI[0] >= (revenge ? 360f : 420f))
{
if (Vector2.Distance(player.Center, npc.Center) > 320f)
{
npc.localAI[0] = 0f;
npc.netUpdate = true;
SoundEngine.PlaySound(SoundID.NPCDeath13, npc.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int totalProjectiles = bossRush ? 10 : expertMode ? 8 : 6;
if (phase3)
totalProjectiles *= 2;
int type = ModContent.ProjectileType<SandPoisonCloud>();
int damage = npc.GetProjectileDamage(type);
for (int i = 0; i < totalProjectiles; i++)
{
Vector2 velocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
velocity = velocity.SafeNormalize(Vector2.UnitY);
velocity *= Main.rand.Next(phase3 ? 300 : 100, 401) * 0.01f;
float maximumVelocityMult = death ? 0.75f : 0.5f;
if (expertMode)
velocity *= 1f + (maximumVelocityMult * (0.5f - lifeRatio));
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + velocity.SafeNormalize(Vector2.UnitY) * 5f, velocity, type, damage, 0f, Main.myPlayer);
}
}
}
}
}
}
// Fire teeth depending on body type
else
{
if (calamityGlobalNPC.newAI[0] == 1f && (!phase3 || phase4))
{
npc.localAI[0] += 1f;
float shootProjectile = 300;
float timer = npc.ai[0] + 15f;
float divisor = timer + shootProjectile;
if (npc.type == ModContent.NPCType<AquaticScourgeBody>())
{
if (npc.localAI[0] % divisor == 0f && (npc.ai[0] % 3f == 0f || getFuckedAI || !death))
{
npc.TargetClosest();
if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
{
SoundEngine.PlaySound(SoundID.Item17, npc.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float toothVelocity = death ? 9f : 8f;
Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY);
int type = ModContent.ProjectileType<SandTooth>();
int damage = npc.GetProjectileDamage(type);
float accelerate = phase4 ? 1f : 0f;
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity * 5f, projectileVelocity * toothVelocity, type, damage, 0f, Main.myPlayer, accelerate, 0f);
}
npc.netUpdate = true;
}
}
}
}
}
// Kill body and tail
if (!head)
{
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<AquaticScourgeHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)npc.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
}
else
{
if (npc.life > Main.npc[(int)npc.ai[0]].life)
npc.life = Main.npc[(int)npc.ai[0]].life;
}
float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f;
if (player.dead || Vector2.Distance(npc.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged))
{
calamityGlobalNPC.newAI[1] = 1f;
npc.TargetClosest(false);
npc.velocity.Y += 2f;
if (npc.position.Y > Main.worldSurface * 16D)
npc.velocity.Y += 2f;
if (npc.position.Y > Main.worldSurface * 16D)
{
for (int a = 0; a < Main.npc.Length; a++)
{
int type = Main.npc[a].type;
if (type == ModContent.NPCType<AquaticScourgeHead>() || type == ModContent.NPCType<AquaticScourgeBody>() || type == ModContent.NPCType<AquaticScourgeBodyAlt>() || type == ModContent.NPCType<AquaticScourgeTail>())
Main.npc[a].active = false;
}
}
}
else
calamityGlobalNPC.newAI[1] = 0f;
// Change direction
if (npc.velocity.X < 0f)
npc.spriteDirection = -1;
else if (npc.velocity.X > 0f)
npc.spriteDirection = 1;
// Alpha changes
if (head || Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
npc.alpha = 0;
}
Vector2 scourgePosition = npc.Center;
Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[npc.target].velocity * 20f : Vector2.Zero;
float scourgeTargetX = player.Center.X + predictionVector.X;
float scourgeTargetY = player.Center.Y + predictionVector.Y;
// Velocity and movement
float scourgeMaxSpeed = 5f;
float scourgeAcceleration = 0.08f;
if (calamityGlobalNPC.newAI[0] == 1f)
{
scourgeMaxSpeed = revenge ? 14.4f : 12f;
scourgeAcceleration = revenge ? 0.18f : 0.15f;
if (expertMode)
{
scourgeMaxSpeed += 2.4f * (1f - lifeRatio);
scourgeAcceleration += 0.03f * (1f - lifeRatio);
}
scourgeMaxSpeed += 3f * enrageScale;
scourgeAcceleration += 0.06f * enrageScale;
if (death || getFuckedAI)
{
scourgeMaxSpeed += 5f;
scourgeAcceleration -= getFuckedAI ? 0f : 0.03f;
scourgeMaxSpeed += Vector2.Distance(player.Center, npc.Center) * 0.001f;
scourgeAcceleration += Vector2.Distance(player.Center, npc.Center) * 0.000045f;
}
// Increase acceleration after spiral attack
if (npc.localAI[3] > 0f)
{
float accelerationMultiplier = MathHelper.Lerp(1f, 2f, npc.localAI[3] / colorFadeTimeAfterSpiral);
scourgeAcceleration *= accelerationMultiplier;
}
if (Main.getGoodWorld)
{
scourgeMaxSpeed *= 1.15f;
scourgeAcceleration *= 1.15f;
}
}
if (head && !doSpiral)
{
if (calamityGlobalNPC.newAI[0] != 1f)
{
scourgeTargetY += 400;
if (Math.Abs(npc.Center.X - player.Center.X) < 500f)
{
if (npc.velocity.X > 0f)
scourgeTargetX = player.Center.X + 600f;
else
scourgeTargetX = player.Center.X - 600f;
}
}
float scourgeHigherSpeed = scourgeMaxSpeed * 1.3f;
float scourgeLowerSpeed = scourgeMaxSpeed * 0.7f;
float scourgeSpeed = npc.velocity.Length();
if (scourgeSpeed > 0f)
{
if (scourgeSpeed > scourgeHigherSpeed)
{
npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY);
npc.velocity *= scourgeHigherSpeed;
}
else if (scourgeSpeed < scourgeLowerSpeed)
{
npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY);
npc.velocity *= scourgeLowerSpeed;
}
}
}
scourgeTargetX = (int)(scourgeTargetX / 16f) * 16;
scourgeTargetY = (int)(scourgeTargetY / 16f) * 16;
scourgePosition.X = (int)(scourgePosition.X / 16f) * 16;
scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16;
scourgeTargetX -= scourgePosition.X;
scourgeTargetY -= scourgePosition.Y;
float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY);
if (!head)
{
if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length)
{
try
{
scourgePosition = npc.Center;
scourgeTargetX = Main.npc[(int)npc.ai[1]].Center.X - scourgePosition.X;
scourgeTargetY = Main.npc[(int)npc.ai[1]].Center.Y - scourgePosition.Y;
}
catch
{
}
npc.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2;
scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY);
int scourgeWidth = npc.width;
scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist;
scourgeTargetX *= scourgeTargetDist;
scourgeTargetY *= scourgeTargetDist;
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + scourgeTargetX;
npc.position.Y = npc.position.Y + scourgeTargetY;
if (scourgeTargetX < 0f)
npc.spriteDirection = -1;
else if (scourgeTargetX > 0f)
npc.spriteDirection = 1;
}
}
else if (!doSpiral)
{
float scourgeAbsoluteTargetX = Math.Abs(scourgeTargetX);
float scourgeAbsoluteTargetY = Math.Abs(scourgeTargetY);
float scourgeTimeToReachTarget = scourgeMaxSpeed / scourgeTargetDist;
scourgeTargetX *= scourgeTimeToReachTarget;
scourgeTargetY *= scourgeTimeToReachTarget;
if ((npc.velocity.X > 0f && scourgeTargetX > 0f) || (npc.velocity.X < 0f && scourgeTargetX < 0f) || (npc.velocity.Y > 0f && scourgeTargetY > 0f) || (npc.velocity.Y < 0f && scourgeTargetY < 0f))
{
if (npc.velocity.X < scourgeTargetX)
{
npc.velocity.X += scourgeAcceleration;
}
else
{
if (npc.velocity.X > scourgeTargetX)
npc.velocity.X -= scourgeAcceleration;
}
if (npc.velocity.Y < scourgeTargetY)
{
npc.velocity.Y += scourgeAcceleration;
}
else
{
if (npc.velocity.Y > scourgeTargetY)
npc.velocity.Y -= scourgeAcceleration;
}
if (Math.Abs(scourgeTargetY) < scourgeMaxSpeed * 0.2 && ((npc.velocity.X > 0f && scourgeTargetX < 0f) || (npc.velocity.X < 0f && scourgeTargetX > 0f)))
{
if (npc.velocity.Y > 0f)
npc.velocity.Y += scourgeAcceleration * 2f;
else
npc.velocity.Y -= scourgeAcceleration * 2f;
}
if (Math.Abs(scourgeTargetX) < scourgeMaxSpeed * 0.2 && ((npc.velocity.Y > 0f && scourgeTargetY < 0f) || (npc.velocity.Y < 0f && scourgeTargetY > 0f)))
{
if (npc.velocity.X > 0f)
npc.velocity.X += scourgeAcceleration * 2f;
else
npc.velocity.X -= scourgeAcceleration * 2f;
}
}
else
{
if (scourgeAbsoluteTargetX > scourgeAbsoluteTargetY)
{
if (npc.velocity.X < scourgeTargetX)
npc.velocity.X += scourgeAcceleration * 1.1f;
else if (npc.velocity.X > scourgeTargetX)
npc.velocity.X -= scourgeAcceleration * 1.1f;
if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < scourgeMaxSpeed * 0.5)
{
if (npc.velocity.Y > 0f)
npc.velocity.Y += scourgeAcceleration;
else
npc.velocity.Y -= scourgeAcceleration;
}
}
else
{
if (npc.velocity.Y < scourgeTargetY)
npc.velocity.Y += scourgeAcceleration * 1.1f;
else if (npc.velocity.Y > scourgeTargetY)
npc.velocity.Y -= scourgeAcceleration * 1.1f;
if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < scourgeMaxSpeed * 0.5)
{
if (npc.velocity.X > 0f)
npc.velocity.X += scourgeAcceleration;
else
npc.velocity.X -= scourgeAcceleration;
}
}
}
npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2;
}
// Calculate contact damage based on velocity
if (!nonHostile)
{
float minimalContactDamageVelocity = scourgeMaxSpeed * 0.25f;
float minimalDamageVelocity = scourgeMaxSpeed * 0.5f;
if (head)
{
if (npc.velocity.Length() <= minimalContactDamageVelocity)
{
npc.damage = (int)Math.Round(npc.defDamage * 0.5);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar);
}
}
else
{
float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
npc.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar);
}
}
}
}
}
}
@@ -1,969 +0,0 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.AstrumAureus;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.NPCs.Bumblebirb;
using CalamityMod.NPCs.CalClone;
using CalamityMod.NPCs.CeaselessVoid;
using CalamityMod.NPCs.Crags;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.NPCs.OldDuke;
using CalamityMod.NPCs.SulphurousSea;
using CalamityMod.NPCs.SunkenSea;
using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Enemy;
using CalamityMod.Sounds;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs
{
public static class AstrumAureusAI
{
public static void VanillaAstrumAureusAI(NPC npc, Mod mod)
{
CalamityGlobalNPC calamityGlobalNPC = npc.Calamity();
CalamityGlobalNPC.astrumAureus = npc.whoAmI;
// Variables
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
// Percent life remaining
float lifeRatio = npc.life / (float)npc.lifeMax;
// Phases
bool phase2 = lifeRatio < (revenge ? 0.85f : expertMode ? 0.8f : 0.75f);
bool phase3 = lifeRatio < (revenge ? 0.7f : expertMode ? 0.6f : 0.5f);
bool phase4 = lifeRatio < (revenge ? 0.5f : 0.4f) && expertMode;
bool phase5 = lifeRatio < 0.3f && revenge;
// Exhaustion
bool exhausted = npc.ai[2] >= (phase3 ? 2f : 1f);
calamityGlobalNPC.DR = exhausted ? 0.2f : 0.4f;
npc.defense = exhausted ? npc.defDefense / 2 : npc.defDefense;
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest();
// Despawn safety, make sure to target another player if the current player target is too far away
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles)
npc.TargetClosest();
Player player = Main.player[npc.target];
// Don't fire projectiles and don't increment phase timers for 4 seconds after the teleport phase to avoid cheap bullshit
float noProjectileOrPhaseIncrementTime = 240f;
bool dontAttack = npc.localAI[3] > 0f;
if (dontAttack)
{
npc.localAI[3] -= 1f;
if (npc.Distance(player.Center) < 240f)
npc.localAI[3] -= death ? 4f : expertMode ? 2f : 1f;
}
float enrageScale = bossRush ? 1f : 0f;
if ((Main.IsItDay() && !player.Calamity().ZoneAstral) || bossRush)
{
npc.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1f;
}
float astralFlameBarrageTimerIncrement = 1f;
if (expertMode)
astralFlameBarrageTimerIncrement += death ? (float)Math.Round(3f * (1f - lifeRatio)) : (float)Math.Round(2f * (1f - lifeRatio));
float walkingVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 6f : 5f;
walkingVelocity += 3f * enrageScale;
if (phase5)
walkingVelocity += 2f;
if (expertMode)
walkingVelocity += 1.5f * (1f - lifeRatio);
if (revenge)
walkingVelocity += Math.Abs(npc.Center.X - player.Center.X) * 0.0025f;
if (Main.getGoodWorld)
walkingVelocity *= 1.15f;
float walkingProjectileVelocity = walkingVelocity * 0.8f;
// Direction
npc.spriteDirection = (npc.direction > 0) ? 1 : -1;
// Used to reduce Aureus' fall speed
bool reduceFallSpeed = npc.velocity.Y > 0f && Collision.SolidCollision(npc.position + Vector2.UnitY * 1.1f * npc.velocity.Y, npc.width, npc.height) && npc.ai[0] == 4f;
// Despawn
bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
if (!player.active || player.dead || despawnDistance)
{
npc.TargetClosest(false);
player = Main.player[npc.target];
if (!player.active || player.dead || despawnDistance)
{
npc.noTileCollide = true;
if (npc.velocity.Y < -3f)
npc.velocity.Y = -3f;
npc.velocity.Y += 0.1f;
if (npc.velocity.Y > 12f)
npc.velocity.Y = 12f;
if (npc.timeLeft > 60)
npc.timeLeft = 60;
if (npc.ai[0] != 0f)
{
npc.ai[0] = 0f;
npc.ai[1] = 0f;
npc.ai[2] = 0f;
npc.ai[3] = 0f;
npc.localAI[2] = 0f;
npc.localAI[3] = 0f;
calamityGlobalNPC.newAI[0] = 0f;
calamityGlobalNPC.newAI[1] = 0f;
npc.netUpdate = true;
}
return;
}
}
else if (npc.timeLeft < 1800)
npc.timeLeft = 1800;
bool geldonPhase1 = lifeRatio > 0.6f && lifeRatio <= 0.7f;
bool geldonPhase2 = lifeRatio <= 0.1f;
if (Main.zenithWorld && (geldonPhase1 || geldonPhase2))
{
AstrumAureus.AstrumAureus astrumAureus = npc.ModNPC<AstrumAureus.AstrumAureus>();
astrumAureus.slimeProjCounter++;
if (astrumAureus.slimeProjCounter % 180 == 0)
{
SoundEngine.PlaySound(SoundID.Item33, npc.Center); // Intentionally keeping the old laser sound in GFB
if (astrumAureus.slimePhase == 1)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<AstralFlame>();
int damage = npc.GetProjectileDamage(type);
int totalProjectiles = bossRush ? 14 : death ? 12 : revenge ? 10 : expertMode ? 8 : 6;
float radians = MathHelper.TwoPi / totalProjectiles;
float velocity = 10f;
Vector2 spinningPoint = new Vector2(0f, -velocity);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f);
}
}
astrumAureus.slimePhase = 0;
}
else
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<AstralLaser>();
int damage = npc.GetProjectileDamage(type);
float aureusLaserSpeed = 7f;
float aureusLaserTargetX = player.Center.X - npc.Center.X;
float aureusLaserTargetY = player.Center.Y - npc.Center.Y;
float aureusLaserTargetDist = (float)Math.Sqrt(aureusLaserTargetX * aureusLaserTargetX + aureusLaserTargetY * aureusLaserTargetY);
aureusLaserTargetDist = aureusLaserSpeed / aureusLaserTargetDist;
aureusLaserTargetX *= aureusLaserTargetDist;
aureusLaserTargetY *= aureusLaserTargetDist;
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, aureusLaserTargetX, aureusLaserTargetY, type, damage, 0f, Main.myPlayer);
for (int i = 0; i < 4; i++)
{
Vector2 offset = new Vector2(Main.rand.Next(-6, 7), Main.rand.Next(-6, 7));
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, aureusLaserTargetX + offset.X, aureusLaserTargetY + offset.Y, type, damage, 0f, Main.myPlayer);
}
}
astrumAureus.slimePhase = 1;
}
}
RevengeanceAndDeathAI.BuffedMimicAI(npc, mod);
npc.noGravity = false;
npc.noTileCollide = false;
return;
}
else
{
npc.noGravity = true;
}
// Emit light when not Idle
if (npc.ai[0] != 1f)
Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1.3f, 0.5f, 0f);
// Fire projectiles while walking, teleporting, or falling
if (npc.ai[0] == 2f || npc.ai[0] >= 5f)
{
if (!dontAttack)
npc.localAI[0] += npc.ai[0] == 2f ? 1f : astralFlameBarrageTimerIncrement;
float astralFlameBarrageGateValue = phase4 ? 30f : 60f;
if (npc.localAI[0] >= astralFlameBarrageGateValue)
{
// Fire astral flames while teleporting
if (npc.ai[0] >= 5f && npc.ai[0] != 7)
{
npc.localAI[0] = 0f;
SoundEngine.PlaySound(AstrumAureus.AstrumAureus.FlameCrystalSound, npc.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float velocity = death ? (8f + npc.localAI[2] * 0.025f) : 7f;
int type = ModContent.ProjectileType<AstralFlame>();
int damage = npc.GetProjectileDamage(type);
float spreadLimit = (phase4 ? 100f : 50f) + enrageScale * 50f;
float randomSpread = (Main.rand.NextFloat() - 0.5f) * spreadLimit;
Vector2 spawnVector = new Vector2(npc.Center.X, npc.Center.Y - 80f * npc.scale);
Vector2 destination = new Vector2(spawnVector.X + randomSpread, spawnVector.Y - 100f * npc.scale);
Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, Vector2.Normalize(destination - spawnVector) * velocity, type, damage, 0f, Main.myPlayer);
}
}
}
float laserBarrageGateValue = phase5 ? 160f : phase3 ? 120f : phase2 ? 80f : 60f;
if (npc.localAI[0] >= laserBarrageGateValue)
{
// Fire astral lasers while walking
if (npc.ai[0] == 2f)
{
npc.localAI[0] = 0f;
SoundEngine.PlaySound(AstrumAureus.AstrumAureus.LaserSound, npc.Center);
if (calamityGlobalNPC.newAI[2] == 0f)
{
calamityGlobalNPC.newAI[2] = 1f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int maxProjectiles = !phase2 ? (bossRush ? 5 : 3) : (bossRush ? 7 : 5);
int spread = !phase2 ? (bossRush ? 11 : 8) : (bossRush ? 12 : 10);
int type = ModContent.ProjectileType<AstralLaser>();
int damage = npc.GetProjectileDamage(type);
Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * walkingProjectileVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f);
}
if (phase3)
{
float flameVelocity = walkingProjectileVelocity;
maxProjectiles = 2;
spread = 45;
type = ModContent.ProjectileType<AstralFlame>();
damage = npc.GetProjectileDamage(type);
projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * flameVelocity;
rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer);
}
}
}
}
else
{
calamityGlobalNPC.newAI[2] = 0f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 19 : death ? 17 : 15);
int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20);
int type = ModContent.ProjectileType<AstralLaser>();
int damage = npc.GetProjectileDamage(type);
int centralLaser = maxProjectiles / 2;
int[] lasersToNotFire = new int[6] { centralLaser - 3, centralLaser - 2, centralLaser - 1, centralLaser + 1, centralLaser + 2, centralLaser + 3 };
Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * walkingProjectileVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3] && i != lasersToNotFire[4] && i != lasersToNotFire[5])
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f);
}
}
}
}
}
}
}
else
npc.localAI[0] = 0f;
// Start up
if (npc.ai[0] == 0f)
{
// Avoid cheap bullshit
npc.damage = 0;
npc.ai[0] = 1f;
npc.netUpdate = true;
CustomGravity();
}
// Idle
else if (npc.ai[0] == 1f)
{
// Avoid cheap bullshit
npc.damage = 0;
// Slow down
npc.velocity.X *= 0.8f;
// Stay vulnerable for 3 seconds
npc.ai[1] += 1f;
if (npc.Distance(player.Center) < 240f)
npc.ai[1] += death ? 4f : expertMode ? 2f : 1f;
if (npc.ai[1] >= 180f || bossRush)
{
// Set AI to random state and reset other AI arrays
npc.TargetClosest();
switch (Main.rand.Next(phase3 ? 3 : 2))
{
case 0:
npc.ai[0] = 2f;
break;
case 1:
npc.ai[0] = 3f;
break;
case 2:
npc.ai[0] = 5f;
break;
default:
break;
}
npc.ai[1] = 0f;
npc.ai[2] = 0f;
// Stop colliding with tiles if entering walking phase
npc.noTileCollide = npc.ai[0] == 2f;
npc.netUpdate = true;
}
else
CustomGravity();
}
// Walk
else if (npc.ai[0] == 2f)
{
// Avoid cheap bullshit
npc.damage = 0;
// Set walking direction
if (Math.Abs(npc.Center.X - player.Center.X) < 200f * npc.scale)
{
npc.velocity.X *= 0.8f;
if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1)
npc.velocity.X = 0f;
}
else
{
float playerLocation = npc.Center.X - player.Center.X;
npc.direction = playerLocation < 0 ? 1 : -1;
if (npc.direction > 0)
npc.velocity.X = (npc.velocity.X * 20f + walkingVelocity) / 21f;
if (npc.direction < 0)
npc.velocity.X = (npc.velocity.X * 20f - walkingVelocity) / 21f;
}
if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height && !npc.collideX)
{
CustomGravity();
npc.noTileCollide = false;
}
else
{
npc.noTileCollide = true;
// Walk through tiles if colliding with tiles and player is out of reach
int aureusHitboxWidth = 80;
int aureusHitboxHeight = 20;
Vector2 aureusHitboxTileCollideSize = new Vector2(npc.Center.X - (aureusHitboxWidth / 2), npc.position.Y + npc.height - aureusHitboxHeight);
bool nearPlayerWalkingThroughTiles = false;
if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f)
nearPlayerWalkingThroughTiles = true;
if (nearPlayerWalkingThroughTiles)
{
npc.velocity.Y += 0.5f;
}
else if (Collision.SolidCollision(aureusHitboxTileCollideSize, aureusHitboxWidth, aureusHitboxHeight))
{
if (npc.velocity.Y > 0f)
npc.velocity.Y = 0f;
if (npc.velocity.Y > -0.2)
npc.velocity.Y -= 0.025f;
else
npc.velocity.Y -= 0.2f;
if (npc.velocity.Y < -4f)
npc.velocity.Y = -4f;
}
else
{
if (npc.velocity.Y < 0f)
npc.velocity.Y = 0f;
if (npc.velocity.Y < 0.1)
npc.velocity.Y += 0.025f;
else
npc.velocity.Y += 0.5f;
}
}
// Walk for a maximum of 6 seconds
if (!dontAttack)
{
npc.ai[1] += 1f;
if (npc.Distance(player.Center) < 240f)
npc.ai[1] += death ? 4f : expertMode ? 2f : 1f;
}
if (npc.ai[1] >= ((bossRush ? 270f : 360f) - (death ? 90f * (1f - lifeRatio) : 0f)))
{
// Collide with tiles again
npc.noTileCollide = false;
// Set AI to next phase (Jump) and reset other AI
npc.TargetClosest();
npc.ai[0] = exhausted ? 1f : 3f;
npc.ai[1] = 0f;
npc.ai[2] += 1f;
npc.netUpdate = true;
}
// Limit downward velocity
if (npc.velocity.Y > 10f)
npc.velocity.Y = 10f;
}
// Jump
else if (npc.ai[0] == 3f)
{
// Avoid cheap bullshit
npc.damage = 0;
npc.noTileCollide = false;
if (npc.velocity.Y == 0f)
{
// Slow down
npc.velocity.X *= 0.8f;
// Half second delay before jumping
if (!dontAttack)
npc.ai[1] += 1f;
if (npc.ai[1] >= 30f)
{
npc.ai[1] = -20f;
}
else if (npc.ai[1] == -1f)
{
// Set damage
npc.damage = npc.defDamage;
// Set jump velocity, reset and set AI to next phase (Stomp)
float distanceFromPlayerOnXAxis = npc.Center.X - player.Center.X;
npc.direction = distanceFromPlayerOnXAxis < 0 ? 1 : -1;
calamityGlobalNPC.newAI[3] = npc.direction;
// The limit for how much Aureus can multiply its jump velocity
float speedMultLimit = 1f;
// Maxes out when the player is a full 2000 pixels away from or above Aureus
float multiplier = 1f / 2000f;
// Increase Aureus jump velocity X if it's far enough away from the player
float distanceAwayFromTarget = Math.Abs(distanceFromPlayerOnXAxis);
float distanceGateValue = 400f;
bool increaseJumpVelocityX = distanceAwayFromTarget > distanceGateValue && expertMode;
if (increaseJumpVelocityX)
{
calamityGlobalNPC.newAI[0] = (distanceAwayFromTarget - distanceGateValue) * multiplier;
if (calamityGlobalNPC.newAI[0] > speedMultLimit)
calamityGlobalNPC.newAI[0] = speedMultLimit;
}
// Increase Aureus jump velocity Y if it's far enough above the player
float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f);
bool increaseJumpVelocityY = distanceBelowTarget > 0f && revenge;
if (increaseJumpVelocityY)
{
calamityGlobalNPC.newAI[1] = distanceBelowTarget * multiplier;
if (calamityGlobalNPC.newAI[1] > speedMultLimit)
calamityGlobalNPC.newAI[1] = speedMultLimit;
}
float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 27f : 20f;
velocity += 6f * enrageScale;
if (expertMode)
velocity += death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio);
if (Main.getGoodWorld)
velocity *= 1.15f;
npc.velocity = (new Vector2(player.Center.X, player.Center.Y - 500f) - npc.Center).SafeNormalize(Vector2.Zero) * velocity;
npc.velocity *= new Vector2(calamityGlobalNPC.newAI[0] + 1f, calamityGlobalNPC.newAI[1] + 1f);
npc.noTileCollide = true;
npc.ai[0] = 4f;
npc.ai[1] = 0f;
SoundEngine.PlaySound(AstrumAureus.AstrumAureus.JumpSound, npc.Center);
npc.netUpdate = true;
}
}
// Don't run custom gravity when starting a jump
if (npc.ai[0] != 4f)
CustomGravity();
}
// Stomp
else if (npc.ai[0] == 4f)
{
if (npc.velocity.Y == 0f)
{
// Avoid cheap bullshit
npc.damage = 0;
// Play stomp sound. Gotta specify the filepath to avoid confusion between the namespace and npc
SoundStyle soundToPlay = Main.zenithWorld ? NPCs.ExoMechs.Ares.AresGaussNuke.NukeExplosionSound : NPCs.AstrumAureus.AstrumAureus.StompSound;
SoundEngine.PlaySound(soundToPlay, npc.Center);
if (Main.zenithWorld)
{
float screenShakePower = 16 * Utils.GetLerpValue(1300f, 0f, npc.Distance(Main.LocalPlayer.Center), true);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower)
Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower;
}
// Stomp and jump again, if stomped twice then reset and set AI to next phase (Teleport or Idle)
npc.TargetClosest();
npc.localAI[1] += 1f;
float maxStompAmt = phase5 ? 5f : phase3 ? 2f : 3f;
if (npc.localAI[1] >= maxStompAmt)
{
npc.ai[0] = exhausted ? 1f : (phase3 ? 5f : 2f);
npc.localAI[1] = 0f;
npc.ai[2] += 1f;
npc.ai[3] = 0f;
npc.noTileCollide = false;
npc.netUpdate = true;
}
else
{
float playerLocation = npc.Center.X - player.Center.X;
npc.direction = playerLocation < 0 ? 1 : -1;
npc.ai[0] = 3f;
npc.ai[3] = 0f;
npc.netUpdate = true;
}
calamityGlobalNPC.newAI[0] = 0f;
calamityGlobalNPC.newAI[1] = 0f;
calamityGlobalNPC.newAI[3] = 0f;
// Spawn dust for visual effect
for (int i = (int)npc.position.X - 20; i < (int)npc.position.X + npc.width + 40; i += 20)
{
for (int j = 0; j < 4; j++)
{
int stompDust = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, ModContent.DustType<AstralOrange>(), 0f, 0f, 100, default, 1.5f);
Main.dust[stompDust].velocity *= 0.2f;
}
}
// Fire lasers or flames on stomp
SoundEngine.PlaySound(AstrumAureus.AstrumAureus.LaserSound, npc.Center);
if (Main.zenithWorld)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = Main.rand.NextBool() ? ModContent.ProjectileType<AstralLaser>() : ModContent.ProjectileType<AstralFlame>();
int damage = npc.GetProjectileDamage(type);
int totalProjectiles = bossRush ? 14 : death ? 12 : revenge ? 10 : expertMode ? 8 : 6;
float radians = MathHelper.TwoPi / totalProjectiles;
float velocity = 10f;
Vector2 spinningPoint = new Vector2(0f, -velocity);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f);
}
}
}
else if (calamityGlobalNPC.newAI[2] == 0f && phase2)
{
calamityGlobalNPC.newAI[2] = 1f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float flameVelocity = 6f;
int maxProjectiles = bossRush ? 4 : death ? 3 : 2;
int spread = bossRush ? 36 : death ? 28 : 20;
int type = ModContent.ProjectileType<AstralFlame>();
int damage = npc.GetProjectileDamage(type);
Vector2 spawnVector = new Vector2(npc.Center.X, npc.Center.Y - 80f * npc.scale);
Vector2 destination = new Vector2(spawnVector.X, spawnVector.Y + 100f * npc.scale);
Vector2 projectileVelocity = Vector2.Normalize(destination - spawnVector) * flameVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector + Vector2.Normalize(perturbedSpeed) * 100f, perturbedSpeed, type, damage, 0f, Main.myPlayer);
}
}
}
else
{
calamityGlobalNPC.newAI[2] = 0f;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float laserVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 7f : death ? 6f : 5f;
int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 17 : death ? 15 : 13);
int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20);
int type = ModContent.ProjectileType<AstralLaser>();
int damage = npc.GetProjectileDamage(type);
int[] lasersToNotFire = new int[4] { 1, 3, maxProjectiles - 2, maxProjectiles - 4 };
Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * laserVelocity;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < maxProjectiles; i++)
{
if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3])
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1)));
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, laserVelocity * 2f);
}
}
}
}
}
else
{
// Set damage
npc.damage = npc.defDamage;
// Set velocities while falling, this happens before the stomp
// Fall through
if (!player.dead)
{
if ((player.position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (player.position.Y < npc.Bottom.Y && npc.velocity.Y < 0f))
npc.noTileCollide = true;
else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)))
npc.noTileCollide = false;
}
if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width)
{
// Make sure Aureus falls quickly when directly on top of or below the player
if (npc.ai[3] < 30f)
npc.ai[3] = 30f;
npc.velocity.X *= 0.8f;
if (npc.Bottom.Y < player.position.Y)
{
// Make sure Aureus falls rather quickly
if (npc.velocity.Y < -3f)
npc.velocity.Y = -3f;
float fallSpeed = 1.2f;
fallSpeed += 0.36f * enrageScale;
if (expertMode)
fallSpeed += death ? 0.36f * (1f - lifeRatio) : 0.24f * (1f - lifeRatio);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
fallSpeed += 0.5f;
if (calamityGlobalNPC.newAI[1] > 0f)
fallSpeed *= calamityGlobalNPC.newAI[1] + 1f;
npc.velocity.Y += fallSpeed;
}
}
else
{
// Push Aureus towards the player on the X axis if he's not directly on top of or below the player
float velocityXChange = 0.2f + Math.Abs(npc.Center.X - player.Center.X) * 0.0001f;
velocityXChange += 0.1f * enrageScale;
if (calamityGlobalNPC.newAI[0] > 0f)
velocityXChange *= calamityGlobalNPC.newAI[0] + 1f;
if (npc.direction < 0)
npc.velocity.X -= velocityXChange;
else if (npc.direction > 0)
npc.velocity.X += velocityXChange;
float velocityXCap = 12f;
velocityXCap += 3.6f * enrageScale;
if (expertMode)
velocityXCap += death ? 3.6f * (1f - lifeRatio) : 2.4f * (1f - lifeRatio);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
velocityXCap += 5f;
if (calamityGlobalNPC.newAI[0] > 0f)
velocityXCap *= calamityGlobalNPC.newAI[0] + 1f;
float playerLocation = npc.Center.X - player.Center.X;
int directionRelativeToTarget = playerLocation < 0 ? 1 : -1;
bool slowDown = directionRelativeToTarget != calamityGlobalNPC.newAI[3];
if (slowDown)
velocityXCap *= 0.333f;
if (npc.velocity.X < -velocityXCap)
npc.velocity.X = -velocityXCap;
if (npc.velocity.X > velocityXCap)
npc.velocity.X = velocityXCap;
}
// Don't start falling quickly until half a second has passed
npc.ai[3] += 1f;
if (npc.ai[3] > 30f)
CustomGravity();
}
}
// Teleport
else if (npc.ai[0] == 5f)
{
// Avoid cheap bullshit
npc.damage = 0;
// Slow down
npc.velocity.X *= 0.8f;
// Start teleport
if (Main.netMode != NetmodeID.MultiplayerClient)
{
npc.localAI[1] += 1f;
if (death)
npc.localAI[2] += 1.25f;
if (phase4)
{
npc.localAI[1] += 1f;
if (death)
npc.localAI[2] += 1.25f;
}
if (npc.localAI[1] >= (bossRush ? 60f : death ? 180f : 240f))
{
// Reset localAI and find a teleport destination
npc.TargetClosest();
npc.localAI[1] = 0f;
Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1000f;
Point point4 = vectorAimedAheadOfTarget.ToTileCoordinates();
int teleportTries = 0;
while (teleportTries < 100)
{
teleportTries++;
int teleportTileX = Main.rand.Next(point4.X - 5, point4.X + 6);
int teleportTileY = Main.rand.Next(point4.Y - 5, point4.Y);
if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile)
{
npc.ai[1] = teleportTileX * 16 + 8;
npc.ai[3] = teleportTileY * 16 + 16;
break;
}
}
// Default teleport if the above conditions aren't met in 100 iterations
if (teleportTries >= 100)
{
Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom;
npc.ai[1] = bottom.X;
npc.ai[3] = bottom.Y;
}
// Set AI to next phase (Mid-teleport)
npc.ai[0] = 6f;
npc.netUpdate = true;
}
}
CustomGravity();
}
// Mid-teleport
else if (npc.ai[0] == 6f)
{
// Avoid cheap bullshit
npc.damage = 0;
if (death)
npc.localAI[2] += 1.25f;
if (phase4)
{
if (death)
npc.localAI[2] += 1.25f;
}
// Turn invisible
npc.alpha += 10;
if (npc.alpha >= 255)
{
// Set position to teleport destination
npc.Bottom = new Vector2(npc.ai[1], npc.ai[3]);
// Reset alpha and set AI to next phase (End of teleport)
npc.alpha = 255;
npc.ai[0] = 7f;
npc.localAI[2] = 0f;
npc.netUpdate = true;
}
// Play sound for cool effect
if (npc.soundDelay == 0)
{
npc.soundDelay = 15;
SoundEngine.PlaySound(AstrumAureus.AstrumAureus.TeleportSound, npc.Center);
}
// Emit dust to make the teleport pretty
for (int i = 0; i < 10; i++)
{
int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType<AstralOrange>(), npc.velocity.X, npc.velocity.Y, 255, default, 2f);
Main.dust[teleportDust].noGravity = true;
Main.dust[teleportDust].velocity *= 0.5f;
}
CustomGravity();
}
// End of teleport
else if (npc.ai[0] == 7f)
{
// Avoid cheap bullshit
npc.damage = 0;
// Turn visible
npc.alpha -= 10;
if (npc.alpha <= 0)
{
// Spawn Aureus Spawns
bool spawnFlag = expertMode;
if (NPC.CountNPCS(ModContent.NPCType<AureusSpawn>()) >= 2)
spawnFlag = false;
if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient)
{
int aureusSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType<AureusSpawn>());
Main.npc[aureusSpawn].velocity.Y = -10f;
Main.npc[aureusSpawn].netUpdate = true;
if (revenge)
{
aureusSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType<AureusSpawn>());
Main.npc[aureusSpawn].velocity.Y = -15f;
Main.npc[aureusSpawn].netUpdate = true;
}
if (death)
{
int damageAmt = npc.lifeMax / 50;
npc.life -= damageAmt;
if (npc.life < 1)
npc.life = 1;
npc.DamageEffect(damageAmt);
}
}
// Reset alpha and set AI to next phase (Idle)
npc.alpha = 0;
npc.ai[0] = exhausted ? 1f : 2f;
npc.ai[1] = 0f;
npc.ai[2] += 1f;
npc.localAI[3] = noProjectileOrPhaseIncrementTime;
// Stop colliding with tiles if entering walking phase
npc.noTileCollide = npc.ai[0] == 2f;
npc.netUpdate = true;
}
// Play sound at teleport destination for cool effect
if (npc.soundDelay == 0)
{
npc.soundDelay = 15;
SoundEngine.PlaySound(SoundID.Item109, npc.Center);
}
// Emit dust to make the teleport pretty
for (int i = 0; i < 10; i++)
{
int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType<AstralOrange>(), npc.velocity.X, npc.velocity.Y, 255, default, 2f);
Main.dust[teleportDust].noGravity = true;
Main.dust[teleportDust].velocity *= 0.5f;
}
CustomGravity();
}
void CustomGravity()
{
float gravity = 0.36f + 0.12f * enrageScale;
float maxFallSpeed = reduceFallSpeed ? 12f : 12f + 4f * enrageScale;
if (calamityGlobalNPC.newAI[1] > 0f && !reduceFallSpeed)
maxFallSpeed *= calamityGlobalNPC.newAI[1] + 1f;
if (Main.getGoodWorld && !reduceFallSpeed)
{
gravity *= 1.15f;
maxFallSpeed *= 1.15f;
}
npc.velocity.Y += gravity;
if (npc.velocity.Y > maxFallSpeed)
npc.velocity.Y = maxFallSpeed;
}
}
}
}
@@ -1,915 +0,0 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.AstrumAureus;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.NPCs.Bumblebirb;
using CalamityMod.NPCs.CalClone;
using CalamityMod.NPCs.CeaselessVoid;
using CalamityMod.NPCs.Crags;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.NPCs.OldDuke;
using CalamityMod.NPCs.SulphurousSea;
using CalamityMod.NPCs.SunkenSea;
using CalamityMod.Packets;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Enemy;
using CalamityMod.Sounds;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs
{
public static class AstrumDeusAI
{
public static void VanillaAstrumDeusAI(NPC npc, Mod mod, bool head)
{
CalamityGlobalNPC calamityGlobalNPC = npc.Calamity();
// Difficulty variables
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
float enrageScale = bossRush ? 0.5f : 0f;
if (Main.IsItDay() || bossRush)
{
npc.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1.5f;
}
// Deus cannot hit for 3 seconds or while invulnerable
bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || npc.dontTakeDamage;
if (doNotDealDamage)
npc.damage = 0;
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest();
Player player = Main.player[npc.target];
bool increaseSpeed = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles;
bool increaseSpeedMore = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
// Despawn safety, make sure to target another player if the current player target is too far away
if (increaseSpeedMore && head)
npc.TargetClosest();
// Inflict Extreme Gravity to nearby players
if (revenge)
{
if (!Main.dedServ)
{
if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles)
Main.LocalPlayer.AddBuff(ModContent.BuffType<DoGExtremeGravity>(), 2);
}
}
// Life
float lifeRatio = npc.life / (float)npc.lifeMax;
// Phases based on life percentage
bool halfHealth = lifeRatio < 0.5f;
bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f;
bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase;
bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode;
bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode;
bool splittingMines = lifeRatio < 0.7f;
bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode;
bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f;
bool deathModeEnragePhase_BodyAndTail = false;
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
float resistanceTime = doubleWormPhase ? 300f : 600f;
calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime;
// Flight timer
float aiSwitchTimer = doubleWormPhase ? (Main.getGoodWorld ? 600f : 1200f) : (Main.getGoodWorld ? 900f : 1800f);
calamityGlobalNPC.newAI[3] += 1f;
if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer)
calamityGlobalNPC.newAI[3] = 0f;
// Sound effect for swapping between attack behaviors in phase 2
if (doubleWormPhase && calamityGlobalNPC.newAI[3] % aiSwitchTimer == 0f && !(deathModeEnragePhase_Head || deathModeEnragePhase_BodyAndTail))
SoundEngine.PlaySound(AstrumDeusHead.SplitSound with { Pitch = -0.2f, Volume = 0.9f }, player.Center);
// Phase for flying at the player
bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase;
// Length of worms
int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50;
int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25;
int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5;
int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length;
// Become gradually more pissed as more worms are killed
int gfbMaxWormCount = 10;
int gfbWormCount = 0;
if (CalamityWorld.LegendaryMode && revenge)
gfbWormCount = NPC.CountNPCS(ModContent.NPCType<AstrumDeusHead>());
if (gfbWormCount > gfbMaxWormCount)
gfbWormCount = gfbMaxWormCount;
if (gfbWormCount > 0)
enrageScale += (gfbMaxWormCount - gfbWormCount) * 0.111f;
// Split into two worms
if (head)
{
float splitAnimationTime = 180f;
bool oneWormAlive = NPC.CountNPCS(ModContent.NPCType<AstrumDeusHead>()) < 2;
bool deathModeFinalWormEnrage = death && doubleWormPhase && oneWormAlive && calamityGlobalNPC.newAI[1] >= resistanceTime;
if (deathModeFinalWormEnrage)
{
if (calamityGlobalNPC.newAI[0] != 3f)
{
SoundEngine.PlaySound(AstrumDeusHead.SplitSound, player.Center);
calamityGlobalNPC.newAI[0] = 3f;
npc.defense = 12;
calamityGlobalNPC.DR = 0.075f;
// Despawns the other deus worm segments
int bodyID = ModContent.NPCType<AstrumDeusBody>();
int tailID = ModContent.NPCType<AstrumDeusTail>();
for (int i = 0; i < Main.maxNPCs; i++)
{
NPC wormseg = Main.npc[i];
if (!wormseg.active)
continue;
if ((wormseg.type == bodyID || wormseg.type == tailID) && Main.npc[(int)wormseg.ai[2]].Calamity().newAI[0] != 3f)
{
wormseg.life = 0;
wormseg.active = false;
}
}
}
calamityGlobalNPC.newAI[2] += 10f;
if (calamityGlobalNPC.newAI[2] > 162f)
calamityGlobalNPC.newAI[2] = 162f;
npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f);
}
bool despawnRemainingWorm = doubleWormPhase && oneWormAlive && !death;
if ((halfHealth && calamityGlobalNPC.newAI[0] == 0f) || despawnRemainingWorm)
{
npc.dontTakeDamage = true;
calamityGlobalNPC.newAI[2] += despawnRemainingWorm ? 10f : 1f;
npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f);
bool despawning = calamityGlobalNPC.newAI[2] == splitAnimationTime;
//
// CODE TWEAKED BY: OZZATRON
// September 20th, 2020
// reason: fixing Astrum Deus death mode NPC cap bug
//
// Despawn the unsplit Astrum Deus and spawn two half-size Astrum Deus worms.
if (despawning)
{
// If this is already a split worm (newAI[0] != 0f) then don't do anything. At all.
if (doubleWormPhase)
return;
// Mark all existing body and tail segments as inactive. This instantly frees up their NPC slots for the freshly spawned worms.
int bodyID = ModContent.NPCType<AstrumDeusBody>();
int tailID = ModContent.NPCType<AstrumDeusTail>();
for (int i = 0; i < Main.maxNPCs; i++)
{
NPC wormseg = Main.npc[i];
if (!wormseg.active)
continue;
if (wormseg.type == bodyID || wormseg.type == tailID)
{
wormseg.life = 0;
wormseg.active = false;
}
}
// The unsplit Astrum Deus worm head will die next frame.
npc.life = 0;
// Do not spawn worms client side. The server handles this.
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int wormamt = Main.zenithWorld ? 5 : 1;
for (int i = 0; i < wormamt; i++)
{
// Now that the original worm doesn't exist, startCount can be zero.
// int startCount = npc.whoAmI + phase1Length + 1;
int startIndexHeadOne = 1;
int headOneID = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadOne);
Main.npc[headOneID].Calamity().newAI[0] = 1f;
Main.npc[headOneID].velocity = Vector2.Normalize(player.Center - Main.npc[headOneID].Center) * 16f;
Main.npc[headOneID].timeLeft *= 20;
Main.npc[headOneID].ForceNetUpdate();
// On server, immediately send the correct extra AI of this head to clients.
if (Main.dedServ)
{
SyncCalamityNPCAIArrayPacket.Send(Main.npc[headOneID]);
}
// Make sure the second split worm is also contiguous.
int startIndexHeadTwo = startIndexHeadOne + phase2Length + 1;
int headTwoID = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadTwo);
Main.npc[headTwoID].Calamity().newAI[0] = 2f;
Main.npc[headTwoID].Calamity().newAI[3] = Main.getGoodWorld ? 300f : 600f;
Main.npc[headTwoID].velocity = Vector2.Normalize(player.Center - Main.npc[headTwoID].Center) * 16f;
Main.npc[headTwoID].timeLeft *= 20;
Main.npc[headTwoID].ForceNetUpdate();
// On server, immediately send the correct extra AI of this head to clients.
if (Main.dedServ)
{
SyncCalamityNPCAIArrayPacket.Send(Main.npc[headTwoID]);
}
}
SoundEngine.PlaySound(AstrumDeusHead.SplitSound, player.Center);
}
return;
}
}
if (Main.zenithWorld && calamityGlobalNPC.newAI[1] < 10f) // desync the deuses
{
float pushForce = 0.25f;
for (int k = 0; k < Main.maxNPCs; k++)
{
NPC otherDeus = Main.npc[k];
// Short circuits to make the loop as fast as possible
if (!otherDeus.active || k == npc.whoAmI)
continue;
// If the other projectile is indeed the same owned by the same player and they're too close, nudge them away.
bool sameProjType = otherDeus.type == npc.type;
float taxicabDist = Vector2.Distance(npc.Center, otherDeus.Center);
float distancegate = 320f;
if (sameProjType && taxicabDist < distancegate)
{
if (npc.position.X < otherDeus.position.X)
npc.velocity.X -= pushForce;
else
npc.velocity.X += pushForce;
if (npc.position.Y < otherDeus.position.Y)
npc.velocity.Y -= pushForce;
else
npc.velocity.Y += pushForce;
}
}
}
}
// Copy dontTakeDamage and Opacity from head
else
{
npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage;
npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity;
deathModeEnragePhase_BodyAndTail = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 3f;
if (deathModeEnragePhase_BodyAndTail)
{
npc.defense = 25;
calamityGlobalNPC.DR = 0.15f;
}
}
// Set worm variable
if (npc.ai[2] > 0f)
npc.realLife = (int)npc.ai[2];
// Alpha effects
if ((head || Main.npc[(int)npc.ai[1]].alpha < 128) && !npc.dontTakeDamage)
{
// Alpha changes
npc.alpha -= 42;
if (npc.alpha < 0)
npc.alpha = 0;
}
// Check if other segments are still alive, if not, die
if (!head)
{
bool shouldDespawn = true;
int headType = ModContent.NPCType<AstrumDeusHead>();
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].type != headType || !Main.npc[i].active)
continue;
shouldDespawn = false;
break;
}
if (shouldDespawn)
{
if (Main.npc.IndexInRange((int)npc.ai[1]) && Main.npc[(int)npc.ai[1]].active && Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
npc.ForceNetUpdate(false);
}
}
// Direction
if (npc.velocity.X < 0f)
npc.spriteDirection = -1;
else if (npc.velocity.X > 0f)
npc.spriteDirection = 1;
// Head code
if (head)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (npc.ai[0] == 0f)
{
int Previous = npc.whoAmI;
int bodyType = ModContent.NPCType<AstrumDeusBody>();
int tailType = ModContent.NPCType<AstrumDeusTail>();
for (int segments = 0; segments < maxLength; segments++)
{
int lol;
if (segments >= 0 && segments < maxLength - 1)
lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, bodyType, npc.whoAmI);
else
lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, tailType, npc.whoAmI);
if (segments % 2 == 0)
Main.npc[lol].localAI[3] = 1f;
Main.npc[lol].realLife = npc.whoAmI;
Main.npc[lol].Calamity().newAI[0] = Main.npc[Previous].Calamity().newAI[0];
Main.npc[lol].Calamity().newAI[3] = Main.npc[Previous].Calamity().newAI[3];
if (Main.dedServ)
{
SyncCalamityNPCAIArrayPacket.Send(Main.npc[lol]);
}
Main.npc[lol].ai[3] = segments + 1;
Main.npc[lol].ai[2] = npc.whoAmI;
Main.npc[lol].ai[1] = Previous;
Main.npc[Previous].ai[0] = lol;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol);
Previous = lol;
}
}
}
if (npc.life > Main.npc[(int)npc.ai[0]].life)
npc.life = Main.npc[(int)npc.ai[0]].life;
}
else
{
if (npc.life > Main.npc[(int)npc.ai[1]].life)
npc.life = Main.npc[(int)npc.ai[1]].life;
}
bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning
float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f;
float segmentVelocityBoost = 5f * (1f - lifeRatio);
segmentVelocity += segmentVelocityBoost;
segmentVelocity += 4f * enrageScale;
if (revenge)
{
float revMultiplier = 1.1f;
segmentVelocity *= revMultiplier;
}
if (head)
{
int headTilePositionX = (int)(npc.position.X / 16f) - 1;
int headTileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2;
int headTilePositionY = (int)(npc.position.Y / 16f) - 1;
int headTileWidthPosY = (int)((npc.position.Y + npc.height) / 16f) + 2;
if (headTilePositionX < 0)
headTilePositionX = 0;
if (headTileWidthPosX > Main.maxTilesX)
headTileWidthPosX = Main.maxTilesX;
if (headTilePositionY < 0)
headTilePositionY = 0;
if (headTileWidthPosY > Main.maxTilesY)
headTileWidthPosY = Main.maxTilesY;
// Fly or not
bool shouldFly = flyAtTarget;
if (!shouldFly)
{
for (int k = headTilePositionX; k < headTileWidthPosX; k++)
{
for (int l = headTilePositionY; l < headTileWidthPosY; l++)
{
if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[Main.tile[k, l].TileType] || (Main.tileSolidTop[Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64))
{
Vector2 vector2;
vector2.X = k * 16f;
vector2.Y = l * 16f;
if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f)
{
shouldFly = true;
break;
}
}
}
}
}
// Start flying if target is not within a certain distance
if (!shouldFly)
{
npc.localAI[1] = 1f;
Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height);
int noFlyZone = 200;
int heightReduction = death ? 130 : (int)(130f * (1f - lifeRatio));
int height = 400 - heightReduction;
bool outsideNoFlyZone = true;
if (npc.position.Y > player.position.Y)
{
for (int m = 0; m < Main.maxPlayers; m++)
{
if (Main.player[m].active)
{
Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, height);
if (rectangle.Intersects(rectangle2))
{
outsideNoFlyZone = false;
break;
}
}
}
if (outsideNoFlyZone)
shouldFly = true;
}
}
else
npc.localAI[1] = 0f;
// Despawn
if (player.dead)
{
shouldFly = false;
float velocity = 2f;
npc.velocity.Y -= velocity;
if ((double)npc.position.Y < Main.topWorld + 16f)
{
segmentVelocity *= 2f;
npc.velocity.Y -= velocity;
}
int headType = ModContent.NPCType<AstrumDeusHead>();
int bodyType = ModContent.NPCType<AstrumDeusBody>();
int tailType = ModContent.NPCType<AstrumDeusBody>();
if ((double)npc.position.Y < Main.topWorld + 16f)
{
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].type == headType || Main.npc[i].type == bodyType || Main.npc[i].type == tailType)
{
Main.npc[i].active = false;
Main.npc[i].ForceNetUpdate(false);
}
}
}
}
// Speed and movement
float speedBoost = death ? (0.1f * (1f - lifeRatio)) : (0.13f * (1f - lifeRatio));
float turnSpeedBoost = death ? (0.18f * (1f - lifeRatio)) : (0.2f * (1f - lifeRatio));
float speed = (hasJustSpawned ? 0.26f : deathModeEnragePhase_Head ? 0.2f : death ? 0.18f : 0.13f) + speedBoost;
float turnSpeed = (hasJustSpawned ? 0.3f : deathModeEnragePhase_Head ? 0.27f : death ? 0.25f : 0.2f) + turnSpeedBoost;
speed += 0.05f * enrageScale;
turnSpeed += 0.08f * enrageScale;
if (flyAtTarget)
{
float speedMultiplier = deathModeEnragePhase_Head ? 1.25f : doubleWormPhase ? (phase3 ? 1.25f : phase2 ? 1.2f : 1.15f) : 1f;
speed *= speedMultiplier;
}
if (revenge)
{
float revMultiplier = 1.1f;
speed *= revMultiplier;
turnSpeed *= revMultiplier;
}
speed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f;
turnSpeed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f;
if (Main.getGoodWorld)
{
speed *= 1.15f;
turnSpeed *= 1.15f;
}
Vector2 deusCenter = npc.Center;
float deusTargetX = player.Center.X;
float deusTargetY = player.Center.Y;
deusTargetX = (int)(deusTargetX / 16f) * 16;
deusTargetY = (int)(deusTargetY / 16f) * 16;
deusCenter.X = (int)(deusCenter.X / 16f) * 16;
deusCenter.Y = (int)(deusCenter.Y / 16f) * 16;
deusTargetX -= deusCenter.X;
deusTargetY -= deusCenter.Y;
if (!shouldFly)
{
npc.velocity.Y += 0.15f;
if (npc.velocity.Y > segmentVelocity)
npc.velocity.Y = segmentVelocity;
// This bool exists to stop the strange wiggle behavior when worms are falling down
bool slowXVelocity = Math.Abs(npc.velocity.X) > speed;
if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.4)
{
if (npc.velocity.X < 0f)
npc.velocity.X -= speed * 1.1f;
else
npc.velocity.X += speed * 1.1f;
}
else if (npc.velocity.Y == segmentVelocity)
{
if (slowXVelocity)
{
if (npc.velocity.X < deusTargetX)
npc.velocity.X += speed;
else if (npc.velocity.X > deusTargetX)
npc.velocity.X -= speed;
}
else
npc.velocity.X = 0f;
}
else if (npc.velocity.Y > 4f)
{
if (slowXVelocity)
{
if (npc.velocity.X < 0f)
npc.velocity.X += speed * 0.9f;
else
npc.velocity.X -= speed * 0.9f;
}
else
npc.velocity.X = 0f;
}
}
else
{
float deusTargetDist = (float)Math.Sqrt(deusTargetX * deusTargetX + deusTargetY * deusTargetY);
float deusAbsoluteTargetX = Math.Abs(deusTargetX);
float deusAbsoluteTargetY = Math.Abs(deusTargetY);
float deusTimeToReachTarget = segmentVelocity / deusTargetDist;
deusTargetX *= deusTimeToReachTarget;
deusTargetY *= deusTimeToReachTarget;
bool speedUpWhileFlying = false;
if (flyAtTarget)
{
if (((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f) || (npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && deusTargetDist < 400f)
{
speedUpWhileFlying = true;
if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < segmentVelocity)
npc.velocity *= 1.1f;
}
if (npc.position.Y > player.position.Y)
{
speedUpWhileFlying = true;
if (Math.Abs(npc.velocity.X) < segmentVelocity / 2f)
{
if (npc.velocity.X == 0f)
npc.velocity.X -= npc.direction;
npc.velocity.X *= 1.1f;
}
else if (npc.velocity.Y > -segmentVelocity)
npc.velocity.Y -= speed;
}
}
if (!speedUpWhileFlying)
{
if (!flyAtTarget)
{
if (((npc.velocity.X > 0f && deusTargetX > 0f) || (npc.velocity.X < 0f && deusTargetX < 0f)) && ((npc.velocity.Y > 0f && deusTargetY > 0f) || (npc.velocity.Y < 0f && deusTargetY < 0f)))
{
if (npc.velocity.X < deusTargetX)
npc.velocity.X += turnSpeed;
else if (npc.velocity.X > deusTargetX)
npc.velocity.X -= turnSpeed;
if (npc.velocity.Y < deusTargetY)
npc.velocity.Y += turnSpeed;
else if (npc.velocity.Y > deusTargetY)
npc.velocity.Y -= turnSpeed;
}
}
if ((npc.velocity.X > 0f && deusTargetX > 0f) || (npc.velocity.X < 0f && deusTargetX < 0f) || (npc.velocity.Y > 0f && deusTargetY > 0f) || (npc.velocity.Y < 0f && deusTargetY < 0f))
{
if (npc.velocity.X < deusTargetX)
npc.velocity.X += speed;
else if (npc.velocity.X > deusTargetX)
npc.velocity.X -= speed;
if (npc.velocity.Y < deusTargetY)
npc.velocity.Y += speed;
else if (npc.velocity.Y > deusTargetY)
npc.velocity.Y -= speed;
if (Math.Abs(deusTargetY) < segmentVelocity * 0.2 && ((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f)))
{
if (npc.velocity.Y > 0f)
npc.velocity.Y += speed * 2f;
else
npc.velocity.Y -= speed * 2f;
}
if (Math.Abs(deusTargetX) < segmentVelocity * 0.2 && ((npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f)))
{
if (npc.velocity.X > 0f)
npc.velocity.X += speed * 2f;
else
npc.velocity.X -= speed * 2f;
}
}
else if (deusAbsoluteTargetX > deusAbsoluteTargetY)
{
if (npc.velocity.X < deusTargetX)
npc.velocity.X += speed * 1.1f;
else if (npc.velocity.X > deusTargetX)
npc.velocity.X -= speed * 1.1f;
if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5)
{
if (npc.velocity.Y > 0f)
npc.velocity.Y += speed;
else
npc.velocity.Y -= speed;
}
}
else
{
if (npc.velocity.Y < deusTargetY)
npc.velocity.Y += speed * 1.1f;
else if (npc.velocity.Y > deusTargetY)
npc.velocity.Y -= speed * 1.1f;
if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5)
{
if (npc.velocity.X > 0f)
npc.velocity.X += speed;
else
npc.velocity.X -= speed;
}
}
}
}
if (shouldFly)
{
if (npc.localAI[0] != 1f)
npc.ForceNetUpdate(false);
npc.localAI[0] = 1f;
}
else
{
if (npc.localAI[0] != 0f)
npc.ForceNetUpdate(false);
npc.localAI[0] = 0f;
}
if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit)
npc.ForceNetUpdate(false);
npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2;
}
// Only the main worm body and tail use this code
else
{
// Shoot lasers
if (npc.type == ModContent.NPCType<AstrumDeusBody>())
{
npc.localAI[0] += 1f;
int shootTime = (doubleWormPhase && expertMode) ? 2 : 1;
float shootProjectile = (doubleWormPhase && expertMode) ? 200 : 400;
float timer = npc.ai[0] + 15f;
float divisor = timer + shootProjectile;
bool canFireProjectiles = npc.Opacity >= 1f;
bool shootGodRays = phase2 || deathModeEnragePhase_BodyAndTail;
if (canFireProjectiles)
{
if (!flyAtTarget || deathModeEnragePhase_BodyAndTail)
{
float laserDivisor = (phase2 && !deathModeEnragePhase_BodyAndTail) ? 4f : 2f;
if (npc.localAI[0] % divisor == 0f && npc.ai[0] % laserDivisor == 0f)
{
npc.TargetClosest();
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (deathModeEnragePhase_BodyAndTail)
{
Vector2 velocity = Vector2.Zero;
if (movingMines)
{
Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
randomMineMovement.Normalize();
randomMineMovement *= Main.rand.Next(90, 121) * 0.01f;
velocity = randomMineMovement;
}
int type = ModContent.ProjectileType<DeusMine>();
int damage = npc.GetProjectileDamage(type);
float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f;
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f);
}
}
if (Vector2.Distance(player.Center, npc.Center) > 80f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float deusLaserSpeed = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f;
Vector2 deusLaserCenter = npc.Center;
float deusLaserTargetX = player.Center.X - deusLaserCenter.X;
float deusLaserTargetY = player.Center.Y - deusLaserCenter.Y;
float deusLaserTargetDist = (float)Math.Sqrt(deusLaserTargetX * deusLaserTargetX + deusLaserTargetY * deusLaserTargetY);
deusLaserTargetDist = deusLaserSpeed / deusLaserTargetDist;
deusLaserTargetX *= deusLaserTargetDist;
deusLaserTargetY *= deusLaserTargetDist;
deusLaserCenter.X += deusLaserTargetX * 5f;
deusLaserCenter.Y += deusLaserTargetY * 5f;
Vector2 shootDirection = new Vector2(deusLaserTargetX, deusLaserTargetY).SafeNormalize(Vector2.UnitY);
Vector2 laserVelocity = shootDirection * deusLaserSpeed;
int type = shootGodRays ? ModContent.ProjectileType<AstralGodRay>() : ModContent.ProjectileType<AstralShot2>();
int damage = npc.GetProjectileDamage(type);
if (shootGodRays)
{
SoundEngine.PlaySound(AstrumDeusHead.GodRaySound, npc.Center);
// Waving beams need to start offset so they cross each other neatly.
float waveSideOffset = Main.rand.NextFloat(9f, 14f);
Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset;
for (int i = -1; i <= 1; i += 2)
{
Vector2 laserStartPos = deusLaserCenter + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f);
Projectile godRay = Projectile.NewProjectileDirect(npc.GetSource_FromAI(), laserStartPos, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y);
// Tell this Phased God Ray exactly which way it should be waving.
godRay.localAI[1] = i * 0.5f;
}
}
else
{
SoundEngine.PlaySound(AstrumDeusHead.LaserSound, npc.Center);
Projectile.NewProjectile(npc.GetSource_FromAI(), deusLaserCenter, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y);
}
}
}
}
}
else
{
if (npc.localAI[0] % divisor == 0f && npc.ai[0] % 2f == 0f)
{
Vector2 velocity = Vector2.Zero;
if (movingMines)
{
Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
randomMineMovement.Normalize();
randomMineMovement *= Main.rand.Next(30, 121) * 0.01f;
velocity = randomMineMovement;
}
int type = ModContent.ProjectileType<DeusMine>();
int damage = npc.GetProjectileDamage(type);
float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f;
Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f);
}
}
}
}
// Follow the head
Vector2 segmentCenter = npc.Center;
float segmentTargetX = player.Center.X;
float segmentTargetY = player.Center.Y;
segmentTargetX = (int)(segmentTargetX / 16f) * 16;
segmentTargetY = (int)(segmentTargetY / 16f) * 16;
segmentCenter.X = (int)(segmentCenter.X / 16f) * 16;
segmentCenter.Y = (int)(segmentCenter.Y / 16f) * 16;
segmentTargetX -= segmentCenter.X;
segmentTargetY -= segmentCenter.Y;
if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length)
{
try
{
segmentCenter = npc.Center;
segmentTargetX = Main.npc[(int)npc.ai[1]].Center.X - segmentCenter.X;
segmentTargetY = Main.npc[(int)npc.ai[1]].Center.Y - segmentCenter.Y;
}
catch
{
}
npc.rotation = (float)Math.Atan2(segmentTargetY, segmentTargetX) + MathHelper.PiOver2;
float segmentTargetDist = (float)Math.Sqrt(segmentTargetX * segmentTargetX + segmentTargetY * segmentTargetY);
int segmentWidth = npc.width;
segmentTargetDist = (segmentTargetDist - segmentWidth) / segmentTargetDist;
segmentTargetX *= segmentTargetDist;
segmentTargetY *= segmentTargetDist;
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + segmentTargetX;
npc.position.Y = npc.position.Y + segmentTargetY;
if (segmentTargetX < 0f)
npc.spriteDirection = -1;
else if (segmentTargetX > 0f)
npc.spriteDirection = 1;
}
}
// Play spawn sound on Deus on the first frame because otherwise the sound wouldn't play properly in multiplayer
if (calamityGlobalNPC.newAI[1] == 0f && !doubleWormPhase)
{
SoundEngine.PlaySound(AstrumDeusHead.SpawnSound, npc.Center);
calamityGlobalNPC.newAI[1] = 1f;
}
// 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing
if (calamityGlobalNPC.newAI[1] < resistanceTime && ((npc.position - npc.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 1f))
calamityGlobalNPC.newAI[1] += 1f;
// Calculate contact damage based on velocity
if (!doNotDealDamage)
{
float minimalContactDamageVelocity = segmentVelocity * 0.25f;
float minimalDamageVelocity = segmentVelocity * 0.5f;
if (head)
{
if (npc.velocity.Length() <= minimalContactDamageVelocity)
{
npc.damage = (int)Math.Round(npc.defDamage * 0.5);
}
else
{
float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar);
}
}
else
{
float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length();
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
{
npc.damage = 0;
}
else
{
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar);
}
}
}
}
}
}
@@ -1,734 +0,0 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Enemy;
using CalamityMod.Sounds;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs
{
public static class BrimstoneElementalAI
{
public static void VanillaBrimstoneElementalAI(NPC npc, Mod mod)
{
CalamityGlobalNPC calamityGlobalNPC = npc.Calamity();
BrimstoneElemental.BrimstoneElemental brimmy = npc.ModNPC<BrimstoneElemental.BrimstoneElemental>();
// Used for Brimling AI states
CalamityGlobalNPC.brimstoneElemental = npc.whoAmI;
// Emit light
Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1.2f, 0f, 0f);
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest();
Player player = Main.player[npc.target];
bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles;
if (!player.active || player.dead || despawnDistance)
{
npc.TargetClosest(false);
player = Main.player[npc.target];
if (!player.active || player.dead || despawnDistance)
{
npc.rotation = npc.velocity.X * 0.04f;
if (npc.velocity.Y > 3f)
npc.velocity.Y = 3f;
npc.velocity.Y -= 0.1f;
if (npc.velocity.Y < -12f)
npc.velocity.Y = -12f;
if (npc.timeLeft > 60)
npc.timeLeft = 60;
if (npc.ai[0] != 0f)
{
npc.ai[0] = 0f;
npc.ai[1] = 0f;
npc.ai[2] = 0f;
npc.ai[3] = 0f;
npc.localAI[0] = 0f;
npc.localAI[1] = 0f;
npc.netUpdate = true;
}
return;
}
}
else if (npc.timeLeft < 1800)
npc.timeLeft = 1800;
CalamityPlayer modPlayer = player.Calamity();
// Reset defense
npc.defense = npc.defDefense;
calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == 4f;
// Percent life remaining
float lifeRatio = npc.life / (float)npc.lifeMax;
// Variables for buffing the AI
bool bossRush = BossRushEvent.BossRushActive;
bool expertMode = Main.expertMode || bossRush;
bool revenge = CalamityWorld.revenge || bossRush;
bool death = CalamityWorld.death || bossRush;
bool phase2 = lifeRatio < 0.5f && revenge;
bool phase3 = lifeRatio < 0.33f;
// Enrage
if ((!player.ZoneUnderworldHeight || !modPlayer.ZoneCalamity) && !bossRush)
{
if (calamityGlobalNPC.newAI[3] > 0f)
calamityGlobalNPC.newAI[3] -= 1f;
}
else
calamityGlobalNPC.newAI[3] = CalamityGlobalNPC.biomeEnrageTimerMax;
bool biomeEnraged = calamityGlobalNPC.newAI[3] <= 0f || bossRush;
float enrageScale = bossRush ? 0.5f : 0f;
if (biomeEnraged && (!player.ZoneUnderworldHeight || bossRush))
{
npc.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 0.5f;
}
if (biomeEnraged && (!modPlayer.ZoneCalamity || bossRush))
{
npc.Calamity().CurrentlyEnraged = !bossRush;
enrageScale += 1f;
}
npc.Calamity().DR = npc.ai[0] == 4f ? 0.6f : 0.2f;
// Emit dust
int dustAmt = (npc.ai[0] == 2f) ? 2 : 1;
int size = (npc.ai[0] == 2f) ? 50 : 35;
if (npc.ai[0] != 1f)
{
for (int i = 0; i < 2; i++)
{
if (Main.rand.Next(3) < dustAmt)
{
int dust = Dust.NewDust(npc.Center - new Vector2(size), size * 2, size * 2, DustID.LifeDrain, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 1.5f);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 0.2f;
Main.dust[dust].fadeIn = 1f;
}
}
}
// Distance from destination where Brimmy stops moving
float movementDistanceGateValue = 100f;
// How fast Brimmy moves to the destination
float baseVelocity = (death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f) * (npc.ai[0] == 5f ? 0.05f : npc.ai[0] == 3f ? 1.5f : 1f);
baseVelocity += 3f * enrageScale;
if (expertMode)
baseVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio);
float baseAcceleration = (death ? 0.12f : 0.1f) * (npc.ai[0] == 5f ? 0.5f : npc.ai[0] == 3f ? 1.5f : 1f);
baseAcceleration += 0.06f * enrageScale;
if (expertMode)
baseAcceleration += 0.03f * (1f - lifeRatio);
// This is where Brimmy should be
Vector2 destination = npc.ai[0] != 3f ? player.Center : new Vector2(player.Center.X, player.Center.Y - 300f);
// How far Brimmy is from where she's supposed to be
Vector2 distanceFromDestination = destination - npc.Center;
// Movement
if (npc.ai[0] != 4f)
CalamityUtils.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity, baseAcceleration, true);
// Rotation and direction
if (npc.ai[0] <= 2f || npc.ai[0] == 5f)
{
npc.rotation = npc.velocity.X * 0.04f;
if (npc.ai[0] != 5 || (npc.ai[1] < 180f && npc.ai[0] == 5f))
{
float playerLocation = npc.Center.X - player.Center.X;
npc.direction = playerLocation < 0f ? 1 : -1;
npc.spriteDirection = npc.direction;
}
}
if (Main.zenithWorld) // in gfb, Brimmy channels the power of the other elementals.
{
int newMode;
if (lifeRatio <= 0.8f && lifeRatio > 0.6f)
{
newMode = 1; // Sand
}
else if (lifeRatio <= 0.6f && lifeRatio > 0.4f)
{
newMode = 2; // Rare Sand
}
else if (lifeRatio <= 0.4f && lifeRatio > 0.2f)
{
newMode = 3; // Cloud
}
else if (lifeRatio <= 0.2f)
{
newMode = 4; // Water
}
else
{
newMode = 0; // Brimstone, default
}
if (newMode != brimmy.currentMode)
{
SoundEngine.PlaySound(SoundID.Item29, npc.Center);
}
brimmy.currentMode = newMode;
}
if (npc.ai[0] == -1f)
{
// Avoid cheap bullshit
npc.damage = 0;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int phase;
int random = phase2 ? 6 : 5;
do phase = Main.rand.Next(random);
while (phase == npc.ai[1] || (phase == 0 && phase3 && revenge) || phase == 1 || phase == 2 || (phase == 4 && npc.localAI[3] != 0f));
npc.ai[0] = phase;
npc.ai[1] = 0f;
// Cocoon phase cooldown
if (npc.localAI[3] > 0f)
npc.localAI[3] -= 1f;
else if (phase == 4)
{
npc.localAI[3] = 3f;
SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HideInShellSound, player.Center);
}
// Prevent netUpdate from being blocked by the spam counter.
// A phase switch sync is a critical operation that must be synced.
npc.ForceNetUpdate(false);
}
}
// Pick a location to teleport to
else if (npc.ai[0] == 0f)
{
// Avoid cheap bullshit
npc.damage = 0;
npc.chaseable = true;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
npc.localAI[1] += 1f;
if (npc.Distance(player.Center) < 160f)
npc.localAI[1] += death ? 4f : expertMode ? 2f : 1f;
if (npc.localAI[1] >= (bossRush ? 90f : death ? 120f : 180f))
{
npc.TargetClosest();
npc.localAI[1] = 0f;
int timer = 0;
int playerPosX;
int playerPosY;
while (true)
{
timer++;
playerPosX = (int)player.Center.X / 16;
playerPosY = (int)player.Center.Y / 16;
int min = 12;
int max = 16;
if (Main.rand.NextBool())
playerPosX += Main.rand.Next(min, max);
else
playerPosX -= Main.rand.Next(min, max);
if (Main.rand.NextBool())
playerPosY += Main.rand.Next(min, max);
else
playerPosY -= Main.rand.Next(min, max);
if (!WorldGen.SolidTile(playerPosX, playerPosY))
break;
if (timer > 100)
return;
}
npc.ai[0] = 1f;
npc.ai[1] = playerPosX;
npc.ai[2] = playerPosY;
npc.netUpdate = true;
}
}
}
// Teleport to location
else if (npc.ai[0] == 1f)
{
// Avoid cheap bullshit
npc.damage = 0;
npc.chaseable = true;
Vector2 position = new Vector2(npc.ai[1] * 16f - (npc.width / 2), npc.ai[2] * 16f - (npc.height / 2));
for (int m = 0; m < 5; m++)
{
int dust = Dust.NewDust(position, npc.width, npc.height, DustID.LifeDrain, 0f, -1f, 90, default, 2f);
Main.dust[dust].noGravity = true;
Main.dust[dust].fadeIn = 1f;
}
npc.alpha += bossRush ? 8 : death ? 5 : revenge ? 4 : expertMode ? 3 : 2;
if (npc.alpha >= 255)
{
int spawnType = brimmy.currentMode == 3 ? NPCID.AngryNimbus : ModContent.NPCType<Brimling>();
int enemyCount = brimmy.currentMode == 3 ? 3 : 1; // 3 angry nimbi if cloud, otherwise 1 brimling
if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(spawnType) < (death ? 1 : 2) && revenge && brimmy.currentMode != 2) // dont spawn anything if gfb rare sand
{
for (int i = 0; i < enemyCount; i++)
NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, spawnType);
}
SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.TeleportSound, npc.Center);
npc.alpha = 255;
npc.position = position;
for (int n = 0; n < 15; n++)
{
int warpDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.LifeDrain, 0f, -1f, 90, default, 3f);
Main.dust[warpDust].noGravity = true;
}
npc.ai[0] = 2f;
npc.netUpdate = true;
}
}
// Either teleport again or go to next AI state
else if (npc.ai[0] == 2f)
{
// Avoid cheap bullshit
npc.damage = 0;
if (npc.alpha >= 255)
{
if (Main.zenithWorld)
{
SoundEngine.PlaySound(SoundID.Item68, npc.Center);
int type = ModContent.ProjectileType<BrimstoneRay>();
int damage = npc.GetProjectileDamage(type);
Vector2 pos = npc.Center;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(0, 1), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(0, -1), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(1, 0), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(-1, 0), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
}
if (brimmy.currentMode >= 1 && brimmy.currentMode <= 3)
{
int tornadoType = brimmy.currentMode == 3 ? ModContent.ProjectileType<StormMarkHostile>() : ProjectileID.SandnadoHostileMark;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(npc.GetSource_FromAI(), pos, Vector2.Zero, tornadoType, damage, 0f, Main.myPlayer, 0f, 0f);
}
}
if (brimmy.currentMode == 2)
{
int healAmt = npc.lifeMax / 25;
if (healAmt > 0)
{
npc.life += healAmt;
npc.HealEffect(healAmt, true);
npc.netUpdate = true;
}
}
}
}
npc.alpha -= 50;
if (npc.alpha <= 0)
{
npc.chaseable = true;
npc.ai[3] += 1f;
npc.alpha = 0;
if (npc.ai[3] >= 2f || phase2 || Main.getGoodWorld)
{
npc.ai[0] = -1f;
npc.ai[1] = 0f;
npc.ai[2] = 0f;
npc.ai[3] = 0f;
}
else
{
npc.ai[0] = 0f;
}
npc.netUpdate = true;
}
}
// Float above target and fire projectiles
else if (npc.ai[0] == 3f)
{
// Avoid cheap bullshit
npc.damage = 0;
npc.chaseable = true;
npc.rotation = npc.velocity.X * 0.04f;
float playerLocation = npc.Center.X - player.Center.X;
npc.direction = playerLocation < 0f ? 1 : -1;
npc.spriteDirection = npc.direction;
npc.ai[1] += 1f;
float divisor = expertMode ? (death ? 80f : revenge ? 45f : 50f) - (float)Math.Ceiling(10f * (1f - lifeRatio)) : 50f;
divisor -= 3f * enrageScale;
float divisor2 = divisor * 2f;
if (npc.ai[1] % divisor == divisor - 1f)
{
float velocity = (death ? 7f : revenge ? 6f : 5f) + (2f * enrageScale) + (expertMode ? 3f * (1f - lifeRatio) : 0f);
int type = ModContent.ProjectileType<BrimstoneHellfireball>();
int damage = npc.GetProjectileDamage(type);
if (brimmy.currentMode == 4)
{
type = ModContent.ProjectileType<FrostMist>();
SoundEngine.PlaySound(SoundID.Item30, player.Center);
}
else
{
SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HellfireballSound, player.Center);
}
Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 5f, projectileVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y);
Main.projectile[proj].timeLeft = 240;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
if (npc.ai[1] % divisor2 == divisor2 - 1f)
{
velocity = (death ? 5f : 4f) + 2f * enrageScale;
type = ModContent.ProjectileType<BrimstoneBarrage>();
damage = npc.GetProjectileDamage(type);
if (brimmy.currentMode == 4)
{
type = ModContent.ProjectileType<WaterSpear>();
SoundEngine.PlaySound(SoundID.Item21, player.Center);
}
else
{
SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.DartSound, player.Center);
}
projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity;
int numProj = death ? 8 : 4;
int spread = death ? 90 : 45;
if (Main.getGoodWorld)
{
numProj *= 3;
spread *= 2;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float rotation = MathHelper.ToRadians(spread);
float projectileVelocityToPass = velocity * 3f;
for (int i = 0; i < numProj; i++)
{
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1)));
int proj2 = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj2].extraUpdates += 1;
}
}
}
}
if (npc.ai[1] >= divisor * (death ? 5f : 10f))
{
npc.TargetClosest();
npc.ai[0] = -1f;
npc.ai[1] = 3f;
npc.ai[2] = 0f;
npc.ai[3] = 0f;
npc.netUpdate = true;
}
}
// Cocoon bullet hell
else if (npc.ai[0] == 4f)
{
// Avoid cheap bullshit
npc.damage = 0;
npc.defense = npc.defDefense * 4;
npc.chaseable = false;
npc.localAI[0] += 1f;
if (Main.getGoodWorld)
npc.localAI[0] += 2f;
if (expertMode)
npc.localAI[0] += 1f - lifeRatio;
npc.localAI[0] += enrageScale;
if (npc.localAI[0] >= 120f)
{
npc.localAI[0] = 0f;
float projectileSpeed = death ? 9f : revenge ? 8f : 6f;
projectileSpeed += 2f * enrageScale;
Vector2 projectileVelocity = player.Center - npc.Center;
float radialOffset = 0.2f;
float diameter = 80f;
projectileVelocity = projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileSpeed;
Vector2 velocity = projectileVelocity;
velocity = velocity.SafeNormalize(Vector2.UnitY);
velocity *= diameter;
int totalProjectiles = 6;
float offsetAngle = (float)Math.PI * radialOffset;
int type = ModContent.ProjectileType<BrimstoneHellblast>();
int damage = npc.GetProjectileDamage(type);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
for (int j = 0; j < totalProjectiles; j++)
{
float radians = j - (totalProjectiles - 1f) / 2f;
Vector2 offset = velocity.RotatedBy(offsetAngle * radians);
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, projectileVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f);
Main.projectile[proj].timeLeft = 300;
Main.projectile[proj].tileCollide = false;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
}
totalProjectiles = 12;
float radians2 = MathHelper.TwoPi / totalProjectiles;
type = ModContent.ProjectileType<BrimstoneBarrage>();
damage = npc.GetProjectileDamage(type);
if (brimmy.currentMode == 4)
{
type = ModContent.ProjectileType<SirenSong>();
SoundEngine.PlaySound(SoundID.Item26, player.Center);
}
else
{
SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.ShellFireSound, player.Center);
}
double angleA = radians2 * 0.5;
double angleB = MathHelper.ToRadians(90f) - angleA;
float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB));
Vector2 spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
float projectileVelocityToPass = projectileSpeed * 3f;
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k);
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
if (death)
{
spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(-velocityX, -projectileSpeed) : new Vector2(0f, -projectileSpeed);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k);
int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255 * 0.75f, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Main.projectile[proj].extraUpdates += 1;
}
}
}
npc.localAI[2] += 1f;
}
npc.velocity *= 0.95f;
npc.rotation = npc.velocity.X * 0.04f;
float playerLocation = npc.Center.X - player.Center.X;
npc.direction = playerLocation < 0f ? 1 : -1;
npc.spriteDirection = npc.direction;
npc.ai[1] += 1f;
if (npc.ai[1] >= (death ? 240f : 300f))
{
npc.TargetClosest();
npc.ai[0] = -1f;
npc.ai[1] = 4f;
npc.ai[2] = 0f;
npc.ai[3] = 0f;
npc.localAI[0] = 0f;
npc.netUpdate = true;
}
}
// Laser beam attack
else if (npc.ai[0] == 5f)
{
// Avoid cheap bullshit
npc.damage = 0;
npc.chaseable = true;
npc.defense = npc.defDefense * 2;
Vector2 source = new Vector2(npc.Center.X + (npc.spriteDirection > 0 ? 34f : -34f), npc.Center.Y - 74f);
Vector2 aimAt = player.Center + player.velocity * 20f;
float aimResponsiveness = bossRush ? 0.05f : (npc.ai[2] == 1f || death) ? 0.1f : 0.25f;
Vector2 aimVector = (aimAt - source).SafeNormalize(Vector2.UnitY);
if (aimVector.HasNaNs())
aimVector = -Vector2.UnitY;
aimVector = (Vector2.Lerp(aimVector, npc.velocity.SafeNormalize(Vector2.UnitY), aimResponsiveness)).SafeNormalize(Vector2.UnitY);
aimVector *= 6f;
Vector2 laserVelocity = aimVector.SafeNormalize(Vector2.UnitY);
if (laserVelocity.HasNaNs())
laserVelocity = -Vector2.UnitY;
calamityGlobalNPC.newAI[1] = laserVelocity.X;
calamityGlobalNPC.newAI[2] = laserVelocity.Y;
// Rev = 190 + 165 = 355
// Death = 165
npc.ai[1] += 1f;
if (npc.ai[1] >= 240f)
{
npc.TargetClosest();
npc.ai[2] += 1f;
npc.localAI[0] = 0f;
npc.localAI[1] = 0f;
if (npc.ai[2] >= (death ? 1f : 2f))
{
npc.ai[0] = -1f;
npc.ai[1] = 5f;
npc.ai[2] = 0f;
calamityGlobalNPC.newAI[0] = 0f;
}
else
{
npc.ai[1] = 0f;
calamityGlobalNPC.newAI[0] = 0f;
}
}
else if (npc.ai[1] >= 180f)
{
npc.velocity *= 0.95f;
if (npc.ai[1] == 180f)
{
SoundEngine.PlaySound(SoundID.Item68, source);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]);
laserVelocity2 = laserVelocity2.SafeNormalize(Vector2.UnitY);
int type = ModContent.ProjectileType<BrimstoneRay>();
int damage = npc.GetProjectileDamage(type);
Projectile.NewProjectile(npc.GetSource_FromAI(), source, laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
if (Main.getGoodWorld)
Projectile.NewProjectile(npc.GetSource_FromAI(), source, -laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
if (Main.zenithWorld)
{
Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(-laserVelocity2.X, laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(laserVelocity2.X, -laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI);
}
}
}
}
else
{
float playSoundTimer = 30f;
if (npc.ai[1] < 150f)
{
switch ((int)npc.ai[2])
{
case 0:
npc.ai[1] += 0.5f;
break;
case 1:
npc.ai[1] += 1f;
playSoundTimer = 40f;
break;
}
if (death)
{
npc.ai[1] += 0.5f;
playSoundTimer += 10f;
}
}
if (npc.ai[1] % playSoundTimer == 0f)
SoundEngine.PlaySound(SoundID.Item20, npc.Center);
if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(npc.GetSource_FromAI(), source, laserVelocity, ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI);
if (Main.getGoodWorld)
Projectile.NewProjectile(npc.GetSource_FromAI(), source, -laserVelocity, ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI);
if (Main.zenithWorld)
{
Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(-laserVelocity.X, laserVelocity.Y), ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI);
Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(laserVelocity.X, -laserVelocity.Y), ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI);
}
}
calamityGlobalNPC.newAI[0] = 1f;
}
else
{
if (npc.ai[1] == 150f)
{
npc.localAI[0] = laserVelocity.X;
npc.localAI[1] = laserVelocity.Y;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, npc.localAI[0], npc.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI);
if (Main.getGoodWorld)
Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, -npc.localAI[0], -npc.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI);
if (Main.zenithWorld)
{
Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, -npc.localAI[0], npc.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI);
Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, npc.localAI[0], -npc.localAI[1], ModContent.ProjectileType<BrimstoneTargetRay>(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI);
}
}
}
}
}
}
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+73 -226
View File
@@ -1564,7 +1564,7 @@ namespace CalamityMod.NPCs
{ NPCID.Creeper, 1800 }, // 0:30 (30 seconds, length of Creepers phase)
{ NPCID.Deerclops, 5400 }, // 1:30 (90 seconds)
{ NPCID.QueenBee, 7200 }, // 2:00 (120 seconds)
{ NPCID.SkeletronHead, 9000 }, // 2:30 (150 seconds)
{ NPCID.SkeletronHead, 7200 }, // 2:00 (120 seconds)
{ NPCID.WallofFlesh, 7200 }, // 2:00 (120 seconds)
{ NPCID.WallofFleshEye, 7200 },
{ NPCID.QueenSlimeBoss, 7200 }, // 2:00 (120 seconds)
@@ -1575,10 +1575,10 @@ namespace CalamityMod.NPCs
{ NPCID.TheDestroyerTail, 10800 },
{ NPCID.SkeletronPrime, 10800 }, // 3:00 (180 seconds)
{ NPCID.Plantera, 10800 }, // 3:00 (180 seconds)
{ NPCID.HallowBoss, 10800 }, // 3:00 (180 seconds)
{ NPCID.Golem, 9000 }, // 2:30 (150 seconds)
{ NPCID.GolemHead, 3600 }, // 1:00 (60 seconds)
{ NPCID.DukeFishron, 9000 }, // 2:30 (150 seconds)
{ NPCID.HallowBoss, 10800 }, // 3:00 (180 seconds)
{ NPCID.CultistBoss, 9000 }, // 2:30 (150 seconds)
{ NPCID.MoonLordCore, 14400 }, // 4:00 (240 seconds)
{ NPCID.MoonLordHand, 7200 }, // 2:00 (120 seconds)
@@ -1604,7 +1604,7 @@ namespace CalamityMod.NPCs
{ NPCType<AquaticScourgeBodyAlt>(), 9000 },
{ NPCType<AquaticScourgeTail>(), 9000 },
{ NPCType<BrimstoneElemental.BrimstoneElemental>(), 10800 }, // 3:00 (180 seconds)
{ NPCType<CalamitasClone>(), 14400 }, // 4:00 (240 seconds)
{ NPCType<CalamitasClone>(), 10800 }, // 3:00 (180 seconds)
{ NPCType<Anahita>(), 10800 }, // 3:00 (180 seconds)
{ NPCType<Leviathan.Leviathan>(), 10800 },
{ NPCType<AstrumAureus.AstrumAureus>(), 10800 }, // 3:00 (180 seconds)
@@ -1613,8 +1613,8 @@ namespace CalamityMod.NPCs
{ NPCType<AstrumDeusTail>(), 7200 },
{ NPCType<PlaguebringerGoliath.PlaguebringerGoliath>(), 10800 }, // 3:00 (180 seconds)
{ NPCType<RavagerBody>(), 10800 }, // 3:00 (180 seconds)
{ NPCType<ProfanedGuardianCommander>(), 5400 }, // 1:30 (90 seconds)
{ NPCType<Bumblefuck>(), 7200 }, // 2:00 (120 seconds)
{ NPCType<ProfanedGuardianCommander>(), 7200 }, // 2:00 (120 seconds)
{ NPCType<Dragonfolly>(), 7200 }, // 2:00 (120 seconds)
{ NPCType<Providence.Providence>(), 14400 }, // 4:00 (240 seconds)
{ NPCType<CeaselessVoid.CeaselessVoid>(), 10800 }, // 3:00 (180 seconds)
{ NPCType<DarkEnergy>(), 1200 }, // 0:20 (20 seconds)
@@ -1627,7 +1627,7 @@ namespace CalamityMod.NPCs
{ NPCType<DevourerofGodsHead>(), 14400 }, // 4:00 (240 seconds)
{ NPCType<DevourerofGodsBody>(), 14400 }, // DoG Phase 1 is 1:30, DoG Phase 2 is 2:30
{ NPCType<DevourerofGodsTail>(), 14400 },
{ NPCType<Yharon.Yharon>(), 14700 }, // 4:05 (245 seconds) -- he spends 5 seconds invincible where you can't do anything
{ NPCType<Yharon.Yharon>(), 14400 }, // 4:00 (240 seconds)
{ NPCType<Apollo>(), 21600 }, // 6:00 (360 seconds)
{ NPCType<Artemis>(), 21600 },
{ NPCType<AresBody>(), 21600 }, // 6:00 (360 seconds)
@@ -1910,17 +1910,16 @@ namespace CalamityMod.NPCs
npc.scale *= Main.zenithWorld ? 2f : 1.2f;
}
else if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType<SkeletronPrime2>())
else if (npc.type == NPCID.SkeletronPrime)
{
// HP boosted in Death Mode due to having two heads (piercing can make them die faster than normal here since they share an HP bar)
npc.lifeMax = (int)Math.Round(npc.lifeMax * (CalamityWorld.death ? 1.7 : 1.2));
npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2);
npc.npcSlots = 12f;
}
else if (npc.type <= NPCID.PrimeLaser && npc.type >= NPCID.PrimeCannon)
{
npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.55);
}
else if (npc.type == NPCID.Retinazer || npc.type == NPCID.Spazmatism || npc.type == NPCType<Foveanator>())
else if (npc.type == NPCID.Retinazer || npc.type == NPCID.Spazmatism)
{
npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2);
npc.npcSlots = 10f;
@@ -2000,11 +1999,11 @@ namespace CalamityMod.NPCs
else if (npc.type == NPCID.KingSlime)
{
if (CalamityWorld.death)
npc.scale = Main.getGoodWorld ? 6f : 2.5f;
npc.scale = CalamityWorld.LegendaryMode ? 6f : 2.5f;
else
npc.scale = Main.getGoodWorld ? 3f : 1.5f;
npc.scale = CalamityWorld.LegendaryMode ? 3f : 1.5f;
npc.lifeMax = (int)Math.Round(npc.lifeMax * (Main.getGoodWorld ? 1.8 : 1.5));
npc.lifeMax = (int)Math.Round(npc.lifeMax * (CalamityWorld.LegendaryMode ? 1.8 : 1.5));
}
else if ((npc.type == NPCID.Wraith || npc.type == NPCID.Mimic || npc.type == NPCID.Reaper || npc.type == NPCID.PresentMimic || npc.type == NPCID.SandElemental || npc.type == NPCID.Ghost) && CalamityWorld.LegendaryMode)
{
@@ -2923,9 +2922,10 @@ namespace CalamityMod.NPCs
npc.dontTakeDamage = true;
break;
// Make Fishron and Anahita Bubbles immune to damage in Death Mode
// Make Fishron and Anahita Bubbles have actual health in Death Mode
case NPCID.DetonatingBubble:
npc.dontTakeDamage = CalamityWorld.death;
if (CalamityWorld.death)
npc.lifeMax = 300;
break;
default:
@@ -2937,7 +2937,7 @@ namespace CalamityMod.NPCs
{
if (!NPC.downedMechBossAny)
{
if (DestroyerIDList.Includes(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDList.Includes(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer || npc.type == NPCType<Foveanator>())
if (DestroyerIDList.Includes(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDList.Includes(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer)
{
double multiplier = Main.expertMode ? EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic;
npc.lifeMax = (int)Math.Round(npc.lifeMax * multiplier);
@@ -2947,7 +2947,7 @@ namespace CalamityMod.NPCs
}
else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1))
{
if (DestroyerIDList.Includes(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDList.Includes(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer || npc.type == NPCType<Foveanator>())
if (DestroyerIDList.Includes(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDList.Includes(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer)
{
double multiplier = Main.expertMode ? EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic;
npc.lifeMax = (int)Math.Round(npc.lifeMax * multiplier);
@@ -3940,9 +3940,6 @@ namespace CalamityMod.NPCs
{
if (CalamityWorld.revenge || BossRushEvent.BossRushActive)
{
if (npc.type == NPCID.SkeletronPrime && (CalamityWorld.death || BossRushEvent.BossRushActive))
index = ExtraTextureRefs.BossHeadIndex_ChadPrime;
if (npc.type == NPCID.DukeFishron && (CalamityWorld.death || BossRushEvent.BossRushActive))
{
float lifeRatio = npc.life / (float)npc.lifeMax;
@@ -3958,7 +3955,7 @@ namespace CalamityMod.NPCs
public override bool PreAI(NPC npc)
{
// Change Spaz and Ret weaknesses and resistances when phase 2 starts.
if (npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer || npc.type == NPCType<Foveanator>())
if (npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer)
{
if (npc.ai[0] >= 2f)
{
@@ -3988,9 +3985,6 @@ namespace CalamityMod.NPCs
{
if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < BossZenDistance)
Main.LocalPlayer.AddBuff(BuffType<BossEffects>(), 2);
if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && npc.type == NPCType<RavagerBody>() && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < BossZenDistance)
Main.LocalPlayer.AddBuff(BuffType<WeakPetrification>(), 2);
}
if (npc.type != NPCType<Draedon>())
@@ -6494,13 +6488,13 @@ namespace CalamityMod.NPCs
if (GrenadeResistIDList.Includes(projectile.type))
{
// Eater of Worlds has a vanilla resist in Expert+, this gives it to him in Normal mode
// Note that Calamity reduces the vanilla resist from 80% to 60%
// Note that Calamity reduces the vanilla resist from 80% to 66%
bool hasResist = EaterOfWorldsIDList.Includes(npc.type) && !Main.expertMode;
// Add a resist for BoC's creepers and Prehardmode worm bosses
if (npc.type == NPCID.Creeper || DesertScourgeIDList.Includes(npc.type) || PerforatorWormIDList.Includes(npc.type))
hasResist = true;
if (hasResist)
modifiers.SourceDamage *= 0.4f;
modifiers.SourceDamage *= 0.33f;
}
if (modPlayer.camper && !player.StandingStill())
@@ -6653,26 +6647,6 @@ namespace CalamityMod.NPCs
#region Check Dead
public override bool CheckDead(NPC npc)
{
if (npc.type == NPCID.SkeletronPrime)
{
if (CalamityWorld.death || BossRushEvent.BossRushActive)
{
// Kill the other head if he's still alive when this head dies
for (int i = 0; i < Main.maxNPCs; i++)
{
NPC nPC = Main.npc[i];
if (nPC.active && nPC.type == NPCType<SkeletronPrime2>() && nPC.life > 0)
{
nPC.life = 0;
nPC.HitEffect();
nPC.checkDead();
nPC.active = false;
nPC.netUpdate = true;
}
}
}
}
if (npc.lifeMax > 1000 && npc.type != NPCID.DungeonSpirit &&
npc.type != NPCType<PhantomSpirit>() &&
npc.type != NPCType<PhantomSpiritS>() &&
@@ -6737,7 +6711,7 @@ namespace CalamityMod.NPCs
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int slimeAmt = Main.getGoodWorld ? Main.rand.Next(6) + 10 : Main.rand.Next(2) + 2; // 2 to 3 extra
int slimeAmt = CalamityWorld.LegendaryMode ? Main.rand.Next(6) + 10 : Main.rand.Next(2) + 2; // 2 to 3 extra
for (int s = 0; s < slimeAmt; s++)
{
int slime = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.position.Y + npc.height), NPCID.BlueSlime, 0, 0f, 0f, 0f, 0f, 255);
@@ -6745,8 +6719,8 @@ namespace CalamityMod.NPCs
npc2.SetDefaults(NPCID.BabySlime);
npc2.velocity.X = npc.velocity.X * 2f;
npc2.velocity.Y = npc.velocity.Y;
npc2.velocity.X += Main.rand.Next(-20, 20) * (Main.getGoodWorld ? 0.5f : 0.1f) + s * npc.direction * (Main.getGoodWorld ? 0.5f : 0.3f);
npc2.velocity.Y -= Main.rand.Next(0, 10) * (Main.getGoodWorld ? 0.5f : 0.1f) + s;
npc2.velocity.X += Main.rand.Next(-20, 20) * (CalamityWorld.LegendaryMode ? 0.5f : 0.1f) + s * npc.direction * (CalamityWorld.LegendaryMode ? 0.5f : 0.3f);
npc2.velocity.Y -= Main.rand.Next(0, 10) * (CalamityWorld.LegendaryMode ? 0.5f : 0.1f) + s;
npc2.ai[0] = -1000 * Main.rand.Next(3);
if (Main.dedServ && slime < Main.maxNPCs)
@@ -6759,7 +6733,7 @@ namespace CalamityMod.NPCs
case NPCID.CursedHammer:
case NPCID.EnchantedSword:
case NPCID.CrimsonAxe:
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
npc.justHit = false;
break;
@@ -6770,13 +6744,13 @@ namespace CalamityMod.NPCs
case NPCID.IceTortoise:
case NPCID.BlackRecluse:
case NPCID.BlackRecluseWall:
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
npc.justHit = false;
break;
case NPCID.Paladin:
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
npc.justHit = false;
break;
@@ -6784,7 +6758,7 @@ namespace CalamityMod.NPCs
if (npc.type == NPCType<Plagueshell>())
{
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
npc.justHit = false;
}
}
@@ -7464,11 +7438,11 @@ namespace CalamityMod.NPCs
#region Drawing
public override void FindFrame(NPC npc, int frameHeight)
{
if (CalamityWorld.revenge || BossRushEvent.BossRushActive)
/*if (CalamityWorld.revenge || BossRushEvent.BossRushActive)
{
if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType<SkeletronPrime2>())
if (npc.type == NPCID.SkeletronPrime)
npc.frameCounter = 0D;
}
}*/
// Increment the bestiary worm timer when hovering over the NPC or having their entry open. Pauses otherwise
if (npc.IsABestiaryIconDummy)
{
@@ -7760,7 +7734,7 @@ namespace CalamityMod.NPCs
if (npc.IsABestiaryIconDummy)
return null;
if (Main.LocalPlayer.Calamity().trippy || (npc.type == NPCID.KingSlime && CalamityWorld.LegendaryMode && CalamityWorld.revenge))
if (Main.LocalPlayer.Calamity().trippy || (npc.type == NPCID.KingSlime && CalamityWorld.LegendaryMode))
return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR);
if (npc.type == NPCID.KingSlime && CalamityWorld.death)
@@ -8015,8 +7989,43 @@ namespace CalamityMod.NPCs
if (CalamityWorld.revenge || BossRushEvent.BossRushActive)
{
if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType<SkeletronPrime2>() || DestroyerIDList.Includes(npc.type))
if (DestroyerIDList.Includes(npc.type))
shouldDrawBool = false;
// Allows correct frames to draw in Rev+ phases
// GFB can rot for all I care
if (npc.type == NPCID.SkeletronPrime && !NPC.IsMechQueenUp)
{
int frameHeight = TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type];
if (npc.ai[1] == 0f || npc.ai[1] == 4f)
{
newAI[2] += 1f;
if (newAI[2] >= 12f)
{
newAI[2] = 0f;
newAI[3] += frameHeight;
if (newAI[3] / frameHeight >= 2f)
newAI[3] = 0f;
}
}
// Spinning probe spawn or fly over phase
else if (npc.ai[1] == 5f || npc.ai[1] == 6f)
{
newAI[2] = 0f;
newAI[3] = frameHeight;
}
// Spinning phase
else
{
newAI[2] = 0f;
newAI[3] = frameHeight * 2;
}
npc.frame.Y = (int)newAI[3];
}
}
if (npc.type == NPCID.Corruptor || npc.type == NPCID.BloodSquid || (npc.type == NPCID.HornetHoney && npc.ai[3] == 1f))
@@ -8218,7 +8227,6 @@ namespace CalamityMod.NPCs
public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
bool masterMode = Main.masterMode || BossRushEvent.BossRushActive;
bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive;
bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
@@ -8453,14 +8461,14 @@ namespace CalamityMod.NPCs
Color currentColor = npc.GetAlpha(drawColor);
float opacity = (1f - Main.npc[NPC.crimsonBoss].life / (float)Main.npc[NPC.crimsonBoss].lifeMax) * 2f;
opacity *= opacity;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
opacity = 1f;
opacity = MathHelper.Clamp(opacity, 0f, 1f);
currentColor.R = (byte)((float)(int)currentColor.R * opacity);
currentColor.G = (byte)((float)(int)currentColor.G * opacity);
currentColor.B = (byte)((float)(int)currentColor.B * opacity);
currentColor.A = (byte)((float)(int)currentColor.A * opacity);
currentColor.R = (byte)(currentColor.R * opacity);
currentColor.G = (byte)(currentColor.G * opacity);
currentColor.B = (byte)(currentColor.B * opacity);
currentColor.A = (byte)(currentColor.A * opacity);
int totalAfterimages = 4;
for (int i = 0; i < totalAfterimages; i++)
{
@@ -8484,90 +8492,6 @@ namespace CalamityMod.NPCs
int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height();
spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f);
}
float secondAfterimageSetHealthValue = (int)(Main.npc[NPC.crimsonBoss].lifeMax * 0.8f);
if (Main.npc[NPC.crimsonBoss].life < secondAfterimageSetHealthValue)
{
currentColor = npc.GetAlpha(drawColor);
float opacityScale = 1f - Main.npc[NPC.crimsonBoss].life / (float)secondAfterimageSetHealthValue;
opacity = Main.getGoodWorld ? 1f : opacityScale;
opacity = MathHelper.Clamp(opacity, 0f, 1f);
currentColor.R = (byte)((float)(int)currentColor.R * opacity);
currentColor.G = (byte)((float)(int)currentColor.G * opacity);
currentColor.B = (byte)((float)(int)currentColor.B * opacity);
currentColor.A = (byte)((float)(int)currentColor.A * opacity);
totalAfterimages = death ? 12 : 4;
for (int i = 0; i < totalAfterimages; i++)
{
Vector2 position = npc.position;
float distanceFromTargetX = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X);
float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y);
if (i > 3)
{
currentColor *= 0.5f;
distanceFromTargetX *= 0.5f;
distanceFromTargetY *= 0.5f;
}
switch (i)
{
case 0:
case 4:
position.X = Main.LocalPlayer.Center.X - distanceFromTargetX;
position.Y = Main.LocalPlayer.Center.Y + distanceFromBrain.Y;
break;
case 1:
case 5:
position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY;
position.X = Main.LocalPlayer.Center.X + distanceFromBrain.X;
break;
case 2:
case 6:
position.X = Main.LocalPlayer.Center.X + distanceFromTargetX;
position.Y = Main.LocalPlayer.Center.Y + distanceFromBrain.Y;
break;
case 3:
case 7:
position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY;
position.X = Main.LocalPlayer.Center.X + distanceFromBrain.X;
break;
case 8:
position.X = Main.LocalPlayer.Center.X - distanceFromTargetX;
position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY;
break;
case 9:
position.X = Main.LocalPlayer.Center.X + distanceFromTargetX;
position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY;
break;
case 10:
position.X = Main.LocalPlayer.Center.X + distanceFromTargetX;
position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY;
break;
case 11:
position.X = Main.LocalPlayer.Center.X - distanceFromTargetX;
position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY;
break;
default:
break;
}
position.X -= npc.width / 2;
position.Y -= npc.height / 2;
int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width();
int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height();
spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f);
}
}
}
float beginTelegraphGateValue = BrainOfCthulhuAI.TimeBeforeCreeperAttack - BrainOfCthulhuAI.CreeperTelegraphTime;
@@ -8652,83 +8576,6 @@ namespace CalamityMod.NPCs
}
}
// His afterimages I can't get to work, so fuck it
else if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType<SkeletronPrime2>())
{
Texture2D npcTexture = (death && npc.type == NPCID.SkeletronPrime) ? ExtraTextureRefs.ChadPrime.Value : TextureAssets.Npc[npc.type].Value;
int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type];
npc.frame.Y = (int)newAI[3];
// Mechdusa drawing
if (NPC.IsMechQueenUp)
{
if (npc.ai[1] == 0f || npc.ai[1] == 4f)
{
newAI[2] += 1f;
if (newAI[2] >= 12f)
{
newAI[2] = 0f;
newAI[3] += frameHeight;
if (newAI[3] / frameHeight >= 5)
newAI[3] = frameHeight * 3;
}
}
else
{
newAI[2] = 0f;
newAI[3] = frameHeight * 5;
}
}
// Floating phase
else if (npc.ai[1] == 0f || npc.ai[1] == 4f)
{
newAI[2] += 1f;
if (newAI[2] >= 12f)
{
newAI[2] = 0f;
newAI[3] += frameHeight;
if (newAI[3] / frameHeight >= 2f)
newAI[3] = 0f;
}
}
// Spinning probe spawn or fly over phase
else if (npc.ai[1] == 5f || npc.ai[1] == 6f)
{
newAI[2] = 0f;
newAI[3] = frameHeight;
}
// Spinning phase
else
{
newAI[2] = 0f;
newAI[3] = frameHeight * 2;
}
npc.frame.Y = (int)newAI[3];
SpriteEffects spriteEffects = SpriteEffects.None;
if (npc.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, npc.GetAlpha(drawColor), npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f);
Color eyesColor = new Color(200, 200, 200, 0);
if (death)
{
int alpha = 192;
eyesColor = npc.type == NPCType<SkeletronPrime2>() ? new Color(150, 100, 255, alpha) : new Color(255, 255, 0, alpha);
Texture2D glowTexture = npc.type == NPCID.SkeletronPrime ? ExtraTextureRefs.ChadPrimeEyeGlowmask.Value : SkeletronPrime2.EyeTexture.Value;
spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, eyesColor, npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f);
}
else
spriteBatch.Draw(TextureAssets.BoneEyes.Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, eyesColor, npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f);
}
else if (npc.type == NPCID.Plantera)
{
// Percent life remaining
@@ -9087,7 +8934,7 @@ namespace CalamityMod.NPCs
{
return DownedBossSystem.downedGuardians;
}
else if (type == NPCType<Bumblefuck>())
else if (type == NPCType<Dragonfolly>())
{
return DownedBossSystem.downedDragonfolly;
}
+3 -1
View File
@@ -75,7 +75,6 @@ namespace CalamityMod.NPCs
};
private static readonly string[] ArmsDealerNames =
{
"Drifter",
"Finchi",
"Heniek", // <@!363404700445442050> (kazurgundu)
"Fire", // <@!354362326947856384> (ultimatefirewaster)
@@ -90,6 +89,7 @@ namespace CalamityMod.NPCs
{
"Joeseph Jostar",
"Storm Havik", // <@!1013452363178197072> (fishnotduck)
"Magorfis Splunt the Greater Finklejim", // <@!147490809334333440> (eidolbyssus)
};
private static readonly string[] CyborgNames =
{
@@ -110,6 +110,7 @@ namespace CalamityMod.NPCs
"Jasmine", // <@!430532867479699456> (phantasmagoria.)
"Cybil", // <@!486507232666845185> (Captain Doofus#????)
"Ruth", // <@!1001307586068492388> (briny_coffee)
"Kanna", // <@!730203712898859018> (cosmoredeathwish)
};
private static readonly string[] DyeTraderNames = null;
private static readonly string[] GoblinTinkererNames =
@@ -342,6 +343,7 @@ namespace CalamityMod.NPCs
{
"Felix", // <@!183424826407518208> (lilac_vrt_olligoci)
"Tardo", // <@!739343546867384391> (midnight295)
"Dali", // <@!460238880436781061> (darthlego)
};
private static readonly string[] TownCatRussianBlueNames = null;
private static readonly string[] TownCatSilverNames =
+6 -6
View File
@@ -154,7 +154,7 @@ namespace CalamityMod.NPCs.CeaselessVoid
if (phase4)
darkEnergyAmt += 1;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
darkEnergyAmt *= 2;
// Spawn a few Dark Energies as soon as the fight starts
@@ -222,7 +222,7 @@ namespace CalamityMod.NPCs.CeaselessVoid
float projectileFireRateMultiplier = MathHelper.Lerp(0.5f, 1.5f, 1f - ((tileEnrageMult - 1f) / 0.5f));
// Decides whether Ceaseless moves closer to its target or not
float distanceRequiredToMove = (Main.getGoodWorld || !anyDarkEnergies) ? 320f : bossRush ? 600f : 720f;
float distanceRequiredToMove = (CalamityWorld.LegendaryMode || !anyDarkEnergies) ? 320f : bossRush ? 600f : 720f;
bool move = Vector2.Distance(NPC.Center, player.Center) > distanceRequiredToMove || !Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1);
// Succ attack
@@ -540,7 +540,7 @@ namespace CalamityMod.NPCs.CeaselessVoid
acceleration *= 2f;
}
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
velocity *= 1.15f;
acceleration *= 1.15f;
@@ -550,8 +550,8 @@ namespace CalamityMod.NPCs.CeaselessVoid
// Move between 8 different positions around the player, in order
float maxDistance = 320f;
Vector2 moveToOffset = succ ? Vector2.Zero : Main.getGoodWorld ? new Vector2(0f, -maxDistance) : Vector2.Zero;
if (!succ && Main.getGoodWorld)
Vector2 moveToOffset = succ ? Vector2.Zero : CalamityWorld.LegendaryMode ? new Vector2(0f, -maxDistance) : Vector2.Zero;
if (!succ && CalamityWorld.LegendaryMode)
{
// Move to a new location every few seconds
calamityGlobalNPC.newAI[2] += 1f;
@@ -603,7 +603,7 @@ namespace CalamityMod.NPCs.CeaselessVoid
Vector2 distanceFromDestination = destination - NPC.Center;
// Movement
if (NPC.Distance(destination) > maxDistance || succ || !Main.getGoodWorld)
if (NPC.Distance(destination) > maxDistance || succ || !CalamityWorld.LegendaryMode)
CalamityUtils.SmoothMovement(NPC, 0f, distanceFromDestination, velocity, acceleration, true);
}
+1 -1
View File
@@ -123,7 +123,7 @@ namespace CalamityMod.NPCs.CeaselessVoid
if (NPC.Opacity > 1f)
NPC.Opacity = 1f;
NPC.scale = MathHelper.Lerp(0.05f, Main.getGoodWorld ? 0.5f : 1f, NPC.Opacity);
NPC.scale = MathHelper.Lerp(0.05f, CalamityWorld.LegendaryMode ? 0.5f : 1f, NPC.Opacity);
}
else
{
+5 -5
View File
@@ -31,13 +31,13 @@ namespace CalamityMod.NPCs.Crabulon
NPC.GetNPCDamage();
NPC.width = 14;
NPC.height = 14;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.scale = 2f;
NPC.lifeMax = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 180 : 15;
NPC.lifeMax = CalamityWorld.LegendaryMode ? 180 : 15;
if (BossRushEvent.BossRushActive)
NPC.lifeMax = 8000;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 2;
AIType = -1;
NPC.knockBackResist = 0.5f;
@@ -71,7 +71,7 @@ namespace CalamityMod.NPCs.Crabulon
bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
float xVelocityLimit = BossRushEvent.BossRushActive ? 12f : death ? 8f : revenge ? 6f : 5f;
float yVelocityLimit = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.25f : death ? 0.75f : revenge ? 0.9f : 1f;
float yVelocityLimit = CalamityWorld.LegendaryMode ? 0.25f : death ? 0.75f : revenge ? 0.9f : 1f;
// Get a target
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
@@ -103,7 +103,7 @@ namespace CalamityMod.NPCs.Crabulon
NPC.rotation = NPC.velocity.X * 0.1f;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
{
float pushVelocity = 0.5f;
foreach (NPC n in Main.ActiveNPCs)
+6 -6
View File
@@ -95,7 +95,7 @@ namespace CalamityMod.NPCs.Crabulon
NPC.Calamity().VulnerableToCold = true;
NPC.Calamity().VulnerableToSickness = true;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
NPC.scale *= 1.5f;
NPC.defense += 12;
@@ -208,7 +208,7 @@ namespace CalamityMod.NPCs.Crabulon
enrageScale += 1f;
}
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
enrageScale += 0.5f;
if (NPC.ai[0] < 2f)
@@ -285,7 +285,7 @@ namespace CalamityMod.NPCs.Crabulon
walkingVelocity += 0.75f;
if (phase4)
walkingVelocity += 1f;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
walkingVelocity *= 2f;
bool shouldWalkSlower = false;
@@ -982,7 +982,7 @@ namespace CalamityMod.NPCs.Crabulon
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int crabShroomSpawnFreq = (int)(NPC.lifeMax * ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.01 : Main.getGoodWorld ? 0.02 : 0.05));
int crabShroomSpawnFreq = (int)(NPC.lifeMax * (CalamityWorld.LegendaryMode ? 0.02 : 0.05));
if ((NPC.life + crabShroomSpawnFreq) < NPC.localAI[0])
{
NPC.localAI[0] = NPC.life;
@@ -994,8 +994,8 @@ namespace CalamityMod.NPCs.Crabulon
int npcType = ModContent.NPCType<CrabShroom>();
int crabShroom = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, npcType);
Main.npc[crabShroom].SetDefaults(npcType);
Main.npc[crabShroom].velocity.X = Main.rand.Next(-50, 51) * (Main.getGoodWorld ? 0.2f : 0.1f);
Main.npc[crabShroom].velocity.Y = Main.rand.Next(-50, -31) * (Main.getGoodWorld ? 0.2f : 0.1f);
Main.npc[crabShroom].velocity.X = Main.rand.Next(-50, 51) * (CalamityWorld.LegendaryMode ? 0.2f : 0.1f);
Main.npc[crabShroom].velocity.Y = Main.rand.Next(-50, -31) * (CalamityWorld.LegendaryMode ? 0.2f : 0.1f);
if (Main.dedServ && crabShroom < Main.maxNPCs)
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, crabShroom);
}
+1 -1
View File
@@ -5,7 +5,7 @@ using CalamityMod.Dusts;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Placeables.Crags;
using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.Particles;
using CalamityMod.World;
using Microsoft.Xna.Framework;
+10 -10
View File
@@ -111,7 +111,7 @@ namespace CalamityMod.NPCs.Cryogen
NPC.HitSound = HitSound;
NPC.DeathSound = DeathSound;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.8f;
if (Main.zenithWorld)
@@ -294,7 +294,7 @@ namespace CalamityMod.NPCs.Cryogen
else if (NPC.timeLeft < 1800)
NPC.timeLeft = 1800;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
{
int spawnType = Main.zenithWorld ? NPCID.RedDevil : NPCID.IceGolem;
if (!NPC.AnyNPCs(spawnType))
@@ -322,13 +322,13 @@ namespace CalamityMod.NPCs.Cryogen
float chargePhaseGateValue = bossRush ? 240f : 360f;
float chargeDuration = 60f;
float chargeTelegraphTime = NPC.ai[0] == 2f ? ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 60f : 80f) : ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 90f : 120f);
float chargeTelegraphTime = NPC.ai[0] == 2f ? (CalamityWorld.LegendaryMode ? 60f : 80f) : (CalamityWorld.LegendaryMode ? 90f : 120f);
float chargeTelegraphMaxRotationIncrement = 1f;
float chargeTelegraphRotationIncrement = chargeTelegraphMaxRotationIncrement / chargeTelegraphTime;
float chargeSlowDownTime = 15f;
float chargeVelocityMin = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 24f : 12f;
float chargeVelocityMax = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 42f : 30f;
if (Main.getGoodWorld)
float chargeVelocityMin = CalamityWorld.LegendaryMode ? 24f : 12f;
float chargeVelocityMax = CalamityWorld.LegendaryMode ? 42f : 30f;
if (CalamityWorld.LegendaryMode)
{
chargePhaseGateValue *= 0.7f;
chargeDuration *= 0.8f;
@@ -414,7 +414,7 @@ namespace CalamityMod.NPCs.Cryogen
playerYDist *= playerDistance;
float inertia = 50f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
inertia *= 0.5f;
NPC.velocity.X = (NPC.velocity.X * inertia + playerXDist) / (inertia + 1f);
@@ -688,7 +688,7 @@ namespace CalamityMod.NPCs.Cryogen
playerYDist *= playerDistance;
float inertia = 50f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
inertia *= 0.5f;
NPC.velocity.X = (NPC.velocity.X * inertia + playerXDist) / (inertia + 1f);
@@ -851,7 +851,7 @@ namespace CalamityMod.NPCs.Cryogen
playerYDist *= playerDistance;
float inertia = 50f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
inertia *= 0.5f;
NPC.velocity.X = (NPC.velocity.X * inertia + playerXDist) / (inertia + 1f);
@@ -1130,7 +1130,7 @@ namespace CalamityMod.NPCs.Cryogen
}
float inertia = 30f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
inertia *= 0.5f;
NPC.velocity.X = (NPC.velocity.X * inertia + playerchargeXDist) / (inertia + 1f);
+1 -1
View File
@@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.Cryogen
NPC.GetNPCDamage();
NPC.width = 216;
NPC.height = 216;
NPC.scale *= (CalamityWorld.death || BossRushEvent.BossRushActive || Main.getGoodWorld) ? 0.8f : 1f;
NPC.scale *= (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.LegendaryMode) ? 0.8f : 1f;
NPC.DR_NERD(0.4f);
NPC.LifeMaxNERB(2800, 3360, 33600);
NPC.Opacity = 0f;
+3 -3
View File
@@ -44,11 +44,11 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.height = 88;
NPC.defense = 5;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.defense += 27;
NPC.LifeMaxNERB(1500, 1800, 40000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax = 4800;
NPC.aiStyle = -1;
AIType = -1;
@@ -173,7 +173,7 @@ namespace CalamityMod.NPCs.DesertScourge
// Calculate contact damage based on velocity
float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHead.SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? DesertNuisanceHead.SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? DesertNuisanceHead.SegmentVelocity_GoodWorld :
death ? DesertNuisanceHead.SegmentVelocity_Death :
DesertNuisanceHead.SegmentVelocity_Expert;
maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio);
@@ -44,11 +44,11 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.height = 78;
NPC.defense = 4;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.defense += 26;
NPC.LifeMaxNERB(1300, 1560, 35000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax = 4000;
NPC.aiStyle = -1;
AIType = -1;
@@ -181,7 +181,7 @@ namespace CalamityMod.NPCs.DesertScourge
// Calculate contact damage based on velocity
float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHeadYoung.SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld :
death ? DesertNuisanceHeadYoung.SegmentVelocity_Death :
DesertNuisanceHeadYoung.SegmentVelocity_Expert;
maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio);
+6 -6
View File
@@ -56,14 +56,14 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.GetNPCDamage();
NPC.defense = 3;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.defense += 19;
NPC.width = 88;
NPC.height = 88;
NPC.LifeMaxNERB(1500, 1800, 40000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax = 4800;
NPC.aiStyle = -1;
AIType = -1;
@@ -146,7 +146,7 @@ namespace CalamityMod.NPCs.DesertScourge
speed += 0.085f * enrageScale;
turnSpeed += 0.17f * enrageScale;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
speed *= 1.1f;
turnSpeed *= 1.2f;
@@ -168,7 +168,7 @@ namespace CalamityMod.NPCs.DesertScourge
{
int previous = NPC.whoAmI;
int minLength = 8;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
minLength *= 2;
int bodyTypeAIVariable = 0;
@@ -272,7 +272,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.spriteDirection = -1;
float maxChaseSpeed = Main.zenithWorld ? SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? SegmentVelocity_GoodWorld :
death ? SegmentVelocity_Death :
SegmentVelocity_Expert;
maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio);
@@ -299,7 +299,7 @@ namespace CalamityMod.NPCs.DesertScourge
}
}
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
{
speed *= 1.5f;
turnSpeed *= 1.5f;
@@ -48,14 +48,14 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.GetNPCDamage();
NPC.defense = 2;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.defense += 18;
NPC.width = 78;
NPC.height = 78;
NPC.LifeMaxNERB(1300, 1560, 35000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax = 4000;
NPC.aiStyle = -1;
AIType = -1;
@@ -142,7 +142,7 @@ namespace CalamityMod.NPCs.DesertScourge
speed += 0.07f * enrageScale;
turnSpeed += 0.14f * enrageScale;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
speed *= 1.1f;
turnSpeed *= 1.2f;
@@ -203,7 +203,7 @@ namespace CalamityMod.NPCs.DesertScourge
{
int previous = NPC.whoAmI;
int minLength = 8;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
minLength *= 2;
int bodyTypeAIVariable = 0;
@@ -311,7 +311,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.spriteDirection = -1;
float maxChaseSpeed = Main.zenithWorld ? SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? SegmentVelocity_GoodWorld :
death ? SegmentVelocity_Death :
SegmentVelocity_Expert;
maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio);
@@ -338,7 +338,7 @@ namespace CalamityMod.NPCs.DesertScourge
}
}
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
{
speed *= 1.5f;
turnSpeed *= 1.5f;
+3 -3
View File
@@ -26,11 +26,11 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.height = 88;
NPC.defense = 8;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.defense += 34;
NPC.LifeMaxNERB(1500, 1800, 40000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax = 4800;
NPC.aiStyle = -1;
AIType = -1;
@@ -137,7 +137,7 @@ namespace CalamityMod.NPCs.DesertScourge
// Calculate contact damage based on velocity
float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHead.SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? DesertNuisanceHead.SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? DesertNuisanceHead.SegmentVelocity_GoodWorld :
death ? DesertNuisanceHead.SegmentVelocity_Death :
DesertNuisanceHead.SegmentVelocity_Expert;
maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio);
@@ -26,11 +26,11 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.height = 78;
NPC.defense = 7;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.defense += 33;
NPC.LifeMaxNERB(1300, 1560, 35000);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax = 4000;
NPC.aiStyle = -1;
AIType = -1;
@@ -145,7 +145,7 @@ namespace CalamityMod.NPCs.DesertScourge
// Calculate contact damage based on velocity
float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHeadYoung.SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld :
death ? DesertNuisanceHeadYoung.SegmentVelocity_Death :
DesertNuisanceHeadYoung.SegmentVelocity_Expert;
maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio);
+3 -3
View File
@@ -50,7 +50,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.DR_NERD(0.05f);
NPC.LifeMaxNERB(4200, 5000, 1150000);
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 4;
NPC.aiStyle = -1;
AIType = -1;
@@ -65,7 +65,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.netAlways = true;
NPC.dontCountMe = true;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.4f;
NPC.Calamity().VulnerableToCold = true;
@@ -217,7 +217,7 @@ namespace CalamityMod.NPCs.DesertScourge
// Calculate contact damage based on velocity
float maxChaseSpeed = Main.zenithWorld ? DesertScourgeHead.SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? DesertScourgeHead.SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? DesertScourgeHead.SegmentVelocity_GoodWorld :
death ? DesertScourgeHead.SegmentVelocity_Death :
expertMode ? DesertScourgeHead.SegmentVelocity_Expert :
DesertScourgeHead.SegmentVelocity_Normal;
+8 -8
View File
@@ -95,7 +95,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.height = 104;
NPC.LifeMaxNERB(4200, 5000, 1150000);
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 4;
NPC.aiStyle = -1;
AIType = -1;
@@ -110,7 +110,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.DeathSound = DeathSound;
NPC.netAlways = true;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.4f;
if (Main.zenithWorld)
@@ -257,7 +257,7 @@ namespace CalamityMod.NPCs.DesertScourge
speed += 0.085f * enrageScale;
turnSpeed += 0.17f * enrageScale;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
speed *= 1.1f;
turnSpeed *= 1.2f;
@@ -431,7 +431,7 @@ namespace CalamityMod.NPCs.DesertScourge
{
int previous = NPC.whoAmI;
int minLength = death ? 24 : revenge ? 21 : expertMode ? 18 : 15;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
minLength *= 3;
int bodyTypeAIVariable = 0;
@@ -542,7 +542,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.spriteDirection = -1;
float maxChaseSpeed = Main.zenithWorld ? SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? SegmentVelocity_GoodWorld :
death ? SegmentVelocity_Death :
expertMode ? SegmentVelocity_Expert :
SegmentVelocity_Normal;
@@ -601,15 +601,15 @@ namespace CalamityMod.NPCs.DesertScourge
{
// Spit a huge spread of sand upwards that falls down
SoundEngine.PlaySound(SandBlastSound, NPC.Center);
float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 16f : bossRush ? 10f : death ? 8.5f : revenge ? 8f : expertMode ? 7.5f : 6f;
float velocity = CalamityWorld.LegendaryMode ? 16f : bossRush ? 10f : death ? 8.5f : revenge ? 8f : expertMode ? 7.5f : 6f;
int type = ModContent.ProjectileType<DesertScourgeSpit>();
int damage = NPC.GetProjectileDamage(type);
Vector2 projectileVelocity = (NPC.Center + NPC.velocity * 10f - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity;
int numProj = bossRush ? 30 : death ? 24 : revenge ? 21 : expertMode ? 18 : 12;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
numProj *= 2;
int spread = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 120 : 90;
int spread = CalamityWorld.LegendaryMode ? 120 : 90;
float rotation = MathHelper.ToRadians(spread);
for (int i = 0; i < numProj; i++)
{
+3 -3
View File
@@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.DR_NERD(0.1f);
NPC.LifeMaxNERB(4200, 5000, 1150000);
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 4;
NPC.aiStyle = -1;
AIType = -1;
@@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.netAlways = true;
NPC.dontCountMe = true;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.4f;
NPC.Calamity().VulnerableToCold = true;
@@ -179,7 +179,7 @@ namespace CalamityMod.NPCs.DesertScourge
// Calculate contact damage based on velocity
float maxChaseSpeed = Main.zenithWorld ? DesertScourgeHead.SegmentVelocity_ZenithSeed :
Main.getGoodWorld ? DesertScourgeHead.SegmentVelocity_GoodWorld :
CalamityWorld.LegendaryMode ? DesertScourgeHead.SegmentVelocity_GoodWorld :
death ? DesertScourgeHead.SegmentVelocity_Death :
expertMode ? DesertScourgeHead.SegmentVelocity_Expert :
DesertScourgeHead.SegmentVelocity_Normal;
+2 -2
View File
@@ -89,7 +89,7 @@ namespace CalamityMod.NPCs.DevourerofGods
NPC.BossBar = Main.BigBossProgressBar.NeverValid;
NPC.dontCountMe = true;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.5f;
// Scale HP in Master
@@ -275,7 +275,7 @@ namespace CalamityMod.NPCs.DevourerofGods
float segmentVelocity = bossRush ? 19f : death ? 17.5f : 16f;
if (expertMode)
segmentVelocity += 4f * (1f - lifeRatio);
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
segmentVelocity *= 1.1f;
// Calculate contact damage based on velocity
+10 -10
View File
@@ -213,7 +213,7 @@ namespace CalamityMod.NPCs.DevourerofGods
NPC.DeathSound = SoundID.NPCDeath14;
NPC.netAlways = true;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.5f;
// Scale HP in Master
@@ -425,7 +425,7 @@ namespace CalamityMod.NPCs.DevourerofGods
groundPhaseTurnSpeed += Vector2.Distance(destination, NPC.Center) * 0.0002f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
segmentVelocity *= 1.1f;
speed *= 1.1f;
@@ -751,10 +751,10 @@ namespace CalamityMod.NPCs.DevourerofGods
// Fireballs
// Check angle and distance to make sure it's realistic that they'd be fired
if (NPC.Opacity >= 1f && (distanceFromTarget > 480f || (CalamityWorld.LegendaryMode && CalamityWorld.revenge)) && (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation())
if (NPC.Opacity >= 1f && (distanceFromTarget > 480f || CalamityWorld.LegendaryMode) && (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation())
{
calamityGlobalNPC.newAI[0] += 1f;
if (calamityGlobalNPC.newAI[0] >= ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 30f : 150f) && calamityGlobalNPC.newAI[0] % ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 30f : phase7 ? 30f : 60f) == 0f)
if (calamityGlobalNPC.newAI[0] >= (CalamityWorld.LegendaryMode ? 30f : 150f) && calamityGlobalNPC.newAI[0] % (CalamityWorld.LegendaryMode ? 30f : phase7 ? 30f : 60f) == 0f)
{
float fireballSpeed = 8f;
Vector2 fireballVelocity = Vector2.Normalize(player.Center - NPC.Center) * fireballSpeed + NPC.velocity * 0.5f;
@@ -769,7 +769,7 @@ namespace CalamityMod.NPCs.DevourerofGods
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, fireballVelocity, type, damage, 0f, Main.myPlayer);
if (CalamityWorld.LegendaryMode && revenge)
if (CalamityWorld.LegendaryMode)
{
for (int l = 0; l < 8; l++)
{
@@ -1112,7 +1112,7 @@ namespace CalamityMod.NPCs.DevourerofGods
speedCopy += Vector2.Distance(destination, NPC.Center) * 0.005f;
turnSpeedCopy += Vector2.Distance(destination, NPC.Center) * 0.00025f;
if (CalamityWorld.LegendaryMode && revenge)
if (CalamityWorld.LegendaryMode)
{
if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation())
speedCopy *= 2f;
@@ -1270,7 +1270,7 @@ namespace CalamityMod.NPCs.DevourerofGods
else if (increaseSpeed)
groundPhaseTurnSpeed *= 2f;
if (CalamityWorld.LegendaryMode && revenge)
if (CalamityWorld.LegendaryMode)
{
if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation())
segmentVelocity *= 2f;
@@ -1871,7 +1871,7 @@ namespace CalamityMod.NPCs.DevourerofGods
turnSpeedCopy += distanceFromTarget * 0.0001f * (1f - lifeRatio);
}
if (CalamityWorld.LegendaryMode && revenge)
if (CalamityWorld.LegendaryMode)
{
if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation())
speedCopy *= 2f;
@@ -2015,7 +2015,7 @@ namespace CalamityMod.NPCs.DevourerofGods
else if (increaseSpeed)
groundPhaseTurnSpeed *= 2f;
if (CalamityWorld.LegendaryMode && revenge)
if (CalamityWorld.LegendaryMode)
{
if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation())
segmentVelocity *= 2f;
@@ -2331,7 +2331,7 @@ namespace CalamityMod.NPCs.DevourerofGods
float mult = revenge ? 1.5f : 3f;
for (int i = 0; i < totalSpreads; i++)
{
int totalProjectiles = (CalamityWorld.LegendaryMode && revenge) ? 30 : bossRush ? 18 : 12;
int totalProjectiles = (CalamityWorld.LegendaryMode) ? 30 : bossRush ? 18 : 12;
float radians = MathHelper.TwoPi / totalProjectiles;
float newVelocity = finalVelocity - i * mult;
float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f);
+2 -2
View File
@@ -85,7 +85,7 @@ namespace CalamityMod.NPCs.DevourerofGods
NPC.takenDamageMultiplier = 1.25f;
NPC.dontCountMe = true;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.5f;
// Scale HP in Master
@@ -309,7 +309,7 @@ namespace CalamityMod.NPCs.DevourerofGods
float segmentVelocity = bossRush ? 19f : death ? 17.5f : 16f;
if (expertMode)
segmentVelocity += 4f * (1f - lifeRatio);
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
segmentVelocity *= 1.1f;
// Calculate contact damage based on velocity
+5 -5
View File
@@ -424,7 +424,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
float timeToLineUpAttack = 30f;
float timeToLineUpCharge = bossRush ? 45f : death ? 60f : revenge ? 68f : expertMode ? 75f : 90f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
timeToLineUpAttack *= 0.5f;
timeToLineUpCharge *= 0.5f;
@@ -445,7 +445,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Charge velocity
float chargeVelocity = bossRush ? 115f : death ? 105f : revenge ? 101.25f : expertMode ? 97.5f : 90f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
baseVelocity *= 1.5f;
chargeVelocity *= 1.15f;
@@ -466,7 +466,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
float rocketPhaseDuration = lastMechAlive ? 60f : 90f;
int numRockets = nerfedAttacks ? 2 : 3;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
numRockets += 3;
// Default vector to fly to
@@ -488,7 +488,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
int randomLocationVarianceX = shouldGetBuffedByBerserkPhase ? 50 : 20;
int randomLocationVarianceY = shouldGetBuffedByBerserkPhase ? 250 : 100;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
randomLocationVarianceX *= 2;
randomLocationVarianceY *= 2;
@@ -1180,7 +1180,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
NPC.ForceNetUpdate();
// Plasma bolts on charge
if (Main.netMode != NetmodeID.MultiplayerClient && (!(Main.zenithWorld && !exoMechdusa) || (CalamityWorld.LegendaryMode && revenge)))
if (Main.netMode != NetmodeID.MultiplayerClient && (!(Main.zenithWorld && !exoMechdusa) || (CalamityWorld.LegendaryMode)))
{
int totalProjectiles = bossRush ? 16 : death ? 12 : 8;
float radians = MathHelper.TwoPi / totalProjectiles;
+5 -4
View File
@@ -505,11 +505,12 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
}
// Prevent mechs from being respawned
if (otherExoMechWasFirst)
// CIT 08JUN2025: This code is pointless and makes me unable to work swapping the laser arm position. Commenting it out.
/*if (otherExoMechWasFirst)
{
if (NPC.ai[3] < 1f)
NPC.ai[3] = 1f;
}
}*/
// Phases
bool spawnOtherExoMechs = lifeRatio < 0.7f && NPC.ai[3] == 0f;
@@ -888,7 +889,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
else
{
// Enrage if the target is more than the deathray length away
if ((distanceFromTarget > DeathrayEnrageDistance || (CalamityWorld.LegendaryMode && revenge)) && EnragedState == (float)Enraged.No)
if ((distanceFromTarget > DeathrayEnrageDistance || (CalamityWorld.LegendaryMode)) && EnragedState == (float)Enraged.No)
{
// Play enrage sound
if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < soundDistance)
@@ -908,7 +909,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
NPC.velocity *= decelerationVelocityMult;
int totalProjectiles = bossRush ? 12 : death ? 10 : revenge ? 9 : expertMode ? 8 : 6;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
totalProjectiles += 4;
float radians = MathHelper.TwoPi / totalProjectiles;
+15 -2
View File
@@ -184,6 +184,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
bool nerfedAttacks = false;
if (exoTwinsAlive)
nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune;
// Used to make the beam only sweep horizontally during mecha mayhem phase
bool mechaMayhem = nerfedAttacks && exoWormAlive && Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] != (float)ThanatosHead.SecondaryPhase.PassiveAndImmune;
// Phases
bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f);
@@ -346,7 +348,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
else if (shouldGetBuffedByBerserkPhase)
deathrayPhaseGateValue *= 0.5f;
float deathrayPhaseVelocity = (nerfedAttacks ? 6f : passivePhase ? 9f : 12f) * baseVelocityMult;
float deathrayPhaseVelocity = (nerfedAttacks ? 8f : passivePhase ? 9f : 12f) * baseVelocityMult;
if (lastMechAlive)
deathrayPhaseVelocity *= 1.2f;
else if (shouldGetBuffedByBerserkPhase)
@@ -512,10 +514,21 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
AIState = (float)Phase.Nothing;
calamityGlobalNPC.newAI[2] = 0f;
// Change deathray sweep type for next deathray phase
// Change deathray sweep type for next deathray phase; this does not affect anything during mecha mayhem
calamityGlobalNPC.newAI[3] += 1f;
if (calamityGlobalNPC.newAI[3] > 1f)
calamityGlobalNPC.newAI[3] = 0f;
// If mecha mayhem, make Ares swap the position of the laser and gauss arms, and ensure the beam always sweeps horizontal
if (mechaMayhem)
{
calamityGlobalNPC.newAI[3] = 0f;
if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 0f)
Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] = 1f;
else
Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] = 0f;
Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ForceNetUpdate();
}
}
break;
+4 -4
View File
@@ -457,7 +457,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
float attackPhaseGateValue = shouldGetBuffedByBerserkPhase ? berserkAttackTime : normalAttackTime;
float timeToLineUpAttack = phase2 ? 30f : 45f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
timeToLineUpAttack *= 0.5f;
// Spin variables
@@ -496,7 +496,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Charge variables
float chargeVelocity = nerfedAttacks ? 60f : bossRush ? 81f : death ? 74f : revenge ? 70.5f : expertMode ? 67f : 60f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
chargeVelocity *= 1.15f;
float chargeDistance = 2000f;
@@ -521,7 +521,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
float baseVelocity = ((AIState == (int)Phase.Deathray || lineUpAttack || AIState == (int)Phase.LaserShotgun) ? 40f : 20f) * baseVelocityMult;
float decelerationVelocityMult = 0.85f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
baseVelocity *= 1.5f;
// Laser shotgun variables
@@ -535,7 +535,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
int randomLocationVarianceX = shouldGetBuffedByBerserkPhase ? 50 : 20;
int randomLocationVarianceY = shouldGetBuffedByBerserkPhase ? 250 : 100;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
randomLocationVarianceX *= 2;
randomLocationVarianceY *= 2;
+1 -1
View File
@@ -531,7 +531,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
else
baseVelocity *= increaseSpeedMult;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
baseVelocity *= 1.15f;
// Calculate contact damage based on velocity
+1 -1
View File
@@ -534,7 +534,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
else
baseVelocity *= increaseSpeedMult;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
baseVelocity *= 1.15f;
// Calculate contact damage based on velocity
+2 -2
View File
@@ -253,7 +253,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
}
public float GetSlowdownAreaEdgeRadius(bool lastMechAlive) =>
(BossRushEvent.BossRushActive ? 400f : CalamityWorld.death ? 600f : CalamityWorld.revenge ? 700f : Main.expertMode ? 800f : 1000f) * (lastMechAlive ? 0.6f : 1f) * (Main.zenithWorld && !exoMechdusa ? 2 : Main.getGoodWorld ? 0.5f : 1f);
(BossRushEvent.BossRushActive ? 400f : CalamityWorld.death ? 600f : CalamityWorld.revenge ? 700f : Main.expertMode ? 800f : 1000f) * (lastMechAlive ? 0.6f : 1f) * (Main.zenithWorld && !exoMechdusa ? 2 : CalamityWorld.LegendaryMode ? 0.5f : 1f);
public int CheckForOtherMechs(ref int targetIndex, out bool exoPrimeAlive, out bool exoTwinsAlive)
{
@@ -527,7 +527,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
else
baseVelocity *= increaseSpeedMult;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
baseVelocity *= 1.15f;
float turnDegrees = baseVelocity * 0.1f * (shouldGetBuffedByBerserkPhase ? 1.25f : 1.1f);
+1 -1
View File
@@ -532,7 +532,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
else
baseVelocity *= increaseSpeedMult;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
baseVelocity *= 1.15f;
// Calculate contact damage based on velocity
+2 -2
View File
@@ -24,10 +24,10 @@ namespace CalamityMod.NPCs.HiveMind
NPC.lifeMax = 120;
if (BossRushEvent.BossRushActive)
NPC.lifeMax = 2000;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 4;
if ((CalamityWorld.LegendaryMode && CalamityWorld.revenge))
if (CalamityWorld.LegendaryMode)
NPC.reflectsProjectiles = true;
NPC.aiStyle = -1;
+6 -6
View File
@@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.HiveMind
NPC.lifeMax = 75;
if (BossRushEvent.BossRushActive)
NPC.lifeMax = 1800;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 4;
NPC.aiStyle = -1;
@@ -73,9 +73,9 @@ namespace CalamityMod.NPCs.HiveMind
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
NPC.TargetClosest();
float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : death ? 7f : revenge ? 6f : 4f;
float acceleration = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.5f : death ? 0.35f : revenge ? 0.3f : 0.2f;
float deceleration = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.9f : death ? 0.95f : revenge ? 0.96f : 0.98f;
float velocity = CalamityWorld.LegendaryMode ? 10f : death ? 7f : revenge ? 6f : 4f;
float acceleration = CalamityWorld.LegendaryMode ? 0.5f : death ? 0.35f : revenge ? 0.3f : 0.2f;
float deceleration = CalamityWorld.LegendaryMode ? 0.9f : death ? 0.95f : revenge ? 0.96f : 0.98f;
if (BossRushEvent.BossRushActive)
{
velocity *= 2f;
@@ -121,7 +121,7 @@ namespace CalamityMod.NPCs.HiveMind
if (dropRain && Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.ai[0] += 1f;
float rainDropRate = Main.getGoodWorld ? 10f : death ? 15f : revenge ? 20f : 30f;
float rainDropRate = CalamityWorld.LegendaryMode ? 10f : death ? 15f : revenge ? 20f : 30f;
if (NPC.ai[0] >= rainDropRate)
{
NPC.ai[0] = 0f;
@@ -129,7 +129,7 @@ namespace CalamityMod.NPCs.HiveMind
int shaderainYos = (int)(NPC.position.Y + NPC.height + 4f);
int type = ModContent.ProjectileType<ShaderainHostile>();
int damage = NPC.GetProjectileDamage(type);
float randomXVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextFloat() * 5f : 0f;
float randomXVelocity = CalamityWorld.LegendaryMode ? Main.rand.NextFloat() * 5f : 0f;
float velocityY = 8f;
Projectile.NewProjectile(NPC.GetSource_FromAI(), shaderainXPos, shaderainYos, randomXVelocity, velocityY, type, damage, 0f, Main.myPlayer);
}
+4 -4
View File
@@ -34,7 +34,7 @@ namespace CalamityMod.NPCs.HiveMind
NPC.lifeMax = 50;
if (BossRushEvent.BossRushActive)
NPC.lifeMax = 1300;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 2;
NPC.knockBackResist = 0.9f;
@@ -110,7 +110,7 @@ namespace CalamityMod.NPCs.HiveMind
float hiveMindVelocity = Main.npc[hiveMind].velocity.Length();
float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f;
float acceleration = 0.8f;
float distanceFromMind = Main.getGoodWorld ? 256f : 128f;
float distanceFromMind = CalamityWorld.LegendaryMode ? 256f : 128f;
float hiveMindX = Main.npc[hiveMind].Center.X;
float hiveMindY = Main.npc[hiveMind].Center.Y;
@@ -183,7 +183,7 @@ namespace CalamityMod.NPCs.HiveMind
if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height))
{
float projSpeed = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
projSpeed *= 1.5f;
Vector2 projDirection = NPC.Center;
@@ -193,7 +193,7 @@ namespace CalamityMod.NPCs.HiveMind
playerDist = projSpeed / playerDist;
playerX *= playerDist;
playerY *= playerDist;
int type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType<VileClot>();
int type = (CalamityWorld.LegendaryMode && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType<VileClot>();
int damage = type == ProjectileID.CursedFlameHostile ? 30 : NPC.GetProjectileDamage(type);
Vector2 projectileVelocity = new Vector2(playerX, playerY);
if (type == ProjectileID.CursedFlameHostile)
+4 -4
View File
@@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.HiveMind
NPC.lifeMax = 75;
if (BossRushEvent.BossRushActive)
NPC.lifeMax = 1300;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.lifeMax *= 2;
NPC.knockBackResist = 0.9f;
@@ -104,7 +104,7 @@ namespace CalamityMod.NPCs.HiveMind
float hiveMindVelocity = Main.npc[hiveMind].velocity.Length();
float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f;
float acceleration = 0.8f;
float distanceFromMind = Main.getGoodWorld ? 192f : 96f;
float distanceFromMind = CalamityWorld.LegendaryMode ? 192f : 96f;
float hiveMindX = Main.npc[hiveMind].Center.X;
float hiveMindY = Main.npc[hiveMind].Center.Y;
@@ -177,7 +177,7 @@ namespace CalamityMod.NPCs.HiveMind
if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height))
{
float projSpeed = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
projSpeed *= 1.5f;
Vector2 projDirection = NPC.Center;
@@ -187,7 +187,7 @@ namespace CalamityMod.NPCs.HiveMind
playerDist = projSpeed / playerDist;
playerX *= playerDist;
playerY *= playerDist;
int type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType<VileClot>();
int type = (CalamityWorld.LegendaryMode && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType<VileClot>();
int damage = type == ProjectileID.CursedFlameHostile ? 30 : NPC.GetProjectileDamage(type);
Vector2 projectileVelocity = new Vector2(playerX, playerY);
if (type == ProjectileID.CursedFlameHostile)
+3 -3
View File
@@ -199,7 +199,7 @@ namespace CalamityMod.NPCs.HiveMind
driftBoost = 1f;
}
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
reelbackFade *= 10;
arcTime *= 0.5f;
@@ -570,7 +570,7 @@ namespace CalamityMod.NPCs.HiveMind
{
NPC.localAI[0] = 1f;
int maxBlobs = death ? 15 : revenge ? 7 : expertMode ? 6 : 5;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
maxBlobs *= 2;
if (Main.zenithWorld)
maxBlobs = 50;
@@ -1114,7 +1114,7 @@ namespace CalamityMod.NPCs.HiveMind
int type = ModContent.ProjectileType<ShadeNimbusHostile>();
int damage = NPC.GetProjectileDamage(type);
Vector2 cloudSpawnPos = new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(NPC.height));
Vector2 randomVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextVector2CircularEdge(4f, 4f) : Vector2.Zero;
Vector2 randomVelocity = CalamityWorld.LegendaryMode ? Main.rand.NextVector2CircularEdge(4f, 4f) : Vector2.Zero;
Projectile.NewProjectile(NPC.GetSource_FromAI(), cloudSpawnPos, randomVelocity, type, damage, 0, Main.myPlayer, 11f);
}
+2 -2
View File
@@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.HiveMind
NPC.width = 30; //324
NPC.height = 30; //216
NPC.defense = 0;
NPC.lifeMax = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10 : 1000;
NPC.lifeMax = CalamityWorld.LegendaryMode ? 10 : 1000;
NPC.knockBackResist = 0f;
NPC.chaseable = false;
NPC.HitSound = SoundID.NPCHit1;
@@ -131,7 +131,7 @@ namespace CalamityMod.NPCs.HiveMind
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.MultiplayerClient && (!NPC.AnyNPCs(ModContent.NPCType<HiveMind>()) || (CalamityWorld.LegendaryMode && CalamityWorld.revenge)))
if (Main.netMode != NetmodeID.MultiplayerClient && (!NPC.AnyNPCs(ModContent.NPCType<HiveMind>()) || CalamityWorld.LegendaryMode))
{
Vector2 spawnAt = NPC.Bottom;
NPC.NewNPC(NPC.GetSource_Death(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType<HiveMind>());
+11 -11
View File
@@ -83,7 +83,7 @@ namespace CalamityMod.NPCs.Leviathan
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.8f;
if (Main.zenithWorld)
@@ -192,9 +192,9 @@ namespace CalamityMod.NPCs.Leviathan
bubbleVelocity += 4f * enrageScale;
if (!leviAlive)
bubbleVelocity += 2f * (1f - lifeRatio);
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
bubbleVelocity *= 1.15f;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
bubbleVelocity *= 2f;
// Phases
@@ -617,14 +617,14 @@ namespace CalamityMod.NPCs.Leviathan
float velocity = death ? 13.5f : 12f;
velocity += 6f * enrageScale;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
velocity *= 1.15f;
Vector2 chargeSetupLocation = Vector2.Normalize(targetVector - NPC.Center - NPC.velocity) * velocity;
float acceleration = death ? 0.28f : 0.25f;
acceleration += 0.2f * enrageScale;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
acceleration *= 1.15f;
if (Math.Abs(NPC.Center.Y - targetVector.Y) > 50f * NPC.scale || Math.Abs(NPC.Center.X - player.Center.X) > 350f * NPC.scale)
@@ -654,7 +654,7 @@ namespace CalamityMod.NPCs.Leviathan
float telegraphDist = 500f;
// In Legendary, the projectiles she fires is randomized
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
{
LegendaryModeAttackChosen = Main.rand.Next(3);
if (LegendaryModeAttackChosen == 2)
@@ -708,7 +708,7 @@ namespace CalamityMod.NPCs.Leviathan
int totalProjectiles = 8;
int projectileDistance = 600;
int type = ModContent.ProjectileType<WaterSpear>();
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
if (CalamityWorld.LegendaryMode)
{
float radians = MathHelper.TwoPi / totalProjectiles;
int damage = NPC.GetProjectileDamage(type);
@@ -827,7 +827,7 @@ namespace CalamityMod.NPCs.Leviathan
if (revenge)
chargeVelocity += 2f + (death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio));
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
chargeVelocity *= 1.15f;
NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeVelocity;
@@ -853,7 +853,7 @@ namespace CalamityMod.NPCs.Leviathan
NPC.Calamity().canBreakPlayerDefense = true;
NPC.damage = (int)Math.Round(NPC.defDamage * 1.5);
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge && NPC.ai[1] % 5f == 0f)
if (CalamityWorld.LegendaryMode && NPC.ai[1] % 5f == 0f)
{
SoundEngine.PlaySound(SoundID.Item85, NPC.Center);
Vector2 bubbleSpawnPos = new Vector2(NPC.position.X + (NPC.width / 2) + (15 * NPC.direction * NPC.scale), NPC.position.Y + 30 * NPC.scale);
@@ -923,7 +923,7 @@ namespace CalamityMod.NPCs.Leviathan
Vector2 chargeSetupLocation = Vector2.Normalize(player.Center + new Vector2(NPC.localAI[0], -distance) - NPC.Center - NPC.velocity) * 12f;
float acceleration = revenge ? 0.75f : 0.5f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
acceleration *= 1.15f;
NPC.SimpleFlyMovement(chargeSetupLocation, acceleration);
@@ -980,7 +980,7 @@ namespace CalamityMod.NPCs.Leviathan
if (DrawProjectileTelegraphTimer > 0)
{
Color telegraphColor = Color.Black;
switch (CalamityWorld.LegendaryMode && CalamityWorld.revenge ? LegendaryModeAttackChosen : (int)NPC.localAI[3])
switch (CalamityWorld.LegendaryMode ? LegendaryModeAttackChosen : (int)NPC.localAI[3])
{
case 0:
telegraphColor = new Color(55, 70, 240);
+1 -1
View File
@@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.Leviathan
NPC.Calamity().VulnerableToCold = false;
NPC.Calamity().VulnerableToSickness = false;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.8f;
}
+1 -1
View File
@@ -55,7 +55,7 @@ namespace CalamityMod.NPCs.Leviathan
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.3f;
// Scale stats in Expert and Master
+7 -7
View File
@@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.Leviathan
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.3f;
if (Main.zenithWorld)
@@ -313,7 +313,7 @@ namespace CalamityMod.NPCs.Leviathan
hoverAcceleration += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio);
}
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
hoverSpeed *= 1.15f;
hoverAcceleration *= 1.15f;
@@ -413,7 +413,7 @@ namespace CalamityMod.NPCs.Leviathan
if (Main.zenithWorld)
{
type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? ProjectileID.BouncyBoulder : ProjectileID.Boulder;
type = CalamityWorld.LegendaryMode ? ProjectileID.BouncyBoulder : ProjectileID.Boulder;
leviCenter.Y -= 5; //Shoot a bit more up since boulders are affected by gravity
damage *= 2;
}
@@ -452,7 +452,7 @@ namespace CalamityMod.NPCs.Leviathan
NPC.ai[1] += activePlayerAmt / 2;
bool spawnedAberration = false;
float aberrationSpawnDelay = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 20f : (!sirenAlive || phase4) ? 60f : 40f;
float aberrationSpawnDelay = CalamityWorld.LegendaryMode ? 20f : (!sirenAlive || phase4) ? 60f : 40f;
if (NPC.ai[1] > aberrationSpawnDelay)
{
NPC.ai[1] = 0f;
@@ -460,7 +460,7 @@ namespace CalamityMod.NPCs.Leviathan
spawnedAberration = true;
}
int spawnLimit = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10 : (sirenAlive && !phase4) ? 1 : (death ? 2 : 3);
int spawnLimit = CalamityWorld.LegendaryMode ? 10 : (sirenAlive && !phase4) ? 1 : (death ? 2 : 3);
if (spawnedAberration && NPC.CountNPCS(ModContent.NPCType<AquaticAberration>()) < spawnLimit)
{
SoundEngine.PlaySound(soundChoice with { Pitch = soundChoice.Pitch + extrapitch }, npcCenter);
@@ -575,7 +575,7 @@ namespace CalamityMod.NPCs.Leviathan
if (revenge && (!sirenAlive || phase4))
lineupSpeed += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio);
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
lineupSpeed *= 1.15f;
Vector2 leviChargeCenter = npcCenter;
@@ -611,7 +611,7 @@ namespace CalamityMod.NPCs.Leviathan
chargeAcceleration += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio);
}
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
{
chargeSpeed *= 1.15f;
chargeAcceleration *= 1.15f;
+2 -1
View File
@@ -1,6 +1,7 @@
using System.IO;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Accessories;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
@@ -58,7 +59,7 @@ namespace CalamityMod.NPCs.Leviathan
NPC.Calamity().VulnerableToWater = false;
NPC.Calamity().ProvidesProximityRage = false;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 0.8f;
}
+1 -1
View File
@@ -439,7 +439,7 @@ namespace CalamityMod.NPCs.NormalNPCs
{
if (!CalamityPlayer.areThereAnyDamnBosses && NPC.downedPlantBoss && !NPC.AnyNPCs(ModContent.NPCType<ArmoredDiggerHead>()))
{
float spawnRateDivisor = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 125f : CalamityWorld.revenge ? 425f : 500f;
float spawnRateDivisor = CalamityWorld.LegendaryMode ? 125f : CalamityWorld.revenge ? 425f : 500f;
return 1 / spawnRateDivisor;
}
}
+2 -2
View File
@@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.NormalNPCs
NPC.height = 30;
if (Main.tenthAnniversaryWorld)
NPC.scale *= 0.5f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
NPC.scale *= 1.1f;
NPC.defense = 5;
@@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.NormalNPCs
bool charging = (attemptingToCharge && farEnoughForCharge && closeEnoughForCharge) || NPC.ai[1] > 0f;
float projectileShootGateValue = CalamityWorld.death ? 180f : 270f;
if (Main.getGoodWorld)
if (CalamityWorld.LegendaryMode)
projectileShootGateValue *= 0.5f;
Vector2 lookAt = target.Center - NPC.Center;
Loaded 100 of 254 files, more files were not shown because too many files have changed in this diff. Show more