00001
00002
00003
00004
00005
00006
00007
00009
00020 #ifndef __GLOBAL_ACTORS_HEADER__
00021 #define __GLOBAL_ACTORS_HEADER__
00022
00023 #include <utility>
00024
00025 #include "defs.h"
00026 #include "utils.h"
00027
00028 namespace hoa_global {
00029
00033 enum GLOBAL_TARGET {
00034 GLOBAL_TARGET_INVALID = -1,
00035 GLOBAL_TARGET_ATTACK_POINT = 0,
00036 GLOBAL_TARGET_ACTOR = 1,
00037 GLOBAL_TARGET_PARTY = 2,
00038 GLOBAL_TARGET_TOTAL = 3
00039 };
00040
00044 enum GLOBAL_USE {
00045 GLOBAL_USE_INVALID = -1,
00046 GLOBAL_USE_MENU = 0,
00047 GLOBAL_USE_BATTLE = 1,
00048 GLOBAL_USE_ALL = 2,
00049 GLOBAL_USE_TOTAL = 3
00050 };
00051
00056 const uint32 GLOBAL_POSITION_HEAD = 0;
00057 const uint32 GLOBAL_POSITION_TORSO = 1;
00058 const uint32 GLOBAL_POSITION_ARMS = 2;
00059 const uint32 GLOBAL_POSITION_LEGS = 3;
00061
00068 const uint32 GLOBAL_CHARACTER_INVALID = 0x00000000;
00069 const uint32 GLOBAL_CHARACTER_CLAUDIUS = 0x00000001;
00070 const uint32 GLOBAL_CHARACTER_LAILA = 0x00000002;
00071 const uint32 GLOBAL_CHARACTER_ALL = 0xFFFFFFFF;
00073
00074
00082 class GlobalTarget {
00083 public:
00084 GlobalTarget()
00085 {}
00086
00087 virtual ~GlobalTarget()
00088 {}
00089
00096 virtual GLOBAL_TARGET GetTargetType() = 0;
00097 };
00098
00099
00111 class GlobalAttackPoint : public GlobalTarget {
00112 friend class GlobalActor;
00113 friend class GlobalCharacter;
00114 friend class GlobalEnemy;
00115
00116 public:
00117 GlobalAttackPoint(GlobalActor* actor_owner) :
00118 _actor_owner(actor_owner) {}
00119
00120 ~GlobalAttackPoint()
00121 {}
00122
00123 GLOBAL_TARGET GetTargetType()
00124 { return GLOBAL_TARGET_ATTACK_POINT; }
00125
00127
00128 hoa_utils::ustring& GetName()
00129 { return _name; }
00130
00131 uint16 GetXPosition() const
00132 { return _x_position; }
00133
00134 uint16 GetYPosition() const
00135 { return _y_position; }
00136
00137 float GetFortitudeModifier() const
00138 { return _fortitude_modifier; }
00139
00140 float GetProtectionModifier() const
00141 { return _protection_modifier; }
00142
00143 float GetEvadeModifier() const
00144 { return _evade_modifier; }
00145
00146 GlobalActor* GetActorOwner() const
00147 { return _actor_owner; }
00148
00149 uint16 GetTotalPhysicalDefense() const
00150 { return _total_physical_defense; }
00151
00152 uint16 GetTotalMetaphysicalDefense() const
00153 { return _total_metaphysical_defense; }
00154
00155 float GetTotalEvadeRating() const
00156 { return _total_evade_rating; }
00158
00159 private:
00164 hoa_utils::ustring _name;
00165
00171 uint16 _x_position, _y_position;
00172
00185 float _fortitude_modifier;
00186 float _protection_modifier;
00187 float _evade_modifier;
00189
00191 GlobalActor* _actor_owner;
00192
00198 uint16 _total_physical_defense;
00199 uint16 _total_metaphysical_defense;
00200 float _total_evade_rating;
00202
00210
00211
00212
00223 bool _LoadData(hoa_script::ReadScriptDescriptor& script);
00224 };
00225
00226
00239 class GlobalActor : public GlobalTarget {
00240 public:
00241 GlobalActor()
00242 {}
00243
00244 virtual ~GlobalActor();
00245
00246 GLOBAL_TARGET GetTargetType()
00247 { return GLOBAL_TARGET_ACTOR; }
00248
00256 virtual bool IsCharacter() = 0;
00257
00261 bool IsAlive() const
00262 { return (_hit_points != 0); }
00263
00270 uint32 GetID() const
00271 { return _id; }
00272
00273 hoa_utils::ustring& GetName()
00274 { return _name; }
00275
00276 std::string& GetFilename()
00277 { return _filename; }
00278
00279 uint32 GetHitPoints() const
00280 { return _hit_points; }
00281
00282 uint32 GetMaxHitPoints() const
00283 { return _max_hit_points; }
00284
00285 uint32 GetSkillPoints() const
00286 { return _skill_points; }
00287
00288 uint32 GetMaxSkillPoints() const
00289 { return _max_skill_points; }
00290
00291 uint32 GetExperienceLevel() const
00292 { return _experience_level; }
00293
00294 uint32 GetExperiencePoints() const
00295 { return _experience_points; }
00296
00297 uint32 GetStrength() const
00298 { return _strength; }
00299
00300 uint32 GetVigor() const
00301 { return _vigor; }
00302
00303 uint32 GetFortitude() const
00304 { return _fortitude; }
00305
00306 uint32 GetProtection() const
00307 { return _protection; }
00308
00309 uint32 GetAgility() const
00310 { return _agility; }
00311
00312 float GetEvade() const
00313 { return _evade; }
00314
00315 uint32 GetTotalPhysicalAttack() const
00316 { return _total_physical_attack; }
00317
00318 uint32 GetTotalMetaphysicalAttack() const
00319 { return _total_metaphysical_attack; }
00320
00321 uint32 GetTotalPhysicalDefense(uint32 index) const;
00322
00323 uint32 GetTotalMetaphysicalDefense(uint32 index) const;
00324
00325 float GetTotalEvadeRating(uint32 index) const;
00326
00327 GlobalWeapon* GetWeaponEquipped() const
00328 { return _weapon_equipped; }
00329
00330 std::vector<GlobalArmor*>* GetArmorEquipped()
00331 { return &_armor_equipped; }
00332
00333 GlobalArmor* GetArmorEquipped(uint32 index) const;
00334
00335 std::vector<GlobalAttackPoint*>* GetAttackPoints()
00336 { return &_attack_points; }
00337
00338 GlobalAttackPoint* GetAttackPoint(uint32 index) const;
00339
00340 std::map<uint32, GlobalSkill*>* GetSkills()
00341 { return &_skills; }
00342
00346 GlobalSkill* GetSkill(uint32 skill_id) const;
00347
00349 GlobalSkill* GetSkill(const GlobalSkill* skill) const;
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00364
00370 void SetExperienceLevel(uint32 xp_level)
00371 { _experience_level = xp_level; }
00372
00373 void SetExperiencePoints(uint32 xp_points)
00374 { _experience_points = xp_points; }
00375
00376 void SetHitPoints(uint32 hp)
00377 { if (hp > _max_hit_points) _hit_points = _max_hit_points; else _hit_points = hp; }
00378
00379 void SetMaxHitPoints(uint32 hp)
00380 { _max_hit_points = hp; if (_hit_points > _max_hit_points) _hit_points = _max_hit_points; }
00381
00382 void SetSkillPoints(uint32 sp)
00383 { if (sp > _max_skill_points) _skill_points = _max_skill_points; else _skill_points = sp; }
00384
00385 void SetMaxSkillPoints(uint32 sp)
00386 { _max_skill_points = sp; if (_skill_points > _max_skill_points) _skill_points = _max_skill_points; }
00387
00388 void SetStrength(uint32 st)
00389 { _strength = st; _CalculateAttackRatings(); }
00390
00391 void SetVigor(uint32 vi)
00392 { _vigor = vi; _CalculateAttackRatings(); }
00393
00394 void SetFortitude(uint32 fo)
00395 { _fortitude = fo; _CalculateDefenseRatings(); }
00396
00397 void SetProtection(uint32 pr)
00398 { _protection = pr; _CalculateDefenseRatings(); }
00399
00400 void SetAgility(uint32 ag)
00401 { _agility = ag; }
00402
00403 void SetEvade(float ev)
00404 { _evade = ev; _CalculateEvadeRatings(); }
00406
00413
00414 void AddHitPoints(uint32 hp)
00415 { _hit_points += hp; if (_hit_points > _max_hit_points) _hit_points = _max_hit_points; }
00416
00418 void SubHitPoints(uint32 hp)
00419 { if (hp < _hit_points) _hit_points -= hp; else _hit_points = 0; }
00420
00422 void AddMaxHitPoints(uint32 hp)
00423 { _max_hit_points += hp; _hit_points += hp; }
00424
00426 void AddSkillPoints(uint32 sp)
00427 { _skill_points += sp; if (_skill_points > _max_skill_points) _skill_points = _max_skill_points; }
00428
00430 void SubSkillPoints(uint32 sp)
00431 { if (sp < _skill_points) _skill_points -= sp; else _skill_points = 0; }
00432
00434 void AddMaxSkillPoints(uint32 sp)
00435 { _max_skill_points += sp; _skill_points += sp; }
00436
00437 void AddStrength(uint32 st)
00438 { _strength += st; _CalculateAttackRatings(); }
00439
00440 void AddVigor(uint32 vi)
00441 { _vigor += vi; _CalculateAttackRatings(); }
00442
00443 void AddFortitude(uint32 fo)
00444 { _fortitude += fo; _CalculateDefenseRatings(); }
00445
00446 void AddProtection(uint32 pr)
00447 { _protection += pr; _CalculateDefenseRatings(); }
00448
00449 void AddAgility(uint32 ag)
00450 { _agility += ag; }
00451
00452 void AddEvade(float ev)
00453 { _evade += ev; _CalculateEvadeRatings(); }
00455
00462 GlobalWeapon* EquipWeapon(GlobalWeapon* weapon);
00463
00472 GlobalArmor* EquipArmor(GlobalArmor* armor, uint32 index);
00473
00480 virtual void AddSkill(uint32 skill_id) = 0;
00481
00482 protected:
00484 uint32 _id;
00485
00487 hoa_utils::ustring _name;
00488
00490 std::string _filename;
00491
00493
00494
00495 uint32 _experience_level;
00496
00498 uint32 _experience_points;
00499
00501 uint32 _hit_points;
00502
00504 uint32 _max_hit_points;
00505
00507 uint32 _skill_points;
00508
00510 uint32 _max_skill_points;
00511
00513 uint32 _strength;
00514
00516 uint32 _vigor;
00517
00519 uint32 _fortitude;
00520
00522 uint32 _protection;
00523
00525 uint32 _agility;
00526
00528 float _evade;
00530
00532 uint32 _total_physical_attack;
00533
00535 uint32 _total_metaphysical_attack;
00536
00540 std::vector<GlobalAttackPoint*> _attack_points;
00541
00550 GlobalWeapon* _weapon_equipped;
00551
00561 std::vector<GlobalArmor*> _armor_equipped;
00562
00567 std::map<uint32, GlobalSkill*> _skills;
00568
00573
00574
00581
00582
00587
00588
00595
00596
00601 void _CalculateAttackRatings();
00602
00608 void _CalculateDefenseRatings();
00609
00614 void _CalculateEvadeRatings();
00615 };
00616
00617
00647 class GlobalCharacterGrowth {
00648 friend class GlobalCharacter;
00649 friend void hoa_defs::BindEngineToLua();
00650
00651 public:
00652 GlobalCharacterGrowth(GlobalCharacter* owner) :
00653 _character_owner(owner) {}
00654
00655 ~GlobalCharacterGrowth();
00656
00661 void AcknowledgeGrowth();
00662
00664
00665 bool IsExperienceLevelGained() const
00666 { return _experience_level_gained; }
00667
00668 bool IsGrowthDetected() const
00669 { return _growth_detected; }
00670
00671 uint32 GetHitPointsGrowth() const
00672 { return _hit_points_growth; }
00673
00674 uint32 GetSkillPointsGrowth() const
00675 { return _skill_points_growth; }
00676
00677 uint32 GetStrengthGrowth() const
00678 { return _strength_growth; }
00679
00680 uint32 GetVigorGrowth() const
00681 { return _vigor_growth; }
00682
00683 uint32 GetFortitudeGrowth() const
00684 { return _fortitude_growth; }
00685
00686 uint32 GetProtectionGrowth() const
00687 { return _protection_growth; }
00688
00689 float GetEvadeGrowth() const
00690 { return _evade_growth; }
00691
00692 std::list<GlobalSkill*>* GetSkillsLearned()
00693 { return &_skills_learned; }
00695
00696 private:
00698 GlobalCharacter* _character_owner;
00699
00701 bool _experience_level_gained;
00702
00704 bool _growth_detected;
00705
00707 uint32 _experience_for_next_level;
00708
00710 uint32 _experience_for_last_level;
00711
00721 uint32 _hit_points_growth;
00722 uint32 _skill_points_growth;
00723 uint32 _strength_growth;
00724 uint32 _vigor_growth;
00725 uint32 _fortitude_growth;
00726 uint32 _protection_growth;
00727 uint32 _agility_growth;
00728 float _evade_growth;
00730
00744 std::deque<std::pair<uint32, uint32> > _hit_points_periodic_growth;
00745 std::deque<std::pair<uint32, uint32> > _skill_points_periodic_growth;
00746 std::deque<std::pair<uint32, uint32> > _strength_periodic_growth;
00747 std::deque<std::pair<uint32, uint32> > _vigor_periodic_growth;
00748 std::deque<std::pair<uint32, uint32> > _fortitude_periodic_growth;
00749 std::deque<std::pair<uint32, uint32> > _protection_periodic_growth;
00750 std::deque<std::pair<uint32, uint32> > _agility_periodic_growth;
00751 std::deque<std::pair<uint32, float> > _evade_periodic_growth;
00753
00758 std::list<GlobalSkill*> _skills_learned;
00759
00764 void _AddSkill(uint32 skill_id);
00765
00771 void _CheckForGrowth();
00772
00784 void _ConstructPeriodicGrowth();
00785
00791 void _DetermineNextLevelExperience();
00792 };
00793
00794
00807 class GlobalCharacter : public GlobalActor {
00808 friend class GlobalCharacterGrowth;
00809
00810 public:
00818 GlobalCharacter(uint32 id, bool initial = true);
00819
00820 virtual ~GlobalCharacter();
00821
00822 bool IsCharacter()
00823 { return true; }
00824
00826
00827 uint32 GetExperienceForNextLevel() const
00828 { return _growth._experience_for_next_level; }
00829
00830 GlobalCharacterGrowth* GetGrowth()
00831 { return &_growth; }
00832
00833 GlobalArmor* GetHeadArmorEquipped()
00834 { return _armor_equipped[0]; }
00835
00836 GlobalArmor* GetTorsoArmorEquipped()
00837 { return _armor_equipped[1]; }
00838
00839 GlobalArmor* GetArmArmorEquipped()
00840 { return _armor_equipped[2]; }
00841
00842 GlobalArmor* GetLegArmorEquipped()
00843 { return _armor_equipped[3]; }
00844
00845 std::vector<GlobalSkill*>* GetAttackSkills()
00846 { return &_attack_skills; }
00847
00848 std::vector<GlobalSkill*>* GetDefenseSkills()
00849 { return &_defense_skills; }
00850
00851 std::vector<GlobalSkill*>* GetSupportSkills()
00852 { return &_support_skills; }
00854
00855 void AddSkill(uint32 skill_id);
00856
00861 bool AddExperiencePoints(uint32 xp);
00862
00863 GlobalArmor* EquipHeadArmor(GlobalArmor* armor)
00864 { return EquipArmor(armor, GLOBAL_POSITION_HEAD); }
00865
00866 GlobalArmor* EquipTorsoArmor(GlobalArmor* armor)
00867 { return EquipArmor(armor, GLOBAL_POSITION_TORSO); }
00868
00869 GlobalArmor* EquipArmArmor(GlobalArmor* armor)
00870 { return EquipArmor(armor, GLOBAL_POSITION_ARMS); }
00871
00872 GlobalArmor* EquipLegArmor(GlobalArmor* armor)
00873 { return EquipArmor(armor, GLOBAL_POSITION_LEGS); }
00874
00875
00877 void AddBattleAnimation(const std::string & name, hoa_video::AnimatedImage anim)
00878 { _battle_animation[name] = anim; }
00879
00880 hoa_video::AnimatedImage* RetrieveBattleAnimation(const std::string & name)
00881 { return &_battle_animation[name]; }
00882
00883 std::vector<hoa_video::StillImage>* GetBattlePortraits()
00884 { return &_battle_portraits; }
00886
00887 protected:
00895 std::vector<GlobalSkill*> _attack_skills;
00896 std::vector<GlobalSkill*> _defense_skills;
00897 std::vector<GlobalSkill*> _support_skills;
00899
00905 GlobalCharacterGrowth _growth;
00906
00919 std::vector<hoa_video::StillImage> _map_frames_standard;
00920
00925 hoa_video::StillImage _map_portrait_standard;
00926
00931 std::map<std::string, hoa_video::AnimatedImage> _battle_animation;
00932
00939 std::vector<hoa_video::StillImage> _battle_portraits;
00940
00945 hoa_video::StillImage _menu_portrait;
00947 };
00948
00949
00963 class GlobalEnemy : public GlobalActor {
00964 public:
00965 GlobalEnemy(uint32 id);
00966
00967 ~GlobalEnemy();
00968
00969 bool IsCharacter()
00970 { return false; }
00971
00978 void AddSkill(uint32 skill_id);
00979
00990 void Initialize(uint32 xp_level);
00991
01000 void DetermineDroppedObjects(std::vector<GlobalObject*>& objects);
01001
01003
01004 uint32 GetSpriteHeight() const
01005 { return _sprite_height; }
01006
01007 uint32 GetSpriteWidth() const
01008 { return _sprite_width; }
01009
01010 uint32 GetDrunesDropped() const
01011 { return _drunes_dropped; }
01012
01013 std::vector<hoa_video::StillImage>* GetBattleSpriteFrames()
01014 { return &_battle_sprite_frames; }
01016
01017 protected:
01019 uint32 _sprite_width, _sprite_height;
01020
01029 float _growth_hit_points;
01030 float _growth_skill_points;
01031 float _growth_experience_points;
01032 float _growth_strength;
01033 float _growth_vigor;
01034 float _growth_fortitude;
01035 float _growth_protection;
01036 float _growth_agility;
01037 float _growth_evade;
01038 float _growth_drunes;
01040
01042 uint32 _drunes_dropped;
01043
01051 std::vector<uint32> _dropped_objects;
01052 std::vector<float> _dropped_chance;
01053 std::vector<uint32> _dropped_level_required;
01055
01063 std::map<uint32, uint32> _skill_set;
01064
01070 std::vector<hoa_video::StillImage> _battle_sprite_frames;
01071 };
01072
01073
01094 class GlobalParty : public GlobalTarget {
01095 public:
01099 GlobalParty(bool allow_duplicates = false) :
01100 _allow_duplicates(allow_duplicates) {}
01101
01102 ~GlobalParty()
01103 {}
01104
01110 void AddActor(GlobalActor* actor, int32 index = -1);
01111
01116 GlobalActor* RemoveActorAtIndex(uint32 index);
01117
01122 GlobalActor* RemoveActorByID(uint32 id);
01123
01128 void RemoveAllActors()
01129 { _actors.clear(); }
01130
01135 void SwapActorsByIndex(uint32 first_index, uint32 second_index);
01136
01141 void SwapActorsByID(uint32 first_id, uint32 second_id);
01142
01148 GlobalActor* ReplaceActorByIndex(uint32 index, GlobalActor* new_actor);
01149
01155 GlobalActor* ReplaceActorByID(uint32 id, GlobalActor* new_actor);
01156
01160 float AverageExperienceLevel() const;
01161
01166 GlobalActor* GetActorAtIndex(uint32 index) const
01167 { if (index >= _actors.size()) return NULL; else return _actors[index]; }
01168
01173 GlobalActor* GetActorByID(uint32 id) const;
01174
01175 GLOBAL_TARGET GetTargetType()
01176 { return GLOBAL_TARGET_PARTY; }
01177
01178 bool IsPartyEmpty() const
01179 { return (_actors.size() == 0); }
01180
01181 bool IsAllowDuplicates() const
01182 { return _allow_duplicates; }
01183
01184 uint32 GetPartySize() const
01185 { return _actors.size(); }
01186
01187 std::vector<GlobalActor*>* GetAllActors()
01188 { return &_actors; }
01189
01190 private:
01194 std::vector<GlobalActor*> _actors;
01195
01197 bool _allow_duplicates;
01198 };
01199
01200 }
01201
01202 #endif // __GLOBAL_ACTORS_HEADER__