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.
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
|
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.
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.
|
|