Submit Your Article Guild Wars 2 Forum RPG Maker VX.com
 
RPG Maker
 

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Window_Skill

Window_Skill


Inherits from: Window_Selectable

Description: This window lists the skills that an actor can use. This window is used both on the main menu and in battle.

Code


class Window_Skill < Window_Selectable
# ------------------------------------
 def initialize(actor)
    super(0, 128, 640, 352)
    @actor = actor
    @column_max = 2
    refresh
    self.index = 0
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  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 0...@actor.skills.size
      @data.push($data_skills[@actor.skills[i]])
    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

Properties


Actor: The actor who is using the skill selected from this window.

Data: An array containing the skills to be drawn. The contents of this array are determined in the refresh method.

Methods


Initialize

Arguments:
Actor: The actor who is using the skill selected from this window.
Local Variables: None

How it Works: This method initializes the window. The window's x coordinate is initialized to 0, the y coordinate is initialized to 128, the width to 640, and the height to 352. The value of @actor is initialized to the actor passed to this method. All the data is then drawn by the refresh method. If the party is in battle, the skill window must be made smaller, so the height is set to 256 in this case. The skill window is also partially transparent in battle, as opposed to completely opaque in the menu, so the back opacity is set to 160.

Skill

Arguments: None
Local Variables: None

How it Works: This method returns the skill in the @data array corresponding to the index of the currently selected skill.

Refresh

Arguments: None
Local Variables: None

How it Works: This method draws the contents of the skill window. First, the window disposes of its contents and constructs an entirely new bitmap, since the height of the bitmap is tailored to the number of skills to be displayed. The @data array is then initialized to an empty array. The @data array is constructed by adding every skill the actor knows to the array. The value of @item_max is now set to the size of the now-full @data array. The bitmap is created, and then the draw_item method is used to draw each individual skill on the menu.

Draw_Item

Arguments:
Index: The index of the skill to be drawn.
Local Variables: None

How it Works: This method draws an individual skill in the window. First, a determination about whether the actor whose skills are being displayed in this window can use the skill being drawn by this method. If the actor can use the skill, its name is drawn in the normal color. If not, the name is drawn in the disabled color. The next thing to do is acquire the coordinates at which the skill's name and icon should be drawn. If the skill's index is even, then the x coordinate at which the skill is drawn is 4. If the skill's index is odd, then x coordinate is 324. The y coordinate at which the skill is drawn is half the index (rounded down) multiplied by 32. The method then acquires the bitmap of the skill's icon. The skill's icon is then drawn in a 24x24 rectangle. The skill's name is drawn, followed by the skill's SP cost to the right of its name. Note that the optional argument "2" is present in the call draw_text for the SP cost. This means that the SP cost will be drawn right-aligned within its bounding box.

Update_Help

Arguments: None
Local Variables: None

How it Works: This method updates the help window with the description of the currently selected skill, or nil if an empty space is currently selected. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

RPG RPG Revolution is an Privacy Policy and Legal