338 lines
15 KiB
C#
338 lines
15 KiB
C#
using System.IO;
|
|
using CalamityMod.Dusts;
|
|
using CalamityMod.Events;
|
|
using CalamityMod.Items.Accessories;
|
|
using CalamityMod.Items.Armor.Vanity;
|
|
using CalamityMod.Items.LoreItems;
|
|
using CalamityMod.Items.Materials;
|
|
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.Melee;
|
|
using CalamityMod.Items.Weapons.Summon;
|
|
using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs;
|
|
using CalamityMod.Sounds;
|
|
using CalamityMod.UI.VanillaBossBars;
|
|
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.CeaselessVoid
|
|
{
|
|
[AutoloadBossHead]
|
|
public class CeaselessVoid : ModNPC
|
|
{
|
|
public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/CeaselessVoidDeath");
|
|
public static readonly SoundStyle BuildupSound = new("CalamityMod/Sounds/Custom/CeaselessVoidDeathBuild");
|
|
|
|
public static Asset<Texture2D> GlowTexture;
|
|
|
|
public bool playedbuildsound = false;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.npcFrameCount[NPC.type] = 6;
|
|
NPCID.Sets.TrailingMode[NPC.type] = 1;
|
|
NPCID.Sets.BossBestiaryPriority.Add(Type);
|
|
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers()
|
|
{
|
|
Scale = 0.55f,
|
|
};
|
|
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
|
|
NPCID.Sets.MPAllowedEnemies[Type] = true;
|
|
if (!Main.dedServ)
|
|
{
|
|
GlowTexture = ModContent.Request<Texture2D>(Texture + "Glow", AssetRequestMode.AsyncLoad);
|
|
}
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
NPC.Calamity().canBreakPlayerDefense = true;
|
|
NPC.GetNPCDamage();
|
|
NPC.npcSlots = 36f;
|
|
NPC.width = 100;
|
|
NPC.height = 100;
|
|
NPC.defense = 80;
|
|
CalamityGlobalNPC global = NPC.Calamity();
|
|
global.DR = 0.5f;
|
|
NPC.LifeMaxNERB(65000, 78000, 72000);
|
|
NPC.value = Item.buyPrice(2, 0, 0, 0);
|
|
NPC.aiStyle = -1;
|
|
AIType = -1;
|
|
NPC.knockBackResist = 0f;
|
|
NPC.noGravity = true;
|
|
NPC.noTileCollide = true;
|
|
NPC.boss = true;
|
|
NPC.BossBar = ModContent.GetInstance<CeaselessVoidBossBar>();
|
|
NPC.DeathSound = DeathSound;
|
|
NPC.Calamity().VulnerableToSickness = 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.TheDungeon,
|
|
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.CeaselessVoid")
|
|
});
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(NPC.dontTakeDamage);
|
|
writer.Write(playedbuildsound);
|
|
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.dontTakeDamage = reader.ReadBoolean();
|
|
playedbuildsound = reader.ReadBoolean();
|
|
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 FindFrame(int frameHeight)
|
|
{
|
|
NPC.frameCounter += 0.15f;
|
|
NPC.frameCounter %= Main.npcFrameCount[NPC.type];
|
|
int frame = (int)NPC.frameCounter;
|
|
NPC.frame.Y = frame * frameHeight;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
CeaselessVoidAI.VanillaCeaselessVoidAI(NPC, Mod);
|
|
}
|
|
|
|
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
|
|
{
|
|
Rectangle targetHitbox = target.Hitbox;
|
|
|
|
float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft());
|
|
float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight());
|
|
float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft());
|
|
float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight());
|
|
|
|
float minDist = hitboxTopLeft;
|
|
if (hitboxTopRight < minDist)
|
|
minDist = hitboxTopRight;
|
|
if (hitboxBotLeft < minDist)
|
|
minDist = hitboxBotLeft;
|
|
if (hitboxBotRight < minDist)
|
|
minDist = hitboxBotRight;
|
|
|
|
return minDist <= 50f;
|
|
}
|
|
|
|
public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
|
|
{
|
|
if (hurtInfo.Damage > 0)
|
|
target.AddBuff(BuffID.VortexDebuff, 60, true);
|
|
}
|
|
|
|
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[NPC.type].Value;
|
|
Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2));
|
|
int afterimageAmt = 7;
|
|
|
|
if (CalamityClientConfig.Instance.Afterimages)
|
|
{
|
|
for (int i = 1; i < afterimageAmt; i += 2)
|
|
{
|
|
Color afterimageColor = drawColor;
|
|
afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f);
|
|
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[NPC.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((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.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);
|
|
|
|
texture2D15 = GlowTexture.Value;
|
|
Color cyanLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f);
|
|
|
|
if (CalamityClientConfig.Instance.Afterimages)
|
|
{
|
|
for (int j = 1; j < afterimageAmt; j++)
|
|
{
|
|
Color extraAfterimageColor = cyanLerp;
|
|
extraAfterimageColor = Color.Lerp(extraAfterimageColor, Color.White, 0.5f);
|
|
extraAfterimageColor *= (float)(afterimageAmt - j) / 15f;
|
|
Vector2 extraAfterimageDrawPos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos;
|
|
extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.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);
|
|
}
|
|
}
|
|
|
|
spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, cyanLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
|
|
|
|
return false;
|
|
}
|
|
|
|
public override void OnKill()
|
|
{
|
|
// Don't bother running any of this in Boss Rush.
|
|
if (BossRushEvent.BossRushActive)
|
|
return;
|
|
|
|
CalamityGlobalNPC.SetNewBossJustDowned(NPC);
|
|
DownedBossSystem.downedCeaselessVoid = true;
|
|
CalamityNetcode.SyncWorld();
|
|
}
|
|
|
|
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
|
{
|
|
npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType<CeaselessVoidBag>()));
|
|
|
|
// Normal drops: Everything that would otherwise be in the bag
|
|
LeadingConditionRule normalOnly = new LeadingConditionRule(new Conditions.NotExpert());
|
|
npcLoot.Add(normalOnly);
|
|
{
|
|
// Weapons
|
|
int[] weapons = new int[]
|
|
{
|
|
ModContent.ItemType<MirrorBlade>(),
|
|
ModContent.ItemType<VoidConcentrationStaff>(),
|
|
};
|
|
normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons));
|
|
|
|
// Materials
|
|
normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType<DarkPlasma>(), 1, 5, 7));
|
|
|
|
// Equipment
|
|
normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType<TheEvolution>()));
|
|
|
|
// Vanity
|
|
normalOnly.Add(ModContent.ItemType<CeaselessVoidMask>(), 7);
|
|
var godSlayerVanity = ItemDropRule.Common(ModContent.ItemType<AncientGodSlayerHelm>(), 20);
|
|
godSlayerVanity.OnSuccess(ItemDropRule.Common(ModContent.ItemType<AncientGodSlayerChestplate>()));
|
|
godSlayerVanity.OnSuccess(ItemDropRule.Common(ModContent.ItemType<AncientGodSlayerLeggings>()));
|
|
normalOnly.Add(godSlayerVanity);
|
|
normalOnly.Add(ModContent.ItemType<ThankYouPainting>(), ThankYouPainting.DropInt);
|
|
}
|
|
|
|
npcLoot.Add(ModContent.ItemType<CeaselessVoidTrophy>(), 10);
|
|
|
|
// Relic
|
|
npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType<CeaselessVoidRelic>());
|
|
|
|
// GFB Eclipse Mirror and Nucleogenesis drop
|
|
var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB);
|
|
{
|
|
GFBOnly.Add(ModContent.ItemType<EclipseMirror>(), hideLootReport: true);
|
|
GFBOnly.Add(ModContent.ItemType<Nucleogenesis>(), hideLootReport: true);
|
|
}
|
|
|
|
// Lore
|
|
npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCeaselessVoid, ModContent.ItemType<LoreCeaselessVoid>(), desc: DropHelper.FirstKillText);
|
|
}
|
|
|
|
public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment)
|
|
{
|
|
NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment);
|
|
}
|
|
|
|
public override void BossLoot(ref string name, ref int potionType)
|
|
{
|
|
potionType = ModContent.ItemType<SupremeHealingPotion>();
|
|
}
|
|
|
|
public override void HitEffect(NPC.HitInfo hit)
|
|
{
|
|
if (NPC.soundDelay == 0 && NPC.life >= NPC.lifeMax * 0.05f)
|
|
{
|
|
NPC.soundDelay = 8;
|
|
float pitchVar = 0;
|
|
if (Main.zenithWorld)
|
|
{
|
|
pitchVar = Main.rand.Next(-60, 41) * 0.01f;
|
|
}
|
|
SoundEngine.PlaySound(CommonCalamitySounds.OtherwordlyHitSound with { Pitch = CommonCalamitySounds.OtherwordlyHitSound.Pitch + pitchVar }, NPC.Center);
|
|
}
|
|
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, hit.HitDirection, -1f, 0, default, 1f);
|
|
Main.dust[dust].noGravity = true;
|
|
}
|
|
|
|
if (NPC.life <= 0)
|
|
{
|
|
NPC.position.X = NPC.position.X + (float)(NPC.width / 2);
|
|
NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2);
|
|
NPC.width = 100;
|
|
NPC.height = 100;
|
|
NPC.position.X = NPC.position.X - (float)(NPC.width / 2);
|
|
NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2);
|
|
for (int i = 0; i < 40; i++)
|
|
{
|
|
int purpleDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f);
|
|
Main.dust[purpleDust].velocity *= 3f;
|
|
Main.dust[purpleDust].noGravity = true;
|
|
if (Main.rand.NextBool())
|
|
{
|
|
Main.dust[purpleDust].scale = 0.5f;
|
|
Main.dust[purpleDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
|
|
}
|
|
}
|
|
for (int j = 0; j < 70; j++)
|
|
{
|
|
int purpleDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f);
|
|
Main.dust[purpleDust2].noGravity = true;
|
|
Main.dust[purpleDust2].velocity *= 5f;
|
|
purpleDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f);
|
|
Main.dust[purpleDust2].noGravity = true;
|
|
Main.dust[purpleDust2].velocity *= 2f;
|
|
}
|
|
|
|
if (Main.netMode != NetmodeID.Server)
|
|
{
|
|
float randomSpread = Main.rand.Next(-200, 201) / 100f;
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find<ModGore>("CeaselessVoid").Type, 1f);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find<ModGore>("CeaselessVoid2").Type, 1f);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find<ModGore>("CeaselessVoid2").Type, 1f);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find<ModGore>("CeaselessVoid3").Type, 1f);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find<ModGore>("CeaselessVoid3").Type, 1f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|