Randomised content, objects, attributes

Hey guys,

I'm new to this textadventure/Quest thing but have a story or journey in my mind i'd like to tell. After reading and watching several tutorials I'm still not sure whether the following things are possible in Quest, for example:

Lets say there is a room. Inside are 3 containers (a,b,c). Every time, I open one container for the first time, it shoulf contain randomised items (x,y,z). After opening it, the content stays the same, like a real container.
Box A should be more likely to contain items from x, than y and z. Box b should contain more likely items from z, than x and y and so on. So every box has a different chance to contain different content based on percentage (?!) every time opend for the first time. I hope this makes sense Oo.

Is it possible to create some sort of database, where I store all items, sorted by different categories (material, use, weight, etc) so the boxes a,b,c can use that data to create their contents?

Thanks a lot!
karg


A way to simplify this might be to not try to randomize it on first open. Just randomize it at startup. It will make no difference to the player (they won't know when it happens), and the effect will be the same.


Sounds good. So in general it is possible?


Yes what you want to do is possible. For the randomization you can use RandomChance to create a percent chance of something happening, or for even greater control I'd personally use GetRandomInt and then check it against my own numbers.

As for item categories you have a couple options there as well. The first would be object types, which allow you to assign a specific type to the object which you can check for as well as allowing you to add specific attributes to the type itself that all objects of that type will automatically be given.

You can also store items outside the game area ie: in a room or object that the player can never reach or see. Then use other objects for categories to hold the items themselves, kinda like a filing cabinet or the way folders work on a computer. I use this one when I quite a bit when I have a lot of scripts controlling a certain aspect of the game. ei: object named control -> contains object named combat -> combat has all the scripts and attributes for combat related things.

Now from your description it sounds like you want to create more sorted lists of your objects more than specific categories. What you'll want for this would be either a list or a dictionary. They are very similar in function however dictionary items aren't specifically ordered, so you'll likely want a list. Fortunately the sorting part is fairly easy as there is a function just for that, ObjectListSort

For the listing and sorting I'd also include those in the game startup then you can reference those lists as needed.


Great, thank you very much!

I'll have a look into all your suggestions. Long way ahead...


Hello Karg, I make tutorial videos for quest's GUI editor and actually made a randomized item spawner here's the video https://www.youtube.com/watch?v=BUGNbe2--Yk
if you have any questions Ill be glad to help any way i can.

Hope it helps

Mike


Hey Mike,

thanks for the link, I'll check it out!

Edit: very useful, for a noob like me, subbed to your channel aswell.


Ah, I'm too late to help

Nice channel though onimike, thanks for the link


I'll just collect any information I can get, so maybe you have something in mind the others didn't mention. Especially onimikes videotutorials are every helpful, because I can just redo the shown things and try to understand them instead of just reading through everything and figure it out on my own [not saying I don't appreciate the others for their help ;)]. I find it very hard to get into all this stuff without any experience in coding(programming whatsoever.


it takes time to learn to code, but the problem is that it's much easier and faster when helping people, via with code, than by trying to explain step by step what/how to do it via the GUI/Editor.

This type of stuff you want to do, involves using List Attributes, so that you can then iterate ('foreach' item, possibly do some action/script) through the List Attribute. Unfortunately, List Attributes is quite a step up, especially, if you haven't even learned the basic Attributes' (Boolean, Integer, Double, String, and/or Object Attributes) and the 'if' Script usage, these two being the "bread and butter" of coding / game making.


there's 4 built-in Randomization Functions:

DiceRoll ( http://docs.textadventures.co.uk/quest/functions/corelibrary/diceroll.html )
GetRandomInt ( http://docs.textadventures.co.uk/quest/functions/getrandomint.html )
GetRandomDouble ( http://docs.textadventures.co.uk/quest/functions/getrandomdouble.html )
RandomChance ( http://docs.textadventures.co.uk/quest/functions/corelibrary/randomchance.html )


useful links:

http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/tutorial/
http://docs.textadventures.co.uk/quest/guides/
http://textadventures.co.uk/forum/samples
http://docs.textadventures.co.uk/quest/guides/character_creation.html

List/Dictionary Attributes and etc related stuff for them:

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

http://docs.textadventures.co.uk/quest/scripts/foreach.html

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk


using the 'GetRandomInt' to select an item from a group of items, and then using 'RandomChance' to determine whether you actually get/use/do-whatever-with that selected item or not, is a great combination for many such RPG type of stuff (treasure chests/monster drops, and many other creative applications).

however, your describe desired design is a bit different than this.


for your design, here's a quick "my example" look at it (probably has some errors and/or due to not knowing how some things work, incomplete, and not fully scalable -- but some framework exists for making it more scalable):

(this does, or attempts to do --- lol, most/all of what TinFoil is talking about in his/her post above)

<game name="example_game">
  <attr name="start" type="script">
    chest_ABC_initialization_function
  </attr>
</game>

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

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

<object name="chest_ABC_data_object">
  <attr name="chest_ABC_objectlist_attribute" type="objectlist">chest_A_object;chest_B_object;chest_C_object</attr>
  <attr name="ABC_objectlist_attribute" type="objectlist">A_object;B_object;C_object</attr>
  <object name="unknown_object">
  </object>
  <object name="A_object">
    <inherit name="item_type" />
  </object>
  <object name="B_object">
    <inherit name="item_type" />
  </object>
  <object name="C_object">
    <inherit name="item_type" />
  </object>
  <object name="chest_A_object">
    <inherit name="chest_ABC_type" />
  </object>
  <object name="chest_B_object">
    <inherit name="chest_ABC_type" />
  </object>
  <object name="chest_C_object">
    <inherit name="chest_ABC_type" />
  </object>
</object>

<type name="chest_ABC_type">
  <inherit name="container_closed" />
  <attr name="parent" type="object">room</attr>
  <attr name="displayverbs" type="listextend">my_open_script</attr>
  <attr name="item_object_attribute" type="object">unknown_object</attr>
  <attr name="my_open_script_attribute" type="script">
    firsttime {
      CloneObjectAndMove (this.item_object_attribute, this)
      this.isopen = true
    } otherwise {
      this.isopen = true
    }
  </attr>
</type>

<type name="item_type">
  <take />
  <drop />
</type>

<verb>
  <property>my_open_script_attribute</property>
  <pattern>my_open_script_attribute</pattern>
  <defaultexpression>You can't open that!</defaultexpression>
</verb>

<function name="chest_ABC_initialization_function">
  foreach (object_variable, chest_ABC_data_object.chest_ABC_objectlist_attribute) {
    if (object_variable = chest_A_object) {
      if (RandomChance (90)) {
        object_variable.item_object_attribute = A_object
      } else if (RandomChance (60)) {
        object_variable.item_object_attribute = B_object
      } else if (RandomChance (30)) {
        object_variable.item_object_attribute = C_object
      } else {
        object_variable.item_object_attribute = ObjectListItem (chest_ABC_data_object.ABC_objectlist_attribute, GetRandomInt (0, ListCount (chest_ABC_data_object.ABC_objectlist_attribute) - 1))
      }
    } else if (object_variable = chest_B_object) {
      if (RandomChance (90)) {
        object_variable.item_object_attribute = B_object
      } else if (RandomChance (60)) {
        object_variable.item_object_attribute = C_object
      } else if (RandomChance (30)) {
        object_variable.item_object_attribute = A_object
      } else {
        object_variable.item_object_attribute = ObjectListItem (chest_ABC_data_object.ABC_objectlist_attribute, GetRandomInt (0, ListCount (chest_ABC_data_object.ABC_objectlist_attribute) - 1))
      }
    } else if (object_variable = chest_C_object) {
      if (RandomChance (90)) {
        object_variable.item_object_attribute = C_object
      } else if (RandomChance (60)) {
        object_variable.item_object_attribute = A_object
      } else if (RandomChance (30)) {
        object_variable.item_object_attribute = B_object
      } else {
        object_variable.item_object_attribute = ObjectListItem (chest_ABC_data_object.ABC_objectlist_attribute, GetRandomInt (0, ListCount (chest_ABC_data_object.ABC_objectlist_attribute) - 1))
      }
    }
  }
</function>

Thats quite some information, holy.. much appreciated, really! I hope you don't expect me to dig through all that in just a couple of days. I just have little time to spare for my newly discovered ambition to create a textadventure. I guess I do need a cheap windows laptop after all (sitting in front of a mac most of the time) to be able to use the non-browser version more frequently in order to get things done.

Honestly, I'm impressed with the response to my initial question, especially due to my missing experience in this whole thing. But I'm repeating myself, thanks for your patience and kindness.


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

Support

Forums