• Console & Mobile Terrarians - news for 1.4.4.9! iOS and Android 1.4.4.9 out now. PS and Xbox should be very soon. Switch and Amazon are in submission. Great way to end the year - everyone on the same version of Terraria! More details HERE.

How to make the npc who sell the item after defeating boss?

regidia89

Terrarian
For example, there is the item called "A" which is selled by the arms dealer.

I want to make "A" is selled by the arms dealer after defeating Eye of Cthulhu.

So, I make the code like this, but it cannot compile.

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using GunNutMod.Items.Weapons;

namespace GunNutMod.Content
{
class ExampleNPCShop : GlobalNPC
{
public override void SetupShop(int type, Chest shop, ref int nextSlot)
{
if (type == NPCID.ArmsDealer)
{
// Adding an item to a vanilla NPC is easy:
// This item sells for the normal price.
shop.item[nextSlot].SetDefaults(ModContent.ItemType<SingleShotgun>());
nextSlot++; // Don't forget this line, it is essential.

if (GameEventCleared.DefeatedEyeOfCthulu)
{
shop.item[nextSlot].SetDefaults(ModContent.ItemType<LeverActionRifle>());
nextSlot++;

shop.item[nextSlot].SetDefaults(ModContent.ItemType<MP5>());
nextSlot++;
}
}
}
}
}

How to solve this problem?

plus. the error message is like this; "error CS0103: The name 'GameEventCleared' does not exist in the current context."
 

Michaelsoftman

Terrarian
Where are you getting GameEventCleared from? You'd just do something like this for Eye of Cthulu:

C#:
if (NPC.downedBoss1) {
                    shop.item[nextSlot].SetDefaults(ModContent.ItemType<CustomItem>());
                    nextSlot++;
                }
 

regidia89

Terrarian
Oh, I got it.
But wait, I have a question about "NPC.downedBoss1".

Is there any keyword another bosses like "defeated Eater of world/Brain of Cthulu" or "defeated Skeletron">
 
Top Bottom