using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.GameContent.Personalities; using Terraria.Localization; namespace ForgottenWawiTech.Content.NPCs.TownNPCs { public class AvalianTrader : ModNPC { public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 25; // The amount of frames the NPC has NPCID.Sets.ExtraFramesCount[NPC.type] = 9; // Generally for Town NPCs, this should be 9 NPCID.Sets.AttackFrameCount[NPC.type] = 4; NPCID.Sets.DangerDetectRange[NPC.type] = 700; // The amount of pixels away from the center of the npc that it tries to attack enemies NPCID.Sets.AttackType[NPC.type] = 0; NPCID.Sets.AttackTime[NPC.type] = 90; // The amount of time it takes for the NPC's attack animation to be over NPCID.Sets.AttackAverageChance[NPC.type] = 30; NPCID.Sets.HatOffsetY[NPC.type] = 4; // For when a party is active, the party hat spawns at a Y offset // Influences how the NPC looks in the Bestiary NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers(0) { Velocity = 1f, // Draws the NPC in the bestiary as if its walking +1 tiles in the x direction Direction = 1 // -1 is left and 1 is right. NPCs are drawn facing the left by default }; NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, drawModifiers); } public override void SetDefaults() { NPC.townNPC = true; NPC.friendly = true; NPC.width = 18; NPC.height = 40; NPC.aiStyle = 7; NPC.damage = 30; NPC.defense = 10; NPC.lifeMax = 500; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath6; NPC.knockBackResist = 0.5f; AnimationType = NPCID.Guide; } public override bool CanTownNPCSpawn(int numTownNPCs) { // Only spawn if a player has obtained RGBass in this world return ForgottenWawiTechSystem.hasObtainedRGBass; } public override List SetNPCNameList() { return new List() { "Kivuli", "Sekai", "Taerik", "Nykra", "Vekir", "Shyrik", "Kaelis", "Nyxal", "Verik", "Skyris", "Taeli", "Nyrik", "Kaevi", "Vyxen", "Syrrik", "Nykai" }; } public override void SetChatButtons(ref string button, ref string button2) { button = Language.GetTextValue("LegacyInterface.28"); // "Shop" } public override void OnChatButtonClicked(bool firstButton, ref string shop) { if (firstButton) { shop = "Shop"; } } public override void AddShops() { new NPCShop(Type) .Add(Condition.DownedMoonLord) .Add(Condition.Hardmode) .Add(ItemID.RainbowBrick, Condition.Hardmode) // TODO: Force Rainbow Brick to not have No Value. .Add() .Register(); } public override string GetChat() { switch (Main.rand.Next(15)) { case 0: return "*avalian chirping*"; case 1: return "Welcome! I've traveled far from Avalon to bring you the finest technology."; case 2: return "These feathers? They're not just for show - they're quite valuable!"; case 3: return "RGB technology is all the rage back home. Everything needs more colors!"; case 4: return "The visor shards I sell are fragments from our most advanced equipment."; case 5: return "My pack may be small, but I've traversed dimensions to get here."; case 6: return "*chirps excitedly* Oh, you're interested in our wares?"; case 7: return "Avalon sends its regards! And its finest materials."; case 8: return "Don't underestimate the power of a well-crafted alloy."; case 9: return "The journey here was long, but your world has such fascinating resources!"; case 10: return "*preens feathers* Presentation is important in any trade."; case 11: return "RGBass - it's not just a material, it's a lifestyle."; case 12: return "I wonder what the other traders back on Avalon would think of this place..."; case 13: return "My species may be small, but we're excellent engineers!"; default: return "Need something? My shop is always open!"; } } public override void TownNPCAttackStrength(ref int damage, ref float knockback) { damage = 50; knockback = 4f; } public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) { cooldown = 10; randExtraCooldown = 30; } public override void TownNPCAttackProj(ref int projType, ref int attackDelay) { projType = 502; attackDelay = 1; } public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) { multiplier = 12f; randomOffset = 2f; } } }