Some thoughts and questions on randomized trophy heads
Talon
13 Dec 2016, 17:56Have a element of my game I did when I first started that i'd like to update and make somewhat more elegant and effective. The basic concept is this, an old hunting lodge that has trophy heads on the wall, each game I'd like to have them change their look each game, so could be from a selection bear, deer, wolf, lion, elephant, rhino head, and so on)
Now while I've had no trouble setting it up using the random text in the processor, the only problem is each time a person looks at the trophy head it will randomly choose again, I know many people who'll look at things multiple times. I'd much rather the description be static throughout the play session.
A complex method I thought might work is using a string list, take a value from it, set it to the heads description and set the script to only fire the first time its looked at. It seems there should be an easier way
What I'd like to eventually have is the trophy head to also show the species that could be linked to the description.. I think that would be using something like a switch, “if alias has deer, then description “Deer”)
Pixie's wonderful generating stuff post though somehow lets me simply provide the options in text or a list attached to an item and then the text is kept static through the play session, also letting you have some random in the alias as well(could be easily used to describe the condition of the trophy head)
Talon

TinFoilMkIV
13 Dec 2016, 20:05try http://docs.textadventures.co.uk/quest/scripts/firsttime.html to pick a random trophy then base the description off whatever value that pulls. That way any followup looks can pull the generated value to keep the description static per playthrough.
hegemonkhan
14 Dec 2016, 02:59indeed, using, 'firsttime/otherwise' Function, and using String/Object List Attributes, along with the 'GetRandomInt' Function and the 'StringListItem/ObjectListItem' Function, to select an item from the String/Object List Attribute, and then to store/save that into a String/Object Attribute, which you can then use to display the needed information, either just based from the string, or in using Objects, and if needed, using string concatenation for the displayment.
an example, using an Objects design:
<object name="old_hunting_lodge_room_object">
</object>
<object name="trophy_room_object">
<attr name="parent" type="object">old_hunting_lodge_room_object</attr>
<object name="trophy_head_object">
<attr name="alias" type="string">trophy head</attr>
<attr name="look" type="script">
firsttime {
trophy_data_object.trophy_object_attribute = ObjectListItem (trophy_data_object.trophy_objectlist_attribute, GetRandomInt (0, ListCount (trophy_data_object.trophy_objectlist_attribute) - 1))
invoke (trophy_data_object.trophy_object_attribute.look) // or, you can use: do (trophy_data_object.trophy_object_attribute, "look")
} otherwise {
invoke (trophy_data_object.trophy_object_attribute.look) // or, you can use: do (trophy_data_object.trophy_object_attribute, "look")
}
</attr>
</object>
</object>
<object name="trophy_data_object">
<attr name="trophy_object_attribute" type="object">unknown_object</attr>
<attr name="trophy_objectlist_attribute" type="objectlist">bear_trophy_object;deer_trophy_object;wolf_trophy_object;lion_trophy_object;elephant_trophy_object;rhino_trophy_object</attr>
<object name="bear_trophy_object">
<attr name="alias" type="string">bear trophy head</attr>
<attr name="species_string_attribute" type="string">bear</attr>
<attr name="look" type="script">
msg ("YOUR_" + UCase (this.species_string_attribute) + "_DESCRIPTION")
</attr>
// etc Attributes if you want/need/have them
</object>
<object name="deer_trophy_object">
<attr name="alias" type="string">deer trophy head</attr>
<attr name="look" type="script">
msg ("YOUR_" + UCase (this.species_string_attribute) + "_DESCRIPTION")
</attr>
// etc Attributes if you want/need/have them
</object>
// etc trophy head Objects of yours
<object name="unknown_object">
<attr name="alias" type="string">unknown alias</attr>
<attr name="species_string_attribute" type="string">unknown species</attr>
<attr name="look" type="script">
msg ("YOUR_" + UCase (this.species_string_attribute) + "_DESCRIPTION")
</attr>
// etc Attributes
</object>
</object>
let me know if you need any help understanding this or need anything explained, and/or if it doesn't work... if there's any errors...
Pixie can create a much better design, and likely add in the editor controls for it, but it's an example for you, even if not the best.
Talon
14 Dec 2016, 03:54I'll take a look at this sometime this evening or tomorrow morning, did get a workable placeholder(without changing the aliases of the objects) using the Pickonestr function(that might have been one of yours) and a prepopulated stringlist, the first time the script picks one of the descriptions, then tells the player what it is, the followups just repeat the picked item from the list.
The Pixie
14 Dec 2016, 08:19I would create an object for each trophy head, in another room inaccessible to the player, and then have a script that runs before the player enters the room. Pick one at random and move it into the room. That way the player can do X DEER, because the deer head will be there.
That script could also modify the room description. Set it up originally for, say, the wolf trophy, but replace the word wolf as appropriate ("this" is a stand-n for the object the script is attached to, in this case the room):
this.description = Replace (this.description, "wolf", "deer")
Talon
14 Dec 2016, 18:15The only problem with that Pixie is not from a technical angle but clutter, if i have multiple heads in the lodge, would have to have multiple of each type in the storeroom(Where i keep all my things that get moved in and out, locked off from players of course) or have the risk of a trophy head moving as its triggered again. so for 3 heads in the lodge i'd need a wolf wolf1 wolf2...right?. Just very many of heads for the effect. The larger the game gets the slower it seems to load... maybe i'm making things to big.
The room description angle is very interesting(for this and rather many of other projects I have using random stuff), not sure i've ever used that sort in my games so far.

TinFoilMkIV
14 Dec 2016, 18:55If you want several heads as a single object then I'd create an attribute for each head and randomly assign them the first time they're looked at or otherwise would be displayed. You could use a list to store the descriptions for each possible head then display them in order based on your head variables.
ie: pseudo code
firsttime {
head1 = (random)
head2 = (random)
head3 = (random)
}
//description goes here
OutputTextNoBr ("On the left you see " + StringListItem (this.list, this.head1))
OutputTextNoBr ("Next to it there is " + StringListItem (this.list, this.head2))
msg ("To the right is mounted " + StringListItem (this.list, this.head2))
EDIT: the room description bit suggested by The Pixie is actually a great tool to randomize environments without object clutter but you lose the interactivity or more detailed descriptions for player inspection. That said if you're aiming for high quality you could use both including altered room descriptions to match variable objects.
Alternatively you can use in room descriptions of items to blend them into the description without having to modify it, although you get the limitation of having the objects have to be at the end of the actual description, which depending on writing style and ability may or may not be an issue.
The Pixie
14 Dec 2016, 20:27Why do you need three wolf heads? Surely you just need the room description to say there are three. Or can the player take them?
So have three heads in the room, and in the script that triggers when the player enters the room, modify their aliases and descriptions.

TinFoilMkIV
14 Dec 2016, 20:33At least in terms of mine, I was assuming that it was desired for the heads to be different animals. Granted my specific example has nothing preventing duplicates being selected.
hegemonkhan
14 Dec 2016, 21:08my code handles/addresses what you'r discussing in these latest posts... though if you need to actually "physically" use the trophy heads, then some more coding is needed, such as in terms of simplicity, the 'Clone and Move (something like this)' Function.
I have a single trophy Object in a room, and within an internal storage/data room, I have the various trophy head Objects. The code handles the randomization of the various trophy heads without doing any moving of Objects.