using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;
using System.IO;
using ReLogic;
using System;
using System.Text.RegularExpressions;
using Microsoft.Xna.Framework.Graphics;
using Terraria.Localization;
namespace PurxyMod.NPCs
{
public class GoblinBush : ModNPC
{
const int COOLDOWN = 110;
int remaining_cooldown = 0;
Random rnd = new Random();
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Bush Goblin");
}
public override void SetDefaults()
{
npc.width = 18;
npc.height = 40;
npc.damage = 12;
npc.defense = 5;
npc.lifeMax = 500;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.value = 100f;
npc.knockBackResist = 0.75f;
npc.aiStyle = 3;
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Zombie];
aiType = 3; // aiType = 3;
animationType = NPCID.Zombie;
}
public override void PostAI()
{
{
Vector2 target = Main.player[npc.target].position;
float dist = Vector2.Distance(npc.position, target);
{
if (dist < 500f)
{
if (remaining_cooldown == 0)
{
Vector2 speed = target - npc.position;
speed.Normalize();
speed *= 11f;
int proj = Projectile.NewProjectile(npc.position.X, npc.position.Y, speed.X, speed.Y, mod.ProjectileType("SeedProjectile"), npc.damage, 1f);
remaining_cooldown = COOLDOWN;
}
if (remaining_cooldown == COOLDOWN)
{
Main.PlaySound(SoundID.Item63, Convert.ToInt32(npc.position.X), Convert.ToInt32(npc.position.Y));
}
remaining_cooldown -= 1;
}
}
}
if (Main.rand.Next(1000) == 0)
{
Main.PlaySound(SoundID.ZombieMoan, Convert.ToInt32(npc.position.X), Convert.ToInt32(npc.position.Y));
}
}
public override void NPCLoot()
{
if (Main.rand.Next(11) == 0)
{
Item.NewItem(npc.getRect(), ItemID.Blowpipe);
}
Item.NewItem(npc.getRect(), ItemID.TatteredCloth, Main.rand.Next(4));
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
return 0.5f;
}
}
}