# POWER UP
include, plotscr.hsd
include, myrpg.hsi
include, scancode.hsi
define script(1, power up, none)
script, power up (
if (key is pressed(key:alt)) then (
wait(0) # Allow the menu to close
variable(hero)
variable(slot)
variable(list)
for (hero, 0, 40) do (
# Change Fire to Fire 2 if Fire Rod is equipped
if (check equipment(hero, slot:weapon) == item:Fire Rod) then (
# If the hero has the normal spell, power it up
if (knows spell(hero, atk:Fire)) then (
for (list, 0, 3) do (
for (slot, 0, 23) do (
if (read spell(hero, list, slot) == atk:Fire) then (
write spell(hero, list, slot, atk:Fire 2)
)
)
)
)
) else (
# If the hero has the powered-up spell, change it to normal
if (knows spell(hero, atk:Fire 2)) then (
for (list, 0, 3) do (
for (slot, 0, 23) do (
if (read spell(hero, list, slot) == atk:Fire 2) then (
write spell(hero, list, slot, atk:Fire)
)
)
)
)
)
# Change Masamune to Masamune 2 if Pendant is equipped
if (check equipment(hero, slot:arms) == item:Pendant) then (
# If the hero has the weak Masamune, power it up
if (check equipment(hero, slot:weapon) == item:Masamune) then (
force equip(hero, slot:weapon, item:Masamune 2)
)
) else (
# If the hero has the powered-up Masamune, change it back
if (check equipment(hero, slot:weapon) == item:Masamune 2) then (
force equip(hero, slot:weapon, item:Masamune 2)
)
)
)
# We also need to swap out any Masamune 2s in inventory
if (inventory(item:Masamune 2)) then (
get item(item:Masamune, inventory(item:Masamune 2))
delete item(item:Masamune 2, inventory(item:Masamune 2))
)
)
)