battle_actors.h

Go to the documentation of this file.
00001 
00002 //            Copyright (C) 2004-2007 by The Allacrost Project
00003 //                         All Rights Reserved
00004 //
00005 // This code is licensed under the GNU GPL version 2. It is free software and
00006 // you may modify it and/or redistribute it under the terms of this license.
00007 // See http://www.gnu.org/copyleft/gpl.html for details.
00009 
00021 #ifndef __BATTLE_ACTORS_HEADER__
00022 #define __BATTLE_ACTORS_HEADER__
00023 
00024 #include "utils.h"
00025 #include "defs.h"
00026 #include "mode_manager.h"
00027 #include "global.h"
00028 #include "global_actors.h"
00029 #include "video.h"
00030 #include "audio.h"
00031 #include "battle.h"
00032 
00033 namespace hoa_battle {
00034 
00035 namespace private_battle {
00036 
00037 // FIX ME
00041 /*enum TEMP_ACTION_STATE {
00042   ACTION_IDLE = 0,
00043   ACTION_WARM_UP = 1,
00044   ACTION_COOL_DOWN = 2
00045 };*/
00046 
00053 class BattleActorEffect {
00054 public:
00055   BattleActorEffect(private_battle::BattleActor* const host)
00056     {}
00057   virtual ~BattleActorEffect()
00058     {}
00059 
00061   void Update()
00062     {}
00064   void CureEffect() const
00065     {}
00066 
00068 
00069   BattleActor* const GetHost() const
00070     { return _host; }
00071   hoa_utils::ustring GetEffectName() const
00072     { return _effect_name; }
00073 
00074   const int32 GetModifiedHealthPoints() const
00075     { return _health_points_modifier; }
00076   const int32 GetModifiedSkillPoints() const
00077     { return _skill_points_modifier; }
00078   const int32 GetModifiedStrength() const
00079     { return _strength_modifier; }
00080   const int32 GetModifiedIntelligence() const
00081     { return _intelligence_modifier; }
00082   const int32 GetModifiedAgility() const
00083     { return _agility_modifier; }
00085 
00086 private:
00088   private_battle::BattleActor* _host;
00090   hoa_utils::ustring _effect_name;
00092   uint32 _time_till_expiration;
00093   // //! Enum value to determine how severe the effect is
00094   // hoa_global::GLOBAL_AFFLICTION_SEVERITY _severity;
00095 
00100   int32 _health_points_modifier;
00101   int32 _skill_points_modifier;
00102   int32 _strength_modifier;
00103   int32 _intelligence_modifier;
00104   int32 _agility_modifier;
00106 }; // class BattleActorEffect
00107 
00108 
00116 class BattleActor
00117 {
00118 public:
00119   BattleActor();
00120   virtual ~BattleActor();
00121 
00125   virtual void TakeDamage(int32 damage);
00126 
00128   void SetQueuedToPerform(bool QueuedToPerform)
00129     { _is_queued_to_perform = QueuedToPerform; }
00130 
00132   bool IsQueuedToPerform() const
00133     { return _is_queued_to_perform; }
00134 
00136   //virtual hoa_global::GlobalActor * GetActor() = 0;
00137 
00138   // \brief Resets the wait time and time meter portrait
00139   void ResetWaitTime();
00140 
00141   // \brief Sets the location of the time meter portrait
00142   // \param new_val new value for the location
00143   void SetTimePortraitLocation(float new_val) { _time_portrait_location = new_val; }
00144 
00145   // \brief Gets the location of the time meter portrait
00146   // \return The location of the time portrait
00147   float GetTimePortraitLocation() { return _time_portrait_location; }
00148 
00149   // \brief Gets the wait time
00150   // \return the wait time
00151   hoa_system::SystemTimer* GetWaitTime() { return &_wait_time; }
00152 
00153   // \brief Called when the actor dies
00154   virtual void OnDeath();
00155 
00156   // \brief Called when the actor is revived
00157   virtual void OnLife();
00158 
00159   // \brief Calculates the actor's physical attack damage
00160   virtual void CalcPhysicalAttack() { }
00161 
00162   // \brief Calculates the actor's metaphysical attack damage
00163   virtual void CalcMetaPhysicalAttack() { }
00164 
00165   // \brief Calculates the actor's physical defense
00166   virtual void CalcPhysicalDefense(hoa_global::GlobalAttackPoint* attack_point = NULL) { }
00167 
00168   // \brief Calculates the actor's metaphysical defense
00169   virtual void CalcMetaPhysicalDefense(hoa_global::GlobalAttackPoint* attack_point = NULL) { }
00170 
00171   // \brief Calculates the actor's evade
00172   virtual void CalcEvade(hoa_global::GlobalAttackPoint* attack_point = NULL) { }
00173 
00174   // \brief Draws the status of the actor
00175   virtual void DrawStatus() { }
00176 
00178   //virtual void DrawSprite();
00179 
00180   // \brief Draws the actor's portrait for the time meter
00181   // \param is_selected If the actor is selected for an action, highlight it
00182   virtual void DrawTimePortrait(bool is_selected);
00183 
00184   // \brief Tells us if the actor is alive
00185   // \return true if alive
00186   virtual bool IsAlive() { return (_hp > 0); }
00187 
00188   // \brief Tells us if this actor is an enemy
00189   // \return true if it is an enemy
00190   virtual bool IsEnemy() { return true; }
00191 
00192   // \brief Copies stats from the passed in GlobalActor to member variables
00193   // \param The actor to copy
00194   void InitBattleActorStats(hoa_global::GlobalActor* actor);
00195 
00197 
00198   float GetXLocation() const
00199     { return _x_location; }
00200 
00201   float GetYLocation() const
00202     { return _y_location; }
00203 
00204   float GetXOrigin() const
00205     { return _x_origin; }
00206 
00207   float GetYOrigin() const
00208     { return _y_origin; }
00209 
00210   void SetXLocation(float x_location)
00211     { _x_location = x_location; }
00212 
00213   void SetYLocation(float y_location)
00214     { _y_location = y_location; }
00215 
00216   void SetXOrigin(float x_origin)
00217     { _x_origin = x_origin; }
00218 
00219   void SetYOrigin(float y_origin)
00220     { _y_origin = y_origin; }
00222 
00224 
00225   uint32 GetPhysicalAttack() const
00226     { return _physical_attack; }
00227 
00228   uint32 GetMetaPhysicalAttack() const
00229     { return _metaphysical_attack; }
00230 
00231   uint32 GetPhysicalDefense() const
00232     { return _physical_defense; }
00233 
00234   uint32 GetMetaPhysicalDefense() const
00235     { return _metaphysical_defense; }
00236 
00237   float GetCombatEvade() const
00238     { return _combat_evade; }
00240 
00242 
00243   uint32 GetHitPoints() const
00244     { return _hp; }
00245 
00246   uint32 GetMaxHitPoints() const
00247     { return _max_hp; }
00248 
00249   uint32 GetSkillPoints() const
00250     { return _sp; }
00251 
00252   uint32 GetMaxSkillPoints() const
00253     { return _max_sp; }
00254 
00255   uint32 GetStrength() const
00256     { return _strength; }
00257 
00258   uint32 GetVigor() const
00259     { return _vigor; }
00260 
00261   uint32 GetFortitude() const
00262     { return _fortitude; }
00263 
00264   uint32 GetProtection() const
00265     { return _protection; }
00266 
00267   uint32 GetAgility() const
00268     { return _agility; }
00269 
00270   float GetEvade() const
00271     { return _evade; }
00273 
00275 
00276   void SetHitPoints(uint32 hp)
00277     { if (hp > _max_hp) _hp = _max_hp; else _hp = hp; }
00278 
00279   void SetMaxHitPoints(uint32 max_hp)
00280     { _max_hp = max_hp; }
00281 
00282   void SetSkillPoints(uint32 sp)
00283     { if (sp > _max_sp) _sp = _max_sp; else _sp = sp; }
00284 
00285   void SetMaxSkillPoints(uint32 max_sp)
00286     { _max_sp = max_sp; }
00287 
00288   void SetStrength(uint32 strength)
00289     { _strength = strength; }
00290 
00291   void SetVigor(uint32 vigor)
00292     { _vigor = vigor; }
00293 
00294   void SetFortitude(uint32 fortitude)
00295     { _fortitude = fortitude; }
00296 
00297   void SetProtection(uint32 protection)
00298     { _protection = protection; }
00299 
00300   void SetAgility(uint32 agility)
00301     { _agility = agility; }
00302 
00303   void SetEvade(float evade)
00304     { _evade = evade; }
00305 
00307 
00308   // \brief Resets the attack timer for the animation
00309   void TEMP_ResetAttackTimer();
00310 
00312   bool TEMP_IsAttacking() const;
00313 
00314 protected:
00316   uint32 _last_update_time;
00317 
00319   float _x_location;
00320 
00322   float _y_location;
00323 
00325   float _x_origin;
00326 
00328   float _y_origin;
00329 
00331 
00332   uint32 _max_hp;
00333   uint32 _hp;
00334   uint32 _max_sp;
00335   uint32 _sp;
00336   uint32 _strength;
00337   uint32 _vigor;
00338   uint32 _fortitude;
00339   uint32 _protection;
00340   uint32 _agility;
00341   float _evade;
00343 
00345 
00346   uint32 _physical_attack;
00347   uint32 _metaphysical_attack;
00348   uint32 _physical_defense;
00349   uint32 _metaphysical_defense;
00350   float _combat_evade;
00352 
00354   //FIX ME this has to go
00355   uint32 _total_time_damaged;
00356 
00358   //FIX ME this has to go unless we have good cause for it
00359   uint32 _damage_dealt;
00360 
00362   bool _is_queued_to_perform;
00363 
00365   hoa_video::StillImage _time_meter_portrait;
00366 
00368   hoa_video::StillImage _time_portrait_selected;
00369 
00371   float _time_portrait_location;
00372 
00374   //FIX ME for now, will also be used for cool down times?
00375   hoa_system::SystemTimer _wait_time;
00376 
00378   hoa_system::SystemTimer _TEMP_attack_animation_timer;
00379 
00381   void _RecalculateWaitTime();
00382 };
00383 
00384 
00388 class BattleCharacterActor : public BattleActor {
00389 public:
00390   BattleCharacterActor(hoa_global::GlobalCharacter * character, float x_location, float y_location);
00391 
00392   virtual ~BattleCharacterActor();
00393 
00395   void Update();
00396 
00398   void DrawSprite();
00399 
00401   void DrawPortrait();
00402 
00403   // \brief Tells us if this actor is an enemy
00404   // \return true if it is an enemy
00405   virtual bool IsEnemy() { return false; }
00406 
00407   // \brief Draws the character's portrait for the time meter
00408   // \param is_selected If the enemy is selected for an action, highlight it
00409   //void DrawTimePortrait(bool is_selected);
00410 
00412   virtual void DrawStatus();
00413 
00414   // \brief Calculates the actor's physical attack damage
00415   virtual void CalcPhysicalAttack();
00416 
00417   // \brief Calculates the actor's metaphysical attack damage
00418   virtual void CalcMetaPhysicalAttack();
00419 
00420   // \brief Calculates the actor's physical defense
00421   virtual void CalcPhysicalDefense(hoa_global::GlobalAttackPoint* attack_point = NULL);
00422 
00423   // \brief Calculates the actor's metaphysical defense
00424   virtual void CalcMetaPhysicalDefense(hoa_global::GlobalAttackPoint* attack_point = NULL);
00425 
00426   // \brief Calculates the actor's evade
00427   virtual void CalcEvade(hoa_global::GlobalAttackPoint* attack_point = NULL);
00428 
00430   //void TakeDamage(uint32 damage);
00431 
00433   //bool IsQueuedToPerform() const
00434   //  { return _is_queued_to_perform; }
00435 
00436   // Sets queued to perform
00437   //void SetQueuedToPerform(bool QueuedToPerform)
00438   //{ _is_queued_to_perform = QueuedToPerform; }
00439 
00441 
00442   /*float GetXLocation() const
00443     { return _x_location; }
00444 
00445   float GetYLocation() const
00446     { return _y_location; }
00447 
00448   float GetXOrigin() const
00449     { return _x_origin; }
00450 
00451   float GetYOrigin() const
00452     { return _y_origin; }
00453 
00454   void SetXLocation(float x_location)
00455     { _x_location = x_location; }
00456 
00457   void SetYLocation(float y_location)
00458     { _y_location = y_location; }
00459 
00460   void SetXOrigin(float x_origin)
00461     { _x_origin = x_origin; }
00462 
00463   void SetYOrigin(float y_origin)
00464     { _y_origin = y_origin; }*/
00466 
00467   // Gets a pointer to the GlobalActor
00468   hoa_global::GlobalCharacter * GetActor()
00469     { return _global_character; }
00470 
00471   // \brief Used to permanently change actor stats.
00472   // \note In most cases this is current HP and SP
00473   virtual void UpdateGlobalActorStats();
00474 
00475   // \brief Sets the location of the time meter portrait
00476   // \param new_val new value for the location
00477   //virtual void SetTimePortraitLocation(float new_val) { _time_portrait_location = new_val; }
00478 
00479   // \brief Gets the location of the time meter portrait
00480   // \return The location of the time portrait
00481   //virtual float GetTimePortraitLocation() { return _time_portrait_location; }
00482 
00483   // \brief Gets the wait time
00484   // \return the wait time
00485   //virtual hoa_system::SystemTimer* GetWaitTime() { return &_wait_time; }
00486 
00487   // \brief Resets the wait time and time meter portrait
00488   //void ResetWaitTime();
00489   
00490     
00491 private:
00493   hoa_global::GlobalCharacter * _global_character;
00494 
00496   /*float _x_location;
00497 
00499   float _y_location;
00500 
00502   float _x_origin;
00503 
00505   float _y_origin;
00506 
00508   //FIX ME this has to go
00509   uint32 _total_time_damaged;
00510 
00512   //FIX ME this has to go unless we have good cause for it
00513   uint32 _damage_dealt;
00514 
00516   bool _is_queued_to_perform;
00517 
00519   hoa_video::StillImage _time_meter_portrait;
00520 
00522   hoa_video::StillImage _time_portrait_selected;*/
00523 
00525   hoa_video::StillImage _status_bar_cover_image;
00526 
00528   hoa_video::StillImage _status_menu_image;
00529 
00531   //float _time_portrait_location;
00532 
00534   //FIX ME for now, will also be used for cool down times?
00535   //hoa_system::SystemTimer _wait_time;
00536 
00538   //void _RecalculateWaitTime();
00539 
00540 }; // end BattleCharacterActor
00541 
00542 
00548 class BattleEnemyActor : public BattleActor {
00549 public:
00550   BattleEnemyActor(hoa_global::GlobalEnemy enemy, float x_location, float y_location);
00551 
00552   virtual ~BattleEnemyActor();
00553 
00555   void Update();
00556 
00558   void DrawSprite();
00559 
00560   // \brief Draws the enemy's portrait for the time meter
00561   // \param is_selected If the enemy is selected for an action, highlight it
00562   //void DrawTimePortrait(bool is_selected);
00563 
00565   virtual void DrawStatus();
00566 
00568   //void TakeDamage(uint32 damage);
00569 
00570   // \brief Calculates the actor's physical attack damage
00571   virtual void CalcPhysicalAttack();
00572 
00573   // \brief Calculates the actor's metaphysical attack damage
00574   virtual void CalcMetaPhysicalAttack();
00575 
00576   // \brief Calculates the actor's physical defense
00577   virtual void CalcPhysicalDefense(hoa_global::GlobalAttackPoint* attack_point = NULL);
00578 
00579   // \brief Calculates the actor's metaphysical defense
00580   virtual void CalcMetaPhysicalDefense(hoa_global::GlobalAttackPoint* attack_point = NULL);
00581 
00582   // \brief Calculates the actor's evade
00583   virtual void CalcEvade(hoa_global::GlobalAttackPoint* attack_point = NULL);
00584 
00586   /*bool IsQueuedToPerform() const
00587     { return _is_queued_to_perform; }
00588 
00589   // Sets queued to perform
00590   void SetQueuedToPerform(bool QueuedToPerform)
00591     { _is_queued_to_perform = QueuedToPerform; }
00592 
00594 
00595   float GetXLocation() const
00596     { return _x_location; }
00597 
00598   float GetYLocation() const
00599     { return _y_location; }
00600 
00601   float GetXOrigin() const
00602     { return _x_origin; }
00603 
00604   float GetYOrigin() const
00605     { return _y_origin; }
00606 
00607   void SetXLocation(float x_location)
00608     { _x_location = x_location; }
00609 
00610   void SetYLocation(float y_location)
00611     { _y_location = y_location; }
00612 
00613   void SetXOrigin(float x_origin)
00614     { _x_origin = x_origin; }
00615 
00616   void SetYOrigin(float y_origin)
00617     { _y_origin = y_origin; }*/
00619 
00621   virtual hoa_global::GlobalEnemy* GetActor()
00622     { return &_global_enemy; }
00623 
00626   /*virtual void SetTimePortraitLocation(float new_val) { _time_portrait_location = new_val; }
00627 
00630   virtual float GetTimePortraitLocation() { return _time_portrait_location; }
00631 
00634   virtual hoa_system::SystemTimer* GetWaitTime() { return &_wait_time; }
00635 
00637   void ResetWaitTime();*/
00638   //inline void SetWaitTime(uint32 wait_time) { _wait_time = wait_time; }
00639 
00641   bool operator<(const BattleEnemyActor & other) const;
00642 
00643 private:
00645   hoa_global::GlobalEnemy _global_enemy;
00646 
00648   /*float _x_location;
00649 
00651   float _y_location;
00652 
00654   float _x_origin;
00655 
00657   float _y_origin;
00658 
00660   //FIX ME this has to go
00661   uint32 _total_time_damaged;
00662 
00664   //FIX ME this has to go unless we have good cause for it
00665   uint32 _damage_dealt;
00666 
00668   bool _is_queued_to_perform;
00669 
00671   hoa_video::StillImage _time_meter_portrait;
00672 
00674   hoa_video::StillImage _time_portrait_selected;
00675 
00677   float _time_portrait_location;
00678 
00680   //FIX ME for now, will also be used for cool down times?
00681   hoa_system::SystemTimer _wait_time;*/
00682 
00684   //uint8 _action_state;
00685 
00686 }; // end BattleEnemyActor
00687 
00688 } // namespace private_battle
00689 
00690 } // namespace hoa_battle
00691 
00692 #endif // __BATTLE_ACTORS_HEADER__
00693 
00694 

Generated on Fri Jul 6 23:11:10 2007 for Hero of Allacrost by  doxygen 1.5.1