Advertisement
MateusAp

yanfly class unlock level

Sep 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1.  
  2. github.com
  3. Otimizado agora
  4. Ver original
  5. #==============================================================================
  6. #
  7. # ▼ Yanfly Engine Ace - Class System Add-On: Class Unlock Level v1.00
  8. # -- Last Updated: 2011.12.20
  9. # -- Level: Normal
  10. # -- Requires: YEA - Class System v1.01+
  11. #
  12. #==============================================================================
  13. $imported = {} if $imported.nil?
  14. $imported["YEA-ClassUnlockLevel"] = true
  15. #==============================================================================
  16. # ▼ Updates
  17. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  18. # 2011.12.20 - Started Script and Finished.
  19. #
  20. #==============================================================================
  21. # ▼ Introduction
  22. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. # This script allows for classes to be unlocked after a class reaches a certain
  24. # level. Note that this script is made for the Class System script and not
  25. # using the MAINTAIN_LEVELS feature. Requirements for unlocking a class can be
  26. # multiple level requirements as well.
  27. #
  28. #==============================================================================
  29. # ▼ Instructions
  30. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. # To install this script, open up your script editor and copy/paste this script
  32. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  33. #
  34. # -----------------------------------------------------------------------------
  35. # Class Notetags - These notetags go in the class notebox in the database.
  36. # -----------------------------------------------------------------------------
  37. # <level unlock requirements>
  38. # class x: level y
  39. # class x: level y
  40. # </level unlock requirements>
  41. # Sets the requirements for unlocking that particular class. The unlocking of
  42. # the class will require classes x to be at level y. Insert multiple of the
  43. # strings in between the two opening and closing notetags to require all of the
  44. # class levels to be met.
  45. #
  46. #==============================================================================
  47. # ▼ Compatibility
  48. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  49. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  50. # it will run with RPG Maker VX without adjusting.
  51. #
  52. # This script requires Yanfly Engine Ace - Class System v1.01+.
  53. #
  54. #==============================================================================
  55. # ▼ Editting anything past this point may potentially result in causing
  56. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  57. # halitosis so edit at your own risk.
  58. #==============================================================================
  59. if $imported["YEA-ClassSystem"] && !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  60. module YEA
  61.   module REGEXP
  62.   module CLASS
  63.     LV_UNLOCK_ON =
  64.       /<(?:LEVEL_UNLOCK_REQUIREMENTS|level unlock requirements)>/i
  65.     LV_UNLOCK_OFF =
  66.       /<\/(?:LEVEL_UNLOCK_REQUIREMENTS|level unlock requirements)>/i
  67.     LV_UNLOCK_STR = /CLASS[ ](\d+): LEVEL[ ](\d+)/i
  68.   end # CLASS
  69.   end # REGEXP
  70. end # YEA
  71. #==============================================================================
  72. # ■ DataManager
  73. #==============================================================================
  74. module DataManager
  75.   #--------------------------------------------------------------------------
  76.   # alias method: load_database
  77.   #--------------------------------------------------------------------------
  78.   class <<self; alias load_database_cul load_database; end
  79.   def self.load_database
  80.     load_database_cul
  81.     load_notetags_cul
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # new method: load_notetags_cul
  85.   #--------------------------------------------------------------------------
  86.   def self.load_notetags_cul
  87.     for obj in $data_classes
  88.       next if obj.nil?
  89.       obj.load_notetags_cul
  90.     end
  91.   end
  92. end # DataManager
  93. #==============================================================================
  94. # ■ RPG::Class
  95. #==============================================================================
  96. class RPG::Class < RPG::BaseItem
  97.   #--------------------------------------------------------------------------
  98.   # public instance variables
  99.   #--------------------------------------------------------------------------
  100.   attr_accessor :level_unlock
  101.   #--------------------------------------------------------------------------
  102.   # common cache: load_notetags_cul
  103.   #--------------------------------------------------------------------------
  104.   def load_notetags_cul
  105.     @level_unlock = {}
  106.     @level_unlock_on = false
  107.     #---
  108.     self.note.split(/[\r\n]+/).each { |line|
  109.       case line
  110.       #---
  111.       when YEA::REGEXP::CLASS::LV_UNLOCK_ON
  112.         @level_unlock_on = true
  113.       when YEA::REGEXP::CLASS::LV_UNLOCK_OFF
  114.         @level_unlock_on = false
  115.       when YEA::REGEXP::CLASS::LV_UNLOCK_STR
  116.         next unless @level_unlock_on
  117.         @level_unlock[$1.to_i] = $2.to_i
  118.       end
  119.     } # self.note.split
  120.     #---
  121.   end
  122. end # RPG::Class
  123. #==============================================================================
  124. # ■ Game_Actor
  125. #==============================================================================
  126. class Game_Actor < Game_Battler
  127.   #--------------------------------------------------------------------------
  128.   # check_level_unlocked_classes
  129.   #--------------------------------------------------------------------------
  130.   def check_level_unlocked_classes
  131.     for item in $data_classes
  132.       next if item.nil?
  133.       next if unlocked_classes.include?(item.id)
  134.       next if item.level_unlock == {}
  135.       next unless class_unlock_level_requirements_met?(item)
  136.       unlock_class(item.id)
  137.     end
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # class_unlock_level_requirements_met?
  141.   #--------------------------------------------------------------------------
  142.   def class_unlock_level_requirements_met?(item)
  143.     for key in item.level_unlock
  144.       class_id = key[0]
  145.       level_req = key[1]
  146.       return false if class_level(class_id) < level_req
  147.     end
  148.     return true
  149.   end
  150. end # Game_Actor
  151. #==============================================================================
  152. # ■ Window_ClassList
  153. #==============================================================================
  154. class Window_ClassList < Window_Selectable
  155.   #--------------------------------------------------------------------------
  156.   # alias method: actor=
  157.   #--------------------------------------------------------------------------
  158.   alias window_classlist_actor_equals_cul actor=
  159.   def actor=(actor)
  160.     return if @actor == actor
  161.     actor.check_level_unlocked_classes
  162.     window_classlist_actor_equals_cul(actor)
  163.   end
  164. end # Window_ClassList
  165. end # $imported["YEA-ClassSystem"] && !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  166. #==============================================================================
  167. #
  168. # ▼ End of File
  169. #
  170. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement