Spawn Items in Shop

I’m using Slayers of Darkmoon loot generation system “Commche 2006”, and I would love to be able to OnOpenStore of the merchant, ADD specified number of random items to the shop.

The loot system’s main script gives me some useful commands that I think I can use:

// Generates a random weapon
// =======================================
// oMob = the creature that just died
// oSack = the object into which you will spawn the weapon
// iRange = the quality of the weapon: 1=lowest 5=highest
// SockChance = a % chance for the generated weapon to be socketed
// DamBroke = a switch to disable chance of damaged/broken weapon: 0=on 1=off
void DropWeapon(object oMob, object oSack, int iRange, int SockChance, int DamBroke);

Can I #include this main script into my store’s OnStoreOpen script (or just when the store is spawned?) and then use the above example in it to spawn a random weapon to the store? And how can I fire that off let’s say 20 times? I’ve got X number of commands like the above that I might want to have run several times for the merchant.

I’ve played around with just the following which feels wrong.

#include "sd_lootsystem"
#include "x2_inc_itemprop"
#include "nw_i0_generic"

void DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);

As always thank you for the suggestions!

Probably the script “DropWeapon” could be included into the on-open script of the shop. You need to find a substitute for “oMob”; no idea what it does. Maybe OBJECT_INVALID will work. And you need to make sure, that the shop-upgrade is only fired once.

I’ve tried this a few different ways. Here’s my latest script for the OnStoreOpen. I can figure out how to only allow that to fire off once later on.

#include "sd_lootsys_tools"
#include "sd_lootsystem"
#include "x2_inc_itemprop"
#include "nw_i0_generic"

void main()
{

    object oStore = OBJECT_SELF;
    object oMob = OBJECT_INVALID;

 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);
 DropWeapon(object oMob, object oStore, int iRange, int SockChance, int DamBroke);

}

I had to add another include for ‘sd_lootsys_tools’ before my script would compile. But no luck with any weapons being added to the store yet.

I found another script for this loot system that generates loot in a chest when opened. So I played around with that to see if I could get it to apply to the store instead. Not sure I understand how it’s defining the chest.

#include "sd_lootsys_tools"
#include "sd_lootsystem"
#include "x2_inc_itemprop"
#include "nw_i0_generic"

void main()
{
    object oPC = GetLastOpenedBy();
    string sTag = GetTag(OBJECT_SELF);

        DropWeapon(oPC, OBJECT_SELF, 1, 0, 1); break;
        DropWeapon(oPC, OBJECT_SELF, 2, 0, 1); break;
        DropWeapon(oPC, OBJECT_SELF, 3, 0, 1); break;
        DropWeapon(oPC, OBJECT_SELF, 4, 0, 1); break;
        DropWeapon(oPC, OBJECT_SELF, 5, 0, 1); break;

}

How can this be adjusted to use the store’s tag or how do I define the store?

That second one looks closer. You don’t need the break; parts nor the string sTag line at all.

If you put that in onstoreopen then OBJECT_SELF should be the store so it should just work.

The first one is broken. You need to call the function not re-declare it over and over. I.e. remove the “object” and “int” bits. And put in values for iRange etc. Look at the calls to DropWeapon on the second script and spot the differences with the ones in the first script.

1 Like

As soon as I saw the chest loot script with the values I instantly realized the first script was missing the values.

Removed the string line and all the breaks; from above and it worked!

Thanks so much for the direction and help!