RPG Maker
 

 Username:
 Password:
   Not a member? Register!

Home > RGSS Script Reference > Game_Troop

Game_Troop


Inherits from: None

Description: This class contains information about the monster group currently being fought, and has methods for settings up the monster group and determining a random target for a monster.

Code


class Game_Troop
# ------------------------------------  
  def initialize
    @enemies = []
  end
# ------------------------------------  
  def enemies
    return @enemies
  end
# ------------------------------------  
  def setup(troop_id)
    @enemies = []
    for i in 0...$data_troops[troop_id].members.size
      @enemies.push(Game_Enemy.new(troop_id, i))
    end
  end
# ------------------------------------  
  def random_target_enemy(hp0 = false)
    roulette = []
    for enemy in @enemies
      if (not hp0 and enemy.exist?) or (hp0 and enemy.hp0?)
        roulette.push(enemy)
      end
    end
    if roulette.size == 0
      return nil
    end
    return roulette[rand(roulette.size)]
  end
# ------------------------------------  
  def random_target_enemy_hp0
    return random_target_enemy(true)
  end
# ------------------------------------  
  def smooth_target_enemy(enemy_index)
    enemy = @enemies[enemy_index]
    if enemy != nil and enemy.exist?
      return enemy
    end
    for enemy in @enemies
      if enemy.exist?
        return enemy
      end
    end
  end
end

Properties


Enemies: An array containing Game_Enemy objects representing the enemies in the monster group.

Methods


Initialize

Arguments: None
Local Variables: None

How it Works: Sets @enemies to an empty array representing an empty monster group.

Enemies

Arguments: None
Local Variables: None

How it Works: Returns the @enemies array.

Setup

Arguments:
Troop_ID: The ID of the monster group to set up.
Local Variables: None

How it Works: Set @enemies to an empty array, then accesses the monster group with the appropriate ID from the data declared in the database. For each enemy in the monster group, a Game_Enemy object is pushed into the array.

Random_Target_Enemy

Arguments:
HP0: A flag that determines whether the enemy chosen should be one with 0 HP. false by default.
Local Variables:
Roulette: An array containing the subset of enemies that are valid targets.

How it Works: Decides a random target in the monster group, either with at least 1 HP or 0 HP, depending on the value of the hp0 value passed to the method. First, the value of roulette is set to an empty array. For each enemy in the monster group that has 1 or more HP (if hp0 is false) or 0 (if hp0 is true), The monster is pushed into the roulette array. The random target chosen is the enemy in the array index chosen by the return roulette[rand(roulette.size)] statement.

Random_Target_Enemy_HP0

Arguments: None
Local Variables: None

How it Works: Calls the Random_Target_Enemy method (see above) with the hp0 flag set to true.

Smooth_Target_Enemy

Arguments:
Enemy_Index: The relative position in the monster group of the enemy to check.
Local Variables: None

How it Works: Ensures the enemy in the relative position passed to it is alive and not hidden. If the enemy is alive and not hidden, the enemy's ID is returned. If not, the loop at the end of the method iterates through the enemies in the monster group and returns the first one it finds that is alive and not hidden. 
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.

By continuing past this page, and by your continued use of this site, you agree to be bound by and abide by the Terms of Use.
©2004 - 2008 RPG RPG Revolution, All Rights Reserved. Contact Us · Privacy Policy · Legal Disclaimer
eXTReMe Tracker