Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Selecting/Deselecting Skills for battle array

What it does
It avoids clutter on the battle skill select screen.

It causes all skills learned by the character to become unequipped. To use them in battle they must first be equipped. This is easy. Just go to the Skills screen and select whatever skills you want to be used in battle. They will change color from gray to white. Selected skills will now be enabled. This was meant to avoid the clutter of having to cursor over Fire 1, Fire 2, Fire 3 in order to get to Fire 4. Late in RPG's players tend to use the same skills and neglect earlier ones.  This is useful for keeping it simple.

I am pretty sure we can find more uses for it.

The code is based on code from Momomo's Ability AP learning system used in XP. Just copy/paste it into a new script above main.

Code:
# Equip/Unequip Skill System
# created/posted by canepalace, based on a similar system coded by Momomo
# just insert over main and it works
# when new skills are learned they must be equipped before they can be used in battle
# this will avoid the clutter of having to skip over Fire 1, when you've learned Fire 3, etc.
# it is also useful for more things that this 
 
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  #  actor_id
  #--------------------------------------------------------------------------
  alias ability_system_initialize initialize
  def initialize(actor_id)
    @ability = {} 
    @ability_skill = [] 
    ability_system_initialize(actor_id)
  end
  
  def ability_equip_ok?(skill_id)
    return true
  end

  def add_ability(skill_id)
    unless @ability_skill.include?(skill_id)
      @ability_skill.push(skill_id)
    end
  end

  def del_ability(skill_id)
    @ability_skill.delete(skill_id)
  end

  def ability_initialize(skill_id)
    @ability[skill_id] = 0
  end

  def equip_ability(skill_id)
    @ability[skill_id] = 1
    add_ability(skill_id)
  end

  def remove_ability(skill_id)
    @ability[skill_id] = 0
    del_ability(skill_id)
  end

  def ability_equip?(skill_id)
    unless @ability.include?(skill_id)
      ability_initialize(skill_id)
    end
    return false if @ability[skill_id] == 0
    return true
  end

  def ability_fix?(skill_id)
    return false
  end

  def og_skills
    return @skills
  end

  def skills
    return @ability_skill
  end

  #--------------------------------------------------------------------------
  # skill_id 
  #--------------------------------------------------------------------------
  alias ability_system_learn_skill learn_skill
  def learn_skill(skill_id)
    ability_system_learn_skill(skill_id)
    if @skills.include?(skill_id) and @ability != nil
      unless @ability.include?(skill_id)
        ability_initialize(skill_id)
        add_ability(skill_id)
      end
    end
  end
  #--------------------------------------------------------------------------
  #     skill_id 
  #--------------------------------------------------------------------------
  alias ability_system_forget_skill forget_skill
  def forget_skill(skill_id)
    ability_system_forget_skill(skill_id)
    remove_ability(skill_id)
  end
  #--------------------------------------------------------------------------
  #     skill_id 
  #--------------------------------------------------------------------------
  alias ability_system_skill_learn? skill_learn?
  def skill_learn?(skill_id)
    if ability_system_skill_learn?(skill_id) or @ability_skill.include?(skill_id)
      return true
    else
      return false
    end
  end
end

#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
#  This window contains cursor movement and scroll functions.
#==============================================================================

class Window_Selectable < Window_Base

  #--------------------------------------------------------------------------
  # * Create Window Contents
  #--------------------------------------------------------------------------
  def create_contents
    self.contents = Bitmap.new(width - 32, [height - 32, row_max * WLH].max)
  end
end

#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
#  This window displays a list of usable skills on the skill screen, etc.
#==============================================================================

class Window_Skill < Window_Selectable

  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
  
    @data = []
    for i in 0...@actor.og_skills.size
      skill = $data_skills[@actor.og_skills[i]]
      if  $game_temp.in_battle and !@actor.ability_equip?(skill)
        #Do not even add skill to list in battle if not equipped
      else
        @data.push(skill)
      end
    end   

    @item_max = @data.size
    create_contents
    for i in 0...@item_max
        draw_item(i) 
    end
    
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    skill = @data[index]
    if skill != nil
      rect.width -= 4
      enabled = @actor.ability_equip?(skill)
      draw_item_name(skill, rect.x, rect.y, enabled)
      self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
    end
  end

end





#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
#  This class performs the skill screen processing.
#==============================================================================

class Scene_Skill < Scene_Base

  #--------------------------------------------------------------------------
  # * Update Skill Selection
  #--------------------------------------------------------------------------
  def update_skill_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::R)
      Sound.play_cursor
      next_actor
    elsif Input.trigger?(Input::L)
      Sound.play_cursor
      prev_actor
    elsif Input.trigger?(Input::C)
      @skill = @skill_window.skill                        
      if @skill == nil 
        @actor.last_skill_id = @skill.id
        Sound.play_buzzer
        return
      end
      if @actor.ability_equip?(@skill)
        @actor.remove_ability(@skill)
        Sound.play_equip
      else                                                
        @actor.equip_ability(@skill) 
        Sound.play_equip
      end      
      @skill_window.refresh
      @status_window.refresh
      return
    else

    end
  end

end




Future Add-ons

  • maximum amount of skills equippable
  • skill information window
 
Pretty cool script.  This could become extremely cool and useful if you put a couple of more features in it.
About finding more uses, I can think of some.
You can add a feature to the script where a certain collection of skills results in an added skill or even stat power-ups.
Another feature could be that the character(s) learn(s) skills that would increase the maximum skill slots but obviously don't show up in battle.
This idea is kind of obscure but maybe each skill contributes to a certain attribute or stat of a character and the creator of the game can toggle whether they want to tell the player what a skill enhances or not.
For Example: Megaman has 5 skill slots.  He equips 4 fire shot skills and an aqua armor skill.  His regular attack now has fire properties according to the amount of fire shots and his water tolerance has increased.  Once again that last one was just a spur of the moment idea.
 
Oh wow as soon as you implement putting a limit on the maximum amount of skills you can equip this is perfect for what I originally wanted to use in my game! I hope you keep working on this! :)
 
Very cool. If this can be applied individual actors, along with a cap of how many skills can be equipped and a Blue Magic script, you can completely recreate the Blue Mage from Final Fantasy XI. An example is equipping Plasma Charge, which also increases your STR and DEX by 3. If you equip it with conjunction with Actinic Burst, you also get a character trait/perk such as Auto Refresh.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top