Move player to a random room of selected rooms? Help.

XanMag
Okay. I'll apologize in advance if this has been covered in a previous post, but I could not find it.

Here's the deal... I have a "ventilation system" maze in my game. Certain sections are only accessible if the player has achieved certain goals. In one of those sections is a gas that disorients the player. They crawl away, totally confused. Their head clears and they realize that they are in a different section of the ventilation system. At this point in the game, about 80% of the ventilation system has already been explored, but 20% has not. Another issue is that this player object cannot/will not go into the main section of the map (only the ventilation system). So, I need to move the player to an already explored section of the ventilation system only.

In short... Can I move the player to a random part of the ventilation system that they have already explored, but NOT into any unexplored part or the main part of the map (non-vent system) and what is the easiest way to accomplish this? I'm trying to learn coding for quest, but it is a painfully glacial process. Please keep that in mind!

Thanks again!!

Xanadu Magoo - The World's Only Hope

HegemonKhan
this is quite a bit more advanced, using ~working with~ lists, but here we go!, hehe

for your request, you want to use: Object Lists, NOT String Lists !!!

http://docs.textadventures.co.uk/quest/ ... tions.html

http://docs.textadventures.co.uk/quest/ ... lists.html
http://docs.textadventures.co.uk/quest/ ... tlist.html
http://docs.textadventures.co.uk/quest/ ... tlist.html
http://docs.textadventures.co.uk/quest/ ... t_add.html
http://docs.textadventures.co.uk/quest/ ... emove.html
http://docs.textadventures.co.uk/quest/ ... count.html
http://docs.textadventures.co.uk/quest/ ... tains.html
http://docs.textadventures.co.uk/quest/ ... mbine.html
http://docs.textadventures.co.uk/quest/ ... clude.html
http://docs.textadventures.co.uk/quest/ ... titem.html
http://docs.textadventures.co.uk/quest/ ... tsort.html
http://docs.textadventures.co.uk/quest/ ... nding.html

http://docs.textadventures.co.uk/quest/ ... reach.html
http://docs.textadventures.co.uk/quest/scripts/for.html
http://docs.textadventures.co.uk/quest/scopes.html
and the 'Gets' and "Alls' in the 'Functions' section~link of~for the wiki

http://docs.textadventures.co.uk/quest/ ... omint.html

the idea here is to add (and~or if you also want greater complexity to make them re-unaccessible: remove) the specific rooms that you want to now be 'accessible' to (or from) an ObjectList (as you make them accessible~unaccessible via within other 'event' scripting locations ~ means ~ methods), and ...

once you got this 'accessible room' ObjectList, then you can do the randomization iteration through it to choose one of the rooms that you'll go to.

so, for brief example:

game.accessible_rooms_objectlist = NewObjectList ()
list add (game.accessible_rooms_objectlist, room_1)
list add (game.accessible_rooms_objectlist, room_2)
etc etc etc

player.parent = ObjectListItem (game.access_rooms_objectlist, GetRandomInt (0, ListCount (game.access_rooms_objectlist) - 1))

about list index ordering:

Object_name.List_Attribute_name = split ("item1;item2;item3", ";")

example:

game.example_stringlist = split ("red;blue;yellow", ";")

0. red (item1)
1. blue (item2)
2. yellow (item3)

while 'yellow' is your 3rd item in the list, it's index catelog (think of like a library, such as organizing books alphabetically) ordering is actually '2', so if I want to get the 'yellow book' (yellow) from the 'library' (our list), I need to get 'book' (our item~Object~String of~witin the list) index of '2', NOT '3'

StringListItem (game.example_stringlist, 0) ====> red
StringListItem (game.example_stringlist, 1) ====> blue
StringListItem (game.example_stringlist, 2) ====> yellow
StringListItem (game.example_stringlist, 3) ====> ERROR, there is no 4th item!

ya, it's a bit confusing... starting at 0 instead of 1

and to add to the confusion...

ListCount (which we need to use for our randomization of dynamic lists to work), gets the quantity of items in the list: 3

however, for-with getting the specific item, we need it's index number:

[ListCount (game.example_stringlist) - 1] = 2 (index number)
[(3 items) - 1] = 2 (index number)

so... conceptually:

player.parent = ObjectListItem (game.accessible_rooms_objectlist, GetRandomInt (0, ListCount (game.accessible_rooms_objectlist) - 1) )
player.parent = ObjectListItem (game.accessible_rooms_object, GetRandomInt (0, your_counted_current_quantity_of_rooms_in_the_objectlist - 1) )
player.parent = ObjectListItem (game.accessible_rooms_object, GetRandomInt (0:index min, X:index max) )
player.parent = ObjectListItem (game.accessible_rooms_object, your_randomly_selected_item's_index_number_between_0_and_X)
player.parent = (your choosen~gotten Object ~ from using its randomly gotten index number in the above step)
player.parent = your_room_object_that_you're_moved_to

do you now understand this, or is it still confusing to you?

----------

here's many similiar things taking place:

---------

not sure if its compatible with the current version of quest, if you want to try to test~play~study it:

if you need help with any of this, let me know, and I'll help you do it

create a new game, go into the entire game code view, delete all of the code, copy and paste my code into it, and then just change the top-most codeline from this:

<asl version="540">

to this:

<asl version="550">
~ OR (not sure what version you're using, lol) ~
<asl version="560">

then, save your game file, and let me know if it works or not. If it doesn't, I'll get it converted so it'll work for you.

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

HK's 'explore' and 'travel' code (moving without using Exits):

(beware: along with lists, this also does use Dictionaries too, which are even more complex~confusing~difficult than are lists)

you 'explore' to discover a new location, and then once that location is discovered, you can then select to 'travel' to that location.

(the code is a bit poor~a bit extra complexity than it needed, I could make it better ~ just too lazy to do so lol, but it's functional)

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>eef801a1-4e6b-4b0a-bdbf-8f3ecfa8389c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns=</statusattributes>
<start type="script">
msg ("Important Note:")
msg ("Type in: help")
</start>
</game>
<object name="homeland">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<object name="grassland">
<inherit name="editor_room" />
</object>
<object name="plains">
<inherit name="editor_room" />
</object>
<object name="desert">
<inherit name="editor_room" />
</object>
<object name="tundra">
<inherit name="editor_room" />
</object>
<object name="swampland">
<inherit name="editor_room" />
</object>
<object name="mountains">
<inherit name="editor_room" />
</object>
<object name="forest">
<inherit name="editor_room" />
</object>
<object name="wasteland">
<inherit name="editor_room" />
</object>
<object name="coastland">
<inherit name="editor_room" />
</object>
<object name="hills">
<inherit name="editor_room" />
</object>
<command name="help_command">
<pattern>help</pattern>
<script>
help_function
</script>
</command>
<command name="explore_command">
<pattern>explore</pattern>
<script>
explore_function
</script>
</command>
<command name="travel_command">
<pattern>travel</pattern>
<script>
travel_function
</script>
</command>
<object name="data_object">
<inherit name="editor_object" />
<travel_string_list type="simplestringlist">homeland</travel_string_list>
<homeland_events_string_list type="simplestringlist">grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery</homeland_events_string_list>
<homeland_events_script_dictionary type="scriptdictionary">
<item key="grassland_discovery">
list add (data_object.travel_string_list, "grassland")
msg ("You've discovered the grassland! Now, you can travel to the grassland and explore it!")
</item>
<item key="plains_discovery">
list add (data_object.travel_string_list, "plains")
msg ("You've discovered the plains! Now, you can travel to the plains and explore it!")
</item>
<item key="desert_discovery">
list add (data_object.travel_string_list, "desert")
msg ("You've discovered the desert! Now, you can travel to the desert and explore it!")
</item>
<item key="tundra_discovery">
list add (data_object.travel_string_list, "tundra")
msg ("You've discovered the tundra! Now, you can travel to the tundra and explore it!")
</item>
<item key="swampland_discovery">
list add (data_object.travel_string_list, "swampland")
msg ("You've discovered the swampland! Now, you can travel to the swampland and explore it!")
</item>
<item key="forest_discovery">
list add (data_object.travel_string_list, "forest")
msg ("You've discovered the forest! Now, you can travel to the forest and explore it!")
</item>
<item key="mountains_discovery">
list add (data_object.travel_string_list, "mountains")
msg ("You've discovered the mountains! Now, you can travel to the mountains and explore it!")
</item>
<item key="hills_discovery">
list add (data_object.travel_string_list, "hills")
msg ("You've discovered the hills! Now, you can travel to the hills and explore it!")
</item>
<item key="wasteland_discovery">
list add (data_object.travel_string_list, "wasteland")
msg ("You've discovered the wasteland! Now, you can travel to the wasteland and explore it!")
</item>
<item key="coastland_discovery">
list add (data_object.travel_string_list, "coastland")
msg ("You've discovered the coastland! Now, you can travel to the coastland and explore it!")
</item>
</homeland_events_script_dictionary>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
game.turns = game.turns + 1
</script>
</turnscript>
<function name="help_function">
msg ("Type 'explore' to explore your area.")
msg ("Type 'travel' to travel to different areas.")
</function>
<function name="explore_function"><![CDATA[
switch (game.pov.parent) {
case (homeland) {
result_1 = ListCount (data_object.homeland_events_string_list) - 1
if (result_1 >= 0) {
result_2 = StringListItem (data_object.homeland_events_string_list,GetRandomInt(0,result_1))
invoke (ScriptDictionaryItem (data_object.homeland_events_script_dictionary,result_2))
on ready {
foreach (item_x, split ("grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery",";")) {
if (result_2 = item_x) {
list remove (data_object.homeland_events_string_list, result_2)
}
}
}
} else {
msg ("There seemingly is nothing left to explore in this area.")
}
}
}
]]></function>
<function name="travel_function">
show menu ("Where do you wish to travel?",data_object.travel_string_list,false) {
if (not game.pov.parent = GetObject (result)) {
game.pov.parent = GetObject (result)
} else {
msg ("You are already at this area.")
ask ("Try again?") {
if (result=true) {
travel_function
} else {
msg ("You realize that you need to discover a new area to travel to first, before you can travel to that place.")
}
}
}
}
</function>
</asl>

jaynabonne
Assuming you want to use standard room navigation (n,s,e,w, etc) and not a special transport function during normal game usage, I would have a master list of the possible rooms you could randomly move to (e.g. all the ones in the ventilation system) and then from that list, generate a new list that all have the "visited" attribute set. That attribute is set whenever someone has been in a room. Then you can randomly select from that restricted list.

XanMag
Well... Lol... Before I ask for more help, I think I'll take this chance to try and learn code a bit. It is a totally foreign language to me and I only understand about 2% of what you posted! =(

But, it'll give me a starting point. Does quest use JavaScript? (don't hate me for asking such a dumb question!) - I've just started using a basic online tutorial and I think it's helping a bit, but its written in JS and I don't want to waste my time. If you have other resources that will help me learn more, I'm game for it.

The second installment of Xanadu Magoo will be put on pause until I learn enough to help me be a better game writer!! Thanks for your continued help!

HegemonKhan
this stuff can be done via the GUI~Editor, but I myself just don't know much with using it to help you, but even with doing it via the GUI~Editor, it's still going to be complicated and confusing.

Did you at least understand the concept of doing it?

Initially accessible vent-maze rooms: room_1,room_2,room_3, etc etc etc

initially NON-accessible verntmaze rooms: room_99,room_98,room_97, etc etc etc

while exploring the above rooms (room_1,room_2,room_3), events happen (such as a 'examine' Verb for the room's wall ~ discovering a breeze upon your body, causing you to find a hidden door to the passageway that the breeze is coming from ~ we would have a script in this 'examine' Verb to add the new room discovered ~ our hidden passageway to our 'accessible rooms' list), which will make the non-accessible rooms, accessible, which is done via:

adding those non-acessible rooms to a list.

then, to randomly go to one of those now accessible rooms (room_99, room_98, room_97), we randomly select one of these rooms from our list. So, by using a list, we can add or remove rooms to or from the list, which is our way of determining which rooms are currently accessible (on the list) vs non-accessible (not on the list), and also, the list enables us to randomly select one of the rooms from the list, to go to it.

Marzipan
I love questions like this, gives me a chance to practice doing things I never even would have thought of. I just hope all these random little demo files I make actually come in handy one day for one of my own games.

This would be pretty simple in Adrift but I've never yet messed around with Quest's list very much. Should be a good project for tonight...

HegemonKhan
@Marzipan:

I can guarentee your 'code test game files' come in handy (mine do anyways) !!!
(though unlike me, make sure you start to organize them better as you start to get a lot of them, lol)

yep, should be a good challenge~practice for you, I think you'll be able to learn quest's lists (and maybe dictionaries too) quickly, as you seem a pretty competent coder already, hehe :D

-------

@XanMag:

Lists aren't too scary, but it does take a bit to understand and get used to them, and then to realize all of their applications, hehe.

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

Support

Forums