add beam wand (thanks lexy)

This commit is contained in:
2025-11-14 22:36:20 +00:00
parent 1219413040
commit f44703376f
12 changed files with 604 additions and 0 deletions
@@ -0,0 +1,97 @@
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
namespace ForgottenWawiTech.Content.NPCs.Enemies.AvalianInvasion
{
public class AvalianTechnician : ModNPC
{
private int laserTimer = 0;
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 6;
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0)
{
Velocity = 1f
};
NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, value);
}
public override void SetDefaults()
{
NPC.width = 36;
NPC.height = 44;
NPC.damage = 40;
NPC.defense = 12;
NPC.lifeMax = 300;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath6;
NPC.value = Item.buyPrice(0, 0, 15, 0);
NPC.knockBackResist = 0.4f;
NPC.aiStyle = NPCAIStyleID.Bat;
}
public override void AI()
{
Player target = Main.player[NPC.target];
if (target.active && !target.dead)
{
laserTimer++;
// Circle around player
float distanceToPlayer = Vector2.Distance(NPC.Center, target.Center);
if (distanceToPlayer > 400f)
{
// Move closer
Vector2 toPlayer = Vector2.Normalize(target.Center - NPC.Center);
NPC.velocity = toPlayer * 4f;
}
else if (distanceToPlayer < 350f)
{
// Orbit
Vector2 toPlayer = target.Center - NPC.Center;
Vector2 perpendicular = new Vector2(-toPlayer.Y, toPlayer.X);
perpendicular.Normalize();
NPC.velocity = perpendicular * 3f;
}
// Fire laser every 60 frames (1 second)
if (laserTimer >= 60)
{
laserTimer = 0;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Vector2 shootDirection = Vector2.Normalize(target.Center - NPC.Center);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center,
shootDirection * 12f, ProjectileID.DeathLaser,
NPC.damage / 2, 1f);
}
}
}
}
public override void HitEffect(NPC.HitInfo hit)
{
if (NPC.life <= 0)
{
// Tech parts and feathers
for (int i = 0; i < 8; i++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Feather);
}
for (int i = 0; i < 5; i++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric);
}
}
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
return 0f; // Controlled by invasion system
}
}
}