Pulling up a random room??

Bochnari
04 Jan 2016, 07:06
Hey there everyone! So i just started toying around with Quest as i've been wanting to write an IF and i'm running through some things in my head, combat, equipment, yada yada yada, but the big thing that i need to be able to do is pull up a random room, or description, or something for a type of "explore" kind of thing, different places when you do it will give you different "scenes" and a possible chance to find loot, enemies, other areas, that kind of stuff. I'm sure it is possible to do, i'm just not figuring it out.

jaynabonne
04 Jan 2016, 07:33
Do you mean select randomly from a fixed set of rooms, or do you mean generate a random maze? (The phrase "pulling up" is a bit vague for me. :) )

HegemonKhan
04 Jan 2016, 18:44
yay! another RPG'er (or at least you want to make a game with RPG aspects anyways, lol)

unfortunately, this is the most complex type of game too, lots of complex coding, laughs.

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

basically, you put~add~set your desired rooms (or whatever Objects or Text) in an Objectlist Attribute (Objects as your list's items) or a Stringlist Attribute (Text as your list's items), (maybe) iterate through those items, and use at least one of the 4 Randomization Functions to select one of them.

this involves using lists and~or dictionary Attributes, which is difficult if you're new to quest and~or especially to coding, but if you're interested:

http://docs.textadventures.co.uk/quest/ ... lists.html (using lists guide)
http://docs.textadventures.co.uk/quest/ ... aries.html (using dictionaries guide)

and this isn't quite what I think you want, and it's a bit more advanced, but if you want to try to study it, here it is:

viewtopic.php?f=18&t=5138 (HK's, mine lol, "Explore" and "Travel" code: aka NOT using Exits to travel)

The 4 Randomization Functions:

http://docs.textadventures.co.uk/quest/ ... eroll.html (DiceRoll)
http://docs.textadventures.co.uk/quest/ ... omint.html (GetRandomInt)
http://docs.textadventures.co.uk/quest/ ... ouble.html (GetRandomDouble)
http://docs.textadventures.co.uk/quest/ ... hance.html (RandomChance)

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

here's a quick example of it (using code as it's quick ~ if you can't work with code, my apologies, but doing a step by step through using the GUI~Editor is a pain and isn't quick, laughs), involving just moving you to that room (we can get into doing other stuff instead, just let me know what specifically):

http://docs.textadventures.co.uk/quest/ ... arent.html (this is the same as the 'MoveObject ()' Function in the GUI~Editor's Script choices)

http://docs.textadventures.co.uk/quest/ ... split.html (the 'Split' Function is a quick way to create a List Attribute)

room_list = split ("room_1; room_2; room_3; room_4; room_5", ";")
random_selection = GetRandomInt (0, ListCount (room_list) - 1)
player.parent = StringListItem (room_list, random_selection)


and say you want to then display the description of that randomly selected room (instead of moving to it):

(hopefully this works, lol)

room_list = split ("room_1; room_2; room_3; room_4; room_5", ";")
random_selection = GetRandomInt (0, ListCount (room_list) - 1)
selected_room = StringListItem (room_list, random_selection
do (GetObject (selected_room), "description")


involving, "loot~drop~treasure chest~class", is similar but involves a bit more code work, and depending on whether you have a single specific "drop" or you want that "drop" to be a randomly selected item, as well.

Bochnari
05 Jan 2016, 06:34
oh gosh! that is so much information! SQUEEE!! I love information! And yes, what i want to do is basically have one "camp" if you will, then from there doing an explore option instead of moving room to room. Obviously at some points there will be the moving room to room aspect, but the basic thing that i need to be able to accomplish is exploring without already knowing the outcome.

It will take me some time to go through all of this and piece together what i do know with what i don't and make something even resembling a prototype, but trust me when i say i'll be posting it up for critique!

HegemonKhan
05 Jan 2016, 07:20
this is indeed a lot of "advanced" (for noob coders like myelf or non-coders, anyways) stuff, and I only gave some quick brief oversight of it and coding examples, so feel free to ask for much more detailed help or explanation with anything. Helping you do it through the GUI~Editor will take more time though, as it's a pain to write~post a guide through it, as opposed to code, laughs.

(let me know, if you know nothing of coding, so I don't keep scaring you with code in my posts. I'll slowly try to help you through using the GUI~Editor as best as I can, if I have to, though others can help you better with the GUI~Editor, as I'm not too familiar with it, having moved on into learning quest's coding)

The Pixie
05 Jan 2016, 09:37
I will echo HK and say it is not straight-forward!

Some asked about combat last month, so I will just direct you to what I said then:
viewtopic.php?f=10&t=5703&p=39301#p39274

Randomly generating a map adds a whole new level of complexity; I know because I have my own game, in beta, that attempts to do just that:
http://textadventures.co.uk/games/view/ ... hqw/deeper

The first thing you need is an algorithm. Think of how you would do it using paper, pencil and dice, and then try that out. Among other things, think about what happens when the map loops back on itself. Then translate that to code. I would suggest each room is named according to its coordinate position, so the player starts in room_0_0, and if he goes north, he gets to room_0_1. This will allow you to later check if a room already exists at a specific location.

I would also suggest you get familiar with types, and have a random room type that all your generated rooms are. Remember to create exits in both directions. Oh, and see if you can also implement all the scenery mentioned in random description, if you feel brave.