Author Topic: Randomize on open?  (Read 397 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Randomize on open?
« on: December 31, 2015, 04:35:44 pm »


               

Hi again!


 


okay I am wondering something, I have this quest that the player needs to get n item out of a chest....is it possible to have like for example 8 chests and randomize in which one of the chests the item it should be in?



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Randomize on open?
« Reply #1 on: December 31, 2015, 04:59:59 pm »


               

CreateItemOnObject("item_template", GetObjectByTag("ChestTag", Random(8)));

This is done before the player starts opening chests. It assumes there are 8 chests with the same tag. Random(8) returns an integer in the range 0-7, which is OK here, because GetObjectByTag numbers the instances as 0-7.


To make it more general, you could count the number of chests first, then use the actual number rather than 8.


 If you prefer unique tags, you could tag the chests as ChestTag0 - ChestTag7:


CreateItemOnObject("item_template", GetObjectByTag("ChestTag" +IntToString(Random(8))));

               
               

               
            

Legacy_bdtgazo

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Randomize on open?
« Reply #2 on: January 06, 2016, 12:18:01 am »


               

Hee hee, I'm doing something similar for a teleporter.  6 chairs in a room, one teleports you further along in the dungeon, the other 5 to "oh poop" situations, random which chair is the good one.  Great for splitting up parties.



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Randomize on open?
« Reply #3 on: January 13, 2016, 05:49:34 am »


               

works like a charm thanks!! '<img'>