]> 4ch.mooo.com Git - 16.git/blob - 16/sod8086/wl_act2.c
undid undid xD
[16.git] / 16 / sod8086 / wl_act2.c
1 // WL_ACT2.C\r
2 \r
3 #include "WL_DEF.H"\r
4 #pragma hdrstop\r
5 \r
6 /*\r
7 =============================================================================\r
8 \r
9                                                  LOCAL CONSTANTS\r
10 \r
11 =============================================================================\r
12 */\r
13 \r
14 #define PROJECTILESIZE  0xc000l\r
15 \r
16 #define BJRUNSPEED      2048\r
17 #define BJJUMPSPEED     680\r
18 \r
19 \r
20 /*\r
21 =============================================================================\r
22 \r
23                                                  GLOBAL VARIABLES\r
24 \r
25 =============================================================================\r
26 */\r
27 \r
28 \r
29 \r
30 /*\r
31 =============================================================================\r
32 \r
33                                                  LOCAL VARIABLES\r
34 \r
35 =============================================================================\r
36 */\r
37 \r
38 \r
39 dirtype dirtable[9] = {northwest,north,northeast,west,nodir,east,\r
40         southwest,south,southeast};\r
41 \r
42 int     starthitpoints[4][NUMENEMIES] =\r
43          //\r
44          // BABY MODE\r
45          //\r
46          {\r
47          {25,   // guards\r
48           50,   // officer\r
49           100,  // SS\r
50           1,    // dogs\r
51           850,  // Hans\r
52           850,  // Schabbs\r
53           200,  // fake hitler\r
54           800,  // mecha hitler\r
55           45,   // mutants\r
56           25,   // ghosts\r
57           25,   // ghosts\r
58           25,   // ghosts\r
59           25,   // ghosts\r
60 \r
61           850,  // Gretel\r
62           850,  // Gift\r
63           850,  // Fat\r
64           5,    // en_spectre,\r
65           1450, // en_angel,\r
66           850,  // en_trans,\r
67           1050, // en_uber,\r
68           950,  // en_will,\r
69           1250  // en_death\r
70           },\r
71          //\r
72          // DON'T HURT ME MODE\r
73          //\r
74          {25,   // guards\r
75           50,   // officer\r
76           100,  // SS\r
77           1,    // dogs\r
78           950,  // Hans\r
79           950,  // Schabbs\r
80           300,  // fake hitler\r
81           950,  // mecha hitler\r
82           55,   // mutants\r
83           25,   // ghosts\r
84           25,   // ghosts\r
85           25,   // ghosts\r
86           25,   // ghosts\r
87 \r
88           950,  // Gretel\r
89           950,  // Gift\r
90           950,  // Fat\r
91           10,   // en_spectre,\r
92           1550, // en_angel,\r
93           950,  // en_trans,\r
94           1150, // en_uber,\r
95           1050, // en_will,\r
96           1350  // en_death\r
97           },\r
98          //\r
99          // BRING 'EM ON MODE\r
100          //\r
101          {25,   // guards\r
102           50,   // officer\r
103           100,  // SS\r
104           1,    // dogs\r
105 \r
106           1050, // Hans\r
107           1550, // Schabbs\r
108           400,  // fake hitler\r
109           1050, // mecha hitler\r
110 \r
111           55,   // mutants\r
112           25,   // ghosts\r
113           25,   // ghosts\r
114           25,   // ghosts\r
115           25,   // ghosts\r
116 \r
117           1050, // Gretel\r
118           1050, // Gift\r
119           1050, // Fat\r
120           15,   // en_spectre,\r
121           1650, // en_angel,\r
122           1050, // en_trans,\r
123           1250, // en_uber,\r
124           1150, // en_will,\r
125           1450  // en_death\r
126           },\r
127          //\r
128          // DEATH INCARNATE MODE\r
129          //\r
130          {25,   // guards\r
131           50,   // officer\r
132           100,  // SS\r
133           1,    // dogs\r
134 \r
135           1200, // Hans\r
136           2400, // Schabbs\r
137           500,  // fake hitler\r
138           1200, // mecha hitler\r
139 \r
140           65,   // mutants\r
141           25,   // ghosts\r
142           25,   // ghosts\r
143           25,   // ghosts\r
144           25,   // ghosts\r
145 \r
146           1200, // Gretel\r
147           1200, // Gift\r
148           1200, // Fat\r
149           25,   // en_spectre,\r
150           2000, // en_angel,\r
151           1200, // en_trans,\r
152           1400, // en_uber,\r
153           1300, // en_will,\r
154           1600  // en_death\r
155           }}\r
156           ;\r
157 \r
158 void    A_StartDeathCam (objtype *ob);\r
159 \r
160 \r
161 void    T_Path (objtype *ob);\r
162 void    T_Shoot (objtype *ob);\r
163 void    T_Bite (objtype *ob);\r
164 void    T_DogChase (objtype *ob);\r
165 void    T_Chase (objtype *ob);\r
166 void    T_Projectile (objtype *ob);\r
167 void    T_Stand (objtype *ob);\r
168 \r
169 void A_DeathScream (objtype *ob);\r
170 \r
171 extern  statetype s_rocket;\r
172 extern  statetype s_smoke1;\r
173 extern  statetype s_smoke2;\r
174 extern  statetype s_smoke3;\r
175 extern  statetype s_smoke4;\r
176 extern  statetype s_boom2;\r
177 extern  statetype s_boom3;\r
178 \r
179 void A_Smoke (objtype *ob);\r
180 \r
181 statetype s_rocket              = {true,SPR_ROCKET_1,3,T_Projectile,A_Smoke,&s_rocket};\r
182 statetype s_smoke1              = {false,SPR_SMOKE_1,3,NULL,NULL,&s_smoke2};\r
183 statetype s_smoke2              = {false,SPR_SMOKE_2,3,NULL,NULL,&s_smoke3};\r
184 statetype s_smoke3              = {false,SPR_SMOKE_3,3,NULL,NULL,&s_smoke4};\r
185 statetype s_smoke4              = {false,SPR_SMOKE_4,3,NULL,NULL,NULL};\r
186 \r
187 statetype s_boom1               = {false,SPR_BOOM_1,6,NULL,NULL,&s_boom2};\r
188 statetype s_boom2               = {false,SPR_BOOM_2,6,NULL,NULL,&s_boom3};\r
189 statetype s_boom3               = {false,SPR_BOOM_3,6,NULL,NULL,NULL};\r
190 \r
191 #ifdef SPEAR\r
192 \r
193 extern  statetype s_hrocket;\r
194 extern  statetype s_hsmoke1;\r
195 extern  statetype s_hsmoke2;\r
196 extern  statetype s_hsmoke3;\r
197 extern  statetype s_hsmoke4;\r
198 extern  statetype s_hboom2;\r
199 extern  statetype s_hboom3;\r
200 \r
201 void A_Smoke (objtype *ob);\r
202 \r
203 statetype s_hrocket             = {true,SPR_HROCKET_1,3,T_Projectile,A_Smoke,&s_hrocket};\r
204 statetype s_hsmoke1             = {false,SPR_HSMOKE_1,3,NULL,NULL,&s_hsmoke2};\r
205 statetype s_hsmoke2             = {false,SPR_HSMOKE_2,3,NULL,NULL,&s_hsmoke3};\r
206 statetype s_hsmoke3             = {false,SPR_HSMOKE_3,3,NULL,NULL,&s_hsmoke4};\r
207 statetype s_hsmoke4             = {false,SPR_HSMOKE_4,3,NULL,NULL,NULL};\r
208 \r
209 statetype s_hboom1              = {false,SPR_HBOOM_1,6,NULL,NULL,&s_hboom2};\r
210 statetype s_hboom2              = {false,SPR_HBOOM_2,6,NULL,NULL,&s_hboom3};\r
211 statetype s_hboom3              = {false,SPR_HBOOM_3,6,NULL,NULL,NULL};\r
212 \r
213 #endif\r
214 \r
215 void    T_Schabb (objtype *ob);\r
216 void    T_SchabbThrow (objtype *ob);\r
217 void    T_Fake (objtype *ob);\r
218 void    T_FakeFire (objtype *ob);\r
219 void    T_Ghosts (objtype *ob);\r
220 \r
221 void A_Slurpie (objtype *ob);\r
222 void A_HitlerMorph (objtype *ob);\r
223 void A_MechaSound (objtype *ob);\r
224 \r
225 /*\r
226 =================\r
227 =\r
228 = A_Smoke\r
229 =\r
230 =================\r
231 */\r
232 \r
233 void A_Smoke (objtype *ob)\r
234 {\r
235         GetNewActor ();\r
236 #ifdef SPEAR\r
237         if (ob->obclass == hrocketobj)\r
238                 new->state = &s_hsmoke1;\r
239         else\r
240 #endif\r
241                 new->state = &s_smoke1;\r
242         new->ticcount = 6;\r
243 \r
244         new->tilex = ob->tilex;\r
245         new->tiley = ob->tiley;\r
246         new->x = ob->x;\r
247         new->y = ob->y;\r
248         new->obclass = inertobj;\r
249         new->active = true;\r
250 \r
251         new->flags = FL_NEVERMARK;\r
252 }\r
253 \r
254 \r
255 /*\r
256 ===================\r
257 =\r
258 = ProjectileTryMove\r
259 =\r
260 = returns true if move ok\r
261 ===================\r
262 */\r
263 \r
264 #define PROJSIZE        0x2000\r
265 \r
266 boolean ProjectileTryMove (objtype *ob)\r
267 {\r
268         int                     xl,yl,xh,yh,x,y;\r
269         objtype         *check;\r
270         long            deltax,deltay;\r
271 \r
272         xl = (ob->x-PROJSIZE) >>TILESHIFT;\r
273         yl = (ob->y-PROJSIZE) >>TILESHIFT;\r
274 \r
275         xh = (ob->x+PROJSIZE) >>TILESHIFT;\r
276         yh = (ob->y+PROJSIZE) >>TILESHIFT;\r
277 \r
278 //\r
279 // check for solid walls\r
280 //\r
281         for (y=yl;y<=yh;y++)\r
282                 for (x=xl;x<=xh;x++)\r
283                 {\r
284                         check = actorat[x][y];\r
285                         if (check && check<objlist)\r
286                                 return false;\r
287                 }\r
288 \r
289         return true;\r
290 }\r
291 \r
292 \r
293 \r
294 /*\r
295 =================\r
296 =\r
297 = T_Projectile\r
298 =\r
299 =================\r
300 */\r
301 \r
302 void T_Projectile (objtype *ob)\r
303 {\r
304         long    deltax,deltay;\r
305         int             damage;\r
306         long    speed;\r
307 \r
308         speed = (long)ob->speed*tics;\r
309 \r
310         deltax = FixedByFrac(speed,costable[ob->angle]);\r
311         deltay = -FixedByFrac(speed,sintable[ob->angle]);\r
312 \r
313         if (deltax>0x10000l)\r
314                 deltax = 0x10000l;\r
315         if (deltay>0x10000l)\r
316                 deltay = 0x10000l;\r
317 \r
318         ob->x += deltax;\r
319         ob->y += deltay;\r
320 \r
321         deltax = LABS(ob->x - player->x);\r
322         deltay = LABS(ob->y - player->y);\r
323 \r
324         if (!ProjectileTryMove (ob))\r
325         {\r
326                 if (ob->obclass == rocketobj)\r
327                 {\r
328                         PlaySoundLocActor(MISSILEHITSND,ob);\r
329                         ob->state = &s_boom1;\r
330                 }\r
331 #ifdef SPEAR\r
332                 else if (ob->obclass == hrocketobj)\r
333                 {\r
334                         PlaySoundLocActor(MISSILEHITSND,ob);\r
335                         ob->state = &s_hboom1;\r
336                 }\r
337 #endif\r
338                 else\r
339                         ob->state = NULL;               // mark for removal\r
340 \r
341                 return;\r
342         }\r
343 \r
344         if (deltax < PROJECTILESIZE && deltay < PROJECTILESIZE)\r
345         {       // hit the player\r
346                 switch (ob->obclass)\r
347                 {\r
348                 case needleobj:\r
349                         damage = (US_RndT() >>3) + 20;\r
350                         break;\r
351                 case rocketobj:\r
352                 case hrocketobj:\r
353                 case sparkobj:\r
354                         damage = (US_RndT() >>3) + 30;\r
355                         break;\r
356                 case fireobj:\r
357                         damage = (US_RndT() >>3);\r
358                         break;\r
359                 }\r
360 \r
361                 TakeDamage (damage,ob);\r
362                 ob->state = NULL;               // mark for removal\r
363                 return;\r
364         }\r
365 \r
366         ob->tilex = ob->x >> TILESHIFT;\r
367         ob->tiley = ob->y >> TILESHIFT;\r
368 \r
369 }\r
370 \r
371 \r
372 \r
373 \r
374 /*\r
375 =============================================================================\r
376 \r
377                                                         GUARD\r
378 \r
379 =============================================================================\r
380 */\r
381 \r
382 //\r
383 // guards\r
384 //\r
385 \r
386 extern  statetype s_grdstand;\r
387 \r
388 extern  statetype s_grdpath1;\r
389 extern  statetype s_grdpath1s;\r
390 extern  statetype s_grdpath2;\r
391 extern  statetype s_grdpath3;\r
392 extern  statetype s_grdpath3s;\r
393 extern  statetype s_grdpath4;\r
394 \r
395 extern  statetype s_grdpain;\r
396 extern  statetype s_grdpain1;\r
397 \r
398 extern  statetype s_grdgiveup;\r
399 \r
400 extern  statetype s_grdshoot1;\r
401 extern  statetype s_grdshoot2;\r
402 extern  statetype s_grdshoot3;\r
403 extern  statetype s_grdshoot4;\r
404 \r
405 extern  statetype s_grdchase1;\r
406 extern  statetype s_grdchase1s;\r
407 extern  statetype s_grdchase2;\r
408 extern  statetype s_grdchase3;\r
409 extern  statetype s_grdchase3s;\r
410 extern  statetype s_grdchase4;\r
411 \r
412 extern  statetype s_grddie1;\r
413 extern  statetype s_grddie1d;\r
414 extern  statetype s_grddie2;\r
415 extern  statetype s_grddie3;\r
416 extern  statetype s_grddie4;\r
417 \r
418 statetype s_grdstand    = {true,SPR_GRD_S_1,0,T_Stand,NULL,&s_grdstand};\r
419 \r
420 statetype s_grdpath1    = {true,SPR_GRD_W1_1,20,T_Path,NULL,&s_grdpath1s};\r
421 statetype s_grdpath1s   = {true,SPR_GRD_W1_1,5,NULL,NULL,&s_grdpath2};\r
422 statetype s_grdpath2    = {true,SPR_GRD_W2_1,15,T_Path,NULL,&s_grdpath3};\r
423 statetype s_grdpath3    = {true,SPR_GRD_W3_1,20,T_Path,NULL,&s_grdpath3s};\r
424 statetype s_grdpath3s   = {true,SPR_GRD_W3_1,5,NULL,NULL,&s_grdpath4};\r
425 statetype s_grdpath4    = {true,SPR_GRD_W4_1,15,T_Path,NULL,&s_grdpath1};\r
426 \r
427 statetype s_grdpain     = {2,SPR_GRD_PAIN_1,10,NULL,NULL,&s_grdchase1};\r
428 statetype s_grdpain1    = {2,SPR_GRD_PAIN_2,10,NULL,NULL,&s_grdchase1};\r
429 \r
430 statetype s_grdshoot1   = {false,SPR_GRD_SHOOT1,20,NULL,NULL,&s_grdshoot2};\r
431 statetype s_grdshoot2   = {false,SPR_GRD_SHOOT2,20,NULL,T_Shoot,&s_grdshoot3};\r
432 statetype s_grdshoot3   = {false,SPR_GRD_SHOOT3,20,NULL,NULL,&s_grdchase1};\r
433 \r
434 statetype s_grdchase1   = {true,SPR_GRD_W1_1,10,T_Chase,NULL,&s_grdchase1s};\r
435 statetype s_grdchase1s  = {true,SPR_GRD_W1_1,3,NULL,NULL,&s_grdchase2};\r
436 statetype s_grdchase2   = {true,SPR_GRD_W2_1,8,T_Chase,NULL,&s_grdchase3};\r
437 statetype s_grdchase3   = {true,SPR_GRD_W3_1,10,T_Chase,NULL,&s_grdchase3s};\r
438 statetype s_grdchase3s  = {true,SPR_GRD_W3_1,3,NULL,NULL,&s_grdchase4};\r
439 statetype s_grdchase4   = {true,SPR_GRD_W4_1,8,T_Chase,NULL,&s_grdchase1};\r
440 \r
441 statetype s_grddie1             = {false,SPR_GRD_DIE_1,15,NULL,A_DeathScream,&s_grddie2};\r
442 statetype s_grddie2             = {false,SPR_GRD_DIE_2,15,NULL,NULL,&s_grddie3};\r
443 statetype s_grddie3             = {false,SPR_GRD_DIE_3,15,NULL,NULL,&s_grddie4};\r
444 statetype s_grddie4             = {false,SPR_GRD_DEAD,0,NULL,NULL,&s_grddie4};\r
445 \r
446 \r
447 #ifndef SPEAR\r
448 //\r
449 // ghosts\r
450 //\r
451 extern  statetype s_blinkychase1;\r
452 extern  statetype s_blinkychase2;\r
453 extern  statetype s_inkychase1;\r
454 extern  statetype s_inkychase2;\r
455 extern  statetype s_pinkychase1;\r
456 extern  statetype s_pinkychase2;\r
457 extern  statetype s_clydechase1;\r
458 extern  statetype s_clydechase2;\r
459 \r
460 statetype s_blinkychase1        = {false,SPR_BLINKY_W1,10,T_Ghosts,NULL,&s_blinkychase2};\r
461 statetype s_blinkychase2        = {false,SPR_BLINKY_W2,10,T_Ghosts,NULL,&s_blinkychase1};\r
462 \r
463 statetype s_inkychase1          = {false,SPR_INKY_W1,10,T_Ghosts,NULL,&s_inkychase2};\r
464 statetype s_inkychase2          = {false,SPR_INKY_W2,10,T_Ghosts,NULL,&s_inkychase1};\r
465 \r
466 statetype s_pinkychase1         = {false,SPR_PINKY_W1,10,T_Ghosts,NULL,&s_pinkychase2};\r
467 statetype s_pinkychase2         = {false,SPR_PINKY_W2,10,T_Ghosts,NULL,&s_pinkychase1};\r
468 \r
469 statetype s_clydechase1         = {false,SPR_CLYDE_W1,10,T_Ghosts,NULL,&s_clydechase2};\r
470 statetype s_clydechase2         = {false,SPR_CLYDE_W2,10,T_Ghosts,NULL,&s_clydechase1};\r
471 #endif\r
472 \r
473 //\r
474 // dogs\r
475 //\r
476 \r
477 extern  statetype s_dogpath1;\r
478 extern  statetype s_dogpath1s;\r
479 extern  statetype s_dogpath2;\r
480 extern  statetype s_dogpath3;\r
481 extern  statetype s_dogpath3s;\r
482 extern  statetype s_dogpath4;\r
483 \r
484 extern  statetype s_dogjump1;\r
485 extern  statetype s_dogjump2;\r
486 extern  statetype s_dogjump3;\r
487 extern  statetype s_dogjump4;\r
488 extern  statetype s_dogjump5;\r
489 \r
490 extern  statetype s_dogchase1;\r
491 extern  statetype s_dogchase1s;\r
492 extern  statetype s_dogchase2;\r
493 extern  statetype s_dogchase3;\r
494 extern  statetype s_dogchase3s;\r
495 extern  statetype s_dogchase4;\r
496 \r
497 extern  statetype s_dogdie1;\r
498 extern  statetype s_dogdie1d;\r
499 extern  statetype s_dogdie2;\r
500 extern  statetype s_dogdie3;\r
501 extern  statetype s_dogdead;\r
502 \r
503 statetype s_dogpath1    = {true,SPR_DOG_W1_1,20,T_Path,NULL,&s_dogpath1s};\r
504 statetype s_dogpath1s   = {true,SPR_DOG_W1_1,5,NULL,NULL,&s_dogpath2};\r
505 statetype s_dogpath2    = {true,SPR_DOG_W2_1,15,T_Path,NULL,&s_dogpath3};\r
506 statetype s_dogpath3    = {true,SPR_DOG_W3_1,20,T_Path,NULL,&s_dogpath3s};\r
507 statetype s_dogpath3s   = {true,SPR_DOG_W3_1,5,NULL,NULL,&s_dogpath4};\r
508 statetype s_dogpath4    = {true,SPR_DOG_W4_1,15,T_Path,NULL,&s_dogpath1};\r
509 \r
510 statetype s_dogjump1    = {false,SPR_DOG_JUMP1,10,NULL,NULL,&s_dogjump2};\r
511 statetype s_dogjump2    = {false,SPR_DOG_JUMP2,10,NULL,T_Bite,&s_dogjump3};\r
512 statetype s_dogjump3    = {false,SPR_DOG_JUMP3,10,NULL,NULL,&s_dogjump4};\r
513 statetype s_dogjump4    = {false,SPR_DOG_JUMP1,10,NULL,NULL,&s_dogjump5};\r
514 statetype s_dogjump5    = {false,SPR_DOG_W1_1,10,NULL,NULL,&s_dogchase1};\r
515 \r
516 statetype s_dogchase1   = {true,SPR_DOG_W1_1,10,T_DogChase,NULL,&s_dogchase1s};\r
517 statetype s_dogchase1s  = {true,SPR_DOG_W1_1,3,NULL,NULL,&s_dogchase2};\r
518 statetype s_dogchase2   = {true,SPR_DOG_W2_1,8,T_DogChase,NULL,&s_dogchase3};\r
519 statetype s_dogchase3   = {true,SPR_DOG_W3_1,10,T_DogChase,NULL,&s_dogchase3s};\r
520 statetype s_dogchase3s  = {true,SPR_DOG_W3_1,3,NULL,NULL,&s_dogchase4};\r
521 statetype s_dogchase4   = {true,SPR_DOG_W4_1,8,T_DogChase,NULL,&s_dogchase1};\r
522 \r
523 statetype s_dogdie1             = {false,SPR_DOG_DIE_1,15,NULL,A_DeathScream,&s_dogdie2};\r
524 statetype s_dogdie2             = {false,SPR_DOG_DIE_2,15,NULL,NULL,&s_dogdie3};\r
525 statetype s_dogdie3             = {false,SPR_DOG_DIE_3,15,NULL,NULL,&s_dogdead};\r
526 statetype s_dogdead             = {false,SPR_DOG_DEAD,15,NULL,NULL,&s_dogdead};\r
527 \r
528 \r
529 //\r
530 // officers\r
531 //\r
532 \r
533 extern  statetype s_ofcstand;\r
534 \r
535 extern  statetype s_ofcpath1;\r
536 extern  statetype s_ofcpath1s;\r
537 extern  statetype s_ofcpath2;\r
538 extern  statetype s_ofcpath3;\r
539 extern  statetype s_ofcpath3s;\r
540 extern  statetype s_ofcpath4;\r
541 \r
542 extern  statetype s_ofcpain;\r
543 extern  statetype s_ofcpain1;\r
544 \r
545 extern  statetype s_ofcgiveup;\r
546 \r
547 extern  statetype s_ofcshoot1;\r
548 extern  statetype s_ofcshoot2;\r
549 extern  statetype s_ofcshoot3;\r
550 extern  statetype s_ofcshoot4;\r
551 \r
552 extern  statetype s_ofcchase1;\r
553 extern  statetype s_ofcchase1s;\r
554 extern  statetype s_ofcchase2;\r
555 extern  statetype s_ofcchase3;\r
556 extern  statetype s_ofcchase3s;\r
557 extern  statetype s_ofcchase4;\r
558 \r
559 extern  statetype s_ofcdie1;\r
560 extern  statetype s_ofcdie2;\r
561 extern  statetype s_ofcdie3;\r
562 extern  statetype s_ofcdie4;\r
563 extern  statetype s_ofcdie5;\r
564 \r
565 statetype s_ofcstand    = {true,SPR_OFC_S_1,0,T_Stand,NULL,&s_ofcstand};\r
566 \r
567 statetype s_ofcpath1    = {true,SPR_OFC_W1_1,20,T_Path,NULL,&s_ofcpath1s};\r
568 statetype s_ofcpath1s   = {true,SPR_OFC_W1_1,5,NULL,NULL,&s_ofcpath2};\r
569 statetype s_ofcpath2    = {true,SPR_OFC_W2_1,15,T_Path,NULL,&s_ofcpath3};\r
570 statetype s_ofcpath3    = {true,SPR_OFC_W3_1,20,T_Path,NULL,&s_ofcpath3s};\r
571 statetype s_ofcpath3s   = {true,SPR_OFC_W3_1,5,NULL,NULL,&s_ofcpath4};\r
572 statetype s_ofcpath4    = {true,SPR_OFC_W4_1,15,T_Path,NULL,&s_ofcpath1};\r
573 \r
574 statetype s_ofcpain     = {2,SPR_OFC_PAIN_1,10,NULL,NULL,&s_ofcchase1};\r
575 statetype s_ofcpain1    = {2,SPR_OFC_PAIN_2,10,NULL,NULL,&s_ofcchase1};\r
576 \r
577 statetype s_ofcshoot1   = {false,SPR_OFC_SHOOT1,6,NULL,NULL,&s_ofcshoot2};\r
578 statetype s_ofcshoot2   = {false,SPR_OFC_SHOOT2,20,NULL,T_Shoot,&s_ofcshoot3};\r
579 statetype s_ofcshoot3   = {false,SPR_OFC_SHOOT3,10,NULL,NULL,&s_ofcchase1};\r
580 \r
581 statetype s_ofcchase1   = {true,SPR_OFC_W1_1,10,T_Chase,NULL,&s_ofcchase1s};\r
582 statetype s_ofcchase1s  = {true,SPR_OFC_W1_1,3,NULL,NULL,&s_ofcchase2};\r
583 statetype s_ofcchase2   = {true,SPR_OFC_W2_1,8,T_Chase,NULL,&s_ofcchase3};\r
584 statetype s_ofcchase3   = {true,SPR_OFC_W3_1,10,T_Chase,NULL,&s_ofcchase3s};\r
585 statetype s_ofcchase3s  = {true,SPR_OFC_W3_1,3,NULL,NULL,&s_ofcchase4};\r
586 statetype s_ofcchase4   = {true,SPR_OFC_W4_1,8,T_Chase,NULL,&s_ofcchase1};\r
587 \r
588 statetype s_ofcdie1             = {false,SPR_OFC_DIE_1,11,NULL,A_DeathScream,&s_ofcdie2};\r
589 statetype s_ofcdie2             = {false,SPR_OFC_DIE_2,11,NULL,NULL,&s_ofcdie3};\r
590 statetype s_ofcdie3             = {false,SPR_OFC_DIE_3,11,NULL,NULL,&s_ofcdie4};\r
591 statetype s_ofcdie4             = {false,SPR_OFC_DIE_4,11,NULL,NULL,&s_ofcdie5};\r
592 statetype s_ofcdie5             = {false,SPR_OFC_DEAD,0,NULL,NULL,&s_ofcdie5};\r
593 \r
594 \r
595 //\r
596 // mutant\r
597 //\r
598 \r
599 extern  statetype s_mutstand;\r
600 \r
601 extern  statetype s_mutpath1;\r
602 extern  statetype s_mutpath1s;\r
603 extern  statetype s_mutpath2;\r
604 extern  statetype s_mutpath3;\r
605 extern  statetype s_mutpath3s;\r
606 extern  statetype s_mutpath4;\r
607 \r
608 extern  statetype s_mutpain;\r
609 extern  statetype s_mutpain1;\r
610 \r
611 extern  statetype s_mutgiveup;\r
612 \r
613 extern  statetype s_mutshoot1;\r
614 extern  statetype s_mutshoot2;\r
615 extern  statetype s_mutshoot3;\r
616 extern  statetype s_mutshoot4;\r
617 \r
618 extern  statetype s_mutchase1;\r
619 extern  statetype s_mutchase1s;\r
620 extern  statetype s_mutchase2;\r
621 extern  statetype s_mutchase3;\r
622 extern  statetype s_mutchase3s;\r
623 extern  statetype s_mutchase4;\r
624 \r
625 extern  statetype s_mutdie1;\r
626 extern  statetype s_mutdie2;\r
627 extern  statetype s_mutdie3;\r
628 extern  statetype s_mutdie4;\r
629 extern  statetype s_mutdie5;\r
630 \r
631 statetype s_mutstand    = {true,SPR_MUT_S_1,0,T_Stand,NULL,&s_mutstand};\r
632 \r
633 statetype s_mutpath1    = {true,SPR_MUT_W1_1,20,T_Path,NULL,&s_mutpath1s};\r
634 statetype s_mutpath1s   = {true,SPR_MUT_W1_1,5,NULL,NULL,&s_mutpath2};\r
635 statetype s_mutpath2    = {true,SPR_MUT_W2_1,15,T_Path,NULL,&s_mutpath3};\r
636 statetype s_mutpath3    = {true,SPR_MUT_W3_1,20,T_Path,NULL,&s_mutpath3s};\r
637 statetype s_mutpath3s   = {true,SPR_MUT_W3_1,5,NULL,NULL,&s_mutpath4};\r
638 statetype s_mutpath4    = {true,SPR_MUT_W4_1,15,T_Path,NULL,&s_mutpath1};\r
639 \r
640 statetype s_mutpain     = {2,SPR_MUT_PAIN_1,10,NULL,NULL,&s_mutchase1};\r
641 statetype s_mutpain1    = {2,SPR_MUT_PAIN_2,10,NULL,NULL,&s_mutchase1};\r
642 \r
643 statetype s_mutshoot1   = {false,SPR_MUT_SHOOT1,6,NULL,T_Shoot,&s_mutshoot2};\r
644 statetype s_mutshoot2   = {false,SPR_MUT_SHOOT2,20,NULL,NULL,&s_mutshoot3};\r
645 statetype s_mutshoot3   = {false,SPR_MUT_SHOOT3,10,NULL,T_Shoot,&s_mutshoot4};\r
646 statetype s_mutshoot4   = {false,SPR_MUT_SHOOT4,20,NULL,NULL,&s_mutchase1};\r
647 \r
648 statetype s_mutchase1   = {true,SPR_MUT_W1_1,10,T_Chase,NULL,&s_mutchase1s};\r
649 statetype s_mutchase1s  = {true,SPR_MUT_W1_1,3,NULL,NULL,&s_mutchase2};\r
650 statetype s_mutchase2   = {true,SPR_MUT_W2_1,8,T_Chase,NULL,&s_mutchase3};\r
651 statetype s_mutchase3   = {true,SPR_MUT_W3_1,10,T_Chase,NULL,&s_mutchase3s};\r
652 statetype s_mutchase3s  = {true,SPR_MUT_W3_1,3,NULL,NULL,&s_mutchase4};\r
653 statetype s_mutchase4   = {true,SPR_MUT_W4_1,8,T_Chase,NULL,&s_mutchase1};\r
654 \r
655 statetype s_mutdie1             = {false,SPR_MUT_DIE_1,7,NULL,A_DeathScream,&s_mutdie2};\r
656 statetype s_mutdie2             = {false,SPR_MUT_DIE_2,7,NULL,NULL,&s_mutdie3};\r
657 statetype s_mutdie3             = {false,SPR_MUT_DIE_3,7,NULL,NULL,&s_mutdie4};\r
658 statetype s_mutdie4             = {false,SPR_MUT_DIE_4,7,NULL,NULL,&s_mutdie5};\r
659 statetype s_mutdie5             = {false,SPR_MUT_DEAD,0,NULL,NULL,&s_mutdie5};\r
660 \r
661 \r
662 //\r
663 // SS\r
664 //\r
665 \r
666 extern  statetype s_ssstand;\r
667 \r
668 extern  statetype s_sspath1;\r
669 extern  statetype s_sspath1s;\r
670 extern  statetype s_sspath2;\r
671 extern  statetype s_sspath3;\r
672 extern  statetype s_sspath3s;\r
673 extern  statetype s_sspath4;\r
674 \r
675 extern  statetype s_sspain;\r
676 extern  statetype s_sspain1;\r
677 \r
678 extern  statetype s_ssshoot1;\r
679 extern  statetype s_ssshoot2;\r
680 extern  statetype s_ssshoot3;\r
681 extern  statetype s_ssshoot4;\r
682 extern  statetype s_ssshoot5;\r
683 extern  statetype s_ssshoot6;\r
684 extern  statetype s_ssshoot7;\r
685 extern  statetype s_ssshoot8;\r
686 extern  statetype s_ssshoot9;\r
687 \r
688 extern  statetype s_sschase1;\r
689 extern  statetype s_sschase1s;\r
690 extern  statetype s_sschase2;\r
691 extern  statetype s_sschase3;\r
692 extern  statetype s_sschase3s;\r
693 extern  statetype s_sschase4;\r
694 \r
695 extern  statetype s_ssdie1;\r
696 extern  statetype s_ssdie2;\r
697 extern  statetype s_ssdie3;\r
698 extern  statetype s_ssdie4;\r
699 \r
700 statetype s_ssstand     = {true,SPR_SS_S_1,0,T_Stand,NULL,&s_ssstand};\r
701 \r
702 statetype s_sspath1     = {true,SPR_SS_W1_1,20,T_Path,NULL,&s_sspath1s};\r
703 statetype s_sspath1s    = {true,SPR_SS_W1_1,5,NULL,NULL,&s_sspath2};\r
704 statetype s_sspath2     = {true,SPR_SS_W2_1,15,T_Path,NULL,&s_sspath3};\r
705 statetype s_sspath3     = {true,SPR_SS_W3_1,20,T_Path,NULL,&s_sspath3s};\r
706 statetype s_sspath3s    = {true,SPR_SS_W3_1,5,NULL,NULL,&s_sspath4};\r
707 statetype s_sspath4     = {true,SPR_SS_W4_1,15,T_Path,NULL,&s_sspath1};\r
708 \r
709 statetype s_sspain              = {2,SPR_SS_PAIN_1,10,NULL,NULL,&s_sschase1};\r
710 statetype s_sspain1     = {2,SPR_SS_PAIN_2,10,NULL,NULL,&s_sschase1};\r
711 \r
712 statetype s_ssshoot1    = {false,SPR_SS_SHOOT1,20,NULL,NULL,&s_ssshoot2};\r
713 statetype s_ssshoot2    = {false,SPR_SS_SHOOT2,20,NULL,T_Shoot,&s_ssshoot3};\r
714 statetype s_ssshoot3    = {false,SPR_SS_SHOOT3,10,NULL,NULL,&s_ssshoot4};\r
715 statetype s_ssshoot4    = {false,SPR_SS_SHOOT2,10,NULL,T_Shoot,&s_ssshoot5};\r
716 statetype s_ssshoot5    = {false,SPR_SS_SHOOT3,10,NULL,NULL,&s_ssshoot6};\r
717 statetype s_ssshoot6    = {false,SPR_SS_SHOOT2,10,NULL,T_Shoot,&s_ssshoot7};\r
718 statetype s_ssshoot7    = {false,SPR_SS_SHOOT3,10,NULL,NULL,&s_ssshoot8};\r
719 statetype s_ssshoot8    = {false,SPR_SS_SHOOT2,10,NULL,T_Shoot,&s_ssshoot9};\r
720 statetype s_ssshoot9    = {false,SPR_SS_SHOOT3,10,NULL,NULL,&s_sschase1};\r
721 \r
722 statetype s_sschase1    = {true,SPR_SS_W1_1,10,T_Chase,NULL,&s_sschase1s};\r
723 statetype s_sschase1s   = {true,SPR_SS_W1_1,3,NULL,NULL,&s_sschase2};\r
724 statetype s_sschase2    = {true,SPR_SS_W2_1,8,T_Chase,NULL,&s_sschase3};\r
725 statetype s_sschase3    = {true,SPR_SS_W3_1,10,T_Chase,NULL,&s_sschase3s};\r
726 statetype s_sschase3s   = {true,SPR_SS_W3_1,3,NULL,NULL,&s_sschase4};\r
727 statetype s_sschase4    = {true,SPR_SS_W4_1,8,T_Chase,NULL,&s_sschase1};\r
728 \r
729 statetype s_ssdie1              = {false,SPR_SS_DIE_1,15,NULL,A_DeathScream,&s_ssdie2};\r
730 statetype s_ssdie2              = {false,SPR_SS_DIE_2,15,NULL,NULL,&s_ssdie3};\r
731 statetype s_ssdie3              = {false,SPR_SS_DIE_3,15,NULL,NULL,&s_ssdie4};\r
732 statetype s_ssdie4              = {false,SPR_SS_DEAD,0,NULL,NULL,&s_ssdie4};\r
733 \r
734 \r
735 #ifndef SPEAR\r
736 //\r
737 // hans\r
738 //\r
739 extern  statetype s_bossstand;\r
740 \r
741 extern  statetype s_bosschase1;\r
742 extern  statetype s_bosschase1s;\r
743 extern  statetype s_bosschase2;\r
744 extern  statetype s_bosschase3;\r
745 extern  statetype s_bosschase3s;\r
746 extern  statetype s_bosschase4;\r
747 \r
748 extern  statetype s_bossdie1;\r
749 extern  statetype s_bossdie2;\r
750 extern  statetype s_bossdie3;\r
751 extern  statetype s_bossdie4;\r
752 \r
753 extern  statetype s_bossshoot1;\r
754 extern  statetype s_bossshoot2;\r
755 extern  statetype s_bossshoot3;\r
756 extern  statetype s_bossshoot4;\r
757 extern  statetype s_bossshoot5;\r
758 extern  statetype s_bossshoot6;\r
759 extern  statetype s_bossshoot7;\r
760 extern  statetype s_bossshoot8;\r
761 \r
762 \r
763 statetype s_bossstand   = {false,SPR_BOSS_W1,0,T_Stand,NULL,&s_bossstand};\r
764 \r
765 statetype s_bosschase1  = {false,SPR_BOSS_W1,10,T_Chase,NULL,&s_bosschase1s};\r
766 statetype s_bosschase1s = {false,SPR_BOSS_W1,3,NULL,NULL,&s_bosschase2};\r
767 statetype s_bosschase2  = {false,SPR_BOSS_W2,8,T_Chase,NULL,&s_bosschase3};\r
768 statetype s_bosschase3  = {false,SPR_BOSS_W3,10,T_Chase,NULL,&s_bosschase3s};\r
769 statetype s_bosschase3s = {false,SPR_BOSS_W3,3,NULL,NULL,&s_bosschase4};\r
770 statetype s_bosschase4  = {false,SPR_BOSS_W4,8,T_Chase,NULL,&s_bosschase1};\r
771 \r
772 statetype s_bossdie1    = {false,SPR_BOSS_DIE1,15,NULL,A_DeathScream,&s_bossdie2};\r
773 statetype s_bossdie2    = {false,SPR_BOSS_DIE2,15,NULL,NULL,&s_bossdie3};\r
774 statetype s_bossdie3    = {false,SPR_BOSS_DIE3,15,NULL,NULL,&s_bossdie4};\r
775 statetype s_bossdie4    = {false,SPR_BOSS_DEAD,0,NULL,NULL,&s_bossdie4};\r
776 \r
777 statetype s_bossshoot1  = {false,SPR_BOSS_SHOOT1,30,NULL,NULL,&s_bossshoot2};\r
778 statetype s_bossshoot2  = {false,SPR_BOSS_SHOOT2,10,NULL,T_Shoot,&s_bossshoot3};\r
779 statetype s_bossshoot3  = {false,SPR_BOSS_SHOOT3,10,NULL,T_Shoot,&s_bossshoot4};\r
780 statetype s_bossshoot4  = {false,SPR_BOSS_SHOOT2,10,NULL,T_Shoot,&s_bossshoot5};\r
781 statetype s_bossshoot5  = {false,SPR_BOSS_SHOOT3,10,NULL,T_Shoot,&s_bossshoot6};\r
782 statetype s_bossshoot6  = {false,SPR_BOSS_SHOOT2,10,NULL,T_Shoot,&s_bossshoot7};\r
783 statetype s_bossshoot7  = {false,SPR_BOSS_SHOOT3,10,NULL,T_Shoot,&s_bossshoot8};\r
784 statetype s_bossshoot8  = {false,SPR_BOSS_SHOOT1,10,NULL,NULL,&s_bosschase1};\r
785 \r
786 \r
787 //\r
788 // gretel\r
789 //\r
790 extern  statetype s_gretelstand;\r
791 \r
792 extern  statetype s_gretelchase1;\r
793 extern  statetype s_gretelchase1s;\r
794 extern  statetype s_gretelchase2;\r
795 extern  statetype s_gretelchase3;\r
796 extern  statetype s_gretelchase3s;\r
797 extern  statetype s_gretelchase4;\r
798 \r
799 extern  statetype s_greteldie1;\r
800 extern  statetype s_greteldie2;\r
801 extern  statetype s_greteldie3;\r
802 extern  statetype s_greteldie4;\r
803 \r
804 extern  statetype s_gretelshoot1;\r
805 extern  statetype s_gretelshoot2;\r
806 extern  statetype s_gretelshoot3;\r
807 extern  statetype s_gretelshoot4;\r
808 extern  statetype s_gretelshoot5;\r
809 extern  statetype s_gretelshoot6;\r
810 extern  statetype s_gretelshoot7;\r
811 extern  statetype s_gretelshoot8;\r
812 \r
813 \r
814 statetype s_gretelstand = {false,SPR_GRETEL_W1,0,T_Stand,NULL,&s_gretelstand};\r
815 \r
816 statetype s_gretelchase1        = {false,SPR_GRETEL_W1,10,T_Chase,NULL,&s_gretelchase1s};\r
817 statetype s_gretelchase1s       = {false,SPR_GRETEL_W1,3,NULL,NULL,&s_gretelchase2};\r
818 statetype s_gretelchase2        = {false,SPR_GRETEL_W2,8,T_Chase,NULL,&s_gretelchase3};\r
819 statetype s_gretelchase3        = {false,SPR_GRETEL_W3,10,T_Chase,NULL,&s_gretelchase3s};\r
820 statetype s_gretelchase3s       = {false,SPR_GRETEL_W3,3,NULL,NULL,&s_gretelchase4};\r
821 statetype s_gretelchase4        = {false,SPR_GRETEL_W4,8,T_Chase,NULL,&s_gretelchase1};\r
822 \r
823 statetype s_greteldie1  = {false,SPR_GRETEL_DIE1,15,NULL,A_DeathScream,&s_greteldie2};\r
824 statetype s_greteldie2  = {false,SPR_GRETEL_DIE2,15,NULL,NULL,&s_greteldie3};\r
825 statetype s_greteldie3  = {false,SPR_GRETEL_DIE3,15,NULL,NULL,&s_greteldie4};\r
826 statetype s_greteldie4  = {false,SPR_GRETEL_DEAD,0,NULL,NULL,&s_greteldie4};\r
827 \r
828 statetype s_gretelshoot1        = {false,SPR_GRETEL_SHOOT1,30,NULL,NULL,&s_gretelshoot2};\r
829 statetype s_gretelshoot2        = {false,SPR_GRETEL_SHOOT2,10,NULL,T_Shoot,&s_gretelshoot3};\r
830 statetype s_gretelshoot3        = {false,SPR_GRETEL_SHOOT3,10,NULL,T_Shoot,&s_gretelshoot4};\r
831 statetype s_gretelshoot4        = {false,SPR_GRETEL_SHOOT2,10,NULL,T_Shoot,&s_gretelshoot5};\r
832 statetype s_gretelshoot5        = {false,SPR_GRETEL_SHOOT3,10,NULL,T_Shoot,&s_gretelshoot6};\r
833 statetype s_gretelshoot6        = {false,SPR_GRETEL_SHOOT2,10,NULL,T_Shoot,&s_gretelshoot7};\r
834 statetype s_gretelshoot7        = {false,SPR_GRETEL_SHOOT3,10,NULL,T_Shoot,&s_gretelshoot8};\r
835 statetype s_gretelshoot8        = {false,SPR_GRETEL_SHOOT1,10,NULL,NULL,&s_gretelchase1};\r
836 #endif\r
837 \r
838 \r
839 /*\r
840 ===============\r
841 =\r
842 = SpawnStand\r
843 =\r
844 ===============\r
845 */\r
846 \r
847 void SpawnStand (enemy_t which, int tilex, int tiley, int dir)\r
848 {\r
849         unsigned        far *map,tile;\r
850 \r
851         switch (which)\r
852         {\r
853         case en_guard:\r
854                 SpawnNewObj (tilex,tiley,&s_grdstand);\r
855                 new->speed = SPDPATROL;\r
856                 if (!loadedgame)\r
857                   gamestate.killtotal++;\r
858                 break;\r
859 \r
860         case en_officer:\r
861                 SpawnNewObj (tilex,tiley,&s_ofcstand);\r
862                 new->speed = SPDPATROL;\r
863                 if (!loadedgame)\r
864                   gamestate.killtotal++;\r
865                 break;\r
866 \r
867         case en_mutant:\r
868                 SpawnNewObj (tilex,tiley,&s_mutstand);\r
869                 new->speed = SPDPATROL;\r
870                 if (!loadedgame)\r
871                   gamestate.killtotal++;\r
872                 break;\r
873 \r
874         case en_ss:\r
875                 SpawnNewObj (tilex,tiley,&s_ssstand);\r
876                 new->speed = SPDPATROL;\r
877                 if (!loadedgame)\r
878                   gamestate.killtotal++;\r
879                 break;\r
880         }\r
881 \r
882 \r
883         map = mapsegs[0]+farmapylookup[tiley]+tilex;\r
884         if (*map == AMBUSHTILE)\r
885         {\r
886                 tilemap[tilex][tiley] = 0;\r
887 \r
888                 if (*(map+1) >= AREATILE)\r
889                         tile = *(map+1);\r
890                 if (*(map-mapwidth) >= AREATILE)\r
891                         tile = *(map-mapwidth);\r
892                 if (*(map+mapwidth) >= AREATILE)\r
893                         tile = *(map+mapwidth);\r
894                 if ( *(map-1) >= AREATILE)\r
895                         tile = *(map-1);\r
896 \r
897                 *map = tile;\r
898                 new->areanumber = tile-AREATILE;\r
899 \r
900                 new->flags |= FL_AMBUSH;\r
901         }\r
902 \r
903         new->obclass = guardobj+which;\r
904         new->hitpoints = starthitpoints[gamestate.difficulty][which];\r
905         new->dir = dir*2;\r
906         new->flags |= FL_SHOOTABLE;\r
907 }\r
908 \r
909 \r
910 \r
911 /*\r
912 ===============\r
913 =\r
914 = SpawnDeadGuard\r
915 =\r
916 ===============\r
917 */\r
918 \r
919 void SpawnDeadGuard (int tilex, int tiley)\r
920 {\r
921         SpawnNewObj (tilex,tiley,&s_grddie4);\r
922         new->obclass = inertobj;\r
923 }\r
924 \r
925 \r
926 \r
927 #ifndef SPEAR\r
928 /*\r
929 ===============\r
930 =\r
931 = SpawnBoss\r
932 =\r
933 ===============\r
934 */\r
935 \r
936 void SpawnBoss (int tilex, int tiley)\r
937 {\r
938         unsigned        far *map,tile;\r
939 \r
940         SpawnNewObj (tilex,tiley,&s_bossstand);\r
941         new->speed = SPDPATROL;\r
942 \r
943         new->obclass = bossobj;\r
944         new->hitpoints = starthitpoints[gamestate.difficulty][en_boss];\r
945         new->dir = south;\r
946         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
947         if (!loadedgame)\r
948           gamestate.killtotal++;\r
949 }\r
950 \r
951 /*\r
952 ===============\r
953 =\r
954 = SpawnGretel\r
955 =\r
956 ===============\r
957 */\r
958 \r
959 void SpawnGretel (int tilex, int tiley)\r
960 {\r
961         unsigned        far *map,tile;\r
962 \r
963         SpawnNewObj (tilex,tiley,&s_gretelstand);\r
964         new->speed = SPDPATROL;\r
965 \r
966         new->obclass = gretelobj;\r
967         new->hitpoints = starthitpoints[gamestate.difficulty][en_gretel];\r
968         new->dir = north;\r
969         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
970         if (!loadedgame)\r
971           gamestate.killtotal++;\r
972 }\r
973 #endif\r
974 \r
975 /*\r
976 ===============\r
977 =\r
978 = SpawnPatrol\r
979 =\r
980 ===============\r
981 */\r
982 \r
983 void SpawnPatrol (enemy_t which, int tilex, int tiley, int dir)\r
984 {\r
985         switch (which)\r
986         {\r
987         case en_guard:\r
988                 SpawnNewObj (tilex,tiley,&s_grdpath1);\r
989                 new->speed = SPDPATROL;\r
990                 if (!loadedgame)\r
991                   gamestate.killtotal++;\r
992                 break;\r
993 \r
994         case en_officer:\r
995                 SpawnNewObj (tilex,tiley,&s_ofcpath1);\r
996                 new->speed = SPDPATROL;\r
997                 if (!loadedgame)\r
998                   gamestate.killtotal++;\r
999                 break;\r
1000 \r
1001         case en_ss:\r
1002                 SpawnNewObj (tilex,tiley,&s_sspath1);\r
1003                 new->speed = SPDPATROL;\r
1004                 if (!loadedgame)\r
1005                   gamestate.killtotal++;\r
1006                 break;\r
1007 \r
1008         case en_mutant:\r
1009                 SpawnNewObj (tilex,tiley,&s_mutpath1);\r
1010                 new->speed = SPDPATROL;\r
1011                 if (!loadedgame)\r
1012                   gamestate.killtotal++;\r
1013                 break;\r
1014 \r
1015         case en_dog:\r
1016                 SpawnNewObj (tilex,tiley,&s_dogpath1);\r
1017                 new->speed = SPDDOG;\r
1018                 if (!loadedgame)\r
1019                   gamestate.killtotal++;\r
1020                 break;\r
1021         }\r
1022 \r
1023         new->obclass = guardobj+which;\r
1024         new->dir = dir*2;\r
1025         new->hitpoints = starthitpoints[gamestate.difficulty][which];\r
1026         new->distance = tileglobal;\r
1027         new->flags |= FL_SHOOTABLE;\r
1028         new->active = true;\r
1029 \r
1030         actorat[new->tilex][new->tiley] = NULL;         // don't use original spot\r
1031 \r
1032         switch (dir)\r
1033         {\r
1034         case 0:\r
1035                 new->tilex++;\r
1036                 break;\r
1037         case 1:\r
1038                 new->tiley--;\r
1039                 break;\r
1040         case 2:\r
1041                 new->tilex--;\r
1042                 break;\r
1043         case 3:\r
1044                 new->tiley++;\r
1045                 break;\r
1046         }\r
1047 \r
1048         actorat[new->tilex][new->tiley] = new;\r
1049 }\r
1050 \r
1051 \r
1052 \r
1053 /*\r
1054 ==================\r
1055 =\r
1056 = A_DeathScream\r
1057 =\r
1058 ==================\r
1059 */\r
1060 \r
1061 void A_DeathScream (objtype *ob)\r
1062 {\r
1063 #ifndef UPLOAD\r
1064 #ifndef SPEAR\r
1065         if (mapon==9 && !US_RndT())\r
1066 #else\r
1067         if ((mapon==18 || mapon==19) && !US_RndT())\r
1068 #endif\r
1069         {\r
1070          switch(ob->obclass)\r
1071          {\r
1072           case mutantobj:\r
1073           case guardobj:\r
1074           case officerobj:\r
1075           case ssobj:\r
1076           case dogobj:\r
1077                 PlaySoundLocActor(DEATHSCREAM6SND,ob);\r
1078                 return;\r
1079          }\r
1080         }\r
1081 #endif\r
1082 \r
1083         switch (ob->obclass)\r
1084         {\r
1085         case mutantobj:\r
1086                 PlaySoundLocActor(AHHHGSND,ob);\r
1087                 break;\r
1088 \r
1089         case guardobj:\r
1090                 {\r
1091                  int sounds[9]={ DEATHSCREAM1SND,\r
1092                                  DEATHSCREAM2SND,\r
1093                                  DEATHSCREAM3SND,\r
1094                                  DEATHSCREAM4SND,\r
1095                                  DEATHSCREAM5SND,\r
1096                                  DEATHSCREAM7SND,\r
1097                                  DEATHSCREAM8SND,\r
1098                                  DEATHSCREAM9SND\r
1099                                  };\r
1100 \r
1101                  #ifndef UPLOAD\r
1102                  PlaySoundLocActor(sounds[US_RndT()%8],ob);\r
1103                  #else\r
1104                  PlaySoundLocActor(sounds[US_RndT()%2],ob);\r
1105                  #endif\r
1106                 }\r
1107                 break;\r
1108         case officerobj:\r
1109                 PlaySoundLocActor(NEINSOVASSND,ob);\r
1110                 break;\r
1111         case ssobj:\r
1112                 PlaySoundLocActor(LEBENSND,ob); // JAB\r
1113                 break;\r
1114         case dogobj:\r
1115                 PlaySoundLocActor(DOGDEATHSND,ob);      // JAB\r
1116                 break;\r
1117 #ifndef SPEAR\r
1118         case bossobj:\r
1119                 SD_PlaySound(MUTTISND);                         // JAB\r
1120                 break;\r
1121         case schabbobj:\r
1122                 SD_PlaySound(MEINGOTTSND);\r
1123                 break;\r
1124         case fakeobj:\r
1125                 SD_PlaySound(HITLERHASND);\r
1126                 break;\r
1127         case mechahitlerobj:\r
1128                 SD_PlaySound(SCHEISTSND);\r
1129                 break;\r
1130         case realhitlerobj:\r
1131                 SD_PlaySound(EVASND);\r
1132                 break;\r
1133         case gretelobj:\r
1134                 SD_PlaySound(MEINSND);\r
1135                 break;\r
1136         case giftobj:\r
1137                 SD_PlaySound(DONNERSND);\r
1138                 break;\r
1139         case fatobj:\r
1140                 SD_PlaySound(ROSESND);\r
1141                 break;\r
1142 #else\r
1143         case spectreobj:\r
1144                 SD_PlaySound(GHOSTFADESND);\r
1145                 break;\r
1146         case angelobj:\r
1147                 SD_PlaySound(ANGELDEATHSND);\r
1148                 break;\r
1149         case transobj:\r
1150                 SD_PlaySound(TRANSDEATHSND);\r
1151                 break;\r
1152         case uberobj:\r
1153                 SD_PlaySound(UBERDEATHSND);\r
1154                 break;\r
1155         case willobj:\r
1156                 SD_PlaySound(WILHELMDEATHSND);\r
1157                 break;\r
1158         case deathobj:\r
1159                 SD_PlaySound(KNIGHTDEATHSND);\r
1160                 break;\r
1161 #endif\r
1162         }\r
1163 }\r
1164 \r
1165 \r
1166 /*\r
1167 =============================================================================\r
1168 \r
1169                                                  SPEAR ACTORS\r
1170 \r
1171 =============================================================================\r
1172 */\r
1173 \r
1174 #ifdef SPEAR\r
1175 \r
1176 void T_Launch (objtype *ob);\r
1177 void T_Will (objtype *ob);\r
1178 \r
1179 extern  statetype s_angelshoot1;\r
1180 extern  statetype s_deathshoot1;\r
1181 extern  statetype s_spark1;\r
1182 \r
1183 //\r
1184 // trans\r
1185 //\r
1186 extern  statetype s_transstand;\r
1187 \r
1188 extern  statetype s_transchase1;\r
1189 extern  statetype s_transchase1s;\r
1190 extern  statetype s_transchase2;\r
1191 extern  statetype s_transchase3;\r
1192 extern  statetype s_transchase3s;\r
1193 extern  statetype s_transchase4;\r
1194 \r
1195 extern  statetype s_transdie0;\r
1196 extern  statetype s_transdie01;\r
1197 extern  statetype s_transdie1;\r
1198 extern  statetype s_transdie2;\r
1199 extern  statetype s_transdie3;\r
1200 extern  statetype s_transdie4;\r
1201 \r
1202 extern  statetype s_transshoot1;\r
1203 extern  statetype s_transshoot2;\r
1204 extern  statetype s_transshoot3;\r
1205 extern  statetype s_transshoot4;\r
1206 extern  statetype s_transshoot5;\r
1207 extern  statetype s_transshoot6;\r
1208 extern  statetype s_transshoot7;\r
1209 extern  statetype s_transshoot8;\r
1210 \r
1211 \r
1212 statetype s_transstand  = {false,SPR_TRANS_W1,0,T_Stand,NULL,&s_transstand};\r
1213 \r
1214 statetype s_transchase1         = {false,SPR_TRANS_W1,10,T_Chase,NULL,&s_transchase1s};\r
1215 statetype s_transchase1s        = {false,SPR_TRANS_W1,3,NULL,NULL,&s_transchase2};\r
1216 statetype s_transchase2         = {false,SPR_TRANS_W2,8,T_Chase,NULL,&s_transchase3};\r
1217 statetype s_transchase3         = {false,SPR_TRANS_W3,10,T_Chase,NULL,&s_transchase3s};\r
1218 statetype s_transchase3s        = {false,SPR_TRANS_W3,3,NULL,NULL,&s_transchase4};\r
1219 statetype s_transchase4         = {false,SPR_TRANS_W4,8,T_Chase,NULL,&s_transchase1};\r
1220 \r
1221 statetype s_transdie0   = {false,SPR_TRANS_W1,1,NULL,A_DeathScream,&s_transdie01};\r
1222 statetype s_transdie01  = {false,SPR_TRANS_W1,1,NULL,NULL,&s_transdie1};\r
1223 statetype s_transdie1   = {false,SPR_TRANS_DIE1,15,NULL,NULL,&s_transdie2};\r
1224 statetype s_transdie2   = {false,SPR_TRANS_DIE2,15,NULL,NULL,&s_transdie3};\r
1225 statetype s_transdie3   = {false,SPR_TRANS_DIE3,15,NULL,NULL,&s_transdie4};\r
1226 statetype s_transdie4   = {false,SPR_TRANS_DEAD,0,NULL,NULL,&s_transdie4};\r
1227 \r
1228 statetype s_transshoot1         = {false,SPR_TRANS_SHOOT1,30,NULL,NULL,&s_transshoot2};\r
1229 statetype s_transshoot2         = {false,SPR_TRANS_SHOOT2,10,NULL,T_Shoot,&s_transshoot3};\r
1230 statetype s_transshoot3         = {false,SPR_TRANS_SHOOT3,10,NULL,T_Shoot,&s_transshoot4};\r
1231 statetype s_transshoot4         = {false,SPR_TRANS_SHOOT2,10,NULL,T_Shoot,&s_transshoot5};\r
1232 statetype s_transshoot5         = {false,SPR_TRANS_SHOOT3,10,NULL,T_Shoot,&s_transshoot6};\r
1233 statetype s_transshoot6         = {false,SPR_TRANS_SHOOT2,10,NULL,T_Shoot,&s_transshoot7};\r
1234 statetype s_transshoot7         = {false,SPR_TRANS_SHOOT3,10,NULL,T_Shoot,&s_transshoot8};\r
1235 statetype s_transshoot8         = {false,SPR_TRANS_SHOOT1,10,NULL,NULL,&s_transchase1};\r
1236 \r
1237 \r
1238 /*\r
1239 ===============\r
1240 =\r
1241 = SpawnTrans\r
1242 =\r
1243 ===============\r
1244 */\r
1245 \r
1246 void SpawnTrans (int tilex, int tiley)\r
1247 {\r
1248         unsigned        far *map,tile;\r
1249 \r
1250         if (SoundBlasterPresent && DigiMode != sds_Off)\r
1251                 s_transdie01.tictime = 105;\r
1252 \r
1253         SpawnNewObj (tilex,tiley,&s_transstand);\r
1254         new->obclass = transobj;\r
1255         new->hitpoints = starthitpoints[gamestate.difficulty][en_trans];\r
1256         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
1257         if (!loadedgame)\r
1258           gamestate.killtotal++;\r
1259 }\r
1260 \r
1261 \r
1262 //\r
1263 // uber\r
1264 //\r
1265 void T_UShoot (objtype *ob);\r
1266 \r
1267 extern  statetype s_uberstand;\r
1268 \r
1269 extern  statetype s_uberchase1;\r
1270 extern  statetype s_uberchase1s;\r
1271 extern  statetype s_uberchase2;\r
1272 extern  statetype s_uberchase3;\r
1273 extern  statetype s_uberchase3s;\r
1274 extern  statetype s_uberchase4;\r
1275 \r
1276 extern  statetype s_uberdie0;\r
1277 extern  statetype s_uberdie01;\r
1278 extern  statetype s_uberdie1;\r
1279 extern  statetype s_uberdie2;\r
1280 extern  statetype s_uberdie3;\r
1281 extern  statetype s_uberdie4;\r
1282 extern  statetype s_uberdie5;\r
1283 \r
1284 extern  statetype s_ubershoot1;\r
1285 extern  statetype s_ubershoot2;\r
1286 extern  statetype s_ubershoot3;\r
1287 extern  statetype s_ubershoot4;\r
1288 extern  statetype s_ubershoot5;\r
1289 extern  statetype s_ubershoot6;\r
1290 extern  statetype s_ubershoot7;\r
1291 \r
1292 \r
1293 statetype s_uberstand   = {false,SPR_UBER_W1,0,T_Stand,NULL,&s_uberstand};\r
1294 \r
1295 statetype s_uberchase1  = {false,SPR_UBER_W1,10,T_Chase,NULL,&s_uberchase1s};\r
1296 statetype s_uberchase1s = {false,SPR_UBER_W1,3,NULL,NULL,&s_uberchase2};\r
1297 statetype s_uberchase2  = {false,SPR_UBER_W2,8,T_Chase,NULL,&s_uberchase3};\r
1298 statetype s_uberchase3  = {false,SPR_UBER_W3,10,T_Chase,NULL,&s_uberchase3s};\r
1299 statetype s_uberchase3s = {false,SPR_UBER_W3,3,NULL,NULL,&s_uberchase4};\r
1300 statetype s_uberchase4  = {false,SPR_UBER_W4,8,T_Chase,NULL,&s_uberchase1};\r
1301 \r
1302 statetype s_uberdie0    = {false,SPR_UBER_W1,1,NULL,A_DeathScream,&s_uberdie01};\r
1303 statetype s_uberdie01   = {false,SPR_UBER_W1,1,NULL,NULL,&s_uberdie1};\r
1304 statetype s_uberdie1    = {false,SPR_UBER_DIE1,15,NULL,NULL,&s_uberdie2};\r
1305 statetype s_uberdie2    = {false,SPR_UBER_DIE2,15,NULL,NULL,&s_uberdie3};\r
1306 statetype s_uberdie3    = {false,SPR_UBER_DIE3,15,NULL,NULL,&s_uberdie4};\r
1307 statetype s_uberdie4    = {false,SPR_UBER_DIE4,15,NULL,NULL,&s_uberdie5};\r
1308 statetype s_uberdie5    = {false,SPR_UBER_DEAD,0,NULL,NULL,&s_uberdie5};\r
1309 \r
1310 statetype s_ubershoot1  = {false,SPR_UBER_SHOOT1,30,NULL,NULL,&s_ubershoot2};\r
1311 statetype s_ubershoot2  = {false,SPR_UBER_SHOOT2,12,NULL,T_UShoot,&s_ubershoot3};\r
1312 statetype s_ubershoot3  = {false,SPR_UBER_SHOOT3,12,NULL,T_UShoot,&s_ubershoot4};\r
1313 statetype s_ubershoot4  = {false,SPR_UBER_SHOOT4,12,NULL,T_UShoot,&s_ubershoot5};\r
1314 statetype s_ubershoot5  = {false,SPR_UBER_SHOOT3,12,NULL,T_UShoot,&s_ubershoot6};\r
1315 statetype s_ubershoot6  = {false,SPR_UBER_SHOOT2,12,NULL,T_UShoot,&s_ubershoot7};\r
1316 statetype s_ubershoot7  = {false,SPR_UBER_SHOOT1,12,NULL,NULL,&s_uberchase1};\r
1317 \r
1318 \r
1319 /*\r
1320 ===============\r
1321 =\r
1322 = SpawnUber\r
1323 =\r
1324 ===============\r
1325 */\r
1326 \r
1327 void SpawnUber (int tilex, int tiley)\r
1328 {\r
1329         unsigned        far *map,tile;\r
1330 \r
1331         if (SoundBlasterPresent && DigiMode != sds_Off)\r
1332                 s_uberdie01.tictime = 70;\r
1333 \r
1334         SpawnNewObj (tilex,tiley,&s_uberstand);\r
1335         new->obclass = uberobj;\r
1336         new->hitpoints = starthitpoints[gamestate.difficulty][en_uber];\r
1337         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
1338         if (!loadedgame)\r
1339           gamestate.killtotal++;\r
1340 }\r
1341 \r
1342 \r
1343 /*\r
1344 ===============\r
1345 =\r
1346 = T_UShoot\r
1347 =\r
1348 ===============\r
1349 */\r
1350 \r
1351 void T_UShoot (objtype *ob)\r
1352 {\r
1353         int     dx,dy,dist;\r
1354 \r
1355         T_Shoot (ob);\r
1356 \r
1357         dx = abs(ob->tilex - player->tilex);\r
1358         dy = abs(ob->tiley - player->tiley);\r
1359         dist = dx>dy ? dx : dy;\r
1360         if (dist <= 1)\r
1361                 TakeDamage (10,ob);\r
1362 }\r
1363 \r
1364 \r
1365 //\r
1366 // will\r
1367 //\r
1368 extern  statetype s_willstand;\r
1369 \r
1370 extern  statetype s_willchase1;\r
1371 extern  statetype s_willchase1s;\r
1372 extern  statetype s_willchase2;\r
1373 extern  statetype s_willchase3;\r
1374 extern  statetype s_willchase3s;\r
1375 extern  statetype s_willchase4;\r
1376 \r
1377 extern  statetype s_willdie1;\r
1378 extern  statetype s_willdie2;\r
1379 extern  statetype s_willdie3;\r
1380 extern  statetype s_willdie4;\r
1381 extern  statetype s_willdie5;\r
1382 extern  statetype s_willdie6;\r
1383 \r
1384 extern  statetype s_willshoot1;\r
1385 extern  statetype s_willshoot2;\r
1386 extern  statetype s_willshoot3;\r
1387 extern  statetype s_willshoot4;\r
1388 extern  statetype s_willshoot5;\r
1389 extern  statetype s_willshoot6;\r
1390 \r
1391 \r
1392 statetype s_willstand   = {false,SPR_WILL_W1,0,T_Stand,NULL,&s_willstand};\r
1393 \r
1394 statetype s_willchase1  = {false,SPR_WILL_W1,10,T_Will,NULL,&s_willchase1s};\r
1395 statetype s_willchase1s = {false,SPR_WILL_W1,3,NULL,NULL,&s_willchase2};\r
1396 statetype s_willchase2  = {false,SPR_WILL_W2,8,T_Will,NULL,&s_willchase3};\r
1397 statetype s_willchase3  = {false,SPR_WILL_W3,10,T_Will,NULL,&s_willchase3s};\r
1398 statetype s_willchase3s = {false,SPR_WILL_W3,3,NULL,NULL,&s_willchase4};\r
1399 statetype s_willchase4  = {false,SPR_WILL_W4,8,T_Will,NULL,&s_willchase1};\r
1400 \r
1401 statetype s_willdeathcam        = {false,SPR_WILL_W1,1,NULL,NULL,&s_willdie1};\r
1402 \r
1403 statetype s_willdie1    = {false,SPR_WILL_W1,1,NULL,A_DeathScream,&s_willdie2};\r
1404 statetype s_willdie2    = {false,SPR_WILL_W1,10,NULL,NULL,&s_willdie3};\r
1405 statetype s_willdie3    = {false,SPR_WILL_DIE1,10,NULL,NULL,&s_willdie4};\r
1406 statetype s_willdie4    = {false,SPR_WILL_DIE2,10,NULL,NULL,&s_willdie5};\r
1407 statetype s_willdie5    = {false,SPR_WILL_DIE3,10,NULL,NULL,&s_willdie6};\r
1408 statetype s_willdie6    = {false,SPR_WILL_DEAD,20,NULL,NULL,&s_willdie6};\r
1409 \r
1410 statetype s_willshoot1  = {false,SPR_WILL_SHOOT1,30,NULL,NULL,&s_willshoot2};\r
1411 statetype s_willshoot2  = {false,SPR_WILL_SHOOT2,10,NULL,T_Launch,&s_willshoot3};\r
1412 statetype s_willshoot3  = {false,SPR_WILL_SHOOT3,10,NULL,T_Shoot,&s_willshoot4};\r
1413 statetype s_willshoot4  = {false,SPR_WILL_SHOOT4,10,NULL,T_Shoot,&s_willshoot5};\r
1414 statetype s_willshoot5  = {false,SPR_WILL_SHOOT3,10,NULL,T_Shoot,&s_willshoot6};\r
1415 statetype s_willshoot6  = {false,SPR_WILL_SHOOT4,10,NULL,T_Shoot,&s_willchase1};\r
1416 \r
1417 \r
1418 /*\r
1419 ===============\r
1420 =\r
1421 = SpawnWill\r
1422 =\r
1423 ===============\r
1424 */\r
1425 \r
1426 void SpawnWill (int tilex, int tiley)\r
1427 {\r
1428         unsigned        far *map,tile;\r
1429 \r
1430         if (SoundBlasterPresent && DigiMode != sds_Off)\r
1431                 s_willdie2.tictime = 70;\r
1432 \r
1433         SpawnNewObj (tilex,tiley,&s_willstand);\r
1434         new->obclass = willobj;\r
1435         new->hitpoints = starthitpoints[gamestate.difficulty][en_will];\r
1436         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
1437         if (!loadedgame)\r
1438           gamestate.killtotal++;\r
1439 }\r
1440 \r
1441 \r
1442 /*\r
1443 ================\r
1444 =\r
1445 = T_Will\r
1446 =\r
1447 ================\r
1448 */\r
1449 \r
1450 void T_Will (objtype *ob)\r
1451 {\r
1452         long move;\r
1453         int     dx,dy,dist;\r
1454         boolean dodge;\r
1455 \r
1456         dodge = false;\r
1457         dx = abs(ob->tilex - player->tilex);\r
1458         dy = abs(ob->tiley - player->tiley);\r
1459         dist = dx>dy ? dx : dy;\r
1460 \r
1461         if (CheckLine(ob))                                              // got a shot at player?\r
1462         {\r
1463                 if ( US_RndT() < (tics<<3) )\r
1464                 {\r
1465                 //\r
1466                 // go into attack frame\r
1467                 //\r
1468                         if (ob->obclass == willobj)\r
1469                                 NewState (ob,&s_willshoot1);\r
1470                         else if (ob->obclass == angelobj)\r
1471                                 NewState (ob,&s_angelshoot1);\r
1472                         else\r
1473                                 NewState (ob,&s_deathshoot1);\r
1474                         return;\r
1475                 }\r
1476                 dodge = true;\r
1477         }\r
1478 \r
1479         if (ob->dir == nodir)\r
1480         {\r
1481                 if (dodge)\r
1482                         SelectDodgeDir (ob);\r
1483                 else\r
1484                         SelectChaseDir (ob);\r
1485                 if (ob->dir == nodir)\r
1486                         return;                                                 // object is blocked in\r
1487         }\r
1488 \r
1489         move = ob->speed*tics;\r
1490 \r
1491         while (move)\r
1492         {\r
1493                 if (ob->distance < 0)\r
1494                 {\r
1495                 //\r
1496                 // waiting for a door to open\r
1497                 //\r
1498                         OpenDoor (-ob->distance-1);\r
1499                         if (doorobjlist[-ob->distance-1].action != dr_open)\r
1500                                 return;\r
1501                         ob->distance = TILEGLOBAL;      // go ahead, the door is now opoen\r
1502                 }\r
1503 \r
1504                 if (move < ob->distance)\r
1505                 {\r
1506                         MoveObj (ob,move);\r
1507                         break;\r
1508                 }\r
1509 \r
1510                 //\r
1511                 // reached goal tile, so select another one\r
1512                 //\r
1513 \r
1514                 //\r
1515                 // fix position to account for round off during moving\r
1516                 //\r
1517                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
1518                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
1519 \r
1520                 move -= ob->distance;\r
1521 \r
1522                 if (dist <4)\r
1523                         SelectRunDir (ob);\r
1524                 else if (dodge)\r
1525                         SelectDodgeDir (ob);\r
1526                 else\r
1527                         SelectChaseDir (ob);\r
1528 \r
1529                 if (ob->dir == nodir)\r
1530                         return;                                                 // object is blocked in\r
1531         }\r
1532 \r
1533 }\r
1534 \r
1535 \r
1536 //\r
1537 // death\r
1538 //\r
1539 extern  statetype s_deathstand;\r
1540 \r
1541 extern  statetype s_deathchase1;\r
1542 extern  statetype s_deathchase1s;\r
1543 extern  statetype s_deathchase2;\r
1544 extern  statetype s_deathchase3;\r
1545 extern  statetype s_deathchase3s;\r
1546 extern  statetype s_deathchase4;\r
1547 \r
1548 extern  statetype s_deathdie1;\r
1549 extern  statetype s_deathdie2;\r
1550 extern  statetype s_deathdie3;\r
1551 extern  statetype s_deathdie4;\r
1552 extern  statetype s_deathdie5;\r
1553 extern  statetype s_deathdie6;\r
1554 extern  statetype s_deathdie7;\r
1555 extern  statetype s_deathdie8;\r
1556 extern  statetype s_deathdie9;\r
1557 \r
1558 extern  statetype s_deathshoot1;\r
1559 extern  statetype s_deathshoot2;\r
1560 extern  statetype s_deathshoot3;\r
1561 extern  statetype s_deathshoot4;\r
1562 extern  statetype s_deathshoot5;\r
1563 \r
1564 \r
1565 statetype s_deathstand  = {false,SPR_DEATH_W1,0,T_Stand,NULL,&s_deathstand};\r
1566 \r
1567 statetype s_deathchase1         = {false,SPR_DEATH_W1,10,T_Will,NULL,&s_deathchase1s};\r
1568 statetype s_deathchase1s        = {false,SPR_DEATH_W1,3,NULL,NULL,&s_deathchase2};\r
1569 statetype s_deathchase2         = {false,SPR_DEATH_W2,8,T_Will,NULL,&s_deathchase3};\r
1570 statetype s_deathchase3         = {false,SPR_DEATH_W3,10,T_Will,NULL,&s_deathchase3s};\r
1571 statetype s_deathchase3s        = {false,SPR_DEATH_W3,3,NULL,NULL,&s_deathchase4};\r
1572 statetype s_deathchase4         = {false,SPR_DEATH_W4,8,T_Will,NULL,&s_deathchase1};\r
1573 \r
1574 statetype s_deathdeathcam       = {false,SPR_DEATH_W1,1,NULL,NULL,&s_deathdie1};\r
1575 \r
1576 statetype s_deathdie1   = {false,SPR_DEATH_W1,1,NULL,A_DeathScream,&s_deathdie2};\r
1577 statetype s_deathdie2   = {false,SPR_DEATH_W1,10,NULL,NULL,&s_deathdie3};\r
1578 statetype s_deathdie3   = {false,SPR_DEATH_DIE1,10,NULL,NULL,&s_deathdie4};\r
1579 statetype s_deathdie4   = {false,SPR_DEATH_DIE2,10,NULL,NULL,&s_deathdie5};\r
1580 statetype s_deathdie5   = {false,SPR_DEATH_DIE3,10,NULL,NULL,&s_deathdie6};\r
1581 statetype s_deathdie6   = {false,SPR_DEATH_DIE4,10,NULL,NULL,&s_deathdie7};\r
1582 statetype s_deathdie7   = {false,SPR_DEATH_DIE5,10,NULL,NULL,&s_deathdie8};\r
1583 statetype s_deathdie8   = {false,SPR_DEATH_DIE6,10,NULL,NULL,&s_deathdie9};\r
1584 statetype s_deathdie9   = {false,SPR_DEATH_DEAD,0,NULL,NULL,&s_deathdie9};\r
1585 \r
1586 statetype s_deathshoot1         = {false,SPR_DEATH_SHOOT1,30,NULL,NULL,&s_deathshoot2};\r
1587 statetype s_deathshoot2         = {false,SPR_DEATH_SHOOT2,10,NULL,T_Launch,&s_deathshoot3};\r
1588 statetype s_deathshoot3         = {false,SPR_DEATH_SHOOT4,10,NULL,T_Shoot,&s_deathshoot4};\r
1589 statetype s_deathshoot4         = {false,SPR_DEATH_SHOOT3,10,NULL,T_Launch,&s_deathshoot5};\r
1590 statetype s_deathshoot5         = {false,SPR_DEATH_SHOOT4,10,NULL,T_Shoot,&s_deathchase1};\r
1591 \r
1592 \r
1593 /*\r
1594 ===============\r
1595 =\r
1596 = SpawnDeath\r
1597 =\r
1598 ===============\r
1599 */\r
1600 \r
1601 void SpawnDeath (int tilex, int tiley)\r
1602 {\r
1603         unsigned        far *map,tile;\r
1604 \r
1605         if (SoundBlasterPresent && DigiMode != sds_Off)\r
1606                 s_deathdie2.tictime = 105;\r
1607 \r
1608         SpawnNewObj (tilex,tiley,&s_deathstand);\r
1609         new->obclass = deathobj;\r
1610         new->hitpoints = starthitpoints[gamestate.difficulty][en_death];\r
1611         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
1612         if (!loadedgame)\r
1613           gamestate.killtotal++;\r
1614 }\r
1615 \r
1616 /*\r
1617 ===============\r
1618 =\r
1619 = T_Launch\r
1620 =\r
1621 ===============\r
1622 */\r
1623 \r
1624 void T_Launch (objtype *ob)\r
1625 {\r
1626         long    deltax,deltay;\r
1627         float   angle;\r
1628         int             iangle;\r
1629 \r
1630         deltax = player->x - ob->x;\r
1631         deltay = ob->y - player->y;\r
1632         angle = atan2 (deltay,deltax);\r
1633         if (angle<0)\r
1634                 angle = M_PI*2+angle;\r
1635         iangle = angle/(M_PI*2)*ANGLES;\r
1636         if (ob->obclass == deathobj)\r
1637         {\r
1638                 T_Shoot (ob);\r
1639                 if (ob->state == &s_deathshoot2)\r
1640                 {\r
1641                         iangle-=4;\r
1642                         if (iangle<0)\r
1643                                 iangle+=ANGLES;\r
1644                 }\r
1645                 else\r
1646                 {\r
1647                         iangle+=4;\r
1648                         if (iangle>=ANGLES)\r
1649                                 iangle-=ANGLES;\r
1650                 }\r
1651         }\r
1652 \r
1653         GetNewActor ();\r
1654         new->state = &s_rocket;\r
1655         new->ticcount = 1;\r
1656 \r
1657         new->tilex = ob->tilex;\r
1658         new->tiley = ob->tiley;\r
1659         new->x = ob->x;\r
1660         new->y = ob->y;\r
1661         new->obclass = rocketobj;\r
1662         switch(ob->obclass)\r
1663         {\r
1664         case deathobj:\r
1665                 new->state = &s_hrocket;\r
1666                 new->obclass = hrocketobj;\r
1667                 PlaySoundLocActor (KNIGHTMISSILESND,new);\r
1668                 break;\r
1669         case angelobj:\r
1670                 new->state = &s_spark1;\r
1671                 new->obclass = sparkobj;\r
1672                 PlaySoundLocActor (ANGELFIRESND,new);\r
1673                 break;\r
1674         default:\r
1675                 PlaySoundLocActor (MISSILEFIRESND,new);\r
1676         }\r
1677 \r
1678         new->dir = nodir;\r
1679         new->angle = iangle;\r
1680         new->speed = 0x2000l;\r
1681         new->flags = FL_NONMARK;\r
1682         new->active = true;\r
1683 }\r
1684 \r
1685 \r
1686 \r
1687 //\r
1688 // angel\r
1689 //\r
1690 void A_Relaunch (objtype *ob);\r
1691 void A_Victory (objtype *ob);\r
1692 void A_StartAttack (objtype *ob);\r
1693 void A_Breathing (objtype *ob);\r
1694 \r
1695 extern  statetype s_angelstand;\r
1696 \r
1697 extern  statetype s_angelchase1;\r
1698 extern  statetype s_angelchase1s;\r
1699 extern  statetype s_angelchase2;\r
1700 extern  statetype s_angelchase3;\r
1701 extern  statetype s_angelchase3s;\r
1702 extern  statetype s_angelchase4;\r
1703 \r
1704 extern  statetype s_angeldie1;\r
1705 extern  statetype s_angeldie11;\r
1706 extern  statetype s_angeldie2;\r
1707 extern  statetype s_angeldie3;\r
1708 extern  statetype s_angeldie4;\r
1709 extern  statetype s_angeldie5;\r
1710 extern  statetype s_angeldie6;\r
1711 extern  statetype s_angeldie7;\r
1712 extern  statetype s_angeldie8;\r
1713 extern  statetype s_angeldie9;\r
1714 \r
1715 extern  statetype s_angelshoot1;\r
1716 extern  statetype s_angelshoot2;\r
1717 extern  statetype s_angelshoot3;\r
1718 extern  statetype s_angelshoot4;\r
1719 extern  statetype s_angelshoot5;\r
1720 extern  statetype s_angelshoot6;\r
1721 \r
1722 extern  statetype s_angeltired;\r
1723 extern  statetype s_angeltired2;\r
1724 extern  statetype s_angeltired3;\r
1725 extern  statetype s_angeltired4;\r
1726 extern  statetype s_angeltired5;\r
1727 extern  statetype s_angeltired6;\r
1728 extern  statetype s_angeltired7;\r
1729 \r
1730 extern  statetype s_spark1;\r
1731 extern  statetype s_spark2;\r
1732 extern  statetype s_spark3;\r
1733 extern  statetype s_spark4;\r
1734 \r
1735 \r
1736 statetype s_angelstand  = {false,SPR_ANGEL_W1,0,T_Stand,NULL,&s_angelstand};\r
1737 \r
1738 statetype s_angelchase1         = {false,SPR_ANGEL_W1,10,T_Will,NULL,&s_angelchase1s};\r
1739 statetype s_angelchase1s        = {false,SPR_ANGEL_W1,3,NULL,NULL,&s_angelchase2};\r
1740 statetype s_angelchase2         = {false,SPR_ANGEL_W2,8,T_Will,NULL,&s_angelchase3};\r
1741 statetype s_angelchase3         = {false,SPR_ANGEL_W3,10,T_Will,NULL,&s_angelchase3s};\r
1742 statetype s_angelchase3s        = {false,SPR_ANGEL_W3,3,NULL,NULL,&s_angelchase4};\r
1743 statetype s_angelchase4         = {false,SPR_ANGEL_W4,8,T_Will,NULL,&s_angelchase1};\r
1744 \r
1745 statetype s_angeldie1   = {false,SPR_ANGEL_W1,1,NULL,A_DeathScream,&s_angeldie11};\r
1746 statetype s_angeldie11  = {false,SPR_ANGEL_W1,1,NULL,NULL,&s_angeldie2};\r
1747 statetype s_angeldie2   = {false,SPR_ANGEL_DIE1,10,NULL,A_Slurpie,&s_angeldie3};\r
1748 statetype s_angeldie3   = {false,SPR_ANGEL_DIE2,10,NULL,NULL,&s_angeldie4};\r
1749 statetype s_angeldie4   = {false,SPR_ANGEL_DIE3,10,NULL,NULL,&s_angeldie5};\r
1750 statetype s_angeldie5   = {false,SPR_ANGEL_DIE4,10,NULL,NULL,&s_angeldie6};\r
1751 statetype s_angeldie6   = {false,SPR_ANGEL_DIE5,10,NULL,NULL,&s_angeldie7};\r
1752 statetype s_angeldie7   = {false,SPR_ANGEL_DIE6,10,NULL,NULL,&s_angeldie8};\r
1753 statetype s_angeldie8   = {false,SPR_ANGEL_DIE7,10,NULL,NULL,&s_angeldie9};\r
1754 statetype s_angeldie9   = {false,SPR_ANGEL_DEAD,130,NULL,A_Victory,&s_angeldie9};\r
1755 \r
1756 statetype s_angelshoot1         = {false,SPR_ANGEL_SHOOT1,10,NULL,A_StartAttack,&s_angelshoot2};\r
1757 statetype s_angelshoot2         = {false,SPR_ANGEL_SHOOT2,20,NULL,T_Launch,&s_angelshoot3};\r
1758 statetype s_angelshoot3         = {false,SPR_ANGEL_SHOOT1,10,NULL,A_Relaunch,&s_angelshoot2};\r
1759 \r
1760 statetype s_angeltired  = {false,SPR_ANGEL_TIRED1,40,NULL,A_Breathing,&s_angeltired2};\r
1761 statetype s_angeltired2 = {false,SPR_ANGEL_TIRED2,40,NULL,NULL,&s_angeltired3};\r
1762 statetype s_angeltired3 = {false,SPR_ANGEL_TIRED1,40,NULL,A_Breathing,&s_angeltired4};\r
1763 statetype s_angeltired4 = {false,SPR_ANGEL_TIRED2,40,NULL,NULL,&s_angeltired5};\r
1764 statetype s_angeltired5 = {false,SPR_ANGEL_TIRED1,40,NULL,A_Breathing,&s_angeltired6};\r
1765 statetype s_angeltired6 = {false,SPR_ANGEL_TIRED2,40,NULL,NULL,&s_angeltired7};\r
1766 statetype s_angeltired7 = {false,SPR_ANGEL_TIRED1,40,NULL,A_Breathing,&s_angelchase1};\r
1767 \r
1768 statetype s_spark1      = {false,SPR_SPARK1,6,T_Projectile,NULL,&s_spark2};\r
1769 statetype s_spark2      = {false,SPR_SPARK2,6,T_Projectile,NULL,&s_spark3};\r
1770 statetype s_spark3      = {false,SPR_SPARK3,6,T_Projectile,NULL,&s_spark4};\r
1771 statetype s_spark4      = {false,SPR_SPARK4,6,T_Projectile,NULL,&s_spark1};\r
1772 \r
1773 \r
1774 #pragma argsused\r
1775 void A_Slurpie (objtype *ob)\r
1776 {\r
1777  SD_PlaySound(SLURPIESND);\r
1778 }\r
1779 \r
1780 #pragma argsused\r
1781 void A_Breathing (objtype *ob)\r
1782 {\r
1783  SD_PlaySound(ANGELTIREDSND);\r
1784 }\r
1785 \r
1786 /*\r
1787 ===============\r
1788 =\r
1789 = SpawnAngel\r
1790 =\r
1791 ===============\r
1792 */\r
1793 \r
1794 void SpawnAngel (int tilex, int tiley)\r
1795 {\r
1796         unsigned        far *map,tile;\r
1797 \r
1798 \r
1799         if (SoundBlasterPresent && DigiMode != sds_Off)\r
1800                 s_angeldie11.tictime = 105;\r
1801 \r
1802         SpawnNewObj (tilex,tiley,&s_angelstand);\r
1803         new->obclass = angelobj;\r
1804         new->hitpoints = starthitpoints[gamestate.difficulty][en_angel];\r
1805         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
1806         if (!loadedgame)\r
1807           gamestate.killtotal++;\r
1808 }\r
1809 \r
1810 \r
1811 /*\r
1812 =================\r
1813 =\r
1814 = A_Victory\r
1815 =\r
1816 =================\r
1817 */\r
1818 \r
1819 #pragma argsused\r
1820 void A_Victory (objtype *ob)\r
1821 {\r
1822         playstate = ex_victorious;\r
1823 }\r
1824 \r
1825 \r
1826 /*\r
1827 =================\r
1828 =\r
1829 = A_StartAttack\r
1830 =\r
1831 =================\r
1832 */\r
1833 \r
1834 void A_StartAttack (objtype *ob)\r
1835 {\r
1836         ob->temp1 = 0;\r
1837 }\r
1838 \r
1839 \r
1840 /*\r
1841 =================\r
1842 =\r
1843 = A_Relaunch\r
1844 =\r
1845 =================\r
1846 */\r
1847 \r
1848 void A_Relaunch (objtype *ob)\r
1849 {\r
1850         if (++ob->temp1 == 3)\r
1851         {\r
1852                 NewState (ob,&s_angeltired);\r
1853                 return;\r
1854         }\r
1855 \r
1856         if (US_RndT()&1)\r
1857         {\r
1858                 NewState (ob,&s_angelchase1);\r
1859                 return;\r
1860         }\r
1861 }\r
1862 \r
1863 \r
1864 \r
1865 \r
1866 //\r
1867 // spectre\r
1868 //\r
1869 void T_SpectreWait (objtype *ob);\r
1870 void A_Dormant (objtype *ob);\r
1871 \r
1872 extern  statetype s_spectrewait1;\r
1873 extern  statetype s_spectrewait2;\r
1874 extern  statetype s_spectrewait3;\r
1875 extern  statetype s_spectrewait4;\r
1876 \r
1877 extern  statetype s_spectrechase1;\r
1878 extern  statetype s_spectrechase2;\r
1879 extern  statetype s_spectrechase3;\r
1880 extern  statetype s_spectrechase4;\r
1881 \r
1882 extern  statetype s_spectredie1;\r
1883 extern  statetype s_spectredie2;\r
1884 extern  statetype s_spectredie3;\r
1885 extern  statetype s_spectredie4;\r
1886 \r
1887 extern  statetype s_spectrewake;\r
1888 \r
1889 statetype s_spectrewait1        = {false,SPR_SPECTRE_W1,10,T_Stand,NULL,&s_spectrewait2};\r
1890 statetype s_spectrewait2        = {false,SPR_SPECTRE_W2,10,T_Stand,NULL,&s_spectrewait3};\r
1891 statetype s_spectrewait3        = {false,SPR_SPECTRE_W3,10,T_Stand,NULL,&s_spectrewait4};\r
1892 statetype s_spectrewait4        = {false,SPR_SPECTRE_W4,10,T_Stand,NULL,&s_spectrewait1};\r
1893 \r
1894 statetype s_spectrechase1       = {false,SPR_SPECTRE_W1,10,T_Ghosts,NULL,&s_spectrechase2};\r
1895 statetype s_spectrechase2       = {false,SPR_SPECTRE_W2,10,T_Ghosts,NULL,&s_spectrechase3};\r
1896 statetype s_spectrechase3       = {false,SPR_SPECTRE_W3,10,T_Ghosts,NULL,&s_spectrechase4};\r
1897 statetype s_spectrechase4       = {false,SPR_SPECTRE_W4,10,T_Ghosts,NULL,&s_spectrechase1};\r
1898 \r
1899 statetype s_spectredie1 = {false,SPR_SPECTRE_F1,10,NULL,NULL,&s_spectredie2};\r
1900 statetype s_spectredie2 = {false,SPR_SPECTRE_F2,10,NULL,NULL,&s_spectredie3};\r
1901 statetype s_spectredie3 = {false,SPR_SPECTRE_F3,10,NULL,NULL,&s_spectredie4};\r
1902 statetype s_spectredie4 = {false,SPR_SPECTRE_F4,300,NULL,NULL,&s_spectrewake};\r
1903 statetype s_spectrewake = {false,SPR_SPECTRE_F4,10,NULL,A_Dormant,&s_spectrewake};\r
1904 \r
1905 /*\r
1906 ===============\r
1907 =\r
1908 = SpawnSpectre\r
1909 =\r
1910 ===============\r
1911 */\r
1912 \r
1913 void SpawnSpectre (int tilex, int tiley)\r
1914 {\r
1915         unsigned        far *map,tile;\r
1916 \r
1917         SpawnNewObj (tilex,tiley,&s_spectrewait1);\r
1918         new->obclass = spectreobj;\r
1919         new->hitpoints = starthitpoints[gamestate.difficulty][en_spectre];\r
1920         new->flags |= FL_SHOOTABLE|FL_AMBUSH; // |FL_NEVERMARK|FL_NONMARK;\r
1921         if (!loadedgame)\r
1922           gamestate.killtotal++;\r
1923 }\r
1924 \r
1925 \r
1926 /*\r
1927 ===============\r
1928 =\r
1929 = A_Dormant\r
1930 =\r
1931 ===============\r
1932 */\r
1933 \r
1934 void A_Dormant (objtype *ob)\r
1935 {\r
1936         long    deltax,deltay;\r
1937         int     xl,xh,yl,yh;\r
1938         int     x,y;\r
1939         objtype *tile;\r
1940 \r
1941         deltax = ob->x - player->x;\r
1942         if (deltax < -MINACTORDIST || deltax > MINACTORDIST)\r
1943                 goto moveok;\r
1944         deltay = ob->y - player->y;\r
1945         if (deltay < -MINACTORDIST || deltay > MINACTORDIST)\r
1946                 goto moveok;\r
1947 \r
1948         return;\r
1949 moveok:\r
1950 \r
1951         xl = (ob->x-MINDIST) >> TILESHIFT;\r
1952         xh = (ob->x+MINDIST) >> TILESHIFT;\r
1953         yl = (ob->y-MINDIST) >> TILESHIFT;\r
1954         yh = (ob->y+MINDIST) >> TILESHIFT;\r
1955 \r
1956         for (y=yl ; y<=yh ; y++)\r
1957                 for (x=xl ; x<=xh ; x++)\r
1958                 {\r
1959                         tile = actorat[x][y];\r
1960                         if (!tile)\r
1961                                 continue;\r
1962                         if (tile && tile<objlist)\r
1963                                 return;\r
1964                         if (((objtype *)tile)->flags&FL_SHOOTABLE)\r
1965                                 return;\r
1966                 }\r
1967 \r
1968         ob->flags |= FL_AMBUSH | FL_SHOOTABLE;\r
1969         ob->flags &= ~FL_ATTACKMODE;\r
1970         ob->dir = nodir;\r
1971         NewState (ob,&s_spectrewait1);\r
1972 }\r
1973 \r
1974 \r
1975 #endif\r
1976 \r
1977 /*\r
1978 =============================================================================\r
1979 \r
1980                                                  SCHABBS / GIFT / FAT\r
1981 \r
1982 =============================================================================\r
1983 */\r
1984 \r
1985 #ifndef SPEAR\r
1986 /*\r
1987 ===============\r
1988 =\r
1989 = SpawnGhosts\r
1990 =\r
1991 ===============\r
1992 */\r
1993 \r
1994 void SpawnGhosts (int which, int tilex, int tiley)\r
1995 {\r
1996         unsigned        far *map,tile;\r
1997 \r
1998         switch(which)\r
1999         {\r
2000          case en_blinky:\r
2001            SpawnNewObj (tilex,tiley,&s_blinkychase1);\r
2002            break;\r
2003          case en_clyde:\r
2004            SpawnNewObj (tilex,tiley,&s_clydechase1);\r
2005            break;\r
2006          case en_pinky:\r
2007            SpawnNewObj (tilex,tiley,&s_pinkychase1);\r
2008            break;\r
2009          case en_inky:\r
2010            SpawnNewObj (tilex,tiley,&s_inkychase1);\r
2011            break;\r
2012         }\r
2013 \r
2014         new->obclass = ghostobj;\r
2015         new->speed = SPDDOG;\r
2016 \r
2017         new->dir = east;\r
2018         new->flags |= FL_AMBUSH;\r
2019         if (!loadedgame)\r
2020           gamestate.killtotal++;\r
2021 }\r
2022 \r
2023 \r
2024 \r
2025 void    T_Gift (objtype *ob);\r
2026 void    T_GiftThrow (objtype *ob);\r
2027 \r
2028 void    T_Fat (objtype *ob);\r
2029 void    T_FatThrow (objtype *ob);\r
2030 \r
2031 //\r
2032 // schabb\r
2033 //\r
2034 extern  statetype s_schabbstand;\r
2035 \r
2036 extern  statetype s_schabbchase1;\r
2037 extern  statetype s_schabbchase1s;\r
2038 extern  statetype s_schabbchase2;\r
2039 extern  statetype s_schabbchase3;\r
2040 extern  statetype s_schabbchase3s;\r
2041 extern  statetype s_schabbchase4;\r
2042 \r
2043 extern  statetype s_schabbdie1;\r
2044 extern  statetype s_schabbdie2;\r
2045 extern  statetype s_schabbdie3;\r
2046 extern  statetype s_schabbdie4;\r
2047 extern  statetype s_schabbdie5;\r
2048 extern  statetype s_schabbdie6;\r
2049 \r
2050 extern  statetype s_schabbshoot1;\r
2051 extern  statetype s_schabbshoot2;\r
2052 \r
2053 extern  statetype s_needle1;\r
2054 extern  statetype s_needle2;\r
2055 extern  statetype s_needle3;\r
2056 extern  statetype s_needle4;\r
2057 \r
2058 extern  statetype s_schabbdeathcam;\r
2059 \r
2060 \r
2061 statetype s_schabbstand = {false,SPR_SCHABB_W1,0,T_Stand,NULL,&s_schabbstand};\r
2062 \r
2063 statetype s_schabbchase1        = {false,SPR_SCHABB_W1,10,T_Schabb,NULL,&s_schabbchase1s};\r
2064 statetype s_schabbchase1s       = {false,SPR_SCHABB_W1,3,NULL,NULL,&s_schabbchase2};\r
2065 statetype s_schabbchase2        = {false,SPR_SCHABB_W2,8,T_Schabb,NULL,&s_schabbchase3};\r
2066 statetype s_schabbchase3        = {false,SPR_SCHABB_W3,10,T_Schabb,NULL,&s_schabbchase3s};\r
2067 statetype s_schabbchase3s       = {false,SPR_SCHABB_W3,3,NULL,NULL,&s_schabbchase4};\r
2068 statetype s_schabbchase4        = {false,SPR_SCHABB_W4,8,T_Schabb,NULL,&s_schabbchase1};\r
2069 \r
2070 statetype s_schabbdeathcam      = {false,SPR_SCHABB_W1,1,NULL,NULL,&s_schabbdie1};\r
2071 \r
2072 statetype s_schabbdie1  = {false,SPR_SCHABB_W1,10,NULL,A_DeathScream,&s_schabbdie2};\r
2073 statetype s_schabbdie2  = {false,SPR_SCHABB_W1,10,NULL,NULL,&s_schabbdie3};\r
2074 statetype s_schabbdie3  = {false,SPR_SCHABB_DIE1,10,NULL,NULL,&s_schabbdie4};\r
2075 statetype s_schabbdie4  = {false,SPR_SCHABB_DIE2,10,NULL,NULL,&s_schabbdie5};\r
2076 statetype s_schabbdie5  = {false,SPR_SCHABB_DIE3,10,NULL,NULL,&s_schabbdie6};\r
2077 statetype s_schabbdie6  = {false,SPR_SCHABB_DEAD,20,NULL,A_StartDeathCam,&s_schabbdie6};\r
2078 \r
2079 statetype s_schabbshoot1        = {false,SPR_SCHABB_SHOOT1,30,NULL,NULL,&s_schabbshoot2};\r
2080 statetype s_schabbshoot2        = {false,SPR_SCHABB_SHOOT2,10,NULL,T_SchabbThrow,&s_schabbchase1};\r
2081 \r
2082 statetype s_needle1     = {false,SPR_HYPO1,6,T_Projectile,NULL,&s_needle2};\r
2083 statetype s_needle2     = {false,SPR_HYPO2,6,T_Projectile,NULL,&s_needle3};\r
2084 statetype s_needle3     = {false,SPR_HYPO3,6,T_Projectile,NULL,&s_needle4};\r
2085 statetype s_needle4     = {false,SPR_HYPO4,6,T_Projectile,NULL,&s_needle1};\r
2086 \r
2087 \r
2088 //\r
2089 // gift\r
2090 //\r
2091 extern  statetype s_giftstand;\r
2092 \r
2093 extern  statetype s_giftchase1;\r
2094 extern  statetype s_giftchase1s;\r
2095 extern  statetype s_giftchase2;\r
2096 extern  statetype s_giftchase3;\r
2097 extern  statetype s_giftchase3s;\r
2098 extern  statetype s_giftchase4;\r
2099 \r
2100 extern  statetype s_giftdie1;\r
2101 extern  statetype s_giftdie2;\r
2102 extern  statetype s_giftdie3;\r
2103 extern  statetype s_giftdie4;\r
2104 extern  statetype s_giftdie5;\r
2105 extern  statetype s_giftdie6;\r
2106 \r
2107 extern  statetype s_giftshoot1;\r
2108 extern  statetype s_giftshoot2;\r
2109 \r
2110 extern  statetype s_needle1;\r
2111 extern  statetype s_needle2;\r
2112 extern  statetype s_needle3;\r
2113 extern  statetype s_needle4;\r
2114 \r
2115 extern  statetype s_giftdeathcam;\r
2116 \r
2117 extern  statetype s_boom1;\r
2118 extern  statetype s_boom2;\r
2119 extern  statetype s_boom3;\r
2120 \r
2121 \r
2122 statetype s_giftstand   = {false,SPR_GIFT_W1,0,T_Stand,NULL,&s_giftstand};\r
2123 \r
2124 statetype s_giftchase1  = {false,SPR_GIFT_W1,10,T_Gift,NULL,&s_giftchase1s};\r
2125 statetype s_giftchase1s = {false,SPR_GIFT_W1,3,NULL,NULL,&s_giftchase2};\r
2126 statetype s_giftchase2  = {false,SPR_GIFT_W2,8,T_Gift,NULL,&s_giftchase3};\r
2127 statetype s_giftchase3  = {false,SPR_GIFT_W3,10,T_Gift,NULL,&s_giftchase3s};\r
2128 statetype s_giftchase3s = {false,SPR_GIFT_W3,3,NULL,NULL,&s_giftchase4};\r
2129 statetype s_giftchase4  = {false,SPR_GIFT_W4,8,T_Gift,NULL,&s_giftchase1};\r
2130 \r
2131 statetype s_giftdeathcam        = {false,SPR_GIFT_W1,1,NULL,NULL,&s_giftdie1};\r
2132 \r
2133 statetype s_giftdie1    = {false,SPR_GIFT_W1,1,NULL,A_DeathScream,&s_giftdie2};\r
2134 statetype s_giftdie2    = {false,SPR_GIFT_W1,10,NULL,NULL,&s_giftdie3};\r
2135 statetype s_giftdie3    = {false,SPR_GIFT_DIE1,10,NULL,NULL,&s_giftdie4};\r
2136 statetype s_giftdie4    = {false,SPR_GIFT_DIE2,10,NULL,NULL,&s_giftdie5};\r
2137 statetype s_giftdie5    = {false,SPR_GIFT_DIE3,10,NULL,NULL,&s_giftdie6};\r
2138 statetype s_giftdie6    = {false,SPR_GIFT_DEAD,20,NULL,A_StartDeathCam,&s_giftdie6};\r
2139 \r
2140 statetype s_giftshoot1  = {false,SPR_GIFT_SHOOT1,30,NULL,NULL,&s_giftshoot2};\r
2141 statetype s_giftshoot2  = {false,SPR_GIFT_SHOOT2,10,NULL,T_GiftThrow,&s_giftchase1};\r
2142 \r
2143 \r
2144 //\r
2145 // fat\r
2146 //\r
2147 extern  statetype s_fatstand;\r
2148 \r
2149 extern  statetype s_fatchase1;\r
2150 extern  statetype s_fatchase1s;\r
2151 extern  statetype s_fatchase2;\r
2152 extern  statetype s_fatchase3;\r
2153 extern  statetype s_fatchase3s;\r
2154 extern  statetype s_fatchase4;\r
2155 \r
2156 extern  statetype s_fatdie1;\r
2157 extern  statetype s_fatdie2;\r
2158 extern  statetype s_fatdie3;\r
2159 extern  statetype s_fatdie4;\r
2160 extern  statetype s_fatdie5;\r
2161 extern  statetype s_fatdie6;\r
2162 \r
2163 extern  statetype s_fatshoot1;\r
2164 extern  statetype s_fatshoot2;\r
2165 extern  statetype s_fatshoot3;\r
2166 extern  statetype s_fatshoot4;\r
2167 extern  statetype s_fatshoot5;\r
2168 extern  statetype s_fatshoot6;\r
2169 \r
2170 extern  statetype s_needle1;\r
2171 extern  statetype s_needle2;\r
2172 extern  statetype s_needle3;\r
2173 extern  statetype s_needle4;\r
2174 \r
2175 extern  statetype s_fatdeathcam;\r
2176 \r
2177 \r
2178 statetype s_fatstand    = {false,SPR_FAT_W1,0,T_Stand,NULL,&s_fatstand};\r
2179 \r
2180 statetype s_fatchase1   = {false,SPR_FAT_W1,10,T_Fat,NULL,&s_fatchase1s};\r
2181 statetype s_fatchase1s  = {false,SPR_FAT_W1,3,NULL,NULL,&s_fatchase2};\r
2182 statetype s_fatchase2   = {false,SPR_FAT_W2,8,T_Fat,NULL,&s_fatchase3};\r
2183 statetype s_fatchase3   = {false,SPR_FAT_W3,10,T_Fat,NULL,&s_fatchase3s};\r
2184 statetype s_fatchase3s  = {false,SPR_FAT_W3,3,NULL,NULL,&s_fatchase4};\r
2185 statetype s_fatchase4   = {false,SPR_FAT_W4,8,T_Fat,NULL,&s_fatchase1};\r
2186 \r
2187 statetype s_fatdeathcam = {false,SPR_FAT_W1,1,NULL,NULL,&s_fatdie1};\r
2188 \r
2189 statetype s_fatdie1     = {false,SPR_FAT_W1,1,NULL,A_DeathScream,&s_fatdie2};\r
2190 statetype s_fatdie2     = {false,SPR_FAT_W1,10,NULL,NULL,&s_fatdie3};\r
2191 statetype s_fatdie3     = {false,SPR_FAT_DIE1,10,NULL,NULL,&s_fatdie4};\r
2192 statetype s_fatdie4     = {false,SPR_FAT_DIE2,10,NULL,NULL,&s_fatdie5};\r
2193 statetype s_fatdie5     = {false,SPR_FAT_DIE3,10,NULL,NULL,&s_fatdie6};\r
2194 statetype s_fatdie6     = {false,SPR_FAT_DEAD,20,NULL,A_StartDeathCam,&s_fatdie6};\r
2195 \r
2196 statetype s_fatshoot1   = {false,SPR_FAT_SHOOT1,30,NULL,NULL,&s_fatshoot2};\r
2197 statetype s_fatshoot2   = {false,SPR_FAT_SHOOT2,10,NULL,T_GiftThrow,&s_fatshoot3};\r
2198 statetype s_fatshoot3   = {false,SPR_FAT_SHOOT3,10,NULL,T_Shoot,&s_fatshoot4};\r
2199 statetype s_fatshoot4   = {false,SPR_FAT_SHOOT4,10,NULL,T_Shoot,&s_fatshoot5};\r
2200 statetype s_fatshoot5   = {false,SPR_FAT_SHOOT3,10,NULL,T_Shoot,&s_fatshoot6};\r
2201 statetype s_fatshoot6   = {false,SPR_FAT_SHOOT4,10,NULL,T_Shoot,&s_fatchase1};\r
2202 \r
2203 \r
2204 /*\r
2205 ===============\r
2206 =\r
2207 = SpawnSchabbs\r
2208 =\r
2209 ===============\r
2210 */\r
2211 \r
2212 void SpawnSchabbs (int tilex, int tiley)\r
2213 {\r
2214         unsigned        far *map,tile;\r
2215 \r
2216         if (DigiMode != sds_Off)\r
2217                 s_schabbdie2.tictime = 140;\r
2218         else\r
2219                 s_schabbdie2.tictime = 5;\r
2220 \r
2221         SpawnNewObj (tilex,tiley,&s_schabbstand);\r
2222         new->speed = SPDPATROL;\r
2223 \r
2224         new->obclass = schabbobj;\r
2225         new->hitpoints = starthitpoints[gamestate.difficulty][en_schabbs];\r
2226         new->dir = south;\r
2227         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
2228         if (!loadedgame)\r
2229           gamestate.killtotal++;\r
2230 }\r
2231 \r
2232 \r
2233 /*\r
2234 ===============\r
2235 =\r
2236 = SpawnGift\r
2237 =\r
2238 ===============\r
2239 */\r
2240 \r
2241 void SpawnGift (int tilex, int tiley)\r
2242 {\r
2243         unsigned        far *map,tile;\r
2244 \r
2245         if (DigiMode != sds_Off)\r
2246           s_giftdie2.tictime = 140;\r
2247         else\r
2248           s_giftdie2.tictime = 5;\r
2249 \r
2250         SpawnNewObj (tilex,tiley,&s_giftstand);\r
2251         new->speed = SPDPATROL;\r
2252 \r
2253         new->obclass = giftobj;\r
2254         new->hitpoints = starthitpoints[gamestate.difficulty][en_gift];\r
2255         new->dir = north;\r
2256         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
2257         if (!loadedgame)\r
2258           gamestate.killtotal++;\r
2259 }\r
2260 \r
2261 \r
2262 /*\r
2263 ===============\r
2264 =\r
2265 = SpawnFat\r
2266 =\r
2267 ===============\r
2268 */\r
2269 \r
2270 void SpawnFat (int tilex, int tiley)\r
2271 {\r
2272         unsigned        far *map,tile;\r
2273 \r
2274         if (DigiMode != sds_Off)\r
2275           s_fatdie2.tictime = 140;\r
2276         else\r
2277           s_fatdie2.tictime = 5;\r
2278 \r
2279         SpawnNewObj (tilex,tiley,&s_fatstand);\r
2280         new->speed = SPDPATROL;\r
2281 \r
2282         new->obclass = fatobj;\r
2283         new->hitpoints = starthitpoints[gamestate.difficulty][en_fat];\r
2284         new->dir = south;\r
2285         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
2286         if (!loadedgame)\r
2287           gamestate.killtotal++;\r
2288 }\r
2289 \r
2290 \r
2291 /*\r
2292 =================\r
2293 =\r
2294 = T_SchabbThrow\r
2295 =\r
2296 =================\r
2297 */\r
2298 \r
2299 void T_SchabbThrow (objtype *ob)\r
2300 {\r
2301         long    deltax,deltay;\r
2302         float   angle;\r
2303         int             iangle;\r
2304 \r
2305         deltax = player->x - ob->x;\r
2306         deltay = ob->y - player->y;\r
2307         angle = atan2 (deltay,deltax);\r
2308         if (angle<0)\r
2309                 angle = M_PI*2+angle;\r
2310         iangle = angle/(M_PI*2)*ANGLES;\r
2311 \r
2312         GetNewActor ();\r
2313         new->state = &s_needle1;\r
2314         new->ticcount = 1;\r
2315 \r
2316         new->tilex = ob->tilex;\r
2317         new->tiley = ob->tiley;\r
2318         new->x = ob->x;\r
2319         new->y = ob->y;\r
2320         new->obclass = needleobj;\r
2321         new->dir = nodir;\r
2322         new->angle = iangle;\r
2323         new->speed = 0x2000l;\r
2324 \r
2325         new->flags = FL_NONMARK;\r
2326         new->active = true;\r
2327 \r
2328         PlaySoundLocActor (SCHABBSTHROWSND,new);\r
2329 }\r
2330 \r
2331 /*\r
2332 =================\r
2333 =\r
2334 = T_GiftThrow\r
2335 =\r
2336 =================\r
2337 */\r
2338 \r
2339 void T_GiftThrow (objtype *ob)\r
2340 {\r
2341         long    deltax,deltay;\r
2342         float   angle;\r
2343         int             iangle;\r
2344 \r
2345         deltax = player->x - ob->x;\r
2346         deltay = ob->y - player->y;\r
2347         angle = atan2 (deltay,deltax);\r
2348         if (angle<0)\r
2349                 angle = M_PI*2+angle;\r
2350         iangle = angle/(M_PI*2)*ANGLES;\r
2351 \r
2352         GetNewActor ();\r
2353         new->state = &s_rocket;\r
2354         new->ticcount = 1;\r
2355 \r
2356         new->tilex = ob->tilex;\r
2357         new->tiley = ob->tiley;\r
2358         new->x = ob->x;\r
2359         new->y = ob->y;\r
2360         new->obclass = rocketobj;\r
2361         new->dir = nodir;\r
2362         new->angle = iangle;\r
2363         new->speed = 0x2000l;\r
2364         new->flags = FL_NONMARK;\r
2365         new->active = true;\r
2366 \r
2367         PlaySoundLocActor (MISSILEFIRESND,new);\r
2368 }\r
2369 \r
2370 \r
2371 \r
2372 /*\r
2373 =================\r
2374 =\r
2375 = T_Schabb\r
2376 =\r
2377 =================\r
2378 */\r
2379 \r
2380 void T_Schabb (objtype *ob)\r
2381 {\r
2382         long move;\r
2383         int     dx,dy,dist;\r
2384         boolean dodge;\r
2385 \r
2386         dodge = false;\r
2387         dx = abs(ob->tilex - player->tilex);\r
2388         dy = abs(ob->tiley - player->tiley);\r
2389         dist = dx>dy ? dx : dy;\r
2390 \r
2391         if (CheckLine(ob))                                              // got a shot at player?\r
2392         {\r
2393 \r
2394                 if ( US_RndT() < (tics<<3) )\r
2395                 {\r
2396                 //\r
2397                 // go into attack frame\r
2398                 //\r
2399                         NewState (ob,&s_schabbshoot1);\r
2400                         return;\r
2401                 }\r
2402                 dodge = true;\r
2403         }\r
2404 \r
2405         if (ob->dir == nodir)\r
2406         {\r
2407                 if (dodge)\r
2408                         SelectDodgeDir (ob);\r
2409                 else\r
2410                         SelectChaseDir (ob);\r
2411                 if (ob->dir == nodir)\r
2412                         return;                                                 // object is blocked in\r
2413         }\r
2414 \r
2415         move = ob->speed*tics;\r
2416 \r
2417         while (move)\r
2418         {\r
2419                 if (ob->distance < 0)\r
2420                 {\r
2421                 //\r
2422                 // waiting for a door to open\r
2423                 //\r
2424                         OpenDoor (-ob->distance-1);\r
2425                         if (doorobjlist[-ob->distance-1].action != dr_open)\r
2426                                 return;\r
2427                         ob->distance = TILEGLOBAL;      // go ahead, the door is now opoen\r
2428                 }\r
2429 \r
2430                 if (move < ob->distance)\r
2431                 {\r
2432                         MoveObj (ob,move);\r
2433                         break;\r
2434                 }\r
2435 \r
2436                 //\r
2437                 // reached goal tile, so select another one\r
2438                 //\r
2439 \r
2440                 //\r
2441                 // fix position to account for round off during moving\r
2442                 //\r
2443                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
2444                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
2445 \r
2446                 move -= ob->distance;\r
2447 \r
2448                 if (dist <4)\r
2449                         SelectRunDir (ob);\r
2450                 else if (dodge)\r
2451                         SelectDodgeDir (ob);\r
2452                 else\r
2453                         SelectChaseDir (ob);\r
2454 \r
2455                 if (ob->dir == nodir)\r
2456                         return;                                                 // object is blocked in\r
2457         }\r
2458 \r
2459 }\r
2460 \r
2461 \r
2462 \r
2463 \r
2464 /*\r
2465 =================\r
2466 =\r
2467 = T_Gift\r
2468 =\r
2469 =================\r
2470 */\r
2471 \r
2472 void T_Gift (objtype *ob)\r
2473 {\r
2474         long move;\r
2475         int     dx,dy,dist;\r
2476         boolean dodge;\r
2477 \r
2478         dodge = false;\r
2479         dx = abs(ob->tilex - player->tilex);\r
2480         dy = abs(ob->tiley - player->tiley);\r
2481         dist = dx>dy ? dx : dy;\r
2482 \r
2483         if (CheckLine(ob))                                              // got a shot at player?\r
2484         {\r
2485 \r
2486                 if ( US_RndT() < (tics<<3) )\r
2487                 {\r
2488                 //\r
2489                 // go into attack frame\r
2490                 //\r
2491                         NewState (ob,&s_giftshoot1);\r
2492                         return;\r
2493                 }\r
2494                 dodge = true;\r
2495         }\r
2496 \r
2497         if (ob->dir == nodir)\r
2498         {\r
2499                 if (dodge)\r
2500                         SelectDodgeDir (ob);\r
2501                 else\r
2502                         SelectChaseDir (ob);\r
2503                 if (ob->dir == nodir)\r
2504                         return;                                                 // object is blocked in\r
2505         }\r
2506 \r
2507         move = ob->speed*tics;\r
2508 \r
2509         while (move)\r
2510         {\r
2511                 if (ob->distance < 0)\r
2512                 {\r
2513                 //\r
2514                 // waiting for a door to open\r
2515                 //\r
2516                         OpenDoor (-ob->distance-1);\r
2517                         if (doorobjlist[-ob->distance-1].action != dr_open)\r
2518                                 return;\r
2519                         ob->distance = TILEGLOBAL;      // go ahead, the door is now opoen\r
2520                 }\r
2521 \r
2522                 if (move < ob->distance)\r
2523                 {\r
2524                         MoveObj (ob,move);\r
2525                         break;\r
2526                 }\r
2527 \r
2528                 //\r
2529                 // reached goal tile, so select another one\r
2530                 //\r
2531 \r
2532                 //\r
2533                 // fix position to account for round off during moving\r
2534                 //\r
2535                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
2536                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
2537 \r
2538                 move -= ob->distance;\r
2539 \r
2540                 if (dist <4)\r
2541                         SelectRunDir (ob);\r
2542                 else if (dodge)\r
2543                         SelectDodgeDir (ob);\r
2544                 else\r
2545                         SelectChaseDir (ob);\r
2546 \r
2547                 if (ob->dir == nodir)\r
2548                         return;                                                 // object is blocked in\r
2549         }\r
2550 \r
2551 }\r
2552 \r
2553 \r
2554 \r
2555 \r
2556 /*\r
2557 =================\r
2558 =\r
2559 = T_Fat\r
2560 =\r
2561 =================\r
2562 */\r
2563 \r
2564 void T_Fat (objtype *ob)\r
2565 {\r
2566         long move;\r
2567         int     dx,dy,dist;\r
2568         boolean dodge;\r
2569 \r
2570         dodge = false;\r
2571         dx = abs(ob->tilex - player->tilex);\r
2572         dy = abs(ob->tiley - player->tiley);\r
2573         dist = dx>dy ? dx : dy;\r
2574 \r
2575         if (CheckLine(ob))                                              // got a shot at player?\r
2576         {\r
2577 \r
2578                 if ( US_RndT() < (tics<<3) )\r
2579                 {\r
2580                 //\r
2581                 // go into attack frame\r
2582                 //\r
2583                         NewState (ob,&s_fatshoot1);\r
2584                         return;\r
2585                 }\r
2586                 dodge = true;\r
2587         }\r
2588 \r
2589         if (ob->dir == nodir)\r
2590         {\r
2591                 if (dodge)\r
2592                         SelectDodgeDir (ob);\r
2593                 else\r
2594                         SelectChaseDir (ob);\r
2595                 if (ob->dir == nodir)\r
2596                         return;                                                 // object is blocked in\r
2597         }\r
2598 \r
2599         move = ob->speed*tics;\r
2600 \r
2601         while (move)\r
2602         {\r
2603                 if (ob->distance < 0)\r
2604                 {\r
2605                 //\r
2606                 // waiting for a door to open\r
2607                 //\r
2608                         OpenDoor (-ob->distance-1);\r
2609                         if (doorobjlist[-ob->distance-1].action != dr_open)\r
2610                                 return;\r
2611                         ob->distance = TILEGLOBAL;      // go ahead, the door is now opoen\r
2612                 }\r
2613 \r
2614                 if (move < ob->distance)\r
2615                 {\r
2616                         MoveObj (ob,move);\r
2617                         break;\r
2618                 }\r
2619 \r
2620                 //\r
2621                 // reached goal tile, so select another one\r
2622                 //\r
2623 \r
2624                 //\r
2625                 // fix position to account for round off during moving\r
2626                 //\r
2627                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
2628                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
2629 \r
2630                 move -= ob->distance;\r
2631 \r
2632                 if (dist <4)\r
2633                         SelectRunDir (ob);\r
2634                 else if (dodge)\r
2635                         SelectDodgeDir (ob);\r
2636                 else\r
2637                         SelectChaseDir (ob);\r
2638 \r
2639                 if (ob->dir == nodir)\r
2640                         return;                                                 // object is blocked in\r
2641         }\r
2642 \r
2643 }\r
2644 \r
2645 \r
2646 \r
2647 /*\r
2648 =============================================================================\r
2649 \r
2650                                                         HITLERS\r
2651 \r
2652 =============================================================================\r
2653 */\r
2654 \r
2655 \r
2656 //\r
2657 // fake\r
2658 //\r
2659 extern  statetype s_fakestand;\r
2660 \r
2661 extern  statetype s_fakechase1;\r
2662 extern  statetype s_fakechase1s;\r
2663 extern  statetype s_fakechase2;\r
2664 extern  statetype s_fakechase3;\r
2665 extern  statetype s_fakechase3s;\r
2666 extern  statetype s_fakechase4;\r
2667 \r
2668 extern  statetype s_fakedie1;\r
2669 extern  statetype s_fakedie2;\r
2670 extern  statetype s_fakedie3;\r
2671 extern  statetype s_fakedie4;\r
2672 extern  statetype s_fakedie5;\r
2673 extern  statetype s_fakedie6;\r
2674 \r
2675 extern  statetype s_fakeshoot1;\r
2676 extern  statetype s_fakeshoot2;\r
2677 extern  statetype s_fakeshoot3;\r
2678 extern  statetype s_fakeshoot4;\r
2679 extern  statetype s_fakeshoot5;\r
2680 extern  statetype s_fakeshoot6;\r
2681 extern  statetype s_fakeshoot7;\r
2682 extern  statetype s_fakeshoot8;\r
2683 extern  statetype s_fakeshoot9;\r
2684 \r
2685 extern  statetype s_fire1;\r
2686 extern  statetype s_fire2;\r
2687 \r
2688 statetype s_fakestand   = {false,SPR_FAKE_W1,0,T_Stand,NULL,&s_fakestand};\r
2689 \r
2690 statetype s_fakechase1  = {false,SPR_FAKE_W1,10,T_Fake,NULL,&s_fakechase1s};\r
2691 statetype s_fakechase1s = {false,SPR_FAKE_W1,3,NULL,NULL,&s_fakechase2};\r
2692 statetype s_fakechase2  = {false,SPR_FAKE_W2,8,T_Fake,NULL,&s_fakechase3};\r
2693 statetype s_fakechase3  = {false,SPR_FAKE_W3,10,T_Fake,NULL,&s_fakechase3s};\r
2694 statetype s_fakechase3s = {false,SPR_FAKE_W3,3,NULL,NULL,&s_fakechase4};\r
2695 statetype s_fakechase4  = {false,SPR_FAKE_W4,8,T_Fake,NULL,&s_fakechase1};\r
2696 \r
2697 statetype s_fakedie1    = {false,SPR_FAKE_DIE1,10,NULL,A_DeathScream,&s_fakedie2};\r
2698 statetype s_fakedie2    = {false,SPR_FAKE_DIE2,10,NULL,NULL,&s_fakedie3};\r
2699 statetype s_fakedie3    = {false,SPR_FAKE_DIE3,10,NULL,NULL,&s_fakedie4};\r
2700 statetype s_fakedie4    = {false,SPR_FAKE_DIE4,10,NULL,NULL,&s_fakedie5};\r
2701 statetype s_fakedie5    = {false,SPR_FAKE_DIE5,10,NULL,NULL,&s_fakedie6};\r
2702 statetype s_fakedie6    = {false,SPR_FAKE_DEAD,0,NULL,NULL,&s_fakedie6};\r
2703 \r
2704 statetype s_fakeshoot1  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot2};\r
2705 statetype s_fakeshoot2  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot3};\r
2706 statetype s_fakeshoot3  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot4};\r
2707 statetype s_fakeshoot4  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot5};\r
2708 statetype s_fakeshoot5  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot6};\r
2709 statetype s_fakeshoot6  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot7};\r
2710 statetype s_fakeshoot7  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot8};\r
2711 statetype s_fakeshoot8  = {false,SPR_FAKE_SHOOT,8,NULL,T_FakeFire,&s_fakeshoot9};\r
2712 statetype s_fakeshoot9  = {false,SPR_FAKE_SHOOT,8,NULL,NULL,&s_fakechase1};\r
2713 \r
2714 statetype s_fire1       = {false,SPR_FIRE1,6,NULL,T_Projectile,&s_fire2};\r
2715 statetype s_fire2       = {false,SPR_FIRE2,6,NULL,T_Projectile,&s_fire1};\r
2716 \r
2717 //\r
2718 // hitler\r
2719 //\r
2720 extern  statetype s_mechachase1;\r
2721 extern  statetype s_mechachase1s;\r
2722 extern  statetype s_mechachase2;\r
2723 extern  statetype s_mechachase3;\r
2724 extern  statetype s_mechachase3s;\r
2725 extern  statetype s_mechachase4;\r
2726 \r
2727 extern  statetype s_mechadie1;\r
2728 extern  statetype s_mechadie2;\r
2729 extern  statetype s_mechadie3;\r
2730 extern  statetype s_mechadie4;\r
2731 \r
2732 extern  statetype s_mechashoot1;\r
2733 extern  statetype s_mechashoot2;\r
2734 extern  statetype s_mechashoot3;\r
2735 extern  statetype s_mechashoot4;\r
2736 extern  statetype s_mechashoot5;\r
2737 extern  statetype s_mechashoot6;\r
2738 \r
2739 \r
2740 extern  statetype s_hitlerchase1;\r
2741 extern  statetype s_hitlerchase1s;\r
2742 extern  statetype s_hitlerchase2;\r
2743 extern  statetype s_hitlerchase3;\r
2744 extern  statetype s_hitlerchase3s;\r
2745 extern  statetype s_hitlerchase4;\r
2746 \r
2747 extern  statetype s_hitlerdie1;\r
2748 extern  statetype s_hitlerdie2;\r
2749 extern  statetype s_hitlerdie3;\r
2750 extern  statetype s_hitlerdie4;\r
2751 extern  statetype s_hitlerdie5;\r
2752 extern  statetype s_hitlerdie6;\r
2753 extern  statetype s_hitlerdie7;\r
2754 extern  statetype s_hitlerdie8;\r
2755 extern  statetype s_hitlerdie9;\r
2756 extern  statetype s_hitlerdie10;\r
2757 \r
2758 extern  statetype s_hitlershoot1;\r
2759 extern  statetype s_hitlershoot2;\r
2760 extern  statetype s_hitlershoot3;\r
2761 extern  statetype s_hitlershoot4;\r
2762 extern  statetype s_hitlershoot5;\r
2763 extern  statetype s_hitlershoot6;\r
2764 \r
2765 extern  statetype s_hitlerdeathcam;\r
2766 \r
2767 statetype s_mechastand  = {false,SPR_MECHA_W1,0,T_Stand,NULL,&s_mechastand};\r
2768 \r
2769 statetype s_mechachase1         = {false,SPR_MECHA_W1,10,T_Chase,A_MechaSound,&s_mechachase1s};\r
2770 statetype s_mechachase1s        = {false,SPR_MECHA_W1,6,NULL,NULL,&s_mechachase2};\r
2771 statetype s_mechachase2         = {false,SPR_MECHA_W2,8,T_Chase,NULL,&s_mechachase3};\r
2772 statetype s_mechachase3         = {false,SPR_MECHA_W3,10,T_Chase,A_MechaSound,&s_mechachase3s};\r
2773 statetype s_mechachase3s        = {false,SPR_MECHA_W3,6,NULL,NULL,&s_mechachase4};\r
2774 statetype s_mechachase4         = {false,SPR_MECHA_W4,8,T_Chase,NULL,&s_mechachase1};\r
2775 \r
2776 statetype s_mechadie1   = {false,SPR_MECHA_DIE1,10,NULL,A_DeathScream,&s_mechadie2};\r
2777 statetype s_mechadie2   = {false,SPR_MECHA_DIE2,10,NULL,NULL,&s_mechadie3};\r
2778 statetype s_mechadie3   = {false,SPR_MECHA_DIE3,10,NULL,A_HitlerMorph,&s_mechadie4};\r
2779 statetype s_mechadie4   = {false,SPR_MECHA_DEAD,0,NULL,NULL,&s_mechadie4};\r
2780 \r
2781 statetype s_mechashoot1         = {false,SPR_MECHA_SHOOT1,30,NULL,NULL,&s_mechashoot2};\r
2782 statetype s_mechashoot2         = {false,SPR_MECHA_SHOOT2,10,NULL,T_Shoot,&s_mechashoot3};\r
2783 statetype s_mechashoot3         = {false,SPR_MECHA_SHOOT3,10,NULL,T_Shoot,&s_mechashoot4};\r
2784 statetype s_mechashoot4         = {false,SPR_MECHA_SHOOT2,10,NULL,T_Shoot,&s_mechashoot5};\r
2785 statetype s_mechashoot5         = {false,SPR_MECHA_SHOOT3,10,NULL,T_Shoot,&s_mechashoot6};\r
2786 statetype s_mechashoot6         = {false,SPR_MECHA_SHOOT2,10,NULL,T_Shoot,&s_mechachase1};\r
2787 \r
2788 \r
2789 statetype s_hitlerchase1        = {false,SPR_HITLER_W1,6,T_Chase,NULL,&s_hitlerchase1s};\r
2790 statetype s_hitlerchase1s       = {false,SPR_HITLER_W1,4,NULL,NULL,&s_hitlerchase2};\r
2791 statetype s_hitlerchase2        = {false,SPR_HITLER_W2,2,T_Chase,NULL,&s_hitlerchase3};\r
2792 statetype s_hitlerchase3        = {false,SPR_HITLER_W3,6,T_Chase,NULL,&s_hitlerchase3s};\r
2793 statetype s_hitlerchase3s       = {false,SPR_HITLER_W3,4,NULL,NULL,&s_hitlerchase4};\r
2794 statetype s_hitlerchase4        = {false,SPR_HITLER_W4,2,T_Chase,NULL,&s_hitlerchase1};\r
2795 \r
2796 statetype s_hitlerdeathcam      = {false,SPR_HITLER_W1,10,NULL,NULL,&s_hitlerdie1};\r
2797 \r
2798 statetype s_hitlerdie1  = {false,SPR_HITLER_W1,1,NULL,A_DeathScream,&s_hitlerdie2};\r
2799 statetype s_hitlerdie2  = {false,SPR_HITLER_W1,10,NULL,NULL,&s_hitlerdie3};\r
2800 statetype s_hitlerdie3  = {false,SPR_HITLER_DIE1,10,NULL,A_Slurpie,&s_hitlerdie4};\r
2801 statetype s_hitlerdie4  = {false,SPR_HITLER_DIE2,10,NULL,NULL,&s_hitlerdie5};\r
2802 statetype s_hitlerdie5  = {false,SPR_HITLER_DIE3,10,NULL,NULL,&s_hitlerdie6};\r
2803 statetype s_hitlerdie6  = {false,SPR_HITLER_DIE4,10,NULL,NULL,&s_hitlerdie7};\r
2804 statetype s_hitlerdie7  = {false,SPR_HITLER_DIE5,10,NULL,NULL,&s_hitlerdie8};\r
2805 statetype s_hitlerdie8  = {false,SPR_HITLER_DIE6,10,NULL,NULL,&s_hitlerdie9};\r
2806 statetype s_hitlerdie9  = {false,SPR_HITLER_DIE7,10,NULL,NULL,&s_hitlerdie10};\r
2807 statetype s_hitlerdie10 = {false,SPR_HITLER_DEAD,20,NULL,A_StartDeathCam,&s_hitlerdie10};\r
2808 \r
2809 statetype s_hitlershoot1        = {false,SPR_HITLER_SHOOT1,30,NULL,NULL,&s_hitlershoot2};\r
2810 statetype s_hitlershoot2        = {false,SPR_HITLER_SHOOT2,10,NULL,T_Shoot,&s_hitlershoot3};\r
2811 statetype s_hitlershoot3        = {false,SPR_HITLER_SHOOT3,10,NULL,T_Shoot,&s_hitlershoot4};\r
2812 statetype s_hitlershoot4        = {false,SPR_HITLER_SHOOT2,10,NULL,T_Shoot,&s_hitlershoot5};\r
2813 statetype s_hitlershoot5        = {false,SPR_HITLER_SHOOT3,10,NULL,T_Shoot,&s_hitlershoot6};\r
2814 statetype s_hitlershoot6        = {false,SPR_HITLER_SHOOT2,10,NULL,T_Shoot,&s_hitlerchase1};\r
2815 \r
2816 \r
2817 \r
2818 /*\r
2819 ===============\r
2820 =\r
2821 = SpawnFakeHitler\r
2822 =\r
2823 ===============\r
2824 */\r
2825 \r
2826 void SpawnFakeHitler (int tilex, int tiley)\r
2827 {\r
2828         unsigned        far *map,tile;\r
2829 \r
2830 \r
2831         if (DigiMode != sds_Off)\r
2832           s_hitlerdie2.tictime = 140;\r
2833         else\r
2834           s_hitlerdie2.tictime = 5;\r
2835 \r
2836         SpawnNewObj (tilex,tiley,&s_fakestand);\r
2837         new->speed = SPDPATROL;\r
2838 \r
2839         new->obclass = fakeobj;\r
2840         new->hitpoints = starthitpoints[gamestate.difficulty][en_fake];\r
2841         new->dir = north;\r
2842         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
2843         if (!loadedgame)\r
2844           gamestate.killtotal++;\r
2845 }\r
2846 \r
2847 \r
2848 /*\r
2849 ===============\r
2850 =\r
2851 = SpawnHitler\r
2852 =\r
2853 ===============\r
2854 */\r
2855 \r
2856 void SpawnHitler (int tilex, int tiley)\r
2857 {\r
2858         unsigned        far *map,tile;\r
2859 \r
2860         if (DigiMode != sds_Off)\r
2861                 s_hitlerdie2.tictime = 140;\r
2862         else\r
2863                 s_hitlerdie2.tictime = 5;\r
2864 \r
2865 \r
2866         SpawnNewObj (tilex,tiley,&s_mechastand);\r
2867         new->speed = SPDPATROL;\r
2868 \r
2869         new->obclass = mechahitlerobj;\r
2870         new->hitpoints = starthitpoints[gamestate.difficulty][en_hitler];\r
2871         new->dir = south;\r
2872         new->flags |= FL_SHOOTABLE|FL_AMBUSH;\r
2873         if (!loadedgame)\r
2874           gamestate.killtotal++;\r
2875 }\r
2876 \r
2877 \r
2878 /*\r
2879 ===============\r
2880 =\r
2881 = A_HitlerMorph\r
2882 =\r
2883 ===============\r
2884 */\r
2885 \r
2886 void A_HitlerMorph (objtype *ob)\r
2887 {\r
2888         unsigned        far *map,tile,hitpoints[4]={500,700,800,900};\r
2889 \r
2890 \r
2891         SpawnNewObj (ob->tilex,ob->tiley,&s_hitlerchase1);\r
2892         new->speed = SPDPATROL*5;\r
2893 \r
2894         new->x = ob->x;\r
2895         new->y = ob->y;\r
2896 \r
2897         new->distance = ob->distance;\r
2898         new->dir = ob->dir;\r
2899         new->flags = ob->flags | FL_SHOOTABLE;\r
2900 \r
2901         new->obclass = realhitlerobj;\r
2902         new->hitpoints = hitpoints[gamestate.difficulty];\r
2903 }\r
2904 \r
2905 \r
2906 ////////////////////////////////////////////////////////\r
2907 //\r
2908 // A_MechaSound\r
2909 // A_Slurpie\r
2910 //\r
2911 ////////////////////////////////////////////////////////\r
2912 void A_MechaSound (objtype *ob)\r
2913 {\r
2914         if (areabyplayer[ob->areanumber])\r
2915                 PlaySoundLocActor (MECHSTEPSND,ob);\r
2916 }\r
2917 \r
2918 \r
2919 #pragma argsused\r
2920 void A_Slurpie (objtype *ob)\r
2921 {\r
2922  SD_PlaySound(SLURPIESND);\r
2923 }\r
2924 \r
2925 /*\r
2926 =================\r
2927 =\r
2928 = T_FakeFire\r
2929 =\r
2930 =================\r
2931 */\r
2932 \r
2933 void T_FakeFire (objtype *ob)\r
2934 {\r
2935         long    deltax,deltay;\r
2936         float   angle;\r
2937         int             iangle;\r
2938 \r
2939         deltax = player->x - ob->x;\r
2940         deltay = ob->y - player->y;\r
2941         angle = atan2 (deltay,deltax);\r
2942         if (angle<0)\r
2943                 angle = M_PI*2+angle;\r
2944         iangle = angle/(M_PI*2)*ANGLES;\r
2945 \r
2946         GetNewActor ();\r
2947         new->state = &s_fire1;\r
2948         new->ticcount = 1;\r
2949 \r
2950         new->tilex = ob->tilex;\r
2951         new->tiley = ob->tiley;\r
2952         new->x = ob->x;\r
2953         new->y = ob->y;\r
2954         new->dir = nodir;\r
2955         new->angle = iangle;\r
2956         new->obclass = fireobj;\r
2957         new->speed = 0x1200l;\r
2958         new->flags = FL_NEVERMARK;\r
2959         new->active = true;\r
2960 \r
2961         PlaySoundLocActor (FLAMETHROWERSND,new);\r
2962 }\r
2963 \r
2964 \r
2965 \r
2966 /*\r
2967 =================\r
2968 =\r
2969 = T_Fake\r
2970 =\r
2971 =================\r
2972 */\r
2973 \r
2974 void T_Fake (objtype *ob)\r
2975 {\r
2976         long move;\r
2977         int     dx,dy,dist;\r
2978         boolean dodge;\r
2979 \r
2980         if (CheckLine(ob))                      // got a shot at player?\r
2981         {\r
2982                 if ( US_RndT() < (tics<<1) )\r
2983                 {\r
2984                 //\r
2985                 // go into attack frame\r
2986                 //\r
2987                         NewState (ob,&s_fakeshoot1);\r
2988                         return;\r
2989                 }\r
2990         }\r
2991 \r
2992         if (ob->dir == nodir)\r
2993         {\r
2994                 SelectDodgeDir (ob);\r
2995                 if (ob->dir == nodir)\r
2996                         return;                                                 // object is blocked in\r
2997         }\r
2998 \r
2999         move = ob->speed*tics;\r
3000 \r
3001         while (move)\r
3002         {\r
3003                 if (move < ob->distance)\r
3004                 {\r
3005                         MoveObj (ob,move);\r
3006                         break;\r
3007                 }\r
3008 \r
3009                 //\r
3010                 // reached goal tile, so select another one\r
3011                 //\r
3012 \r
3013                 //\r
3014                 // fix position to account for round off during moving\r
3015                 //\r
3016                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
3017                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
3018 \r
3019                 move -= ob->distance;\r
3020 \r
3021                 SelectDodgeDir (ob);\r
3022 \r
3023                 if (ob->dir == nodir)\r
3024                         return;                                                 // object is blocked in\r
3025         }\r
3026 \r
3027 }\r
3028 \r
3029 #endif\r
3030 /*\r
3031 ============================================================================\r
3032 \r
3033                                                         STAND\r
3034 \r
3035 ============================================================================\r
3036 */\r
3037 \r
3038 \r
3039 /*\r
3040 ===============\r
3041 =\r
3042 = T_Stand\r
3043 =\r
3044 ===============\r
3045 */\r
3046 \r
3047 void T_Stand (objtype *ob)\r
3048 {\r
3049         SightPlayer (ob);\r
3050 }\r
3051 \r
3052 \r
3053 /*\r
3054 ============================================================================\r
3055 \r
3056                                                                 CHASE\r
3057 \r
3058 ============================================================================\r
3059 */\r
3060 \r
3061 /*\r
3062 =================\r
3063 =\r
3064 = T_Chase\r
3065 =\r
3066 =================\r
3067 */\r
3068 \r
3069 void T_Chase (objtype *ob)\r
3070 {\r
3071         long move;\r
3072         int     dx,dy,dist,chance;\r
3073         boolean dodge;\r
3074 \r
3075         if (gamestate.victoryflag)\r
3076                 return;\r
3077 \r
3078         dodge = false;\r
3079         if (CheckLine(ob))      // got a shot at player?\r
3080         {\r
3081                 dx = abs(ob->tilex - player->tilex);\r
3082                 dy = abs(ob->tiley - player->tiley);\r
3083                 dist = dx>dy ? dx : dy;\r
3084                 if (!dist || (dist==1 && ob->distance<0x4000) )\r
3085                         chance = 300;\r
3086                 else\r
3087                         chance = (tics<<4)/dist;\r
3088 \r
3089                 if ( US_RndT()<chance)\r
3090                 {\r
3091                 //\r
3092                 // go into attack frame\r
3093                 //\r
3094                         switch (ob->obclass)\r
3095                         {\r
3096                         case guardobj:\r
3097                                 NewState (ob,&s_grdshoot1);\r
3098                                 break;\r
3099                         case officerobj:\r
3100                                 NewState (ob,&s_ofcshoot1);\r
3101                                 break;\r
3102                         case mutantobj:\r
3103                                 NewState (ob,&s_mutshoot1);\r
3104                                 break;\r
3105                         case ssobj:\r
3106                                 NewState (ob,&s_ssshoot1);\r
3107                                 break;\r
3108 #ifndef SPEAR\r
3109                         case bossobj:\r
3110                                 NewState (ob,&s_bossshoot1);\r
3111                                 break;\r
3112                         case gretelobj:\r
3113                                 NewState (ob,&s_gretelshoot1);\r
3114                                 break;\r
3115                         case mechahitlerobj:\r
3116                                 NewState (ob,&s_mechashoot1);\r
3117                                 break;\r
3118                         case realhitlerobj:\r
3119                                 NewState (ob,&s_hitlershoot1);\r
3120                                 break;\r
3121 #else\r
3122                         case angelobj:\r
3123                                 NewState (ob,&s_angelshoot1);\r
3124                                 break;\r
3125                         case transobj:\r
3126                                 NewState (ob,&s_transshoot1);\r
3127                                 break;\r
3128                         case uberobj:\r
3129                                 NewState (ob,&s_ubershoot1);\r
3130                                 break;\r
3131                         case willobj:\r
3132                                 NewState (ob,&s_willshoot1);\r
3133                                 break;\r
3134                         case deathobj:\r
3135                                 NewState (ob,&s_deathshoot1);\r
3136                                 break;\r
3137 #endif\r
3138                         }\r
3139                         return;\r
3140                 }\r
3141                 dodge = true;\r
3142         }\r
3143 \r
3144         if (ob->dir == nodir)\r
3145         {\r
3146                 if (dodge)\r
3147                         SelectDodgeDir (ob);\r
3148                 else\r
3149                         SelectChaseDir (ob);\r
3150                 if (ob->dir == nodir)\r
3151                         return;                                                 // object is blocked in\r
3152         }\r
3153 \r
3154         move = ob->speed*tics;\r
3155 \r
3156         while (move)\r
3157         {\r
3158                 if (ob->distance < 0)\r
3159                 {\r
3160                 //\r
3161                 // waiting for a door to open\r
3162                 //\r
3163                         OpenDoor (-ob->distance-1);\r
3164                         if (doorobjlist[-ob->distance-1].action != dr_open)\r
3165                                 return;\r
3166                         ob->distance = TILEGLOBAL;      // go ahead, the door is now opoen\r
3167                 }\r
3168 \r
3169                 if (move < ob->distance)\r
3170                 {\r
3171                         MoveObj (ob,move);\r
3172                         break;\r
3173                 }\r
3174 \r
3175                 //\r
3176                 // reached goal tile, so select another one\r
3177                 //\r
3178 \r
3179                 //\r
3180                 // fix position to account for round off during moving\r
3181                 //\r
3182                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
3183                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
3184 \r
3185                 move -= ob->distance;\r
3186 \r
3187                 if (dodge)\r
3188                         SelectDodgeDir (ob);\r
3189                 else\r
3190                         SelectChaseDir (ob);\r
3191 \r
3192                 if (ob->dir == nodir)\r
3193                         return;                                                 // object is blocked in\r
3194         }\r
3195 \r
3196 }\r
3197 \r
3198 \r
3199 /*\r
3200 =================\r
3201 =\r
3202 = T_Ghosts\r
3203 =\r
3204 =================\r
3205 */\r
3206 \r
3207 void T_Ghosts (objtype *ob)\r
3208 {\r
3209         long move;\r
3210 \r
3211 \r
3212         if (ob->dir == nodir)\r
3213         {\r
3214                 SelectChaseDir (ob);\r
3215                 if (ob->dir == nodir)\r
3216                         return;                                                 // object is blocked in\r
3217         }\r
3218 \r
3219         move = ob->speed*tics;\r
3220 \r
3221         while (move)\r
3222         {\r
3223                 if (move < ob->distance)\r
3224                 {\r
3225                         MoveObj (ob,move);\r
3226                         break;\r
3227                 }\r
3228 \r
3229                 //\r
3230                 // reached goal tile, so select another one\r
3231                 //\r
3232 \r
3233                 //\r
3234                 // fix position to account for round off during moving\r
3235                 //\r
3236                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
3237                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
3238 \r
3239                 move -= ob->distance;\r
3240 \r
3241                 SelectChaseDir (ob);\r
3242 \r
3243                 if (ob->dir == nodir)\r
3244                         return;                                                 // object is blocked in\r
3245         }\r
3246 \r
3247 }\r
3248 \r
3249 /*\r
3250 =================\r
3251 =\r
3252 = T_DogChase\r
3253 =\r
3254 =================\r
3255 */\r
3256 \r
3257 void T_DogChase (objtype *ob)\r
3258 {\r
3259         long    move;\r
3260         int             dist,chance;\r
3261         long    dx,dy;\r
3262 \r
3263 \r
3264         if (ob->dir == nodir)\r
3265         {\r
3266                 SelectDodgeDir (ob);\r
3267                 if (ob->dir == nodir)\r
3268                         return;                                                 // object is blocked in\r
3269         }\r
3270 \r
3271         move = ob->speed*tics;\r
3272 \r
3273         while (move)\r
3274         {\r
3275         //\r
3276         // check for byte range\r
3277         //\r
3278                 dx = player->x - ob->x;\r
3279                 if (dx<0)\r
3280                         dx = -dx;\r
3281                 dx -= move;\r
3282                 if (dx <= MINACTORDIST)\r
3283                 {\r
3284                         dy = player->y - ob->y;\r
3285                         if (dy<0)\r
3286                                 dy = -dy;\r
3287                         dy -= move;\r
3288                         if (dy <= MINACTORDIST)\r
3289                         {\r
3290                                 NewState (ob,&s_dogjump1);\r
3291                                 return;\r
3292                         }\r
3293                 }\r
3294 \r
3295                 if (move < ob->distance)\r
3296                 {\r
3297                         MoveObj (ob,move);\r
3298                         break;\r
3299                 }\r
3300 \r
3301                 //\r
3302                 // reached goal tile, so select another one\r
3303                 //\r
3304 \r
3305                 //\r
3306                 // fix position to account for round off during moving\r
3307                 //\r
3308                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
3309                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
3310 \r
3311                 move -= ob->distance;\r
3312 \r
3313                 SelectDodgeDir (ob);\r
3314 \r
3315                 if (ob->dir == nodir)\r
3316                         return;                                                 // object is blocked in\r
3317         }\r
3318 \r
3319 }\r
3320 \r
3321 \r
3322 \r
3323 /*\r
3324 ============================================================================\r
3325 \r
3326                                                                 PATH\r
3327 \r
3328 ============================================================================\r
3329 */\r
3330 \r
3331 \r
3332 /*\r
3333 ===============\r
3334 =\r
3335 = SelectPathDir\r
3336 =\r
3337 ===============\r
3338 */\r
3339 \r
3340 void SelectPathDir (objtype *ob)\r
3341 {\r
3342         unsigned spot;\r
3343 \r
3344         spot = MAPSPOT(ob->tilex,ob->tiley,1)-ICONARROWS;\r
3345 \r
3346         if (spot<8)\r
3347         {\r
3348         // new direction\r
3349                 ob->dir = spot;\r
3350         }\r
3351 \r
3352         ob->distance = TILEGLOBAL;\r
3353 \r
3354         if (!TryWalk (ob))\r
3355                 ob->dir = nodir;\r
3356 }\r
3357 \r
3358 \r
3359 /*\r
3360 ===============\r
3361 =\r
3362 = T_Path\r
3363 =\r
3364 ===============\r
3365 */\r
3366 \r
3367 void T_Path (objtype *ob)\r
3368 {\r
3369         long    move;\r
3370         long    deltax,deltay,size;\r
3371 \r
3372         if (SightPlayer (ob))\r
3373                 return;\r
3374 \r
3375         if (ob->dir == nodir)\r
3376         {\r
3377                 SelectPathDir (ob);\r
3378                 if (ob->dir == nodir)\r
3379                         return;                                 // all movement is blocked\r
3380         }\r
3381 \r
3382 \r
3383         move = ob->speed*tics;\r
3384 \r
3385         while (move)\r
3386         {\r
3387                 if (ob->distance < 0)\r
3388                 {\r
3389                 //\r
3390                 // waiting for a door to open\r
3391                 //\r
3392                         OpenDoor (-ob->distance-1);\r
3393                         if (doorobjlist[-ob->distance-1].action != dr_open)\r
3394                                 return;\r
3395                         ob->distance = TILEGLOBAL;      // go ahead, the door is now opoen\r
3396                 }\r
3397 \r
3398                 if (move < ob->distance)\r
3399                 {\r
3400                         MoveObj (ob,move);\r
3401                         break;\r
3402                 }\r
3403 \r
3404                 if (ob->tilex>MAPSIZE || ob->tiley>MAPSIZE)\r
3405                 {\r
3406                         sprintf (str,"T_Path hit a wall at %u,%u, dir %u"\r
3407                         ,ob->tilex,ob->tiley,ob->dir);\r
3408                         Quit (str);\r
3409                 }\r
3410 \r
3411 \r
3412 \r
3413                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
3414                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
3415                 move -= ob->distance;\r
3416 \r
3417                 SelectPathDir (ob);\r
3418 \r
3419                 if (ob->dir == nodir)\r
3420                         return;                                 // all movement is blocked\r
3421         }\r
3422 }\r
3423 \r
3424 \r
3425 /*\r
3426 =============================================================================\r
3427 \r
3428                                                                 FIGHT\r
3429 \r
3430 =============================================================================\r
3431 */\r
3432 \r
3433 \r
3434 /*\r
3435 ===============\r
3436 =\r
3437 = T_Shoot\r
3438 =\r
3439 = Try to damage the player, based on skill level and player's speed\r
3440 =\r
3441 ===============\r
3442 */\r
3443 \r
3444 void T_Shoot (objtype *ob)\r
3445 {\r
3446         int     dx,dy,dist;\r
3447         int     hitchance,damage;\r
3448 \r
3449         hitchance = 128;\r
3450 \r
3451         if (!areabyplayer[ob->areanumber])\r
3452                 return;\r
3453 \r
3454         if (!CheckLine (ob))                    // player is behind a wall\r
3455           return;\r
3456 \r
3457         dx = abs(ob->tilex - player->tilex);\r
3458         dy = abs(ob->tiley - player->tiley);\r
3459         dist = dx>dy ? dx:dy;\r
3460 \r
3461         if (ob->obclass == ssobj || ob->obclass == bossobj)\r
3462                 dist = dist*2/3;                                        // ss are better shots\r
3463 \r
3464         if (thrustspeed >= RUNSPEED)\r
3465         {\r
3466                 if (ob->flags&FL_VISABLE)\r
3467                         hitchance = 160-dist*16;                // player can see to dodge\r
3468                 else\r
3469                         hitchance = 160-dist*8;\r
3470         }\r
3471         else\r
3472         {\r
3473                 if (ob->flags&FL_VISABLE)\r
3474                         hitchance = 256-dist*16;                // player can see to dodge\r
3475                 else\r
3476                         hitchance = 256-dist*8;\r
3477         }\r
3478 \r
3479 // see if the shot was a hit\r
3480 \r
3481         if (US_RndT()<hitchance)\r
3482         {\r
3483                 if (dist<2)\r
3484                         damage = US_RndT()>>2;\r
3485                 else if (dist<4)\r
3486                         damage = US_RndT()>>3;\r
3487                 else\r
3488                         damage = US_RndT()>>4;\r
3489 \r
3490                 TakeDamage (damage,ob);\r
3491         }\r
3492 \r
3493         switch(ob->obclass)\r
3494         {\r
3495          case ssobj:\r
3496            PlaySoundLocActor(SSFIRESND,ob);\r
3497            break;\r
3498 #ifndef SPEAR\r
3499          case giftobj:\r
3500          case fatobj:\r
3501            PlaySoundLocActor(MISSILEFIRESND,ob);\r
3502            break;\r
3503          case mechahitlerobj:\r
3504          case realhitlerobj:\r
3505          case bossobj:\r
3506            PlaySoundLocActor(BOSSFIRESND,ob);\r
3507            break;\r
3508          case schabbobj:\r
3509            PlaySoundLocActor(SCHABBSTHROWSND,ob);\r
3510            break;\r
3511          case fakeobj:\r
3512            PlaySoundLocActor(FLAMETHROWERSND,ob);\r
3513            break;\r
3514 #endif\r
3515          default:\r
3516            PlaySoundLocActor(NAZIFIRESND,ob);\r
3517         }\r
3518 \r
3519 }\r
3520 \r
3521 \r
3522 /*\r
3523 ===============\r
3524 =\r
3525 = T_Bite\r
3526 =\r
3527 ===============\r
3528 */\r
3529 \r
3530 void T_Bite (objtype *ob)\r
3531 {\r
3532         long    dx,dy;\r
3533         int     hitchance,damage;\r
3534 \r
3535 \r
3536         PlaySoundLocActor(DOGATTACKSND,ob);     // JAB\r
3537 \r
3538         dx = player->x - ob->x;\r
3539         if (dx<0)\r
3540                 dx = -dx;\r
3541         dx -= TILEGLOBAL;\r
3542         if (dx <= MINACTORDIST)\r
3543         {\r
3544                 dy = player->y - ob->y;\r
3545                 if (dy<0)\r
3546                         dy = -dy;\r
3547                 dy -= TILEGLOBAL;\r
3548                 if (dy <= MINACTORDIST)\r
3549                 {\r
3550                    if (US_RndT()<180)\r
3551                    {\r
3552                            TakeDamage (US_RndT()>>4,ob);\r
3553                            return;\r
3554                    }\r
3555                 }\r
3556         }\r
3557 \r
3558         return;\r
3559 }\r
3560 \r
3561 \r
3562 #ifndef SPEAR\r
3563 /*\r
3564 ============================================================================\r
3565 \r
3566                                                         BJ VICTORY\r
3567 \r
3568 ============================================================================\r
3569 */\r
3570 \r
3571 \r
3572 //\r
3573 // BJ victory\r
3574 //\r
3575 \r
3576 void T_BJRun (objtype *ob);\r
3577 void T_BJJump (objtype *ob);\r
3578 void T_BJDone (objtype *ob);\r
3579 void T_BJYell (objtype *ob);\r
3580 \r
3581 void T_DeathCam (objtype *ob);\r
3582 \r
3583 extern  statetype s_bjrun1;\r
3584 extern  statetype s_bjrun1s;\r
3585 extern  statetype s_bjrun2;\r
3586 extern  statetype s_bjrun3;\r
3587 extern  statetype s_bjrun3s;\r
3588 extern  statetype s_bjrun4;\r
3589 \r
3590 extern  statetype s_bjjump1;\r
3591 extern  statetype s_bjjump2;\r
3592 extern  statetype s_bjjump3;\r
3593 extern  statetype s_bjjump4;\r
3594 \r
3595 \r
3596 statetype s_bjrun1      = {false,SPR_BJ_W1,12,T_BJRun,NULL,&s_bjrun1s};\r
3597 statetype s_bjrun1s     = {false,SPR_BJ_W1,3, NULL,NULL,&s_bjrun2};\r
3598 statetype s_bjrun2      = {false,SPR_BJ_W2,8,T_BJRun,NULL,&s_bjrun3};\r
3599 statetype s_bjrun3      = {false,SPR_BJ_W3,12,T_BJRun,NULL,&s_bjrun3s};\r
3600 statetype s_bjrun3s     = {false,SPR_BJ_W3,3, NULL,NULL,&s_bjrun4};\r
3601 statetype s_bjrun4      = {false,SPR_BJ_W4,8,T_BJRun,NULL,&s_bjrun1};\r
3602 \r
3603 \r
3604 statetype s_bjjump1     = {false,SPR_BJ_JUMP1,14,T_BJJump,NULL,&s_bjjump2};\r
3605 statetype s_bjjump2     = {false,SPR_BJ_JUMP2,14,T_BJJump,T_BJYell,&s_bjjump3};\r
3606 statetype s_bjjump3     = {false,SPR_BJ_JUMP3,14,T_BJJump,NULL,&s_bjjump4};\r
3607 statetype s_bjjump4     = {false,SPR_BJ_JUMP4,300,NULL,T_BJDone,&s_bjjump4};\r
3608 \r
3609 \r
3610 statetype s_deathcam = {false,0,0,NULL,NULL,NULL};\r
3611 \r
3612 \r
3613 /*\r
3614 ===============\r
3615 =\r
3616 = SpawnBJVictory\r
3617 =\r
3618 ===============\r
3619 */\r
3620 \r
3621 void SpawnBJVictory (void)\r
3622 {\r
3623         unsigned        far *map,tile;\r
3624 \r
3625         SpawnNewObj (player->tilex,player->tiley+1,&s_bjrun1);\r
3626         new->x = player->x;\r
3627         new->y = player->y;\r
3628         new->obclass = bjobj;\r
3629         new->dir = north;\r
3630         new->temp1 = 6;                 // tiles to run forward\r
3631 }\r
3632 \r
3633 \r
3634 \r
3635 /*\r
3636 ===============\r
3637 =\r
3638 = T_BJRun\r
3639 =\r
3640 ===============\r
3641 */\r
3642 \r
3643 void T_BJRun (objtype *ob)\r
3644 {\r
3645         long    move;\r
3646 \r
3647         move = BJRUNSPEED*tics;\r
3648 \r
3649         while (move)\r
3650         {\r
3651                 if (move < ob->distance)\r
3652                 {\r
3653                         MoveObj (ob,move);\r
3654                         break;\r
3655                 }\r
3656 \r
3657 \r
3658                 ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;\r
3659                 ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;\r
3660                 move -= ob->distance;\r
3661 \r
3662                 SelectPathDir (ob);\r
3663 \r
3664                 if ( !(--ob->temp1) )\r
3665                 {\r
3666                         NewState (ob,&s_bjjump1);\r
3667                         return;\r
3668                 }\r
3669         }\r
3670 }\r
3671 \r
3672 \r
3673 /*\r
3674 ===============\r
3675 =\r
3676 = T_BJJump\r
3677 =\r
3678 ===============\r
3679 */\r
3680 \r
3681 void T_BJJump (objtype *ob)\r
3682 {\r
3683         long    move;\r
3684 \r
3685         move = BJJUMPSPEED*tics;\r
3686         MoveObj (ob,move);\r
3687 }\r
3688 \r
3689 \r
3690 /*\r
3691 ===============\r
3692 =\r
3693 = T_BJYell\r
3694 =\r
3695 ===============\r
3696 */\r
3697 \r
3698 void T_BJYell (objtype *ob)\r
3699 {\r
3700         PlaySoundLocActor(YEAHSND,ob);  // JAB\r
3701 }\r
3702 \r
3703 \r
3704 /*\r
3705 ===============\r
3706 =\r
3707 = T_BJDone\r
3708 =\r
3709 ===============\r
3710 */\r
3711 \r
3712 #pragma argsused\r
3713 void T_BJDone (objtype *ob)\r
3714 {\r
3715         playstate = ex_victorious;                              // exit castle tile\r
3716 }\r
3717 \r
3718 \r
3719 \r
3720 //===========================================================================\r
3721 \r
3722 \r
3723 /*\r
3724 ===============\r
3725 =\r
3726 = CheckPosition\r
3727 =\r
3728 ===============\r
3729 */\r
3730 \r
3731 boolean CheckPosition (objtype *ob)\r
3732 {\r
3733         int     x,y,xl,yl,xh,yh;\r
3734         objtype *check;\r
3735 \r
3736         xl = (ob->x-PLAYERSIZE) >>TILESHIFT;\r
3737         yl = (ob->y-PLAYERSIZE) >>TILESHIFT;\r
3738 \r
3739         xh = (ob->x+PLAYERSIZE) >>TILESHIFT;\r
3740         yh = (ob->y+PLAYERSIZE) >>TILESHIFT;\r
3741 \r
3742         //\r
3743         // check for solid walls\r
3744         //\r
3745         for (y=yl;y<=yh;y++)\r
3746                 for (x=xl;x<=xh;x++)\r
3747                 {\r
3748                         check = actorat[x][y];\r
3749                         if (check && check<objlist)\r
3750                                 return false;\r
3751                 }\r
3752 \r
3753         return true;\r
3754 }\r
3755 \r
3756 \r
3757 /*\r
3758 ===============\r
3759 =\r
3760 = A_StartDeathCam\r
3761 =\r
3762 ===============\r
3763 */\r
3764 \r
3765 void    A_StartDeathCam (objtype *ob)\r
3766 {\r
3767         long    dx,dy;\r
3768         float   fangle;\r
3769         long    xmove,ymove;\r
3770         long    dist;\r
3771         int             temp,i;\r
3772 \r
3773         FinishPaletteShifts ();\r
3774 \r
3775         VW_WaitVBL (100);\r
3776 \r
3777         if (gamestate.victoryflag)\r
3778         {\r
3779                 playstate = ex_victorious;                              // exit castle tile\r
3780                 return;\r
3781         }\r
3782 \r
3783         gamestate.victoryflag = true;\r
3784         VW_Bar (0,0,320,200-STATUSLINES,127);\r
3785         FizzleFade(bufferofs,displayofs,320,200-STATUSLINES,70,false);\r
3786 \r
3787         PM_UnlockMainMem ();\r
3788         CA_UpLevel ();\r
3789         CacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);\r
3790         #ifdef JAPAN\r
3791         #ifndef JAPDEMO\r
3792         CA_CacheScreen(C_LETSSEEPIC);\r
3793         #endif\r
3794         #else\r
3795         Write(0,7,STR_SEEAGAIN);\r
3796         #endif\r
3797         CA_DownLevel ();\r
3798         PM_CheckMainMem ();\r
3799 \r
3800         VW_UpdateScreen ();\r
3801 \r
3802         IN_UserInput(300);\r
3803 \r
3804 //\r
3805 // line angle up exactly\r
3806 //\r
3807         NewState (player,&s_deathcam);\r
3808 \r
3809         player->x = gamestate.killx;\r
3810         player->y = gamestate.killy;\r
3811 \r
3812         dx = ob->x - player->x;\r
3813         dy = player->y - ob->y;\r
3814 \r
3815         fangle = atan2(dy,dx);                  // returns -pi to pi\r
3816         if (fangle<0)\r
3817                 fangle = M_PI*2+fangle;\r
3818 \r
3819         player->angle = fangle/(M_PI*2)*ANGLES;\r
3820 \r
3821 //\r
3822 // try to position as close as possible without being in a wall\r
3823 //\r
3824         dist = 0x14000l;\r
3825         do\r
3826         {\r
3827                 xmove = FixedByFrac(dist,costable[player->angle]);\r
3828                 ymove = -FixedByFrac(dist,sintable[player->angle]);\r
3829 \r
3830                 player->x = ob->x - xmove;\r
3831                 player->y = ob->y - ymove;\r
3832                 dist += 0x1000;\r
3833 \r
3834         } while (!CheckPosition (player));\r
3835         plux = player->x >> UNSIGNEDSHIFT;                      // scale to fit in unsigned\r
3836         pluy = player->y >> UNSIGNEDSHIFT;\r
3837         player->tilex = player->x >> TILESHIFT;         // scale to tile values\r
3838         player->tiley = player->y >> TILESHIFT;\r
3839 \r
3840 //\r
3841 // go back to the game\r
3842 //\r
3843         temp = bufferofs;\r
3844         for (i=0;i<3;i++)\r
3845         {\r
3846                 bufferofs = screenloc[i];\r
3847                 DrawPlayBorder ();\r
3848         }\r
3849         bufferofs = temp;\r
3850 \r
3851         fizzlein = true;\r
3852         switch (ob->obclass)\r
3853         {\r
3854 #ifndef SPEAR\r
3855         case schabbobj:\r
3856                 NewState (ob,&s_schabbdeathcam);\r
3857                 break;\r
3858         case realhitlerobj:\r
3859                 NewState (ob,&s_hitlerdeathcam);\r
3860                 break;\r
3861         case giftobj:\r
3862                 NewState (ob,&s_giftdeathcam);\r
3863                 break;\r
3864         case fatobj:\r
3865                 NewState (ob,&s_fatdeathcam);\r
3866                 break;\r
3867 #endif\r
3868         }\r
3869 \r
3870 }\r
3871 \r
3872 #endif\r