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.

Skill Equipment System

Skill Equipment System
Authors: game_guy
Version: 1.34


Introduction

Okay well its a system that makes it so you can't use all of your skills at once while in battle. Instead you have to equip them. Now here's the catch. Every skill has its own "ap" so when its equipped it takes some of the actor's ap. That way you can't use all of your skills and it adds some uniqueness to the game.

Features

  • Equip Skills Strategically
  • Only Equip Limited Amount of Skills Using Ap
  • Have Different Starting Ap for Each Actor
  • Have Different Ap Gain for Each Actor per Level Up
  • Have Different Ap for Each Skill
  • Have an Exit Scene for When the Skill Equipment Closes

Screenshots

skill.png

Demo

Updating Demo

Script

Code:
 

#===============================================================================

# Skill Equipment System

# Author game_guy

# Version 1.34

#-------------------------------------------------------------------------------

# Intro:

# Okay well its a system that makes it so you can't use all of your skills at

# once while in battle. Instead you have to equip them. Now here's the catch.

# Every skill has its own "ap" so when its equipped it takes some of the actor's

# ap. That way you can't use all of your skills and it adds some uniqueness to 

# the game.

#

# Features:

# Equip Skills Strategically

# Only Equip Limited Amount of Skills Using Ap

# Have Different Starting Ap for Each Actor

# Have Different Ap Gain for Each Actor per Level Up

# Have Different Ap for Each Skill

# Have an Exit Scene for When the Skill Equipment Closes

#

# Instructions:

# Okay so these could be confusing but lets try and get through this.

# Okay they're not that confusing. Okay so go down where it says

# # Begin Config

# And do all of you're configuration there. 

#

# Now theres some stuff you need to know. 

#

# When adding a skill it does not automatically equip it. So to equip a

# skill use this

# $game_actors[actor_id].equip_skill(skill_id)

# To unequip a skill use this

# $game_actors[id].remove_skill(skill_id)

#

# Now it will not equip it unless there's enough ap left. So you can either do

# this $game_actors[id].add_map(amount) to add to max ap or you can do this

# $game_actors[id].clear_skills to unequip all skills and give all ap back.

# Just to make it a bit easier.

#

# You can always remove max ap to by doing this

# $game_actors[id].remove_map(amount) but note that doing that clears the

# equipped skills as well to avoid any problems. 

#

# To open the skill equipment scene use this.

# $scene = $scene = Scene_SkillEquip.new(actor_id)

# To tell if a skill is equipped or not you'll notice the text is greyed out.

# That means it equipped. If its white it means it can be equipped.

# In the scene though to equip/unequip things just press the action button.

#

# Well thats about it. 

# Credits:

# game_guy ~ for making it

# Ethan ~ for the idea of it

# Branden ~ beta testing

#

# Enjoy and give credits.

#===============================================================================

module GameGuy

  #---------------------------------------------------------------------------

  # ApWord     = This is the word that displays when showing the ap the actor

  #              has.

  #---------------------------------------------------------------------------

  ApWord       = "AP"

  #---------------------------------------------------------------------------

  # StartingAp = The starting ap for every actor. Different amounts can be

  #              defined below at # Config Starting Ap.

  #---------------------------------------------------------------------------

  StartingAp   = 5

  #---------------------------------------------------------------------------

  # ApCost     = The default ap cost for all skills. Different amounts can be

  #              defined below at # Config Ap Costs.

  #---------------------------------------------------------------------------

  ApCost       = 5

  #---------------------------------------------------------------------------

  # ApGain     = The max ap gained when an actor levels up. Different amounts

  #              can be defined below at # Config Sp Gain

  #---------------------------------------------------------------------------

  ApGain       = 2

  #---------------------------------------------------------------------------

  # ExitScene  = The scene it goes to when the Skill Equipment closes.

  #

  #---------------------------------------------------------------------------

  ExitScene    = Scene_Menu.new

  def self.start_ap(id)

    case id

    #-------------------------------------------------------------------------

    # Config Starting Ap

    # Use this when configuring

    # when actor_id then return starting_ap

    #-------------------------------------------------------------------------

    when 1 then return 10 # Actor 1 : Aluxes

    when 2 then return 8  # Actor 2 : Basil

    end

    return StartingAp

  end

  def self.skill_ap(id)

    case id

    #-------------------------------------------------------------------------

    # Config Ap Costs

    # Use this when configuring

    # when skill_id then return ap_cost

    #-------------------------------------------------------------------------

    when 1 then return 2 # Skill Id 1 : Heal

    when 7 then return 3 # Skill Id 7 : Fire

    end

    return ApCost

  end

  def self.ap_gain(id)

    case id

    #-------------------------------------------------------------------------

    # Config Ap gain

    # Use this when configuring

    # when actor_id then return ap_gain

    #-------------------------------------------------------------------------

    when 1 then return 4 # Actor 1 : Aluxes

    end

    return ApGain

  end

end

 

#==============================================================================

# Game_Actor

#------------------------------------------------------------------------------

# Added stuff for Skill Equipping.

#==============================================================================

class Game_Actor

  attr_accessor :eskills

  attr_accessor :skills

  attr_accessor :skillap

  attr_accessor :skillmaxap

  attr_accessor :eeskills

  alias gg_add_stuff_lat_ap setup

  def setup(actor_id)

    @actor = $data_actors[actor_id]

    @skillap = GameGuy.start_ap(actor_id)

    @skillmaxap = GameGuy.start_ap(actor_id)

    @eskills = []

    @eeskills = []

    return gg_add_stuff_lat_ap(actor_id)

  end

  def learn_skill(skill_id)

    if skill_id > 0 and not skill_learn?(skill_id)

      @eskills.push(skill_id)

      @eskills.sort!

    end

  end

  def forget_skill(skill_id)

    @eskills.delete(skill_id)

  end

  def equip_skill(skill_id)

    skill = $data_skills[skill_id]

    if @skillap < GameGuy.skill_ap(skill.id)

      return

    end

    @skillap -= GameGuy.skill_ap(skill.id)

    if skill_id > 0 && @eskills.include?(skill_id)

      @skills.push(skill_id)

      @skills.sort!

      @eeskills.push(skill_id)

    end

  end

  def remove_skill(id)

    @skillap += GameGuy.skill_ap(id)

    @skills.delete(id)

    @eeskills.delete(id)

  end

  def add_map(n)

    @skillmaxap += n

    clear_skills

    @skillap = @skillmaxap

  end

  def remove_map(n)

    @skillmaxap -= n

    if @skillmaxap < 0

      @skillmaxap = 0

    end

    if @skillap > @skillmaxap

      @skillap = @skillmaxap

    end

    clear_skills

  end

  def exp=(exp)

    @exp = [[exp, 9999999].min, 0].max

    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0

      @level += 1

      @ap += GameGuy.ap_gain(@id)

      for j in $data_classes[@class_id].learnings

        if j.level == @level

          learn_skill(j.skill_id)

        end

      end

    end

    while @exp < @exp_list[@level]

      @level -= 1

    end

    @hp = [@hp, self.maxhp].min

    @sp = [@sp, self.maxsp].min

  end

  def clear_skills

    @skills = []

    @eeskills = []

    @ap = @maxap

  end

end

 

#==============================================================================

# Window_GGAPSkill

#------------------------------------------------------------------------------

# Copy of Window_Skill but just slightly different.

#==============================================================================

class Window_GGAPSkill < Window_Selectable

  def initialize(actor)

    super(0, 128, 640, 352)

    @actor = actor

    @column_max = 2

    refresh

    self.index = 0

  end

  def skill

    return @data[self.index]

  end

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    for i in [email=0...@actor.eskills.size]0...@actor.eskills.size[/email]

      skill = $data_skills[@actor.eskills[i]]

      if skill != nil

        @data.push(skill)

      end

    end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

  def draw_item(index)

    skill = @data[index]

    if @actor.skill_can_use?(skill.id)

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 2 * (288 + 32)

    y = index / 2 * 32

    rect = Rect.new(x, y, self.width / @column_max - 32, 32)

    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

    bitmap = RPG::Cache.icon(skill.icon_name)

    opacity = self.contents.font.color == normal_color ? 255 : 128

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)

    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)

  end

  def update_help

    @help_window.set_text(self.skill == nil ? "" : self.skill.description)

  end

end

 

#==============================================================================

# Window_GGAPSkillEquip

#------------------------------------------------------------------------------

# Window uses for equipping skills.

#==============================================================================

class Window_GGAPSkillEquip < Window_Selectable

  def initialize(actor)

    super(0, 128, 640, 352)

    @actor = actor

    @column_max = 2

    refresh

    self.index = 0

  end

  def skill

    return @data[self.index]

  end

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    for i in [email=0...@actor.eskills.size]0...@actor.eskills.size[/email]

      skill = $data_skills[@actor.eskills[i]]

      if skill != nil

        @data.push(skill)

      end

    end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

  def draw_item(index)

    skill = @data[index]

    if @actor.eeskills.include?(skill.id)

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 2 * (288 + 32)

    y = index / 2 * 32

    rect = Rect.new(x, y, self.width / @column_max - 32, 32)

    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

    bitmap = RPG::Cache.icon(skill.icon_name)

    opacity = self.contents.font.color == normal_color ? 255 : 128

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)

    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)

  end

  def update_help

    @help_window.set_text(self.skill == nil ? "" : self.skill.description)

  end

end

 

#==============================================================================

# Window_GGActorAp

#------------------------------------------------------------------------------

# Window used to display AP and Actor name.

#==============================================================================

class Window_GGActorAp < Window_Base

  def initialize(actor)

    super(0,64,640,64)

    self.contents = Bitmap.new(width-32,height-32)

    @actor = $game_actors[actor]

    refresh

  end

  def refresh

    self.contents.clear

    ap = GameGuy::ApWord

    self.contents.draw_text(0, 0, 640, 32, "#{@actor.name}")

    self.contents.draw_text(0, 0, 640, 32, "#{ap} #{@actor.skillap} / " +

                                           "#{@actor.skillmaxap}", 2)

  end

end

 

#==============================================================================

# Scene_Skill

#------------------------------------------------------------------------------

# Just slightly modded the main method.

#==============================================================================

 

 

#==============================================================================

# Scene_SkillEquip

#------------------------------------------------------------------------------

# The scene that deals with equipping skills.

#==============================================================================

class Scene_SkillEquip

  def initialize(actor_id=1)

    @id = actor_id

  end

  def main

    @actor = $game_actors[@id]

    @help_window = Window_Help.new

    @skill_window = Window_GGAPSkillEquip.new(@actor)

    @skill_window.help_window = @help_window

    @status_window = Window_GGActorAp.new(@actor.id)

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    @help_window.dispose

    @skill_window.dispose

    @status_window.dispose

  end

  def update

    @help_window.update

    @skill_window.update

    @status_window.update

    if @skill_window.active

      update_skill

      return

    end

  end

  def update_skill

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = GameGuy::ExitScene

      return

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      skill = @skill_window.skill

      if @actor.eeskills.include?(skill.id)

        @actor.remove_skill(skill.id)

      else

        if @actor.skillap < GameGuy.skill_ap(skill.id)

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        @actor.equip_skill(skill.id)

      end

      @status_window.refresh

      @skill_window.refresh

      return

    end

  end

end

 

Instructions

In the script.

Compatibility

Not tested with SDK.

Credits and Thanks

  • game_guy ~ for making it
  • Ethan (A Friend) ~ for making the idea of it
  • Branden ~ beta testing

Author's Notes

Give credits and enjoy
 
silver wind":1mmti8hw said:
what does Ap stand for?
30 bucks on Ability Points! :grin:

As for the system... I dunno, while it looks like an idea that could work out, I'm not too fond of the execution... scripting style aside (sometimes you have seperators, sometimes not... then there's weird class names such as Window_GCActorAp, varying comma spacing, and even a whole redundant header for a Scene_Skill mod that doesn't exist... as well as horrible - and I mean horrible- commenting, especially in the module part as there's no comments anywhere else... you don't seem to follow any conventions at all), I wonder what's with the design.
Judging from the screenshot alone, the actor has 4 skills in total, two of which are equipped (perfect white), while the other two aren't (semi-transparent white) - so far, so good, unles this is actually the window you spawn in battle - you really don't need to see skills that you can't use anyway.
Well, then there's random numbers next to the skill names... my first guess was that these are AP, as that's the only unit even suggested by the screenshot, however with a max amount of AP given, that can hardly be the case. So, it has to be MP/SP/whatever, meaning the number for the needed AP is completely missing. Why's that, is this just the skill window, and you manage skills in a different scene? In that case, I wonder why you even mention AP in there, which btw would even be redundant in battle, or why there isn't a screenshot of that scene. Overall, the Name/AP window seems to wait for something being displayed on the far right the way you seperated it.
Finally, there's the strange layout of the shown scene: The help window is at the highest position, the skill window at the lowest. These two tied-together elements are seperated with a status bar that - despite having no purpose whatsoever, aside from showing some values noone needs in this scene - isn't even vaguely related to either the help or the skill window.

I suggest you work out those things, as I think this could turn out as a pretty fun script to integrate in games.


On a general note, you might want to edit your font sizes... note that phpbb works with percentage values - this isn't vB ;) Also, you're crediting three people there, and below mention you want people to give credits, making me assume you mean at least two... now, you don't really expect anyone to credit someone for beta testing or giving you the idea for this now, do you? :huh:
 
The credits thing. Its something I always do and will do. Its always been a habit. Someone helped me test it, or helped me come up with the idea, I feel they need credit. I at least expect people to credit me the others are there just for being credited by me.

Okay the AP value up there isn't useless. It just happens that the 2 skills equip require 0 AP. The designs ugly I know. It uses its own scene and windows so in battle you only see your equipped skills. The AP is there to show you how much ap used / how much ap total. Like I said the designs ugly and I plan on remaking it. The numbers next to the skills are sp cost, and in my design I've layed out you'll be able to tell.

I'm just experimenting with my comment style. I don't really care for comments all throughout my code. I prefer comments for introductions, features, instructions, credits etc. I know it may be selfish or nooby but I don't like explaining my code or how I did it. Also to note, if I were to remake this right now it'd be coded a lot differently, it'd look a lot differently. I made this I believe sometime last year.

Anyways thanks for pointing out the flaws, I will fix them all when I have time. I really appreciate your input. Its hard to improve something when like the other forum I posted this on, one person posted "Great script." thats it. So thank you.

The AP is customary. It is Ability Points but can be changed. And there is a script call in the instructions.
 
The thing with commenting is, not to have it at least doesn't hurt readability, however yours is pretty cluttered and all over the place, while even the seperators are missing in other places. It's totally discouraging to read through it, and will therefore discourage people from working with your script (that doesn't mean they won't use it, it means they won't try to figure stuff out they can do with it). Personally, I never comment my scripts really, unless there's vast understanding issues (like in the Database Flag Reader of mine) - nevertheless, I always pay attention to write clean code that goes within the bounds of RMVXP's standarts, so everyone can easily adapt to it.

As for the AP display, it's useless because you can't affect how AP are used from that scene at all. Now you could say it might interest the player at the time, but yeah... then you could just as well write HP in there (which probably WOULD be effective, as there's the chance of healing spells being available), nevermind SP.

Other than that, I hope you're successful ironing out the flaws ^^
 

Tuna

Awesome Bro

This sounds very familiar to the AP system in
eability_e.jpg

which apparently has been repeatedly imitated in XP and VX
Immagine-3.jpg

So if you weren't aware that you're pretty much imitating Final Fantasy 9, you might want to check out that AP system to give you some inspiration, or try to track down one of the XP/VX scripts of it that are probably already floating around out there.

Godspeed. :biggrin:
 

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