get hero stat

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

get hero stat

Post by Willy Elektrix »

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: Select all

if (score == 14)
then, begin
show text box (141)
end
Last edited by Willy Elektrix on Sun Sep 04, 2011 5:16 pm, edited 1 time in total.
User avatar
KF Harlock
Slime Knight
Posts: 194
Joined: Wed Oct 22, 2008 10:45 am
Location: East Coast USA
Contact:

Post by KF Harlock »

You should be able to do it like this:

Code: Select all

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! <a href="http://www.slimesalad.com/forum/viewgam ... 4363">Grab it today!</a>
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

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.
User avatar
KF Harlock
Slime Knight
Posts: 194
Joined: Wed Oct 22, 2008 10:45 am
Location: East Coast USA
Contact:

Post by KF Harlock »

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! <a href="http://www.slimesalad.com/forum/viewgam ... 4363">Grab it today!</a>
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

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.
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

Thanks for your help Harlock. I got it working.
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

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: Select all

variablename &#58;= current map

if &#40;variablename == 1&#41;
then, begin
show text box &#40;1&#41;
end

if &#40;variablename == 2&#41;
then, begin
show text box &#40;2&#41;
end
Except that's not right since "current map" doesn't really work like that. Any thoughts?
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

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: Select all

if &#40;current map == 1&#41;
then, begin
show text box &#40;1&#41;
end

if &#40;current map == 2&#41;
then, begin
show text box &#40;2&#41;
end 
Post Reply