using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace wch.NPCs
{
public class UnicornPony : ModNPC
{
public override bool Autoload(ref string name, ref string texture)
{
name = "UnicornPony";
return mod.Properties.Autoload;
}
public override void SetDefaults()
{
npc.name = "Unicorn Pony";
npc.townNPC = true;
npc.friendly = true;
npc.width = 18;
npc.height = 40;
npc.aiStyle = 7;
npc.damage = 10;
npc.defense = 15;
npc.lifeMax = 250;
npc.soundHit = 1;
npc.soundKilled = 1;
npc.knockBackResist = 0.5f;
Main.npcFrameCount[npc.type] = 26;
NPCID.Sets.ExtraFramesCount[npc.type] = 9;
NPCID.Sets.AttackFrameCount[npc.type] = 4;
NPCID.Sets.DangerDetectRange[npc.type] = 200;
NPCID.Sets.AttackType[npc.type] = 1;
NPCID.Sets.AttackTime[npc.type] = 20;
NPCID.Sets.AttackAverageChance[npc.type] = 25;
animationType = NPCID.Guide;
}
public override void DrawTownAttackGun(ref float scale, ref int item, ref int closeness)
{
scale = 1f;
item = ItemID.PlatinumBow;
closeness = 12;
}
public override bool CanTownNPCSpawn(int numTownNPCs, int money)
{
for (int k = 0; k < 255; k++)
{
Player player = Main.player[k];
if (player.active)
{
for (int j = 0; j < player.inventory.Length; j++)
{
if (player.inventory[j].type == mod.ItemType("TestItem"))
{
return true;
}
}
}
}
return false;
}
public override string TownNPCName()
{
switch (WorldGen.genRand.Next(3))
{
case 0:
return "EnergySway";
default:
return "CresentSpark";
}
}
public override string GetChat()
{
switch (Main.rand.Next(3))
{
case 0:
return "What? You never seen a talking unicorn before?";
default:
return "For the last time, I'm a PONY! Not a HORSE! Somebody just can't figure out the difference.";
}
}
public override void SetChatButtons(ref string button, ref string button2)
{
button = Lang.inter[28];
}
public override void OnChatButtonClicked(bool firstButton, ref bool shop)
{
if (firstButton)
{
shop = true;
}
}
public override void SetupShop(Chest shop, ref int nextSlot)
{
shop.item[nextSlot].SetDefaults(ItemID.WoodenArrow);
nextSlot++;
if (Main.moonPhase < 2)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("WoodSheild"));
nextSlot++;
}
else if (Main.moonPhase < 6)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("LavaSheild"));
nextSlot++;
}
else
{
}
}
public override void TownNPCAttackStrength(ref int damage, ref float knockback)
{
damage = 20;
knockback = 4f;
}
public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
{
cooldown = 10;
randExtraCooldown = 40;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)
{
projType = ProjectileID.JestersArrow;
attackDelay = 5;
}
public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)
{
multiplier = 12f;
randomOffset = 2f;
}
}
}