321 lines
14 KiB
C#
321 lines
14 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
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.TreasureBags;
|
|
using CalamityMod.Items.Weapons.Magic;
|
|
using CalamityMod.Items.Weapons.Melee;
|
|
using CalamityMod.Items.Weapons.Ranged;
|
|
using CalamityMod.Items.Weapons.Summon;
|
|
using CalamityMod.NPCs.TownNPCs;
|
|
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System.IO;
|
|
using Terraria;
|
|
using Terraria.GameContent;
|
|
using Terraria.GameContent.Bestiary;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
using Terraria.GameContent.ItemDropRules;
|
|
using CalamityMod.Sounds;
|
|
|
|
namespace CalamityMod.NPCs.CalClone
|
|
{
|
|
[AutoloadBossHead]
|
|
public class CalamitasClone : ModNPC
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Calamitas Clone");
|
|
Main.npcFrameCount[NPC.type] = 6;
|
|
NPCID.Sets.TrailingMode[NPC.type] = 1;
|
|
NPCID.Sets.BossBestiaryPriority.Add(Type);
|
|
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0)
|
|
{
|
|
Scale = 0.65f,
|
|
PortraitScale = 0.65f
|
|
};
|
|
value.Position.Y -= 10f;
|
|
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
|
|
NPCID.Sets.MPAllowedEnemies[Type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
NPC.Calamity().canBreakPlayerDefense = true;
|
|
NPC.GetNPCDamage();
|
|
NPC.npcSlots = 14f;
|
|
NPC.width = 120;
|
|
NPC.height = 120;
|
|
|
|
if (CalamityWorld.death || BossRushEvent.BossRushActive)
|
|
NPC.scale *= 0.8f;
|
|
|
|
NPC.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 12 : 25;
|
|
NPC.value = Item.buyPrice(0, 50, 0, 0);
|
|
NPC.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.075f : 0.15f);
|
|
NPC.LifeMaxNERB(37500, 45000, 520000);
|
|
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
|
|
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
|
|
NPC.aiStyle = -1;
|
|
AIType = -1;
|
|
NPC.knockBackResist = 0f;
|
|
NPC.boss = true;
|
|
NPC.noGravity = true;
|
|
NPC.noTileCollide = true;
|
|
NPC.HitSound = SoundID.NPCHit4;
|
|
NPC.DeathSound = SoundID.NPCDeath14;
|
|
NPC.Calamity().VulnerableToHeat = false;
|
|
NPC.Calamity().VulnerableToCold = true;
|
|
NPC.Calamity().VulnerableToWater = true;
|
|
}
|
|
|
|
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
|
{
|
|
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] {
|
|
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Times.NightTime,
|
|
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface,
|
|
|
|
// Will move to localization whenever that is cleaned up.
|
|
new FlavorTextBestiaryInfoElement("A mysterious burning form which only appears at night, wreathed in brimstone fire. It has a twisted mind and misplaced pride in its abilities.")
|
|
});
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(NPC.dontTakeDamage);
|
|
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();
|
|
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()
|
|
{
|
|
CalamityAI.CalamitasCloneAI(NPC, Mod);
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
|
|
{
|
|
SpriteEffects spriteEffects = SpriteEffects.None;
|
|
if (NPC.spriteDirection == 1)
|
|
spriteEffects = SpriteEffects.FlipHorizontally;
|
|
|
|
Texture2D texture = TextureAssets.Npc[NPC.type].Value;
|
|
Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[NPC.type] / 2));
|
|
Color white = Color.White;
|
|
float colorLerpAmt = 0.5f;
|
|
int afterimageAmt = 7;
|
|
|
|
if (CalamityConfig.Instance.Afterimages)
|
|
{
|
|
for (int i = 1; i < afterimageAmt; i += 2)
|
|
{
|
|
Color color1 = drawColor;
|
|
color1 = Color.Lerp(color1, white, colorLerpAmt);
|
|
color1 = NPC.GetAlpha(color1);
|
|
color1 *= (float)(afterimageAmt - i) / 15f;
|
|
Vector2 offset = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos;
|
|
offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f;
|
|
offset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY);
|
|
spriteBatch.Draw(texture, offset, NPC.frame, color1, NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
|
}
|
|
}
|
|
|
|
Vector2 npcOffset = NPC.Center - screenPos;
|
|
npcOffset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f;
|
|
npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY);
|
|
spriteBatch.Draw(texture, npcOffset, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
|
|
|
texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/CalClone/CalamitasCloneGlow").Value;
|
|
Color color = Color.Lerp(Color.White, Color.Red, 0.5f);
|
|
if (CalamityWorld.getFixedBoi)
|
|
{
|
|
color = Color.CornflowerBlue;
|
|
}
|
|
|
|
if (CalamityConfig.Instance.Afterimages)
|
|
{
|
|
for (int i = 1; i < afterimageAmt; i++)
|
|
{
|
|
Color color2 = color;
|
|
color2 = Color.Lerp(color2, white, colorLerpAmt);
|
|
color2 *= (float)(afterimageAmt - i) / 15f;
|
|
Vector2 offset = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos;
|
|
offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f;
|
|
offset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY);
|
|
spriteBatch.Draw(texture, offset, NPC.frame, color2, NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
|
}
|
|
}
|
|
|
|
spriteBatch.Draw(texture, npcOffset, NPC.frame, color, NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
|
|
|
return false;
|
|
}
|
|
|
|
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
|
{
|
|
npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType<CalamitasCloneBag>()));
|
|
npcLoot.Add(ItemID.BrokenHeroSword);
|
|
|
|
// Normal drops: Everything that would otherwise be in the bag
|
|
var normalOnly = npcLoot.DefineNormalOnlyDropSet();
|
|
{
|
|
// Items
|
|
int[] items = new int[]
|
|
{
|
|
ModContent.ItemType<Oblivion>(),
|
|
ModContent.ItemType<Animosity>(),
|
|
ModContent.ItemType<LashesofChaos>(),
|
|
ModContent.ItemType<EntropysVigil>()
|
|
};
|
|
normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, items));
|
|
|
|
// Equipment
|
|
normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType<VoidofCalamity>()));
|
|
normalOnly.Add(ModContent.ItemType<ChaosStone>(), DropHelper.NormalWeaponDropRateFraction);
|
|
normalOnly.Add(ModContent.ItemType<Regenator>(), 10);
|
|
|
|
// Materials
|
|
normalOnly.Add(ModContent.ItemType<EssenceofHavoc>(), 1, 5, 10);
|
|
normalOnly.Add(ModContent.ItemType<AshesofCalamity>(), 1, 25, 30);
|
|
|
|
// Vanity
|
|
normalOnly.Add(ModContent.ItemType<CalamitasCloneMask>(), 7);
|
|
var calVanity = ItemDropRule.Common(ModContent.ItemType<HoodOfCalamity>(), 10);
|
|
calVanity.OnSuccess(ItemDropRule.Common(ModContent.ItemType<RobesOfCalamity>()));
|
|
normalOnly.Add(calVanity);
|
|
normalOnly.Add(ModContent.ItemType<ThankYouPainting>(), ThankYouPainting.DropInt);
|
|
}
|
|
|
|
npcLoot.Add(ModContent.ItemType<CalamitasCloneTrophy>(), 10);
|
|
|
|
// Relic
|
|
npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType<CalamitasCloneRelic>());
|
|
|
|
// Lore
|
|
npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCalamitasClone, ModContent.ItemType<LoreCalamitasClone>(), desc: DropHelper.FirstKillText);
|
|
}
|
|
|
|
public override void OnKill()
|
|
{
|
|
CalamityGlobalNPC.SetNewBossJustDowned(NPC);
|
|
|
|
CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType<THIEF>() }, DownedBossSystem.downedCalamitasClone);
|
|
|
|
// Abyss awakens after killing Calamitas
|
|
string key = "Mods.CalamityMod.PlantBossText";
|
|
Color messageColor = Color.RoyalBlue;
|
|
|
|
if (!DownedBossSystem.downedCalamitasClone)
|
|
{
|
|
if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active)
|
|
SoundEngine.PlaySound(CommonCalamitySounds.WyrmScreamSound, Main.player[Main.myPlayer].Center);
|
|
|
|
CalamityUtils.DisplayLocalizedText(key, messageColor);
|
|
}
|
|
|
|
// Mark the Calamitas Clone as dead
|
|
DownedBossSystem.downedCalamitasClone = true;
|
|
CalamityNetcode.SyncWorld();
|
|
}
|
|
|
|
public override void BossLoot(ref string name, ref int potionType)
|
|
{
|
|
name = "The Calamitas Clone";
|
|
potionType = ItemID.GreaterHealingPotion;
|
|
}
|
|
|
|
public override void HitEffect(int hitDirection, double damage)
|
|
{
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Brimstone, hitDirection, -1f, 0, default, 1f);
|
|
}
|
|
if (NPC.life <= 0)
|
|
{
|
|
if (Main.netMode != NetmodeID.Server)
|
|
{
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Calamitas").Type, NPC.scale);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Calamitas2").Type, NPC.scale);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Calamitas3").Type, NPC.scale);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Calamitas4").Type, NPC.scale);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Calamitas5").Type, NPC.scale);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Calamitas6").Type, NPC.scale);
|
|
}
|
|
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 num621 = 0; num621 < 40; num621++)
|
|
{
|
|
int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num622].velocity *= 3f;
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
Main.dust[num622].scale = 0.5f;
|
|
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
|
|
}
|
|
}
|
|
for (int num623 = 0; num623 < 70; num623++)
|
|
{
|
|
int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f);
|
|
Main.dust[num624].noGravity = true;
|
|
Main.dust[num624].velocity *= 5f;
|
|
num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num624].velocity *= 2f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
|
|
{
|
|
NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale);
|
|
NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier());
|
|
}
|
|
|
|
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
|
|
{
|
|
cooldownSlot = ImmunityCooldownID.Bosses;
|
|
return true;
|
|
}
|
|
|
|
public override void OnHitPlayer(Player player, int damage, bool crit)
|
|
{
|
|
if (damage > 0)
|
|
player.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300, true);
|
|
}
|
|
}
|
|
}
|