Hi.
I'm wanting to make it so if you keep using 'look' or a similar mouse mode on a hotspot or character, the message displayed changes each time.
So like if you keep looking at a mundane item, the narrator can gradually get more and more fed up with each reply, then eventually stop at one 'end' message that persists for the rest of the game. (Like an example is if looking at a door, it'll just say "It's a door" constantly after exhausting all the other mesages)
I'm sure it can be done in AGS as I've seen other games do it (Five Days a Stranger etc), but I can't figure out how to do it myself.
Does anyone have an idea on how to get it to work?
Cheer in advance.
I think you could create a variable who stores the number of times you looked at the hotspot. Each time you look at it, you increase this number and you create a condition who check this number and acts differntly depending on this value.
Raw example:
int hotspot_looked = 0
..
function hHOTSPOT_Look()
{
if (hotspot_looked == 0)
{
player.Say("first time dialog");
hotspot_looked = hotspot_looked + 1;
}
else if (hotspot_looked == 1)
{
player.Say("second time dialog");
hotspot_looked = hotspot_looked + 1;
}
...
else if (hotspot_looked == 10)
{
player.Say("last time dialog");
}
}
The variable could also be replaced with a custom property for the hotspot that you change each time :
hHOTSPOT.GetProperty("hotspot_looked") to retrieve the value
hHOTSPOT.SetProperty("hotspot_looked", NEW VALUE) to set the new value
Hope this helps you...
edit : corrections in the code following Crimson Wizard's remarks...
Just do not repeat "hotspot_looked = hotspot_looked + 1;" under every condition, put it once in the end of the function, and optionally reset number if you want them to start anew.
function hHOTSPOT_Look()
{
<... All the code ...>
// if you want them to repeat from the start again -
hotspot_looked++; // increase by 1
if (hotspot_looked > 10)
hotspot_looked = 0; // reset
// if you do not want them to restart
if (hotspot_looked < 10)
hotspot_looked++; // increase by 1
}
Another note: setting property only works for AGS 3.4.0 and higher, so if you are using older versions you'd have to stick to variable.
Quote from: NicolaGs on Sat 25/02/2017 13:01:04
I think you could create a variable who stores the number of times you looked at the hotspot. Each time you look at it, you increase this number and you create a condition who check this number and acts differntly depending on this value.
Raw example:
int hotspot_looked = 0
..
function hHOTSPOT_Look()
{
if (hotspot_looked == 0)
{
player.Say("first time dialog");
hotspot_looked = hotspot_looked + 1;
}
if (hotspot_looked == 1)
{
player.Say("second time dialog");
hotspot_looked = hotspot_looked + 1;
}
...
if (hotspot_looked == 10)
{
player.Say("last time dialog");
}
}
The variable could also be replaced with a custom property for the hotspot that you change each time :
hHOTSPOT.GetProperty("hotspot_looked") to retrieve the value
hHOTSPOT.SetProperty("hotspot_looked", NEW VALUE) to set the new value
Hope this helps you...
Thank you.
I've given this a try in my current project, however all the comments are played one after another in one go for some reason.
I think I'm doing something wrong.
Change second and every following "if" to "else if".
(Last "if" could be changed to just "else")
Also, I recommend moving "hotspot_looked = hotspot_looked + 1;" line to the very end of the function, as I showed in example in my reply (see above).
Quote from: DJ_Gora on Sat 25/02/2017 13:28:50
however all the comments are played one after another in one go for some reason.
I think I'm doing something wrong.
Of course, I did it too quickly. The fact that I incremented the variable in each If statement is
dumb since each time the value is incremented and so the following condition is always true... Crimson Wizard gave you the right advice.
I edited my previous post.
I got it working, Crimson Wizards modifications helped.
Now my character and the narrator can have witty banter until the cows come home.
Thanks a lot for the help, guys!
Just a quicky footnote...
I've recently started using Game.DoOnceOnly... so you could spare a variable there...
function hHOTSPOT_Look()
{
if (Game.DoOnceOnly("1st time look at hotspot")
{
player.Say("first time dialog");
}
else if (Game.DoOnceOnly("2nd time look at hotspot")
{
player.Say("second time dialog");
}
...
else // Last time you only need a else
{
player.Say("last time dialog");
}
}
Since Game.DoOnceOnly only fires up once in game, it will automatically turn that If/if else into false, after it was run the first time. ;)
Cassiebsg's way is probably neater if you want to avoid having a huge list of variables - though definitely make sure you have a unique name for each Game.DoOnceOnly, for example:
function hTable_Look()
{
if (Game.DoOnceOnly("Room3_hTable_Look1")
{
player.Say("first time dialog");
}
else if (Game.DoOnceOnly("Room3_hTable_Look2")
{
player.Say("second time dialog");
}
...
else // Last time you only need a else
{
player.Say("last time dialog");
}
}