1 ////////////////////////////////////////////////////////////////////////////////
2 //            Copyright (C) 2004-2007 by The Allacrost Project
3 //                         All Rights Reserved
4 //
5 // This code is licensed under the GNU GPL version 2. It is free software
6 // and you may modify it and/or redistribute it under the terms of this license.
7 // See http://www.gnu.org/copyleft/gpl.html for details.
8 ////////////////////////////////////////////////////////////////////////////////
9 
10 /** ****************************************************************************
11 *** \file    global_utils.h
12 *** \author  Tyler Olsen, rootslinux@allacrost.org
13 *** \brief   Header file for global game utility code
14 ***
15 *** This file contains several common constants, enums, and functions that are
16 *** used by various global classes.
17 *** ***************************************************************************/
18 
19 #ifndef __GLOBAL_UTILS_HEADER__
20 #define __GLOBAL_UTILS_HEADER__
21 
22 #include "defs.h"
23 #include "utils.h"
24 
25 namespace hoa_global {
26 
27 namespace private_global {
28 
29 /** \name Object ID Range Constants
30 *** These constants set the maximum valid ID ranges for each object category.
31 *** The full valid range for each object category ID is:
32 *** - Items:            1-10000
33 *** - Weapons:      10001-20000
34 *** - Head Armor:   20001-30000
35 *** - Torso Armor:  30001-40000
36 *** - Arm Armor:    40001-50000
37 *** - Leg Armor:    50001-60000
38 *** - Shards:       60001-70000
39 *** - Key Items:    70001-80000
40 **/
41 //@{
42 const uint32 OBJECT_ID_INVALID   = 0;
43 const uint32 MAX_ITEM_ID         = 10000;
44 const uint32 MAX_WEAPON_ID       = 20000;
45 const uint32 MAX_HEAD_ARMOR_ID   = 30000;
46 const uint32 MAX_TORSO_ARMOR_ID  = 40000;
47 const uint32 MAX_ARM_ARMOR_ID    = 50000;
48 const uint32 MAX_LEG_ARMOR_ID    = 60000;
49 const uint32 MAX_SHARD_ID        = 70000;
50 const uint32 MAX_KEY_ITEM_ID     = 80000;
51 const uint32 OBJECT_ID_EXCEEDS   = 80001;
52 //@}
53 
54 
55 /** \name Skill ID Range Constants
56 *** These constants set the maximum valid ID ranges for each skill category.
57 *** The full valid range for each skill category ID is:
58 *** - Attack:        1-10000
59 *** - Defend:    10001-20000
60 *** - Support:   20001-30000
61 **/
62 //@{
63 const uint32 MAX_ATTACK_ID   = 10000;
64 const uint32 MAX_DEFEND_ID   = 20000;
65 const uint32 MAX_SUPPORT_ID  = 30000;
66 //@}
67 
68 } // namespace private_global
69 
70 //! \brief A return value used for when a specified event name fails to be found
71 const int32 GLOBAL_BAD_EVENT = 0xFFFFFFFF;
72 
73 
74 /** \name Target Types
75 *** \brief Enum values used for declaring the type of targets for items, skills, and actions.
76 ***
77 *** There are three types of groups within these target types:
78 *** - Attack Point Types: GLOBAL_TARGET_SELF_POINT, GLOBAL_TARGET_ALLY_POINT, GLOBAL_TARGET_FOE_POINT
79 *** - Actor Types: GLOBAL_TARGET_SELF, GLOBAL_TARGET_ALLY, GLOBAL_TARGET_FOE
80 *** - Party Types: GLOBAL_TARGET_ALL_ALLIES, GLOBAL_TARGET_ALL_FOES
81 ***
82 *** \note The phrasing of "ally" and "foe" in these enum names is relative to the context it is used in.
83 *** For example, a character using a skill that targets an ally will target one of the other characters in
84 *** the party while a foe target will select an enemy on the opposing party. On the other hand, if an enemy
85 *** to the character party is selecting an ally target it will target one of the other enemies in the party
86 *** and the foe of the enemy is a character.
87 **/
88 enum GLOBAL_TARGET {
89 	GLOBAL_TARGET_INVALID      = -1,
90 	GLOBAL_TARGET_SELF_POINT   =  0,
91 	GLOBAL_TARGET_ALLY_POINT   =  1, //!< \note This includes allowing the user to target itself
92 	GLOBAL_TARGET_FOE_POINT    =  2,
93 	GLOBAL_TARGET_SELF         =  3,
94 	GLOBAL_TARGET_ALLY         =  4, //!< \note This includes allowing the user to target itself
95 	GLOBAL_TARGET_FOE          =  5,
96 	GLOBAL_TARGET_ALL_ALLIES   =  6,
97 	GLOBAL_TARGET_ALL_FOES     =  7,
98 	GLOBAL_TARGET_TOTAL        =  8
99 };
100 
101 
102 /** \name GlobalItem and GlobalSkill Usage Cases
103 *** \brief Enum values used for identification of different game object types
104 **/
105 enum GLOBAL_USE {
106 	GLOBAL_USE_INVALID = -1,
107 	GLOBAL_USE_FIELD   =  0, //!< Usable only in maps and menus
108 	GLOBAL_USE_BATTLE  =  1, //!< Usable only in battle
109 	GLOBAL_USE_ALL     =  2, //!< Usable at any time and any location
110 	GLOBAL_USE_TOTAL   =  3
111 };
112 
113 
114 /** \name Game Character IDs
115 *** \brief Integers that are used for identification of characters
116 *** These series of constants are used as bit-masks for determining things such as if the character
117 *** may use a certain item. Only one bit should be set for each character ID.
118 ***
119 *** \note The IDs for each character are defined in the dat/global.lua file.
120 **/
121 //@{
122 const uint32 GLOBAL_CHARACTER_INVALID     = 0x00000000;
123 const uint32 GLOBAL_CHARACTER_ALL         = 0xFFFFFFFF;
124 //@}
125 
126 
127 /** \name Character Attack Point Positions
128 *** \brief Integers that represent the index location of the four attack points and armor types for characters
129 **/
130 //@{
131 const uint32 GLOBAL_POSITION_HEAD  = 0;
132 const uint32 GLOBAL_POSITION_TORSO = 1;
133 const uint32 GLOBAL_POSITION_ARMS  = 2;
134 const uint32 GLOBAL_POSITION_LEGS  = 3;
135 //@}
136 
137 
138 //! \brief The maximum number of characters that can be in the active party
139 const uint32 GLOBAL_MAX_PARTY_SIZE = 4;
140 
141 
142 /** \name GlobalObject Types
143 *** \brief Used for identification of different game object types
144 **/
145 enum GLOBAL_OBJECT {
146 	GLOBAL_OBJECT_INVALID     = -1,
147 	GLOBAL_OBJECT_ITEM        =  0,
148 	GLOBAL_OBJECT_WEAPON      =  1,
149 	GLOBAL_OBJECT_HEAD_ARMOR  =  2,
150 	GLOBAL_OBJECT_TORSO_ARMOR =  3,
151 	GLOBAL_OBJECT_ARM_ARMOR   =  4,
152 	GLOBAL_OBJECT_LEG_ARMOR   =  5,
153 	GLOBAL_OBJECT_SHARD       =  6,
154 	GLOBAL_OBJECT_KEY_ITEM    =  7,
155 	GLOBAL_OBJECT_TOTAL       =  8
156 };
157 
158 
159 /** \name Elemental Effect Types
160 *** \brief Used to identify the eight different types of elementals
161 *** There are a total of four physical and four metaphysical elemental effects
162 **/
163 enum GLOBAL_ELEMENTAL {
164 	GLOBAL_ELEMENTAL_INVALID    = -1,
165 	GLOBAL_ELEMENTAL_FIRE       =  0,
166 	GLOBAL_ELEMENTAL_WATER      =  1,
167 	GLOBAL_ELEMENTAL_VOLT       =  2,
168 	GLOBAL_ELEMENTAL_EARTH      =  3,
169 	GLOBAL_ELEMENTAL_SLICING    =  4,
170 	GLOBAL_ELEMENTAL_SMASHING   =  5,
171 	GLOBAL_ELEMENTAL_MAULING    =  6,
172 	GLOBAL_ELEMENTAL_PIERCING   =  7,
173 	GLOBAL_ELEMENTAL_TOTAL      =  8
174 };
175 
176 
177 /** \name Status Effect Types
178 *** \brief Used to identify the various types of status effects
179 **/
180 enum GLOBAL_STATUS {
181 	GLOBAL_STATUS_INVALID            = -1,
182 	GLOBAL_STATUS_HP_BOOST           =  0,
183 	GLOBAL_STATUS_HP_DRAIN           =  1,
184 	GLOBAL_STATUS_SP_BOOST           =  2,
185 	GLOBAL_STATUS_SP_DRAIN           =  3,
186 	GLOBAL_STATUS_STRENGTH_BOOST     =  4,
187 	GLOBAL_STATUS_STRENGTH_DRAIN     =  5,
188 	GLOBAL_STATUS_VIGOR_BOOST        =  6,
189 	GLOBAL_STATUS_VIGOR_DRAIN        =  7,
190 	GLOBAL_STATUS_FORTITUDE_BOOST    =  8,
191 	GLOBAL_STATUS_FORTITUDE_DRAIN    =  9,
192 	GLOBAL_STATUS_PROTECTION_BOOST   = 10,
193 	GLOBAL_STATUS_PROTECTION_DRAIN   = 11,
194 	GLOBAL_STATUS_AGILITY_BOOST      = 12,
195 	GLOBAL_STATUS_AGILITY_DRAIN      = 13,
196 	GLOBAL_STATUS_EVADE_BOOST        = 14,
197 	GLOBAL_STATUS_EVADE_DRAIN        = 15,
198 	GLOBAL_STATUS_PARALYSIS          = 16,
199 	GLOBAL_STATUS_TOTAL              = 17
200 };
201 
202 
203 /** \name Effect Intensity Levels
204 *** \brief Used to reflect the potency of elemental and status effects
205 *** There are nine valid intensity levels. Four negative, four positive, and one neutral.
206 *** The neutral intensity level essentially equates to "no effect".
207 **/
208 enum GLOBAL_INTENSITY {
209 	GLOBAL_INTENSITY_INVALID       = -5,
210 	GLOBAL_INTENSITY_NEG_EXTREME   = -4,
211 	GLOBAL_INTENSITY_NEG_GREATER   = -3,
212 	GLOBAL_INTENSITY_NEG_MODERATE  = -2,
213 	GLOBAL_INTENSITY_NEG_LESSER    = -1,
214 	GLOBAL_INTENSITY_NEUTRAL       =  0,
215 	GLOBAL_INTENSITY_POS_LESSER    =  1,
216 	GLOBAL_INTENSITY_POS_MODERATE  =  2,
217 	GLOBAL_INTENSITY_POS_GREATER   =  3,
218 	GLOBAL_INTENSITY_POS_EXTREME   =  4,
219 	GLOBAL_INTENSITY_TOTAL         =  5
220 };
221 
222 
223 /** \name Skill Types
224 *** \brief Enum values used to identify the type of a skill.
225 **/
226 enum GLOBAL_SKILL {
227 	GLOBAL_SKILL_INVALID  = -1,
228 	GLOBAL_SKILL_ATTACK   =  0,
229 	GLOBAL_SKILL_DEFEND   =  1,
230 	GLOBAL_SKILL_SUPPORT  =  2,
231 	GLOBAL_SKILL_TOTAL    =  3
232 };
233 
234 
235 /** \brief Retrieves a string representation for any GLOBAL_TARGET enum value
236 *** \param target The target enum value to find the string for
237 *** \return Translated text that describes the target
238 **/
239 std::string GetTargetText(GLOBAL_TARGET target);
240 
241 
242 /** \brief Returns true if the target selects an attack point
243 *** \param target The target enum value to analyze
244 **/
245 bool IsTargetPoint(GLOBAL_TARGET target);
246 
247 
248 /** \brief Returns true if the target selects an actor
249 *** \param target The target enum value to analyze
250 **/
251 bool IsTargetActor(GLOBAL_TARGET target);
252 
253 
254 /** \brief Returns true if the target selects a party
255 *** \param target The target enum value to analyze
256 **/
257 bool IsTargetParty(GLOBAL_TARGET target);
258 
259 
260 /** \brief Returns true if the target selects the user
261 *** \param target The target enum value to analyze
262 **/
263 bool IsTargetSelf(GLOBAL_TARGET target);
264 
265 
266 /** \brief Returns true if the target selects an ally
267 *** \param target The target enum value to analyze
268 **/
269 bool IsTargetAlly(GLOBAL_TARGET target);
270 
271 
272 /** \brief Returns true if the target selects a foe
273 *** \param target The target enum value to analyze
274 **/
275 bool IsTargetFoe(GLOBAL_TARGET target);
276 
277 
278 /** \brief Creates a new GlobalObject and returns a pointer to it
279 *** \param id The id value of the object to create
280 *** \param count The count of the new object to create (default value == 1)
281 *** \return A pointer to the newly created GlobalObject, or NULL if the object could not be created
282 ***
283 *** This function does not actually create a GlobalObject (it can't since its an abstract class).
284 *** It creates one of the derived object class types depending on the value of the id argument.
285 **/
286 GlobalObject* GlobalCreateNewObject(uint32 id, uint32 count = 1);
287 
288 
289 /** \brief Increments a GLOBAL_INTENSITY enumerated value
290 *** \param intensity A reference to the intensity data to modify
291 *** \param amount The number of levels to increase the intensity by (default == 1)
292 *** \return True if the intensity data was modified or false if it was left unchanged
293 *** \note The intensity will not be allowed to increase beyond the valid intensity range
294 **/
295 bool IncrementIntensity(GLOBAL_INTENSITY& intensity, uint8 amount = 1);
296 
297 
298 /** \brief Decrements a GLOBAL_INTENSITY enumerated value
299 *** \param intensity A reference to the intensity data to modify
300 *** \param amount The number of levels to decrease the intensity by (default == 1)
301 *** \return True if the intensity data was modified or false if it was left unchanged
302 *** \note The intensity will not be allowed to decrease beyond the valid intensity range
303 **/
304 bool DecrementIntensity(GLOBAL_INTENSITY& intensity, uint8 amount = 1);
305 
306 } // namespace hoa_global
307 
308 #endif // __GLOBAL_UTILS_HEADER__
309