1 #pragma once
2 
3 //********************************************************************************************
4 //*
5 //*    This file is part of Egoboo.
6 //*
7 //*    Egoboo is free software: you can redistribute it and/or modify it
8 //*    under the terms of the GNU General Public License as published by
9 //*    the Free Software Foundation, either version 3 of the License, or
10 //*    (at your option) any later version.
11 //*
12 //*    Egoboo is distributed in the hope that it will be useful, but
13 //*    WITHOUT ANY WARRANTY; without even the implied warranty of
14 //*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //*    General Public License for more details.
16 //*
17 //*    You should have received a copy of the GNU General Public License
18 //*    along with Egoboo.  If not, see <http://www.gnu.org/licenses/>.
19 //*
20 //********************************************************************************************
21 
22 /// @file file_formats/cap_file.h
23 /// @details routines for reading and writing the character profile file data.txt
24 
25 #include "egoboo_typedef.h"
26 #include "IDSZ_map.h"
27 
28 #if defined(__cplusplus)
29 extern "C"
30 {
31 #endif
32 
33 //--------------------------------------------------------------------------------------------
34 //--------------------------------------------------------------------------------------------
35 #define MAXCAPNAMESIZE      32                      ///< Character class names
36 
37 //Levels
38 #define MAXBASELEVEL            6                 ///< Basic Levels 0-5
39 #define MAXLEVEL               20                 ///< Absolute max level
40 
41 #define GRIP_VERTS             4
42 
43 #define CAP_INFINITE_WEIGHT   0xFF
44 #define CAP_MAX_WEIGHT        0xFE
45 
46 /// The various ID strings that every character has
47     enum e_idsz_type
48     {
49         IDSZ_PARENT = 0,                             ///< Parent index
50         IDSZ_TYPE,                                   ///< Self index
51         IDSZ_SKILL,                                  ///< Skill index
52         IDSZ_SPECIAL,                                ///< Special index
53         IDSZ_HATE,                                   ///< Hate index
54         IDSZ_VULNERABILITY,                          ///< Vulnerability index
55         IDSZ_COUNT                                   ///< ID strings per character
56     };
57 
58 /// The possible damage types
59     enum e_damage_type
60     {
61         DAMAGE_SLASH = 0,
62         DAMAGE_CRUSH,
63         DAMAGE_POKE,
64         DAMAGE_HOLY,                             ///< (Most invert Holy damage )
65         DAMAGE_EVIL,
66         DAMAGE_FIRE,
67         DAMAGE_ICE,
68         DAMAGE_ZAP,
69         DAMAGE_COUNT,
70 
71         DAMAGE_NONE      = 255
72     };
73 
74 /// A list of the possible special experience types
75     enum e_xp_type
76     {
77         XP_FINDSECRET = 0,                          ///< Finding a secret
78         XP_WINQUEST,                                ///< Beating a module or a subquest
79         XP_USEDUNKOWN,                              ///< Used an unknown item
80         XP_KILLENEMY,                               ///< Killed an enemy
81         XP_KILLSLEEPY,                              ///< Killed a sleeping enemy
82         XP_KILLHATED,                               ///< Killed a hated enemy
83         XP_TEAMKILL,                                ///< Team has killed an enemy
84         XP_TALKGOOD,                                ///< Talk good, er...  I mean well
85         XP_COUNT,                                   ///< Number of ways to get experience
86 
87         XP_DIRECT     = 255                         ///< No modification
88     };
89     typedef enum e_xp_type xp_type;
90 
91 /// BB@> enumerated "speech" soun
92 /// @details We COULD ge the scripts to classify which
93 /// sound to use for the "ouch", the "too much baggage", etc.
94 /// also some left-over sounds from the RTS days, but they might be useful if an NPC
95 /// uses messages to control his minions.
96 ///
97 /// for example:
98 /// necromancer sends message to all minions "attack blah"
99 /// zombie minion responds with "moooooaaaaannn" automatically because that is the sound
100 /// registered as his SPEECH_ATTACK sound.
101 /// It seems to have a lot of potential to me. It *could* be done completely in the scripts,
102 /// but the idea of having registered sounds for certain actions makes a lot of sense to me! :)
103 
104     enum e_sound_types
105     {
106         SOUND_FOOTFALL = 0,
107         SOUND_JUMP,
108         SOUND_SPAWN,
109         SOUND_DEATH,
110 
111         /// old "RTS" stuff
112         SPEECH_MOVE,
113         SPEECH_MOVEALT,
114         SPEECH_ATTACK,
115         SPEECH_ASSIST,
116         SPEECH_TERRAIN,
117         SPEECH_SELECT,
118 
119         SOUND_COUNT,
120 
121         SPEECH_BEGIN = SPEECH_MOVE,
122         SPEECH_END   = SPEECH_SELECT
123     };
124 
125 /// Where an item is being held
126     enum e_slots
127     {
128         SLOT_LEFT  = 0,
129         SLOT_RIGHT,
130         SLOT_COUNT
131     };
132     typedef enum e_slots slot_t;
133 
134 /// The possible extended slots that an object might be equipped in
135 /// @details This system is not fully implemented yet
136     enum e_inventory
137     {
138         INVEN_PACK = 0,
139         INVEN_NECK,
140         INVEN_WRIS,
141         INVEN_FOOT,
142         INVEN_COUNT
143     };
144     typedef enum e_inventory inventory_t;
145 
146 /// What gender a character can be spawned with
147     enum e_chr_gender
148     {
149         GENDER_FEMALE = 0,
150         GENDER_MALE,
151         GENDER_OTHER,
152         GENDER_RANDOM,
153         GENDER_COUNT
154     };
155 
156 #define ULTRABLUDY           2          ///< This makes any damage draw blud
157 
158 //Damage shifts
159 #define DAMAGEINVICTUS      (1 << 5)                      ///< 00x00000 Invictus to this type of damage
160 #define DAMAGEMANA          (1 << 4)                      ///< 000x0000 Deals damage to mana
161 #define DAMAGECHARGE        (1 << 3)                       ///< 0000x000 Converts damage to mana
162 #define DAMAGEINVERT        (1 << 2)                       ///< 00000x00 Makes damage heal
163 #define DAMAGESHIFT         3                       ///< 000000xx Resistance ( 1 is common )
164 
165 #define GET_DAMAGE_RESIST(BITS) ( (BITS) & DAMAGESHIFT )
166 
167 //--------------------------------------------------------------------------------------------
168 //--------------------------------------------------------------------------------------------
169 
170 /// The character statistic data in the form used in data.txt
171     struct s_cap_stat
172     {
173         FRange val;
174         FRange perlevel;
175     };
176     typedef struct s_cap_stat cap_stat_t;
177 
178 //--------------------------------------------------------------------------------------------
179 
180 /// The character profile data, or cap
181 /// The internal representation of the information in data.txt
182     struct s_cap
183     {
184         EGO_PROFILE_STUFF
185 
186         // naming
187         char         classname[MAXCAPNAMESIZE];            ///< Class name
188 
189         // skins
190         char         skinname[MAX_SKIN][MAXCAPNAMESIZE];   ///< Skin name
191         Uint16       skincost[MAX_SKIN];                   ///< Store prices
192         float        maxaccel[MAX_SKIN];                   ///< Acceleration for each skin
193         Uint8        skindressy;                           ///< Bits to tell whether the skins are "dressy"
194 
195         // overrides
196         int          skin_override;                  ///< -1 or 0-3.. For import
197         Uint8        level_override;                 ///< 0 for normal
198         int          state_override;                 ///< 0 for normal
199         int          content_override;               ///< 0 for normal
200 
201         IDSZ         idsz[IDSZ_COUNT];              ///< ID strings
202 
203         // inventory
204         Uint8        ammomax;                       ///< Ammo stuff
205         Uint8        ammo;
206         Sint16       money;                         ///< Money
207 
208         // characer stats
209         Uint8        gender;                        ///< Gender
210 
211         // life
212         cap_stat_t   life_stat;                     ///< Life statistics
213         UFP8_T       life_return;                    ///< Life regeneration
214         UFP8_T       life_heal;
215         UFP8_T       life_spawn;                     ///< Life left from last module
216 
217         // mana
218         cap_stat_t   mana_stat;                     ///< Mana statistics
219         cap_stat_t   manareturn_stat;               ///< Mana regeneration statistics
220         cap_stat_t   manaflow_stat;                 ///< Mana channeling
221         Uint16       mana_spawn;                      ///< Life left from last module
222 
223         cap_stat_t   strength_stat;                 ///< Strength
224         cap_stat_t   wisdom_stat;                   ///< Wisdom
225         cap_stat_t   intelligence_stat;             ///< Intlligence
226         cap_stat_t   dexterity_stat;                ///< Dexterity
227 
228         // physics
229         Uint8        weight;                        ///< Weight
230         float        dampen;                        ///< Bounciness
231         float        bumpdampen;                    ///< Mass
232 
233         float        size;                          ///< Scale of model
234         float        size_perlevel;                  ///< Scale increases
235         Uint32       shadow_size;                    ///< Shadow size
236         Uint32       bump_size;                     ///< Bounding octagon
237         bool_t       bump_override_size;            ///< let bump_size override the measured object size
238         Uint32       bump_sizebig;                  ///< For octagonal bumpers
239         bool_t       bump_override_sizebig;         ///< let bump_sizebig override the measured object size
240         Uint32       bump_height;                   ///< the height of the object
241         bool_t       bump_override_height;          ///< let bump_height overrride the measured height of the object
242         Uint8        stoppedby;                     ///< Collision Mask
243 
244         // movement
245         float        jump;                          ///< Jump power
246         Uint8        jumpnumber;                    ///< Number of jumps ( Ninja )
247         float        anim_speed_sneak;              ///< Sneak threshold
248         float        anim_speed_walk;               ///< Walk threshold
249         float        anim_speed_run;                ///< Run threshold
250         Uint8        flyheight;                     ///< Fly height
251         bool_t       waterwalk;                     ///< Walk on water?
252 
253         // status graphics
254         Uint8        lifecolor;                     ///< Life bar color
255         Uint8        manacolor;                     ///< Mana bar color
256         bool_t       draw_icon;                     ///< Draw icon
257 
258         // model graphics
259         Uint8        flashand;                      ///< Flashing rate
260         Uint8        alpha;                         ///< Transparency
261         Uint8        light;                         ///< Light blending
262         bool_t       transferblend;                 ///< Transfer blending to rider/weapons
263         Uint8        sheen;                         ///< How shiny it is ( 0-15 )
264         bool_t       enviro;                        ///< Phong map this baby?
265         SFP8_T       uoffvel;                       ///< "horizontal" texture movement rate
266         SFP8_T       voffvel;                       ///< "vertical" texture movement rate
267         bool_t       uniformlit;                    ///< Bad lighting?
268         bool_t       reflect;                       ///< Draw the reflection
269         bool_t       alwaysdraw;                    ///< Always render
270         bool_t       forceshadow;                   ///< Draw a shadow?
271         bool_t       ripple;                        ///< Spawn ripples?
272         bool_t       dont_cull_backfaces;           ///< Force the drawing of backfaces?
273         bool_t       skin_has_transparency;         ///< The skin has transparent areas
274 
275         // attack blocking info
276         Uint16       iframefacing;                  ///< Invincibility frame
277         Uint16       iframeangle;
278         Uint16       nframefacing;                  ///< Normal frame
279         Uint16       nframeangle;
280 
281         // defense
282         bool_t       resistbumpspawn;                        ///< Don't catch fire
283         Uint8        defense[MAX_SKIN];                      ///< Defense for each skin
284         Uint8        damage_modifier[DAMAGE_COUNT][MAX_SKIN];
285 
286         // xp
287         Uint32       experience_forlevel[MAXLEVEL];  ///< Experience needed for next level
288         FRange       experience;                     ///< Starting experience
289         Uint16       experience_worth;               ///< Amount given to killer/user
290         float        experience_exchange;            ///< Adds to worth
291         float        experience_rate[XP_COUNT];
292 
293         // sound
294         Sint8        sound_index[SOUND_COUNT];       ///< a map for soundX.wav to sound types
295 
296         // flags
297         bool_t       isequipment;                    ///< Behave in silly ways
298         bool_t       isitem;                         ///< Is it an item?
299         bool_t       ismount;                        ///< Can you ride it?
300         bool_t       isstackable;                    ///< Is it arrowlike?
301         bool_t       invictus;                       ///< Is it invincible?
302         bool_t       platform;                       ///< Can be stood on?
303         bool_t       canuseplatforms;                ///< Can use platforms?
304         bool_t       cangrabmoney;                   ///< Collect money?
305         bool_t       canopenstuff;                   ///< Open chests/doors?
306         bool_t       canbedazed;                     ///< Can it be dazed?
307         bool_t       canbegrogged;                   ///< Can it be grogged?
308         bool_t       istoobig;                       ///< Can't be put in pack
309         bool_t       isranged;                       ///< Flag for ranged weapon
310         bool_t       nameknown;                      ///< Is the class name known?
311         bool_t       usageknown;                     ///< Is its usage known
312         bool_t       cancarrytonextmodule;           ///< Take it with you?
313         Uint8        damagetarget_damagetype;               ///< For AI DamageTarget
314         bool_t       slotvalid[SLOT_COUNT];          ///< Left/Right hands valid
315         bool_t       ridercanattack;                 ///< Rider attack?
316         Uint8        kursechance;                    ///< Chance of being kursed
317         Sint8        hidestate;                      ///< Don't draw when...
318         Sint8        isvaluable;                     ///< Force to be valuable
319         int          spelleffect_type;               ///< is the object that a spellbook generates
320 
321         // item usage
322         bool_t       needskillidtouse;               ///< Check IDSZ first?
323         Uint8        weaponaction;                   ///< Animation needed to swing
324         Sint16       manacost;                       ///< How much mana to use this object?
325         Uint8        attack_attached;                ///< Do we have attack particles?
326         int          attack_lpip;                    ///< What kind of attack particles?
327         bool_t       attack_fast;                    ///< Ignores the default reload time?
328 
329         float        str_bonus;                      ///< Strength     damage factor
330         float        wis_bonus;                      ///< Wisdom       damage factor
331         float        int_bonus;                      ///< Intelligence damage factor
332         float        dex_bonus;                      ///< dexterity    damage factor
333 
334         // special particle effects
335         Uint8        attachedprt_amount;              ///< Number of sticky particles
336         Uint8        attachedprt_reaffirm_damagetype; ///< Re-attach sticky particles? Relight that torch...
337         int          attachedprt_lpip;                ///< Which kind of sticky particle
338 
339         Uint8        gopoofprt_amount;                ///< Amount of poof particles
340         Sint16       gopoofprt_facingadd;             ///< Angular spread of poof particles
341         int          gopoofprt_lpip;                  ///< Which poof particle
342 
343         Uint8        blud_valid;                      ///< Has blud? ( yuck )
344         int          blud_lpip;                       ///< What kind of blud?
345 
346         // skill system
347         IDSZ_node_t  skills[MAX_IDSZ_MAP_SIZE];
348         int          see_invisible_level;             ///< Can it see invisible?
349 
350         // random stuff
351         bool_t       stickybutt;                    ///< Stick to the ground?
352     };
353 
354     typedef struct s_cap cap_t;
355 
356 //--------------------------------------------------------------------------------------------
357 //--------------------------------------------------------------------------------------------
358     cap_t * load_one_cap_file_vfs( const char * tmploadname, cap_t * pcap );
359     bool_t  save_one_cap_file_vfs( const char * szSaveName, const char * szTemplateFile, cap_t * pcap );
360 
361     cap_t * cap_init( cap_t * pcap );
362 
363 //--------------------------------------------------------------------------------------------
364 //--------------------------------------------------------------------------------------------
365 
366 #if defined(__cplusplus)
367 }
368 #endif
369 
370 //--------------------------------------------------------------------------------------------
371 //--------------------------------------------------------------------------------------------
372 
373 #define _cap_file_h