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

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Game_BattleAction

Game_BattleAction


Inherits from: None

Description: This class describes a battle action's properties and has methods used in determining the validity and scope of a battle action, as well as the methods that decide the last target or a random target for forced actions.

Code


class Game_BattleAction
# ------------------------------------
  attr_accessor speed
  attr_accessor kind
  attr_accessor basic
  attr_accessor skill_id
  attr_accessor item_id
  attr_accessor target_index
# ------------------------------------
  def initialize
    clear
  end
# ------------------------------------  
  def clear
    @speed = 0
    @kind = 0
    @basic = 3
    @skill_id = 0
    @item_id = 0
    @target_index = -1
  end
# ------------------------------------  
  def valid
    return (not (@kind == 0 and @basic == 3))
  end
# ------------------------------------  
  def for_one_friend
    if @kind == 1 and [3, 5].include($data_skills[@skill_id].scope)
      return true
    end
    if @kind == 2 and [3, 5].include($data_items[@item_id].scope)
      return true
    end
    return false
  end
# ------------------------------------  
  def for_one_friend_hp0
    if @kind == 1 and [5].include($data_skills[@skill_id].scope)
      return true
    end
    if @kind == 2 and [5].include($data_items[@item_id].scope)
      return true
    end
    return false
  end
# ------------------------------------  
  def decide_random_target_for_actor
    if for_one_friend_hp0
      @target_index = $game_party.random_target_actor_hp0.index
    elsif for_one_friend
      @target_index = $game_party.random_target_actor.index
    else
      @target_index = $game_troop.random_target_enemy.index
    end
  end
# ------------------------------------  
  def decide_random_target_for_enemy
      if for_one_friend_hp0
      @target_index = $game_troop.random_target_enemy_hp0.index
    elsif for_one_friend
      @target_index = $game_troop.random_target_enemy.index
    else
      @target_index = $game_party.random_target_actor.index
    end
  end
# ------------------------------------  
  def decide_last_target_for_actor
    if @target_index == -1
      battler = nil
    elsif for_one_friend
      battler = $game_party.actors[@target_index]
    else
      battler = $game_troop.enemies[@target_index]
    end
    if battler == nil or not battler.exist
      clear
    end
  end
# ------------------------------------  
  def decide_last_target_for_enemy
     if @target_index == -1
      battler = nil
    elsif for_one_friend
      battler = $game_troop.enemies[@target_index]
    else
      battler = $game_party.actors[@target_index]
    end
    if battler == nil or not battler.exist
      clear
    end
  end
end

Properties


Speed: The action's speed.

Kind: The kind of action being taken (0 = basic, 1 = skill, 2 = item).

Basic: The type of basic action being taken (0 = Attack, 1 = Defend, 2 = Escape, 3 = No Action)

Skill_ID: The skill ID for a skill action.

Item_ID: The item ID for an item action.

Target_Index: The target index for the action. The index for a party member is his relative positions in the party, and the index for a monster is its ID number. If an action doesn't have a single target or has no target, its target index is -1.

Methods


Initialize

Arguments: None
Local Variables: None

How it Works: Makes a call to the clear method, which sets the class's instance variables to values that represent a null action.

Clear

Arguments: None
Local Variables: None

How it Works: Sets the class's instance variables to their default values, which represent a null action.

Valid

Arguments: None
Local Variables: None

How it Works: Checks to see if the action represented by the instance variables @kind and @basic constitute a valid action.

For_One_Friend

Arguments: None
Local Variables: None

How it Works: Checks to see if the value of $data_skills[@skill_id].scope or $data_items[@item_id].scope includes the values 3 or 5. Either of these values being equal to 3 means that the skill or item can be used on one ally, while the value being 5 means it can be used on one ally with HP 0. 
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