Advertisement
roninator2

Fomar0153 Skill Charges Mod

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