using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
using Terraria.Graphics.CameraModifiers;
using Terraria.ID;
using Terraria.ModLoader;
namespace mymodname.NPCs
{
[AutoloadBossHead]
public class bossname : ModNPC
{
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 2;
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0)
{
Velocity = 1f
};
NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, value);
NPCID.Sets.SpecificDebuffImmunity[Type][BuffID.Confused] = true;
}
public override void SetDefaults()
{
NPC.width = 123;
NPC.height = 159;
NPC.damage = 20;
NPC.defense = 10;
NPC.lifeMax = 6969;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.value = 420f;
NPC.knockBackResist = 0f;
NPC.aiStyle = 26;
NPC.boss = true;
NPC.npcSlots = 10f;
}
public override void FindFrame(int frameHeight)
{
int startFrame = 0;
int finalFrame = 1;
int frameSpeed = 2;
NPC.frameCounter += 0.5f;
NPC.frameCounter += NPC.velocity.Length() / 10f;
if (NPC.frameCounter > frameSpeed)
{
NPC.frameCounter = 0;
NPC.frame.Y += frameHeight;
if (NPC.frame.Y > finalFrame * frameHeight)
{
NPC.frame.Y = startFrame * frameHeight;
}
}
}
public override void BossLoot(ref string name, ref int potionType)
{
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
//npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType<bossbag>()));
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<Items.bosstrophy>(), 10));
//npcLoot.Add(ItemDropRule.MasterModeCommonDrop(ModContent.ItemType<Items.bossrelic>()));
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<Item>(), 1, 4, 9));
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<Item>(), 3));
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<item>(), 5));
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<Item>(), 4));
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<Items.Wearable.bossmask>(), 7));
}
public override void AI()
{
// This should almost always be the first code in AI() as it is responsible for finding the proper player target
if (NPC.target < 0 || NPC.target == 255 || Main.player[NPC.target].dead || !Main.player[NPC.target].active)
{
NPC.TargetClosest();
}
Player player = Main.player[NPC.target];
if (player.dead)
{
// If the targeted player is dead, flee
NPC.velocity.Y -= 0.04f;
// This method makes it so when the boss is in "despawn range" (outside of the screen), it despawns in 10 ticks
NPC.EncourageDespawn(10);
return;
}
}
public override void OnKill()
{
NPC.SetEventFlagCleared(ref DownedBossSystem.downedBossname, -1);
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new MoonLordPortraitBackgroundProviderBestiaryInfoElement(),
new FlavorTextBestiaryInfoElement("entry"),
});
}
}
}