I've been looking into this for a while but I can't seem to find much. Basically what I'm trying to do is when a certain variable ("Sanity") is below a certain number, a dice roll or random number is pulled up every time you enter a room. Certain numbers pull up an effect and certain numbers do not. Is this possible? I don't know how particularly advanced something like this is. Think something like the morality meter in "I have no mouth" but instead of changing the ending, it makes certain things happen at random.
It is not clear for me which exactly part of the task was a problem for you, is it getting random number, or setting a condition? Maybe drawing meter on screen too? Please be more precise. (Usually it helps to set a task plan, writing all the points you want to do, but have trouble with)
Regarding dice rolls, Random function is usually the solution:
if (Sanity < 10)
{
int dice_roll = Random(100);
if (dice_roll < 25)
{
// do something
}
}
Reference: http://www.adventuregamestudio.co.uk/wiki/Game_/_Global_functions#Random
Quote from: Crimson Wizard on Mon 24/08/2015 23:00:46
It is not clear for me which exactly part of the task was a problem for you, is it getting random number, or setting a condition? Maybe drawing meter on screen too? Please be more precise.
Regarding dice rolls, Random function is usually the solution:
if (Sanity < 10)
{
int dice_roll = Random(100);
if (dice_roll < 25)
{
// do something
}
}
Reference: http://www.adventuregamestudio.co.uk/wiki/Game_/_Global_functions#Random
Dice Roll mainly. Also linking certain effects to certain numbers (Basically making the dice rolls act as "flags" for things like hallucinations or teleporting you into other rooms). Thanks, this was a pretty big help. When I get everything in what I'm planning done, I'll make a template of it and put it up as contribution to the community. I have other questions about making variables, but I think I can find that on the wiki.
Edit: I THINK I did it, not sure.
int player_Sanity=50
if (player_Sanity< 10)
{
int dice_roll = Random(100);
if (dice_roll < 25)
{
// do something
}
}