tModLoader Is it possible to replace an NPC item drop with a different item?

Nate2

Terrarian
I presume this'd be done by editing the drop rule as explained here, although I don't know how to change the item from that correctly.

Additional related question: How would a downedBoss bool work into that?
 
Yes, you can add, remove, and change drop rules using GlobalNPC.ModifyNPCLoot(). The issue with doing this is that the drop rule system is complex and uses an interface, meaning that the type of an item dropped by a drop rule cannot be determined for any given rule. If you happen to know the class of the particular rule you wish to change, then you can probably just use the same method as the one you linked in the example mod to change it.
Alternatively, you could use GlobalItem.OnSpawn() and look for the spawn source EntitySource_Loot. If you find an item with the type you want dropping from the NPC you want, you could try changing it. You could, technically, call Item.SetDefaults(), but I would not recommend it. A more safe solution may be to set the stack size of the item to 0, then spawn a new item of whatever type you want.
 
what i do........
1762066058512.png

1762066503162.png
 
You typed:
Code:
drop.condition is !NPC.downedPlantBoss
the type of drop.condition is Condition, the type of NPC.downedPlantBoss is bool, and the type of !NPC.downedPlantBoss is bool. The is keyword, typically, is used to cast the value on the left to the constant type on the right.

Did you mean?
Code:
drop.condition is not Condition.DownedPlantera
or?
Code:
drop.condition is Condition.NotDownedPlantera
 
1762155934261.png

1762155954228.png

The original drop condition I'm trying to remove uses !NPC.downedPlantBoss, and I'm not sure if NotDownedPlantera would actually affect that.
 
The original drop condition uses "AddConditionalPerPlayer"
1762157169702.png

I ignored this because I didn't know if it was vanilla or Calamity, but realistically i shouldve figured this out first thats my bad
 
It might be too much work to be worth it, so maybe, instead of checking the condition, you could just check the item it drops (can this item be dropped from this boss any other way?). In order to see if the conditions are the same, you would have to know the type of npcLoot, and know what AddConditonalPerPlayer() does. I couldn't find either of these, so maybe they are part of whatever that mod is.
 
Back
Top Bottom