# ╔═════════════════════════════════════╦════════════════════╗ # ║ Title: KFBQ Spell Groups & Uses ║ Version: 1.00 ║ # ║ Author: Roninator2 ║ ║ # ╠═════════════════════════════════════╬════════════════════╣ # ║ Function: ║ Date Created ║ # ║ ╠════════════════════╣ # ║ FFMQ Style spell use ║ 09 Mar 2023 ║ # ╚═════════════════════════════════════╩════════════════════╝ # ╔══════════════════════════════════════════════════════════╗ # ║ Instructions: ║ # ║ ║ # ║ Set the note tag on spells to indicate what group ║ # ║ the spell belongs in ║ # ║ Other options include black and wizard ║ # ║ Set the note tag on the actors to indicate the rate ║ # ║ at which the player will gain new spell uses ║ # ║ ║ # ║ Numbers - 5 starting points, 1 gained every 2 levels ║ # ║ So ║ # ║ is start with 2 and gain 1 every 3 levels ║ # ╚══════════════════════════════════════════════════════════╝ # ╔══════════════════════════════════════════════════════════╗ # ║ Terms of use: ║ # ║ Free for all uses in RPG Maker - Except nudity ║ # ╚══════════════════════════════════════════════════════════╝ #============================================================================== # * Module R2 Spell #============================================================================== module R2_Spell_Group # Skill notetag # SpellGroup = //i # Actor notetag # /i end #============================================================================== # * DataManager #============================================================================== module DataManager #-------------------------------------------------------------------------- # alias method: load_database #-------------------------------------------------------------------------- class < 0 when :black return true if self.blackspells > 0 when :wizard return true if self.wizardspells > 0 else return false end end end #-------------------------------------------------------------------------- # * Pay Cost of Using Skill #-------------------------------------------------------------------------- def pay_skill_cost(skill) if self.is_a?(Game_Enemy) return else spellgrp = skill.spellgroup self.pay_spells(spellgrp) end end end #============================================================================== # * Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Determine if Cost of Using Skill Can Be Paid #-------------------------------------------------------------------------- def skill_cost_payable?(skill) if self.is_a?(Game_Actor) case skill.stype_id when 1 return true if self.whitespells > 0 return false when 2 return true if self.blackspells > 0 return false when 3 return true if self.wizardspells > 0 return false else return true end else tp >= skill_tp_cost(skill) && mp >= skill_mp_cost(skill) end end #-------------------------------------------------------------------------- # * Pay Cost of Using Skill #-------------------------------------------------------------------------- def pay_skill_cost(skill) if self.is_a?(Game_Actor) case skill.stype_id when 1 self.pay_spells(:white) when 2 self.pay_spells(:black) when 3 self.pay_spells(:wizard) else self.mp -= skill_mp_cost(skill) self.tp -= skill_tp_cost(skill) end else self.mp -= skill_mp_cost(skill) self.tp -= skill_tp_cost(skill) end end end #============================================================================== # ** Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :actorspells attr_reader :whitespells attr_reader :blackspells attr_reader :wizardspells #-------------------------------------------------------------------------- # * Alias Actor Initialize #-------------------------------------------------------------------------- alias r2_actor_setup setup def setup(i) r2_actor_setup(i) add_spells end #-------------------------------------------------------------------------- # * Add Actor Spell Counts #-------------------------------------------------------------------------- def add_spells @actorspells = actor.actorspells @whitespells = actor.actorwhitecount @blackspells = actor.actorblackcount @wizardspells = actor.actorwizardcount end #-------------------------------------------------------------------------- # * Add Actor Spell Counts #-------------------------------------------------------------------------- def pay_spells(type) case type when :white @whitespells -= 1 when :black @blackspells -= 1 when :wizard @wizardspells -= 0 end end #-------------------------------------------------------------------------- # * Recover All #-------------------------------------------------------------------------- alias r2_actor_spells_recover recover_all def recover_all r2_actor_spells_recover refresh_spells end #-------------------------------------------------------------------------- # * Add Actor Spell Counts #-------------------------------------------------------------------------- def refresh_spells @whitespells = actor.actorwhitecount @blackspells = actor.actorblackcount @wizardspells = actor.actorwizardcount end #-------------------------------------------------------------------------- # * Level Up #-------------------------------------------------------------------------- alias r2_spell_level_up level_up def level_up r2_spell_level_up spells_up end #-------------------------------------------------------------------------- # * Increase Spell Count #-------------------------------------------------------------------------- def spells_up white = @actorspells[:white] black = @actorspells[:black] wizard = @actorspells[:wizard] @actorspells.each do |group| sym = group[0] base = group[1][0] incr = group[1][1] levl = group[1][2] gain = ((@level - 1) / levl).to_i spell_up = (gain * incr) + base spell_up - 1 if levl == 1 case sym when :white actor.actorwhitecount = spell_up when :black actor.actorblackcount = spell_up when :wizard actor.actorwizardcount = spell_up end end end end