Init Commit because im an Init Twat
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.Chat;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace ForgottenWawiTech.Content.NPCs.OriginalLyyka
|
||||
{
|
||||
[AutoloadBossHead]
|
||||
public class Lyyka : ModNPC
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
// DisplayName.SetDefault("Original Lyyka");
|
||||
Main.npcFrameCount[NPC.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
NPC.width = 40;
|
||||
NPC.height = 40;
|
||||
NPC.damage = 1786;
|
||||
NPC.defense = 290;
|
||||
NPC.lifeMax = 1000000;
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
NPC.DeathSound = SoundID.NPCDeath1;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.boss = true;
|
||||
NPC.aiStyle = -1;
|
||||
NPC.value = Item.buyPrice(0, 1, 0, 0);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Phased boss AI for Lyyka:
|
||||
// - At 50% HP, spawn Terra. Lyyka becomes invulnerable and waits until Terra is defeated -> Phase 2
|
||||
// - At 30% HP (after Terra phase), spawn Clara. Lyyka becomes invulnerable and waits until Clara is defeated -> Phase 3
|
||||
|
||||
NPC.TargetClosest(false);
|
||||
Player target = Main.player[NPC.target];
|
||||
if (!target.active || target.dead)
|
||||
{
|
||||
NPC.timeLeft = 300;
|
||||
return;
|
||||
}
|
||||
|
||||
int phase = (int)NPC.ai[0]; // 0 = initial, 1 = waiting Terra, 2 = after Terra, 3 = waiting Clara, 4 = final
|
||||
int flags = (int)NPC.ai[1]; // bit0 = Terra spawned, bit1 = Clara spawned
|
||||
|
||||
// Phase 0: before Terra summoned
|
||||
if (phase == 0)
|
||||
{
|
||||
if (NPC.life <= NPC.lifeMax / 2 && (flags & 1) == 0)
|
||||
{
|
||||
flags |= 1;
|
||||
NPC.ai[1] = flags;
|
||||
|
||||
// Make invulnerable and wait for Terra
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.ai[0] = 1;
|
||||
NPC.netUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
// basic approach movement
|
||||
if (NPC.ai[0] == 0)
|
||||
{
|
||||
Vector2 dir = (target.Center - NPC.Center);
|
||||
if (dir.Length() > 8f)
|
||||
{
|
||||
dir.Normalize();
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, dir * 3.5f, 0.02f);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Phase 1: waiting for Terra
|
||||
else if (phase == 1)
|
||||
{
|
||||
bool terraAlive = false;
|
||||
int terraType = ModContent.NPCType<Terra>();
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
NPC check = Main.npc[i];
|
||||
if (check.active && check.type == terraType)
|
||||
{
|
||||
terraAlive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!terraAlive)
|
||||
{
|
||||
NPC.dontTakeDamage = false;
|
||||
NPC.ai[0] = 2; // enter Phase 2
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.velocity *= 0.98f; // idle while waiting
|
||||
}
|
||||
}
|
||||
// Phase 2: after Terra defeated, before Clara
|
||||
else if (phase == 2)
|
||||
{
|
||||
// When at or below 30% HP, spawn Clara (if not already spawned)
|
||||
if (NPC.life <= (int)(NPC.lifeMax * 0.3f) && (flags & 2) == 0)
|
||||
{
|
||||
flags |= 2;
|
||||
NPC.ai[1] = flags;
|
||||
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.ai[0] = 3; // waiting for Clara
|
||||
NPC.netUpdate = true;
|
||||
|
||||
string announceClara = "Clara descends from the sky!";
|
||||
}
|
||||
|
||||
// basic movement in Phase 2
|
||||
Vector2 dir2 = (target.Center - NPC.Center);
|
||||
if (dir2.Length() > 8f)
|
||||
{
|
||||
dir2.Normalize();
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, dir2 * 4f, 0.02f);
|
||||
}
|
||||
}
|
||||
// Phase 3: waiting for Clara
|
||||
else if (phase == 3)
|
||||
{
|
||||
bool claraAlive = false;
|
||||
int claraType = ModContent.NPCType<Clara>();
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
NPC check = Main.npc[i];
|
||||
if (check.active && check.type == claraType)
|
||||
{
|
||||
claraAlive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!claraAlive)
|
||||
{
|
||||
NPC.dontTakeDamage = false;
|
||||
NPC.ai[0] = 4; // final phase
|
||||
NPC.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.velocity *= 0.98f;
|
||||
}
|
||||
}
|
||||
// Phase 4+: final behaviour
|
||||
else
|
||||
{
|
||||
Vector2 dir3 = (target.Center - NPC.Center);
|
||||
if (dir3.Length() > 8f)
|
||||
{
|
||||
dir3.Normalize();
|
||||
NPC.velocity = Vector2.Lerp(NPC.velocity, dir3 * 4.5f, 0.02f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnKill()
|
||||
{
|
||||
/* // Spawn LyykaNPC when killed
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NPC.NewNPC(NPC.GetSource_Death(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<LyykaNPC>());
|
||||
}
|
||||
else
|
||||
{
|
||||
NetMessage.SendData(MessageID.SpawnNPC, number: ModContent.NPCType<LyykaNPC>(), number2: NPC.whoAmI);
|
||||
} */
|
||||
// Set a world flag or similar to indicate Lyyka has been defeated
|
||||
WorldDefeatedBosses.Lyyka = true;
|
||||
// Immediate sync of world flags
|
||||
WorldDefeatedBosses.Sync(ModContent.GetInstance<ForgottenWawiTech>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user