Fomar0153

Fomar0153 - Learn Skills by Element use 1.1

Apr 2nd, 2012
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.10 KB | None | 0 0
  1. =begin
  2. Learn Skills by Element use
  3. by Fomar0153
  4. Version 1.1
  5. ----------------------
  6. Notes
  7. ----------------------
  8. No requirements
  9. Allows you to learn new skills by using skills of the same element.
  10. ----------------------
  11. Instructions
  12. ----------------------
  13. You will need to edit module Fomar, further instructions
  14. are located there.
  15. ----------------------
  16. Change Log
  17. ----------------------
  18. 1.0 -> 1.1 Fixed a bug that could cause crashing.
  19. ----------------------
  20. Known bugs
  21. ----------------------
  22. None
  23. =end
  24. module Fomar
  25.  
  26.   ELEMENTS = []
  27.   # Add/Edit lines like the ones below
  28.   ELEMENTS[3] = {}
  29.   # ELEMENTS[id][uses] = [NEW_SKILL_ID, NEW_SKILL_ID...]
  30.   ELEMENTS[3][50]  = [52,53]
  31.   ELEMENTS[3][100] = [54]
  32.  
  33. end
  34.  
  35. class Game_Actor < Game_Battler
  36.   #--------------------------------------------------------------------------
  37.   # ● Aliases setup
  38.   #--------------------------------------------------------------------------
  39.   alias seu_setup setup
  40.   def setup(actor_id)
  41.     seu_setup(actor_id)
  42.     @element_uses = []
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● New Method add_element_use
  46.   #--------------------------------------------------------------------------
  47.   def add_element_use(id)
  48.     return if id == -1
  49.     if @element_uses[id].nil?
  50.       @element_uses[id] = 0
  51.     end
  52.     @element_uses[id] += 1
  53.     return if Fomar::ELEMENTS[id].nil?
  54.     unless Fomar::ELEMENTS[id][@element_uses[id]].nil?
  55.       for skill in Fomar::ELEMENTS[id][@element_uses[id]]
  56.         learn_skill(skill)
  57.         $game_message.add(@name + ' learns ' + $data_skills[skill].name)
  58.       end
  59.     end
  60.   end
  61. end
  62.  
  63. class Game_Battler < Game_BattlerBase
  64.   #--------------------------------------------------------------------------
  65.   # ● Aliases item_apply
  66.   #--------------------------------------------------------------------------
  67.   alias seu_item_apply item_apply
  68.   def item_apply(user, item)
  69.     seu_item_apply(user, item)
  70.     if user.is_a?(Game_Actor) and item.is_a?(RPG::Skill)
  71.       user.add_element_use(item.damage.element_id)
  72.     end
  73.   end
  74. end
Add Comment
Please, Sign In to add comment