completely changed event_queue logic
[h2d.git] / structs.c
blob91ed4557b6c88d613c0c8d69681e98f595bc0445
1 #define defstruct typedef struct
3 defstruct { int x, y; } vec2i;
4 typedef vec2i mcrd; //[m]ap coords
5 typedef vec2i scrd; //[s]creen coords
8 // TODO переставить местами поля
9 defstruct {
10 int see;
11 int morale;
12 int health;
13 int attack; // meele damage
14 int defence;
15 int mvp;
16 char * name;
17 int * ter_mvp; // terrain move cost
18 int * ter_def; // terrain defence bonus
19 int * ter_atk; // terrain attack bonus
20 } unit_type;
24 defstruct {
25 l_node n;
26 unit_type * type;
27 int id;
28 int health;
29 int player;
30 bool can_attack;
31 int mvp;
32 mcrd mcrd;
33 scrd scrd;
34 l_list features[1];
35 } unit;
39 defstruct {
40 int fog; // fog of war. how many units see this tile
41 int cost; // цена полного пути до клетки
42 int type;
43 mcrd parent;
44 unit * unit;
45 } tile;
48 #define FEATURE_RNG 1
49 #define FEATURE_BRSK 2
50 #define FEATURE_INVIS 3
51 #define FEATURE_IGNR 4
52 #define FEATURE_ARMORED 5
53 #define FEATURE_ARMPIERC 6
54 #define FEATURE_NORETURN 7
56 defstruct { int power; } feature_berserk;
57 defstruct { int power, range, ammo; } feature_range;
59 typedef union {
60 feature_range rng; // has ranged attack
61 feature_berserk brsk; // berserk TODO
62 bool invis; // invisible
63 bool ignr; // ignore enemys ZOC
64 bool armored;
65 bool armour_piercing; // ignores armor
66 bool noreturn;
67 } feature_data;
69 defstruct {l_node n; int type; feature_data data;} feature;
72 // map node / path node / used in pathfinding
73 defstruct { l_node n; mcrd crd; } mnode;
76 #define EVENT_MOVE 0
77 #define EVENT_MELEE 1
78 #define EVENT_RANGE 2
80 // byte-count event_move unit-id directon[0..5]
81 // byte-count event_melee attacker-id direction dead
82 // byte-count event_range attacker-id defender-id dead
84 defstruct { l_node n; int * data; } event ;
88 defstruct {
89 tile * map;
90 l_list * st; // stack for filling map
91 l_list * path; // stores path
92 l_list * units; // stores units
93 //l_list * eq; // events queue
94 l_list * event_queue; // events queue
95 int * e; //event data
96 //unit * su;
97 unit * selunit;
98 int mi; // move index... rename!
99 mcrd selhex;
100 int mode;
101 int index; // внутренний индекс события
102 //int i; // внутренний индекс события
103 } world;