Scripts:Swap hero equipment

From OHRRPGCE-Wiki
Jump to: navigation, search

This script swaps the equipment of two heroes (arguments are their positions in the party, e.g. returned by findhero).

This script if useful if you want to transform a hero to one with different stats, appearance, etc, but preserve equipment. Add the new version of the hero to the party, put them in the position of the original hero, swap equipment, and delete or swap out and lock the original:

add hero (hero: Red Mage)
swap by name (hero: Red Mage, hero: Onion Knight)
swap hero equipment (find hero (hero: Red Mage), find hero (hero: Onion Knight))
delete hero (hero: Onion Knight)

The Script[edit]

# Swap the equips of two heroes (arguments are their positions in the
# party, e.g. returned by findhero).
#
# A Note from the dictionary:
# When a hero's equipment changes, the current values of all stats other
# than HP and MP for the hero are reset to their new maximum values. The
# current values of the HP and MP stats are capped to the new maximums
# but not otherwise changed, so you might like to check and scale up the
# HP and MP of the hero if the new max is more than the old one.
script, swap hero equipment, hero1, hero2, begin
  variable (item, slot)
  for (slot, 1, 5) do, begin # There are 5 equip slots
    item1 := check equipment (hero1)
    item2 := check equipment (hero2)
    unequip (hero1, slot)
    unequip (hero2, slot)
    if (item1 > -1) then (force equip (hero2, slot, item1))
    if (item2 > -1) then (force equip (hero1, slot, item2))
  end
end

See also[edit]