Files
ForgottenWawiTech/Content/NPCs/OriginalNeptune/Raccoon.cs
T

69 lines
2.0 KiB
C#

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
namespace ForgottenWawiTech.Content.NPCs.OriginalNeptune
{
[AutoloadBossHead]
public class Raccoon : ModNPC
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("Raccoon");
Main.npcFrameCount[NPC.type] = 1;
}
public override void SetDefaults()
{
NPC.width = 40;
NPC.height = 40;
NPC.damage = 70;
NPC.defense = 16;
NPC.lifeMax = 18000;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.knockBackResist = 0f;
NPC.boss = true;
NPC.aiStyle = -1; // custom behavior later
NPC.value = Item.buyPrice(0, 1, 75, 0);
}
public override void AI()
{
// Placeholder AI: dash toward player occasionally
Player target = Main.player[NPC.target];
if (!target.active || target.dead)
{
NPC.TargetClosest(false);
target = Main.player[NPC.target];
if (!target.active || target.dead)
{
NPC.velocity.Y -= 0.1f;
}
}
NPC.ai[0]++;
if (NPC.ai[0] < 60)
{
// approach
Vector2 dir = target.Center - NPC.Center;
dir.Normalize();
NPC.velocity = dir * 3f;
}
else if (NPC.ai[0] == 60)
{
// dash
Vector2 dash = target.Center - NPC.Center;
dash.Normalize();
NPC.velocity = dash * 10f;
}
else if (NPC.ai[0] > 120)
{
NPC.ai[0] = 0;
}
NPC.spriteDirection = NPC.direction = (target.Center.X < NPC.Center.X) ? -1 : 1;
}
}
}