tModLoader Tmodloader Boss NPC help Required

_Sunshy

Skeletron Prime
I have recently started getting into tmodloader modding, but I would like some help with a problem about custom projectiles fired from a custom boss.
I hacked together a boss from a few different sources:

Al0n37
Insu Cookie
and the Example Mod by Bluemagic123

Here is the code:

Code:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace OddsAndEnds.NPCs.NullSlime
{
    public class NullSlime : ModNPC
    {
        public override void SetDefaults()
        {
            npc.aiStyle = 1;
            npc.lifeMax = 5000;
            npc.damage = 15;
            npc.defense = 200;
            npc.knockBackResist = 0;
            npc.width = 28;
            npc.height = 44;
            aiType = NPCID.KingSlime;
            npc.npcSlots = 1f;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = false;
            npc.noTileCollide = false;
            npc.HitSound = SoundID.NPCHit8;
            npc.DeathSound = SoundID.NPCDeath14;
            npc.netAlways = true;
        }

        public override void BossLoot(ref string name, ref int potionType)
        {
            potionType = ItemID.GreaterHealingPotion;
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.GoldBar, 50);
        }
        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax += (int)(npc.lifeMax * 0.579f * bossLifeScale);
            npc.damage += (int)(npc.damage * 0.6f);
        }
        public override void AI()
        {
            npc.ai[0]++;
            Player P = Main.player[npc.target];
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            npc.netUpdate = true;

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;[SPOILER="1"][/SPOILER]
                int type = mod.ProjectileType("MagicSlime");
                Main.PlaySound(23, (int)npc.position.X, (int)npc.position.Y, 17);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;
                int type = mod.ProjectileType("FireSlime");
                Main.PlaySound(24, (int)npc.position.X, (int)npc.position.Y, 27);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;
                int type = mod.ProjectileType("IceSlime");
                Main.PlaySound(25, (int)npc.position.X, (int)npc.position.Y, 37);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;
                int type = mod.ProjectileType("CursedSlime");
                Main.PlaySound(26, (int)npc.position.X, (int)npc.position.Y, 47);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }
        }
    }
}

The issue is that only two of the four projectiles fire, The ones that fire are the Fire Slime and Cursed Slime.
If you need any of the projectile codes, you can ask and I will post them as well.
 
I have recently started getting into tmodloader modding, but I would like some help with a problem about custom projectiles fired from a custom boss.
I hacked together a boss from a few different sources:

Al0n37
Insu Cookie
and the Example Mod by Bluemagic123

Here is the code:

Code:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace OddsAndEnds.NPCs.NullSlime
{
    public class NullSlime : ModNPC
    {
        public override void SetDefaults()
        {
            npc.aiStyle = 1;
            npc.lifeMax = 5000;
            npc.damage = 15;
            npc.defense = 200;
            npc.knockBackResist = 0;
            npc.width = 28;
            npc.height = 44;
            aiType = NPCID.KingSlime;
            npc.npcSlots = 1f;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = false;
            npc.noTileCollide = false;
            npc.HitSound = SoundID.NPCHit8;
            npc.DeathSound = SoundID.NPCDeath14;
            npc.netAlways = true;
        }

        public override void BossLoot(ref string name, ref int potionType)
        {
            potionType = ItemID.GreaterHealingPotion;
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.GoldBar, 50);
        }
        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax += (int)(npc.lifeMax * 0.579f * bossLifeScale);
            npc.damage += (int)(npc.damage * 0.6f);
        }
        public override void AI()
        {
            npc.ai[0]++;
            Player P = Main.player[npc.target];
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            npc.netUpdate = true;

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;[SPOILER="1"][/SPOILER]
                int type = mod.ProjectileType("MagicSlime");
                Main.PlaySound(23, (int)npc.position.X, (int)npc.position.Y, 17);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;
                int type = mod.ProjectileType("FireSlime");
                Main.PlaySound(24, (int)npc.position.X, (int)npc.position.Y, 27);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;
                int type = mod.ProjectileType("IceSlime");
                Main.PlaySound(25, (int)npc.position.X, (int)npc.position.Y, 37);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }

            npc.ai[1]++;
            if (npc.ai[1] >= 230)
            {
                float Speed = 20f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 10;
                int type = mod.ProjectileType("CursedSlime");
                Main.PlaySound(26, (int)npc.position.X, (int)npc.position.Y, 47);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }
        }
    }
}

The issue is that only two of the four projectiles fire, The ones that fire are the Fire Slime and Cursed Slime.
If you need any of the projectile codes, you can ask and I will post them as well.
Judging from the code, you have no idea how counters work. Also, if this ran fully correctly, it would fire all of them at once at the same time in the same trajecotry, which is probably not what you want.

Basically theres a bunch of thing going wrong here....

But first off, what are trying to do? I see that you are creating four seperateporjectiles but I am unsure how it is determined when to shoot or where to shoot, so describe to us the boss shooting mechanic.
 
Judging from the code, you have no idea how counters work. Also, if this ran fully correctly, it would fire all of them at once at the same time in the same trajecotry, which is probably not what you want.

Basically theres a bunch of thing going wrong here....

But first off, what are trying to do? I see that you are creating four seperateporjectiles but I am unsure how it is determined when to shoot or where to shoot, so describe to us the boss shooting mechanic.

I am aware this is an ugly hack with no structure and professional format to it, no need to remind me of that. But as for your question, I want 4 projectiles to fire in a "wave effect" somewhat like this:

-----Projectile
--------Projectile
--------Projectile
-----Projectile

Sorry once again for the crude and unprofessional code :/.

(I tried adding a different X coordinate to each projectile after I saw your message, however I still had the same issue.)
 
Back
Top Bottom