Advertisement
Guest User

Skill Transformation by Use

a guest
Apr 20th, 2012
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. #======================================================================
  2. # Skill Transformation by Use - 0.8
  3. # Script by Nyx (20, april, 2012)
  4. # edmilsonrobson@gmail.com
  5. #
  6. # E-mail me for suggestions, questions, bugs, etc
  7. #======================================================================
  8. # Feel free to change at your own will. :)
  9. #======================================================================
  10.  
  11. #======================================================================
  12. #
  13. # HOW TO USE:
  14. #
  15. # At the "notes" box on your skill databases, put the following text:
  16. #
  17. # stransid:x:y
  18. #
  19. # "x" being the ID of the new skill that will be learned and "y" being
  20. # the number of uses needed for transformation.
  21. #
  22. # e.g:
  23. #
  24. # stransid:131:10
  25. #
  26. # means that the skill with that note will
  27. # transform into the Skill which ID is 131 after 10 uses.
  28. #
  29. #======================================================================
  30. # Future updates:
  31. # - Better note recognition
  32. # - Better battle notification
  33. #======================================================================
  34.  
  35.  
  36. #===============================
  37. # CONFIG
  38. #===============================
  39.  
  40. module STrans
  41.  
  42. NOTIFY_TRANS = true # If true, show a battle message notifying
  43. # the transformation
  44.  
  45. TRANS_VOCAB = "%s's skill evolved to \"%s\"!" # Notify message
  46.  
  47. OVERRIDES_ON_TRANS = false # If true, the old skill will be deleted
  48. # If false, the old and new skills will coexist
  49.  
  50. SHOW_USES = true # If true, shows a number that represents how many
  51. # times the skill was used next to its name on
  52. # the skill menu and on battle
  53.  
  54. end
  55.  
  56. #===============================
  57. # END OF CONFIG
  58. #===============================
  59.  
  60. class Game_Actor < Game_Battler
  61.  
  62. attr_accessor :times_used
  63.  
  64. #=======================================================
  65. # Modified setup so I can declare the @times_used array
  66. #=======================================================
  67. alias su_setup setup
  68. def setup(actor_id)
  69. @times_used = []
  70. su_setup(actor_id)
  71. end
  72.  
  73. #====================================================
  74. # An altered version of learn_skill from Game_Actor.
  75. # The changes include notifying the transformation
  76. #====================================================
  77. def learn_skill(skill_id)
  78. unless skill_learn?($data_skills[skill_id])
  79. @skills.push(skill_id)
  80. @skills.sort!
  81. @times_used[skill_id]=0
  82. if $game_party.in_battle
  83. @transformed=true
  84. $game_message.add(sprintf(STrans::TRANS_VOCAB,@name,$data_skills[skill_id].name))
  85. end
  86. end
  87. end
  88.  
  89.  
  90. #====================================================
  91. # Altered version of the method use_item.
  92. # The values 2 and 1 for item.id represents Guard
  93. # and Attack, respectively (they're skills!)
  94. #====================================================
  95. def use_item(item)
  96. pay_skill_cost(item) if item.is_a?(RPG::Skill)
  97. consume_item(item) if item.is_a?(RPG::Item)
  98. item.effects.each {|effect| item_global_effect_apply(effect) }
  99. if item.is_a?(RPG::Skill) and item.id!=2 and item.id!=1
  100. @times_used[item.id] = @times_used[item.id] + 1
  101. if item.note.include?("stransid")
  102. exp_needed = item.note.split(":")[2].to_i
  103. upgrade_skill(item) if @times_used[item.id]==exp_needed and STrans::NOTIFY_TRANS
  104. end
  105. end
  106. end
  107.  
  108. #==========================
  109. # Upgrades the skill.
  110. #==========================
  111. def upgrade_skill(item)
  112. note = item.note
  113. upgrade_id = note.split(":")[1].to_i
  114. forget_skill(item.id) if STrans::OVERRIDES_ON_TRANS
  115. learn_skill(upgrade_id)
  116. end
  117.  
  118.  
  119. end
  120.  
  121. #====================================================
  122. # The two modified classes below add the possibility
  123. # of showing the number of uses of the skill
  124. # if SHOW_USES was set to true.
  125. #====================================================
  126.  
  127. class Window_SkillList < Window_Selectable
  128.  
  129. def draw_item_name(item, x, y, enabled = true, width = 172)
  130. return unless item
  131. draw_icon(item.icon_index, x, y, enabled)
  132. change_color(normal_color, enabled)
  133. if STrans::SHOW_USES
  134. draw_text(x + 24, y, width, line_height, item.name + " (" + (@actor.times_used[item.id]).to_s + ")")
  135. else
  136. draw_text(x + 24, y, width, line_height, item.name)
  137. end
  138.  
  139. end
  140.  
  141. end
  142.  
  143. class Window_BattleSkill < Window_SkillList
  144.  
  145. def draw_item_name(item, x, y, enabled = true, width = 172)
  146. return unless item
  147. draw_icon(item.icon_index, x, y, enabled)
  148. change_color(normal_color, enabled)
  149. if STrans::SHOW_USES
  150. draw_text(x + 24, y, width, line_height, item.name + " (" + (@actor.times_used[item.id]).to_s + ")")
  151. else
  152. draw_text(x + 24, y, width, line_height, item.name)
  153. end
  154. end
  155.  
  156. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement