Advertisement
Fomar0153

Fomar0153 - Skill Charges 1.1

Apr 21st, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. =begin
  2. Skill Charges
  3. by Fomar0153
  4. Version 1.1
  5. ----------------------
  6. Notes
  7. ----------------------
  8. This script can implement two new features.
  9. The first is skill charges, each time you learn a skill
  10. you gain a charge in it and you're allowed to use that skill
  11. only as many times as you have charges per battle.
  12. The second feature is that each time you learn a skill after
  13. initially learning it the skill gets more powerful.
  14. Using both features together allows for your skills to get
  15. weaker each time you use a charge.
  16. ----------------------
  17. Instructions
  18. ----------------------
  19. Change the variables in the Fomar module to suit your needs.
  20. Then notetag the skills to use charges with <charges>
  21. ----------------------
  22. Change Log
  23. ----------------------
  24. 1.0 -> 1.1 : Added a notetag to identify charge skills.
  25. ----------------------
  26. Known bugs
  27. ----------------------
  28. None
  29. =end
  30. module Fomar
  31.  
  32. # With this set to true you can only use each skill as
  33. # many times as you have skill charges
  34. SKILL_CHARGES = true
  35. # 50% increase in skill power per additional charge
  36. # set to 0.0 if you don't want this feature
  37. SKILL_CHARGES_POWER_INC = 0.5
  38. # Set to true to display a message when you gain a skill charge
  39. SKILL_CHARGES_MSG = true
  40. # %s will be replaced with the actor's name and skill's name
  41. SKILL_CHARGES_VOCAB = "%s gained a skill charge of %s."
  42.  
  43. end
  44.  
  45. class Game_Actor < Game_Battler
  46.  
  47. attr_accessor :skill_charges
  48. attr_accessor :used_skill_charges
  49.  
  50. alias sc_setup setup
  51. def setup(actor_id)
  52. @skill_charges = []
  53. @used_skill_charges = []
  54. sc_setup(actor_id)
  55. end
  56.  
  57. alias sc_learn_skill learn_skill
  58. def learn_skill(skill_id)
  59. if skill_learn?($data_skills[skill_id])
  60. @skill_charges[skill_id] += 1
  61. if $game_party.in_battle and Fomar::SKILL_CHARGES_MSG
  62. $game_message.add(sprintf(Fomar::SKILL_CHARGES_VOCAB, @name, $data_skills[skill_id].name))
  63. end
  64. else
  65. sc_learn_skill(skill_id)
  66. @skill_charges[skill_id] = 1
  67. end
  68. end
  69.  
  70. def usable?(item)
  71. return super unless $game_party.in_battle
  72. return super if item.is_a?(RPG::Skill) && (item.id == attack_skill_id || item.id == guard_skill_id)
  73. return false if (item.is_a?(RPG::Skill) and item.charges) &&
  74. (@skill_charges[item.id] - @used_skill_charges[item.id] == 0 && Fomar::SKILL_CHARGES)
  75. return super(item)
  76. end
  77.  
  78. def reset_skill_charges
  79. for skill in @skills + [attack_skill_id,guard_skill_id]
  80. @used_skill_charges[skill] = 0
  81. end
  82. end
  83.  
  84. alias sc_use_item use_item
  85. def use_item(item)
  86. sc_use_item(item)
  87. return unless $game_party.in_battle
  88. @used_skill_charges[item.id] += 1 if item.is_a?(RPG::Skill) and item.charges
  89. end
  90.  
  91. def skill_damage_mult(item)
  92. return 1.0 if item.id == attack_skill_id or item.id == guard_skill_id
  93. if @used_skill_charges[item.id].nil?
  94. @used_skill_charges[item.id] = 0
  95. end
  96. return 1.0 + (@skill_charges[item.id] - @used_skill_charges[item.id]).to_f * Fomar::SKILL_CHARGES_POWER_INC
  97. end
  98.  
  99. end
  100.  
  101. class Game_Battler < Game_BattlerBase
  102.  
  103. alias sc_item_element_rate item_element_rate
  104. def item_element_rate(user, item)
  105. if user.actor? and (item.is_a?(RPG::Skill) and item.charges)
  106. sc_item_element_rate(user, item) * user.skill_damage_mult(item)
  107. else
  108. sc_item_element_rate(user, item)
  109. end
  110. end
  111.  
  112. end
  113.  
  114. module BattleManager
  115.  
  116. class << self
  117. alias sc_setup setup
  118. end
  119.  
  120. def self.setup(troop_id, can_escape = true, can_lose = false)
  121. sc_setup(troop_id, can_escape, can_lose)
  122. for actor in $game_party.members
  123. actor.reset_skill_charges
  124. end
  125. end
  126.  
  127. end
  128.  
  129. class Window_BattleSkill < Window_SkillList
  130.  
  131. alias charges_draw_item_name draw_item_name
  132. def draw_item_name(item, x, y, enabled = true, width = 172)
  133. return unless item
  134. return charges_draw_item_name(item,x,y,enabled,width) unless item.charges
  135. draw_icon(item.icon_index, x, y, enabled)
  136. change_color(normal_color, enabled)
  137. draw_text(x + 24, y, width, line_height, item.name + " (" + (@actor.skill_charges[item.id] - @actor.used_skill_charges[item.id]).to_s + ")")
  138. end
  139.  
  140. end
  141.  
  142. class RPG::Skill
  143. def charges
  144. if @charges.nil?
  145. @charges = @note.include?("<charges>")
  146. end
  147. @charges
  148. end
  149. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement