Files
ForgottenWawiTech/Content/NPCs/Enemies/AvalianInvasion/AvalianEliteCommando.cs
T
2025-11-14 22:36:20 +00:00

120 lines
4.1 KiB
C#

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
namespace ForgottenWawiTech.Content.NPCs.Enemies.AvalianInvasion
{
public class AvalianEliteCommando : ModNPC
{
private int attackTimer = 0;
private int teleportTimer = 0;
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 8;
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0)
{
Velocity = 1f
};
NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, value);
}
public override void SetDefaults()
{
NPC.width = 38;
NPC.height = 48;
NPC.damage = 70;
NPC.defense = 30;
NPC.lifeMax = 800;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath6;
NPC.value = Item.buyPrice(0, 0, 50, 0);
NPC.knockBackResist = 0.1f;
NPC.aiStyle = NPCAIStyleID.Bat;
}
public override void AI()
{
Player target = Main.player[NPC.target];
if (target.active && !target.dead)
{
attackTimer++;
teleportTimer++;
// Fast movement
Vector2 toPlayer = Vector2.Normalize(target.Center - NPC.Center);
float distanceToPlayer = Vector2.Distance(NPC.Center, target.Center);
// Teleport mechanic every 180 frames (3 seconds)
if (teleportTimer >= 180 && distanceToPlayer > 200f)
{
teleportTimer = 0;
// Teleport dust effect
for (int i = 0; i < 20; i++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric);
}
// Teleport near player
Vector2 teleportPos = target.Center + new Vector2(Main.rand.Next(-200, 200), -150);
NPC.position = teleportPos;
for (int i = 0; i < 20; i++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric);
}
}
// Rapid fire attack every 30 frames (0.5 seconds)
if (attackTimer >= 30)
{
attackTimer = 0;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Vector2 shootDirection = Vector2.Normalize(target.Center - NPC.Center);
// Triple shot spread
for (int i = -1; i <= 1; i++)
{
Vector2 perturbedSpeed = shootDirection.RotatedBy(MathHelper.ToRadians(15 * i));
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center,
perturbedSpeed * 14f, ProjectileID.MartianTurretBolt,
NPC.damage / 3, 1f);
}
}
}
// Aggressive movement
if (distanceToPlayer > 150f)
{
NPC.velocity = toPlayer * 6f;
}
}
}
public override void HitEffect(NPC.HitInfo hit)
{
if (NPC.life <= 0)
{
// Epic death effects
for (int i = 0; i < 20; i++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Feather);
}
for (int i = 0; i < 15; i++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric);
}
}
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
return 0f; // Controlled by invasion system
}
}
}