-
Notifications
You must be signed in to change notification settings - Fork 2
/
flipper.qc
369 lines (321 loc) · 8.48 KB
/
flipper.qc
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#ifdef SINGLE_PLAYER
#include "m_flipper.h"
static int sound_chomp;
static int sound_attack;
static int sound_pain1;
static int sound_pain2;
static int sound_death;
static int sound_idle;
static int sound_search;
static int sound_sight;
static mframe_t flipper_frames_stand [] = {
{ ai_stand }
};
static var mmove_t flipper_move_stand = { FRAME_flphor01, FRAME_flphor01 };
static void flipper_stand(entity self)
{
self.monsterinfo.currentmove = &flipper_move_stand;
}
const float FLIPPER_RUN_SPEED = 24f;
static mframe_t flipper_frames_run [] = {
{ ai_run, FLIPPER_RUN_SPEED }, // 6
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED }, // 10
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED }, // 20
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED },
{ ai_run, FLIPPER_RUN_SPEED } // 29
};
static var mmove_t flipper_move_run_loop = { FRAME_flpver06, FRAME_flpver29 };
static void flipper_run_loop(entity self)
{
self.monsterinfo.currentmove = &flipper_move_run_loop;
}
static mframe_t flipper_frames_run_start [] = {
{ ai_run, 8 },
{ ai_run, 8 },
{ ai_run, 8 },
{ ai_run, 8 },
{ ai_run, 8 },
{ ai_run, 8 }
};
static var mmove_t flipper_move_run_start = { FRAME_flpver01, FRAME_flpver06, flipper_run_loop };
static void flipper_run(entity self)
{
self.monsterinfo.currentmove = &flipper_move_run_start;
}
/* Standard Swimming */
static mframe_t flipper_frames_walk [] = {
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 },
{ ai_walk, 4 }
};
static var mmove_t flipper_move_walk = { FRAME_flphor01, FRAME_flphor24 };
static void flipper_walk(entity self)
{
self.monsterinfo.currentmove = &flipper_move_walk;
}
static mframe_t flipper_frames_start_run [] = {
{ ai_run, 8 },
{ ai_run, 8 },
{ ai_run, 8 },
{ ai_run, 8 },
{ ai_run, 8, flipper_run }
};
static var mmove_t flipper_move_start_run = { FRAME_flphor01, FRAME_flphor05 };
static void flipper_start_run(entity self)
{
self.monsterinfo.currentmove = &flipper_move_start_run;
}
static mframe_t flipper_frames_pain2 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t flipper_move_pain2 = { FRAME_flppn101, FRAME_flppn105, flipper_run };
static mframe_t flipper_frames_pain1 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t flipper_move_pain1 = { FRAME_flppn201, FRAME_flppn205, flipper_run };
static void flipper_bite(entity self)
{
static const vector aim = [ MELEE_DISTANCE, 0, 0 ];
fire_hit(self, aim, 5, 0);
}
static void flipper_preattack(entity self)
{
gi.sound(self, CHAN_WEAPON, sound_chomp, 1, ATTN_NORM, 0);
}
static mframe_t flipper_frames_attack [] = {
{ ai_charge, 0, flipper_preattack },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge, 0, flipper_bite },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge, 0, flipper_bite },
{ ai_charge }
};
static var mmove_t flipper_move_attack = { FRAME_flpbit01, FRAME_flpbit20, flipper_run };
static void flipper_melee(entity self)
{
self.monsterinfo.currentmove = &flipper_move_attack;
}
static void flipper_pain(entity self, entity other, float kick, int damage)
{
int n;
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
if (level.framenum < self.pain_debounce_framenum)
return;
self.pain_debounce_framenum = level.framenum + 3 * BASE_FRAMERATE;
if (skill.intVal == 3)
return; // no pain anims in nightmare
n = (Q_rand() + 1) % 2;
if (n == 0) {
gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
self.monsterinfo.currentmove = &flipper_move_pain1;
} else {
gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
self.monsterinfo.currentmove = &flipper_move_pain2;
}
}
static void flipper_dead(entity self)
{
self.mins = '-16 -16 -24';
self.maxs = '16 16 -8';
self.movetype = MOVETYPE_TOSS;
self.svflags |= SVF_DEADMONSTER;
self.nextthink = 0;
gi.linkentity(self);
}
static mframe_t flipper_frames_death [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t flipper_move_death = { FRAME_flpdth01, FRAME_flpdth56, flipper_dead };
static void flipper_sight(entity self, entity other)
{
gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
}
static void flipper_die(entity self, entity inflictor, entity attacker, int damage, vector point)
{
int n;
// check for gib
if (self.health <= self.gib_health) {
gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
for (n = 0; n < 2; n++)
ThrowGib(self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
for (n = 0; n < 2; n++)
ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
ThrowHead(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
self.deadflag = DEAD_DEAD;
return;
}
if (self.deadflag == DEAD_DEAD)
return;
// regular death
gi.sound(self, CHAN_VOICE, sound_death, 1, ATTN_NORM, 0);
self.deadflag = DEAD_DEAD;
self.takedamage = true;
self.monsterinfo.currentmove = &flipper_move_death;
}
/*QUAKED monster_flipper (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
*/
API_FUNC static void SP_monster_flipper(entity self)
{
if (deathmatch.intVal) {
G_FreeEdict(self);
return;
}
if (!flipper_move_stand.frame)
{
flipper_move_stand.frame = &flipper_frames_stand;
flipper_move_run_loop.frame = &flipper_frames_run;
flipper_move_run_start.frame = &flipper_frames_run_start;
flipper_move_walk.frame = &flipper_frames_walk;
flipper_move_start_run.frame = &flipper_frames_start_run;
flipper_move_pain2.frame = &flipper_frames_pain2;
flipper_move_pain1.frame = &flipper_frames_pain1;
flipper_move_attack.frame = &flipper_frames_attack;
flipper_move_death.frame = &flipper_frames_death;
}
sound_pain1 = gi.soundindex("flipper/flppain1.wav");
sound_pain2 = gi.soundindex("flipper/flppain2.wav");
sound_death = gi.soundindex("flipper/flpdeth1.wav");
sound_chomp = gi.soundindex("flipper/flpatck1.wav");
sound_attack = gi.soundindex("flipper/flpatck2.wav");
sound_idle = gi.soundindex("flipper/flpidle1.wav");
sound_search = gi.soundindex("flipper/flpsrch1.wav");
sound_sight = gi.soundindex("flipper/flpsght1.wav");
self.movetype = MOVETYPE_STEP;
self.solid = SOLID_BBOX;
self.s.modelindex = gi.modelindex("models/monsters/flipper/tris.md2");
self.mins = '-16 -16 0';
self.maxs = '16 16 32';
self.health = 50;
self.gib_health = -30;
self.mass = 100;
self.pain = flipper_pain;
self.die = flipper_die;
self.monsterinfo.stand = flipper_stand;
self.monsterinfo.walk = flipper_walk;
self.monsterinfo.run = flipper_start_run;
self.monsterinfo.melee = flipper_melee;
self.monsterinfo.sight = flipper_sight;
gi.linkentity(self);
self.monsterinfo.currentmove = &flipper_move_stand;
self.monsterinfo.scale = MODEL_SCALE;
swimmonster_start(self);
}
#endif