using CalamityMod.Buffs;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatBuffs;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.AcidRain;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.Astral;
using CalamityMod.NPCs.AstrumAureus;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.NPCs.Bumblebirb;
using CalamityMod.NPCs.Calamitas;
using CalamityMod.NPCs.CeaselessVoid;
using CalamityMod.NPCs.Crabulon;
using CalamityMod.NPCs.Crags;
using CalamityMod.NPCs.Cryogen;
using CalamityMod.NPCs.DesertScourge;
using CalamityMod.NPCs.DevourerofGods;
using CalamityMod.NPCs.HiveMind;
using CalamityMod.NPCs.Leviathan;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.NPCs.OldDuke;
using CalamityMod.NPCs.Perforator;
using CalamityMod.NPCs.PlaguebringerGoliath;
using CalamityMod.NPCs.Polterghast;
using CalamityMod.NPCs.ProfanedGuardians;
using CalamityMod.NPCs.Providence;
using CalamityMod.NPCs.Ravager;
using CalamityMod.NPCs.Signus;
using CalamityMod.NPCs.SlimeGod;
using CalamityMod.NPCs.StormWeaver;
using CalamityMod.NPCs.SulphurousSea;
using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.NPCs.Yharon;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.DraedonsArsenal;
using CalamityMod.Projectiles.Magic;
using CalamityMod.Projectiles.Melee;
using CalamityMod.Projectiles.Ranged;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.Projectiles.Summon;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.UI;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.GameContent.Events;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.NPCs
{
public class CalamityGlobalNPC : GlobalNPC
{
#region Variables
public float DR { get; set; } = 0f;
public int KillTime { get; set; } = 0;
///
/// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false.
///
public bool unbreakableDR = false;
///
/// Overrides the normal DR math and uses custom DR reductions for each debuff, registered separately.
/// Used primarily by post-Moon Lord bosses.
///
public bool customDR = false;
public Dictionary flatDRReductions = new Dictionary();
public Dictionary multDRReductions = new Dictionary();
///
/// Allows hostile NPCs to deal damage to the player's defense stat, used mostly for hard-hitting bosses.
///
public bool canBreakPlayerDefense = false;
// Distance values for when bosses increase velocity to catch up to their target
public const float CatchUpDistance200Tiles = 3200f;
public const float CatchUpDistance350Tiles = 5600f;
// Max velocity used in contact damage scaling
public float maxVelocity = 0f;
// Town NPC shop alert animation variables
public int shopAlertAnimTimer = 0;
public int shopAlertAnimFrame = 0;
// NewAI
internal const int maxAIMod = 4;
public float[] newAI = new float[maxAIMod];
public int AITimer = 0;
// Town NPC Patreon
public bool setNewName = true;
// Draedons Remote
public static bool DraedonMayhem = false;
// Debuffs
public int vaporfied = 0;
public int timeSlow = 0;
public int gState = 0;
public int tesla = 0;
public int tSad = 0;
public int eFreeze = 0;
public int silvaStun = 0;
public int eutrophication = 0;
public int webbed = 0;
public int slowed = 0;
public int electrified = 0;
public int yellowCandle = 0;
public int pearlAura = 0;
public int wCleave = 0;
public int bBlood = 0;
public int dFlames = 0;
public int marked = 0;
public int irradiated = 0;
public int bFlames = 0;
public int hFlames = 0;
public int pFlames = 0;
public int aCrunch = 0;
public int pShred = 0;
public int cDepth = 0;
public int gsInferno = 0;
public int astralInfection = 0;
public int aFlames = 0;
public int wDeath = 0;
public int nightwither = 0;
public int enraged = 0;
public int shellfishVore = 0;
public int clamDebuff = 0;
public int sulphurPoison = 0;
public int ladHearts = 0;
public int kamiFlu = 0;
public int relicOfResilienceCooldown = 0;
public int relicOfResilienceWeakness = 0;
public int GaussFluxTimer = 0;
// whoAmI Variables
public static int[] bobbitWormBottom = new int[5];
public static int hiveMind = -1;
public static int perfHive = -1;
public static int slimeGodPurple = -1;
public static int slimeGodRed = -1;
public static int slimeGod = -1;
public static int laserEye = -1;
public static int fireEye = -1;
public static int primeLaser = -1;
public static int primeCannon = -1;
public static int primeVice = -1;
public static int primeSaw = -1;
public static int brimstoneElemental = -1;
public static int cataclysm = -1;
public static int catastrophe = -1;
public static int calamitas = -1;
public static int leviathan = -1;
public static int siren = -1;
public static int scavenger = -1;
public static int energyFlame = -1;
public static int doughnutBoss = -1;
public static int holyBossAttacker = -1;
public static int holyBossDefender = -1;
public static int holyBossHealer = -1;
public static int holyBoss = -1;
public static int voidBoss = -1;
public static int signus = -1;
public static int ghostBossClone = -1;
public static int ghostBoss = -1;
public static int DoGHead = -1;
public static int SCalCataclysm = -1;
public static int SCalCatastrophe = -1;
public static int SCal = -1;
public static int SCalWorm = -1;
// Collections
public static SortedDictionary BossRushHPChanges = new SortedDictionary
{
// Tier 1
{ NPCID.QueenBee, 3150000 }, // 30 seconds
{ NPCID.BrainofCthulhu, 1000000 }, // 30 seconds with creepers
{ NPCID.Creeper, 100000 },
{ NPCID.KingSlime, 3000000 }, // 30 seconds
{ NPCID.BlueSlime, 36000 },
{ NPCID.SlimeSpiked, 72000 },
{ NPCID.GreenSlime, 27000 },
{ NPCID.RedSlime, 54000 },
{ NPCID.PurpleSlime, 72000 },
{ NPCID.YellowSlime, 63000 },
{ NPCID.IceSlime, 45000 },
{ NPCID.UmbrellaSlime, 54000 },
{ NPCID.RainbowSlime, 300000 },
{ NPCID.Pinky, 150000 },
{ NPCID.EyeofCthulhu, 4500000 }, // 30 seconds
{ NPCID.ServantofCthulhu, 60000 },
{ NPCID.SkeletronPrime, 1100000 }, // 30 seconds
{ NPCID.PrimeVice, 540000 },
{ NPCID.PrimeCannon, 450000 },
{ NPCID.PrimeSaw, 450000 },
{ NPCID.PrimeLaser, 380000 },
{ NPCID.Golem, 500000 }, // 30 seconds
{ NPCID.GolemHead, 300000 },
{ NPCID.GolemHeadFree, 300000 },
{ NPCID.GolemFistLeft, 250000 },
{ NPCID.GolemFistRight, 250000 },
{ NPCID.EaterofWorldsHead, 100000 }, // 30 seconds + immunity timer at start
{ NPCID.EaterofWorldsBody, 100000 },
{ NPCID.EaterofWorldsTail, 100000 },
// Tier 2
{ NPCID.TheDestroyer, 2500000 }, // 30 seconds + immunity timer at start
{ NPCID.TheDestroyerBody, 2500000 },
{ NPCID.TheDestroyerTail, 2500000 },
{ NPCID.Probe, 100000 },
{ NPCID.Spazmatism, 1500000 }, // 30 seconds
{ NPCID.Retinazer, 1250000 },
{ NPCID.WallofFlesh, 4500000 }, // 30 seconds
{ NPCID.WallofFleshEye, 4500000 },
{ NPCID.SkeletronHead, 1600000 }, // 30 seconds
{ NPCID.SkeletronHand, 600000 },
// Tier 3
{ NPCID.CultistBoss, 2200000 }, // 30 seconds
{ NPCID.CultistDragonHead, 600000 },
{ NPCID.CultistDragonBody1, 600000 },
{ NPCID.CultistDragonBody2, 600000 },
{ NPCID.CultistDragonBody3, 600000 },
{ NPCID.CultistDragonBody4, 600000 },
{ NPCID.CultistDragonTail, 600000 },
{ NPCID.AncientCultistSquidhead, 500000 },
{ NPCID.Plantera, 1600000 }, // 30 seconds
{ NPCID.PlanterasTentacle, 400000 },
// Tier 4
{ NPCID.DukeFishron, 2900000 }, // 30 seconds
{ NPCID.MoonLordCore, 1600000 }, // 1 minute
{ NPCID.MoonLordHand, 450000 },
{ NPCID.MoonLordHead, 600000 },
{ NPCID.MoonLordLeechBlob, 8000 }
// 8 minutes in total for vanilla Boss Rush bosses
};
public static SortedDictionary BossValues = new SortedDictionary
{
{ NPCID.QueenBee, Item.buyPrice(0, 5)},
{ NPCID.SkeletronHead, Item.buyPrice(0, 7) },
{ NPCID.DukeFishron, Item.buyPrice(0, 25) },
{ NPCID.CultistBoss, Item.buyPrice(0, 25) },
{ NPCID.MoonLordCore, Item.buyPrice(0, 30) }
};
///
/// Lists of enemies that resist piercing to some extent (mostly worms).
/// Could prove useful for other things as well.
///
public static List AstrumDeusIDs = new List
{
NPCType(),
NPCType(),
NPCType()
};
public static List CosmicGuardianIDs = new List
{
NPCType(),
NPCType(),
NPCType()
};
public static List AquaticScourgeIDs = new List
{
NPCType(),
NPCType(),
NPCType(),
NPCType()
};
public static List PerforatorIDs = new List
{
NPCType(),
NPCType(),
NPCType(),
NPCType(),
NPCType(),
NPCType(),
NPCType(),
NPCType(),
NPCType()
};
public static List DesertScourgeIDs = new List
{
NPCType(),
NPCType(),
NPCType()
};
public static List EaterofWorldsIDs = new List
{
NPCID.EaterofWorldsHead,
NPCID.EaterofWorldsBody,
NPCID.EaterofWorldsTail
};
public static List DeathModeSplittingWormIDs = new List
{
NPCID.DuneSplicerHead,
NPCID.DuneSplicerBody,
NPCID.DuneSplicerTail,
NPCID.DiggerHead,
NPCID.DiggerBody,
NPCID.DiggerTail,
NPCID.SeekerHead,
NPCID.SeekerBody,
NPCID.SeekerTail
};
public static List DestroyerIDs = new List
{
NPCID.TheDestroyer,
NPCID.TheDestroyerBody,
NPCID.TheDestroyerTail
};
public static List DarkEnergyIDs = new List
{
NPCType(),
NPCType(),
NPCType()
};
public static List StormWeaverIDs = new List
{
NPCType(),
NPCType(),
NPCType()
};
public static List GrenadeResistIDs = new List
{
ProjectileID.Grenade,
ProjectileID.StickyGrenade,
ProjectileID.BouncyGrenade,
ProjectileID.Bomb,
ProjectileID.StickyBomb,
ProjectileID.BouncyBomb,
ProjectileID.Dynamite,
ProjectileID.StickyDynamite,
ProjectileID.BouncyDynamite,
ProjectileID.Explosives,
ProjectileID.ExplosiveBunny,
ProjectileID.PartyGirlGrenade,
ProjectileID.BombFish,
ProjectileID.Beenade,
ProjectileID.Bee,
ProjectileID.GiantBee,
ProjectileType()
//ProjectileID.ScarabBomb
};
public static List ZeroContactDamageNPCList = new List
{
NPCID.DarkCaster,
NPCID.FireImp,
NPCID.Tim,
NPCID.CultistArcherBlue,
NPCID.DesertDjinn,
NPCID.DiabolistRed,
NPCID.DiabolistWhite,
NPCID.Gastropod,
NPCID.IceElemental,
NPCID.IchorSticker,
NPCID.Necromancer,
NPCID.NecromancerArmored,
NPCID.RaggedCaster,
NPCID.RaggedCasterOpenCoat,
NPCID.RuneWizard,
NPCID.SkeletonArcher,
NPCID.SkeletonCommando,
NPCID.SkeletonSniper,
NPCID.TacticalSkeleton,
NPCID.Clown,
NPCID.GoblinArcher,
NPCID.GoblinSorcerer,
NPCID.GoblinSummoner,
NPCID.PirateCrossbower,
NPCID.PirateDeadeye,
NPCID.PirateCaptain,
NPCID.DrManFly,
NPCID.MartianWalker,
NPCID.MartianTurret,
NPCID.ElfCopter,
NPCID.ElfArcher,
NPCID.NebulaBrain,
NPCID.StardustJellyfishBig,
NPCID.PirateShipCannon,
NPCID.MartianSaucer,
NPCID.MartianSaucerCannon,
NPCID.MartianSaucerCore,
NPCID.MartianSaucerTurret,
NPCID.Probe,
NPCID.CultistBoss,
NPCID.GolemHeadFree,
NPCID.MoonLordFreeEye,
NPCID.PlanterasHook
};
#endregion
#region Instance Per Entity
public override bool InstancePerEntity => true;
#endregion
#region Reset Effects
public override void ResetEffects(NPC npc)
{
void ResetSavedIndex(ref int type, int type1, int type2 = -1)
{
if (type >= 0)
{
if (!Main.npc[type].active)
{
type = -1;
}
else if (type2 == -1)
{
if (Main.npc[type].type != type1)
type = -1;
}
else
{
if (Main.npc[type].type != type1 && Main.npc[type].type != type2)
type = -1;
}
}
}
for (int i = 0; i < bobbitWormBottom.Length; i++)
ResetSavedIndex(ref bobbitWormBottom[i], NPCType());
ResetSavedIndex(ref hiveMind, NPCType());
ResetSavedIndex(ref perfHive, NPCType());
ResetSavedIndex(ref slimeGodPurple, NPCType(), NPCType());
ResetSavedIndex(ref slimeGodRed, NPCType(), NPCType());
ResetSavedIndex(ref slimeGod, NPCType());
ResetSavedIndex(ref laserEye, NPCID.Retinazer);
ResetSavedIndex(ref fireEye, NPCID.Spazmatism);
ResetSavedIndex(ref primeLaser, NPCID.PrimeLaser);
ResetSavedIndex(ref primeCannon, NPCID.PrimeCannon);
ResetSavedIndex(ref primeVice, NPCID.PrimeVice);
ResetSavedIndex(ref primeSaw, NPCID.PrimeSaw);
ResetSavedIndex(ref brimstoneElemental, NPCType());
ResetSavedIndex(ref cataclysm, NPCType());
ResetSavedIndex(ref catastrophe, NPCType());
ResetSavedIndex(ref calamitas, NPCType());
ResetSavedIndex(ref leviathan, NPCType());
ResetSavedIndex(ref siren, NPCType());
ResetSavedIndex(ref scavenger, NPCType());
ResetSavedIndex(ref energyFlame, NPCType());
ResetSavedIndex(ref doughnutBoss, NPCType());
ResetSavedIndex(ref holyBossAttacker, NPCType());
ResetSavedIndex(ref holyBossDefender, NPCType());
ResetSavedIndex(ref holyBossHealer, NPCType());
ResetSavedIndex(ref holyBoss, NPCType());
ResetSavedIndex(ref voidBoss, NPCType());
ResetSavedIndex(ref signus, NPCType());
ResetSavedIndex(ref ghostBossClone, NPCType());
ResetSavedIndex(ref ghostBoss, NPCType());
ResetSavedIndex(ref DoGHead, NPCType(), NPCType());
ResetSavedIndex(ref SCalCataclysm, NPCType());
ResetSavedIndex(ref SCalCatastrophe, NPCType());
ResetSavedIndex(ref SCal, NPCType());
ResetSavedIndex(ref SCalWorm, NPCType());
CalamityGlobalTownNPC.ResetTownNPCNameBools(npc, mod);
}
#endregion
#region Life Regen
public override void UpdateLifeRegen(NPC npc, ref int damage)
{
int genLimit = Main.maxTilesX / 2;
int abyssChasmX = CalamityWorld.abyssSide ? genLimit - (genLimit - 135) : genLimit + (genLimit - 135);
bool abyssPosX = false;
if (CalamityWorld.abyssSide)
{
if ((double)(npc.position.X / 16f) < abyssChasmX + 80)
{
abyssPosX = true;
}
}
else
{
if ((double)(npc.position.X / 16f) > abyssChasmX - 80)
{
abyssPosX = true;
}
}
bool inAbyss = ((npc.position.Y / 16f > (Main.rockLayer - Main.maxTilesY * 0.05)) && ((double)(npc.position.Y / 16f) <= Main.maxTilesY - 250) && abyssPosX) || CalamityWorld.abyssTiles > 200;
bool hurtByAbyss = npc.wet && npc.damage > 0 && !npc.boss && !npc.friendly && !npc.dontTakeDamage && inAbyss && !npc.buffImmune[BuffType()];
if (hurtByAbyss)
{
npc.AddBuff(BuffType(), 2);
npc.DeathSound = null;
npc.HitSound = null;
}
if (npc.damage > 0 && !npc.boss && !npc.friendly && !npc.dontTakeDamage && CalamityWorld.sulphurTiles > 30 &&
!npc.buffImmune[BuffID.Poisoned] && !npc.buffImmune[BuffType()])
{
if (npc.wet)
{
npc.AddBuff(BuffID.Poisoned, 2);
}
if (Main.raining)
{
npc.AddBuff(BuffType(), 2);
}
}
if (npc.venom)
{
if (npc.lifeRegen > 0)
{
npc.lifeRegen = 0;
}
int projectileCount = 0;
for (int j = 0; j < Main.maxProjectiles; j++)
{
if (Main.projectile[j].active &&
(Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType()) &&
Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI)
{
projectileCount++;
}
}
if (projectileCount > 0)
{
npc.lifeRegen -= projectileCount * 30;
if (damage < projectileCount * 6)
{
damage = projectileCount * 6;
}
}
}
if (npc.javelined)
{
if (npc.lifeRegen > 0)
{
npc.lifeRegen = 0;
}
int projectileCount = 0;
for (int j = 0; j < Main.maxProjectiles; j++)
{
if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() &&
Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI)
{
projectileCount++;
}
}
if (projectileCount > 0)
{
npc.lifeRegen -= projectileCount * 20;
if (damage < projectileCount * 4)
{
damage = projectileCount * 4;
}
}
}
if (shellfishVore > 0)
{
int projectileCount = 0;
for (int j = 0; j < Main.maxProjectiles; j++)
{
if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() &&
Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI)
{
projectileCount++;
if (projectileCount >= 5)
{
projectileCount = 5;
break;
}
}
}
ApplyDPSDebuff(shellfishVore, projectileCount * 250, projectileCount * 50, ref npc.lifeRegen, ref damage);
}
if (clamDebuff > 0)
{
int projectileCount = 0;
for (int j = 0; j < Main.maxProjectiles; j++)
{
if (Main.projectile[j].active && Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI)
{
if (Main.projectile[j].type == ProjectileType())
projectileCount += 2;
if (Main.projectile[j].type == ProjectileType())
projectileCount++;
}
}
ApplyDPSDebuff(clamDebuff, projectileCount * 15, projectileCount * 3, ref npc.lifeRegen, ref damage);
}
if (cDepth > 0)
{
if (npc.defense < 0)
{
npc.defense = 0;
}
int depthDamage = Main.hardMode ? 80 : 12;
if (hurtByAbyss)
{
depthDamage = 300;
}
int calcDepthDamage = depthDamage - npc.defense;
if (calcDepthDamage < 0)
{
calcDepthDamage = 0;
}
if (npc.lifeRegen > 0)
{
npc.lifeRegen = 0;
}
npc.lifeRegen -= calcDepthDamage * 5;
if (damage < calcDepthDamage)
{
damage = calcDepthDamage;
}
}
if (irradiated > 0)
{
int projectileCount = 0;
for (int j = 0; j < Main.maxProjectiles; j++)
{
if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() &&
Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI)
{
projectileCount++;
}
}
if (projectileCount > 0)
{
ApplyDPSDebuff(irradiated, projectileCount * 20, projectileCount * 4, ref npc.lifeRegen, ref damage);
}
else
{
ApplyDPSDebuff(irradiated, 20, 4, ref npc.lifeRegen, ref damage);
}
}
// Exo Freeze, Glacial State and Temporal Sadness don't work on bosses or other specific enemies.
if (!npc.boss && !CalamityLists.movementImpairImmuneList.Contains(npc.type))
{
if (eFreeze > 0 && !BossRushEvent.BossRushActive)
{
npc.velocity.X = 0f;
npc.velocity.Y += 0.1f;
if (npc.velocity.Y > 15f)
npc.velocity.Y = 15f;
}
else if (gState > 0)
{
npc.velocity.X = 0f;
npc.velocity.Y += 0.05f;
if (npc.velocity.Y > 15f)
npc.velocity.Y = 15f;
}
if (tSad > 0)
{
npc.velocity /= 2f;
}
}
//Oiled debuff makes flame debuffs 25% more effective
if (npc.oiled)
{
int oiledDoT = (bFlames > 0 ? 10 : 0) + (hFlames > 0 ? 13 : 0) + (gsInferno > 0 ? 63 : 0) + (aFlames > 0 ? 32 : 0) + (dFlames > 0 ? 625 : 0);
if (oiledDoT > 0)
{
int lifeRegenValue = oiledDoT * 4 + 12;
npc.lifeRegen -= lifeRegenValue;
int damageValue = lifeRegenValue / 6;
if (damage < damageValue)
damage = damageValue;
}
}
ApplyDPSDebuff(vaporfied, 30, 6, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(bFlames, 40, 8, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(hFlames, 50, 10, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(pFlames, 100, 20, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(gsInferno, 250, 50, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(astralInfection, 75, 15, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(aFlames, 125, 25, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(pShred, 1500, 300, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(nightwither, 200, 40, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(dFlames, 2500, 500, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(bBlood, 50, 10, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(kamiFlu, 250, 25, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(sulphurPoison, 180, 36, ref npc.lifeRegen, ref damage);
if (npc.velocity.X == 0)
ApplyDPSDebuff(electrified, 10, 2, ref npc.lifeRegen, ref damage);
else
ApplyDPSDebuff(electrified, 40, 8, ref npc.lifeRegen, ref damage);
}
public void ApplyDPSDebuff(int debuff, int lifeRegenValue, int damageValue, ref int lifeRegen, ref int damage)
{
if (debuff > 0)
{
if (lifeRegen > 0)
{
lifeRegen = 0;
}
lifeRegen -= lifeRegenValue;
if (damage < damageValue)
{
damage = damageValue;
}
}
}
#endregion
#region Set Defaults
public override void SetDefaults(NPC npc)
{
for (int m = 0; m < maxAIMod; m++)
{
newAI[m] = 0f;
}
// Apply DR to vanilla NPCs.
// This also applies DR to other mods' NPCs who have set up their NPCs to have DR.
if (CalamityMod.DRValues.ContainsKey(npc.type))
{
CalamityMod.DRValues.TryGetValue(npc.type, out float newDR);
DR = newDR;
}
if (CalamityMod.bossKillTimes.ContainsKey(npc.type))
{
CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime);
KillTime = revKillTime;
}
if (npc.boss && CalamityWorld.revenge)
{
if (npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
((npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType()) && npc.Calamity().newAI[0] != 0f))
{
if (Main.netMode != NetmodeID.Server)
{
if (!Main.LocalPlayer.dead && Main.LocalPlayer.active)
{
Main.LocalPlayer.Calamity().adrenaline = 0;
}
}
}
}
DebuffImmunities(npc);
if (BossRushEvent.BossRushActive)
{
BossRushStatChanges(npc, mod);
}
BossValueChanges(npc);
if (CalamityWorld.defiled)
{
npc.value = (int)(npc.value * 1.5);
}
if (DraedonMayhem)
{
DraedonMechaMayhemStatChanges(npc);
}
if (CalamityWorld.revenge)
{
RevDeathStatChanges(npc, mod);
}
OtherStatChanges(npc);
}
#endregion
#region Debuff Immunities
private void DebuffImmunities(NPC npc)
{
// Check out NPCDebuffs.cs as this function sets the debuff immunities for all enemies in Cal bar the ones described below.
npc.SetNPCDebuffImmunities();
// All bosses and several enemies are automatically immune to most of the movement debuffs. Silva Stun and Exo Freeze are excluded, but will not affect a boss if it has the debuff regardless.
if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss)
{
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffID.Webbed] = true;
npc.buffImmune[BuffID.Slow] = true;
}
// All enemies are automatically immune to the Confused debuff, so we must specifically set them not to be.
// Extra note: Clams are not in this list as they initially immune to Confused, but are no longer immune once aggro'd. This is set in their AI().
if (CalamityLists.confusionEnemyList.Contains(npc.type))
{
npc.buffImmune[BuffID.Confused] = false;
}
// Any enemy not immune to Venom shouldn't be immune to Sulphuric Poisoning as it is an upgrade.
if (!npc.buffImmune[BuffID.Venom])
{
npc.buffImmune[BuffType()] = false;
}
// Sets certain vanilla NPCs and all town NPCs to be immune to all debuffs.
if (DestroyerIDs.Contains(npc.type) || npc.type == NPCID.SkeletronHead || (EaterofWorldsIDs.Contains(npc.type) && BossRushEvent.BossRushActive) || npc.type == NPCID.DD2EterniaCrystal || npc.townNPC || npc.type == NPCID.SpikeBall || npc.type == NPCID.BlazingWheel)
{
for (int k = 0; k < npc.buffImmune.Length; k++)
{
npc.buffImmune[k] = true;
}
if (npc.townNPC)
{
npc.buffImmune[BuffID.Wet] = false;
npc.buffImmune[BuffID.Slimed] = false;
npc.buffImmune[BuffID.Lovestruck] = false;
npc.buffImmune[BuffID.Stinky] = false;
}
}
// Most bosses and boss servants are not immune to Kami Flu.
if (YanmeisKnifeSlash.CanRecieveCoolEffectsFrom(npc))
npc.buffImmune[BuffType()] = false;
// Nothing should be immune to Enraged.
npc.buffImmune[BuffType()] = false;
// Extra Notes:
// Shellfish minions set debuff immunity to Shellfish Claps on enemy hits, so most things are technically not immune.
// The Spiteful Candle sets the debuff immunity of Spite to all nearby enemies in the tile file for an enemy with less than 99% DR.
}
#endregion
#region Boss Rush Stat Changes
private void BossRushStatChanges(NPC npc, Mod mod)
{
if (!npc.friendly)
{
npc.buffImmune[BuffType()] = false;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffType()] = true;
npc.buffImmune[BuffID.Webbed] = true;
npc.buffImmune[BuffID.Slow] = true;
}
foreach (KeyValuePair BossRushHPChange in BossRushHPChanges)
{
if (npc.type == BossRushHPChange.Key)
{
npc.lifeMax = BossRushHPChange.Value;
break;
}
}
}
#endregion
#region Boss Value Changes
private void BossValueChanges(NPC npc)
{
foreach (KeyValuePair BossValue in BossValues)
{
if (npc.type == BossValue.Key)
{
npc.value = BossValue.Value;
break;
}
}
}
#endregion
#region Draedon Mecha Mayhem Stat Changes
private void DraedonMechaMayhemStatChanges(NPC npc)
{
switch (npc.type)
{
case NPCID.TheDestroyer:
case NPCID.TheDestroyerBody:
case NPCID.TheDestroyerTail:
npc.lifeMax = (int)(npc.lifeMax * 1.8);
npc.scale = 1.5f;
npc.npcSlots = 10f;
break;
case NPCID.Probe:
npc.lifeMax = (int)(npc.lifeMax * 1.6);
npc.scale *= 1.2f;
break;
case NPCID.SkeletronPrime:
npc.lifeMax = (int)(npc.lifeMax * 1.45);
npc.npcSlots = 12f;
break;
case NPCID.PrimeVice:
case NPCID.PrimeCannon:
case NPCID.PrimeSaw:
case NPCID.PrimeLaser:
npc.lifeMax = (int)(npc.lifeMax * 0.8);
break;
case NPCID.Retinazer:
case NPCID.Spazmatism:
npc.lifeMax = (int)(npc.lifeMax * 1.8);
npc.npcSlots = 10f;
break;
}
}
#endregion
#region Revengeance and Death Mode Stat Changes
private void RevDeathStatChanges(NPC npc, Mod mod)
{
npc.value = (int)(npc.value * 1.5);
if (DeathModeSplittingWormIDs.Contains(npc.type))
{
if (CalamityWorld.death)
npc.lifeMax = (int)(npc.lifeMax * 0.5);
}
if (npc.type == NPCID.Mothron)
{
npc.scale = 1.25f;
}
else if (npc.type == NPCID.MoonLordCore)
{
npc.lifeMax = (int)(npc.lifeMax * 2.2);
npc.npcSlots = 36f;
}
else if (npc.type == NPCID.MoonLordHand || npc.type == NPCID.MoonLordHead || npc.type == NPCID.MoonLordLeechBlob)
{
npc.lifeMax = (int)(npc.lifeMax * 1.2);
}
else if (npc.type >= NPCID.CultistDragonHead && npc.type <= NPCID.CultistDragonTail)
{
npc.lifeMax = (int)(npc.lifeMax * 5.0);
}
else if (npc.type == NPCID.DukeFishron)
{
npc.lifeMax = (int)(npc.lifeMax * 1.95);
npc.npcSlots = 20f;
}
else if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2)
{
npc.lifeMax = (int)(npc.lifeMax * 5.0);
}
else if (npc.type == NPCID.Golem)
{
npc.lifeMax = (int)(npc.lifeMax * 3.5);
npc.npcSlots = 64f;
}
else if (npc.type == NPCID.GolemHead)
{
npc.width = npc.height = 100;
npc.lifeMax = (int)(npc.lifeMax * 1.5);
}
else if (npc.type == NPCID.GolemHeadFree)
{
npc.width = npc.height = 100;
npc.lifeMax = (int)(npc.lifeMax * 1.7);
npc.dontTakeDamage = false;
}
else if (npc.type == NPCID.Plantera)
{
npc.lifeMax = (int)(npc.lifeMax * 2.35);
npc.npcSlots = 32f;
}
else if (npc.type == NPCID.WallofFlesh || npc.type == NPCID.WallofFleshEye)
{
npc.lifeMax = (int)(npc.lifeMax * 1.9);
if (npc.type == NPCID.WallofFlesh)
{
npc.npcSlots = 20f;
}
}
else if (npc.type == NPCID.TheHungryII || npc.type == NPCID.LeechHead || npc.type == NPCID.LeechBody || npc.type == NPCID.LeechTail)
{
npc.lifeMax = (int)(npc.lifeMax * 1.05);
}
else if (npc.type == NPCID.SkeletronHead)
{
if (CalamityWorld.death)
npc.lifeMax = (int)(npc.lifeMax * 0.5);
else
npc.lifeMax = (int)(npc.lifeMax * 0.75);
npc.npcSlots = 12f;
}
else if (npc.type == NPCID.SkeletronHand)
{
if (CalamityWorld.death)
npc.lifeMax = (int)(npc.lifeMax * 0.65);
else
npc.lifeMax = (int)(npc.lifeMax * 0.9);
}
else if (npc.type == NPCID.QueenBee)
{
npc.lifeMax = (int)(npc.lifeMax * 1.2);
npc.npcSlots = 14f;
}
else if ((npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) && CalamityPlayer.areThereAnyDamnBosses)
{
npc.lifeMax = (int)(npc.lifeMax * 1.4);
npc.scale = 1.25f;
}
else if (npc.type == NPCID.BrainofCthulhu)
{
npc.lifeMax = (int)(npc.lifeMax * 1.6);
npc.npcSlots = 12f;
}
else if (npc.type == NPCID.Creeper)
{
npc.lifeMax = (int)(npc.lifeMax * 1.1);
}
else if (EaterofWorldsIDs.Contains(npc.type))
{
npc.lifeMax = (int)(npc.lifeMax * 1.3);
if (npc.type == NPCID.EaterofWorldsHead)
npc.npcSlots = 10f;
if (CalamityWorld.death)
npc.scale = 1.1f;
}
else if (npc.type == NPCID.EyeofCthulhu)
{
npc.lifeMax = (int)(npc.lifeMax * 1.3);
npc.npcSlots = 10f;
}
else if (npc.type == NPCID.KingSlime)
{
if (CalamityWorld.death)
npc.scale = 3f;
}
else if (npc.type == NPCID.Wraith || npc.type == NPCID.Mimic || npc.type == NPCID.Reaper || npc.type == NPCID.PresentMimic || npc.type == NPCID.SandElemental)
{
npc.knockBackResist = 0f;
}
if (!DraedonMayhem)
{
if (DestroyerIDs.Contains(npc.type))
{
npc.lifeMax = (int)(npc.lifeMax * 1.25);
npc.scale = 1.5f;
npc.npcSlots = 10f;
}
else if (npc.type == NPCID.SkeletronPrime)
{
npc.lifeMax = (int)(npc.lifeMax * 1.2);
npc.npcSlots = 12f;
}
else if (npc.type <= NPCID.PrimeLaser && npc.type >= NPCID.PrimeCannon)
{
npc.lifeMax = (int)(npc.lifeMax * 0.65);
}
else if (npc.type == NPCID.Retinazer)
{
npc.lifeMax = (int)(npc.lifeMax * 1.3);
npc.npcSlots = 10f;
}
else if (npc.type == NPCID.Spazmatism)
{
npc.lifeMax = (int)(npc.lifeMax * 1.35);
npc.npcSlots = 10f;
}
}
if (CalamityLists.revengeanceLifeStealExceptionList.Contains(npc.type))
{
npc.canGhostHeal = false;
}
}
#endregion
#region Other Stat Changes
private void OtherStatChanges(NPC npc)
{
switch (npc.type)
{
case NPCID.EyeofCthulhu:
case NPCID.EaterofSouls:
case NPCID.Corruptor:
case NPCID.DevourerHead:
case NPCID.WalkingAntlion:
case NPCID.Crawdad:
case NPCID.Crawdad2: // chomp
case NPCID.DungeonGuardian:
case NPCID.ManEater:
case NPCID.AngryTrapper:
case NPCID.Snatcher:
case NPCID.SpikeBall:
case NPCID.TombCrawlerHead: // lol
case NPCID.DesertBeast: // don't ask me why basilisks are called this
case NPCID.BoneLee:
case NPCID.Paladin:
case NPCID.BigMimicCorruption:
case NPCID.BigMimicCrimson:
case NPCID.BigMimicHallow:
case NPCID.DiggerHead:
case NPCID.SeekerHead:
case NPCID.DuneSplicerHead:
case NPCID.SolarCrawltipedeHead: // everybody hates this enemy lol, but they're not that bad
case NPCID.Mimic:
case NPCID.SandShark:
case NPCID.SandsharkCorrupt:
case NPCID.SandsharkCrimson:
case NPCID.SandsharkHallow:
case NPCID.GoblinWarrior:
case NPCID.Butcher:
case NPCID.DeadlySphere:
case NPCID.Mothron:
case NPCID.Reaper:
case NPCID.Psycho:
case NPCID.PresentMimic:
case NPCID.Yeti:
case NPCID.NebulaBeast:
case NPCID.SolarCorite: // pain
case NPCID.StardustWormHead:
case NPCID.EaterofWorldsHead:
case NPCID.SkeletronHead:
case NPCID.WallofFlesh:
case NPCID.TheHungry:
case NPCID.TheHungryII:
case NPCID.Spazmatism:
case NPCID.TheDestroyer:
case NPCID.SkeletronPrime:
case NPCID.PrimeVice:
case NPCID.PrimeSaw:
case NPCID.Plantera:
case NPCID.PlanterasTentacle:
case NPCID.Golem:
case NPCID.GolemFistLeft:
case NPCID.GolemFistRight:
case NPCID.CultistDragonHead:
case NPCID.AncientLight:
case NPCID.DD2OgreT2:
case NPCID.DD2OgreT3:
case NPCID.DD2Betsy:
case NPCID.PumpkingBlade:
case NPCID.SantaNK1:
case NPCID.DukeFishron:
canBreakPlayerDefense = true;
break;
default:
break;
}
// Fix Sharkron hitboxes
if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2)
{
npc.width = npc.height = 36;
// Don't do damage for 42 frames after spawning in
npc.damage = npc.defDamage;
if (npc.alpha > 0)
npc.damage = 0;
}
// Make Core hitbox bigger
if (npc.type == NPCID.MartianSaucerCore)
{
npc.width *= 2;
npc.height *= 2;
}
if (npc.type == NPCID.CultistBoss)
{
npc.lifeMax = (int)(npc.lifeMax * (CalamityWorld.revenge ? 2 : 1.2));
npc.npcSlots = 20f;
}
else if (npc.type == NPCID.DungeonGuardian)
{
npc.lifeMax = (int)(npc.lifeMax * 0.1);
}
if (npc.type >= NPCID.TombCrawlerHead && npc.type <= NPCID.TombCrawlerTail && !Main.hardMode)
{
npc.lifeMax = (int)(npc.lifeMax * 0.6);
}
if (npc.type == NPCID.GreenJellyfish && !Main.hardMode)
{
npc.damage = 40;
npc.defDamage = npc.damage;
npc.defense = 4;
npc.defDefense = npc.defense;
}
if (Main.bloodMoon && NPC.downedMoonlord && !npc.boss && !npc.friendly && !npc.dontTakeDamage && npc.lifeMax <= 2000 && npc.damage > 0)
{
npc.lifeMax = (int)(npc.lifeMax * 3.5);
npc.damage += 100;
npc.life = npc.lifeMax;
npc.defDamage = npc.damage;
}
if (CalamityWorld.downedDoG)
{
if (CalamityLists.pumpkinMoonBuffList.Contains(npc.type))
{
npc.lifeMax = (int)(npc.lifeMax * 7.5);
npc.damage += 30;
npc.life = npc.lifeMax;
npc.defDamage = npc.damage;
}
else if (CalamityLists.frostMoonBuffList.Contains(npc.type))
{
npc.lifeMax = (int)(npc.lifeMax * 6D);
npc.damage += 30;
npc.life = npc.lifeMax;
npc.defDamage = npc.damage;
}
else if (CalamityLists.eclipseBuffList.Contains(npc.type))
{
npc.lifeMax = (int)(npc.lifeMax * 10D);
npc.damage += 30;
npc.life = npc.lifeMax;
npc.defDamage = npc.damage;
}
}
if (NPC.downedMoonlord)
{
if (CalamityLists.dungeonEnemyBuffList.Contains(npc.type))
{
npc.lifeMax = (int)(npc.lifeMax * 2.5);
npc.damage += 90;
npc.life = npc.lifeMax;
npc.defDamage = npc.damage;
}
}
if (CalamityWorld.revenge)
{
double damageMultiplier = 1D;
bool containsNPC = false;
if (CalamityLists.revengeanceEnemyBuffList25Percent.Contains(npc.type))
{
damageMultiplier += 0.25;
containsNPC = true;
}
else if (CalamityLists.revengeanceEnemyBuffList20Percent.Contains(npc.type))
{
damageMultiplier += 0.2;
containsNPC = true;
}
else if (CalamityLists.revengeanceEnemyBuffList15Percent.Contains(npc.type))
{
damageMultiplier += 0.15;
containsNPC = true;
}
else if (CalamityLists.revengeanceEnemyBuffList10Percent.Contains(npc.type))
{
damageMultiplier += 0.1;
containsNPC = true;
}
if (containsNPC)
{
if (CalamityWorld.death)
damageMultiplier += (damageMultiplier - 1D) * 0.6;
npc.damage = (int)(npc.damage * damageMultiplier);
npc.defDamage = npc.damage;
}
}
if (npc.type < NPCID.Count && NPCStats.BossStats.ContactDamageValues.ContainsKey(npc.type))
{
npc.GetNPCDamage();
npc.defDamage = npc.damage;
}
if ((npc.boss && npc.type != NPCID.MartianSaucerCore && npc.type < NPCID.Count) || CalamityLists.bossHPScaleList.Contains(npc.type))
{
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
npc.lifeMax += (int)(npc.lifeMax * HPBoost);
}
}
#endregion
#region Special Drawing
public static void DrawGlowmask(NPC npc, SpriteBatch spriteBatch, Texture2D texture = null, bool invertedDirection = false, Vector2 offset = default)
{
if (texture is null)
texture = Main.npcTexture[npc.type];
SpriteEffects effects = npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
if (invertedDirection)
effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
spriteBatch.Draw(texture,
npc.Center - Main.screenPosition + offset,
npc.frame,
Color.White,
npc.rotation,
npc.Size / 2f,
npc.scale,
effects,
0f);
}
public static void DrawAfterimage(NPC npc, SpriteBatch spriteBatch, Color startingColor, Color endingColor, Texture2D texture = null,
Func rotationCalculation = null, bool directioning = false, bool invertedDirection = false)
{
if (NPCID.Sets.TrailingMode[npc.type] != 1)
return;
SpriteEffects spriteEffects = SpriteEffects.None;
if (npc.spriteDirection == -1 && directioning)
{
spriteEffects = SpriteEffects.FlipHorizontally;
}
if (invertedDirection)
{
spriteEffects ^= SpriteEffects.FlipHorizontally; // Same as x XOR 1, or x XOR TRUE, which inverts the bit. In this case, this reverses the horizontal flip
}
// Set the rotation calculation to a predefined value. The null default is solely so that
if (rotationCalculation is null)
{
rotationCalculation = (nPC, afterimageIndex) => nPC.rotation;
}
endingColor.A = 0;
Color drawColor = npc.GetAlpha(startingColor);
Texture2D npcTexture = texture ?? Main.npcTexture[npc.type];
Vector2 origin = npc.Size * 0.5f;
int afterimageCounter = 1;
while (afterimageCounter < NPCID.Sets.TrailCacheLength[npc.type] && CalamityConfig.Instance.Afterimages)
{
Color colorToDraw = Color.Lerp(drawColor, endingColor, afterimageCounter / (float)NPCID.Sets.TrailCacheLength[npc.type]);
colorToDraw *= afterimageCounter / (float)NPCID.Sets.TrailCacheLength[npc.type];
spriteBatch.Draw(npcTexture,
npc.oldPos[afterimageCounter] + npc.Size / 2f - Main.screenPosition + Vector2.UnitY * npc.gfxOffY,
npc.frame,
colorToDraw,
rotationCalculation.Invoke(npc, afterimageCounter),
origin,
npc.scale,
spriteEffects,
0f);
afterimageCounter++;
}
}
#endregion
#region Scale Expert Multiplayer Stats
public override void ScaleExpertStats(NPC npc, int numPlayers, float bossLifeScale)
{
// Do absolutely nothing in single player, or in multiplayer with only one player connected.
if (Main.netMode == NetmodeID.SinglePlayer || numPlayers <= 1)
return;
bool countsAsBoss = npc.boss || NPCID.Sets.TechnicallyABoss[npc.type];
bool scalesLikeBoss = countsAsBoss || CalamityLists.bossHPScaleList.Contains(npc.type);
bool isCalamityNPC = npc.modNPC != null && npc.modNPC.mod == CalamityMod.Instance;
// All bosses, NPCs that are supposed to scale like bosses, and Calamity NPCs follow these rules.
if (scalesLikeBoss || isCalamityNPC)
{
double scalar;
switch (numPlayers) // Decrease HP in multiplayer before vanilla scaling
{
case 1:
scalar = 1.0;
break;
case 2:
scalar = 0.82; // 1.64
break;
case 3:
scalar = 0.72; // 2.16
break;
case 4:
scalar = 0.64; // 2.56
break;
case 5:
scalar = 0.57; // 2.85
break;
case 6:
scalar = 0.52; // 3.12
break;
default:
scalar = 0.47; // 3.29 + 0.47 per player beyond 7
break;
}
npc.lifeMax = (int)(npc.lifeMax * scalar);
}
}
#endregion
#region Can Hit Player
public override bool CanHitPlayer(NPC npc, Player target, ref int cooldownSlot)
{
if (!npc.boss && !npc.friendly && !npc.dontTakeDamage)
{
if (CalamityWorld.downedDoG && (Main.pumpkinMoon || Main.snowMoon || Main.eclipse))
{
cooldownSlot = 1;
}
}
if (target.Calamity().prismaticHelmet && !CalamityPlayer.areThereAnyDamnBosses)
{
if (npc.lifeMax < 500)
{
return false;
}
}
return true;
}
#endregion
#region Strike NPC
public override bool StrikeNPC(NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit)
{
// Don't bother tampering with the damage is it is already zero.
// Zero damage does not happen in the base game and is always indicative of antibutcher in Calamity.
if (damage == 0D)
return false;
// Damage reduction on spawn
bool destroyerResist = DestroyerIDs.Contains(npc.type) && (CalamityWorld.revenge || BossRushEvent.BossRushActive);
bool eaterofWorldsResist = EaterofWorldsIDs.Contains(npc.type) && BossRushEvent.BossRushActive;
if (destroyerResist || eaterofWorldsResist || AstrumDeusIDs.Contains(npc.type))
{
if (newAI[1] < 600f || (newAI[2] > 0f && DestroyerIDs.Contains(npc.type)))
{
damage *= 0.01;
}
}
// Large Deus worm takes reduced damage to last a long enough time
if (AstrumDeusIDs.Contains(npc.type) && newAI[0] == 0f)
{
damage *= 0.8;
}
// Override hand/head eye 'death' code and use custom 'death' code instead, this is here just in case the AI code fails
if (CalamityWorld.revenge || BossRushEvent.BossRushActive)
{
if (npc.type == NPCID.MoonLordHand || npc.type == NPCID.MoonLordHead)
{
if (npc.life - (int)damage <= 0)
{
if (newAI[0] != 1f)
{
newAI[0] = 1f;
npc.life = npc.lifeMax;
npc.netUpdate = true;
npc.dontTakeDamage = true;
}
}
}
}
// Yellow Candle provides +5% damage which ignores both DR and defense.
// However, armor penetration bonus damage has already been applied, so it's slightly higher than it should be.
double yellowCandleDamage = 0.05 * damage;
// Apply modifications to enemy's current defense based on Calamity debuffs.
// As with defense and DR, flat reductions apply first, then multiplicative reductions.
int effectiveDefense = npc.defense -
(pFlames > 0 ? Plague.DefenseReduction : 0) -
(wDeath > 0 ? WhisperingDeath.DefenseReduction : 0) -
(gsInferno > 0 ? GodSlayerInferno.DefenseReduction : 0) -
(astralInfection > 0 ? AstralInfectionDebuff.DefenseReduction : 0) -
(aFlames > 0 ? AbyssalFlames.DefenseReduction : 0) -
(wCleave > 0 ? WarCleave.DefenseReduction : 0) -
(gState > 0 ? GlacialState.DefenseReduction : 0) -
(aCrunch > 0 ? ArmorCrunch.DefenseReduction : 0) -
(marked > 0 && DR <= 0f ? MarkedforDeath.DefenseReduction : 0);
// Defense can never be negative and has a minimum value of zero.
if (effectiveDefense < 0)
effectiveDefense = 0;
// Apply vanilla-style defense before DR, using Calamity's reduced defense.
damage = Main.CalculateDamage((int)damage, effectiveDefense);
// DR applies after vanilla defense.
damage = ApplyDR(npc, damage, yellowCandleDamage);
// Cancel out vanilla defense math by reversing the calculation vanilla is about to perform.
// While roundabout, this is safer than returning false to stop vanilla damage calculations entirely.
// Other mods will probably expect the vanilla code to run and may compensate for it themselves.
damage = Main.CalculateDamage((int)damage, -defense);
return true;
}
///
/// Modifies damage incoming to an NPC based on their DR (damage reduction) stat added by Calamity.
/// This is entirely separate from vanilla's takenDamageMultiplier.
///
/// Incoming damage. Has been modified by Main.DamageVar and boosted by armor penetration, but nothing else.
///
private double ApplyDR(NPC npc, double damage, double yellowCandleDamage)
{
if ((DR <= 0f && KillTime == 0) || damage <= 1.0)
return damage;
// If the NPC currently has unbreakable DR, it cannot be reduced by any means.
// If custom DR is enabled, use that instead of normal DR.
float effectiveDR = unbreakableDR ? DR : (customDR ? CustomDRMath(npc, DR) : DefaultDRMath(npc, DR));
// DR floor is 0%. Nothing can have negative DR.
if (effectiveDR <= 0f)
effectiveDR = 0f;
// Add Yellow Candle damage if the NPC isn't supposed to be "near invincible"
if (yellowCandle > 0 && DR < 0.99f && npc.takenDamageMultiplier > 0.05f)
damage += yellowCandleDamage;
// Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac
if (KillTime > 0 && AITimer < KillTime && !BossRushEvent.BossRushActive)
{
float DRScalar = !GetDownedBossVariable(npc.type) || CalamityConfig.Instance.FullPowerReactiveBossDR ? 1.5f : 1f;
/*if (Main.masterMode)
DRScalar = 5f;*/
// Boost Providence timed DR during the night
if (npc.type == NPCType() && !Main.dayTime)
DRScalar = 10f;
// The limit for how much extra DR the boss can have
float extraDRLimit = (1f - DR) * DRScalar;
// Ranges from 1 to 0
float currentHPRatio = npc.life / (float)npc.lifeMax;
// Ranges from 0 to 1
float killTimeRatio = AITimer / (float)KillTime;
// If the player is damaging the boss too quickly
float extraDRScalar = currentHPRatio + killTimeRatio;
if (extraDRScalar < 1f)
{
// Ranges from 0 to (extraDRLimit / 2)
effectiveDR += extraDRLimit - (extraDRLimit / (1f + (1f - extraDRScalar)));
}
}
double newDamage = (1f - effectiveDR) * damage;
return newDamage < 1.0 ? 1.0 : newDamage;
}
private float DefaultDRMath(NPC npc, float DR)
{
float calcDR = DR;
if (marked > 0)
calcDR *= 0.5f;
if (npc.betsysCurse)
calcDR *= 0.66f;
if (wCleave > 0)
calcDR *= 0.75f;
if (npc.Calamity().kamiFlu > 0)
calcDR *= KamiDebuff.MultiplicativeDamageReduction;
if (npc.onFire2)
calcDR *= 0.8f;
return calcDR;
}
private float CustomDRMath(NPC npc, float DR)
{
void FlatEditDR(ref float theDR, bool npcHasDebuff, int buffID)
{
if (npcHasDebuff && flatDRReductions.TryGetValue(buffID, out float reduction))
theDR -= reduction;
}
void MultEditDR(ref float theDR, bool npcHasDebuff, int buffID)
{
if (npcHasDebuff && multDRReductions.TryGetValue(buffID, out float multiplier))
theDR *= multiplier;
}
float calcDR = DR;
// Apply flat reductions first. All vanilla debuffs check their internal booleans.
FlatEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned);
FlatEditDR(ref calcDR, npc.onFire, BuffID.OnFire);
FlatEditDR(ref calcDR, npc.venom, BuffID.Venom);
FlatEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn);
FlatEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame);
FlatEditDR(ref calcDR, npc.daybreak, BuffID.Daybreak);
FlatEditDR(ref calcDR, npc.betsysCurse, BuffID.BetsysCurse);
FlatEditDR(ref calcDR, npc.onFire2, BuffID.CursedInferno);
// Modded debuffs are handled modularly and use HasBuff.
foreach (KeyValuePair entry in flatDRReductions)
{
int buffID = entry.Key;
if (buffID >= BuffID.Count && npc.HasBuff(buffID))
calcDR -= entry.Value;
}
// Apply multiplicative reductions second. All vanilla debuffs check their internal booleans.
MultEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned);
MultEditDR(ref calcDR, npc.onFire, BuffID.OnFire);
MultEditDR(ref calcDR, npc.venom, BuffID.Venom);
MultEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn);
MultEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame);
MultEditDR(ref calcDR, npc.daybreak, BuffID.Daybreak);
MultEditDR(ref calcDR, npc.betsysCurse, BuffID.BetsysCurse);
MultEditDR(ref calcDR, npc.onFire2, BuffID.CursedInferno);
// Modded debuffs are handled modularly and use HasBuff.
foreach (KeyValuePair entry in multDRReductions)
{
int buffID = entry.Key;
if (buffID >= BuffID.Count && npc.HasBuff(buffID))
calcDR *= entry.Value;
}
return calcDR;
}
#endregion
#region Boss Head Slot
public override void BossHeadSlot(NPC npc, ref int index)
{
if (CalamityWorld.revenge)
{
if (npc.type == NPCID.BrainofCthulhu)
{
if (npc.life / (float)npc.lifeMax < (CalamityWorld.death ? 1f : 0.2f))
index = -1;
}
if (npc.type == NPCID.DukeFishron && CalamityWorld.death)
{
if (npc.life / (float)npc.lifeMax < 0.4f)
index = -1;
}
}
}
#endregion
#region Pre AI
public override bool PreAI(NPC npc)
{
CalamityGlobalTownNPC.SetPatreonTownNPCName(npc, mod);
if (CalamityPlayer.areThereAnyDamnBosses)
{
if (npc.velocity.Length() > maxVelocity)
maxVelocity = npc.velocity.Length();
}
if (KillTime > 0 && AITimer < KillTime)
AITimer++;
if (npc.type == NPCID.TargetDummy || npc.type == NPCType())
{
npc.chaseable = !CalamityPlayer.areThereAnyDamnBosses;
npc.dontTakeDamage = CalamityPlayer.areThereAnyDamnBosses;
}
// Setting this in SetDefaults will disable expert mode scaling, so put it here instead
if (ZeroContactDamageNPCList.Contains(npc.type))
npc.damage = npc.defDamage = 0;
if (DestroyerIDs.Contains(npc.type) || EaterofWorldsIDs.Contains(npc.type))
npc.buffImmune[BuffType()] = false;
if (npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.Hornet || npc.type == NPCID.HornetFatty || npc.type == NPCID.HornetHoney ||
npc.type == NPCID.HornetLeafy || npc.type == NPCID.HornetSpikey || npc.type == NPCID.HornetStingy || npc.type == NPCID.BigHornetStingy || npc.type == NPCID.LittleHornetStingy ||
npc.type == NPCID.BigHornetSpikey || npc.type == NPCID.LittleHornetSpikey || npc.type == NPCID.BigHornetLeafy || npc.type == NPCID.LittleHornetLeafy ||
npc.type == NPCID.BigHornetHoney || npc.type == NPCID.LittleHornetHoney || npc.type == NPCID.BigHornetFatty || npc.type == NPCID.LittleHornetFatty)
{
if (Main.player[npc.target].Calamity().queenBeeLore)
{
CalamityGlobalAI.QueenBeeLoreEffect(npc);
return false;
}
}
if (BossRushEvent.BossRushActive && !npc.friendly && !npc.townNPC)
BossRushForceDespawnOtherNPCs(npc, mod);
if (CalamityWorld.revenge || BossRushEvent.BossRushActive)
{
switch (npc.type)
{
case NPCID.KingSlime:
return CalamityGlobalAI.BuffedKingSlimeAI(npc, mod);
case NPCID.EyeofCthulhu:
return CalamityGlobalAI.BuffedEyeofCthulhuAI(npc, enraged > 0, mod);
case NPCID.EaterofWorldsHead:
case NPCID.EaterofWorldsBody:
case NPCID.EaterofWorldsTail:
return CalamityGlobalAI.BuffedEaterofWorldsAI(npc, mod);
case NPCID.BrainofCthulhu:
return CalamityGlobalAI.BuffedBrainofCthulhuAI(npc, enraged > 0, mod);
case NPCID.Creeper:
return CalamityGlobalAI.BuffedCreeperAI(npc, enraged > 0, mod);
case NPCID.QueenBee:
return CalamityGlobalAI.BuffedQueenBeeAI(npc, mod);
case NPCID.SkeletronHand:
return CalamityGlobalAI.BuffedSkeletronHandAI(npc, enraged > 0, mod);
case NPCID.SkeletronHead:
return CalamityGlobalAI.BuffedSkeletronAI(npc, enraged > 0, mod);
case NPCID.WallofFlesh:
return CalamityGlobalAI.BuffedWallofFleshAI(npc, enraged > 0, mod);
case NPCID.WallofFleshEye:
return CalamityGlobalAI.BuffedWallofFleshEyeAI(npc, enraged > 0, mod);
case NPCID.TheDestroyer:
case NPCID.TheDestroyerBody:
case NPCID.TheDestroyerTail:
return CalamityGlobalAI.BuffedDestroyerAI(npc, enraged > 0, mod);
case NPCID.Probe:
return CalamityGlobalAI.BuffedProbeAI(npc, mod);
case NPCID.Retinazer:
return CalamityGlobalAI.BuffedRetinazerAI(npc, enraged > 0, mod);
case NPCID.Spazmatism:
return CalamityGlobalAI.BuffedSpazmatismAI(npc, enraged > 0, mod);
case NPCID.SkeletronPrime:
return CalamityGlobalAI.BuffedSkeletronPrimeAI(npc, enraged > 0, mod);
case NPCID.PrimeLaser:
return CalamityGlobalAI.BuffedPrimeLaserAI(npc, mod);
case NPCID.PrimeCannon:
return CalamityGlobalAI.BuffedPrimeCannonAI(npc, mod);
case NPCID.PrimeVice:
return CalamityGlobalAI.BuffedPrimeViceAI(npc, mod);
case NPCID.PrimeSaw:
return CalamityGlobalAI.BuffedPrimeSawAI(npc, mod);
case NPCID.Plantera:
return CalamityGlobalAI.BuffedPlanteraAI(npc, enraged > 0, mod);
case NPCID.PlanterasHook:
return CalamityGlobalAI.BuffedPlanterasHookAI(npc, mod);
case NPCID.PlanterasTentacle:
return CalamityGlobalAI.BuffedPlanterasTentacleAI(npc, mod);
case NPCID.Golem:
return CalamityGlobalAI.BuffedGolemAI(npc, enraged > 0, mod);
case NPCID.GolemHead:
return CalamityGlobalAI.BuffedGolemHeadAI(npc, enraged > 0, mod);
case NPCID.GolemHeadFree:
return CalamityGlobalAI.BuffedGolemHeadFreeAI(npc, enraged > 0, mod);
case NPCID.DukeFishron:
return CalamityGlobalAI.BuffedDukeFishronAI(npc, enraged > 0, mod);
case NPCID.Pumpking:
if (CalamityWorld.downedDoG)
{
return CalamityGlobalAI.BuffedPumpkingAI(npc);
}
break;
case NPCID.PumpkingBlade:
if (CalamityWorld.downedDoG)
{
return CalamityGlobalAI.BuffedPumpkingBladeAI(npc);
}
break;
case NPCID.IceQueen:
if (CalamityWorld.downedDoG)
{
return CalamityGlobalAI.BuffedIceQueenAI(npc);
}
break;
case NPCID.Mothron:
if (CalamityWorld.downedDoG)
{
return CalamityGlobalAI.BuffedMothronAI(npc);
}
break;
case NPCID.CultistBoss:
case NPCID.CultistBossClone:
return CalamityGlobalAI.BuffedCultistAI(npc, enraged > 0, mod);
case NPCID.AncientLight:
return CalamityGlobalAI.BuffedAncientLightAI(npc, mod);
case NPCID.AncientDoom:
return CalamityGlobalAI.BuffedAncientDoomAI(npc, mod);
case NPCID.MoonLordCore:
case NPCID.MoonLordHand:
case NPCID.MoonLordHead:
case NPCID.MoonLordFreeEye:
case NPCID.MoonLordLeechBlob:
return CalamityGlobalAI.BuffedMoonLordAI(npc, enraged > 0, mod);
default:
break;
}
}
else if (npc.type == NPCID.Retinazer)
{
return CalamityGlobalAI.TrueMeleeRetinazerPhase2AI(npc);
}
if (CalamityWorld.death)
{
switch (npc.aiStyle)
{
case 1:
if (npc.type == NPCType() || npc.type == NPCType() ||
npc.type == NPCType() || npc.type == NPCType() ||
npc.type == NPCType() || npc.type == NPCType() ||
npc.type == NPCType() || npc.type == NPCType() ||
npc.type == NPCType())
{
return CalamityGlobalAI.BuffedSlimeAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.BlueSlime:
case NPCID.MotherSlime:
case NPCID.LavaSlime:
case NPCID.DungeonSlime:
case NPCID.CorruptSlime:
case NPCID.IlluminantSlime:
case NPCID.ToxicSludge:
case NPCID.IceSlime:
case NPCID.Crimslime:
case NPCID.SpikedIceSlime:
case NPCID.SpikedJungleSlime:
case NPCID.UmbrellaSlime:
case NPCID.RainbowSlime:
case NPCID.SlimeMasked:
case NPCID.HoppinJack:
case NPCID.SlimeRibbonWhite:
case NPCID.SlimeRibbonYellow:
case NPCID.SlimeRibbonGreen:
case NPCID.SlimeRibbonRed:
case NPCID.SlimeSpiked:
case NPCID.SandSlime:
return CalamityGlobalAI.BuffedSlimeAI(npc, mod);
}
}
break;
case 2:
if (npc.type == NPCType() || npc.type == NPCType())
{
return CalamityGlobalAI.BuffedDemonEyeAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.DemonEye:
case NPCID.TheHungryII:
case NPCID.WanderingEye:
case NPCID.PigronCorruption:
case NPCID.PigronHallow:
case NPCID.PigronCrimson:
case NPCID.CataractEye:
case NPCID.SleepyEye:
case NPCID.DialatedEye:
case NPCID.GreenEye:
case NPCID.PurpleEye:
case NPCID.DemonEyeOwl:
case NPCID.DemonEyeSpaceship:
return CalamityGlobalAI.BuffedDemonEyeAI(npc, mod);
}
}
break;
case 3:
if (npc.type == NPCType() ||
npc.type == NPCType() || npc.type == NPCType())
{
return CalamityGlobalAI.BuffedFighterAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.Zombie:
case NPCID.ArmedZombie:
case NPCID.ArmedZombieEskimo:
case NPCID.ArmedZombiePincussion:
case NPCID.ArmedZombieSlimed:
case NPCID.ArmedZombieSwamp:
case NPCID.ArmedZombieTwiggy:
case NPCID.ArmedZombieCenx:
case NPCID.Skeleton:
case NPCID.AngryBones:
case NPCID.UndeadMiner:
case NPCID.CorruptBunny:
case NPCID.DoctorBones:
case NPCID.TheGroom:
case NPCID.Crab:
case NPCID.GoblinScout:
case NPCID.ArmoredSkeleton:
case NPCID.Mummy:
case NPCID.DarkMummy:
case NPCID.LightMummy:
case NPCID.Werewolf:
case NPCID.Clown:
case NPCID.SkeletonArcher:
case NPCID.ChaosElemental:
case NPCID.BaldZombie:
case NPCID.PossessedArmor:
case NPCID.ZombieEskimo:
case NPCID.BlackRecluse:
case NPCID.WallCreeper:
case NPCID.UndeadViking:
case NPCID.CorruptPenguin:
case NPCID.FaceMonster:
case NPCID.SnowFlinx:
case NPCID.PincushionZombie:
case NPCID.SlimedZombie:
case NPCID.SwampZombie:
case NPCID.TwiggyZombie:
case NPCID.Nymph:
case NPCID.ArmoredViking:
case NPCID.Lihzahrd:
case NPCID.LihzahrdCrawler:
case NPCID.FemaleZombie:
case NPCID.HeadacheSkeleton:
case NPCID.MisassembledSkeleton:
case NPCID.PantlessSkeleton:
case NPCID.IcyMerman:
case NPCID.PirateDeckhand:
case NPCID.PirateCorsair:
case NPCID.PirateDeadeye:
case NPCID.PirateCrossbower:
case NPCID.PirateCaptain:
case NPCID.CochinealBeetle:
case NPCID.CyanBeetle:
case NPCID.LacBeetle:
case NPCID.SeaSnail:
case NPCID.ZombieRaincoat:
case NPCID.JungleCreeper:
case NPCID.BloodCrawler:
case NPCID.IceGolem:
case NPCID.Eyezor:
case NPCID.ZombieMushroom:
case NPCID.ZombieMushroomHat:
case NPCID.AnomuraFungus:
case NPCID.MushiLadybug:
case NPCID.RustyArmoredBonesAxe:
case NPCID.RustyArmoredBonesFlail:
case NPCID.RustyArmoredBonesSword:
case NPCID.RustyArmoredBonesSwordNoArmor:
case NPCID.BlueArmoredBones:
case NPCID.BlueArmoredBonesMace:
case NPCID.BlueArmoredBonesNoPants:
case NPCID.BlueArmoredBonesSword:
case NPCID.HellArmoredBones:
case NPCID.HellArmoredBonesSpikeShield:
case NPCID.HellArmoredBonesMace:
case NPCID.HellArmoredBonesSword:
case NPCID.BoneLee:
case NPCID.Paladin:
case NPCID.SkeletonSniper:
case NPCID.TacticalSkeleton:
case NPCID.SkeletonCommando:
case NPCID.AngryBonesBig:
case NPCID.AngryBonesBigMuscle:
case NPCID.AngryBonesBigHelmet:
case NPCID.Scarecrow1:
case NPCID.Scarecrow2:
case NPCID.Scarecrow3:
case NPCID.Scarecrow4:
case NPCID.Scarecrow5:
case NPCID.Scarecrow6:
case NPCID.Scarecrow7:
case NPCID.Scarecrow8:
case NPCID.Scarecrow9:
case NPCID.Scarecrow10:
case NPCID.ZombieDoctor:
case NPCID.ZombieSuperman:
case NPCID.ZombiePixie:
case NPCID.SkeletonTopHat:
case NPCID.SkeletonAstonaut:
case NPCID.SkeletonAlien:
case NPCID.Splinterling:
case NPCID.ZombieXmas:
case NPCID.ZombieSweater:
case NPCID.ZombieElf:
case NPCID.ZombieElfBeard:
case NPCID.ZombieElfGirl:
case NPCID.GingerbreadMan:
case NPCID.Yeti:
case NPCID.Nutcracker:
case NPCID.NutcrackerSpinning:
case NPCID.ElfArcher:
case NPCID.Krampus:
case NPCID.CultistArcherBlue:
case NPCID.CultistArcherWhite:
case NPCID.BrainScrambler:
case NPCID.RayGunner:
case NPCID.MartianOfficer:
case NPCID.GrayGrunt:
case NPCID.MartianEngineer:
case NPCID.GigaZapper:
case NPCID.Scutlix:
case NPCID.BoneThrowingSkeleton:
case NPCID.BoneThrowingSkeleton2:
case NPCID.BoneThrowingSkeleton3:
case NPCID.BoneThrowingSkeleton4:
case NPCID.CrimsonBunny:
case NPCID.CrimsonPenguin:
case NPCID.Medusa:
case NPCID.GreekSkeleton:
case NPCID.GraniteGolem:
case NPCID.BloodZombie:
case NPCID.Crawdad:
case NPCID.Crawdad2:
case NPCID.Salamander:
case NPCID.Salamander2:
case NPCID.Salamander3:
case NPCID.Salamander4:
case NPCID.Salamander5:
case NPCID.Salamander6:
case NPCID.Salamander7:
case NPCID.Salamander8:
case NPCID.Salamander9:
case NPCID.WalkingAntlion:
case NPCID.DesertGhoul:
case NPCID.DesertGhoulCorruption:
case NPCID.DesertGhoulCrimson:
case NPCID.DesertGhoulHallow:
case NPCID.DesertLamiaLight:
case NPCID.DesertLamiaDark:
case NPCID.DesertScorpionWalk:
case NPCID.DesertBeast:
case NPCID.StardustSoldier:
case NPCID.StardustSpiderBig:
case NPCID.NebulaSoldier:
case NPCID.VortexRifleman:
case NPCID.VortexSoldier:
case NPCID.VortexLarva:
case NPCID.VortexHornet:
case NPCID.VortexHornetQueen:
case NPCID.SolarDrakomire:
case NPCID.SolarSpearman:
case NPCID.SolarSolenian:
case NPCID.Frankenstein:
case NPCID.SwampThing:
case NPCID.Vampire:
case NPCID.Butcher:
case NPCID.CreatureFromTheDeep:
case NPCID.Fritz:
case NPCID.Nailhead:
case NPCID.Psycho:
case NPCID.ThePossessed:
case NPCID.DrManFly:
case NPCID.GoblinPeon:
case NPCID.GoblinThief:
case NPCID.GoblinWarrior:
case NPCID.GoblinArcher:
case NPCID.GoblinSummoner:
case NPCID.MartianWalker:
case NPCID.DemonTaxCollector:
case NPCID.TheBride:
return CalamityGlobalAI.BuffedFighterAI(npc, mod);
}
}
break;
case 5:
switch (npc.type)
{
case NPCID.ServantofCthulhu:
case NPCID.EaterofSouls:
case NPCID.MeteorHead:
case NPCID.Corruptor:
case NPCID.Crimera:
case NPCID.Moth:
case NPCID.Parrot:
return CalamityGlobalAI.BuffedFlyingAI(npc, mod);
}
break;
case 6:
switch (npc.type)
{
case NPCID.DevourerHead:
case NPCID.DevourerBody:
case NPCID.DevourerTail:
case NPCID.GiantWormHead:
case NPCID.GiantWormBody:
case NPCID.GiantWormTail:
case NPCID.BoneSerpentHead:
case NPCID.BoneSerpentBody:
case NPCID.BoneSerpentTail:
case NPCID.WyvernHead:
case NPCID.WyvernLegs:
case NPCID.WyvernBody:
case NPCID.WyvernBody2:
case NPCID.WyvernBody3:
case NPCID.WyvernTail:
case NPCID.DiggerHead:
case NPCID.DiggerBody:
case NPCID.DiggerTail:
case NPCID.SeekerHead:
case NPCID.SeekerBody:
case NPCID.SeekerTail:
case NPCID.LeechHead:
case NPCID.LeechBody:
case NPCID.LeechTail:
case NPCID.TombCrawlerHead:
case NPCID.TombCrawlerBody:
case NPCID.TombCrawlerTail:
case NPCID.DuneSplicerHead:
case NPCID.DuneSplicerBody:
case NPCID.DuneSplicerTail:
case NPCID.StardustWormHead:
case NPCID.SolarCrawltipedeHead:
case NPCID.SolarCrawltipedeBody:
case NPCID.SolarCrawltipedeTail:
return CalamityGlobalAI.BuffedWormAI(npc, mod);
}
break;
case 8:
switch (npc.type)
{
case NPCID.FireImp:
case NPCID.DarkCaster:
case NPCID.Tim:
case NPCID.RuneWizard:
case NPCID.RaggedCaster:
case NPCID.RaggedCasterOpenCoat:
case NPCID.Necromancer:
case NPCID.NecromancerArmored:
case NPCID.DiabolistRed:
case NPCID.DiabolistWhite:
case NPCID.DesertDjinn:
case NPCID.GoblinSorcerer:
return CalamityGlobalAI.BuffedCasterAI(npc, mod);
}
break;
case 13:
switch (npc.type)
{
case NPCID.ManEater:
case NPCID.Snatcher:
case NPCID.Clinger:
case NPCID.AngryTrapper:
case NPCID.FungiBulb:
case NPCID.GiantFungiBulb:
return CalamityGlobalAI.BuffedPlantAI(npc, mod);
}
break;
case 14:
if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType())
{
return CalamityGlobalAI.BuffedBatAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.Harpy:
case NPCID.CaveBat:
case NPCID.JungleBat:
case NPCID.Hellbat:
case NPCID.Demon:
case NPCID.VoodooDemon:
case NPCID.GiantBat:
case NPCID.Slimer:
case NPCID.IlluminantBat:
case NPCID.IceBat:
case NPCID.Lavabat:
case NPCID.GiantFlyingFox:
case NPCID.RedDevil:
case NPCID.FlyingSnake:
case NPCID.VampireBat:
return CalamityGlobalAI.BuffedBatAI(npc, mod);
}
}
break;
case 16:
switch (npc.type)
{
case NPCID.CorruptGoldfish:
case NPCID.Piranha:
case NPCID.Shark:
case NPCID.AnglerFish:
case NPCID.Arapaima:
case NPCID.BloodFeeder:
case NPCID.CrimsonGoldfish:
return CalamityGlobalAI.BuffedSwimmingAI(npc, mod);
}
break;
case 18:
switch (npc.type)
{
case NPCID.BlueJellyfish:
case NPCID.PinkJellyfish:
case NPCID.GreenJellyfish:
case NPCID.Squid:
case NPCID.BloodJelly:
case NPCID.FungoFish:
return CalamityGlobalAI.BuffedJellyfishAI(npc, mod);
}
break;
case 19:
switch (npc.type)
{
case NPCID.Antlion:
return CalamityGlobalAI.BuffedAntlionAI(npc, mod);
}
break;
case 20:
switch (npc.type)
{
case NPCID.SpikeBall:
return CalamityGlobalAI.BuffedSpikeBallAI(npc, mod);
}
break;
case 21:
switch (npc.type)
{
case NPCID.BlazingWheel:
return CalamityGlobalAI.BuffedBlazingWheelAI(npc, mod);
}
break;
case 22:
switch (npc.type)
{
case NPCID.Pixie:
case NPCID.Wraith:
case NPCID.Gastropod:
case NPCID.IceElemental:
case NPCID.FloatyGross:
case NPCID.IchorSticker:
case NPCID.Ghost:
case NPCID.Poltergeist:
case NPCID.Drippler:
case NPCID.Reaper:
return CalamityGlobalAI.BuffedHoveringAI(npc, mod);
}
break;
case 23:
switch (npc.type)
{
case NPCID.CursedHammer:
case NPCID.EnchantedSword:
case NPCID.CrimsonAxe:
return CalamityGlobalAI.BuffedFlyingWeaponAI(npc, mod);
}
break;
case 25:
switch (npc.type)
{
case NPCID.Mimic:
case NPCID.PresentMimic:
return CalamityGlobalAI.BuffedMimicAI(npc, mod);
}
break;
case 26:
if (npc.type == NPCType())
{
return CalamityGlobalAI.BuffedUnicornAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.Unicorn:
case NPCID.Wolf:
case NPCID.HeadlessHorseman:
case NPCID.Hellhound:
case NPCID.StardustSpiderSmall:
case NPCID.NebulaBeast:
case NPCID.Tumbleweed:
return CalamityGlobalAI.BuffedUnicornAI(npc, mod);
}
}
break;
case 39:
if (npc.type == NPCType() || npc.type == NPCType())
{
return CalamityGlobalAI.BuffedTortoiseAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.GiantTortoise:
case NPCID.IceTortoise:
case NPCID.GiantShelly:
case NPCID.GiantShelly2:
case NPCID.SolarSroller:
return CalamityGlobalAI.BuffedTortoiseAI(npc, mod);
}
}
break;
case 40:
switch (npc.type)
{
case NPCID.BlackRecluseWall:
case NPCID.WallCreeperWall:
case NPCID.JungleCreeperWall:
case NPCID.BloodCrawlerWall:
case NPCID.DesertScorpionWall:
return CalamityGlobalAI.BuffedSpiderAI(npc, mod);
}
break;
case 41:
if (npc.type == NPCType())
{
return CalamityGlobalAI.BuffedHerplingAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.Herpling:
case NPCID.Derpling:
return CalamityGlobalAI.BuffedHerplingAI(npc, mod);
}
}
break;
case 44:
switch (npc.type)
{
case NPCID.FlyingFish:
case NPCID.FlyingAntlion:
return CalamityGlobalAI.BuffedFlyingFishAI(npc, mod);
}
break;
case 49:
switch (npc.type)
{
case NPCID.AngryNimbus:
return CalamityGlobalAI.BuffedAngryNimbusAI(npc, mod);
}
break;
case 50:
switch (npc.type)
{
case NPCID.FungiSpore:
case NPCID.Spore:
return CalamityGlobalAI.BuffedSporeAI(npc, mod);
}
break;
case 73:
switch (npc.type)
{
case NPCID.MartianTurret:
return CalamityGlobalAI.BuffedTeslaTurretAI(npc, mod);
}
break;
case 74:
switch (npc.type)
{
case NPCID.MartianDrone:
case NPCID.SolarCorite:
return CalamityGlobalAI.BuffedCoriteAI(npc, mod);
}
break;
case 80:
switch (npc.type)
{
case NPCID.MartianProbe:
return CalamityGlobalAI.BuffedMartianProbeAI(npc, mod);
}
break;
case 89:
switch (npc.type)
{
case NPCID.MothronEgg:
return CalamityGlobalAI.BuffedMothronEggAI(npc, mod);
}
break;
case 91:
if (npc.type == NPCType())
{
return CalamityGlobalAI.BuffedGraniteElementalAI(npc, mod);
}
else
{
switch (npc.type)
{
case NPCID.GraniteFlyer:
return CalamityGlobalAI.BuffedGraniteElementalAI(npc, mod);
}
}
break;
default:
break;
}
}
else if (Main.expertMode)
{
if (npc.type == NPCID.FungiSpore || npc.type == NPCID.Spore)
return CalamityGlobalAI.BuffedSporeAI(npc, mod);
}
return true;
}
#endregion
#region Boss Rush Force Despawn Other NPCs
private void BossRushForceDespawnOtherNPCs(NPC npc, Mod mod)
{
switch (BossRushEvent.BossRushStage)
{
case 0:
if (npc.type != NPCID.QueenBee)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 1:
if (npc.type != NPCID.BrainofCthulhu && npc.type != NPCID.Creeper)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 2:
if (npc.type != NPCID.KingSlime && npc.type != NPCID.BlueSlime && npc.type != NPCID.SlimeSpiked && npc.type != NPCType() &&
npc.type != NPCID.YellowSlime && npc.type != NPCID.PurpleSlime && npc.type != NPCID.GreenSlime && npc.type != NPCID.RedSlime &&
npc.type != NPCID.IceSlime && npc.type != NPCID.UmbrellaSlime && npc.type != NPCID.RainbowSlime && npc.type != NPCID.Pinky)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 3:
if (npc.type != NPCID.EyeofCthulhu && npc.type != NPCID.ServantofCthulhu)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 4:
if (npc.type != NPCID.SkeletronPrime && npc.type != NPCID.PrimeSaw && npc.type != NPCID.PrimeVice &&
npc.type != NPCID.PrimeCannon && npc.type != NPCID.PrimeLaser && npc.type != NPCID.Probe)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 5:
if (npc.type != NPCID.Golem && npc.type != NPCID.GolemFistLeft && npc.type != NPCID.GolemFistRight &&
npc.type != NPCID.GolemHead && npc.type != NPCID.GolemHeadFree)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 6:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 7:
if (!EaterofWorldsIDs.Contains(npc.type) && npc.type != NPCID.VileSpit)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 8:
if (npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 9:
if (!DestroyerIDs.Contains(npc.type) && npc.type != NPCID.Probe)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 10:
if (npc.type != NPCID.Spazmatism && npc.type != NPCID.Retinazer)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 11:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCID.Spazmatism && npc.type != NPCID.Retinazer)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 12:
if (npc.type != NPCID.WallofFlesh && npc.type != NPCID.WallofFleshEye && npc.type != NPCID.TheHungry &&
npc.type != NPCID.TheHungryII && npc.type != NPCID.LeechHead && npc.type != NPCID.LeechBody &&
npc.type != NPCID.LeechTail)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 13:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 14:
if (npc.type != NPCID.SkeletronHead && npc.type != NPCID.SkeletronHand)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 15:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 16:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 17:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 18:
if (npc.type != NPCID.CultistBoss && npc.type != NPCID.CultistBossClone && npc.type != NPCID.CultistDragonHead &&
npc.type != NPCID.CultistDragonBody1 && npc.type != NPCID.CultistDragonBody2 && npc.type != NPCID.CultistDragonBody3 &&
npc.type != NPCID.CultistDragonBody4 && npc.type != NPCID.CultistDragonTail && npc.type != NPCID.AncientCultistSquidhead &&
npc.type != NPCID.AncientLight && npc.type != NPCID.AncientDoom)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 19:
if (npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 20:
if (npc.type != NPCID.Plantera && npc.type != NPCID.PlanterasTentacle && npc.type != NPCID.PlanterasHook &&
npc.type != NPCID.Spore)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 21:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 22:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 23:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 24:
if (npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 25:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 26:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 27:
if (npc.type != NPCID.DukeFishron && npc.type != NPCID.DetonatingBubble && npc.type != NPCID.Sharkron &&
npc.type != NPCID.Sharkron2)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 28:
if (npc.type != NPCID.MoonLordCore && npc.type != NPCID.MoonLordHead && npc.type != NPCID.MoonLordHand &&
npc.type != NPCID.MoonLordLeechBlob && npc.type != NPCID.MoonLordFreeEye)
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 29:
if (!AstrumDeusIDs.Contains(npc.type))
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 30:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 31:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType())
{
npc.active = false;
npc.netUpdate = true;
}
break;
case 32:
if (npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType() && npc.type != NPCType() &&
npc.type != NPCType