hoa_global::GlobalCharacterGrowth Class Reference

A container class for tracking the growth of a character. More...

#include <global_actors.h>

Collaboration diagram for hoa_global::GlobalCharacterGrowth:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void AcknowledgeGrowth ()
 Processes any growth that has occured by modifier the character's stats If an experience level is gained, this function will open up the script file that contains the character's definition and get new growth stats for the next experience level.
 GlobalCharacterGrowth (GlobalCharacter *owner)
 ~GlobalCharacterGrowth ()
Class member access functions
float GetEvadeGrowth () const
uint32 GetFortitudeGrowth () const
uint32 GetHitPointsGrowth () const
uint32 GetProtectionGrowth () const
uint32 GetSkillPointsGrowth () const
std::list< GlobalSkill * > * GetSkillsLearned ()
uint32 GetStrengthGrowth () const
uint32 GetVigorGrowth () const
bool IsExperienceLevelGained () const
bool IsGrowthDetected () const

Private Member Functions

void _AddSkill (uint32 skill_id)
 Adds a new skill for the character to learn at the next experience level gained.
void _CheckForGrowth ()
 Examines if any growth has occured as a result of the character's experience points This is called by GlobalCharacter whenever the character's experience points change. If any growth is detected, the _growth_detected member is set and the various growth members of the class are incremented by the growth amount.
void _ConstructPeriodicGrowth ()
 Constructs the numerous periodic growth deques when growth stats for a new level are loaded in After new growth stats have been loaded in for a level, this function takes those values, breaks them apart, and spreads out their growth periodically. 50% of the growth is saved for when the character reaches a new level, while the other 50% are rewarded as the character's experience grows to values in between the previous experience level marker and the next.
void _DetermineNextLevelExperience ()
 An algorithm that computes how many experience points are needed to reach the next level This algorithm is a function of the current experience level and the experience points that were required to reach the current level. This function modifies the _experience_for_next_level and _experience_for_last_level members.

Private Attributes

GlobalCharacter_character_owner
 A pointer to the character which this growth belongs to.
uint32 _experience_for_last_level
 The experience points that were required to reach the previous experience level.
uint32 _experience_for_next_level
 The experience points required to reach the next experience level.
bool _experience_level_gained
 Set to true when it is detected that a new experience level has been reached.
bool _growth_detected
 Set to true when it is detected that sufficient experience for at least one stat to grow has been reached.
std::list< GlobalSkill * > _skills_learned
 Contains any and all skills that are to be learned when the next experience level is reached These are automatically added to the character by this class after the new experience level growth has been acknowledged.
uint32 _agility_growth
float _evade_growth
uint32 _fortitude_growth
uint32 _hit_points_growth
 The amount of growth that should be added to each of the character's stats These members are incremented by the _UpdateGrowth() function, which detects when a character has enough experience points to meet a growth requirement. They are all cleared to zero after a call to AcknowledgeGrowth().
uint32 _protection_growth
uint32 _skill_points_growth
uint32 _strength_growth
uint32 _vigor_growth
std::deque< std::pair< uint32,
uint32 > > 
_agility_periodic_growth
std::deque< std::pair< uint32,
float > > 
_evade_periodic_growth
std::deque< std::pair< uint32,
uint32 > > 
_fortitude_periodic_growth
std::deque< std::pair< uint32,
uint32 > > 
_hit_points_periodic_growth
 The periodic growth of the stats as a function of experience points The purpose of these containers is to support the gradual growth of characters. The first member in each pair is the experience points required for that growth to occur, while the second member is the value of the growth. Each entry in the deques are ordered from lowest (front) to highest (back) XP requirements. The final entry in each deque should be the growth for when the next experience level is reached. Note that these structures do not need to contain any entries (ie, a stat does not need to grow on every level).
std::deque< std::pair< uint32,
uint32 > > 
_protection_periodic_growth
std::deque< std::pair< uint32,
uint32 > > 
_skill_points_periodic_growth
std::deque< std::pair< uint32,
uint32 > > 
_strength_periodic_growth
std::deque< std::pair< uint32,
uint32 > > 
_vigor_periodic_growth

Friends

void BindEngineToLua ()
 Contains the binding code which makes the C++ engine available to Lua This method should only be called once. It must be called after the ScriptEngine is initialized, otherwise the application will crash.
class GlobalCharacter

Detailed Description

A container class for tracking the growth of a character.

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

This class is essentially an extension of the GlobalCharacter class that manages and updates the character's growth. The primary reason that this class exists is to provide an interface for external code to determine when character growth occurs, inform the player of the growth, and acknoleged the growth.

The recommended proceedure for processing character growth is as follows:

  1. If the return value of GlobalCharacter::AddExperiencePoints is true, growth has occured and should be processed.
  2. Call GlobalCharacter::GetGrowth() to retrieve a pointer to this object
  3. Call IsExperienceLevel() to determine whether the type growth is a new experience level, or simply gradual growth.
  4. If the growth type is gradual, call the various Growth() methods and report any non-zero values to the player. Then call AcknoledgeGrowth()
  5. Otherwise if the growth type is a new level, report growth plus any skills learned and call AcknoledgeGrowth() (*see note)

Note:
When an experience level is gained, after the call to AcknowledgeGrowth() there may be new growth available (because the character gained multiple experience levels or met the requirements for additional gradual growth for the new experience level to gain). Thus, you should strongly consider calling the IsGrowthDetected() method after AcknowledgeGrowth() to report any further character growth that occured after the character reached a new level.
Todo:
Add gradual stat growth feature

Definition at line 647 of file global_actors.h.


Constructor & Destructor Documentation

hoa_global::GlobalCharacterGrowth::GlobalCharacterGrowth ( GlobalCharacter owner  )  [inline]

Definition at line 652 of file global_actors.h.

hoa_global::GlobalCharacterGrowth::~GlobalCharacterGrowth (  ) 

Definition at line 261 of file global_actors.cpp.

References _skills_learned.


Member Function Documentation

void hoa_global::GlobalCharacterGrowth::_AddSkill ( uint32  skill_id  )  [private]

Adds a new skill for the character to learn at the next experience level gained.

Parameters:
skill_id The ID number of the skill to add
Note:
This function is bound to and invoked by Lua to add all of the skills to be learned

Definition at line 318 of file global_actors.cpp.

References _skills_learned, hoa_global::GlobalSkill::GetID(), and hoa_global::GLOBAL_DEBUG.

Here is the call graph for this function:

void hoa_global::GlobalCharacterGrowth::_CheckForGrowth (  )  [private]

Examines if any growth has occured as a result of the character's experience points This is called by GlobalCharacter whenever the character's experience points change. If any growth is detected, the _growth_detected member is set and the various growth members of the class are incremented by the growth amount.

Definition at line 348 of file global_actors.cpp.

References _agility_growth, _agility_periodic_growth, _character_owner, _evade_growth, _evade_periodic_growth, _experience_for_next_level, _experience_level_gained, _fortitude_growth, _fortitude_periodic_growth, _growth_detected, _hit_points_growth, _hit_points_periodic_growth, _protection_growth, _protection_periodic_growth, _skill_points_growth, _skill_points_periodic_growth, _skills_learned, _strength_growth, _strength_periodic_growth, _vigor_growth, _vigor_periodic_growth, hoa_global::GlobalActor::GetExperiencePoints(), hoa_global::GlobalActor::GetSkill(), and hoa_global::GLOBAL_DEBUG.

Referenced by AcknowledgeGrowth(), and hoa_global::GlobalCharacter::AddExperiencePoints().

Here is the call graph for this function:

void hoa_global::GlobalCharacterGrowth::_ConstructPeriodicGrowth (  )  [private]

Constructs the numerous periodic growth deques when growth stats for a new level are loaded in After new growth stats have been loaded in for a level, this function takes those values, breaks them apart, and spreads out their growth periodically. 50% of the growth is saved for when the character reaches a new level, while the other 50% are rewarded as the character's experience grows to values in between the previous experience level marker and the next.

Note:
The growth members should contain the total growth stats when this function is called. These members will be set back to zero by the time the function returns as their values will be split up and placed in numerous entries in the periodic_growth deques. All periodic_growth deques should be empty when this function is called.

Definition at line 552 of file global_actors.cpp.

References _agility_growth, _agility_periodic_growth, _evade_growth, _evade_periodic_growth, _experience_for_next_level, _fortitude_growth, _fortitude_periodic_growth, _hit_points_growth, _hit_points_periodic_growth, _protection_growth, _protection_periodic_growth, _skill_points_growth, _skill_points_periodic_growth, _strength_growth, _strength_periodic_growth, _vigor_growth, and _vigor_periodic_growth.

Referenced by AcknowledgeGrowth(), and hoa_global::GlobalCharacter::GlobalCharacter().

void hoa_global::GlobalCharacterGrowth::_DetermineNextLevelExperience (  )  [private]

An algorithm that computes how many experience points are needed to reach the next level This algorithm is a function of the current experience level and the experience points that were required to reach the current level. This function modifies the _experience_for_next_level and _experience_for_last_level members.

Definition at line 577 of file global_actors.cpp.

References _experience_for_last_level, and _experience_for_next_level.

Referenced by AcknowledgeGrowth(), and hoa_global::GlobalCharacter::GlobalCharacter().

void hoa_global::GlobalCharacterGrowth::AcknowledgeGrowth (  ) 

Processes any growth that has occured by modifier the character's stats If an experience level is gained, this function will open up the script file that contains the character's definition and get new growth stats for the next experience level.

Definition at line 270 of file global_actors.cpp.

References _agility_growth, _character_owner, _CheckForGrowth(), _ConstructPeriodicGrowth(), _DetermineNextLevelExperience(), _evade_growth, hoa_global::GlobalActor::_experience_level, _experience_level_gained, _fortitude_growth, _growth_detected, _hit_points_growth, _protection_growth, _skill_points_growth, _strength_growth, _vigor_growth, hoa_script::ReadScriptDescriptor::GetLuaState(), hoa_global::GLOBAL_DEBUG, hoa_script::GameScript::HandleCastError(), hoa_script::GameScript::HandleLuaError(), hoa_script::ReadScriptDescriptor::OpenFile(), and hoa_script::ScriptManager.

Here is the call graph for this function:

float hoa_global::GlobalCharacterGrowth::GetEvadeGrowth (  )  const [inline]

Definition at line 689 of file global_actors.h.

References _evade_growth.

uint32 hoa_global::GlobalCharacterGrowth::GetFortitudeGrowth (  )  const [inline]

Definition at line 683 of file global_actors.h.

References _fortitude_growth.

uint32 hoa_global::GlobalCharacterGrowth::GetHitPointsGrowth (  )  const [inline]

Definition at line 671 of file global_actors.h.

References _hit_points_growth.

uint32 hoa_global::GlobalCharacterGrowth::GetProtectionGrowth (  )  const [inline]

Definition at line 686 of file global_actors.h.

References _protection_growth.

uint32 hoa_global::GlobalCharacterGrowth::GetSkillPointsGrowth (  )  const [inline]

Definition at line 674 of file global_actors.h.

References _skill_points_growth.

std::list<GlobalSkill*>* hoa_global::GlobalCharacterGrowth::GetSkillsLearned (  )  [inline]

Definition at line 692 of file global_actors.h.

References _skills_learned.

uint32 hoa_global::GlobalCharacterGrowth::GetStrengthGrowth (  )  const [inline]

Definition at line 677 of file global_actors.h.

References _strength_growth.

uint32 hoa_global::GlobalCharacterGrowth::GetVigorGrowth (  )  const [inline]

Definition at line 680 of file global_actors.h.

References _vigor_growth.

bool hoa_global::GlobalCharacterGrowth::IsExperienceLevelGained (  )  const [inline]

Definition at line 665 of file global_actors.h.

References _experience_level_gained.

bool hoa_global::GlobalCharacterGrowth::IsGrowthDetected (  )  const [inline]

Definition at line 668 of file global_actors.h.

References _growth_detected.

Referenced by hoa_global::GlobalCharacter::AddExperiencePoints().


Friends And Related Function Documentation

void BindEngineToLua (  )  [friend]

Contains the binding code which makes the C++ engine available to Lua This method should only be called once. It must be called after the ScriptEngine is initialized, otherwise the application will crash.

Definition at line 55 of file defs.cpp.

friend class GlobalCharacter [friend]

Definition at line 648 of file global_actors.h.


Member Data Documentation

uint32 hoa_global::GlobalCharacterGrowth::_agility_growth [private]

Definition at line 727 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), and AcknowledgeGrowth().

std::deque<std::pair<uint32, uint32> > hoa_global::GlobalCharacterGrowth::_agility_periodic_growth [private]

Definition at line 750 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().

GlobalCharacter* hoa_global::GlobalCharacterGrowth::_character_owner [private]

A pointer to the character which this growth belongs to.

Definition at line 698 of file global_actors.h.

Referenced by _CheckForGrowth(), and AcknowledgeGrowth().

float hoa_global::GlobalCharacterGrowth::_evade_growth [private]

Definition at line 728 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), AcknowledgeGrowth(), and GetEvadeGrowth().

std::deque<std::pair<uint32, float> > hoa_global::GlobalCharacterGrowth::_evade_periodic_growth [private]

Definition at line 751 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().

uint32 hoa_global::GlobalCharacterGrowth::_experience_for_last_level [private]

The experience points that were required to reach the previous experience level.

Definition at line 710 of file global_actors.h.

Referenced by _DetermineNextLevelExperience(), and hoa_global::GlobalCharacter::GlobalCharacter().

uint32 hoa_global::GlobalCharacterGrowth::_experience_for_next_level [private]

The experience points required to reach the next experience level.

Definition at line 707 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), _DetermineNextLevelExperience(), hoa_global::GlobalCharacter::GetExperienceForNextLevel(), and hoa_global::GlobalCharacter::GlobalCharacter().

bool hoa_global::GlobalCharacterGrowth::_experience_level_gained [private]

Set to true when it is detected that a new experience level has been reached.

Definition at line 701 of file global_actors.h.

Referenced by _CheckForGrowth(), AcknowledgeGrowth(), and IsExperienceLevelGained().

uint32 hoa_global::GlobalCharacterGrowth::_fortitude_growth [private]

Definition at line 725 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), AcknowledgeGrowth(), and GetFortitudeGrowth().

std::deque<std::pair<uint32, uint32> > hoa_global::GlobalCharacterGrowth::_fortitude_periodic_growth [private]

Definition at line 748 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().

bool hoa_global::GlobalCharacterGrowth::_growth_detected [private]

Set to true when it is detected that sufficient experience for at least one stat to grow has been reached.

Definition at line 704 of file global_actors.h.

Referenced by _CheckForGrowth(), AcknowledgeGrowth(), and IsGrowthDetected().

uint32 hoa_global::GlobalCharacterGrowth::_hit_points_growth [private]

The amount of growth that should be added to each of the character's stats These members are incremented by the _UpdateGrowth() function, which detects when a character has enough experience points to meet a growth requirement. They are all cleared to zero after a call to AcknowledgeGrowth().

Note:
These members are given read/write access in Lua so that Lua may use them to set the growth of stats for the next level

Definition at line 721 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), AcknowledgeGrowth(), and GetHitPointsGrowth().

std::deque<std::pair<uint32, uint32> > hoa_global::GlobalCharacterGrowth::_hit_points_periodic_growth [private]

The periodic growth of the stats as a function of experience points The purpose of these containers is to support the gradual growth of characters. The first member in each pair is the experience points required for that growth to occur, while the second member is the value of the growth. Each entry in the deques are ordered from lowest (front) to highest (back) XP requirements. The final entry in each deque should be the growth for when the next experience level is reached. Note that these structures do not need to contain any entries (ie, a stat does not need to grow on every level).

These containers are emptied when a new experience level occurs, and are also re-constructed after the experience level gain has been acknowledged.

Definition at line 744 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().

uint32 hoa_global::GlobalCharacterGrowth::_protection_growth [private]

Definition at line 726 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), AcknowledgeGrowth(), and GetProtectionGrowth().

std::deque<std::pair<uint32, uint32> > hoa_global::GlobalCharacterGrowth::_protection_periodic_growth [private]

Definition at line 749 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().

uint32 hoa_global::GlobalCharacterGrowth::_skill_points_growth [private]

Definition at line 722 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), AcknowledgeGrowth(), and GetSkillPointsGrowth().

std::deque<std::pair<uint32, uint32> > hoa_global::GlobalCharacterGrowth::_skill_points_periodic_growth [private]

Definition at line 745 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().

std::list<GlobalSkill*> hoa_global::GlobalCharacterGrowth::_skills_learned [private]

Contains any and all skills that are to be learned when the next experience level is reached These are automatically added to the character by this class after the new experience level growth has been acknowledged.

Definition at line 758 of file global_actors.h.

Referenced by _AddSkill(), _CheckForGrowth(), GetSkillsLearned(), and ~GlobalCharacterGrowth().

uint32 hoa_global::GlobalCharacterGrowth::_strength_growth [private]

Definition at line 723 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), AcknowledgeGrowth(), and GetStrengthGrowth().

std::deque<std::pair<uint32, uint32> > hoa_global::GlobalCharacterGrowth::_strength_periodic_growth [private]

Definition at line 746 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().

uint32 hoa_global::GlobalCharacterGrowth::_vigor_growth [private]

Definition at line 724 of file global_actors.h.

Referenced by _CheckForGrowth(), _ConstructPeriodicGrowth(), AcknowledgeGrowth(), and GetVigorGrowth().

std::deque<std::pair<uint32, uint32> > hoa_global::GlobalCharacterGrowth::_vigor_periodic_growth [private]

Definition at line 747 of file global_actors.h.

Referenced by _CheckForGrowth(), and _ConstructPeriodicGrowth().


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