Page 1 of 1
Adding to a stat
Posted: Sat Jul 04, 2009 2:05 am
by RMZ
Hey, I'm working on my game, and I'm trying to set up a scene where the heroes get a boost in HP. I was pretty sure I did something like this before, and I've seen it done in other games. I'm doing this by caterpillar position, as it'll happen to characters 0,1,and 2.
set hero stat ((hero by rank(0),stat:HP, get hero stat ((hero by rank(0),stat:HP)+50, maximum stat)))
That's what I put so far, and it didn't work... I mean, this isn't hard right? I thought it was something simple like:
Add to stat ((hero by rank (where)),stat:stat,amount)
But that acts like it's healing the player instead of boosting their total hp.
I'd appreciate some help.
Posted: Sat Jul 04, 2009 3:08 am
by FnrrfYgmSchnish
Not really much of a plotscripting expert (and I've never really done any stat-boosting scripts...), but it looks like you have too many parentheses.
So maybe:
Code: Select all
set hero stat(hero by rank(0),stat:HP,get hero stat(hero by rank(0),stat:HP)+50, maximum stat)
If that was the only problem, though, I would think Hamsterspeak would catch it and spit out an error message while compiling it. So I guess it must be something else...
Posted: Sun Jul 05, 2009 12:49 am
by msw188
This is partially a parentheses issue, but also you're forgetting that you need to tell the script to 'get' the maximum stat, and 'set' the maximum stat. The setting part of it should look like:
Code: Select all
set hero stat ( hero by rank (0), stat:HP, get hero stat()+50, maximum stat )
Then when we fill in the get hero stat part, it looks like:
Code: Select all
set hero stat ( hero by rank (0), stat:HP, get hero stat(herobyrank(0),stat:HP,maximumstat)+50, maximum stat )
Sometimes it's helpful to type your commands from the outside in like this. At least, I think so. If that even made any sense.
Posted: Sun Jul 05, 2009 2:21 am
by Bob the Hamster
Msw is right on the money here.
Personally, I like you use a variable for this kind of thing.
Code: Select all
variable(hp)
hp := get hero stat(hero by rank(0), stat:HP, maximum stat)
hp += 50
set hero stat (hero by rank(0), stat:HP, hp, maximum stat)
It is longer, but I think it is easier to read.