Random exit

falcon
19 Sept 2016, 21:47

How do I make an exit that goes to multiple possible rooms?


hegemonkhan
19 Sept 2016, 23:57

I believe Pixie has a library for this stuff (see the 'libraries and code samples' forum board), but the general idea/concept/logic is this:

have a list of possible rooms, choose one of those rooms randomly (using whatever combination of the 4 randomization functions: GetRandomInt, GetRandomDouble, DiceRoll, and/or RandomChance) and use the list functions for handling usage of that rndomly selected room, which you'll use as the room that you're moved ("exited") to. Pixie's library takes this further, handling room accessibility (if an exit is still locked/blocked, then it shouldn't be an option for you to be moved to --- which Pixie deals-with/handles in his/her library) too.

an quick simple brief example:

http://docs.textadventures.co.uk/quest/guides/using_lists.html

<object name="room"></object>

<object name="room_1"></object>
<object name="room_2"></object>
<object name="room_3"></object>

<object name="global_data_object">
  <attr name="room_list_A" type="objectlist">room_1; room_2; room_3</attr>
</object>

<object name="player">
  <attr name="parent" type="object">room</attr>
</object>

// scripting:

randomly_selected_room_variable = ObjectListItem (global_data_object.room_list_A, GetRandomInt (0, ListCount (global_data_object.room_list_A) - 1))
MoveObject (player, randomly_selected_room_variable)