Advertisement
roninator2

Jeneeus Guruman Armour & Item Required Skills

Dec 6th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.48 KB | None | 0 0
  1. #==============================================================================
  2. # ** Armor and Item Required Skills
  3. # by: Jeneeus Guruman
  4. # Modded by: Roninator2
  5. #   Added on using armor items not types <req_arm: n>
  6. #------------------------------------------------------------------------------
  7. #  This script allows to:
  8. #     - Make some skills requires armor types to use it. It is the same as the
  9. #     weapon-required skill but in armors.
  10. #     - Make some skills require items in the party's inventory to use it.
  11. #
  12. #   How to use:
  13. #
  14. #     * Plug-n-play
  15. #     * Place this below default and non-aliased scripts.
  16. #      
  17. #       <req_atype: n>
  18. #       n: the index number of the armor type
  19. #       required for the skill (which is beside the name in the "Terms" tab)
  20. #
  21. #     * Note: If you put more than 1, the skill can be used if EITHER 1 of
  22. #       the armor types is equiipped.
  23. #      
  24. #       <req_arm: n>
  25. #       n: the index number of the armor
  26. #
  27. #       <req_item: n, amount, comnsumed?>
  28. #       n: the index number of the item in the database
  29. #       required for the skill (which is beside the name in the "Terms" tab)
  30. #       amount: the amount of the specified item needed to use a skill.
  31. #       consumed?: the item needed needed to be consumed or not (true or false).
  32. #       Notetag examples:
  33. #         <req_item: 1, 2, true>    => A skill needs to have at least 2 "Potions"
  34. #       in the inventory to use the skill and those will be consumed after use.
  35. #
  36. #     * Note: If you put more than 1, the skill can be used if ALL of
  37. #       the items is in the party's inventory.
  38. #
  39. #==============================================================================
  40.  
  41. #----------------------------------------------------------------------------
  42. # * Do not edit anything below here. Or else, evil errors will be released
  43. # from the other dimension of evil.
  44. #----------------------------------------------------------------------------
  45.  
  46. module Jene
  47.   REQ_ATYPE = /<req_atype[:]?\s*(\d+)>/i
  48.   REQ_AREQ = /<req_arm[:]?\s*(\d+)>/i
  49.   REQ_IREQ = /<req_item[:]?\s*(\d+)\s*[,]?\s*(\d+)\s*[,]?\s*(true|false)>/i
  50. end
  51.  
  52. class RPG::Skill
  53.  
  54.   def required_atype_ids
  55.     bonus_arr = []
  56.     self.note.each_line { |line|
  57.       if line =~ Jene::REQ_ATYPE
  58.         bonus_arr.push($1.to_i)
  59.       end
  60.     }
  61.     return bonus_arr
  62.   end
  63.  
  64.   def required_areq_ids
  65.     bonus_arr = []
  66.     self.note.each_line { |line|
  67.       if line =~ Jene::REQ_AREQ
  68.         bonus_arr.push($1.to_i)
  69.       end
  70.     }
  71.     return bonus_arr
  72.   end
  73.  
  74.   def required_items
  75.     bonus_arr = []
  76.     self.note.each_line { |line|
  77.       if line =~ Jene::REQ_IREQ
  78.         bonus_arr.push([$1.to_i, $2.to_i, $3 == "true"])
  79.       end
  80.     }
  81.     return bonus_arr
  82.   end
  83. end
  84.  
  85. #==============================================================================
  86. # ** Game_BattlerBase
  87. #------------------------------------------------------------------------------
  88. #  This base class handles battlers. It mainly contains methods for calculating
  89. # parameters. It is used as a super class of the Game_Battler class.
  90. #==============================================================================
  91.  
  92. class Game_BattlerBase
  93.   #--------------------------------------------------------------------------
  94.   # * Check Usability Conditions for Skill
  95.   #--------------------------------------------------------------------------
  96.   alias jene_req_skill_conditions_met? skill_conditions_met?
  97.   def skill_conditions_met?(skill)
  98.     return false unless skill_atype_ok?(skill) && skill_ireq_ok?(skill) && skill_areq_ok?(skill)
  99.     jene_req_skill_conditions_met?(skill)
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # * Determine if Skill-Required Armor Is Equipped
  103.   #--------------------------------------------------------------------------
  104.   def skill_atype_ok?(skill)
  105.     return true
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # * Determine if Skill-Required Armor Is Equipped
  109.   #--------------------------------------------------------------------------
  110.   def skill_areq_ok?(skill)
  111.     return true
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # * Determine if Skill-Required Item Is In Inventory
  115.   #--------------------------------------------------------------------------
  116.   def skill_ireq_ok?(skill)
  117.     return true
  118.   end
  119. end
  120.  
  121. #==============================================================================
  122. # ** Game_Actor
  123. #------------------------------------------------------------------------------
  124. #  This class handles actors. It is used within the Game_Actors class
  125. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
  126. #==============================================================================
  127.  
  128. class Game_Actor < Game_Battler
  129.   #--------------------------------------------------------------------------
  130.   # * Determine if Skill-Required Armor Is Equipped
  131.   #--------------------------------------------------------------------------
  132.   def skill_atype_ok?(skill)
  133.     return true if skill.required_atype_ids.size == 0
  134.     for i in skill.required_atype_ids
  135.       return true if atype_equipped?(i)
  136.     end
  137.     return false
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # * Determine if Skill-Required Armor Is Equipped
  141.   #--------------------------------------------------------------------------
  142.   def skill_areq_ok?(skill)
  143.     return true if skill.required_areq_ids.size == 0
  144.     for i in skill.required_areq_ids
  145.       return true if areq_equipped?(i)
  146.     end
  147.     return false
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Determine if Specific Type of Armor Is Equipped
  151.   #--------------------------------------------------------------------------
  152.   def atype_equipped?(atype_id)
  153.     armors.any? {|armor| armor.atype_id == atype_id }
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # * Determine if Specific Type of Armor Is Equipped
  157.   #--------------------------------------------------------------------------
  158.   def areq_equipped?(areq_id)
  159.     armors.any? {|armor| armor.id == areq_id }
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # * Determine if Skill-Required Item Is In Inventory
  163.   #--------------------------------------------------------------------------
  164.   def skill_ireq_ok?(skill)
  165.     for i in skill.required_items
  166.       item = $data_items[i[0]]
  167.       return false unless $game_party.item_number(item) >= i[1]
  168.     end
  169.     return true
  170.   end
  171. end
  172.  
  173. #==============================================================================
  174. # ** Game_Battler
  175. #------------------------------------------------------------------------------
  176. #  A battler class with methods for sprites and actions added. This class
  177. # is used as a super class of the Game_Actor class and Game_Enemy class.
  178. #==============================================================================
  179.  
  180. class Game_Battler < Game_BattlerBase
  181.   #--------------------------------------------------------------------------
  182.   # * Use Skill/Item
  183.   #    Called for the acting side and applies the effect to other than the user.
  184.   #--------------------------------------------------------------------------
  185.   alias jene_ireq_use_item use_item
  186.   def use_item(item)
  187.     consume_item(item) if item.is_a?(RPG::Skill) && !item.required_items.empty?
  188.     jene_ireq_use_item(item)
  189.   end
  190. end
  191.  
  192. #==============================================================================
  193. # ** Game_Party
  194. #------------------------------------------------------------------------------
  195. #  This class handles parties. Information such as gold and items is included.
  196. # Instances of this class are referenced by $game_party.
  197. #==============================================================================
  198.  
  199. class Game_Party < Game_Unit
  200.   #--------------------------------------------------------------------------
  201.   # * Consume Items
  202.   #    If the specified object is a consumable item, the number in investory
  203.   #    will be reduced by 1.
  204.   #--------------------------------------------------------------------------
  205.   alias jene_ireq_consume_item consume_item
  206.   def consume_item(item)
  207.     if item.is_a?(RPG::Skill)
  208.       for i in item.required_items
  209.         item2 = $data_items[i[0]]
  210.         lose_item(item2, i[1]) if i[2]
  211.       end
  212.     end
  213.     jene_ireq_consume_item(item)
  214.   end
  215. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement