Advertisement
Fomar0153

Fomar0153 - Skill Charges 1.0

Mar 15th, 2012
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.82 KB | None | 0 0
  1. =begin
  2. Skill Charges
  3. by Fomar0153
  4. Version 1.0
  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. ----------------------
  21. Known bugs
  22. ----------------------
  23. None
  24. =end
  25. module Fomar
  26.  
  27.   # With this set to true you can only use each skill as
  28.   # many times as you have skill charges
  29.   SKILL_CHARGES = true
  30.   # 50% increase in skill power per additional charge
  31.   # set to 0.0 if you don't want this feature
  32.   SKILL_CHARGES_POWER_INC = 0.5
  33.   # Set to true to display a message when you gain a skill charge
  34.   SKILL_CHARGES_MSG = true
  35.   # %s will be replaced with the actor's name and skill's name
  36.   SKILL_CHARGES_VOCAB = "%s gained a skill charge of %s."
  37.  
  38. end
  39.  
  40. class Game_Actor < Game_Battler
  41.  
  42.   attr_accessor :skill_charges
  43.   attr_accessor :used_skill_charges
  44.  
  45.   alias sc_setup setup
  46.   def setup(actor_id)
  47.     @skill_charges = []
  48.     @used_skill_charges = []
  49.     sc_setup(actor_id)
  50.   end
  51.  
  52.   alias sc_learn_skill learn_skill
  53.   def learn_skill(skill_id)
  54.     if skill_learn?($data_skills[skill_id])
  55.       @skill_charges[skill_id] += 1
  56.       if $game_party.in_battle and Fomar::SKILL_CHARGES_MSG
  57.         $game_message.add(sprintf(Fomar::SKILL_CHARGES_VOCAB, @name, $data_skills[skill_id].name))
  58.       end
  59.     else
  60.       sc_learn_skill(skill_id)
  61.       @skill_charges[skill_id] = 1
  62.     end
  63.   end
  64.  
  65.   def usable?(item)
  66.     return super unless $game_party.in_battle
  67.     return super if item.is_a?(RPG::Skill) && (item.id == attack_skill_id || item.id == guard_skill_id)
  68.     return false if item.is_a?(RPG::Skill) &&
  69.       (@skill_charges[item.id] - @used_skill_charges[item.id] == 0 && Fomar::SKILL_CHARGES)
  70.     return super(item)
  71.   end
  72.  
  73.   def reset_skill_charges
  74.     for skill in @skills + [attack_skill_id,guard_skill_id]
  75.       @used_skill_charges[skill] = 0
  76.     end
  77.   end
  78.  
  79.   alias sc_use_item use_item
  80.   def use_item(item)
  81.     sc_use_item(item)
  82.     return unless $game_party.in_battle
  83.     @used_skill_charges[item.id] += 1 if item.is_a?(RPG::Skill)
  84.   end
  85.  
  86.   def skill_damage_mult(item)
  87.     return 1.0 if item.id == attack_skill_id or item.id == guard_skill_id
  88.     if @used_skill_charges[item.id].nil?
  89.       @used_skill_charges[item.id] = 0
  90.     end
  91.     return 1.0 + (@skill_charges[item.id] - @used_skill_charges[item.id]).to_f * Fomar::SKILL_CHARGES_POWER_INC
  92.   end
  93.  
  94. end
  95.  
  96. class Game_Battler < Game_BattlerBase
  97.  
  98.   alias sc_item_element_rate item_element_rate
  99.   def item_element_rate(user, item)
  100.     if user.actor? and item.is_a?(RPG::Skill)
  101.       sc_item_element_rate(user, item) * user.skill_damage_mult(item)
  102.     else
  103.       sc_item_element_rate(user, item)
  104.     end
  105.   end
  106.  
  107. end
  108.  
  109. module BattleManager
  110.  
  111.   class << self
  112.     alias sc_setup setup
  113.   end
  114.  
  115.   def self.setup(troop_id, can_escape = true, can_lose = false)
  116.     sc_setup(troop_id, can_escape, can_lose)
  117.     for actor in $game_party.members
  118.       actor.reset_skill_charges
  119.     end
  120.   end
  121.  
  122. end
  123.  
  124. class Window_BattleSkill < Window_SkillList
  125.  
  126.   def draw_item_name(item, x, y, enabled = true, width = 172)
  127.     return unless item
  128.     draw_icon(item.icon_index, x, y, enabled)
  129.     change_color(normal_color, enabled)
  130.     draw_text(x + 24, y, width, line_height, item.name + " (" + (@actor.skill_charges[item.id] - @actor.used_skill_charges[item.id]).to_s + ")")
  131.   end
  132.  
  133. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement