Query re: Hardcoded treasure drops?

Hello :slight_smile:

I’m working on building my own small PW for a group of friends. My scripting knowledge is quite basic, but am developing it slowly.

I’m using a very simple loot system, which stores variables with percentages and resrefs of items on each creature. Exactly what I’m after, and simple enough to use.

However, while this gives me complete control over the loot the creatures drop, they occasionally still drop gold or potions etc which seems to be called from a elsewhere?

Copied my OnDeath script below which uses Grani’s idea.

I looked at nw_c2_default7 and can’t see anything about loot generation there?

Any ideas?

Thanks!

[https://neverwintervault.org/project/nwn1/script/granis-simple-loot-system]

void main()
{
ExecuteScript(“nw_c2_default7”, OBJECT_SELF);

//Get resrefs of loot and chances of drop specified in variables
int nL1 = GetLocalInt(OBJECT_SELF, “loot_01”);
string sL1 = GetLocalString(OBJECT_SELF,“resref_01”);

int nL2 = GetLocalInt(OBJECT_SELF, “loot_02”);
string sL2 = GetLocalString(OBJECT_SELF,“resref_02”);

int nL3 = GetLocalInt(OBJECT_SELF, “loot_03”);
string sL3 = GetLocalString(OBJECT_SELF,“resref_03”);

int nL4 = GetLocalInt(OBJECT_SELF, “loot_04”);
string sL4 = GetLocalString(OBJECT_SELF,“resref_04”);

int nL5 = GetLocalInt(OBJECT_SELF, “loot_05”);
string sL5 = GetLocalString(OBJECT_SELF,“resref_05”);

int nL6 = GetLocalInt(OBJECT_SELF, “loot_06”);
string sL6 = GetLocalString(OBJECT_SELF,“resref_06”);

int nL7 = GetLocalInt(OBJECT_SELF, “loot_07”);
string sL7 = GetLocalString(OBJECT_SELF,“resref_07”);

int nL8 = GetLocalInt(OBJECT_SELF, “loot_08”);
string sL8 = GetLocalString(OBJECT_SELF,“resref_08”);

int nL9 = GetLocalInt(OBJECT_SELF, “loot_09”);
string sL9 = GetLocalString(OBJECT_SELF,“resref_09”);

int nL10 = GetLocalInt(OBJECT_SELF, “loot_10”);
string sL10 = GetLocalString(OBJECT_SELF,“resref_10”);

int nStack = GetLocalInt(OBJECT_SELF, “loot_stack”);
string sStack = GetLocalString(OBJECT_SELF,“resref_stack”);
int nNumber = GetLocalInt(OBJECT_SELF, “amount_stack”);

//generate the loot; or not
if (d100()<=nL1)
{
CreateItemOnObject(sL1, OBJECT_SELF);
}

if (d100()<=nL2)
{
CreateItemOnObject(sL2, OBJECT_SELF);
}

if (d100()<=nL3)
{
CreateItemOnObject(sL3, OBJECT_SELF);
}

if (d100()<=nL4)
{
CreateItemOnObject(sL4, OBJECT_SELF);
}

if (d100()<=nL5)
{
CreateItemOnObject(sL5, OBJECT_SELF);
}

if (d100()<=nL6)
{
CreateItemOnObject(sL6, OBJECT_SELF);
}

if (d100()<=nL7)
{
CreateItemOnObject(sL7, OBJECT_SELF);
}

if (d100()<=nL8)
{
CreateItemOnObject(sL8, OBJECT_SELF);
}

if (d100()<=nL9)
{
CreateItemOnObject(sL9, OBJECT_SELF);
}

if (d100()<=nL10)
{
CreateItemOnObject(sL10, OBJECT_SELF);
}

if (d100()<=nStack)
{
CreateItemOnObject(sStack, OBJECT_SELF, nNumber);
}

}

Almost. :smiley: Random treasure gets generated in OnSpawn (nw_c2_default9), not in OnDeath (nw_c2_default7).

Try setting the integer X2_L_NOTREASURE to 1 on the module to deactivate all random treasure spawns on creatures via nw_c2_default9, or set it on the creature to deactivate random treasure spawns on that creature specifically.

Also, sidenote: You can use [code] insert code here [/code] for shiny code formatting in posts here.

1 Like

You’re truly my Guardian Angel here TheBarbarian!

Thank you very much :slight_smile:

1 Like

There is a drop code for craft-able items on death, like blood(it mostly for placables)
the function called craft_drop_items.