-
Notifications
You must be signed in to change notification settings - Fork 1
/
thinker.h
170 lines (140 loc) · 3.51 KB
/
thinker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef __THINKER_H__
#define __THINKER_H__
#ifndef MAXANIMFRAMES
# define MAXANIMFRAMES 32
#endif
#if !defined(__GBOOL__) || !defined(__UINT__)
# include "common.h"
#endif
// should match tags in pathfind.h
typedef enum {
TP_NONE,
TP_START,
TP_GOAL,
TP_BOTH,
TP_SQUARE,
TP_PATH_SQUARES,
TP_PATH_TIME,
TP_PATH_SQUARES_AND_TIME,
TP_PATH_NONE
} thinkerpathtype_t;
typedef enum {
TT_NONE,
TT_REDGHOST,
TT_YELLOWGHOST,
TT_CYANGHOST,
TT_PINKGHOST,
TT_CHERIES,
TT_PEACHES,
TT_EYES,
TOTAL_THINKER_TYPES
} thinkertype_t;
typedef enum {
AT_LEFT,
AT_RIGHT,
AT_UP,
AT_DOWN,
AT_LEFTCHASED,
AT_RIGHTCHASED,
AT_UPCHASED,
AT_DOWNCHASED,
AT_LEFTBLINK,
AT_RIGHTBLINK,
AT_UPBLINK,
AT_DOWNBLINK,
TOTAL_GHOST_ANIMATIONS
} ghostanimations_t;
#include "image.h"
// one for each type of animation
// ie, for ghosts chasing & being chased & up, down, left & right versions
typedef struct animation_s {
char *name;
// enemy mode connected to, if any
int mode;
int maxframes;
int frame;
int lastframe;
int nextframe;
int tpframe; // ticks per frame
int mspframe; // milli-seconds per frame (use one or the other)
int tic;
gbool needdraw;
image_t *frames[MAXANIMFRAMES];
} animation_t;
#define __animation_default { "", -1, 1, 0, 0, 0, 6, 0, gfalse }
// should match square pool size in pathfind.h
#ifndef SQUAREPOOLSIZE
# define SQUAREPOOLSIZE 320
#endif
typedef struct thinkerpath_s {
// path length held
int length;
// time generated
int msecGenerated;
// max size this struct holds
int maxSize;
// toggles whether to recompute by time or by number
// of squares traveled.
int pathType;
//
int path[SQUAREPOOLSIZE][2];
// how long until re-compute
int msecTilRegen;
int nSqrTilRegen;
// current index into path[] that thinker is using
int currentIndex;
// first square (usually 1)
int startIndex;
// if set, force a regen
gbool forceRegen;
// id tag
int tag[SQUAREPOOLSIZE];
// square index into path. 0, 1, 2, 3
int index[SQUAREPOOLSIZE];
// turn off to not gen a path at all
gbool usingPath;
//
void *owner;
// tracking coordinates
point2_t sq;
vec2_t pix;
} thinkerpath_t;
typedef struct thinker_s {
// square thinker is on
point2_t sq;
// pix offset in the square
vec2_t pix;
// move amount
vec2_t ma;
thinkertype_t type;
int hitpoints;
void (*think) (void *);
uint dirmoving;
int spaceout;
int searchmode;
uint maxanim;
uint currentanim;
animation_t *anims;
struct thinker_s *next;
struct thinker_s *prev;
int id;
gbool eaten;
int eaten_timer;
gbool chased;
gbool dead;
gbool startChasedMode;
vec2_t spawn;
vec2_t respawn;
vec2_t respawnpix;
int chasedQuad;
void *owner;
thinkerpath_t path;
} thinker_t;
#define __thinker_default {{-1,-1}, {-1,-1},{0,0}, TT_NONE, 1, NULL, \
DIR_NONE, 600, 0, 1, 0, NULL, NULL, NULL, \
-1, gfalse, 0, gfalse, gfalse, gfalse, \
{-1,-1}, {-1,-1}, {0,0}, -1, NULL }
void T_EatGhost (thinker_t *tp);
void T_InitThinkerPath (thinker_t *);
gbool T_SpawnEyes (int x, int y, int gx, int gy);
#endif /* __THINKER_H__ */