C6_ACT2.C 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. /* Catacomb Apocalypse Source Code
  2. * Copyright (C) 1993-2014 Flat Rock Software
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. // C3_PLAY.C
  19. #include "DEF.H"
  20. #pragma hdrstop
  21. /*
  22. =============================================================================
  23. GLOBAL VARIABLES
  24. =============================================================================
  25. */
  26. boolean ShootPlayer (objtype *ob, short obclass, short speed, statetype *state);
  27. void T_ShootPlayer(objtype *ob);
  28. short head_base_delay;
  29. /*
  30. =============================================================================
  31. LOCAL VARIABLES
  32. =============================================================================
  33. */
  34. void T_ShooterObj(objtype *ob);
  35. void SpawnRamBone(int tilex, int tiley);
  36. void T_SkeletonShoot(objtype *ob);
  37. void SpawnFutureMage (int tilex, int tiley);
  38. void T_FMageShoot(objtype *ob);
  39. void SpawnRoboTank(int tilex, int tiley);
  40. void T_RoboTankShoot(objtype *ob);
  41. void SpawnStompy(int tilex, int tiley);
  42. void T_StompyShoot(objtype *ob);
  43. void SpawnBug(int tilex, int tiley);
  44. void T_BugShoot(objtype *ob);
  45. void SpawnShooterEye(int tilex, int tiley);
  46. void T_EyeShootPlayer(objtype *ob);
  47. void SpawnRunningEye(int tilex, int tiley);
  48. void T_RunningEye(objtype *ob);
  49. /*
  50. =============================================================================
  51. LARGE SOUND
  52. =============================================================================
  53. */
  54. void LargeSound (objtype *ob)
  55. {
  56. if (ob->temp1 != SOUNDPLAYED)
  57. {
  58. SD_PlaySound(LARGEMONSTERSND);
  59. ob->temp1 = SOUNDPLAYED;
  60. }
  61. }
  62. /*
  63. =============================================================================
  64. SMALL SOUND
  65. =============================================================================
  66. */
  67. void SmallSound (objtype *ob)
  68. {
  69. if (ob->temp1 != SOUNDPLAYED)
  70. {
  71. SD_PlaySound(SMALLMONSTERSND);
  72. ob->temp1 = SOUNDPLAYED;
  73. }
  74. }
  75. /*
  76. =============================================================================
  77. RAMBONE
  78. =============================================================================
  79. */
  80. statetype s_skel_1 = {RAMBONEWALK1PIC, 10, &T_ShooterObj, &s_skel_2};
  81. statetype s_skel_2 = {RAMBONEWALK2PIC, 10, &T_ShooterObj, &s_skel_3};
  82. statetype s_skel_3 = {RAMBONEWALK3PIC, 10, &T_ShooterObj, &s_skel_4};
  83. statetype s_skel_4 = {RAMBONEWALK4PIC, 10, &T_ShooterObj, &s_skel_1};
  84. statetype s_skel_attack1 = {RAMBONEATTACK1PIC, 12, NULL, &s_skel_attack2};
  85. statetype s_skel_attack2 = {RAMBONEATTACK2PIC, 20, NULL, &s_skel_attack3};
  86. statetype s_skel_attack3 = {RAMBONEATTACK2PIC, -1, T_SkeletonShoot, &s_skel_attack4};
  87. statetype s_skel_attack4 = {RAMBONEATTACK3PIC, 20, NULL, &s_skel_ouch};
  88. statetype s_skel_ouch = {RAMBONEATTACK1PIC, 10, NULL, &s_skel_1};
  89. statetype s_skel_die1 = {RAMBONEDEATH1PIC, 40, NULL, &s_skel_die2};
  90. statetype s_skel_die2 = {RAMBONEDEATH2PIC, 30, NULL, &s_skel_die3};
  91. statetype s_skel_die3 = {RAMBONEDEATH3PIC, 20, &LargeSound, NULL};
  92. statetype s_skel_shot1 = {RAMBONESHOT1PIC, 10, &T_ShootPlayer, &s_skel_shot2};
  93. statetype s_skel_shot2 = {RAMBONESHOT2PIC, 10, &T_ShootPlayer, &s_skel_shot1};
  94. #define shooter_mode ob->temp1
  95. #define shooter_delay ob->temp2
  96. /*
  97. ===============
  98. =
  99. = SpawnSkeleton
  100. =
  101. ===============
  102. */
  103. void SpawnRamBone(int tilex, int tiley)
  104. {
  105. SpawnNewObj(tilex, tiley, &s_skel_1,PIXRADIUS*20);
  106. new->obclass = ramboneobj;
  107. new->speed = 2036;
  108. new->flags |= of_shootable;
  109. new->hitpoints = EasyHitPoints(12);
  110. }
  111. /*
  112. =================
  113. =
  114. = T_SkeletonShoot
  115. =
  116. =================
  117. */
  118. void T_SkeletonShoot(objtype *ob)
  119. {
  120. ShootPlayer(ob, rbshotobj, MSHOTSPEED, &s_skel_shot1);
  121. }
  122. /*
  123. =============================================================================
  124. FUTURE MAGE
  125. =============================================================================
  126. */
  127. statetype s_fmage1 = {FMAGEWALK1PIC, 20, &T_ShooterObj, &s_fmage2};
  128. statetype s_fmage2 = {FMAGEWALK2PIC, 20, &T_ShooterObj, &s_fmage3};
  129. statetype s_fmage3 = {FMAGEWALK3PIC, 20, &T_ShooterObj, &s_fmage1};
  130. statetype s_fmageattack1 = {FMAGEATTACK1PIC, 20, NULL, &s_fmageattack2};
  131. statetype s_fmageattack2 = {FMAGEATTACK1PIC, -1, &T_FMageShoot, &s_fmageattack3};
  132. statetype s_fmageattack3 = {FMAGEATTACK2PIC, 30, NULL, &s_fmage1};
  133. statetype s_fmageouch = {FMAGEATTACK1PIC, 10, NULL, &s_fmage1};
  134. statetype s_fmagedie1 = {FMAGEDEATH1PIC, 40, NULL, &s_fmagedie2};
  135. statetype s_fmagedie2 = {FMAGEDEATH2PIC, 30, &SmallSound, &s_fmagedie3};
  136. statetype s_fmagedie3 = {FMAGEDEATH3PIC, 0, NULL, &s_fmagedie3};
  137. statetype s_fmshot1 = {FMAGESHOT1PIC, 8, &T_ShootPlayer, &s_fmshot2};
  138. statetype s_fmshot2 = {FMAGESHOT2PIC, 8, &T_ShootPlayer, &s_fmshot1};
  139. /*
  140. =================
  141. =
  142. = SpawnFutureMage
  143. =
  144. =================
  145. */
  146. void SpawnFutureMage (int tilex, int tiley)
  147. {
  148. SpawnNewObj(tilex, tiley, &s_fmage1, PIXRADIUS*15);
  149. new->obclass = fmageobj;
  150. new->speed = 3072;
  151. new->flags |= of_shootable;
  152. new->hitpoints = EasyHitPoints(12);
  153. }
  154. /*
  155. =================
  156. =
  157. = T_FMageShoot
  158. =
  159. =================
  160. */
  161. void T_FMageShoot(objtype *ob)
  162. {
  163. ShootPlayer(ob, fmshotobj, MSHOTSPEED, &s_fmshot1);
  164. }
  165. /*
  166. =============================================================================
  167. ROBO TANK
  168. =============================================================================
  169. */
  170. statetype s_robotank_walk1 = {ROBOTANKWALK1PIC, 15, &T_ShooterObj, &s_robotank_walk2};
  171. statetype s_robotank_walk2 = {ROBOTANKWALK2PIC, 15, &T_ShooterObj, &s_robotank_walk3};
  172. statetype s_robotank_walk3 = {ROBOTANKWALK3PIC, 15, &T_ShooterObj, &s_robotank_walk4};
  173. statetype s_robotank_walk4 = {ROBOTANKWALK4PIC, 15, &T_ShooterObj, &s_robotank_walk1};
  174. statetype s_robotank_attack1 = {ROBOTANKWALK1PIC, 15, NULL, &s_robotank_attack2};
  175. statetype s_robotank_attack2 = {ROBOTANKATTACK1PIC, 15, NULL, &s_robotank_attack3};
  176. statetype s_robotank_attack3 = {ROBOTANKATTACK1PIC, -1, &T_RoboTankShoot, &s_robotank_attack4};
  177. statetype s_robotank_attack4 = {ROBOTANKWALK1PIC, 15, NULL, &s_robotank_walk1};
  178. statetype s_robotank_death1 = {ROBOTANKDEATH1PIC, 8, NULL, &s_robotank_death2};
  179. statetype s_robotank_death2 = {ROBOTANKDEATH2PIC, 8, NULL, &s_robotank_death3};
  180. statetype s_robotank_death3 = {ROBOTANKDEATH2PIC, -1, &T_AlternateStates, &s_robotank_death1};
  181. statetype s_robotank_death4 = {ROBOTANKDEATH3PIC, 25, &ExplosionSnd, &s_robotank_death5};
  182. statetype s_robotank_death5 = {ROBOTANKDEATH4PIC, 20, NULL, &s_robotank_death5};
  183. statetype s_robotank_shot1 = {PSHOT1PIC, 10, &T_ShootPlayer, &s_robotank_shot2};
  184. statetype s_robotank_shot2 = {PSHOT2PIC, 10, &T_ShootPlayer, &s_robotank_shot1};
  185. /*
  186. =================
  187. =
  188. = SpawnRoboTank
  189. =
  190. =================
  191. */
  192. void SpawnRoboTank(int tilex, int tiley)
  193. {
  194. SpawnNewObj(tilex, tiley, &s_robotank_walk1, PIXRADIUS*35);
  195. new->obclass = robotankobj;
  196. new->speed = 1700;
  197. new->flags |= of_shootable;
  198. new->hitpoints = EasyHitPoints(25);
  199. }
  200. /*
  201. =================
  202. =
  203. = T_RoboTankShoot
  204. =
  205. =================
  206. */
  207. void T_RoboTankShoot(objtype *ob)
  208. {
  209. ShootPlayer(ob, rtshotobj, 7000, &s_robotank_shot1);
  210. }
  211. /*
  212. ====================
  213. =
  214. = T_AlternateStates
  215. =
  216. ====================
  217. */
  218. void T_AlternateStates(objtype *ob)
  219. {
  220. if (ob->temp1--)
  221. {
  222. ob->state = ob->state->next;
  223. }
  224. else
  225. {
  226. if (ob->state == &s_robotank_death3)
  227. ob->state = &s_robotank_death4;
  228. else
  229. ob->state = &s_aqua_die4;
  230. }
  231. ob->ticcount = ob->state->tictime;
  232. }
  233. /*
  234. =============================================================================
  235. STOMPY
  236. =============================================================================
  237. */
  238. statetype s_stompy_walk1 = {STOMPYWALK1PIC, 15, &T_ShooterObj, &s_stompy_walk2};
  239. statetype s_stompy_walk2 = {STOMPYWALK2PIC, 15, &T_ShooterObj, &s_stompy_walk3};
  240. statetype s_stompy_walk3 = {STOMPYWALK3PIC, 15, &T_ShooterObj, &s_stompy_walk4};
  241. statetype s_stompy_walk4 = {STOMPYWALK4PIC, 15, &T_ShooterObj, &s_stompy_walk1};
  242. statetype s_stompy_attack1 = {STOMPYATTACK1PIC, 10, NULL, &s_stompy_attack2};
  243. statetype s_stompy_attack2 = {STOMPYATTACK2PIC, 15, NULL, &s_stompy_attack3};
  244. statetype s_stompy_attack3 = {STOMPYATTACK2PIC, -1, T_StompyShoot, &s_stompy_attack4};
  245. statetype s_stompy_attack4 = {STOMPYATTACK1PIC, 10, NULL, &s_stompy_walk1};
  246. statetype s_stompy_ouch = {STOMPYATTACK1PIC, 10, NULL, &s_stompy_walk2};
  247. statetype s_stompy_death1 = {STOMPYDEATH1PIC, 45, &ExplosionSnd, &s_stompy_death2};
  248. statetype s_stompy_death2 = {STOMPYDEATH2PIC, 30, NULL, &s_stompy_death3};
  249. statetype s_stompy_death3 = {STOMPYDEATH3PIC, 25, NULL, &s_stompy_death4};
  250. statetype s_stompy_death4 = {STOMPYDEATH4PIC, 20, NULL, NULL};
  251. statetype s_stompy_shot1 = {STOMPYSHOT1PIC, 6, &T_ShootPlayer, &s_stompy_shot2};
  252. statetype s_stompy_shot2 = {STOMPYSHOT2PIC, 6, &T_ShootPlayer, &s_stompy_shot3};
  253. statetype s_stompy_shot3 = {STOMPYSHOT1PIC, 6, &T_ShootPlayer, &s_stompy_shot4};
  254. statetype s_stompy_shot4 = {STOMPYSHOT3PIC, 6, &T_ShootPlayer, &s_stompy_shot5};
  255. statetype s_stompy_shot5 = {STOMPYSHOT4PIC, 6, &T_ShootPlayer, &s_stompy_shot4};
  256. /*
  257. =================
  258. =
  259. = SpawnStompy
  260. =
  261. =================
  262. */
  263. void SpawnStompy(int tilex, int tiley)
  264. {
  265. SpawnNewObj(tilex, tiley, &s_stompy_walk1, PIXRADIUS*25);
  266. new->obclass = stompyobj;
  267. new->speed = 1800;
  268. new->flags |= of_shootable;
  269. new->hitpoints = EasyHitPoints(20);
  270. }
  271. /*
  272. =================
  273. =
  274. = T_StompyShoot
  275. =
  276. =================
  277. */
  278. void T_StompyShoot(objtype *ob)
  279. {
  280. ShootPlayer(ob, syshotobj, 8500, &s_stompy_shot1);
  281. }
  282. /*
  283. =============================================================================
  284. BUG
  285. =============================================================================
  286. */
  287. statetype s_bug_walk1 = {BUG_WALK1PIC, 15, &T_ShooterObj, &s_bug_walk2};
  288. statetype s_bug_walk2 = {BUG_WALK2PIC, 15, &T_ShooterObj, &s_bug_walk3};
  289. statetype s_bug_walk3 = {BUG_WALK3PIC, 15, &T_ShooterObj, &s_bug_walk1};
  290. statetype s_bug_attack1 = {BUG_ATTACK1PIC, 20, NULL, &s_bug_attack2};
  291. statetype s_bug_attack2 = {BUG_ATTACK2PIC, 20, NULL, &s_bug_attack3};
  292. statetype s_bug_attack3 = {BUG_ATTACK2PIC, -1, &T_BugShoot, &s_bug_attack4};
  293. statetype s_bug_attack4 = {BUG_ATTACK1PIC, 15, NULL, &s_bug_walk1};
  294. statetype s_bug_ouch = {BUG_WALK1PIC, 10, NULL, &s_bug_walk2};
  295. statetype s_bug_death1 = {BUG_DEATH1PIC, 35, &SmallSound, &s_bug_death2};
  296. statetype s_bug_death2 = {BUG_DEATH2PIC, 10, NULL, &s_bug_death2};
  297. statetype s_bug_shot1 = {BUG_SHOT1PIC, 10, &T_ShootPlayer, &s_bug_shot2};
  298. statetype s_bug_shot2 = {BUG_SHOT2PIC, 10, &T_ShootPlayer, &s_bug_shot1};
  299. /*
  300. =================
  301. =
  302. = SpawnBug
  303. =
  304. =================
  305. */
  306. void SpawnBug(int tilex, int tiley)
  307. {
  308. SpawnNewObj(tilex, tiley, &s_bug_walk1, PIXRADIUS*20);
  309. new->obclass = bugobj;
  310. new->speed = 1500;
  311. new->flags |= of_shootable;
  312. new->hitpoints = EasyHitPoints(10);
  313. }
  314. /*
  315. =================
  316. =
  317. = T_BugShoot
  318. =
  319. =================
  320. */
  321. void T_BugShoot(objtype *ob)
  322. {
  323. ShootPlayer(ob, bgshotobj, 8000, &s_bug_shot1);
  324. }
  325. /*
  326. =============================================================================
  327. MEC EYE
  328. =============================================================================
  329. */
  330. void T_EyeShootPlayer (objtype *ob);
  331. statetype s_eye_pause = {EYE_WALK1PIC,40,NULL,&s_eye_2};
  332. statetype s_eye_1 = {EYE_WALK1PIC,20,T_ShooterObj,&s_eye_2};
  333. statetype s_eye_2 = {EYE_WALK2PIC,20,T_ShooterObj,&s_eye_3};
  334. statetype s_eye_3 = {EYE_WALK3PIC,20,T_ShooterObj,&s_eye_4};
  335. statetype s_eye_4 = {EYE_WALK2PIC,20,T_ShooterObj,&s_eye_1};
  336. statetype s_eye_shootplayer_1 = {EYE_WALK1PIC,1,T_EyeShootPlayer,&s_eye_shootplayer_2};
  337. statetype s_eye_shootplayer_2 = {EYE_WALK1PIC,20,NULL,&s_eye_1};
  338. statetype s_eye_ouch = {EYE_OUCH1PIC,8,NULL,&s_eye_ouch2};
  339. statetype s_eye_ouch2 = {EYE_OUCH2PIC,8,NULL,&s_eye_1};
  340. statetype s_eye_die1 = {EYE_DEATH1PIC,22,NULL,&s_eye_die2};
  341. statetype s_eye_die2 = {EYE_DEATH2PIC,22,&SmallSound,&s_eye_die3};
  342. statetype s_eye_die3 = {EYE_DEATH3PIC,22,NULL,&s_eye_die4};
  343. statetype s_eye_die4 = {EYE_DEATH4PIC,22,NULL,&s_eye_die4};
  344. statetype s_eshot1 = {EYE_SHOT1PIC,8,&T_ShootPlayer,&s_eshot2};
  345. statetype s_eshot2 = {EYE_SHOT2PIC,8,&T_ShootPlayer,&s_eshot1};
  346. //-------------------------------------------------------------------------
  347. // SpawnEye()
  348. //-------------------------------------------------------------------------
  349. void SpawnShooterEye(int tilex, int tiley)
  350. {
  351. objtype *ob;
  352. SpawnNewObj(tilex,tiley,&s_eye_1,PIXRADIUS*10);
  353. ob = new;
  354. new->obclass = eyeobj;
  355. new->speed = 3000;
  356. new->flags |= of_shootable;
  357. new->hitpoints = EasyHitPoints(15);
  358. shooter_mode = sm_other1;
  359. }
  360. //---------------------------------------------------------------------------
  361. // T_EyeShootPlayer
  362. //---------------------------------------------------------------------------
  363. void T_EyeShootPlayer (objtype *ob)
  364. {
  365. ShootPlayer(ob, eshotobj, ESHOTSPEED, &s_eshot1);
  366. }
  367. /*
  368. ===============
  369. =
  370. = T_ShooterObj
  371. =
  372. = **********
  373. = ***NOTE*** This routine controls the thinks for the RamBone, RoboTank,
  374. = ********** Stompy, Future Mage, Bug, and Old Mage
  375. =
  376. ===============
  377. */
  378. void T_ShooterObj(objtype *ob)
  379. {
  380. fixed tempx,tempy;
  381. unsigned temp_tilex,temp_tiley;
  382. int angle;
  383. shooter_delay -= realtics;
  384. if (shooter_delay < 0)
  385. {
  386. shooter_mode = random(sm_dummy);
  387. shooter_delay = random(10*60)+random(50);
  388. }
  389. tempx = player->x;
  390. tempy = player->y;
  391. temp_tilex = player->tilex;
  392. temp_tiley = player->tiley;
  393. switch (shooter_mode)
  394. {
  395. case sm_other1:
  396. case sm_other2:
  397. case sm_other3:
  398. case sm_other4:
  399. player->x = ((long)other_x[shooter_mode]<<TILESHIFT)+TILEGLOBAL/2;
  400. player->y = ((long)other_y[shooter_mode]<<TILESHIFT)+TILEGLOBAL/2;
  401. player->tilex = other_x[shooter_mode];
  402. player->tiley = other_y[shooter_mode];
  403. break;
  404. }
  405. if (Chase(ob,true))
  406. shooter_delay = 0;
  407. player->x = tempx;
  408. player->y = tempy;
  409. player->tilex = temp_tilex;
  410. player->tiley = temp_tiley;
  411. angle = AngleNearPlayer(ob);
  412. // Handle shooting for the different characters controlled by this think.
  413. switch (ob->obclass)
  414. {
  415. case ramboneobj:
  416. if (!random(2) && (angle != -1))
  417. {
  418. ob->state = &s_skel_attack1;
  419. ob->ticcount = ob->state->tictime;
  420. }
  421. break;
  422. case fmageobj:
  423. if (!random(8) && (angle != -1))
  424. {
  425. ob->state = &s_fmageattack1;
  426. ob->ticcount = ob->state->tictime;
  427. }
  428. break;
  429. case robotankobj:
  430. if (!random(15) && (angle != -1))
  431. {
  432. ob->state = &s_robotank_attack1;
  433. ob->ticcount = ob->state->tictime;
  434. }
  435. break;
  436. case stompyobj:
  437. if (angle != -1)
  438. {
  439. ob->state = &s_stompy_attack1;
  440. ob->ticcount = ob->state->tictime;
  441. }
  442. break;
  443. case bugobj:
  444. if (!random(5) && (angle != -1))
  445. {
  446. ob->state = &s_bug_attack1;
  447. ob->ticcount = ob->state->tictime;
  448. }
  449. break;
  450. case eyeobj:
  451. if (!random(2) && (angle != -1))
  452. {
  453. ob->state = &s_eye_shootplayer_1;
  454. ob->ticcount = ob->state->tictime;
  455. }
  456. break;
  457. }
  458. }
  459. /*
  460. =============================================================================
  461. RUNNING EYE
  462. =============================================================================
  463. */
  464. statetype s_reye_1 = {EYE_WALK1PIC, 20, &T_RunningEye, &s_reye_2};
  465. statetype s_reye_2 = {EYE_WALK2PIC, 20, &T_RunningEye, &s_reye_3};
  466. statetype s_reye_3 = {EYE_WALK3PIC, 20, &T_RunningEye, &s_reye_4};
  467. statetype s_reye_4 = {EYE_WALK2PIC, 20, &T_RunningEye, &s_reye_1};
  468. statetype s_reye_ouch = {EYE_OUCH1PIC, 8, NULL, &s_reye_ouch2};
  469. statetype s_reye_ouch2 = {EYE_OUCH2PIC, 8, NULL, &s_reye_1};
  470. statetype s_reye_die1 = {EYE_DEATH1PIC, 22, NULL, &s_reye_die2};
  471. statetype s_reye_die2 = {EYE_DEATH2PIC, 22, &SmallSound, &s_reye_die3};
  472. statetype s_reye_die3 = {EYE_DEATH3PIC, 22, NULL, &s_reye_die4};
  473. statetype s_reye_die4 = {EYE_DEATH4PIC, 22, NULL, &s_reye_die4};
  474. /*
  475. ====================
  476. =
  477. = SpawnRunningEye()
  478. =
  479. ====================
  480. */
  481. void SpawnRunningEye(int tilex, int tiley)
  482. {
  483. SpawnNewObj(tilex,tiley,&s_reye_1,PIXRADIUS*25);
  484. new->obclass = reyeobj;
  485. new->speed = 3500;
  486. new->flags |= of_shootable;
  487. new->hitpoints = EasyHitPoints(15);
  488. new->temp2 = (*(mapsegs[2]+farmapylookup[tiley+1]+tilex))>>8;
  489. *(mapsegs[2]+farmapylookup[tiley+1]+tilex) = 0;
  490. new->temp1 = 2;
  491. if (!new->temp2)
  492. Quit("Initialize the running eye!\n");
  493. }
  494. /*
  495. ====================
  496. =
  497. = T_RunningEye
  498. =
  499. ====================
  500. */
  501. void T_RunningEye(objtype *ob)
  502. {
  503. int x, y, dir_num, switch_num;
  504. fixed tempx,tempy;
  505. unsigned temp_tilex,temp_tiley;
  506. dir_num = *(mapsegs[2]+farmapylookup[ob->tiley]+ob->tilex);
  507. dir_num = dir_num>>8;
  508. if (!dir_num)
  509. dir_num = ob->temp2;
  510. if (dir_num == 5)
  511. {
  512. if (ob->temp1)
  513. {
  514. ob->temp1--;
  515. }
  516. else
  517. {
  518. ob->temp1 = 2;
  519. actorat[ob->tilex][ob->tiley] = 0;
  520. switch (ob->temp2)
  521. {
  522. case 1:
  523. ob->tiley = ob->tiley-1;
  524. ob->y = ((long)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2;
  525. break;
  526. case 2:
  527. ob->tilex = ob->tilex+1;
  528. ob->x = ((long)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2;
  529. break;
  530. case 3:
  531. ob->tiley = ob->tiley+1;
  532. ob->y = ((long)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2;
  533. break;
  534. case 0:
  535. case 4:
  536. ob->tilex = ob->tilex-1;
  537. ob->x = ((long)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2;
  538. break;
  539. }
  540. CalcBounds (ob);
  541. ChaseThink(ob,false);
  542. actorat[ob->tilex][ob->tiley] = ob;
  543. return;
  544. }
  545. }
  546. tempx = player->x;
  547. tempy = player->y;
  548. temp_tilex = player->tilex;
  549. temp_tiley = player->tiley;
  550. if (dir_num == 5)
  551. switch_num = ob->temp2;
  552. else
  553. switch_num = dir_num;
  554. switch (switch_num)
  555. {
  556. case 1:
  557. player->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
  558. player->y = ((long)(ob->tiley-2)<<TILESHIFT)+TILEGLOBAL/2;
  559. player->tilex = ob->tilex;
  560. player->tiley = ob->tiley-2;
  561. break;
  562. case 2:
  563. player->x = ((long)(ob->tilex+2)<<TILESHIFT)+TILEGLOBAL/2;
  564. player->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
  565. player->tilex = ob->tilex+2;
  566. player->tiley = ob->tiley;
  567. break;
  568. case 3:
  569. player->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
  570. player->y = ((long)(ob->tiley+2)<<TILESHIFT)+TILEGLOBAL/2;
  571. player->tilex = ob->tilex;
  572. player->tiley = ob->tiley+2;
  573. break;
  574. case 0:
  575. case 4:
  576. player->x = ((long)(ob->tilex-2)<<TILESHIFT)+TILEGLOBAL/2;
  577. player->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
  578. player->tilex = ob->tilex-2;
  579. player->tiley = ob->tiley;
  580. break;
  581. }
  582. Chase(ob, false);
  583. player->x = tempx;
  584. player->y = tempy;
  585. player->tilex = temp_tilex;
  586. player->tiley = temp_tiley;
  587. if (dir_num != 5)
  588. ob->temp2 = dir_num;
  589. }
  590. /*
  591. =============================================================================
  592. EGYPTIAN HEAD
  593. =============================================================================
  594. */
  595. void T_Head(objtype *ob);
  596. statetype s_head = {HEADPIC, 20, &T_Head, &s_head};
  597. statetype s_head_shot1 = {PSHOT1PIC, 10, &T_ShootPlayer, &s_head_shot2};
  598. statetype s_head_shot2 = {PSHOT2PIC, 10, &T_ShootPlayer, &s_head_shot1};
  599. /*
  600. ===================
  601. =
  602. = SpawnEgyptianHead
  603. =
  604. ===================
  605. */
  606. void SpawnEgyptianHead (int tilex, int tiley)
  607. {
  608. objtype *ob;
  609. short current_head_delay;
  610. unsigned tile;
  611. SpawnNewObj(tilex, tiley, &s_head, PIXRADIUS*35);
  612. ob = new;
  613. head_mode = h_wait_to_rise;
  614. tile = *(mapsegs[2]+farmapylookup[tiley+1]+tilex);
  615. if (tile)
  616. head_delay = (tile>>8)*30;
  617. else
  618. {
  619. current_head_delay = (3*60)+random(3*60);
  620. head_delay = head_base_delay+current_head_delay;
  621. head_base_delay += current_head_delay;
  622. if (head_base_delay > 8*60)
  623. head_base_delay = 0;
  624. }
  625. new->obclass = realsolidobj;
  626. new->speed = 3000;
  627. new->flags |= of_shootable;
  628. }
  629. //--------------------------------------------------------------------------
  630. // T_Head()
  631. //--------------------------------------------------------------------------
  632. void T_Head(objtype *ob)
  633. {
  634. fixed tempx,tempy;
  635. unsigned temp_tilex,temp_tiley;
  636. int angle;
  637. switch (head_mode)
  638. {
  639. case h_wait_to_rise:
  640. if (head_delay < 0)
  641. {
  642. if ((ob->tilex == player->tilex) && (ob->tiley == player->tiley))
  643. break;
  644. if (CheckHandAttack(ob))
  645. break;
  646. ob->obclass = headobj;
  647. ob->active = always;
  648. head_mode = h_active;
  649. head_delay = random(100)+random(60);
  650. ob->hitpoints = EasyHitPoints(16);
  651. }
  652. else
  653. head_delay -= tics;
  654. break;
  655. case h_player1:
  656. case h_player2:
  657. case h_player3:
  658. case h_player4:
  659. case h_active:
  660. Chase (ob,true);
  661. if (!random(2) && (angle != -1))
  662. ShootPlayer(ob, hshotobj, 10000, &s_head_shot1);
  663. head_delay -= tics;
  664. if (head_delay < 0)
  665. {
  666. head_mode = random(h_other4)+1;
  667. head_delay = random(10*60)+random(50);
  668. }
  669. break;
  670. case h_other1:
  671. case h_other2:
  672. case h_other3:
  673. case h_other4:
  674. tempx = player->x;
  675. tempy = player->y;
  676. temp_tilex = player->tilex;
  677. temp_tiley = player->tiley;
  678. player->x = ((long)other_x[head_mode]<<TILESHIFT)+TILEGLOBAL/2;
  679. player->y = ((long)other_y[head_mode]<<TILESHIFT)+TILEGLOBAL/2;
  680. player->tilex = other_x[head_mode];
  681. player->tiley = other_y[head_mode];
  682. if (Chase(ob,true))
  683. head_delay = 0;
  684. player->x = tempx;
  685. player->y = tempy;
  686. player->tilex = temp_tilex;
  687. player->tiley = temp_tiley;
  688. head_delay -= tics;
  689. if (head_delay <= 0)
  690. {
  691. head_mode = h_active;
  692. head_delay = random(10*60)+random(50);
  693. }
  694. break;
  695. }
  696. }