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

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Window_BattleStatus

Window_BattleStatus


Inherits from: Window_Base

Description: This class is for the window that shows the party's HP, SP, and status in battle.

Code


class Window_BattleStatus < Window_Base
# ------------------------------------
 def initialize
    super(0, 320, 640, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    @level_up_flags = [false, false, false, false]
    refresh
  end
# ------------------------------------
  def dispose
    super
  end
# ------------------------------------
  def level_up(actor_index)
    @level_up_flags[actor_index] = true
  end
# ------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      actor_x = i * 160 + 4
      draw_actor_name(actor, actor_x, 0)
      draw_actor_hp(actor, actor_x, 32, 120)
      draw_actor_sp(actor, actor_x, 64, 120)
      if @level_up_flags[i]
        self.contents.font.color = normal_color
        self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
      else
        draw_actor_state(actor, actor_x, 96)
      end
    end
  end
# ------------------------------------
  def update
    super
    if $game_temp.battle_main_phase
      self.contents_opacity -= 4 if self.contents_opacity > 191
    else
      self.contents_opacity += 4 if self.contents_opacity < 255
    end
  end
end

Properties


Level_Up_Flags: An array of four flags, one for each position within the party, that tell the window whether it should display the character's status (if the flag is false) or the string "LEVEL UP!" (if the flag is true).

Methods


Initialize

Arguments: None
Local Variables: None

How it Works: This method initializes the window's state. First, it sets the x and y coordinates of the window's upper-left pixel to 0, 320, and its width and height to 640 and 160, respectively. The four flags in @level_up_flags are initially set to false since the string "LEVEL UP!" won't be shown under most circumstances. Finally, the call to refresh populates the window with data.

Dispose

Arguments: None
Local Variables: None

How it Works: This method simply calls its superclass method to clear the window and free the memory allocated to it.

Level_Up

Arguments:
Actor_Index: The relative party position of the actor whose level up flag should be set.
Local Variables: None

How it Works: This method sets one flag in @level_up_flags. The array index of the flag set is equal to the index value passed to this method.

Refresh

Arguments: None
Local Variables: None

How it Works: This method draws the window's contents. First, the existing contents of the window are cleared. For each actor in the party, the following is carried out: The method determines at what x coordinate the text for this actor should be drawn. This value is equal to 160 times the actor's index, plus 4 (remember that the first actor has an index of 0). The actor's name is then drawn at this x coordinate, and y coordinate 0. The actor's HP is drawn at this x coordinate, and y coordinate 32, and the actor's SP is drawn at this x coordinate, and y coordinate 64. Note that the allowed width for both the HP and SP text is 120, which by default is not enough to allow the maximum value to be drawn. If the level up flag for this actor is set, then the string "LEVEL UP!" is drawn at the x coordinate established above, and y coordinate 96. Otherwise, the Window_Base#Draw_Actor_State method is called to draw the actor's status ailments. Please see the documentation for Window_Base for information on how this method works.

Update

Arguments: None
Local Variables: None

How it Works: This method updates the window's contents. First, Window_Base#Update is called to perform updating common to all windows. The updating specific to this window involves the text opacity. If the battle's current phase is 4 (Main Phase), the text opacity decreases by 4 each frame if its opacity is more than 191. If it is not the main phase, then the text opacity increases by 4 if its opacity is less than 255. The practical effect of this is that at the beginning of the main phase, the opacity of the text will decrease by 64 over a period of 16 frames, and the reverse will happen at the end of the main phase. 
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