Scripts:Power Up
From OHRRPGCE-Wiki
Let's say you have a Fire Rod in your game, which you want to improve the power of fire spells. Or you have a Pendant that unlocks the power of the Masamune, making it stronger. You can create these effects with this plotscript. The trick is that the powered-up fire spell and sword are actually a different attack/item -- the script switches between them.
Script[edit]
# POWER UP
include, plotscr.hsd
include, myrpg.hsi
include, scancode.hsi
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))
)
)
Usage[edit]
This script should be set as the on-keypress script. If you already have an on-keypress script, you can still use this one -- just copy its contents into your own script. The script has some limitations:
- You shouldn't use it if you have multiple copies of the same hero.
- It won't change anything while the menu is open. For example, if the player changes his equipment and casts a spell without leaving the menu, he'll get the original spell instead of the new one.
- Along the same lines, it's a bad idea to make the powered-up item have different stat changes. This will confuse the player. You can make it more powerful by giving it a different attack instead.