V-Gears 0
Free Final Fantasy VII engine.
BattleManager Class Reference

The battle manager. More...

#include <BattleManager.h>

Inheritance diagram for BattleManager:
Collaboration diagram for BattleManager:

Classes

struct  BattleCamera
 A battle camera settings. More...
 
struct  Spoil
 Item earned during the battle. More...
 

Public Types

enum  LAYOUT {
  NORMAL = 0 , PREEMPTIVE = 1 , BACK_ATTACK = 2 , SIDE_ATTACK = 3 ,
  PINCER_ATTACK = 4 , SOLO = 5 , UNKNOWN_0 = 6 , UNKNOWN_1 = 7 ,
  LOCKED = 8
}
 Possible battle layouts. More...
 
- Public Types inherited from Manager
enum  Module { FIELD = 0 , BATTLE = 1 , WORLD = 2 }
 The modules the entity manager can handle. More...
 

Public Member Functions

 BattleManager ()
 Constructor. More...
 
virtual ~BattleManager ()
 Destructor. More...
 
void Input (const VGears::Event &event) override
 Handles an input event. More...
 
void UpdateDebug () override
 Updates the battle in the manager with debug information. More...
 
void OnResize () override
 Handles resizing events. More...
 
void ClearField () override
 Clears all field information in the battle manager. More...
 
void ClearBattle () override
 Clears all battle information in the battle manager. More...
 
void ClearWorld () override
 Clears all world map information in the battle manager. More...
 
void StartBattle (const unsigned int id)
 Starts a battle. More...
 
void EndBattle ()
 Ends the current battle. More...
 
std::vector< EnemyGetEnemies () const
 Retrieves the list of enemies. More...
 
void AddEnemy (const unsigned int id, const Ogre::Vector3 pos, const bool front, const bool visible, const bool targeteable, const bool active, const std::string cover)
 Adds an enemy to the manager for the next battle. More...
 
unsigned int ScriptGetEnemyCount () const
 Retrieves the number of enemies in the battle. More...
 
EnemyScriptGetEnemy (const unsigned int index)
 Retrieves an enemy. More...
 
void Load ()
 Loads enemy info from the enemy XML enemy file. More...
 
void SetLayout (const LAYOUT layout)
 Sets the battle layout. More...
 
void SetFormationId (const int id)
 Sets the battle formation ID. More...
 
void SetNextFormationId (const int id)
 Sets the battle formation ID for the next battle, if any. More...
 
void SetEscapeability (const float difficulty)
 Sets escaping data for the battle. More...
 
void SetSkipVictoryPose (const bool skip)
 Sets the battle to show or skip the victory pose. More...
 
void SetSkipSpoils (const bool skip)
 Sets the battle to show or skip the spoils screens. More...
 
void SetLocation (const int id, const Ogre::String name)
 Sets the battle location. More...
 
void SetArenaBattle (const bool arena)
 Indicates if the battle is an arena battle. More...
 
void SetInitialCamera (const unsigned int id)
 Sets the initial camera. More...
 
void AddCamera (const unsigned int id, const Ogre::Vector3 pos, const Ogre::Vector3 dir)
 Adds a camera for the next battle. More...
 
- Public Member Functions inherited from Manager
 Manager ()
 Constructor. More...
 
virtual ~Manager ()
 Destructor. More...
 
Module GetModule () const
 Retrieves the currently selected module. More...
 
bool IsModule (const Module module) const
 Checks the currently selected module. More...
 
bool IsFieldModule () const
 Checks if the currently selected module is the field module. More...
 
bool IsBattleModule () const
 Checks if the currently selected module is the battle module. More...
 
bool IsWorldModule () const
 Checks if the currently selected module is the world module. More...
 
void SetModule (const Module module)
 Sets the current module for the entity manager. More...
 
void SetFieldModule ()
 Sets the current module to the field mode. More...
 
void SetBattleModule ()
 Sets the current module to the battle mode. More...
 
void SetWorldModule ()
 Sets the current module to the world map mode. More...
 
void SetPreviousModule ()
 Sets the module that was loaded before a battle. More...
 
virtual void Input (const VGears::Event &event)=0
 Handles an input event. More...
 
void Update ()
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void UpdateDebug ()=0
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void OnResize ()=0
 Handles resizing events. More...
 
void Clear ()
 Clears the manager. More...
 
void Clear (const Module module)
 Clears the manager. More...
 
virtual void ClearField ()=0
 Clear all field information in the manager. More...
 
virtual void ClearBattle ()=0
 Clear all battle information in the manager. More...
 
virtual void ClearWorld ()=0
 Clear all world map information in the manager. More...
 
void ClearAll ()
 Clears the manager. More...
 
void ScriptSetPaused (const bool paused)
 Handles game pausing. More...
 

Private Member Functions

void LoadParty ()
 Loads the party members into the battle. More...
 
void UpdateField () override
 Updates the manager while in the field. More...
 
void UpdateBattle () override
 Updates the manager during a battle. More...
 
void UpdateWorld () override
 Updates manager while in the world map. More...
 

Private Attributes

Ogre::SceneNode * scene_node_
 The scene node. More...
 
int formation_id_
 The current battle formation ID. More...
 
int next_formation_id_
 The battle formation ID for the next battle, if any. More...
 
std::vector< BattleCameracamera_
 
unsigned int initial_camera_
 Default camera ID. More...
 
LAYOUT layout_
 Battle layout. More...
 
float escape_difficulty_
 Difficulty to escape the battle. More...
 
bool arena_battle_
 Indicates if the current battle is an arena one. More...
 
bool show_victory_pose_
 Indicates if the victory pose must be shown at the battle end. More...
 
bool show_spoils_
 Indicates if the spoils screens must be shown at the battle end. More...
 
bool preemptive_
 Indicates if the battle can be preemptive (not if it will definitely be). More...
 
unsigned int money_
 Money earned during the current battle. More...
 
std::vector< Spoilspoil_
 List of items earned during the battle. More...
 
std::vector< Enemyenemies_
 List of enemies for the battle. More...
 
std::vector< XmlBattleCharactersFile::BattleCharactercharacter_model_map_
 Map of playable character models. More...
 
std::vector< XmlBattleScenesFile::BattleScenescene_model_map_
 Map of battle scene models. More...
 

Static Private Attributes

static const float ENEMY_SCALE = 0.0032f
 Scale factor for battle enemy models. More...
 
static const float PARTY_SCALE = 0.0039f
 Scale factor for battle character models. More...
 
static const float SCENE_SCALE = 0.0012f
 Scale factor for battle background models. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Manager
virtual void UpdateField ()=0
 Updates the field entities in the manager. More...
 
virtual void UpdateBattle ()=0
 Updates the battle entities in the manager. More...
 
virtual void UpdateWorld ()=0
 Updates the world map entities in the manager. More...
 
void Update (Module module)
 Updates the entities of one module in the manager. More...
 
- Protected Attributes inherited from Manager
Module module_
 The currently selected module. More...
 
Module prev_module_
 The previous module. More...
 
bool paused_
 Indicates if the game is paused. More...
 

Detailed Description

The battle manager.

Member Enumeration Documentation

◆ LAYOUT

Possible battle layouts.

Enumerator
NORMAL 

Normal battle.

Party facing enemies, all ATBs filled at random, they start filling at the battle start.

PREEMPTIVE 

Preemptive attack.

Enemies are facing backwards, their ATBs start empty and only start to fill after an attack or after a set amount of time. PArty starts with full ATBs.

BACK_ATTACK 

Party attacked from the back.

Party members are facing backwards, with their rows reversed. Their ATBs are empty and only start to fill after an attack or after a set amount of time. Enemies start with full ATBs.

SIDE_ATTACK 

Party surrounds the enemy.

Party members alternated on both sides of the battle. They are considered front row for offense and back row for defense. Their ATBs start full. Party-targeted commands only target one side. Enemies in the middle, facing in a random direction. Their ATBs start with a random amount. When attacked, an enemy turns to the attacker.

PINCER_ATTACK 

Enemies surrounds the party.

Enemies alternated on both sides of the battle. They are considered front row for offense and back row for defense. Their ATBs start full. Multiple-targeted commands only target one side. Party members in the middle, facing in a random direction. Their ATBs start with a random amount. When attacked, they turn to the attacker.

SOLO 

Reserved for scripted battles with only one character.

Works the same as {

See also
NORMAL}. In the original game, it's used for the Yuffie pagoda battles and Cloud's last battle against sephiroth
UNKNOWN_0 

Unknown.

Never used in the original game.

UNKNOWN_1 

Unknown.

Never used in the original game.

LOCKED 

Locked formation.

Same as {

See also
NORMAL}, but every party member and enemy is forced in the front row, and the "Change" command is disabled.

Constructor & Destructor Documentation

◆ BattleManager()

BattleManager::BattleManager ( )

Constructor.

◆ ~BattleManager()

BattleManager::~BattleManager ( )
virtual

Destructor.

Member Function Documentation

◆ AddCamera()

void BattleManager::AddCamera ( const unsigned int  id,
const Ogre::Vector3  pos,
const Ogre::Vector3  dir 
)

Adds a camera for the next battle.

Parameters
[in]idCamera ID.
[in]posCamera position (x, y, z).
[in]dirCamera orientation (a point the camera will point to).

◆ AddEnemy()

void BattleManager::AddEnemy ( const unsigned int  id,
const Ogre::Vector3  pos,
const bool  front,
const bool  visible,
const bool  targeteable,
const bool  active,
const std::string  cover 
)

Adds an enemy to the manager for the next battle.

Parameters
[in]idEnemy ID.
[in]posEnemy position (x, y, z).
[in]frontTrue to set the enemy in the front row, false for back row.
[in]visibleIndicates enemy visibility.
[in]targeteableIndicates if the enemy can be targeted.
[in]activeIndicates whether the enemy main script is active or not.
[in]coverCover binary flags string.

◆ ClearBattle()

void BattleManager::ClearBattle ( )
overridevirtual

Clears all battle information in the battle manager.

Implements Manager.

◆ ClearField()

void BattleManager::ClearField ( )
overridevirtual

Clears all field information in the battle manager.

Does nothing.

Implements Manager.

◆ ClearWorld()

void BattleManager::ClearWorld ( )
overridevirtual

Clears all world map information in the battle manager.

Implements Manager.

◆ EndBattle()

void BattleManager::EndBattle ( )

Ends the current battle.

◆ GetEnemies()

std::vector< Enemy > BattleManager::GetEnemies ( ) const

Retrieves the list of enemies.

Returns
The list of enemies.

◆ Input()

void BattleManager::Input ( const VGears::Event event)
overridevirtual

Handles an input event.

Parameters
[in]eventEvent to handle.

Implements Manager.

◆ Load()

void BattleManager::Load ( )

Loads enemy info from the enemy XML enemy file.

◆ LoadParty()

void BattleManager::LoadParty ( )
private

Loads the party members into the battle.

◆ OnResize()

void BattleManager::OnResize ( )
overridevirtual

Handles resizing events.

Implements Manager.

◆ ScriptGetEnemy()

Enemy * BattleManager::ScriptGetEnemy ( const unsigned int  index)

Retrieves an enemy.

To be called from Lua scripts.

Parameters
[in]indexThe enemy index, 0 based. must be lower than reported by {
See also
ScriptGetEnemyCount}.
Returns
The enemy at the selected indes, nullptr if it doesn't exists.

◆ ScriptGetEnemyCount()

unsigned int BattleManager::ScriptGetEnemyCount ( ) const

Retrieves the number of enemies in the battle.

To be called from Lua scripts.

Returns
The number of enemies in the battle formation.

◆ SetArenaBattle()

void BattleManager::SetArenaBattle ( const bool  arena)

Indicates if the battle is an arena battle.

Parameters
[in]arenaTrue for arena battles, false for every other battles.

◆ SetEscapeability()

void BattleManager::SetEscapeability ( const float  difficulty)

Sets escaping data for the battle.

Parameters
[in]difficultyValues between 0 and 1 (exclusive) set the escaping difficulty from easy to hard. 0 Means the battle can be escaped instantly. Any other value means the battle can't be escaped from.

◆ SetFormationId()

void BattleManager::SetFormationId ( const int  id)

Sets the battle formation ID.

Parameters
[in]idBattle formation ID. Negative values to clean the manager.

◆ SetInitialCamera()

void BattleManager::SetInitialCamera ( const unsigned int  id)

Sets the initial camera.

Can be set before configuring the camera, but if the battle starts and this index is invalid, it's undefined behavior.

Parameters
[in]idID of the initial camera.

◆ SetLayout()

void BattleManager::SetLayout ( const LAYOUT  layout)

Sets the battle layout.

Parameters
[in]layoutThe battle layout. {
See also
LAYOUT}. When one of the unknowns is specified, the normal will be applied.

◆ SetLocation()

void BattleManager::SetLocation ( const int  id,
const Ogre::String  name 
)

Sets the battle location.

Parameters
[in]idLocation ID.
[in]nameLocation name, for debug purposes only. Can be empty or null.

◆ SetNextFormationId()

void BattleManager::SetNextFormationId ( const int  id)

Sets the battle formation ID for the next battle, if any.

If set, a new battle will happen when this one is over, instead of returning to the field.

Parameters
[in]idNext battle formation ID. Negative values if none.

◆ SetSkipSpoils()

void BattleManager::SetSkipSpoils ( const bool  skip)

Sets the battle to show or skip the spoils screens.

◆ SetSkipVictoryPose()

void BattleManager::SetSkipVictoryPose ( const bool  skip)

Sets the battle to show or skip the victory pose.

◆ StartBattle()

void BattleManager::StartBattle ( const unsigned int  id)

Starts a battle.

Parameters
idBattle ID.

◆ UpdateBattle()

void BattleManager::UpdateBattle ( )
overrideprivatevirtual

Updates the manager during a battle.

Implements Manager.

◆ UpdateDebug()

void BattleManager::UpdateDebug ( )
overridevirtual

Updates the battle in the manager with debug information.

It's automatically called from {

See also
Update}.

Implements Manager.

◆ UpdateField()

void BattleManager::UpdateField ( )
overrideprivatevirtual

Updates the manager while in the field.

It does nothing

Implements Manager.

◆ UpdateWorld()

void BattleManager::UpdateWorld ( )
overrideprivatevirtual

Updates manager while in the world map.

It does nothing

Implements Manager.

Member Data Documentation

◆ arena_battle_

bool BattleManager::arena_battle_
private

Indicates if the current battle is an arena one.

◆ camera_

std::vector<BattleCamera> BattleManager::camera_
private

◆ character_model_map_

std::vector<XmlBattleCharactersFile::BattleCharacter> BattleManager::character_model_map_
private

Map of playable character models.

◆ enemies_

std::vector<Enemy> BattleManager::enemies_
private

List of enemies for the battle.

◆ ENEMY_SCALE

const float BattleManager::ENEMY_SCALE = 0.0032f
staticprivate

Scale factor for battle enemy models.

◆ escape_difficulty_

float BattleManager::escape_difficulty_
private

Difficulty to escape the battle.

◆ formation_id_

int BattleManager::formation_id_
private

The current battle formation ID.

◆ initial_camera_

unsigned int BattleManager::initial_camera_
private

Default camera ID.

◆ layout_

LAYOUT BattleManager::layout_
private

Battle layout.

◆ money_

unsigned int BattleManager::money_
private

Money earned during the current battle.

◆ next_formation_id_

int BattleManager::next_formation_id_
private

The battle formation ID for the next battle, if any.

◆ PARTY_SCALE

const float BattleManager::PARTY_SCALE = 0.0039f
staticprivate

Scale factor for battle character models.

◆ preemptive_

bool BattleManager::preemptive_
private

Indicates if the battle can be preemptive (not if it will definitely be).

◆ scene_model_map_

std::vector<XmlBattleScenesFile::BattleScene> BattleManager::scene_model_map_
private

Map of battle scene models.

◆ scene_node_

Ogre::SceneNode* BattleManager::scene_node_
private

The scene node.

◆ SCENE_SCALE

const float BattleManager::SCENE_SCALE = 0.0012f
staticprivate

Scale factor for battle background models.

◆ show_spoils_

bool BattleManager::show_spoils_
private

Indicates if the spoils screens must be shown at the battle end.

◆ show_victory_pose_

bool BattleManager::show_victory_pose_
private

Indicates if the victory pose must be shown at the battle end.

◆ spoil_

std::vector<Spoil> BattleManager::spoil_
private

List of items earned during the battle.


The documentation for this class was generated from the following files: