using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.Utilities;
namespace DarkFantasy.NPCs
{
[AutoloadHead]
public class Firekeeper : ModNPC
{
public override string Texture
{
get
{
return "DarkFantasy/NPCs/Firekeeper";
}
}
public override bool Autoload(ref string name)
{
name = "Firekeeper";
return mod.Properties.Autoload;
}
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Firekeeper");
Main.npcFrameCount[npc.type] = 23;
NPCID.Sets.ExtraFramesCount[npc.type] = 5;
NPCID.Sets.AttackFrameCount[npc.type] = 4;
NPCID.Sets.DangerDetectRange[npc.type] = 600;
NPCID.Sets.AttackType[npc.type] = 0;
NPCID.Sets.AttackTime[npc.type] = 25;
NPCID.Sets.AttackAverageChance[npc.type] = 2;
NPCID.Sets.HatOffsetY[npc.type] = 6;
}
public override void SetDefaults()
{
npc.townNPC = true;
npc.friendly = true;
npc.width = 40;
npc.height = 58;
npc.aiStyle = 7;
npc.damage = 20;
npc.defense = 15;
npc.lifeMax = 250;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.knockBackResist = 0.7f;
animationType = NPCID.Steampunker;
}
public override string TownNPCName()
{
switch (WorldGen.genRand.Next(4))
{
case 0:
return "-";
}
}
public override void FindFrame(int frameHeight)
{
/*npc.frame.Width = 40;
if (((int)Main.time / 10) % 2 == 0)
{
npc.frame.X = 40;
}
else
{
npc.frame.X = 0;
}*/
}
public override string GetChat()
{
switch (Main.rand.Next(5))
{
default:
return "Ashen one, to be Unkindled is to be a vessel for souls. Sovereignless souls will become thy strength. I will show thee how. Ashen one, bring me souls, plucked from their vessels...";
}
}
/*
// Consider using this alternate approach to choosing a random thing. Very useful for a variety of use cases.
// The WeightedRandom class needs "using Terraria.Utilities;" to use
public override string GetChat()
{
WeightedRandom<string> chat = new WeightedRandom<string>();
int partyGirl = NPC.FindFirstNPC(NPCID.PartyGirl);
if (partyGirl >= 0 && Main.rand.Next(4) == 0)
{
chat.Add("Can you please tell " + Main.npc[partyGirl].GivenName + " to stop decorating my house with colors?");
}
chat.Add("Sometimes I feel like I'm different from everyone else here.");
chat.Add("What's your favorite color? My favorite colors are white and black.");
chat.Add("What? I don't have any arms or legs? Oh, don't be ridiculous!");
chat.Add("This message has a weight of 5, meaning it appears 5 times more often.", 5.0);
chat.Add("This message has a weight of 0.1, meaning it appears 10 times as rare.", 0.1);
return chat; // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
}
*/
public override void SetChatButtons(ref string button, ref string button2)
{
button = Language.GetTextValue("LegacyInterface.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.ThornsPotion);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.LesserManaPotion);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.LesserHealingPotion);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.WoodenArrow);
nextSlot++;
if (Main.moonPhase < 2)
{
shop.item[nextSlot].SetDefaults(ItemID.ManaPotion);
nextSlot++;
}
if (Main.moonPhase < 2)
{
shop.item[nextSlot].SetDefaults(ItemID.WrathPotion);
nextSlot++;
}
else if (Main.moonPhase < 4)
{
shop.item[nextSlot].SetDefaults(ItemID.JestersArrow);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.HolyArrow);
nextSlot++;
}
else if (Main.moonPhase < 6)
{
shop.item[nextSlot].SetDefaults(ItemID.SilverBow);
nextSlot++;
}
else
{
}
}
public override void TownNPCAttackStrength(ref int damage, ref float knockback)// Allows you to determine the damage and knockback of this town NPC attack
{
damage = 9; //npc damage
knockback = 0f; //npc knockback
}
public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) //Allows you to determine the cooldown between each of this town NPC's attack. The cooldown will be a number greater than or equal to the first parameter, and less then the sum of the two parameters.
{
cooldown = 5;
randExtraCooldown = 10;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)//Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the projectile to actually appear
{
projType = ProjectileID.BallofFire;
attackDelay = 1;
}
public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)//Allows you to determine the speed at which this town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity
{
multiplier = 7f;
// randomOffset = 4f;
}
//----------------------------------This is an example of how to make the npc use a gun and a projectile ----------------------------------
/*public override void DrawTownAttackGun(ref float scale, ref int item, ref int closeness) //Allows you to customize how this town NPC's weapon is drawn when this NPC is shooting (this NPC must have an attack type of 1). Scale is a multiplier for the item's drawing size, item is the ID of the item to be drawn, and closeness is how close the item should be drawn to the NPC.
{
scale = 1f;
item = mod.ItemType("GunName");
closeness = 20;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)//Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the projectile to actually appear
{
projType = ProjectileID.CrystalBullet;
attackDelay = 1;
}
public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)//Allows you to determine the speed at which this town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity
{
multiplier = 7f;
// randomOffset = 4f;
} */
}
}