home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / misc / wolfsrc.1 / WL_ACT2.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  94KB  |  3,873 lines

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