Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #** Quasi Skill Type Equip v 2.1
- #==============================================================================
- # Allows players to equip skill types.
- #==============================================================================
- # Instructions:
- # Very simple to use, mostly plug and play.
- #
- # If used with Quasi Passive Equip or Quasi Skill Equip, place this ABOVE those
- # scripts!
- #------------------------------------------------------------------------------
- # * Note Tag
- #------------------------------------------------------------------------------
- # <stype_slots: #>
- # Can be placed in actors note box, or weapons/armor. Default is 0
- #
- # If an actor has 2 stype slots, and equips a weapon with 2 more slots. You
- # will be able to equip 4 skill types. If you unequip the weapon, the last
- # 2 skill types equipped, will be unequipped.
- #------------------------------------------------------------------------------
- # * Log
- #------------------------------------------------------------------------------
- # v 2.1 9/4/14
- # - Fixed a bug that caused game to freeze
- # v 2.0 9/3/14
- # - Removed optional passive equip.
- # - Added compatibility with Passive Equip and Skill Equip
- # v 1.1, 9/1/14
- # - Fixed a problem with passive skills when unequipping items with
- # passive slots
- #-----------------------------------------------------------------------------
- module Quasi
- module STypeEquip
- # Title to appear in the command window.
- NAME = "Stype Equip"
- # Give descriptions to your skill types
- # stype_id => "description",
- # ** don't forget the comma unless it's the last one
- DESC = {
- 1 => "Special skills are very weak",
- 4 => "Test1 Skills are overpowered"
- }
- end
- end
- #==============================================================================#
- # By Quasi (http://quasixi.wordpress.com/)
- # - 6/10/14
- #==============================================================================#
- # ** Stop! Do not edit anything below, unless you know what you **
- # ** are doing! **
- #==============================================================================#
- $imported = {} if $imported.nil?
- $imported["Quasi_STypeEquip"] = 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 qesinit initialize
- attr_accessor :equipped_skill_types
- attr_accessor :equipped_passive
- #--------------------------------------------------------------------------
- # * Object Initialization
- # ** ALIAS **
- #--------------------------------------------------------------------------
- def initialize
- qesinit
- @equipped_skill_types = []
- 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 qesce change_equip
- def stype_slots
- slots = actor.stype_slots
- @equips.each {|e| next if e.object.nil? ; slots += e.object.stype_slots}
- slots
- end
- def check_stype_slots
- if equipped_skill_types.size > stype_slots
- equipped_skill_types.slice!(stype_slots..equipped_skill_types.size)
- end
- end
- #--------------------------------------------------------------------------
- # * Change Equipment
- # slot_id: Equipment slot ID
- # item: Weapon/armor (remove equipment if nil)
- # ** ALIAS **
- #--------------------------------------------------------------------------
- def change_equip(slot_id, item)
- qesce(slot_id, item)
- check_stype_slots
- 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 qesccw create_command_window
- alias qesciw create_item_window
- #--------------------------------------------------------------------------
- # * Update Method
- # ~ Don't really like this, but needed to fix visibility issue.
- #--------------------------------------------------------------------------
- def update
- super
- if $imported["Quasi_PassiveEquip"] && $imported["Quasi_SkillEquip"]
- update_with_both
- elsif $imported["Quasi_SkillEquip"]
- update_with_sequip
- elsif $imported["Quasi_PassiveEquip"]
- update_with_passive
- else
- update_solo
- end
- end
- def update_solo
- case @command_window.command_name(@command_window.index)
- when Quasi::STypeEquip::NAME
- @stype_window.show if !@stype_window.visible
- @item_window.hide if @item_window.visible
- else
- @item_window.show if !@item_window.visible
- @stype_window.hide if @stype_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
- @stype_window.hide if @stype_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
- else
- @item_window.show if !@item_window.visible
- @stype_window.hide if @stype_window.visible
- @skill_equip_window.hide if @skill_equip_window.visible
- end
- end
- def update_with_passive
- 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
- qesccw
- @command_window.set_handler(:stype, method(:command_stype))
- end
- #--------------------------------------------------------------------------
- # * Create Skill type Window
- # ** ALIAS **
- #--------------------------------------------------------------------------
- def create_item_window
- qesciw
- wx = @item_window.x
- wy = @item_window.y
- ww = @item_window.width
- wh = @item_window.height
- @stype_window = Window_STypeList.new(wx, wy, ww, wh)
- @stype_window.actor = @actor
- @stype_window.viewport = @viewport
- @stype_window.help_window = @help_window
- @stype_window.set_handler(:ok, method(:on_stype_ok))
- @stype_window.set_handler(:cancel, method(:on_stype_cancel))
- end
- #--------------------------------------------------------------------------
- # * Skill Type Command
- # ** NEW **
- #--------------------------------------------------------------------------
- def command_stype
- @actor.stype_slots
- @stype_window.activate
- @stype_window.select(0)
- end
- #--------------------------------------------------------------------------
- # * Skill Type [OK]
- # ** NEW **
- #--------------------------------------------------------------------------
- def on_stype_ok
- if @stype_window.item
- if @actor.equipped_skill_types.include?(@stype_window.item)
- Sound.play_ok
- @actor.equipped_skill_types.delete(@stype_window.item)
- else
- if @actor.equipped_skill_types.size >= @actor.stype_slots
- Sound.play_buzzer
- else
- Sound.play_ok
- @actor.equipped_skill_types.push(@stype_window.item)
- end
- end
- end
- @stype_window.refresh
- @stype_window.activate
- @command_window.refresh
- end
- #--------------------------------------------------------------------------
- # * Skill Type [Cancel]
- # ** NEW **
- #--------------------------------------------------------------------------
- def on_stype_cancel
- @stype_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
- #--------------------------------------------------------------------------
- # * Create Command List
- # ** REWRITE **
- #--------------------------------------------------------------------------
- def make_command_list
- add_command(Quasi::STypeEquip::NAME, :stype, true)
- return unless @actor
- @actor.equipped_skill_types.sort.each do |stype_id|
- name = $data_system.skill_types[stype_id]
- add_command(name, :skill, true, stype_id)
- end
- end
- end
- #==============================================================================
- # ** Window_STypeList (NEW)
- #------------------------------------------------------------------------------
- # This window is for displaying a list of available skills types
- # on the skill window.
- #==============================================================================
- class Window_STypeList < 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
- #--------------------------------------------------------------------------
- # * Create Skill List
- #--------------------------------------------------------------------------
- def make_item_list
- return if !@actor
- @data += @actor.added_skill_types
- @actor.skills.each do |s|
- if $imported["Quasi_Passive"]
- next if s.stype_id == Quasi::Passive::TYPE
- end
- @data.push(s.stype_id)
- end
- @data.uniq!; @data.sort!
- end
- #--------------------------------------------------------------------------
- # * Restore Previous Selection Position
- #--------------------------------------------------------------------------
- def select_last
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- if skill
- stype = $data_system.skill_types[skill]
- rect = item_rect(index)
- rect.width -= 4
- enable = @actor.equipped_skill_types.include?(skill)
- change_color(normal_color, enable)
- draw_text(rect.x + 24, rect.y, 172, 24, stype)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- stype = Quasi::STypeEquip::DESC[@data[index]]
- stype = "" if stype.nil?
- sa = @actor.skills.select {|s| s.stype_id==@data[index]}
- sa = sa.size
- stype += "\n #{sa} Skills known."
- @help_window.set_text(stype)
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- end
- #==============================================================================
- # ** Window_ActorCommand
- #------------------------------------------------------------------------------
- # This window is for selecting an actor's action on the battle screen.
- #==============================================================================
- class Window_ActorCommand < Window_Command
- #--------------------------------------------------------------------------
- # * Add Skill Command to List
- # ** REWRITE **
- #--------------------------------------------------------------------------
- def add_skill_commands
- @actor.equipped_skill_types.sort.each do |stype_id|
- name = $data_system.skill_types[stype_id]
- add_command(name, :skill, true, stype_id)
- end
- end
- end
- #==============================================================================
- # ** RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- def stype_slots
- if @stype_slots.nil?
- if @note =~ /<(?:stype_slots):(.*)>/i
- @stype_slots = $1.to_i
- else
- @stype_slots = 0
- end
- end
- @stype_slots
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement