global_objects.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
00006 // and 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 
00020 #ifndef __GLOBAL_OBJECTS_HEADER__
00021 #define __GLOBAL_OBJECTS_HEADER__
00022 
00023 #include "defs.h"
00024 #include "utils.h"
00025 #include "image.h"
00026 #include "script.h"
00027 
00028 #include "global_actors.h"
00029 
00030 namespace hoa_global {
00031 
00032 namespace private_global {
00033 
00047 const uint32 MAX_ITEM_ID         = 10000;
00048 const uint32 MAX_WEAPON_ID       = 20000;
00049 const uint32 MAX_HEAD_ARMOR_ID   = 30000;
00050 const uint32 MAX_TORSO_ARMOR_ID  = 40000;
00051 const uint32 MAX_ARM_ARMOR_ID    = 50000;
00052 const uint32 MAX_LEG_ARMOR_ID    = 60000;
00053 const uint32 MAX_SHARD_ID        = 70000;
00054 const uint32 MAX_KEY_ITEM_ID     = 80000;
00056 
00057 } // namespace private_global
00058 
00062 enum GLOBAL_OBJECT {
00063   GLOBAL_OBJECT_INVALID     = -1,
00064   GLOBAL_OBJECT_ITEM        =  0,
00065   GLOBAL_OBJECT_WEAPON      =  1,
00066   GLOBAL_OBJECT_HEAD_ARMOR  =  2,
00067   GLOBAL_OBJECT_TORSO_ARMOR =  3,
00068   GLOBAL_OBJECT_ARM_ARMOR   =  4,
00069   GLOBAL_OBJECT_LEG_ARMOR   =  5,
00070   GLOBAL_OBJECT_SHARD       =  6,
00071   GLOBAL_OBJECT_KEY_ITEM    =  7,
00072   GLOBAL_OBJECT_TOTAL       =  8
00073 };
00074 
00083 GlobalObject* GlobalCreateNewObject(uint32 id, uint32 count = 1);
00084 
00085 
00098 class GlobalObject {
00099 public:
00100   GlobalObject() :
00101     _id(0), _count(0) {}
00102 
00103   GlobalObject(uint32 id, uint32 count) :
00104     _id(id), _count(count) {}
00105 
00106   virtual ~GlobalObject()
00107     {}
00108 
00112   virtual GLOBAL_OBJECT GetObjectType() const = 0;
00113 
00117   void IncrementCount(uint32 count = 1)
00118     { _count += count; }
00119 
00125   void DecrementCount(uint32 count = 1)
00126     { if (count > _count) _count = 0; else _count -= count; }
00127 
00129 
00130   uint32 GetID() const
00131     { return _id; }
00132 
00133   hoa_utils::ustring GetName() const
00134     { return _name; }
00135 
00136   hoa_utils::ustring GetDescription() const
00137     { return _description; }
00138 
00139   uint32 GetCount() const
00140     { return _count; }
00141 
00142   void SetCount(uint32 count)
00143     { _count = count; }
00144 
00145   uint32 GetPrice() const
00146     { return _price; }
00147 
00148   const hoa_video::StillImage& GetIconImage() const
00149     { return _icon_image; }
00151 
00152 protected:
00156   uint32 _id;
00157 
00159   hoa_utils::ustring _name;
00160 
00162   hoa_utils::ustring _description;
00163 
00165   uint32 _count;
00166 
00168   uint32 _price;
00169 
00171   hoa_video::StillImage _icon_image;
00172 }; // class GlobalObject
00173 
00174 
00188 class GlobalItem : public GlobalObject {
00189 public:
00190   GlobalItem(uint32 id, uint32 count = 1);
00191 
00192   ~GlobalItem();
00193 
00194   GLOBAL_OBJECT GetObjectType() const
00195     { return GLOBAL_OBJECT_ITEM; }
00196 
00198   bool IsUsableInBattle()
00199     { return ((_usage == GLOBAL_USE_BATTLE) || (_usage == GLOBAL_USE_ALL)); }
00200 
00202   bool IsUsableInMenu()
00203     { return ((_usage == GLOBAL_USE_MENU) || (_usage == GLOBAL_USE_ALL)); }
00204 
00209   void BattleUse(hoa_battle::private_battle::BattleActor* target, hoa_battle::private_battle::BattleActor* instigator);
00210 
00214   void MenuUse(GlobalCharacter* target);
00215 
00217 
00218   GLOBAL_USE GetUsage() const
00219     { return _usage; }
00220 
00221   GLOBAL_TARGET GetTargetType() const
00222     { return _target_type; }
00223 
00224   bool IsTargetAlly() const
00225     { return _target_ally; }
00227 
00228 private:
00233   GLOBAL_USE _usage;
00234 
00238   GLOBAL_TARGET _target_type;
00239 
00241   bool _target_ally;
00242 
00244   ScriptObject* _battle_use_function;
00245 
00247   ScriptObject* _menu_use_function;
00248 }; // class GlobalItem : public GlobalObject
00249 
00250 
00258 class GlobalWeapon : public GlobalObject {
00259 public:
00260   GlobalWeapon(uint32 id, uint32 count = 1);
00261 
00262   ~GlobalWeapon()
00263     {}
00264 
00265   GLOBAL_OBJECT GetObjectType() const
00266     { return GLOBAL_OBJECT_WEAPON; }
00267 
00268   uint32 GetPhysicalAttack() const
00269     { return _physical_attack; }
00270 
00271   uint32 GetMetaphysicalAttack() const
00272     { return _metaphysical_attack; }
00273 
00274   uint32 GetUsableBy() const
00275     { return _usable_by; }
00276 
00277 private:
00279   uint32 _physical_attack;
00280 
00282   uint32 _metaphysical_attack;
00283 
00287   uint32 _usable_by;
00288 
00289   // TODO: Add elementals, status, and shard sockets to weapons
00290   // std::map<GLOBAL_ELEMENTAL, uint32> _elemental_bonuses;
00291   // std::map<GLOBAL_STATUS, uint32> _status_bonuses;
00292   // std::vector<GlobalShard*> _sockets;
00293 }; // class GlobalWeapon : public GlobalObject
00294 
00295 
00305 class GlobalArmor : public GlobalObject {
00306 public:
00307   GlobalArmor(uint32 id, uint32 count = 1);
00308 
00309   ~GlobalArmor()
00310     {}
00311 
00312   GLOBAL_OBJECT GetObjectType() const;
00313 
00314   uint32 GetPhysicalDefense() const
00315     { return _physical_defense; }
00316 
00317   uint32 GetMetaphysicalDefense() const
00318     { return _metaphysical_defense; }
00319 
00320   uint32 GetUsableBy() const
00321     { return _usable_by; }
00322 
00323 private:
00325   uint32 _physical_defense;
00326 
00328   uint32 _metaphysical_defense;
00329 
00333   uint32 _usable_by;
00334 
00335   // TODO: Add elementals, status, and shard sockets to armor
00336   // std::map<GLOBAL_ELEMENTAL, uint32> _elemental_bonuses;
00337   // std::map<GLOBAL_STATUS, uint32> _status_bonuses;
00338   // std::vector<GlobalShard*> _sockets;
00339 }; // class GlobalArmor : public GlobalObject
00340 
00341 
00350 class GlobalShard : public GlobalObject {
00351 public:
00352   GlobalShard(uint32 id, uint32 count = 1) :
00353     GlobalObject(id, count) {}
00354 
00355   GLOBAL_OBJECT GetObjectType() const
00356     { return GLOBAL_OBJECT_SHARD; }
00357 }; // class GlobalShard : public GlobalObject
00358 
00359 
00368 class GlobalKeyItem : public GlobalObject {
00369 public:
00370   GlobalKeyItem(uint32 id, uint32 count = 1) :
00371     GlobalObject(id, count) {}
00372 
00373   GLOBAL_OBJECT GetObjectType() const
00374     { return GLOBAL_OBJECT_KEY_ITEM; }
00375 }; // class GlobalKeyItem : public GlobalObject
00376 
00377 } // namespace hoa_global
00378 
00379 #endif // __GLOBAL_OBJECTS_HEADER__

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