C5_ACT4.C 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. /* Catacomb Armageddon 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. // C4_PLAY.C
  19. #include "DEF.H"
  20. #pragma hdrstop
  21. /*
  22. =============================================================================
  23. LOCAL CONSTANTS
  24. =============================================================================
  25. */
  26. //-------------------------------------------------------------------------
  27. //
  28. // ARCH OBJECTS
  29. //
  30. //-------------------------------------------------------------------------
  31. //-------------------------------------------------------------------------
  32. // ARCH
  33. //-------------------------------------------------------------------------
  34. void SpawnArch(int tilex, int tiley, int num);
  35. extern statetype s_arch_1;
  36. extern statetype s_arch_2;
  37. extern statetype s_arch_3;
  38. extern statetype s_arch_4;
  39. extern statetype s_arch_5;
  40. extern statetype s_arch_6;
  41. extern statetype s_arch_7;
  42. extern statetype s_arch_8;
  43. extern statetype s_arch_9;
  44. extern statetype s_arch_10;
  45. extern statetype s_arch_11;
  46. extern statetype s_arch_12;
  47. extern statetype s_arch_13;
  48. statetype s_arch_1 = {ARCH1PIC, 20, NULL, &s_arch_1};
  49. statetype s_arch_2 = {ARCH2PIC, 20, NULL, &s_arch_2};
  50. statetype s_arch_3 = {ARCH3PIC, 20, NULL, &s_arch_3};
  51. statetype s_arch_4 = {ARCH4PIC, 20, NULL, &s_arch_4};
  52. statetype s_arch_5 = {ARCH5PIC, 20, NULL, &s_arch_5};
  53. statetype s_arch_6 = {ARCH6PIC, 20, NULL, &s_arch_6};
  54. statetype s_arch_7 = {ARCH7PIC, 20, NULL, &s_arch_7};
  55. statetype s_arch_8 = {ARCH8PIC, 20, NULL, &s_arch_8};
  56. statetype s_arch_9 = {ARCH9PIC, 20, NULL, &s_arch_9};
  57. statetype s_arch_10 = {ARCH10PIC, 20, NULL, &s_arch_10};
  58. statetype s_arch_11 = {ARCH11PIC, 20, NULL, &s_arch_11};
  59. statetype s_arch_12 = {ARCH12PIC, 20, NULL, &s_arch_12};
  60. statetype s_arch_13 = {ARCH13PIC, 20, NULL, &s_arch_13};
  61. void SpawnArch (int tilex, int tiley, int num)
  62. {
  63. statetype *objstate;
  64. switch (num)
  65. {
  66. case 1:
  67. objstate = &s_arch_1;
  68. break;
  69. case 2:
  70. objstate = &s_arch_2;
  71. break;
  72. case 3:
  73. objstate = &s_arch_3;
  74. break;
  75. case 4:
  76. objstate = &s_arch_4;
  77. break;
  78. case 5:
  79. objstate = &s_arch_5;
  80. break;
  81. case 6:
  82. objstate = &s_arch_6;
  83. break;
  84. case 7:
  85. objstate = &s_arch_7;
  86. break;
  87. case 8:
  88. objstate = &s_arch_8;
  89. break;
  90. case 9:
  91. objstate = &s_arch_9;
  92. break;
  93. case 10:
  94. objstate = &s_arch_10;
  95. break;
  96. case 11:
  97. objstate = &s_arch_11;
  98. break;
  99. case 12:
  100. objstate = &s_arch_12;
  101. break;
  102. case 13:
  103. objstate = &s_arch_13;
  104. break;
  105. }
  106. ASpawnNewObj(tilex,tiley,objstate,PIXRADIUS*35);
  107. new->obclass = solidobj;
  108. new->flags &= ~of_shootable;
  109. }
  110. //-------------------------------------------------------------------------
  111. //
  112. // MISC OBJECTS
  113. //
  114. //-------------------------------------------------------------------------
  115. //-------------------------------------------------------------------------
  116. // COLUMN, SULPHUR GAS HOLE, FIRE POT, FOUNTAIN
  117. //-------------------------------------------------------------------------
  118. void SpawnMiscObjects(int tilex, int tiley, int num);
  119. extern statetype s_column;
  120. extern statetype s_sulphur_gas_1;
  121. extern statetype s_sulphur_gas_2;
  122. extern statetype s_sulphur_gas_3;
  123. extern statetype s_fire_pot_1;
  124. extern statetype s_fire_pot_2;
  125. extern statetype s_fountain;
  126. statetype s_column = {COLUMNPIC, 20, NULL, &s_column};
  127. statetype s_sulphur_gas_1 = {SULPHUR_GAS_1PIC, 20, NULL, &s_sulphur_gas_2};
  128. statetype s_sulphur_gas_2 = {SULPHUR_GAS_2PIC, 20, NULL, &s_sulphur_gas_3};
  129. statetype s_sulphur_gas_3 = {SULPHUR_GAS_3PIC, 20, NULL, &s_sulphur_gas_1};
  130. statetype s_fire_pot_1 = {FIRE_POT_1PIC, 20, NULL, &s_fire_pot_2};
  131. statetype s_fire_pot_2 = {FIRE_POT_2PIC, 20, NULL, &s_fire_pot_1};
  132. statetype s_fountain = {WFOUNTAINPIC, 20, NULL, &s_fountain};
  133. void SpawnMiscObjects(int tilex, int tiley, int num)
  134. {
  135. statetype *objstate;
  136. switch (num)
  137. {
  138. case 1:
  139. objstate = &s_column;
  140. break;
  141. case 2:
  142. objstate = &s_sulphur_gas_1;
  143. break;
  144. case 3:
  145. objstate = &s_fire_pot_1;
  146. break;
  147. case 4:
  148. objstate = &s_fountain;
  149. break;
  150. }
  151. SpawnNewObj(tilex,tiley,objstate,PIXRADIUS*35);
  152. new->obclass = realsolidobj;
  153. if (num == 2)
  154. new->flags &= ~of_shootable;
  155. else
  156. new->flags |= of_shootable;
  157. }
  158. #if 0
  159. void SpawnColumn(int tilex, int tiley);
  160. extern statetype s_column;
  161. statetype s_column = {COLUMNPIC, 20, NULL, &s_column};
  162. void SpawnColumn(int tilex, int tiley)
  163. {
  164. SpawnNewObj(tilex,tiley,&s_column,PIXRADIUS*35);
  165. new->obclass = realsolidobj;
  166. new->flags |= of_shootable;
  167. }
  168. //-------------------------------------------------------------------------
  169. // SULPHUR GAS
  170. //-------------------------------------------------------------------------
  171. void SpawnSulphurGas(int tilex, int tiley);
  172. extern statetype s_sulphur_gas_1;
  173. extern statetype s_sulphur_gas_2;
  174. extern statetype s_sulphur_gas_3;
  175. statetype s_sulphur_gas_1 = {SULPHUR_GAS_1PIC, 20, NULL, &s_sulphur_gas_2};
  176. statetype s_sulphur_gas_2 = {SULPHUR_GAS_2PIC, 20, NULL, &s_sulphur_gas_3};
  177. statetype s_sulphur_gas_3 = {SULPHUR_GAS_3PIC, 20, NULL, &s_sulphur_gas_1};
  178. void SpawnSulphurGas(int tilex, int tiley)
  179. {
  180. SpawnNewObj(tilex,tiley,&s_sulphur_gas_1,PIXRADIUS*35);
  181. new->obclass = realsolidobj;
  182. new->flags &= ~of_shootable;
  183. }
  184. //-------------------------------------------------------------------------
  185. // FIRE POT
  186. //-------------------------------------------------------------------------
  187. void SpawnFirePot(int tilex, int tiley);
  188. extern statetype s_fire_pot_1;
  189. extern statetype s_fire_pot_2;
  190. statetype s_fire_pot_1 = {FIRE_POT_1PIC, 20, NULL, &s_fire_pot_2};
  191. statetype s_fire_pot_2 = {FIRE_POT_2PIC, 20, NULL, &s_fire_pot_1};
  192. void SpawnFirePot(int tilex, int tiley)
  193. {
  194. SpawnNewObj(tilex,tiley,&s_fire_pot_1,PIXRADIUS*35);
  195. new->obclass = realsolidobj;
  196. new->flags |= of_shootable;
  197. }
  198. //------------------------------------------------------------------------
  199. // FOUNTAIN
  200. //------------------------------------------------------------------------
  201. void SpawnFountain(int tilex, int tiley);
  202. extern statetype s_fountain;
  203. statetype s_fountain = {WFOUNTAINPIC, 20, NULL, &s_fountain};
  204. void SpawnFountain(int tilex, int tiley)
  205. {
  206. SpawnNewObj(tilex,tiley,&s_fountain,PIXRADIUS*35);
  207. new->obclass = realsolidobj;
  208. new->flags |= of_shootable;
  209. }
  210. #endif
  211. //------------------------------------------------------------------------
  212. // FORCE FIELD
  213. //------------------------------------------------------------------------
  214. void SpawnForceField(int tilex, int tiley);
  215. void T_ForceField(objtype *ob);
  216. void T_ForceFieldRemove(objtype *ob);
  217. extern statetype s_force_field_1;
  218. extern statetype s_force_field_2;
  219. extern statetype s_force_field_3;
  220. extern statetype s_force_field_4;
  221. extern statetype s_force_field_die1;
  222. statetype s_force_field_1 = {FORCE_FIELD_1PIC, 10, T_ForceField, &s_force_field_2};
  223. statetype s_force_field_2 = {FORCE_FIELD_2PIC, 10, T_ForceField, &s_force_field_3};
  224. statetype s_force_field_3 = {FORCE_FIELD_3PIC, 10, T_ForceField, &s_force_field_4};
  225. statetype s_force_field_4 = {FORCE_FIELD_4PIC, 10, T_ForceField, &s_force_field_1};
  226. statetype s_force_field_die = {0,0,T_ForceFieldRemove,&s_force_field_die1};
  227. statetype s_force_field_die1 = {0,0,NULL,NULL};
  228. void SpawnForceField(int tilex, int tiley)
  229. {
  230. SpawnNewObj(tilex,tiley,&s_force_field_1,PIXRADIUS*35);
  231. new->obclass = solidobj;
  232. new->hitpoints = EasyHitPoints(20);
  233. new->flags |= of_forcefield; //sets bit 7 :: makes it nonsolid, but also detectable
  234. // without adding another object type!
  235. new->flags |= of_shootable;
  236. }
  237. void T_ForceField(objtype *ob)
  238. {
  239. long move,deltax,deltay,size;
  240. size = (long)ob->size + player->size;
  241. deltax = ob->x - player->x;
  242. deltay = ob->y - player->y;
  243. if (deltax <= size && deltax >= -size
  244. && deltay <= size && deltay >= -size)
  245. TakeDamage (20);
  246. }
  247. void T_ForceFieldRemove(objtype *ob)
  248. {
  249. actorat[ob->tilex][ob->tiley] = 0;
  250. }
  251. //------------------------------------------------------------------------
  252. // SKELETON HANGING FROM CEILING
  253. //------------------------------------------------------------------------
  254. void SpawnSkeletonHanging(int tilex, int tiley);
  255. void T_SkelHangThink(objtype *ob);
  256. extern statetype s_skeleton_hanging;
  257. statetype s_skeleton_hanging = {SKEL_HANGPIC, 20, T_SkelHangThink, &s_skeleton_hanging};
  258. void SpawnSkeletonHanging(int tilex, int tiley)
  259. {
  260. unsigned tile;
  261. SpawnNewObj(tilex,tiley,&s_skeleton_hanging,PIXRADIUS*35);
  262. new->obclass = solidobj;
  263. tile = *(mapsegs[2]+farmapylookup[tiley+1]+tilex);
  264. if (tile)
  265. new->temp1 = (tile>>8)*30;
  266. else
  267. new->temp1 = (3*60)+random(4*60);
  268. new->flags |= of_shootable;
  269. }
  270. void T_SkelHangThink(objtype *ob)
  271. {
  272. ob->temp1 -= realtics;
  273. if (ob->temp1 <= 0)
  274. {
  275. ob->state = &s_skel_1;
  276. ob->ticcount = ob->state->tictime;
  277. ob->obclass = skeletonobj;
  278. ob->speed = 2036;
  279. ob->flags |= of_shootable;
  280. ob->hitpoints = EasyHitPoints(12);
  281. }
  282. }
  283. /////////////////////////////////////////////////////////////////////////////
  284. //
  285. // EasyHitPoints
  286. //
  287. // Checks to see if the player has selected the easy mode for playing.
  288. // If so then the normal hit points are cut in half.
  289. // This is when the object is spawned.
  290. //
  291. // Parms
  292. // NrmHitPts - the normal hit points
  293. //
  294. // Returns
  295. // Half of NrmHitPts
  296. //
  297. /////////////////////////////////////////////////////////////////////////////
  298. int EasyHitPoints(int NrmHitPts)
  299. {
  300. if (EASYMODEON) // Wimpy, Wimpy, Wimpy!!!!!
  301. {
  302. return(NrmHitPts/4);
  303. }
  304. else
  305. return(NrmHitPts);
  306. }
  307. /////////////////////////////////////////////////////////////////////////////
  308. //
  309. // EasyDoDamage
  310. //
  311. // Checks to see if the player has selected the easy mode for playing.
  312. // If so then the normal amount of damage is cut in half.
  313. // This is called each time a monster does damage.
  314. //
  315. // Parms
  316. // Damage - the normal damage taken
  317. //
  318. // Returns
  319. // Half of Damage
  320. //
  321. /////////////////////////////////////////////////////////////////////////////
  322. int EasyDoDamage(int Damage)
  323. {
  324. if (EASYMODEON) // Wimpy, Wimpy, Wimpy!!!!!
  325. return(Damage/2);
  326. else
  327. return(Damage);
  328. }