Post new topic    
Liquid Metal Slime
Send private message
get hero stat 
 PostSun Sep 04, 2011 5:16 pm
Send private message Reply with quote
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)?

Code:

if (score == 14)
then, begin
show text box (141)
end
Slime Knight
Send private message
 
 PostSun Sep 04, 2011 7:09 pm
Send private message Reply with quote
You should be able to do it like this:

Code:

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".
SPELLSHARD: THE BLACK CROWN OF HORGOTH now COMPLETE! Grab it today!
Metal King Slime
Send private message
 
 PostMon Sep 05, 2011 2:24 am
Send private message Reply with quote
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)".
Slime Knight
Send private message
 
 PostMon Sep 05, 2011 6:42 am
Send private message Reply with quote
Thanks, TMC. After all these years, I still get unclear on which commands take party slot, which take caterpillar slot, and which take hero ID... @_@
SPELLSHARD: THE BLACK CROWN OF HORGOTH now COMPLETE! Grab it today!
Metal King Slime
Send private message
 
 PostMon Sep 05, 2011 8:22 am
Send private message Reply with quote
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.
Liquid Metal Slime
Send private message
 
 PostMon Sep 05, 2011 3:42 pm
Send private message Reply with quote
Thanks for your help Harlock. I got it working.
Liquid Metal Slime
Send private message
 
 PostThu Sep 08, 2011 1:08 am
Send private message Reply with quote
Howdy. I've got another one. I want to make an menu option that displays a different text box depending on which map you are on.

How would I use the "current map" command to make it into an "if" statement. For instance...

Code:

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?
Liquid Metal King Slime
Send private message
 
 PostThu Sep 08, 2011 1:23 am
Send private message Reply with quote
Willy Elektrix wrote:

Except that's not right since "current map" doesn't really work like that. Any thoughts?


Actually, yes, current map does work like that.

The script you wrote should work fine. Although you can actually simplify it a bit further and not use a variable:

Code:

if (current map == 1)
then, begin
show text box (1)
end

if (current map == 2)
then, begin
show text box (2)
end
Display posts from previous: