tAPI [Tutorial] Custom Bosses - NPC AI and Server Syncing

error: in class declaration, structure or member interface exist incorrect token if
Code:
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
               }

              }
            }
         }
    }
}
what I did wrong
You have an extra bracket somewhere

Or maybe this?
Code:
          npc.ai[0] += 1;
          if (npc.ai[1] >= 100)  // 230 is projectile fire rate
          {
             for(int i = 0; i < 255; i++)
             {
             
             }
          }

            int rand = Main.rand.Next(5);
            int num = mod.ProjectileType("Gust");
            }
        }
    }
}
I seriously don't know what you are trying to do here, and here is an example on how to use a counter.

Code:
public override void AI()
{
   //Increment counter
   projectile.ai[0] += 1f
   
   //If the counter divided by 60 has a remainder of 0 do the thing NOTE: 60 ticks = 1 sec
   if(projectile.ai[0] % 60 == 0)
   {
      //Produces projectile and gets the index of projectile
      int projectileIndex = Projectile.NewProjectile(/*NewProjectile stuff because of laziness*/);
      Main.projectile[projectileIndex].hostile = true; //Set the projectile in the array to hostile
      Main.projectile[projectileIndex].friendly = false; //Set the projectile in the array to be not friendly
   }
}
 
Last time I promise :)
134,41 „KahanMod.NPCs.Bosses.Yama.CanHitNPC(Terraria.Projectile, Terraria.NPC)”: didn't find proper method to change
Code:
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 = 4f;
         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
               }

             
            }
         }
        }
        public override bool? CanHitNPC(NPC npc)
        {
              if(npc.type == "Yama")
              {
                bool flag = true;
                for(int k = 0; k < 200; k++)
                {
                     if(Main.npc[k].active && Main.npc[k].type == "HorseFace")
                     {
                       flag = false;
                       break;
                     }
                }
                if(!flag)
                {
                   return false;
                }
              }
              return null;
        }

        public override bool? CanHitNPC(Projectile projectile, NPC npc)
        {
            if(npc.type == "Yama")
            {
                return CanHitNPC(npc);
            }
            return null;
        }

    }
}
 
Last time I promise :)
134,41 „KahanMod.NPCs.Bosses.Yama.CanHitNPC(Terraria.Projectile, Terraria.NPC)”: didn't find proper method to change
Code:
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 = 4f;
         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
               }

            
            }
         }
        }
        public override bool? CanHitNPC(NPC npc)
        {
              if(npc.type == "Yama")
              {
                bool flag = true;
                for(int k = 0; k < 200; k++)
                {
                     if(Main.npc[k].active && Main.npc[k].type == "HorseFace")
                     {
                       flag = false;
                       break;
                     }
                }
                if(!flag)
                {
                   return false;
                }
              }
              return null;
        }

        public override bool? CanHitNPC(Projectile projectile, NPC npc)
        {
            if(npc.type == "Yama")
            {
                return CanHitNPC(npc);
            }
            return null;
        }

    }
}
I have no idea what you're trying to do.
 
I dont know too much about bools how can I make it
It's just a type of variable that stores either "true" or "false", here's an example on your problem
Code:
public override void AI()
{
   bool exists = false;
   for(int i = 0; i < Main.npc.Length - 1; i++)
   {
      if(Main.npc[i] == mod.NPCType("ModEnemy") && npc.active)
      {
         exists = true;
         break;
      }
   }
   if(exists)
   {
      npc.dontTakeDamage = true;
   }
   else
   {
      npc.dontTakeDamage = false;
   }
}
 
It's just a type of variable that stores either "true" or "false", here's an example on your problem
Code:
public override void AI()
{
   bool exists = false;
   for(int i = 0; i < Main.npc.Length - 1; i++)
   {
      if(Main.npc[i] == mod.NPCType("ModEnemy") && npc.active)
      {
         exists = true;
         break;
      }
   }
   if(exists)
   {
      npc.dontTakeDamage = true;
   }
   else
   {
      npc.dontTakeDamage = false;
   }
}
still getting same error
Code:
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 = 4f;
         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
               }

             
            }
         }
        
         bool exists = false;
         for(int i = 0; i < Main.npc.Length - 1; i++)
         {
             if(Main.npc[i] == mod.NPCType("HorseFace") && npc.active)
             {
              exists = true;
              break;
             }  
         }
         if(exists)
         {
           npc.dontTakeDamage = true;
         }
         else
         {
           npc.dontTakeDamage = false;
         }

        }
        public override bool? CanHitNPC(NPC npc)
        {
              if(npc.type == "Yama")
              {
                bool flag = true;
                for(int k = 0; k < 200; k++)
                {
                     if(Main.npc[k].active && Main.npc[k].type == "HorseFace")
                     {
                       flag = false;
                       break;
                     }
                }
                if(!flag)
                {
                   return false;
                }
              }
              return null;
        }

        public override bool? CanHitNPC(Projectile projectile, NPC npc)
        {
            if(npc.type == "Yama")
            {
                return CanHitNPC(npc);
            }
            return null;
        }

    }
}
 
I'm almost finished with my boss, but I have one question. How can you make it so that the boss can only be spawned in a certain biome? I know that it would go in my public override bool CanUseItem(Player player) from my summon item script, but I don't know how I make it so that it returns if I'm not in the jungle biome. Please help me! Thanks.
 
Try using player.ZoneJungle in an if statement, not so sure it will work though.
Thanks so much! It worked!
[doublepost=1496667447,1496667368][/doublepost]I just have one more question and then my boss will be complete! How do you make it so that the boss has an icon on the minimap?
 
Thanks so much! It worked!
[doublepost=1496667447,1496667368][/doublepost]I just have one more question and then my boss will be complete! How do you make it so that the boss has an icon on the minimap?
I think it only requires need to have a file with the name of your boss + "_Head_Boss", as it is autoloaded. So the file name should be something like

Code:
BossName_Head_Boss.png
 
still getting same error
Code:
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 = 4f;
         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
               }

            
            }
         }
       
         bool exists = false;
         for(int i = 0; i < Main.npc.Length - 1; i++)
         {
             if(Main.npc[i] == mod.NPCType("HorseFace") && npc.active)
             {
              exists = true;
              break;
             } 
         }
         if(exists)
         {
           npc.dontTakeDamage = true;
         }
         else
         {
           npc.dontTakeDamage = false;
         }

        }
        public override bool? CanHitNPC(NPC npc)
        {
              if(npc.type == "Yama")
              {
                bool flag = true;
                for(int k = 0; k < 200; k++)
                {
                     if(Main.npc[k].active && Main.npc[k].type == "HorseFace")
                     {
                       flag = false;
                       break;
                     }
                }
                if(!flag)
                {
                   return false;
                }
              }
              return null;
        }

        public override bool? CanHitNPC(Projectile projectile, NPC npc)
        {
            if(npc.type == "Yama")
            {
                return CanHitNPC(npc);
            }
            return null;
        }

    }
}
Just remove the CanHit hooks entirely.
 
Just remove the CanHit hooks entirely.
166,7 Cannot use operator *==* for arguments of operation type NPC or int
Code:
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.6f * 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 = 4f;
         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
               }

             
            }
         }
          
         bool exists = false;
         for(int i = 0; i < Main.npc.Length - 1; i++)
         {
             if(Main.npc[i] == mod.NPCType("HorseFace") && npc.active)
             {
              exists = true;
              break;
             } 
         }
         if(exists)
         {
           npc.dontTakeDamage = true;
         }
         else
         {
           npc.dontTakeDamage = false;
         }

        }
    }
}
 
166,7 Cannot use operator *==* for arguments of operation type NPC or int
Code:
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.6f * 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 = 4f;
         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
               }

            
            }
         }
         
         bool exists = false;
         for(int i = 0; i < Main.npc.Length - 1; i++)
         {
             if(Main.npc[i] == mod.NPCType("HorseFace") && npc.active)
             {
              exists = true;
              break;
             }
         }
         if(exists)
         {
           npc.dontTakeDamage = true;
         }
         else
         {
           npc.dontTakeDamage = false;
         }

        }
    }
}
You need to make "Main.npc" to "Main.npc.type" Since that returns an NPC, not an int.
 
Element.SystemArray doesnt include definition *type* didnt find expansing method *type* that gets first argument *System.Array*
Code:
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.6f * 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 = 4f;
         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
               }

             
            }
         }
          
         bool exists = false;
         for(int i = 0; i < Main.npc.Length - 1; i++)
         {
             if(Main.npc.type[i] == mod.NPCType("HorseFace") && npc.active)
             {
              exists = true;
              break;
             } 
         }
         if(exists)
         {
           npc.dontTakeDamage = true;
         }
         else
         {
           npc.dontTakeDamage = false;
         }

        }
    }
}
 
Element.SystemArray doesnt include definition *type* didnt find expansing method *type* that gets first argument *System.Array*
Code:
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.6f * 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 = 4f;
         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
               }

            
            }
         }
         
         bool exists = false;
         for(int i = 0; i < Main.npc.Length - 1; i++)
         {
             if(Main.npc.type[i] == mod.NPCType("HorseFace") && npc.active)
             {
              exists = true;
              break;
             }
         }
         if(exists)
         {
           npc.dontTakeDamage = true;
         }
         else
         {
           npc.dontTakeDamage = false;
         }

        }
    }
}
After the square brackets. So it should be Main.npc.type
 
Please help me one more time! I completely finished my boss, but now I'm trying to update my mod to v 0.10.0.1, and I get the error message:
error CS0115: 'KnightmareLegacy.NPCs.Bosses.QueenSlime.QueenSlime.AutoloadHead(ref string, ref string)': no suitable method found to override
Here is the code I'm using to auto load the head texture. I don't know what I'm supposed to do, because this code worked in the older version!
Code:
   public override void AutoloadHead(ref string headTexture, ref string bossHeadTexture)
        {
            bossHeadTexture = "KnightmareLegacy/NPCs/Bosses/QueenSlime/QueenSlime_Head_Boss";
        }
 
Sorry guys, I'm well aware that this isn't the right place to ask, but I decided to anyways because everyone here is so helpful. Even if you can't answer my question, could you please point me to some people who could? My mod has been growing and growing, but with all of my custom boss music, my mod has gotten too big to be published on the mod browser. I was wondering if anyone here knew how to make a standalone mod with it's own .exe, so that people can actually play my mod? Thanks for your time!
 
Back
Top Bottom