Random flavour text

kurto321
I'll get straight to the point. Apologies if this is a common question or if there's a simple solution

The player moves to a road in a city. Upon entering the room, I'd like to print a line of flavour text describing something that's happening (such as 'some children run past' or 'a man walks past briskly'), but I'd like it to be randomly chosen from multiple lines which would be typed up by me.

So far the only way I can think of to do this would be a 'when entering the room' script that has an 'if' script attached, with a 10% chance of printing the line, else a 10% chance of printing a different line, that has another 'if' attached to that for the next one...etc.

Is there a simpler way to do this? What I'm thinking is a script that lets you add multiple text boxes with a modifyable percentage chance of printing one of the text boxes (chosen at random) upon entering the room.

Hope I explained adequately.

jaynabonne
There is a "rnd" text processor command, where you give it the sequence of strings and it picks a random one. If you look in the text processor documentation, you should see it. (I'm sorry I don't have the link.)

kurto321
Ah, thank you! I found the documentation and worked out how to use it the way I've been needing. And just now I realised I don't even need to use code view! Thanks again :)

jaynabonne
Yes, the text processor can be quite handy. :)

The Pixie
Bear in mind some people will try to look at the man or the children. If you choose to handle that, it gets rather more complicated...

HegemonKhan
there's actually some libraries by Pixie and others, on the same effects, but in regards to npcs/dialogue dynamic'ism (randomization flavor'ing), vs a location-description dynamic'ism (randomization falvor'ing) that you're asking for, so you could take a look at them for ideas on how to do such stuff. But, this is not easy stuff to do, and gets quite messy/complex/complicated, unless you're a really good programmer, with a really good design/system for/of it.

-------

As Jay mentioned, the simpliest method is to use the '(inline-if-ternary) random' text processor commands in your 'msg' Scripts (GUI~Editor: 'print a message' Script).

XanMag
You could, if so obliged, use the following command to draw randomly from a string list you have created on the attributes panes on your object.

n = GetRandomInt (0, ListCount (Blerk.jokes) - 1)
msg ("Blerk thinks for a moment and says, " + StringListItem(Blerk.jokes, n))


Just replace my object 'Blerk' and attribute 'jokes' to whatever your object and attributes are.

Also, to solve the problem Pixie persented, you could implement a script dictionary if you are courageous enough. Here is a link to a thread that I eventually figured out. If you are interested, I'll share my working script dictionary so you can get an idea how to do it! Let me know!

viewtopic.php?f=10&t=5873

HegemonKhan
@ XanMag (and SeaChameleon):

(Randomization + Stringlists + If Scripts) and (Randomization + Scriptdictionaries) produce the same results for what you want, just different ways of doing them (essentially, for what you want to do, the Scriptdictionary just combines Stringlists+If Scripts into "one process", a Scriptdictionary). As can be seen/demonstrated below:

Randomization + Stringlist + If Scripts:

game.combat_action_stringlist = split ("attack; defend; cast/magic; item; escape", ";")

// 'monster' Object's 'fight' Verb:

monster.AI_combat_choice_string = StringListItem (game.combat_action_string, GetRandomInt (0, ListCount (game.combat_action_list) - 1))
if (monster.AI_combat_choice_string = "attack") {
player.current_life = player.current_life - monster.damage
}
else if (monster.AI_combat_choice_string = "defend") {
monster.defense = monster.defense * 2
}
// etc etc etc etc 'else ifs', for: cast/magic, item, escape

// tecnically, we wouldn't do the Stringlist for the AI's combat choices, as the Stringlist is only needed for humans to know their choices ("attack=0, defend=1, cast/magic=2, item=3, escape=4" to decide (aka, it wouldn't even be using randomization to begin with), whereas the computer/AI doesn't need to know that "0 = attack", as it is using randomization, as it just "decides" (does) what the randomization selects (0-4), it doesn't need to know that '0' is "attack, '1' is "defend", etc etc etc


is the same as:

Randomization + Scriptdictionary:

<game name="xxx">
<attr name="AI_combat_action_scriptdictionary" type="scriptdictionary">
<item key="0">
player.current_life = player.current_life - monster.damage
</item>
<item key="1">
monster.defense = monster.defense * 2
</item>
// etc etc etc 'item keys' for: cast/magic, item, escape
</attr>
</game>

// 'monster' Object's 'fight' Verb:

invoke (ScriptDictionaryItem (game.AI_combat_action_scriptdictionary, GetRandomInt (0, DictionaryCount (game.AI_combat_action_scriptdictionary) - 1)))

Anonynn
You could do something like..

{once:{random:children walk by and then a man a few moments later:man walks by and then some children go running past later}}

object
man (type look description(first time))
children (type look description(first time))
*make then not visible.

Then if the player types.
Look at man...it'll bring up his description.

Afterward, you can add something to the "otherwise" script part of it, remove object "man" and type a little message that says he's too far away now to see or something like that. You can do the same thing with the children too.

Just an idea!

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

Support

Forums