Update oddball6x8 font.
[runemen.git] / src / rune.h
blob64da7bb7c5550d5cec6dc00e4e279b470c8bd50a
1 #ifndef _RUNE_H
2 #define _RUNE_H
4 #include <SDL.h>
5 #include "visual.h"
7 #define MAX_FACTIONS 8
9 #define MAX_UNITS 512
10 #define MAX_HOUSES 128
11 #define MAX_FLAGS 64 /* (per faction) */
13 #define MAX_POOLS MAX_UNITS
15 #define TILE_W 16
16 #define TILE_H 16
18 #define MAX_ANIM 6
19 #define ANIM_IDLE 0
20 #define ANIM_WALK 1
21 #define ANIM_CARRY 2
22 #define ANIM_HIT 3
23 #define ANIM_DEATH 4
24 #define ANIM_FACE 5
26 #define ANIM_BUILDING 0
27 #define ANIM_BUILT 1
28 #define ANIM_WORK 3
29 #define ANIM_DAMAGE 4
30 #define ANIM_ICON 5
32 #define UAXIS_TYPE 0
33 #define UAXIS_MODE 1
34 #define UAXIS_FRAME 2
35 #define UAXIS_FACEFRAME 3
37 #define HAXIS_TYPE 0
38 #define HAXIS_STATE 1
39 #define HAXIS_FRAME 2
41 #define HACT_NONE 0
42 #define HACT_UNLOAD_GOLD 0x0001
43 #define HACT_UNLOAD_ORE 0x0002
44 #define HACT_XXX1 0x0004
45 #define HACT_XXX2 0x0008
46 #define HACT_XXX3 0x0010
47 #define HACT_XXX5 0x0020
48 #define HACT_XXX6 0x0040
49 #define HACT_XXX7 0x0080
51 //#define DEBUG_PATHFIND
53 /* How much "energy" various unit actions cost */
54 #define ECOST_SLIDE 5
55 #define ECOST_VISIT 10
56 #define ECOST_WALK 10
58 typedef enum MoveMethod {
59 Walk, Ride, Fly, Trample, Skyride,
60 } MoveMethod;
61 typedef enum AttackMethod {
62 Melee, Ranged, Cast, Talk
63 } AttackMethod;
64 typedef enum SpellType {
65 None, Heal, Enchant, Descent, Burry, Summon, Protect, Earthskin
66 } SpellType;
67 typedef enum PerceptionMethod {
68 Sight, Smell
69 } PerceptionMethod;
72 #define LEN_UNIT_ID 32
73 #define LEN_UNIT_TITLE 80
74 #define LEN_UNIT_NAME 80
76 #define LEN_HOUSE_ID 32
77 #define LEN_HOUSE_TITLE 80
78 #define LEN_HOUSE_NAME 80
80 #define LEN_FACTION_TITLE 80
82 #define MAX_UNITTABS 6
83 #define MAX_HOUSETABS 6
85 #define MAX_SCENT 8
86 #define SCENT_HUMAN 0
87 #define SCENT_ANIMAL 1
88 #define SCENT_MAGIC 2
90 #define MM_MAX 4
91 #define MM_WALK 0
92 #define MM_RIDE 1
93 #define MM_FLY 2
94 #define MM_TRAMPLE 3
96 #define AM_MAX 4
97 #define AM_MELEE 0
98 #define AM_RANGED 1
99 #define AM_CAST 2
100 #define AM_TALK 3
102 #define SPELL_MAX 10
103 #define SPELL_MAGICMISSILE 0
104 #define SPELL_HEAL 1
105 #define SPELL_ENCHANT 2
106 #define SPELL_DESCENT 3
107 #define SPELL_BURRY 4
109 #define MAX_SKILLS 7
110 #define SKILL_BUILD 0
111 #define SKILL_REPAIR 1
112 #define SKILL_MELEE 2
113 #define SKILL_RANGED 3
114 #define SKILL_RIDE 4
115 #define SKILL_MAGERY 5
116 #define SKILL_TRADE 6
118 #define MAX_STAT 6
119 #define S_STR 0
120 #define S_DEX 1
121 #define S_CON 2
122 #define S_INT 3
123 #define S_MET 4
124 #define S_CHR 5
125 #define MAX_PARAMS (MAX_STAT + MAX_STAT)
127 #define HMENU_ITEMS 10
129 #define MAX_RESOURCES 7
130 #define RES_GOLD 0
131 #define RES_ORE 1
132 #define RES_FORCIBLE 2
133 #define RES_SWORD 3
134 #define RES_BOW 4
135 #define RES_HORSE 5
136 #define RES_GRAAK 6
138 typedef struct house_p house_p;
139 typedef struct house_t house_t;
140 typedef struct unit_t unit_t;
141 typedef struct unit_p unit_p;
143 typedef struct faction_t faction_t;
144 typedef struct flag_t flag_t;
146 typedef struct pool_t pool_t;
148 struct flag_t {
150 Uint8 faction;
151 Uint8 type;
153 Uint16 reward;
155 Uint8 x;
156 Uint8 y;
157 house_t *house;
158 unit_t *unit;
159 Uint8 w;
160 Uint8 h;
162 unit_t *units[8];
163 int num_units;
166 struct faction_t {
167 char title[LEN_FACTION_TITLE];
168 SDL_Color color;
170 Uint32 gold;
171 Uint32 ore;
173 Uint8 gold_tax;
174 Uint8 ore_tax;
176 flag_t flags[MAX_FLAGS];
177 int num_flags;
180 struct unit_p {
181 char id[LEN_UNIT_ID];
182 char title[LEN_UNIT_TITLE];
183 SDL_Color color;
185 Sint8 base_stat[MAX_STAT];
187 AttackMethod attack;
188 MoveMethod move;
189 SpellType spell;
190 PerceptionMethod perc;
192 Uint8 base_scent[MAX_SCENT];
194 Uint32 flags;
195 Uint8 modus;
197 Uint8 w;
198 Uint8 h;
200 animation_t body;
201 animation_t face;
204 struct house_p {
205 char id[LEN_HOUSE_ID];
206 char title[LEN_HOUSE_TITLE];
208 Uint32 gold_cost;
209 Uint32 ore_cost;
211 Uint8 w;
212 Uint8 h;
214 /* Visuals */
215 Uint8 icon;
216 SDL_Rect unbuilt;
217 animation_t body;
220 struct house_t {
221 Uint8 tile;
222 char title[LEN_HOUSE_TITLE];
223 Uint32 gold_cost;
224 Uint8 w;
225 Uint8 h;
227 Uint8 x;
228 Uint8 y;
230 Uint8 faction;
231 Sint8 flag_id[MAX_FACTIONS]; /* Back-ref to assigned flags */
233 Uint8 capacity;
234 Uint8 visitors;
236 Uint16 hp;
237 Uint16 max_hp;
239 Uint8 built; /* Construction finished */
241 /* Visuals */
242 Sint8 framecnt; /* Frame counter */
243 Uint8 frame; /* Current animation frame */
244 Uint8 *axis_refs[MAX_AAXIS]; /* reservered */
247 struct unit_t {
248 Uint8 tile;
250 Sint8 base_stat[MAX_STAT];
251 Sint8 rune_stat[MAX_STAT];
252 Sint8 calc_stat[MAX_STAT];
254 Uint8 stat_bid[MAX_STAT];
256 Uint8 base_skill[MAX_SKILLS];
257 Uint8 calc_skill[MAX_SKILLS];
259 char name[LEN_UNIT_NAME];
261 Uint16 gold;
262 Uint16 fame;
263 Sint16 happiness;
265 Uint16 dmg;
266 Uint16 max_hp;
267 Uint8 level;
268 Uint8 exp;
270 Uint16 progress;
271 Uint16 carry_gold;
272 Uint16 carry_ore;
274 house_t *visiting; /* link to container house (i.e. "gold mine") */
276 unit_t *inside; /* link to container unit (i.e. "transport ship") */
277 Uint8 capacity; /* number of child units this can hold */
278 Uint8 passengers; /* number of child units currently holding */
280 Uint8 x;
281 Uint8 y;
283 Uint8 tx;
284 Uint8 ty;
286 Sint8 ox;
287 Sint8 oy;
289 Uint32 energy;
291 Uint8 pin;
292 Uint8 mode;
293 Uint8 baloon;
295 Sint8 faction; /* Faction id */
296 Sint8 flag_id[MAX_FACTIONS];
298 Uint32 color;
300 Uint8 top_desire; /* AI-related */
301 Uint8 top_method;
302 Uint8 modus;
303 Uint8 strategy;
304 Uint8 tactic;
305 Uint8 step;
307 Uint8 block; /* Useless variable to mark during iteration to avoid endless recursion */
309 unit_t *link;
310 Uint8 ref_count[MAX_STAT];
311 Uint16 link_id;
312 Uint8 link_stat;
314 pool_t *pool;
315 Uint8 ref_counts;
317 int path[16];
318 Uint8 target_type;
319 Uint16 target_id;
320 #ifdef DEBUG_PATHFIND
321 long d[256000]; /* d[i] is the length of the shortest path between the source (s) and node i */
322 int prev[256000]; /* prev[i] is the node that comes right before i in the shortest path from the source to i*/
323 int tar_x;
324 int tar_y;
325 #endif
327 /* Visuals */
328 Uint8 frame;
329 Sint8 framecnt;
330 Uint8 faceframe;
331 Uint8 *axis_refs[MAX_AAXIS]; /* reservered */
333 /* Need refresh */
334 struct {
335 int stats; /* Need to update stats due to magic linking */
336 int skills; /* Need to update skills due to stats change/level up/equipment change */
337 int target; /* Need to find new target */
338 int path; /* Need to find new path to target */
339 } refresh;
342 struct pool_t {
343 unit_t *tail;
344 unit_t *head;
345 Uint8 stat;
346 Uint16 pool;
349 #endif