Add unit and house tabs, flag button.
[runemen.git] / src / rune.h
blob8b569b8ef45e984f88e14e90d54e5216965bcad4
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 6
110 #define MAX_STAT 6
111 #define S_STR 0
112 #define S_DEX 1
113 #define S_CON 2
114 #define S_INT 3
115 #define S_MET 4
116 #define S_CHR 5
117 #define MAX_PARAMS (MAX_STAT + MAX_STAT)
119 #define HMENU_ITEMS 10
121 #define MAX_RESOURCES 7
122 #define RES_GOLD 0
123 #define RES_ORE 1
124 #define RES_FORCIBLE 2
125 #define RES_SWORD 3
126 #define RES_BOW 4
127 #define RES_HORSE 5
128 #define RES_GRAAK 6
130 typedef struct house_p house_p;
131 typedef struct house_t house_t;
132 typedef struct unit_t unit_t;
133 typedef struct unit_p unit_p;
135 typedef struct faction_t faction_t;
136 typedef struct flag_t flag_t;
138 typedef struct pool_t pool_t;
140 struct flag_t {
142 Uint8 faction;
143 Uint8 type;
145 Uint16 reward;
147 Uint8 x;
148 Uint8 y;
149 house_t *house;
150 unit_t *unit;
151 Uint8 w;
152 Uint8 h;
154 unit_t *units[8];
155 int num_units;
158 struct faction_t {
159 char title[LEN_FACTION_TITLE];
160 SDL_Color color;
162 Uint32 gold;
163 Uint32 ore;
165 Uint8 gold_tax;
166 Uint8 ore_tax;
168 flag_t flags[MAX_FLAGS];
169 int num_flags;
172 struct unit_p {
173 char id[LEN_UNIT_ID];
174 char title[LEN_UNIT_TITLE];
175 SDL_Color color;
177 Sint8 base_stat[MAX_STAT];
179 AttackMethod attack;
180 MoveMethod move;
181 SpellType spell;
182 PerceptionMethod perc;
184 Uint8 base_scent[MAX_SCENT];
186 Uint32 flags;
187 Uint8 modus;
189 Uint8 w;
190 Uint8 h;
192 animation_t body;
193 animation_t face;
196 struct house_p {
197 char id[LEN_HOUSE_ID];
198 char title[LEN_HOUSE_TITLE];
200 Uint32 gold_cost;
201 Uint32 ore_cost;
203 Uint8 w;
204 Uint8 h;
206 /* Visuals */
207 Uint8 icon;
208 SDL_Rect unbuilt;
209 animation_t body;
212 struct house_t {
213 Uint8 tile;
214 char title[LEN_HOUSE_TITLE];
215 Uint32 gold_cost;
216 Uint8 w;
217 Uint8 h;
219 Uint8 x;
220 Uint8 y;
222 Uint8 faction;
223 Sint8 flag_id[MAX_FACTIONS]; /* Back-ref to assigned flags */
225 Uint8 capacity;
226 Uint8 visitors;
228 Uint16 hp;
229 Uint16 max_hp;
231 Uint8 built; /* Construction finished */
233 /* Visuals */
234 Sint8 framecnt; /* Frame counter */
235 Uint8 frame; /* Current animation frame */
236 Uint8 *axis_refs[MAX_AAXIS]; /* reservered */
239 struct unit_t {
240 Uint8 tile;
242 Sint8 base_stat[MAX_STAT];
243 Sint8 rune_stat[MAX_STAT];
244 Sint8 calc_stat[MAX_STAT];
246 Uint8 stat_bid[MAX_STAT];
248 char name[LEN_UNIT_NAME];
250 Uint16 gold;
251 Uint16 fame;
252 Sint16 happiness;
254 Uint16 dmg;
255 Uint16 max_hp;
256 Uint8 level;
257 Uint8 exp;
259 Uint16 progress;
260 Uint16 carry_gold;
261 Uint16 carry_ore;
263 house_t *visiting; /* link to container house (i.e. "gold mine") */
265 unit_t *inside; /* link to container unit (i.e. "transport ship") */
266 Uint8 capacity; /* number of child units this can hold */
268 Uint8 x;
269 Uint8 y;
271 Uint8 tx;
272 Uint8 ty;
274 Sint8 ox;
275 Sint8 oy;
277 Uint32 energy;
279 Uint8 pin;
280 Uint8 mode;
281 Uint8 baloon;
283 Sint8 faction; /* Faction id */
284 Sint8 flag_id[MAX_FACTIONS];
286 Uint32 color;
288 Uint8 top_desire; /* AI-related */
289 Uint8 top_method;
290 Uint8 modus;
291 Uint8 strategy;
292 Uint8 tactic;
293 Uint8 step;
295 Uint8 block; /* Useless variable to mark during iteration to avoid endless recursion */
297 unit_t *link;
298 Uint8 ref_count[MAX_STAT];
299 Uint16 link_id;
300 Uint8 link_stat;
302 pool_t *pool;
303 Uint8 ref_counts;
305 int path[16];
306 Uint8 target_type;
307 Uint16 target_id;
308 #ifdef DEBUG_PATHFIND
309 long d[256000]; /* d[i] is the length of the shortest path between the source (s) and node i */
310 int prev[256000]; /* prev[i] is the node that comes right before i in the shortest path from the source to i*/
311 int tar_x;
312 int tar_y;
313 #endif
315 /* Visuals */
316 Uint8 frame;
317 Sint8 framecnt;
318 Uint8 faceframe;
319 Uint8 *axis_refs[MAX_AAXIS]; /* reservered */
322 struct pool_t {
323 unit_t *tail;
324 unit_t *head;
325 Uint8 stat;
326 Uint16 pool;
329 #endif