Home > RGSS Script Reference > Arrow_Enemy
Arrow_Enemy
Inherits from: Arrow_Base
Description: This class defines the behavior of the cursor when pointing at an enemy in battle.
class Arrow_Enemy < Arrow_Base
# ------------------------------------
def enemy
return $game_troop.enemies[@index]
end
# ------------------------------------
def update
super
$game_troop.enemies.size.times do
break if self.enemy.exist?
@index += 1
@index %= $game_troop.enemies.size
end
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += $game_troop.enemies.size - 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
if self.enemy != nil
self.x = self.enemy.screen_x
self.y = self.enemy.screen_y
end
end
# ------------------------------------
def update_help
@help_window.set_enemy(self.enemy)
end
end
|
This class has no properties.
Enemy
Arguments: None
Local Variables: None
How it Works: This method returns the name of the enemy in the specified position in the monster group. For instance, if the enemy group consists of (Goblin, Kobold, Dragon) and the current index is 1, then the enemy method will return "Kobold".
Update
Arguments: None
Local Variables: None
How it Works: This method processes input from the player that moves the arrow cursor. If the engine detects that the player has pressed the left arrow, the value of @index is decremented. If the right arrow is pressed, the value of @index is incremented. In either case, if index falls outside the values 0..[enemy_group_size-1], the cursor will "wrap around" to 0 or enemy_group_size-1 in accordance with the statement
@index %= $game_troop.enemies.size
After executing this statement, the final part of the method updates the arrow's coordinates.
Update_Help
Arguments: None
Local Variables: None
How it Works: This method updates the help window with the name of the currently selected enemy.
|
|