using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace KahanMod.NPCs.Bosses
{
public class Yama : ModNPC
{
public override void SetDefaults()
{
npc.name = "Yama";
npc.displayName = "Yama";
npc.aiStyle = 0;
npc.lifeMax = 9000;
npc.damage = 40;
npc.defense = 25;
npc.knockBackResist = 0f;
npc.width = 60;
npc.height = 30;
animationType = NPCID.BoundGoblin;
Main.npcFrameCount[npc.type] = 2;
npc.value = Item.buyPrice(0, 0, 10, 0);
npc.npcSlots = 1f;
npc.boss = true;
npc.lavaImmune = true;
npc.noGravity = true;
npc.noTileCollide = true;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath17;
npc.buffImmune[24] = false;
music = MusicID.Boss2;
npc.netAlways = true;
}
public override void AutoloadHead(ref string headTexture, ref string bossHeadTexture)
{
bossHeadTexture = "KahanMod/NPCs/Bosses/Yama_Head_Boss";
}
public override void BossLoot(ref string name, ref int potionType)
{
potionType = ItemID.HealingPotion;
if (Main.expertMode)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("YamaTreasureBag"));
}
else
{
int choice = Main.rand.Next(3);
if (choice == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("YoyoMold"));
}
if (choice == 1)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("FlailMold"));
}
if (choice == 2)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("KatanaMold"));
}
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RedFragment"), Main.rand.Next(5, 10));
}
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.6f);
}
public override void AI()
{
Player player = Main.player[npc.target];
Vector2 moveTo = player.Center + new Vector2(0f, -200f);
float speed = 3f;
Vector2 move = moveTo - npc.Center;
float magnitude = (float) Math.Sqrt(move.X * move.X + move.Y * move.Y);
move *= speed / magnitude;
npc.velocity = move;
npc.ai[0] += 1;
if(npc.ai[0] %(60 * 10) == 0)
{
for(int i = 0; i < 5; i++)
{
if (npc.ai[0] % 600 == 0)
{
NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("TorturedSoul")); //NPC name
}
}
}
}
if (npc.life <= npc.lifeMax * 0.5f)
{
for(int i = 0; i < 1; i++)
{
if (npc.ai[0] % 600 == 0)
{
NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("HorseFace")); //NPC name
}
}
}
}
}
}