Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #** Quasi Passive Skills Equip v 2.2
- #==============================================================================
- # Allows players to equip passive skills inside the skill menu.
- #==============================================================================
- # Instructions:
- # Very simple to use, mostly plug and play.
- #
- # For the Passive Equips you will need my Passive Scripts
- # - Passive Skills ( State based )
- # http://quasixi.wordpress.com/2014/03/23/quasi-passive/
- #
- # or
- #
- # - Fixed Passive Skills
- # http://quasixi.wordpress.com/2014/03/26/quasi-fixed-passive/
- #
- # Can work with both, or just one. This needs to be placed BELOW those scripts.
- #
- # If used with Quasi Skill Type Equip, place this BELOW it.
- #------------------------------------------------------------------------------
- # * Note Tag
- #------------------------------------------------------------------------------
- # <passive_slots: #>
- # Can be placed in actors note box, or weapons/armor. Default is 0
- #
- # If an actor has 2 passive slots, and equips a weapon with 2 more slots. You
- # will be able to equip 4 passive skills. If you unequip the weapon, the last
- # 2 passive skills equipped, will be unequipped.
- #------------------------------------------------------------------------------
- # * Log
- #------------------------------------------------------------------------------
- # v 2.1-2.2 9/4/14
- # - Fixed a bug that caused game to freeze
- # - Fixed a bug where fixed passives didn't list when used with state passive
- # - Fixed a bug with passive learn
- #-----------------------------------------------------------------------------
- module Quasi
- module PassiveEquip
- # Title to appear in the command window.
- # Only matters if one of my passive scripts is installed.
- NAMEPASSIVE = "Passive"
- # What to show in the help window.
- HELP = "Passives Equiped" # shows "Passive Equiped: total/max"
- end
- end
- #==============================================================================#
- # By Quasi (http://quasixi.wordpress.com/)
- # - 9/1/14
- #==============================================================================#
- # ** Stop! Do not edit anything below, unless you know what you **
- # ** are doing! **
- #==============================================================================#
- $imported = {} if $imported.nil?
- $imported["Quasi_PassiveEquip"] = 2.0
- #==============================================================================
- # ** Game_BattlerBase
- #------------------------------------------------------------------------------
- # This base class handles battlers. It mainly contains methods for calculating
- # parameters. It is used as a super class of the Game_Battler class.
- #==============================================================================
- class Game_BattlerBase
- alias qepinit initialize
- attr_accessor :equipped_passive
- #--------------------------------------------------------------------------
- # * Object Initialization
- # ** ALIAS **
- #--------------------------------------------------------------------------
- def initialize
- qepinit
- @equipped_passive = [] # Only used if [Quasi Passive] is installed
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It is used within the Game_Actors class
- # ($game_actors) and is also referenced from the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- alias qepce change_equip
- #--------------------------------------------------------------------------
- # * Change Equipment
- # slot_id: Equipment slot ID
- # item: Weapon/armor (remove equipment if nil)
- # ** ALIAS **
- #--------------------------------------------------------------------------
- def change_equip(slot_id, item)
- qepce(slot_id, item)
- check_passive_slots
- end
- def passive_slots
- pslots = actor.passive_slots
- @equips.each {|e| next if e.object.nil? ; pslots += e.object.passive_slots}
- pslots
- end
- def check_passive_slots
- if equipped_passive.size > passive_slots
- equipped_passive.each_with_index do |p, i|
- next if i < passive_slots
- forget_passive(p) if $imported["Quasi_Passive"]
- remove_fixed_passive(p) if $imported["Quasi_Fixed_Passive"]
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Patch for Passive
- #--------------------------------------------------------------------------
- def learn_passive(skill_id)
- return unless equipped_passive.include?(skill_id)
- return unless skill_learn?($data_skills[skill_id])
- passive = $data_skills[skill_id].passive
- add_new_state(passive.to_i) if passive
- reset_state_counts(passive.to_i) if passive
- end
- def forget_passive(skill_id)
- if equipped_passive.include?(skill_id)
- passive = $data_skills[skill_id].passive
- remove_passive(passive.to_i) if passive
- equipped_passive.delete(skill_id) if !$imported["Quasi_Fixed_Passive"]
- end
- end
- #--------------------------------------------------------------------------
- # * Patch for Fixed Passive
- #--------------------------------------------------------------------------
- alias qepafp add_fixed_passive if $imported["Quasi_Fixed_Passive"]
- def add_fixed_passive(skill_id)
- return unless equipped_passive.include?(skill_id)
- return unless skill_learn?($data_skills[skill_id])
- passive = $data_skills[skill_id].quasi_passive
- passive.each {|p| passive_list(p, 1)} if passive
- end
- def remove_fixed_passive(skill_id)
- if equipped_passive.include?(skill_id)
- passive = $data_skills[skill_id].quasi_passive
- passive.each {|p| passive_list(p, -1)} if passive
- equipped_passive.delete(skill_id)
- end
- end
- end
- #==============================================================================
- # ** Scene_Skill
- #------------------------------------------------------------------------------
- # This class performs skill screen processing. Skills are handled as items for
- # the sake of process sharing.
- #==============================================================================
- class Scene_Skill < Scene_ItemBase
- alias qepccw create_command_window
- alias qepciw create_item_window
- #--------------------------------------------------------------------------
- # * Update Method
- # ~ Don't really like this, but needed to fix visibility issue.
- #--------------------------------------------------------------------------
- def update
- super
- if $imported["Quasi_STypeEquip"] && $imported["Quasi_SkillEquip"]
- update_with_both
- elsif $imported["Quasi_SkillEquip"]
- update_with_sequip
- elsif $imported["Quasi_STypeEquip"]
- update_with_stype
- else
- update_solo
- end
- end
- def update_solo
- case @command_window.command_name(@command_window.index)
- when Quasi::PassiveEquip::NAMEPASSIVE
- @passive_window.show if !@passive_window.visible
- @item_window.hide if @item_window.visible
- else
- @item_window.show if !@item_window.visible
- @passive_window.hide if @passive_window.visible
- end
- end
- def update_with_sequip
- case @command_window.command_name(@command_window.index)
- when Quasi::SkillEquip::NAMESKILL
- @skill_equip_window.show if !@skill_equip_window.visible
- @item_window.hide if @item_window.visible
- @passive_window.hide if @passive_window.visible
- when Quasi::PassiveEquip::NAMEPASSIVE
- @passive_window.show if !@passive_window.visible
- @skill_equip_window.hide if @skill_equip_window.visible
- @item_window.hide if @item_window.visible
- else
- @item_window.show if !@item_window.visible
- @passive_window.hide if @passive_window.visible
- @skill_equip_window.hide if @skill_equip_window.visible
- end
- end
- def update_with_stype
- case @command_window.command_name(@command_window.index)
- when Quasi::PassiveEquip::NAMEPASSIVE
- @passive_window.show if !@passive_window.visible
- @item_window.hide if @item_window.visible
- @stype_window.hide if @stype_window.visible
- when Quasi::STypeEquip::NAME
- @stype_window.show if !@stype_window.visible
- @passive_window.hide if @passive_window.visible
- @item_window.hide if @item_window.visible
- else
- @item_window.show if !@item_window.visible
- @passive_window.hide if @passive_window.visible
- @stype_window.hide if @stype_window.visible
- end
- end
- def update_with_both
- case @command_window.command_name(@command_window.index)
- when Quasi::SkillEquip::NAMESKILL
- @skill_equip_window.show if !@skill_equip_window.visible
- @item_window.hide if @item_window.visible
- @stype_window.hide if @stype_window.visible
- @passive_window.hide if @passive_window.visible
- when Quasi::STypeEquip::NAME
- @stype_window.show if !@stype_window.visible
- @skill_equip_window.hide if @skill_equip_window.visible
- @item_window.hide if @item_window.visible
- @passive_window.hide if @passive_window.visible
- when Quasi::PassiveEquip::NAMEPASSIVE
- @passive_window.show if !@passive_window.visible
- @skill_equip_window.hide if @skill_equip_window.visible
- @stype_window.hide if @stype_window.visible
- @item_window.hide if @item_window.visible
- else
- @item_window.show if !@item_window.visible
- @passive_window.hide if @passive_window.visible
- @stype_window.hide if @stype_window.visible
- @skill_equip_window.hide if @skill_equip_window.visible
- end
- return
- end
- #--------------------------------------------------------------------------
- # * Create Command Window
- # ** ALIAS **
- #--------------------------------------------------------------------------
- def create_command_window
- qepccw
- @command_window.set_handler(:passive, method(:command_passive))
- end
- #--------------------------------------------------------------------------
- # * Create Skill type Window
- # ** ALIAS **
- #--------------------------------------------------------------------------
- def create_item_window
- qepciw
- create_passive_window
- end
- #--------------------------------------------------------------------------
- # * Create Passive Window
- # ** NEW **
- #--------------------------------------------------------------------------
- def create_passive_window
- wx = @item_window.x
- wy = @item_window.y
- ww = @item_window.width
- wh = @item_window.height
- @passive_window = Window_PassiveList.new(wx, wy, ww, wh)
- @passive_window.actor = @actor
- @passive_window.viewport = @viewport
- @passive_window.help_window = @help_window
- @passive_window.set_handler(:ok, method(:on_passive_ok))
- @passive_window.set_handler(:cancel, method(:on_passive_cancel))
- end
- #--------------------------------------------------------------------------
- # * Passive Command
- # ** NEW **
- #--------------------------------------------------------------------------
- def command_passive
- @passive_window.activate
- @passive_window.select(0)
- end
- #--------------------------------------------------------------------------
- # * Passive [OK]
- # ** NEW **
- #--------------------------------------------------------------------------
- def on_passive_ok
- if @passive_window.item
- if @actor.equipped_passive.include?(@passive_window.item.id)
- Sound.play_ok
- @actor.forget_passive(@passive_window.item.id) if $imported["Quasi_Passive"]
- @actor.remove_fixed_passive(@passive_window.item.id) if $imported["Quasi_Fixed_Passive"]
- else
- if @actor.equipped_passive.size >= @actor.passive_slots
- Sound.play_buzzer
- else
- Sound.play_ok
- @actor.equipped_passive.push(@passive_window.item.id)
- @actor.learn_passive(@passive_window.item.id) if $imported["Quasi_Passive"]
- @actor.add_fixed_passive(@passive_window.item.id) if $imported["Quasi_Fixed_Passive"]
- end
- end
- end
- @status_window.refresh
- @passive_window.refresh
- @passive_window.activate
- end
- #--------------------------------------------------------------------------
- # * Passive [Cancel]
- # ** NEW **
- #--------------------------------------------------------------------------
- def on_passive_cancel
- @passive_window.unselect
- @command_window.activate
- end
- end
- #==============================================================================
- # ** Window_SkillCommand
- #------------------------------------------------------------------------------
- # This window is for selecting commands (special attacks, magic, etc.) on the
- # skill screen.
- #==============================================================================
- class Window_SkillCommand < Window_Command
- alias qpemcl make_command_list
- #--------------------------------------------------------------------------
- # * Create Command List
- # ** REWRITE **
- #--------------------------------------------------------------------------
- def make_command_list
- add_command(Quasi::PassiveEquip::NAMEPASSIVE, :passive, true)
- qpemcl
- end
- end
- #==============================================================================
- # ** Window_PassiveList (NEW)
- #------------------------------------------------------------------------------
- # This window is for displaying a list of available passive skills
- # on the skill window.
- #==============================================================================
- class Window_PassiveList < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super
- @actor = nil
- @data = []
- end
- #--------------------------------------------------------------------------
- # * Set Actor
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- self.oy = 0
- end
- #--------------------------------------------------------------------------
- # * Get Digit Count
- #--------------------------------------------------------------------------
- def col_max
- return 2
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items
- #--------------------------------------------------------------------------
- def item_max
- @data ? @data.size : 1
- end
- #--------------------------------------------------------------------------
- # * Get Skill
- #--------------------------------------------------------------------------
- def item
- @data && index >= 0 ? @data[index] : nil
- end
- #--------------------------------------------------------------------------
- # * Processing When OK Button Is Pressed
- #--------------------------------------------------------------------------
- def process_ok
- Input.update
- deactivate
- call_ok_handler
- end
- #--------------------------------------------------------------------------
- # * Restore Previous Selection Position
- #--------------------------------------------------------------------------
- def select_last
- end
- #--------------------------------------------------------------------------
- # * Create Skill List
- #--------------------------------------------------------------------------
- def make_item_list
- return if !@actor
- @data = []
- @actor.skills.each do |skill|
- if $imported["Quasi_Passive"] && $imported["Quasi_Fixed_Passive"]
- next unless skill.passive || skill.quasi_passive
- elsif $imported["Quasi_Passive"]
- next unless skill.passive
- elsif $imported["Quasi_Fixed_Passive"]
- next unless skill.quasi_passive
- end
- @data.push(skill)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- if skill
- rect = item_rect(index)
- rect.width -= 4
- enable = @actor.equipped_passive.include?(skill.id)
- draw_item_name(skill, rect.x, rect.y, enable)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- text = item ? item.description : ""
- pl = @actor.equipped_passive.size
- pt = @actor.passive_slots
- text += "\n#{Quasi::PassiveEquip::HELP}: #{pl}/#{pt}"
- @help_window.set_text(text)
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- end
- #==============================================================================
- # ** RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- def passive_slots
- if @passive_slots.nil?
- if @note =~ /<(?:passive_slots):(.*)>/i
- @passive_slots = $1.to_i
- else
- @passive_slots = 0
- end
- end
- @passive_slots
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement