You think after having written 3 games, I'd know how to do something simple like this, but I don't.
In my game, I've renamed the Ctr stat to Score. This stat keeps track of the points you've earned from achieving special objectives. At the end of the game, I want to display messages based on what your score is. I did something similar to this on my last game, but this time Score is a hero stat instead of a variable.
How do I make the hero stat Score into a variable I can use in an If statement (example below)?
variable(scorekeeper)
scorekeeper := getherostat(me, stat:score)
if (scorekeeper == 14), then,
begin
showtextbox(141)
#other stuff
end
I just used "scorekeeper" as the variable name to distinguish it from the name of the "score" stat; you can name it most anything.
Note also that using "me" in getherostat assumes you're counting the score of whatever player is at the first position in your party, to have it specifically target a hero, you'd use "findhero(hero:heroname)" in place of "me".
Minor nitpick, but note that "getherostat(me, stat:score)" does not return the value of the Score stat for the party leader. getherostat takes a party slot, not a caterpillar party slot, so using 'me' isn't correct if it's possible for the player to rearrange the party (slot 0 might be empty). So yes, using findhero is better, for example "find hero (leader)".
Last edited by TMC on Mon Sep 05, 2011 2:25 am, edited 1 time in total.
It took me years to learn as well! The rule is things related to the on-map walkabouts, except their graphics --- x/y/z position, direction, and speed --- are per-caterpillar party slot. Speed is an odd exception: heroes not in the active party don't have a speed. Nearly everything else acts on hero data, such as sprites, stats, name, spell lists, etc. and takes the party slot. As for hero definition ID, the only things which use it are party manipulation commands such as addhero... and unfortunately also un/lockhero, deletehero, and swapin/outhero which is just plain wrong and broken, because it means these commands don't support parties with multiple copies of the same hero ID. Ideally addhero and findhero (and swapbyname) would be the only commands using a hero ID.
variablename := current map
if (variablename == 1)
then, begin
show text box (1)
end
if (variablename == 2)
then, begin
show text box (2)
end
Except that's not right since "current map" doesn't really work like that. Any thoughts?