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,85 @@
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
namespace ForgottenWawiTech.Content.NPCs.Enemies.AvalianInvasion
{
public class AvalianRifleman : ModNPC
{
private int shootTimer = 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 = 34;
NPC.height = 42;
NPC.damage = 55;
NPC.defense = 20;
NPC.lifeMax = 400;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath6;
NPC.value = Item.buyPrice(0, 0, 10, 0);
NPC.knockBackResist = 0.3f;
NPC.aiStyle = NPCAIStyleID.Bat; // Flying ranged enemy
}
public override void AI()
{
// Ranged attack behavior
Player target = Main.player[NPC.target];
if (target.active && !target.dead)
{
shootTimer++;
// Keep distance from player
float distanceToPlayer = Vector2.Distance(NPC.Center, target.Center);
if (distanceToPlayer < 300f)
{
// Move away
Vector2 awayDirection = Vector2.Normalize(NPC.Center - target.Center);
NPC.velocity = awayDirection * 3f;
}
// Shoot every 90 frames (1.5 seconds)
if (shootTimer >= 90)
{
shootTimer = 0;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Vector2 shootDirection = Vector2.Normalize(target.Center - NPC.Center);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center,
shootDirection * 10f, ProjectileID.BulletHighVelocity,
NPC.damage / 2, 1f);
}
}
}
}
public override void HitEffect(NPC.HitInfo hit)
{
if (NPC.life <= 0)
{
for (int i = 0; i < 12; i++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Feather);
}
}
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
return 0f; // Controlled by invasion system
}
}
}