tModLoader Boss - NPC name error

peachy

Skeletron Prime
Oh hi again.

I have another error.

Its making a boss. Heres the code:

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

namespace MoreWeapons.NPC.Boss
{
    public class BossName : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Rainbow";
            npc.displayName = "Rainbow";
            npc.aiStyle = 5;  //5 is the flying AI
            npc.lifeMax = 1500;   //boss life
            npc.damage = 70;  //boss damage
            npc.defense = 50;    //boss defense
            npc.knockBackResist = 0f;
            npc.width = 100;
            npc.height = 100;
            animationType = NPCID.DemonEye;   //this boss will behavior like the DemonEye
            Main.npcFrameCount[npc.type] = 2;    //boss frame/animation
            npc.value = Item.buyPrice(0, 40, 75, 45);
            npc.npcSlots = 1f;
            npc.boss = true; 
            npc.lavaImmune = true;
            npc.noGravity = true;
            npc.noTileCollide = true;
            npc.soundHit = 8;
            npc.soundKilled = 14;
            npc.buffImmune[24] = true;
            music = MusicID.Boss2;
            npc.netAlways = true;
        }
        public void AutoloadHead(ref string headTexture, ref string bossHeadTexture)
        {
            bossHeadTexture = "MoreWeapons/Boss/RainbowBossHead"; //the boss head texture
        }
        public override void BossLoot(ref string name, ref int potionType)
        {
            potionType = ItemID.GreatersHealingPotion;   //boss drops
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("RainbowSword"));
        }
        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);  //boss life scale in expertmode
            npc.damage = (int)(npc.damage * 0.6f);  //boss damage increase in expermode
        }
    }
}

And the error message happening is:
{IMAGE ATTACHED}

Please help and don't ignore this please. :D
 

Attachments

  • Screenshot (33).png
    Screenshot (33).png
    525.4 KB · Views: 116
Setting names in SetDefaults is deprecated, these days you have to do that in SetStaticDefaults:
  1. Remove npc.name = "Rainbow";
  2. Add snippet below:
Code:
public override void SetStaticDefaults()
{
    DisplayName.SetDefault("Rainbow");
}
 
Right, OK, thanks for the help but I have another problem but its with the Item Spawn.

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MoreWeapons.NPC.ItemSpawn
{
    public class ItemName : ModItem
    {
        public override void SetDefaults()
        {
            DisplayName.SetDefault("Rainbow Boss Spawn");
            item.width = 20;
            item.height = 20;
            item.maxStack = 1;
            Tooltip.SetDefault("Embrace the rainbows. FIGHT THE RAINBOWS.");
            item.value = 100;
            item.rare = 1;
            item.useAnimation = 30;
            item.useTime = 30;
            item.useStyle = 4;
            item.consumable = true;
        }
        public override bool CanUseItem(Player player)
        {          
            return !NPC.AnyNPCs(mod.NPCType("BossName"));  //you can't spawn this boss multiple times
            return !Main.dayTime;   //can use only at night
        }
        public override bool UseItem(Player player)
        {
            NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("BossName"));   //boss spawn
            Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);

            return true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.IronOre, 75);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Here is the ERROR:
{IMAGE}

Please don't ignore.
 

Attachments

  • Screenshot (34).png
    Screenshot (34).png
    515 KB · Views: 287
Back
Top Bottom