Author Topic: Random Loot, stacks  (Read 365 times)

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Random Loot, stacks
« on: November 16, 2013, 10:25:30 am »


                Just a quickie, how will I get my random loot script to spawn a random number of stacked things (like gold coins) and determine something like... spawn 10 - 100 normal nwn gold pieces ?
I can make it grab a total stack size of a certain item, but that'll create too many instances of same item and/or too much of the said item in the chest. (For example, instead of random number, I get 999 item gold coins (worth 100 each) and that's waaaaay too much loot '<img'>
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Random Loot, stacks
« Reply #1 on: November 16, 2013, 06:32:38 pm »


               So you're saying you want to give a creature a random amount of gold between, say, 10-100 gold pieces?
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Random Loot, stacks
« Reply #2 on: November 16, 2013, 08:41:55 pm »


               Creature or a container (chests mainly, but creatures would be great too) I'm using a system that picks stuff based on a dice roll, from source chests that I stuff in an unaccessible area.
But the basic's the same. I can create instances that have a certain amount of things in a stack, but I'd rather have a script get stacked items like gold, to a certain amount (anything between 1 and 100 for example).
               
               

               


                     Modifié par JerrodAmolyan, 16 novembre 2013 - 08:42 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Random Loot, stacks
« Reply #3 on: November 16, 2013, 10:03:07 pm »


               If you put this script in an OnOpened event for a container, it spawns 50-100 gold each time you open it.  If you want to fire the script from something besides the object, obviously you'd need to replace OBJECT_SELF with GetObjectByTag or something.  Is this roughly what you wanted?

void main()
{
    int nRand = Random(51) + 50;
    CreateItemOnObject("nw_it_gold001", OBJECT_SELF, nRand);
}