hoa_map::private_map::EnemySprite Class Reference

A mobile map object that induces a battle to occur if the player touches it. More...

#include <map_sprites.h>

Inheritance diagram for hoa_map::private_map::EnemySprite:

Inheritance graph
[legend]
Collaboration diagram for hoa_map::private_map::EnemySprite:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void AddEnemy (uint32 enemy_id)
 Adds an enemy with the specified ID to the last party in _enemy_parties.
virtual void Draw ()
 Draws the sprite frame in the appropriate position on the screen, if it is visible.
 EnemySprite (std::string file)
 A constructor for when the enemy sprite is stored in the definition of a single file.
 EnemySprite ()
 The default constructor which typically requires that the user make several additional calls to setup the sprite properties.
bool Load ()
 Loads the enemy's data from a file and returns true if it was successful.
void NewEnemyParty ()
 Adds a new empty vector to the _enemy_parties member.
void Reset ()
 Resets various members of the class so that the enemy is dead, invisible, and does not produce a collision.
const std::vector< uint32 > & RetrieveRandomParty ()
 Returns a reference to a random party of enemies.
virtual void Update ()
 Updates the sprite's position and state.
Class Member Access Functions
void ChangeStateDead ()
void ChangeStateHostile ()
void ChangeStateSpawning ()
float GetAggroRange () const
std::string GetBattleMusicTheme () const
uint32 GetTimeToChange () const
uint32 GetTimeToSpawn () const
bool IsDead () const
bool IsHostile () const
bool IsSpawning () const
void SetAggroRange (float range)
void SetBattleMusicTheme (const std::string &music_theme)
void SetTimeToChange (uint32 time)
void SetTimeToSpawn (uint32 time)
void SetZone (EnemyZone *zone)

Private Types

enum  STATE { SPAWNING, HOSTILE, DEAD }
 The states that the enemy sprite may be in. More...

Private Attributes

float _aggro_range
 A value which determines how close the player needs to be for the enemy to aggressively seek to confront it.
hoa_video::Color _color
 Used to gradually fade in the sprite as it is spawning by adjusting the alpha channel.
std::vector< std::vector<
uint32 > > 
_enemy_parties
 Contains the possible groups of enemies that may appear in a battle should the player encounter this enemy sprite The numbers contained within this member are ID numbers for the enemy. If the.
std::string _music_theme
 The default battle music theme for the monster.
bool _out_of_zone
 Indicates if the enemy is outside of its zone. If it is, it won't change direction until it gets back in.
STATE _state
 The state that the enemy sprite is in.
uint32 _time_dir_change
 ???
uint32 _time_elapsed
 A timer used for spawning.
uint32 _time_to_spawn
 ???
private_map::EnemyZone_zone
 The zone that the enemy sprite belongs to.

Detailed Description

A mobile map object that induces a battle to occur if the player touches it.

****************************************************************************

There are really two types of enemy sprites. The first type behave just like map sprites and can have scripted movement sequences. The second type belong to EnemyZones, where they fade into existence and pursue after the player's sprite should the player enter the zone.

An enemy sprite in a zone can be in one of 3 states: SPAWNING, HOSTILE or DEAD. In the spawning state, the enemy becomes gradually visible, is immobile, and cannot be touched or attacked. In the hostile state, the enemies roams the map and will cause a battle if touched by the player. In the dead state, the enemy is invisible and waits for the EnemyZone to reset it in another position, so that it may spawn once more.

Definition at line 393 of file map_sprites.h.


Member Enumeration Documentation

enum hoa_map::private_map::EnemySprite::STATE [private]

The states that the enemy sprite may be in.

Enumerator:
SPAWNING 
HOSTILE 
DEAD 

Definition at line 396 of file map_sprites.h.


Constructor & Destructor Documentation

hoa_map::private_map::EnemySprite::EnemySprite (  ) 

The default constructor which typically requires that the user make several additional calls to setup the sprite properties.

Definition at line 567 of file map_sprites.cpp.

References hoa_map::private_map::MapObject::_object_type, hoa_map::private_map::ENEMY_TYPE, hoa_map::private_map::MapObject::filename, hoa_map::private_map::VirtualSprite::moving, and Reset().

Here is the call graph for this function:

hoa_map::private_map::EnemySprite::EnemySprite ( std::string  file  ) 

A constructor for when the enemy sprite is stored in the definition of a single file.

Definition at line 581 of file map_sprites.cpp.

References hoa_map::private_map::MapObject::_object_type, hoa_map::private_map::ENEMY_TYPE, hoa_map::private_map::MapObject::filename, hoa_map::private_map::VirtualSprite::moving, and Reset().

Here is the call graph for this function:


Member Function Documentation

void hoa_map::private_map::EnemySprite::AddEnemy ( uint32  enemy_id  ) 

Adds an enemy with the specified ID to the last party in _enemy_parties.

Parameters:
enemy_id The ID of the enemy to add
Note:
MapMode should have already loaded a GlobalEnemy with this ID and retained it within the MapMode::_enemies member. If this is not the case, this function will print a warning message.

Definition at line 620 of file map_sprites.cpp.

References hoa_map::MapMode::_enemies, _enemy_parties, hoa_map::MapMode::_loading_map, and hoa_map::MAP_DEBUG.

void hoa_map::private_map::EnemySprite::ChangeStateDead (  )  [inline]

Definition at line 480 of file map_sprites.h.

References _zone, hoa_map::private_map::EnemyZone::EnemyDead(), and Reset().

Here is the call graph for this function:

void hoa_map::private_map::EnemySprite::ChangeStateHostile (  )  [inline]

Definition at line 489 of file map_sprites.h.

References _color, _state, HOSTILE, hoa_map::private_map::MapObject::no_collision, hoa_video::Color::SetAlpha(), and hoa_map::private_map::MapObject::updatable.

Referenced by Update().

Here is the call graph for this function:

void hoa_map::private_map::EnemySprite::ChangeStateSpawning (  )  [inline]

Definition at line 486 of file map_sprites.h.

References _state, hoa_map::private_map::MapObject::no_collision, SPAWNING, and hoa_map::private_map::MapObject::updatable.

void hoa_map::private_map::EnemySprite::Draw (  )  [virtual]

Draws the sprite frame in the appropriate position on the screen, if it is visible.

Reimplemented from hoa_map::private_map::MapSprite.

Definition at line 745 of file map_sprites.cpp.

References _color, _state, hoa_map::private_map::MapSprite::animations, hoa_map::private_map::MapSprite::current_animation, DEAD, hoa_map::private_map::MapObject::DrawHelper(), hoa_video::GameVideo::DrawImage(), and hoa_video::VideoManager.

Here is the call graph for this function:

float hoa_map::private_map::EnemySprite::GetAggroRange (  )  const [inline]

Definition at line 444 of file map_sprites.h.

References _aggro_range.

std::string hoa_map::private_map::EnemySprite::GetBattleMusicTheme (  )  const [inline]

Definition at line 453 of file map_sprites.h.

References _music_theme.

uint32 hoa_map::private_map::EnemySprite::GetTimeToChange (  )  const [inline]

Definition at line 447 of file map_sprites.h.

References _time_dir_change.

Referenced by hoa_map::private_map::EnemyZone::AddEnemy(), and Update().

uint32 hoa_map::private_map::EnemySprite::GetTimeToSpawn (  )  const [inline]

Definition at line 450 of file map_sprites.h.

References _time_to_spawn.

bool hoa_map::private_map::EnemySprite::IsDead (  )  const [inline]

Definition at line 456 of file map_sprites.h.

References _state, and DEAD.

bool hoa_map::private_map::EnemySprite::IsHostile (  )  const [inline]

Definition at line 462 of file map_sprites.h.

References _state, and HOSTILE.

bool hoa_map::private_map::EnemySprite::IsSpawning (  )  const [inline]

Definition at line 459 of file map_sprites.h.

References _state, and SPAWNING.

bool hoa_map::private_map::EnemySprite::Load (  ) 

Loads the enemy's data from a file and returns true if it was successful.

Definition at line 596 of file map_sprites.cpp.

References hoa_map::private_map::MapObject::filename, hoa_script::ReadScriptDescriptor::GetLuaState(), hoa_map::private_map::MapSprite::LoadStandardAnimations(), hoa_script::ReadScriptDescriptor::OpenFile(), and hoa_script::ReadScriptDescriptor::ReadString().

Here is the call graph for this function:

void hoa_map::private_map::EnemySprite::NewEnemyParty (  )  [inline]

Adds a new empty vector to the _enemy_parties member.

Note:
Make sure to populate this vector by adding at least one enemy!

Definition at line 429 of file map_sprites.h.

References _enemy_parties.

void hoa_map::private_map::EnemySprite::Reset (  ) 

Resets various members of the class so that the enemy is dead, invisible, and does not produce a collision.

Definition at line 609 of file map_sprites.cpp.

References _color, _out_of_zone, _state, _time_elapsed, DEAD, hoa_map::private_map::MapObject::no_collision, hoa_video::Color::SetAlpha(), and hoa_map::private_map::MapObject::updatable.

Referenced by hoa_map::private_map::EnemyZone::AddEnemy(), ChangeStateDead(), and EnemySprite().

Here is the call graph for this function:

const std::vector< uint32 > & hoa_map::private_map::EnemySprite::RetrieveRandomParty (  ) 

Returns a reference to a random party of enemies.

Definition at line 649 of file map_sprites.cpp.

References _enemy_parties.

void hoa_map::private_map::EnemySprite::SetAggroRange ( float  range  )  [inline]

Definition at line 468 of file map_sprites.h.

References _aggro_range.

void hoa_map::private_map::EnemySprite::SetBattleMusicTheme ( const std::string &  music_theme  )  [inline]

Definition at line 477 of file map_sprites.h.

References _music_theme.

void hoa_map::private_map::EnemySprite::SetTimeToChange ( uint32  time  )  [inline]

Definition at line 471 of file map_sprites.h.

References _time_dir_change.

Referenced by hoa_map::private_map::EnemyZone::AddEnemy().

void hoa_map::private_map::EnemySprite::SetTimeToSpawn ( uint32  time  )  [inline]

Definition at line 474 of file map_sprites.h.

References _time_to_spawn.

void hoa_map::private_map::EnemySprite::SetZone ( EnemyZone zone  )  [inline]

Definition at line 465 of file map_sprites.h.

References _zone.

Referenced by hoa_map::private_map::EnemyZone::AddEnemy().

void hoa_map::private_map::EnemySprite::Update (  )  [virtual]

Updates the sprite's position and state.

Reimplemented from hoa_map::private_map::MapSprite.

Definition at line 660 of file map_sprites.cpp.

References _aggro_range, hoa_map::MapMode::_camera, _color, hoa_map::MapMode::_current_map, _out_of_zone, _state, _time_elapsed, _time_to_spawn, _zone, hoa_map::private_map::VirtualSprite::CalculateOppositeDirection(), ChangeStateHostile(), hoa_map::private_map::MapObject::ComputeXLocation(), hoa_map::private_map::MapObject::ComputeYLocation(), hoa_map::private_map::VirtualSprite::current_action, DEAD, hoa_map::private_map::EAST, hoa_video::Color::GetAlpha(), hoa_map::private_map::VirtualSprite::GetDirection(), GetTimeToChange(), hoa_system::GameSystem::GetUpdateTime(), HOSTILE, hoa_map::private_map::MapZone::IsInsideZone(), hoa_map::private_map::EnemyZone::IsRestraining(), hoa_map::private_map::NORTH, hoa_map::private_map::NORTHEAST, hoa_map::private_map::NORTHWEST, hoa_utils::RandomBoundedInteger(), hoa_video::Color::SetAlpha(), hoa_map::private_map::VirtualSprite::SetDirection(), hoa_map::private_map::SOUTH, hoa_map::private_map::SOUTHEAST, hoa_map::private_map::SOUTHWEST, SPAWNING, hoa_system::SystemManager, hoa_map::private_map::MapSprite::Update(), hoa_map::private_map::WEST, hoa_map::private_map::MapObject::x_position, and hoa_map::private_map::MapObject::y_position.

Here is the call graph for this function:


Member Data Documentation

float hoa_map::private_map::EnemySprite::_aggro_range [private]

A value which determines how close the player needs to be for the enemy to aggressively seek to confront it.

Definition at line 507 of file map_sprites.h.

Referenced by GetAggroRange(), SetAggroRange(), and Update().

hoa_video::Color hoa_map::private_map::EnemySprite::_color [private]

Used to gradually fade in the sprite as it is spawning by adjusting the alpha channel.

Definition at line 498 of file map_sprites.h.

Referenced by ChangeStateHostile(), Draw(), Reset(), and Update().

std::vector<std::vector<uint32> > hoa_map::private_map::EnemySprite::_enemy_parties [private]

Contains the possible groups of enemies that may appear in a battle should the player encounter this enemy sprite The numbers contained within this member are ID numbers for the enemy. If the.

Definition at line 524 of file map_sprites.h.

Referenced by AddEnemy(), NewEnemyParty(), and RetrieveRandomParty().

std::string hoa_map::private_map::EnemySprite::_music_theme [private]

The default battle music theme for the monster.

Definition at line 519 of file map_sprites.h.

Referenced by GetBattleMusicTheme(), and SetBattleMusicTheme().

bool hoa_map::private_map::EnemySprite::_out_of_zone [private]

Indicates if the enemy is outside of its zone. If it is, it won't change direction until it gets back in.

Definition at line 516 of file map_sprites.h.

Referenced by Reset(), and Update().

STATE hoa_map::private_map::EnemySprite::_state [private]

The state that the enemy sprite is in.

Definition at line 504 of file map_sprites.h.

Referenced by ChangeStateHostile(), ChangeStateSpawning(), Draw(), IsDead(), IsHostile(), IsSpawning(), Reset(), and Update().

uint32 hoa_map::private_map::EnemySprite::_time_dir_change [private]

???

Definition at line 510 of file map_sprites.h.

Referenced by GetTimeToChange(), and SetTimeToChange().

uint32 hoa_map::private_map::EnemySprite::_time_elapsed [private]

A timer used for spawning.

Definition at line 501 of file map_sprites.h.

Referenced by Reset(), and Update().

uint32 hoa_map::private_map::EnemySprite::_time_to_spawn [private]

???

Definition at line 513 of file map_sprites.h.

Referenced by GetTimeToSpawn(), SetTimeToSpawn(), and Update().

private_map::EnemyZone* hoa_map::private_map::EnemySprite::_zone [private]

The zone that the enemy sprite belongs to.

Definition at line 495 of file map_sprites.h.

Referenced by ChangeStateDead(), SetZone(), and Update().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:14:49 2007 for Hero of Allacrost by  doxygen 1.5.1