Scripts:Lockpicking

From OHRRPGCE-Wiki

If you ever wanted to make your heroes to be able to pick locks to be able to loot items or even set tags on or off (Works for opening doors), then this script example is for you!


plotscript, exampleLock, begin

#Assume that tag 2 means that the player Has the item 1, a lockpick.
#Assume that the optional tag 3 checks if the player will break or will not break the lockpick as a cost
#Assume that tag 4 is necessary for the NPC that triggers this script to disappear.
suspend player
 
 if (check tag(2)) then ( #Checks if the player has a lockpick
 
  show backdrop() #Optional backdrop
  show text box() #This text box may show the player instructions for him/her to start.
  wait for key # Prevents automatic failure
  
  if (check tag(3)) then ( #Optional: Checks if the player has or has not to pay a lockpick. (Will or will not be deleted)
  
  ) else (
  
   delete item (1)
  
  )
 
  if (key is pressed (key:up)) then ( #This is a good system; Make a puzzle in which the player has to discover a pattern of up and down keys
 
    show text box() #Displays that this combination was correct
    wait (40) 
    show text box() #Tells the player to do use the <- arrow key to finish (Optional)
    wait for key #Prevents automatic failure
    
    if (key is pressed (key:left)) then ( # Finishes the lock
    
     show text box() #Tells the player that the lock is open.
     get item () #Loot
     set tag (4, on) #Sets the tag that made the "lock" disappear on so that players won't trigger this script anymore
    
    ) else (
    
     show text box() #Failed
    
    )
 
  ) else (
 
    show text box() #Failed
   
  )
  
 )
 
 show map
 
 resume player 

end

This script shows a combination of only one key. To add more keys, you need to make another if inside the first key-check if, and place the Finish-lock if at the end. This process may seem long and complicated, but it works perfectly.