Scripts:Teaching spells through equipment

From OHRRPGCE-Wiki
Jump to navigationJump to search

This script allows a hero to learn a spell by equipping an item but also the hero forgets the spell if the hero removes the item. Make sure that you set this script as your new-game plotscript and load-game plotscript or that it is called by a script that is set as either of those already.

Script[edit]

plotscript, somebody wears a spell charm, begin
  variable (Hero A,Hero B,Hero C,Hero D,Equipment,Spell) #I'm using these variables so it's 
                                                         #easier to understand when reading it.
  set variable (Hero A, 0)
  set variable (Hero B, 1)
  set variable (Hero C, 2)
  set variable (Hero D, 3)
  set variable (Equipment,item:spelchrm) #Use the item's name as defined by your game's .HSI
  set variable (Spell,atk:Firaga) #Use the spell's name as defined by your game's .HSI
   while (true) do,begin 
   wait (1)
     if ((check equipment (Hero A,5))==Equipment) #In this example the script is checking if 
                                                  #the item spelchrm is being equipped by the first hero in his accessory
                                                  #slot (or the last slot 
                                                  #on the equip screen).  Be sure to change the 5 to another number to suit
                                                  #your needs.
       then, begin
         teach spell (Hero A,Spell)
       end
       else, begin
         forget spell (Hero A,Spell)
       end
     if ((check equipment (Hero B,5))==Equipment) #Now just repeat the first part for each of the other heroes.
       then, begin
         teach spell (Hero B,Spell)
       end
       else, begin
         forget spell (Hero B,Spell)
       end
     if ((check equipment (Hero C,5))==Equipment)
       then, begin
         teach spell (Hero C,Spell)
       end
       else, begin
         forget spell (Hero C,Spell)
       end
     if ((check equipment (Hero D,5))==Equipment)
       then, begin
         teach spell (Hero D,Spell)
       end
       else, begin
         forget spell (Hero D,Spell)
       end
     end
   end

#Make sure that your heroes have the capacity to learn the spell by setting it as "Learned 
#from item" on their spell list.  Otherwise they won't learn it.
#There is a minor issue: This script won't work unless the player exits all the menus and 
#takes a step.  It's pretty minor but it may irk the player that the spell doesn't exist 
#immediately.  You can probably solve this with a text box.