Help with GenerateNpcTreasure

Hi, im a bit confused about the GenerateNpcTreasure function.
I want to spawn a npc with loot but cant figure this one out. help appreciated!


oCreature=CreateObject(OBJECT_TYPE_CREATURE, CreatureRef, Spawnpoint, FALSE);
int nTreasureValue = 4;
object oTreasureGetter = oCreature;
object oKiller = OBJECT_SELF;
GenerateNPCTreasure(nTreasureValue, oTreasureGetter, oKiller)

Reading the Lexicon It would seem that the best place to call GenerateNPCTreasure() is in the OnSpawn event for that creature. This means that you are better off creating a custom version of that creature in the palette using edit copy and adding your script to it. So you would make a small script like -

#include "nw_o2_coninclude"

void main()

Call it whatever you want and on your custom creatures properties, under the scripts tab, find the OnSpawn event and click the button with … on it. Click that and select your little script. Now when you run -

    object oCreature = CreateObject(OBJECT_TYPE_CREATURE, CreatureRef, Spawnpoint, FALSE);

your NPC will spawn with the treasure on it.


Actually, it depends on what the treasure is. Scrolls, potions and other useable items dropped into the creature’s inventory can often be used by the creature in combat. I remember years and years ago on a PW I scripted and built for, one of the random loots that “zombies” and “skeletons” could drop was a cure light potion. I used to get a good laugh when they would drink them and “commit suicide” at times. This also nullified the intention that the potions were meant for lower level characters to find and use to make life a little more forgiving for them. Same thing often happened with various scrolls and even minor enchanted weapons. The “fix” was to instead create the loot in the creature’s OnDeath event and not it’s OnSpawn.