counter stat scripting

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

counter stat scripting

Post by Willy Elektrix »

When a particular item is used, it calls a script that should raise Fuel (MP) +10 and Medals (Counter) +1. Below is the script. It almost works, however the Medals stat appears as 0 (wrong) on the Stats screen but as 1 (right) on the Equip screen. The Fuel stat shows correctly on both.

Am I explaining this well? Does anyone have any idea what's going on?

plotscript, medal, begin
variable(who)
who := pick hero
if (who == -1) then (exit script)
variable(oldstat)
oldstat := get hero stat(who, stat:Fuel, maximum stat)
set hero stat(who, stat:Fuel, oldstat + 10, maximum stat)
oldstat := get hero stat(who, stat:Medals, maximum stat)
set hero stat(who, stat:Medals, oldstat + 1, maximum stat)
delete item (68, 1)
end
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:

Re: counter stat scripting

Post by Bob the Hamster »

Code: Select all

oldstat := get hero stat(who, stat:Medals, maximum stat)
set hero stat(who, stat:Medals, oldstat + 1, maximum stat)
set hero stat(who, stat:Medals, oldstat + 1, current stat)
You should set both the maximum stat and the current stat. If you just set the maximum stat, then the change doesn't really take effect until after the next battle ends.
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Re: counter stat scripting

Post by Willy Elektrix »

James Paige wrote:

Code: Select all

oldstat := get hero stat(who, stat:Medals, maximum stat)
set hero stat(who, stat:Medals, oldstat + 1, maximum stat)
set hero stat(who, stat:Medals, oldstat + 1, current stat)
You should set both the maximum stat and the current stat. If you just set the maximum stat, then the change doesn't really take effect until after the next battle ends.
As usual, you are the man.
Post Reply