Advertisement
TheSixth

Equip Slot Lock Feature

May 5th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.21 KB | None | 0 0
  1. =begin
  2.  
  3. Equip Slot Lock Feature
  4. Made by: Sixth
  5.  
  6. By default, there is no way to lock an equipment slot, you can only lock entire
  7. equip types, such as weapons, accessories, etc.
  8. This script will let you lock the equip slots themselves regardless of what the
  9. actor have equipped there.
  10.  
  11. You can use the following note-tag on actors, classes, weapons, armors and
  12. states:
  13.  
  14.   <slot lock: slot_index1, slot_index2, ...>
  15.  
  16. Replace the slot_indexX parts with the index of the equipment slot you want to
  17. lock. The 1st slot's index is 0, the 2nd slot's index is 1, and so on.
  18.  
  19. Examples: <slot lock: 0>, <slot lock: 2, 4, 6>, <slot lock: 0,1>
  20.  
  21. NOTE:
  22. There are 2 ways of removing an equipment that is locked this way:
  23.  
  24. 1.
  25. Remove all feature objects containing the slot lock note-tag for the equipment
  26. slot the equipment is on. This won't automatically unequip the equipment from
  27. the slot, of course, but it will let the player change that equipment again if
  28. he/she wants to.
  29.  
  30. 2. Manually "force-remove" it by eventing.
  31. Even if the equipment is removed, if the actor have some other feature objects
  32. locking that slot, the slot will stay locked still.
  33.  
  34. If you want to temporary block a slot for an actor, doing it with states is a
  35. pretty viable solution, but you can also put the note-tag on the equipment which
  36. is equipped on that slot to get the same results. Doing the latter will lock the
  37. slot whenever that equipment is equipped though, so if you don't want that, you
  38. will have to use a state, I guess.
  39.  
  40. Place this script below the default scripts but above the "Main" slot.
  41.  
  42. =end
  43.  
  44. class RPG::BaseItem
  45.  
  46.   attr_accessor :slot_lock
  47.  
  48.   def slot_lock
  49.     init_slot_lock if @slot_lock.nil?
  50.     return @slot_lock
  51.   end
  52.  
  53.   def init_slot_lock
  54.     @slot_lock = []
  55.     if @note =~ /<slot lock:(?:\s*)([^>]*)>/i
  56.       $1.split(/(?:\s*,\s*)/).each {|sid| @slot_lock << sid.to_i }
  57.     end
  58.   end
  59.  
  60. end
  61.  
  62. class Game_Actor < Game_Battler
  63.  
  64.   def slot_lock
  65.     return feature_objects.inject([]) {|r,obj| r += obj.slot_lock if obj }
  66.   end
  67.  
  68.   alias add_slock9927 equip_change_ok?
  69.   def equip_change_ok?(sid)
  70.     return false if slot_lock.include?(sid)
  71.     add_slock9927(sid)
  72.   end
  73.  
  74. end
  75. # End of script! O_O
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement