Advertisement
Fomar0153

Fomar0153 - Learn Skills Based on Usage

Jan 13th, 2012
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.47 KB | None | 0 0
  1. =begin
  2. Skills Level Up Based on Usage Script
  3. by Fomar0153
  4. Version 1.1
  5. ----------------------
  6. Notes
  7. ----------------------
  8. No requirements
  9. Allows you to learn new skills by using your existing skills.
  10. ----------------------
  11. Instructions
  12. ----------------------
  13. You will need to edit module Skill_Uses, further instructions
  14. are located there.
  15. ----------------------
  16. Changelog
  17. ----------------------
  18. 1.0 -> 1.1: Fixed a bug where script would crash outside of battles.
  19. ----------------------
  20. Known bugs
  21. ----------------------
  22. None
  23. =end
  24. module Skill_Uses
  25.  
  26.   SKILLS = []
  27.   # Add/Edit lines like the one below
  28.   # SKILLS[ORIGINAL] = [NEW, USES, REPLACE] REPLACE should be true or false
  29.   SKILLS[3] = [4, 50, true]
  30.   # Reads as: When using skill 3 for it's 50th time replace it with skill 4
  31.  
  32. end
  33.  
  34. class Game_Actor < Game_Battler
  35.   #--------------------------------------------------------------------------
  36.   # ● Aliases setup
  37.   #--------------------------------------------------------------------------
  38.   alias fomar0003_setup setup
  39.   def setup(actor_id)
  40.     fomar0003_setup(actor_id)
  41.     @skill_uses = []
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● New Method add_skill_use
  45.   #--------------------------------------------------------------------------
  46.   def add_skill_use(id)
  47.     if @skill_uses[id] == nil
  48.       @skill_uses[id] = 0
  49.     end
  50.     @skill_uses[id] += 1
  51.     unless Skill_Uses::SKILLS[id] == nil
  52.       if @skill_uses[id] == Skill_Uses::SKILLS[id][1]
  53.         learn_skill(Skill_Uses::SKILLS[id][0])
  54.         forget_skill(id) if Skill_Uses::SKILLS[id][2]
  55.         $game_message.add(@name + " learns " + $data_skills[Skill_Uses::SKILLS[id][0]].name + ".")
  56.       end
  57.     end
  58.   end
  59. end
  60.  
  61. class Game_Battler < Game_BattlerBase
  62.   #--------------------------------------------------------------------------
  63.   # ● Aliases item_apply
  64.   #--------------------------------------------------------------------------
  65.   alias fomar0004_item_apply item_apply
  66.   def item_apply(user, item)
  67.     if user.is_a?(Game_Actor) and item.is_a?(RPG::Skill)
  68.       user.add_skill_use(item.id)
  69.     end
  70.     fomar0004_item_apply(user, item)
  71.   end
  72. end
  73.  
  74. class Scene_Battle < Scene_Base
  75.   #--------------------------------------------------------------------------
  76.   # ● New method add_text
  77.   #--------------------------------------------------------------------------
  78.   def add_text(text)
  79.     @log_window.add_text(text)
  80.   end
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement