1 /*! 2 * \file 3 * \ingroup stats_window 4 * \brief Attributes und statistics handling 5 */ 6 #ifndef __STATS_H__ 7 #define __STATS_H__ 8 9 #include <SDL_types.h> 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #define FLOATINGMESSAGE_NORTH 1 16 #define FLOATINGMESSAGE_EAST 2 17 #define FLOATINGMESSAGE_SOUTH 3 18 #define FLOATINGMESSAGE_WEST 4 19 #define FLOATINGMESSAGE_MIDDLE 5 20 21 /*! 22 * The names structure is used for all sort of attributes, skill, nexi to give them a long and a short name. 23 */ 24 typedef struct 25 { 26 unsigned char name[21]; /*!< the common, long name */ 27 #ifdef WRITE_XML 28 int saved_name; 29 #endif 30 unsigned char shortname[7]; /*!< a short-name for the given name */ 31 #ifdef WRITE_XML 32 int saved_shortname; 33 #endif 34 } names; 35 36 /*! 37 * The attrib_16 structure is used to store the base and the current value of an attribute. 38 */ 39 typedef struct 40 { 41 Sint16 base; /*!< the base value of the attribute */ 42 Sint16 cur; /*!< the current value of the attribute. This might be modified by blessings, for example. */ 43 } attrib_16; 44 45 /*! 46 * The attrib_16f structure stores two function pointers, that are used to calculate the base and current value of a cross attribute. 47 */ 48 typedef struct 49 { 50 Sint16 (*base)(void); /*!< function pointer to aquire the base value of a cross attribute. */ 51 Sint16 (*cur)(void); /*!< funtion pointer to aquire the current value of a cross attribute */ 52 } attrib_16f; 53 54 /*! 55 * attributes_struct stores all the names and short names of all the attributes, cross attributes, nexi, skills, food level, pickpoints, material and ethereal points and carry capacity. 56 */ 57 struct attributes_struct 58 { 59 unsigned char base[30]; /*!< buffer to store the \see names of a base attribute */ 60 61 names phy; /*!< name and short name of physic base attribute */ 62 names coo; /*!< name and short name of coordination base attribute */ 63 64 names rea; /*!< name and short name of reasoning base attribute */ 65 names wil; /*!< name and short name of will base attribute */ 66 67 names ins; /*!< name and short name of instinct base attribute */ 68 names vit; /*!< name and short name of vitality base attribute */ 69 70 unsigned char cross[30]; /*!< buffer to store the \see names of a cross attribute */ 71 names might; /*!< name and short name of might cross attribute */ 72 names matter; /*!< name and short name of matter cross attribute */ 73 names tough; /*!< name and short name of toughness cross attribute */ 74 names react; /*!< name and short name of reaction cross attribute */ 75 names charm; /*!< name and short name of charm cross attribute */ 76 names perc; /*!< name and short name of perception cross attribute */ 77 names ration; /*!< name and short name of rationality cross attribute */ 78 names dext; /*!< name and short name of dexterity cross attribute */ 79 names eth; /*!< name and short name of ethereality cross attribute */ 80 81 unsigned char nexus[30]; /*!< buffer to store the \see names of a nexus */ 82 names human_nex; /*!< name and short name of human nexus */ 83 names animal_nex; /*!< name and short name of animal nexus */ 84 names vegetal_nex; /*!< name and short name of vegetal nexus */ 85 names inorganic_nex; /*!< name and short name of inorganic nexus */ 86 names artificial_nex; /*!< name and short name of artificial nexus */ 87 names magic_nex; /*!< name and short name of magic nexus */ 88 89 unsigned char skills[30]; /*!< buffer to store the \see names of a skill */ 90 names manufacturing_skill; /*!< name and short name of manufacturing skill */ 91 names harvesting_skill; /*!< name and short name of harvesting skill */ 92 names alchemy_skill; /*!< name and short name of alchemy skill */ 93 names overall_skill; /*!< name and short name of overall skill */ 94 names attack_skill; /*!< name and short name of attack skill */ 95 names defense_skill; /*!< name and short name of defense skill */ 96 names magic_skill; /*!< name and short name of magic skill */ 97 names potion_skill; /*!< name and short name of potion skill */ 98 names summoning_skill; /*!< name and short name of summoning skill */ 99 names crafting_skill; /*!< name and short name of crafting skill */ 100 names engineering_skill; /*!< name and short name of engineering skill */ 101 names tailoring_skill; /*!< name and short name of tailoring skill */ 102 names ranging_skill; /*!< name and short name of ranging skill */ 103 104 names food; /*!< name and short name of food level */ 105 unsigned char pickpoints[30]; /*!< available pickpoints */ 106 names material_points; /*!< name and short name of material points */ 107 names ethereal_points; /*!< name and short name of ethereal points */ 108 names action_points; /*!< name and short name of action points */ 109 110 names carry_capacity; /*!< name and short name of carry capacity */ 111 }; 112 113 extern struct attributes_struct attributes; /*!< global variable for an actors attributes */ 114 115 /*! 116 * The player_attribs structure takes care of all the attributes of a player. 117 */ 118 typedef struct 119 { 120 unsigned char name[20]; /*!< name (of what? player? current selected attrib/skill/...?) */ 121 122 attrib_16 phy; /*!< base and current value of the physic base attribute */ 123 attrib_16 coo; /*!< base and current value of the coordination base attribute */ 124 125 attrib_16 rea; /*!< base and current value of the reasoning base attribute */ 126 attrib_16 wil; /*!< base and current value of the will base attribute */ 127 128 attrib_16 ins; /*!< base and current value of the instinct base attribute */ 129 attrib_16 vit; /*!< base and current value of the vitality base attribute */ 130 131 attrib_16f might; /*!< functions to get the base and current value of the might cross attribute */ 132 attrib_16f matter; /*!< functions to get the base and current value of the matter cross attribute */ 133 attrib_16f tough; /*!< functions to get the base and current value of the toughness cross attribute */ 134 attrib_16f charm; /*!< functions to get the base and current value of the charm cross attribute */ 135 attrib_16f react; /*!< functions to get the base and current value of the reaction cross attribute */ 136 attrib_16f perc; /*!< functions to get the base and current value of the perception cross attribute */ 137 attrib_16f ration; /*!< functions to get the base and current value of the rationality cross attribute */ 138 attrib_16f dext; /*!< functions to get the base and current value of the dexterity cross attribute */ 139 attrib_16f eth; /*!< functions to get the base and current value of the ethereality cross attribute */ 140 141 attrib_16 human_nex; /*!< base and current value of the human nexus */ 142 attrib_16 animal_nex; /*!< base and current value of the animal nexus */ 143 attrib_16 vegetal_nex; /*!< base and current value of the vegetal nexus */ 144 attrib_16 inorganic_nex; /*!< base and current value of the inorganic nexus */ 145 attrib_16 artificial_nex; /*!< base and current value of the artificial nexus */ 146 attrib_16 magic_nex; /*!< base and current value of the magic nexus */ 147 148 attrib_16 material_points; /*!< base and current value of the players material points */ 149 attrib_16 ethereal_points; /*!< base and current value of the players ethereal points */ 150 attrib_16 action_points; /*!< base and current value of the players action points */ 151 152 attrib_16 manufacturing_skill; /*!< base and current value of the manu skill */ 153 attrib_16 harvesting_skill; /*!< base and current value of the harvesting skill */ 154 attrib_16 alchemy_skill; /*!< base and current value of the alchemy skill */ 155 attrib_16 overall_skill; /*!< base and current value of the overall skill */ 156 attrib_16 attack_skill; /*!< base and current value of the attack skill */ 157 attrib_16 defense_skill; /*!< base and current value of the defense skill */ 158 attrib_16 magic_skill; /*!< base and current value of the magic skill */ 159 attrib_16 potion_skill; /*!< base and current value of the potion skill */ 160 attrib_16 summoning_skill; /*!< base and current value of the summoning skill */ 161 attrib_16 crafting_skill; /*!< base and current value of the crafting skill */ 162 attrib_16 engineering_skill; /*!< base and current value of the engineering skill */ 163 attrib_16 tailoring_skill; /*!< base and current value of the tailoring skill */ 164 attrib_16 ranging_skill; /*!< base and current value of the ranging skill */ 165 166 attrib_16 carry_capacity; /*!< base and current value of the carry capacity */ 167 168 Sint8 food_level; /*!< current food level */ 169 170 Uint32 manufacturing_exp; /*!< current manu experience */ 171 Uint32 manufacturing_exp_next_lev; /*!< experience level to reach next manu level */ 172 Uint32 harvesting_exp; /*!< current harvesting experience */ 173 Uint32 harvesting_exp_next_lev; /*!< experience level to reach next harvesting level */ 174 Uint32 alchemy_exp; /*!< current alchemy experience */ 175 Uint32 alchemy_exp_next_lev; /*!< experience level to reach next alchemy level */ 176 Uint32 overall_exp; /*!< current overal experience */ 177 Uint32 overall_exp_next_lev; /*!< experience level to reach next overall level */ 178 Uint32 attack_exp; /*!< current attack experience */ 179 Uint32 attack_exp_next_lev; /*!< experience level to reach next attack level */ 180 Uint32 defense_exp; /*!< current defense experience */ 181 Uint32 defense_exp_next_lev; /*!< experience level to reach next defense level */ 182 Uint32 magic_exp; /*!< current magic experience */ 183 Uint32 magic_exp_next_lev; /*!< experience level to reach next magic level */ 184 Uint32 potion_exp; /*!< current potion experience */ 185 Uint32 potion_exp_next_lev; /*!< experience level to reach next potion level */ 186 Uint32 summoning_exp; /*!< current summoning level */ 187 Uint32 summoning_exp_next_lev; /*!< experience level to reach next summoning level */ 188 Uint32 crafting_exp; /*!< current crafting experience */ 189 Uint32 crafting_exp_next_lev; /*!< experience level to reach next crafting level */ 190 Uint32 engineering_exp; /*!< current engineering experience */ 191 Uint32 engineering_exp_next_lev; /*!< experience level to reach next engineering level */ 192 Uint32 tailoring_exp; /*!< current tailoring experience */ 193 Uint32 tailoring_exp_next_lev; /*!< experience level to reach next tailoring level */ 194 Uint32 ranging_exp; /*!< current ranging experience */ 195 Uint32 ranging_exp_next_lev; /*!< experience level to reach next ranging level */ 196 197 Uint16 researching; /*!< flag to indicate whether a player is currently researching anything or not */ 198 Uint32 research_completed; /*!< if a player is currently researching anything, this value will show how much pages are already read */ 199 Uint32 research_total; /*!< if a player is currently researching anything, this value show the total amount of pages to read, until the book is completely read. */ 200 } player_attribs; 201 202 /* Array for skills info required by stats bar. Stored in an array 203 to allow processing in a loop and avoiding duplicating the code. 204 Possible TBD: Really, the skills should be stored in an array 205 at source so more duplicate code can be removed and new skills 206 added more simply. */ 207 struct stats_struct 208 { 209 Uint32 *exp; 210 Uint32 *next_lev; 211 attrib_16 *skillattr; 212 names *skillnames; 213 int is_selected; 214 }; 215 216 /*! 217 * Indexes for plat stats arrays 218 */ 219 enum { SI_ATT = 0, SI_DEF, SI_HAR, SI_ALC, SI_MAG, SI_POT, SI_SUM, SI_MAN, SI_CRA, SI_ENG, SI_TAI, SI_RAN, SI_ALL }; 220 221 /*! 222 * An array of pointers to the player stats information - enables looping rather than duplicate code. 223 */ 224 extern struct stats_struct statsinfo[]; 225 extern Uint32 last_exp[]; 226 227 #define NUM_SKILLS 13 /*!< the number of skills */ 228 #define NUM_WATCH_STAT 14 /*!< allow watching stats 0-13 */ 229 230 extern int have_stats; /*!< indicator for whether or not the stats have been send to us yet*/ 231 232 extern player_attribs your_info; /*!< the players attributes */ 233 234 /*! 235 * \ingroup stats_window 236 * \brief Retrieves the statistics of the player. 237 * 238 * Retrieves all the statistics of the player and stores them in the parameter stats. 239 * 240 * \param stats 241 * 242 * \callgraph 243 */ 244 void get_the_stats(Sint16 *stats, size_t len_in_bytes); 245 246 /*! 247 * \ingroup stats_window 248 * \brief Gets the part of the stats that is specified by name. 249 * 250 * Gets the part of the stats that is specified by name. 251 * 252 * \param name The name of the stat to get. Can be an attribute, cross attribute, skill or nexus 253 * \param value The value of the stat to get. 254 */ 255 void get_partial_stat(unsigned char name,Sint32 value); 256 257 /*! 258 * \ingroup other 259 * \brief Initializes the callbacks used to calculate base and current value of the cross attributes. 260 * 261 * Initializes the callbacks used to calculate base and current value of the cross attributes. 262 * 263 */ 264 void init_attribf(void); 265 266 /*! 267 * \ingroup stats_window 268 * \brief Sets the window handler functions for the statistics window 269 * 270 * Sets the window handler functions for the statistics window 271 * 272 * \param window_id id of window created for tab 273 * 274 * \callgraph 275 */ 276 void fill_stats_win (int window_id); 277 278 extern int floatingmessages_enabled; 279 void drawactor_floatingmessages(int actor_id, float healthbar_z); 280 void add_floating_message(int actor_id, char * str, int direction, float r, float g, float b, int active_time); 281 void init_statsinfo_array(void); 282 void init_floating_messages(void); 283 void cleanup_floating_messages(void); 284 285 #ifdef __cplusplus 286 } // extern "C" 287 #endif 288 289 #endif 290