Wyvern boss help!

Arso

Terrarian
I am trying to do a wyvern boss but it gives error, this is the code:

C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using ArsosMod;

namespace ArsosMod.NPCs.Boss
{ 
    public class WyvernBody : ModNPC
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ascended Wyvern");
        }
        public override void SetDefaults()
        {
            npc.width = 48;             
            npc.height = 50;         
            npc.damage = 10;
            npc.defense = 5;
            npc.lifeMax = 1;
            npc.knockBackResist = 0.0f;
            npc.behindTiles = true;
            npc.noTileCollide = true;
            npc.netAlways = true;
            npc.noGravity = true;
            npc.dontCountMe = true;
            npc.HitSound = SoundID.NPCHit1;
        }

        public override bool PreAI()
        {
            if (npc.ai[3] > 0)
                npc.realLife = (int)npc.ai[3];
            if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
                npc.TargetClosest(true);
            if (Main.player[npc.target].dead && npc.timeLeft > 300)
                npc.timeLeft = 300;

            if (Main.netMode != 1)
            {
                if (!Main.npc[(int)npc.ai[1]].active)
                {
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.active = false;
                    NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
                }
            }

            if (npc.ai[1] < (double)Main.npc.Length)
            {
              
                Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
                float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
                npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
                float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
                float dist = (length - (float)npc.width) / length;
                float posX = dirX * dist;
                float posY = dirY * dist;

                npc.velocity = Vector2.Zero;
                npc.position.X = npc.position.X + posX;
                npc.position.Y = npc.position.Y + posY;
            }
            return false;
        }

        public override bool PreDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color drawColor)
        {
            Texture2D texture = Main.npcTexture[npc.type];
            Vector2 origin = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f);
            Main.spriteBatch.Draw(texture, npc.Center - Main.screenPosition, new Rectangle?(), drawColor, npc.rotation, origin, npc.scale, SpriteEffects.None, 0);
            return false;
        }
        public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
        {

            return false;   
        }
    }
}

And this is the error :
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 4: cannot convert from 'string' to 'Terraria.Localization.NetworkText' ArsosMod C:\Users\Aris\Documents\My Games\Terraria\ModLoader\Mod Sources\ArsosMod\NPCs\Boss\WyvernBody.cs 54 Active

I am not very good at coding what am I have to do?
 
Last edited:
I am trying to do a wyvern boss but it's head is half and other segments are'nt there, this is the picture of it in game:
1603272801360.png


And this is the code:
C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using ArsosMod;
using ArsosMod.NPCs.Boss;

namespace ArsosMod.NPCs.Boss
{
    [AutoloadBossHead]
    public class AWyvernHead : ModNPC
    {
        public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernHead"; } }
        private static double spaceLayer => Main.worldSurface * 0.35;

        public bool loludided;
        private bool weakness;
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ascended Wyvern");
            NPCID.Sets.TechnicallyABoss[npc.type] = true;
            Main.npcFrameCount[npc.type] = 3;
        }

        public override void SetDefaults()
        {
            npc.aiStyle = -1;
            npc.lifeMax = 70000;
            npc.damage = 75;
            npc.defense = 10;
            npc.knockBackResist = 0f;
            npc.width = 35;
            npc.height = 100;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = true;
            npc.noTileCollide = true;
            npc.value = Item.buyPrice(0, 0, 2, 10);
            npc.npcSlots = 5f;
            npc.netAlways = true;
            npc.DeathSound = SoundID.NPCDeath8;
            npc.HitSound = SoundID.NPCHit7;
            npc.behindTiles = true;
        }

        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.6f);
            npc.damage = (int)(npc.damage * 0.8f);
        }

        public override bool PreAI()
        {
            Player player = Main.player[npc.target];
            float dist = npc.Distance(player.Center);
            if (npc.alpha != 0)
            {
                for (int spawnDust = 0; spawnDust < 2; spawnDust++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = true;
                    Main.dust[num935].noLight = true;
                }
            }
            npc.alpha -= 12;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }

            if (Main.netMode != 1)
            {
                if (npc.ai[0] == 0)
                {
                    npc.realLife = npc.whoAmI;
                    int latestNPC = npc.whoAmI;
                    int segment = 0;
                    int WyrmlingLength = 3;
                    for (int i = 0; i < WyrmlingLength; ++i)
                    {
                        if (segment == 0 || segment == 1)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernLegs"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;
                            segment += 1;
                        }
                        if (segment == 2)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernBody"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;
                            segment += 1;
                        }
                    }

                    latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernTail"), npc.whoAmI, 0, latestNPC);
                    Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                    Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;

                    npc.ai[0] = 1;
                    npc.netUpdate = true;
                }
            }

            int minTilePosX = (int)(npc.position.X / 16.0) - 1;
            int maxTilePosX = (int)((npc.position.X + npc.width) / 16.0) + 2;
            int minTilePosY = (int)(npc.position.Y / 16.0) - 1;
            int maxTilePosY = (int)((npc.position.Y + npc.height) / 16.0) + 2;
            if (minTilePosX < 0)
                minTilePosX = 0;
            if (maxTilePosX > Main.maxTilesX)
                maxTilePosX = Main.maxTilesX;
            if (minTilePosY < 0)
                minTilePosY = 0;
            if (maxTilePosY > Main.maxTilesY)
                maxTilePosY = Main.maxTilesY;

            bool collision = true;

            for (int i = minTilePosX; i < maxTilePosX; ++i)
            {
                for (int j = minTilePosY; j < maxTilePosY; ++j)
                {
                    if (Main.tile[i, j] != null && (Main.tile[i, j].nactive() && (Main.tileSolid[(int)Main.tile[i, j].type] || Main.tileSolidTop[(int)Main.tile[i, j].type] && (int)Main.tile[i, j].frameY == 0) || (int)Main.tile[i, j].liquid > 64))
                    {
                        Vector2 vector2;
                        vector2.X = (float)(i * 16);
                        vector2.Y = (float)(j * 16);
                        if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16.0 && (npc.position.Y + npc.height > (double)vector2.Y && npc.position.Y < vector2.Y + 16.0))
                        {
                            collision = true;
                            if (Main.rand.Next(100) == 0 && Main.tile[i, j].nactive())
                                WorldGen.KillTile(i, j, true, true, false);
                        }
                    }
                }
            }
            float speed = 5f;
            float acceleration = 0.1f;

            Vector2 npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
            float targetXPos = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2);
            float targetYPos = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2);

            float targetRoundedPosX = (float)((int)(targetXPos / 16.0) * 16);
            float targetRoundedPosY = (float)((int)(targetYPos / 16.0) * 16);
            npcCenter.X = (float)((int)(npcCenter.X / 16.0) * 16);
            npcCenter.Y = (float)((int)(npcCenter.Y / 16.0) * 16);
            float dirX = targetRoundedPosX - npcCenter.X;
            float dirY = targetRoundedPosY - npcCenter.Y;
            npc.TargetClosest(true);
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);

            float absDirX = Math.Abs(dirX);
            float absDirY = Math.Abs(dirY);
            float newSpeed = speed / length;
            dirX = dirX * (newSpeed * 2);
            dirY = dirY * (newSpeed * 2);
            if (npc.velocity.X > 0.0 && dirX > 0.0 || npc.velocity.X < 0.0 && dirX < 0.0 || (npc.velocity.Y > 0.0 && dirY > 0.0 || npc.velocity.Y < 0.0 && dirY < 0.0))
            {
                if (npc.velocity.X < dirX)
                    npc.velocity.X = npc.velocity.X + acceleration;
                else if (npc.velocity.X > dirX)
                    npc.velocity.X = npc.velocity.X - acceleration;
                if (npc.velocity.Y < dirY)
                    npc.velocity.Y = npc.velocity.Y + acceleration;
                else if (npc.velocity.Y > dirY)
                    npc.velocity.Y = npc.velocity.Y - acceleration;
                if (Math.Abs(dirY) < speed * 0.2 && (npc.velocity.X > 0.0 && dirX < 0.0 || npc.velocity.X < 0.0 && dirX > 0.0))
                {
                    if (npc.velocity.Y > 0.0)
                        npc.velocity.Y = npc.velocity.Y + acceleration * 2f;
                    else
                        npc.velocity.Y = npc.velocity.Y - acceleration * 2f;
                }
                if (Math.Abs(dirX) < speed * 0.2 && (npc.velocity.Y > 0.0 && dirY < 0.0 || npc.velocity.Y < 0.0 && dirY > 0.0))
                {
                    if (npc.velocity.X > 0.0)
                        npc.velocity.X = npc.velocity.X + acceleration * 2f;
                    else
                        npc.velocity.X = npc.velocity.X - acceleration * 2f;
                }
            }
            else if (absDirX > absDirY)
            {
                if (npc.velocity.X < dirX)
                    npc.velocity.X = npc.velocity.X + acceleration * 1.1f;
                else if (npc.velocity.X > dirX)
                    npc.velocity.X = npc.velocity.X - acceleration * 1.1f;

                if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                {
                    if (npc.velocity.Y > 0.0)
                        npc.velocity.Y = npc.velocity.Y + acceleration;
                    else
                        npc.velocity.Y = npc.velocity.Y - acceleration;
                }
            }
            else
            {
                if (npc.velocity.Y < dirY)
                    npc.velocity.Y = npc.velocity.Y + acceleration * 1.1f;
                else if (npc.velocity.Y > dirY)
                    npc.velocity.Y = npc.velocity.Y - acceleration * 1.1f;

                if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                {
                    if (npc.velocity.X > 0.0)
                        npc.velocity.X = npc.velocity.X + acceleration;
                    else
                        npc.velocity.X = npc.velocity.X - acceleration;
                }
            }
            if (Main.player[npc.target].dead)
            {
                npc.velocity.Y = npc.velocity.Y + 1f;
                if ((double)npc.position.Y > Main.rockLayer * 16.0)
                {
                    npc.velocity.Y = npc.velocity.Y + 1f;
                    speed = 30f;
                }
                if ((double)npc.position.Y > Main.rockLayer * 16.0)
                {
                    for (int num957 = 0; num957 < 200; num957++)
                    {
                        if (Main.npc[num957].aiStyle == npc.aiStyle)
                        {
                            Main.npc[num957].active = false;
                        }
                    }
                }
            }

            npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + 1.57f;
            if (npc.velocity.X < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }

            if (collision)
            {
                if (npc.localAI[0] != 1)
                    npc.netUpdate = true;
                npc.localAI[0] = 1f;
            }
            if ((npc.velocity.X > 0.0 && npc.oldVelocity.X < 0.0 || npc.velocity.X < 0.0 && npc.oldVelocity.X > 0.0 || (npc.velocity.Y > 0.0 && npc.oldVelocity.Y < 0.0 || npc.velocity.Y < 0.0 && npc.oldVelocity.Y > 0.0)) && !npc.justHit)
                npc.netUpdate = true;

            return false;
        }
    }
}
public class AwyvernLegs : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernLegs"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();
        npc.width = 50;
        npc.height = 54;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }
    public override void HitEffect(int hitDirection, double damage)
    {
        if (npc.life <= 0)
        {

            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 44;
            npc.height = 78;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }
    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                // NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }


        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }
}
public class AWyvernBody : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernBody"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();
        npc.width = 32;
        npc.height = 44;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override void HitEffect(int hitDirection, double damage)
    {

        if (npc.life <= 0)
        {
            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 20;
            npc.height = 40;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }
    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                // NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }

        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }

}

public class AWyvernTail : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernTail"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();

        npc.width = 18;
        npc.height = 96;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override void HitEffect(int hitDirection, double damage)
    {
        if (npc.life <= 0)
        {

            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 44;
            npc.height = 78;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }

    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AkumaADust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }

        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }
}

What Am I have to do?
 
I am trying to do a wyvern boss but it's other segments are'nt coming, this is the picture of it in game:

1603366087964.png


And this is the code:
C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using ArsosMod;
using ArsosMod.NPCs.Boss;

namespace ArsosMod.NPCs.Boss
{
    [AutoloadBossHead]
    public class AWyvernHead : ModNPC
    {
        public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernHead"; } }
        private static double spaceLayer => Main.worldSurface * 0.35;

        public bool loludided;
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ascended Wyvern");
            NPCID.Sets.TechnicallyABoss[npc.type] = true;
        }


        public override void SetDefaults()
        {
            npc.aiStyle = -1;
            npc.lifeMax = 70000;
            npc.damage = 75;
            npc.defense = 10;
            npc.knockBackResist = 0f;
            npc.width = 35;
            npc.height = 100;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = true;
            npc.noTileCollide = true;
            npc.value = Item.buyPrice(0, 0, 2, 10);
            npc.npcSlots = 6f;
            npc.netAlways = true;
            npc.DeathSound = SoundID.NPCDeath8;
            npc.HitSound = SoundID.NPCHit7;
            npc.behindTiles = true;
            music = mod.GetSoundSlot(SoundType.Music, "Sounds/Music/AwyvernMusic");
            musicPriority = MusicPriority.BossHigh;
        }

        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.6f);
            npc.damage = (int)(npc.damage * 0.8f);
        }

        public override bool PreAI()
        {
            Player player = Main.player[npc.target];
            float dist = npc.Distance(player.Center);
            if (npc.alpha != 0)
            {
                for (int spawnDust = 0; spawnDust < 2; spawnDust++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = true;
                    Main.dust[num935].noLight = true;
                }
            }
            npc.alpha -= 12;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }

            if (Main.netMode != 1)
            {
                if (npc.ai[0] == 0)
                {
                    npc.realLife = npc.whoAmI;
                    int latestNPC = npc.whoAmI;
                    int segment = 0;
                    int WyrmlingLength = 3;
                    for (int i = 0; i < WyrmlingLength; ++i)
                    {
                        if (segment == 0 || segment == 1)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernLegs"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;
                            segment += 1;
                        }
                        if (segment == 2)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernBody"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;
                            segment += 1;
                        }
                        if (segment == 3)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernBody1"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;
                            segment += 1;
                        }
                        if (segment == 4)
                        {
                            latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernBody2"), npc.whoAmI, 0, latestNPC);
                            Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                            Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;
                            segment += 1;
                        }
                    }

                    latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("AWyvernTail"), npc.whoAmI, 0, latestNPC);
                    Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                    Main.npc[(int)latestNPC].ai[3] = npc.whoAmI;

                    npc.ai[0] = 1;
                    npc.netUpdate = true;
                }
            }

            int minTilePosX = (int)(npc.position.X / 16.0) - 1;
            int maxTilePosX = (int)((npc.position.X + npc.width) / 16.0) + 2;
            int minTilePosY = (int)(npc.position.Y / 16.0) - 1;
            int maxTilePosY = (int)((npc.position.Y + npc.height) / 16.0) + 2;
            if (minTilePosX < 0)
                minTilePosX = 0;
            if (maxTilePosX > Main.maxTilesX)
                maxTilePosX = Main.maxTilesX;
            if (minTilePosY < 0)
                minTilePosY = 0;
            if (maxTilePosY > Main.maxTilesY)
                maxTilePosY = Main.maxTilesY;

            bool collision = true;

            for (int i = minTilePosX; i < maxTilePosX; ++i)
            {
                for (int j = minTilePosY; j < maxTilePosY; ++j)
                {
                    if (Main.tile[i, j] != null && (Main.tile[i, j].nactive() && (Main.tileSolid[(int)Main.tile[i, j].type] || Main.tileSolidTop[(int)Main.tile[i, j].type] && (int)Main.tile[i, j].frameY == 0) || (int)Main.tile[i, j].liquid > 64))
                    {
                        Vector2 vector2;
                        vector2.X = (float)(i * 16);
                        vector2.Y = (float)(j * 16);
                        if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16.0 && (npc.position.Y + npc.height > (double)vector2.Y && npc.position.Y < vector2.Y + 16.0))
                        {
                            collision = true;
                            if (Main.rand.Next(100) == 0 && Main.tile[i, j].nactive())
                                WorldGen.KillTile(i, j, true, true, false);
                        }
                    }
                }
            }
            float speed = 5f;
            float acceleration = 0.1f;

            Vector2 npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
            float targetXPos = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2);
            float targetYPos = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2);

            float targetRoundedPosX = (float)((int)(targetXPos / 16.0) * 16);
            float targetRoundedPosY = (float)((int)(targetYPos / 16.0) * 16);
            npcCenter.X = (float)((int)(npcCenter.X / 16.0) * 16);
            npcCenter.Y = (float)((int)(npcCenter.Y / 16.0) * 16);
            float dirX = targetRoundedPosX - npcCenter.X;
            float dirY = targetRoundedPosY - npcCenter.Y;
            npc.TargetClosest(true);
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);

            float absDirX = Math.Abs(dirX);
            float absDirY = Math.Abs(dirY);
            float newSpeed = speed / length;
            dirX = dirX * (newSpeed * 2);
            dirY = dirY * (newSpeed * 2);
            if (npc.velocity.X > 0.0 && dirX > 0.0 || npc.velocity.X < 0.0 && dirX < 0.0 || (npc.velocity.Y > 0.0 && dirY > 0.0 || npc.velocity.Y < 0.0 && dirY < 0.0))
            {
                if (npc.velocity.X < dirX)
                    npc.velocity.X = npc.velocity.X + acceleration;
                else if (npc.velocity.X > dirX)
                    npc.velocity.X = npc.velocity.X - acceleration;
                if (npc.velocity.Y < dirY)
                    npc.velocity.Y = npc.velocity.Y + acceleration;
                else if (npc.velocity.Y > dirY)
                    npc.velocity.Y = npc.velocity.Y - acceleration;
                if (Math.Abs(dirY) < speed * 0.2 && (npc.velocity.X > 0.0 && dirX < 0.0 || npc.velocity.X < 0.0 && dirX > 0.0))
                {
                    if (npc.velocity.Y > 0.0)
                        npc.velocity.Y = npc.velocity.Y + acceleration * 2f;
                    else
                        npc.velocity.Y = npc.velocity.Y - acceleration * 2f;
                }
                if (Math.Abs(dirX) < speed * 0.2 && (npc.velocity.Y > 0.0 && dirY < 0.0 || npc.velocity.Y < 0.0 && dirY > 0.0))
                {
                    if (npc.velocity.X > 0.0)
                        npc.velocity.X = npc.velocity.X + acceleration * 2f;
                    else
                        npc.velocity.X = npc.velocity.X - acceleration * 2f;
                }
            }
            else if (absDirX > absDirY)
            {
                if (npc.velocity.X < dirX)
                    npc.velocity.X = npc.velocity.X + acceleration * 1.1f;
                else if (npc.velocity.X > dirX)
                    npc.velocity.X = npc.velocity.X - acceleration * 1.1f;

                if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                {
                    if (npc.velocity.Y > 0.0)
                        npc.velocity.Y = npc.velocity.Y + acceleration;
                    else
                        npc.velocity.Y = npc.velocity.Y - acceleration;
                }
            }
            else
            {
                if (npc.velocity.Y < dirY)
                    npc.velocity.Y = npc.velocity.Y + acceleration * 1.1f;
                else if (npc.velocity.Y > dirY)
                    npc.velocity.Y = npc.velocity.Y - acceleration * 1.1f;

                if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < speed * 0.5)
                {
                    if (npc.velocity.X > 0.0)
                        npc.velocity.X = npc.velocity.X + acceleration;
                    else
                        npc.velocity.X = npc.velocity.X - acceleration;
                }
            }
            if (Main.player[npc.target].dead)
            {
                npc.velocity.Y = npc.velocity.Y + 1f;
                if ((double)npc.position.Y > Main.rockLayer * 16.0)
                {
                    npc.velocity.Y = npc.velocity.Y + 1f;
                    speed = 30f;
                }
                if ((double)npc.position.Y > Main.rockLayer * 16.0)
                {
                    for (int num957 = 0; num957 < 200; num957++)
                    {
                        if (Main.npc[num957].aiStyle == npc.aiStyle)
                        {
                            Main.npc[num957].active = false;
                        }
                    }
                }
            }

            npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + 1.57f;
            if (npc.velocity.X < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }

            if (collision)
            {
                if (npc.localAI[0] != 1)
                    npc.netUpdate = true;
                npc.localAI[0] = 1f;
            }
            if ((npc.velocity.X > 0.0 && npc.oldVelocity.X < 0.0 || npc.velocity.X < 0.0 && npc.oldVelocity.X > 0.0 || (npc.velocity.Y > 0.0 && npc.oldVelocity.Y < 0.0 || npc.velocity.Y < 0.0 && npc.oldVelocity.Y > 0.0)) && !npc.justHit)
                npc.netUpdate = true;

            return false;
        } 
    }
}
public class AwyvernLegs : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernLegs"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();
        npc.width = 50;
        npc.height = 54;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }
    public override void HitEffect(int hitDirection, double damage)
    {
        if (npc.life <= 0)
        {

            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 44;
            npc.height = 78;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }
    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                // NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }


        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }
}
public class AWyvernBody : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernBody"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();
        npc.width = 32;
        npc.height = 44;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override void HitEffect(int hitDirection, double damage)
    {

        if (npc.life <= 0)
        {
            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 20;
            npc.height = 40;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }
    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                // NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }

        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }

}

public class AWyvernBody1 : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernBody1"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();
        npc.width = 28;
        npc.height = 44;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override void HitEffect(int hitDirection, double damage)
    {

        if (npc.life <= 0)
        {
            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 20;
            npc.height = 40;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }
    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                // NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }

        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }

}

public class AWyvernBody2 : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernBody2"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();
        npc.width = 24;
        npc.height = 44;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override void HitEffect(int hitDirection, double damage)
    {

        if (npc.life <= 0)
        {
            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 20;
            npc.height = 40;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }
    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                // NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }

        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }

}

public class AWyvernTail : AWyvernHead
{
    public override string Texture { get { return "ArsosMod/NPCs/Boss/AWyvernTail"; } }

    public override void SetStaticDefaults()
    {
        DisplayName.SetDefault("Ascended Wyvern");
    }

    public override void SetDefaults()
    {
        base.SetDefaults();

        npc.width = 18;
        npc.height = 96;
        npc.dontCountMe = true;

        npc.alpha = 255;
    }

    public override void HitEffect(int hitDirection, double damage)
    {
        if (npc.life <= 0)
        {

            npc.position.X = npc.position.X + (float)(npc.width / 2);
            npc.position.Y = npc.position.Y + (float)(npc.height / 2);
            npc.width = 44;
            npc.height = 78;
            npc.position.X = npc.position.X - (float)(npc.width / 2);
            npc.position.Y = npc.position.Y - (float)(npc.height / 2);
            int dust1 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            int dust2 = ModContent.DustType<ArsosMod.Dusts.AWyvernDust>();
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust1, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust1].velocity *= 0.5f;
            Main.dust[dust1].scale *= 1.3f;
            Main.dust[dust1].fadeIn = 1f;
            Main.dust[dust1].noGravity = false;
            Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, dust2, 0f, 0f, 0, default(Color), 1f);
            Main.dust[dust2].velocity *= 0.5f;
            Main.dust[dust2].scale *= 1.3f;
            Main.dust[dust2].fadeIn = 1f;
            Main.dust[dust2].noGravity = true;
        }
    }

    public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
    {
        return false;
    }

    public override bool PreAI()
    {
        if (npc.ai[3] > 0)
            npc.realLife = (int)npc.ai[3];
        if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            npc.TargetClosest(true);
        if (Main.player[npc.target].dead && npc.timeLeft > 300)
            npc.timeLeft = 300;

        if (Main.netMode != 1)
        {
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                // NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
            }
        }

        if (Main.npc[(int)npc.ai[1]].alpha < 128)
        {
            if (npc.alpha != 0)
            {
                for (int num934 = 0; num934 < 2; num934++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, mod.DustType("AWyvernDust"), 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num935].noGravity = false;
                    Main.dust[num935].noLight = false;
                }
            }
            npc.alpha -= 42;
            if (npc.alpha < 0)
            {
                npc.alpha = 0;
            }
        }

        if (npc.ai[1] < (double)Main.npc.Length)
        {
            // We're getting the center of this NPC.
            Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
            // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
            float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
            float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
            // We then use Atan2 to get a correct rotation towards that parent NPC.
            npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
            // We also get the length of the direction vector.
            float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
            // We calculate a new, correct distance.
            float dist = (length - (float)npc.width) / length;
            float posX = dirX * dist;
            float posY = dirY * dist;

            // Reset the velocity of this NPC, because we don't want it to move on its own
            if (dirX < 0f)
            {
                npc.spriteDirection = 1;

            }
            else
            {
                npc.spriteDirection = -1;
            }
            // And set this NPCs position accordingly to that of this NPCs parent NPC.
            npc.position.X = npc.position.X + posX;
            npc.position.Y = npc.position.Y + posY;
        }
        return false;
    }
    public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
    {
        npc.lifeMax = (int)(npc.lifeMax * 0.6f);
        npc.damage = (int)(npc.damage * 0.8f);
    }
}

What Am I have to do?
 
Hi @Arso - we don't allow mutliple threads for the same topic on this forum, so I've merged them together for you. Try and keep all the discussion in here please!
 
Back
Top Bottom