Aller au contenu

Photo

Randomize on open?


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Who said that I

Who said that I
  • Members
  • 492 messages

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?



#2
Proleric

Proleric
  • Members
  • 2 352 messages
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))));

  • Tarot Redhand, Shadooow et Who said that I aiment ceci

#3
bdtgazo

bdtgazo
  • Members
  • 53 messages

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.



#4
Who said that I

Who said that I
  • Members
  • 492 messages

works like a charm thanks!! :D