Easy Random Event generator

A very easy random event trigger
simply put this into a Function and trigger when needed. Obviously have to change names around but i hipe you get it.

events = NewStringList()
if (player.class="Adventurer") {
  list add (events, "largeruins")
}
list add (events, "bear")
list add (events, "villager")
list add (events, "findresource")
switch ((PickOneString(events))) {
  case ("bear") {
    // script here
  }
  case ("village") {
    // Script
  }
}

basically you can run IF statements to add to the list then set up what happens if the item is picked.


Nice way to do it.

Depending on the situation, it might be worth using a scriptdictionary rather than a switch block. You could put a scriptdictionary of all possible events on the game object, and use the same code to determine which events are currently accessible. Also, you could use Split to quickly add the events that are always available.

So it would look like:

events = Split ("bear;village;treasure")
if (player.class="Herbalist") {
  list add (events, "rareflowers")
}
if (player.health < 90) {
  list add (events, "healingshrine")
}
invoke (ScriptDictionaryItem (game.randomevents, PickOneString(events)))

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums