Ambrosia Garden Archive
    • Number generator anywhere?


      I ran across this last night and couldn't find anything within Coldstone(so I made a
      hack around it which while it works, it is ugly and isn't as precise as I'd like). Is
      there any way to generate a random number within a given parameter and assign it to
      a value(such as, but not limited to, a global variable)?

      In my instance I wanted a shopkeeper to have a variance of items to sell. Since I haven't
      found a way to have the shop program itself generate items at random, I created 5
      different shop locations, each selling similar but varied items. I then set up a
      global variable called gb_randomshop. Since I didn't think the shop should be different
      if the player just clicks on "Leave" and then enter's back in, I wanted a load call for
      the zone, so that when the zone loads the randonshop variable would be rolled a number
      0-4, and based on that number the appropriate shop would be loaded when the player asks
      to see the shop.

      Well, obviously I couldn't find anything like this in the Coldstone engine. The only
      thing close that I could find was the random action event call. So what I did was this:

      When the zone loads I call an event called "roll random shop." Within it it looks like
      this:

      random action event: If (random roll < 20) { (gb_randomshop = 0); }
      else
      random action event: If (random roll < 20) { (gb_randomshop = 1); }
      else
      random action event: If (random roll < 20) { (gb_randomshop = 2); }
      else
      random action event: If (random roll < 20) { (gb_randomshop = 3); }
      else
      random action event: If (random roll < 20) { (gb_randomshop = 4); }

      Then I have a conditional on the npc who is the shopkeep, so that when the shop is called
      for I run through a check on gb_randomshop and based on its value I send the player to
      the correct shop.

      As I mentioned, the above method does work. gb_randomshop is changing as the zone loads
      which is what I want. However, those stataticians out there probably realize that the
      chances of gb_randomshop being chosen as a given number is not an even 20% chance
      all the way through, as it would be if I could just call an event that did a:
      random roll: roll a die between (x),(y) and assign value to (z) -- Where x,y are
      integer values and z is a variable to set(anywhere from globals to stats, etc).

      If there is something like this available and I just missed it, please let me know.

      Thanks

      ------------------
      Surprise! You are the lucky winner of random I.R.S. Audit! Just type
      in your name and social security number. Please remember that leaving
      the room is punishable under law:
      Name_______________________ SSN# --___

    • Quote

      Originally posted by Stark Bledfast:
      **I ran across this last night and couldn't find anything within Coldstone(so I made a
      hack around it which while it works, it is ugly and isn't as precise as I'd like). Is
      there any way to generate a random number within a given parameter and assign it to
      a value(such as, but not limited to, a global variable)?
      **

      Yes: use "Change Global", and set the variable called as you like as "Random" (the last button, after, set, add, subtract, multiply, and divide (which should be Integer divide)). In the value field, set any number you like (or even a variable set to some value), and you will have a random number between 0 and the number you set - 1, inclusive.

      Hope this helps,

      Alois

      ------------------

    • You're kidding me, right? Random is in the change global call? Crud, I looked in there
      initially...

      I feel silly.

      Thanks. 🙂

      ------------------
      Surprise! You are the lucky winner of random I.R.S. Audit! Just type
      in your name and social security number. Please remember that leaving
      the room is punishable under law:
      Name_______________________ SSN# --___