m_insane.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /*
  16. ==============================================================================
  17. insane
  18. ==============================================================================
  19. */
  20. #include "g_local.h"
  21. #include "m_insane.h"
  22. static int sound_fist;
  23. static int sound_shake;
  24. static int sound_moan;
  25. static int sound_scream[8];
  26. void insane_fist (edict_t *self)
  27. {
  28. gi.sound (self, CHAN_VOICE, sound_fist, 1, ATTN_IDLE, 0);
  29. }
  30. void insane_shake (edict_t *self)
  31. {
  32. gi.sound (self, CHAN_VOICE, sound_shake, 1, ATTN_IDLE, 0);
  33. }
  34. void insane_moan (edict_t *self)
  35. {
  36. gi.sound (self, CHAN_VOICE, sound_moan, 1, ATTN_IDLE, 0);
  37. }
  38. void insane_scream (edict_t *self)
  39. {
  40. gi.sound (self, CHAN_VOICE, sound_scream[rand()%8], 1, ATTN_IDLE, 0);
  41. }
  42. void insane_stand (edict_t *self);
  43. void insane_dead (edict_t *self);
  44. void insane_cross (edict_t *self);
  45. void insane_walk (edict_t *self);
  46. void insane_run (edict_t *self);
  47. void insane_checkdown (edict_t *self);
  48. void insane_checkup (edict_t *self);
  49. void insane_onground (edict_t *self);
  50. mframe_t insane_frames_stand_normal [] =
  51. {
  52. ai_stand, 0, NULL,
  53. ai_stand, 0, NULL,
  54. ai_stand, 0, NULL,
  55. ai_stand, 0, NULL,
  56. ai_stand, 0, NULL,
  57. ai_stand, 0, insane_checkdown
  58. };
  59. mmove_t insane_move_stand_normal = {FRAME_stand60, FRAME_stand65, insane_frames_stand_normal, insane_stand};
  60. mframe_t insane_frames_stand_insane [] =
  61. {
  62. ai_stand, 0, insane_shake,
  63. ai_stand, 0, NULL,
  64. ai_stand, 0, NULL,
  65. ai_stand, 0, NULL,
  66. ai_stand, 0, NULL,
  67. ai_stand, 0, NULL,
  68. ai_stand, 0, NULL,
  69. ai_stand, 0, NULL,
  70. ai_stand, 0, NULL,
  71. ai_stand, 0, NULL,
  72. ai_stand, 0, NULL,
  73. ai_stand, 0, NULL,
  74. ai_stand, 0, NULL,
  75. ai_stand, 0, NULL,
  76. ai_stand, 0, NULL,
  77. ai_stand, 0, NULL,
  78. ai_stand, 0, NULL,
  79. ai_stand, 0, NULL,
  80. ai_stand, 0, NULL,
  81. ai_stand, 0, NULL,
  82. ai_stand, 0, NULL,
  83. ai_stand, 0, NULL,
  84. ai_stand, 0, NULL,
  85. ai_stand, 0, NULL,
  86. ai_stand, 0, NULL,
  87. ai_stand, 0, NULL,
  88. ai_stand, 0, NULL,
  89. ai_stand, 0, NULL,
  90. ai_stand, 0, NULL,
  91. ai_stand, 0, insane_checkdown
  92. };
  93. mmove_t insane_move_stand_insane = {FRAME_stand65, FRAME_stand94, insane_frames_stand_insane, insane_stand};
  94. mframe_t insane_frames_uptodown [] =
  95. {
  96. ai_move, 0, NULL,
  97. ai_move, 0, NULL,
  98. ai_move, 0, NULL,
  99. ai_move, 0, NULL,
  100. ai_move, 0, NULL,
  101. ai_move, 0, NULL,
  102. ai_move, 0, NULL,
  103. ai_move, 0, insane_moan,
  104. ai_move, 0, NULL,
  105. ai_move, 0, NULL,
  106. ai_move, 0, NULL,
  107. ai_move, 0, NULL,
  108. ai_move, 0, NULL,
  109. ai_move, 0, NULL,
  110. ai_move, 0, NULL,
  111. ai_move, 0, NULL,
  112. ai_move, 0, NULL,
  113. ai_move, 0, NULL,
  114. ai_move, 0, NULL,
  115. ai_move, 0, NULL,
  116. ai_move, 2.7, NULL,
  117. ai_move, 4.1, NULL,
  118. ai_move, 6, NULL,
  119. ai_move, 7.6, NULL,
  120. ai_move, 3.6, NULL,
  121. ai_move, 0, NULL,
  122. ai_move, 0, NULL,
  123. ai_move, 0, insane_fist,
  124. ai_move, 0, NULL,
  125. ai_move, 0, NULL,
  126. ai_move, 0, NULL,
  127. ai_move, 0, NULL,
  128. ai_move, 0, NULL,
  129. ai_move, 0, insane_fist,
  130. ai_move, 0, NULL,
  131. ai_move, 0, NULL,
  132. ai_move, 0, NULL,
  133. ai_move, 0, NULL,
  134. ai_move, 0, NULL,
  135. ai_move, 0, NULL
  136. };
  137. mmove_t insane_move_uptodown = {FRAME_stand1, FRAME_stand40, insane_frames_uptodown, insane_onground};
  138. mframe_t insane_frames_downtoup [] =
  139. {
  140. ai_move, -0.7, NULL, // 41
  141. ai_move, -1.2, NULL, // 42
  142. ai_move, -1.5, NULL, // 43
  143. ai_move, -4.5, NULL, // 44
  144. ai_move, -3.5, NULL, // 45
  145. ai_move, -0.2, NULL, // 46
  146. ai_move, 0, NULL, // 47
  147. ai_move, -1.3, NULL, // 48
  148. ai_move, -3, NULL, // 49
  149. ai_move, -2, NULL, // 50
  150. ai_move, 0, NULL, // 51
  151. ai_move, 0, NULL, // 52
  152. ai_move, 0, NULL, // 53
  153. ai_move, -3.3, NULL, // 54
  154. ai_move, -1.6, NULL, // 55
  155. ai_move, -0.3, NULL, // 56
  156. ai_move, 0, NULL, // 57
  157. ai_move, 0, NULL, // 58
  158. ai_move, 0, NULL // 59
  159. };
  160. mmove_t insane_move_downtoup = {FRAME_stand41, FRAME_stand59, insane_frames_downtoup, insane_stand};
  161. mframe_t insane_frames_jumpdown [] =
  162. {
  163. ai_move, 0.2, NULL,
  164. ai_move, 11.5, NULL,
  165. ai_move, 5.1, NULL,
  166. ai_move, 7.1, NULL,
  167. ai_move, 0, NULL
  168. };
  169. mmove_t insane_move_jumpdown = {FRAME_stand96, FRAME_stand100, insane_frames_jumpdown, insane_onground};
  170. mframe_t insane_frames_down [] =
  171. {
  172. ai_move, 0, NULL, // 100
  173. ai_move, 0, NULL,
  174. ai_move, 0, NULL,
  175. ai_move, 0, NULL,
  176. ai_move, 0, NULL,
  177. ai_move, 0, NULL,
  178. ai_move, 0, NULL,
  179. ai_move, 0, NULL,
  180. ai_move, 0, NULL,
  181. ai_move, 0, NULL,
  182. ai_move, 0, NULL, // 110
  183. ai_move, -1.7, NULL,
  184. ai_move, -1.6, NULL,
  185. ai_move, 0, NULL,
  186. ai_move, 0, NULL,
  187. ai_move, 0, NULL,
  188. ai_move, 0, insane_fist,
  189. ai_move, 0, NULL,
  190. ai_move, 0, NULL,
  191. ai_move, 0, NULL,
  192. ai_move, 0, NULL, // 120
  193. ai_move, 0, NULL,
  194. ai_move, 0, NULL,
  195. ai_move, 0, NULL,
  196. ai_move, 0, NULL,
  197. ai_move, 0, NULL,
  198. ai_move, 0, NULL,
  199. ai_move, 0, NULL,
  200. ai_move, 0, NULL,
  201. ai_move, 0, NULL,
  202. ai_move, 0, NULL, // 130
  203. ai_move, 0, NULL,
  204. ai_move, 0, NULL,
  205. ai_move, 0, insane_moan,
  206. ai_move, 0, NULL,
  207. ai_move, 0, NULL,
  208. ai_move, 0, NULL,
  209. ai_move, 0, NULL,
  210. ai_move, 0, NULL,
  211. ai_move, 0, NULL,
  212. ai_move, 0, NULL, // 140
  213. ai_move, 0, NULL,
  214. ai_move, 0, NULL,
  215. ai_move, 0, NULL,
  216. ai_move, 0, NULL,
  217. ai_move, 0, NULL,
  218. ai_move, 0, NULL,
  219. ai_move, 0, NULL,
  220. ai_move, 0, NULL,
  221. ai_move, 0, NULL,
  222. ai_move, 0, NULL, // 150
  223. ai_move, 0.5, NULL,
  224. ai_move, 0, NULL,
  225. ai_move, -0.2, insane_scream,
  226. ai_move, 0, NULL,
  227. ai_move, 0.2, NULL,
  228. ai_move, 0.4, NULL,
  229. ai_move, 0.6, NULL,
  230. ai_move, 0.8, NULL,
  231. ai_move, 0.7, NULL,
  232. ai_move, 0, insane_checkup // 160
  233. };
  234. mmove_t insane_move_down = {FRAME_stand100, FRAME_stand160, insane_frames_down, insane_onground};
  235. mframe_t insane_frames_walk_normal [] =
  236. {
  237. ai_walk, 0, insane_scream,
  238. ai_walk, 2.5, NULL,
  239. ai_walk, 3.5, NULL,
  240. ai_walk, 1.7, NULL,
  241. ai_walk, 2.3, NULL,
  242. ai_walk, 2.4, NULL,
  243. ai_walk, 2.2, NULL,
  244. ai_walk, 4.2, NULL,
  245. ai_walk, 5.6, NULL,
  246. ai_walk, 3.3, NULL,
  247. ai_walk, 2.4, NULL,
  248. ai_walk, 0.9, NULL,
  249. ai_walk, 0, NULL
  250. };
  251. mmove_t insane_move_walk_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_walk};
  252. mmove_t insane_move_run_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_run};
  253. mframe_t insane_frames_walk_insane [] =
  254. {
  255. ai_walk, 0, insane_scream, // walk 1
  256. ai_walk, 3.4, NULL, // walk 2
  257. ai_walk, 3.6, NULL, // 3
  258. ai_walk, 2.9, NULL, // 4
  259. ai_walk, 2.2, NULL, // 5
  260. ai_walk, 2.6, NULL, // 6
  261. ai_walk, 0, NULL, // 7
  262. ai_walk, 0.7, NULL, // 8
  263. ai_walk, 4.8, NULL, // 9
  264. ai_walk, 5.3, NULL, // 10
  265. ai_walk, 1.1, NULL, // 11
  266. ai_walk, 2, NULL, // 12
  267. ai_walk, 0.5, NULL, // 13
  268. ai_walk, 0, NULL, // 14
  269. ai_walk, 0, NULL, // 15
  270. ai_walk, 4.9, NULL, // 16
  271. ai_walk, 6.7, NULL, // 17
  272. ai_walk, 3.8, NULL, // 18
  273. ai_walk, 2, NULL, // 19
  274. ai_walk, 0.2, NULL, // 20
  275. ai_walk, 0, NULL, // 21
  276. ai_walk, 3.4, NULL, // 22
  277. ai_walk, 6.4, NULL, // 23
  278. ai_walk, 5, NULL, // 24
  279. ai_walk, 1.8, NULL, // 25
  280. ai_walk, 0, NULL // 26
  281. };
  282. mmove_t insane_move_walk_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_walk};
  283. mmove_t insane_move_run_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_run};
  284. mframe_t insane_frames_stand_pain [] =
  285. {
  286. ai_move, 0, NULL,
  287. ai_move, 0, NULL,
  288. ai_move, 0, NULL,
  289. ai_move, 0, NULL,
  290. ai_move, 0, NULL,
  291. ai_move, 0, NULL,
  292. ai_move, 0, NULL,
  293. ai_move, 0, NULL,
  294. ai_move, 0, NULL,
  295. ai_move, 0, NULL,
  296. ai_move, 0, NULL
  297. };
  298. mmove_t insane_move_stand_pain = {FRAME_st_pain2, FRAME_st_pain12, insane_frames_stand_pain, insane_run};
  299. mframe_t insane_frames_stand_death [] =
  300. {
  301. ai_move, 0, NULL,
  302. ai_move, 0, NULL,
  303. ai_move, 0, NULL,
  304. ai_move, 0, NULL,
  305. ai_move, 0, NULL,
  306. ai_move, 0, NULL,
  307. ai_move, 0, NULL,
  308. ai_move, 0, NULL,
  309. ai_move, 0, NULL,
  310. ai_move, 0, NULL,
  311. ai_move, 0, NULL,
  312. ai_move, 0, NULL,
  313. ai_move, 0, NULL,
  314. ai_move, 0, NULL,
  315. ai_move, 0, NULL,
  316. ai_move, 0, NULL,
  317. ai_move, 0, NULL
  318. };
  319. mmove_t insane_move_stand_death = {FRAME_st_death2, FRAME_st_death18, insane_frames_stand_death, insane_dead};
  320. mframe_t insane_frames_crawl [] =
  321. {
  322. ai_walk, 0, insane_scream,
  323. ai_walk, 1.5, NULL,
  324. ai_walk, 2.1, NULL,
  325. ai_walk, 3.6, NULL,
  326. ai_walk, 2, NULL,
  327. ai_walk, 0.9, NULL,
  328. ai_walk, 3, NULL,
  329. ai_walk, 3.4, NULL,
  330. ai_walk, 2.4, NULL
  331. };
  332. mmove_t insane_move_crawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
  333. mmove_t insane_move_runcrawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
  334. mframe_t insane_frames_crawl_pain [] =
  335. {
  336. ai_move, 0, NULL,
  337. ai_move, 0, NULL,
  338. ai_move, 0, NULL,
  339. ai_move, 0, NULL,
  340. ai_move, 0, NULL,
  341. ai_move, 0, NULL,
  342. ai_move, 0, NULL,
  343. ai_move, 0, NULL,
  344. ai_move, 0, NULL
  345. };
  346. mmove_t insane_move_crawl_pain = {FRAME_cr_pain2, FRAME_cr_pain10, insane_frames_crawl_pain, insane_run};
  347. mframe_t insane_frames_crawl_death [] =
  348. {
  349. ai_move, 0, NULL,
  350. ai_move, 0, NULL,
  351. ai_move, 0, NULL,
  352. ai_move, 0, NULL,
  353. ai_move, 0, NULL,
  354. ai_move, 0, NULL,
  355. ai_move, 0, NULL
  356. };
  357. mmove_t insane_move_crawl_death = {FRAME_cr_death10, FRAME_cr_death16, insane_frames_crawl_death, insane_dead};
  358. mframe_t insane_frames_cross [] =
  359. {
  360. ai_move, 0, insane_moan,
  361. ai_move, 0, NULL,
  362. ai_move, 0, NULL,
  363. ai_move, 0, NULL,
  364. ai_move, 0, NULL,
  365. ai_move, 0, NULL,
  366. ai_move, 0, NULL,
  367. ai_move, 0, NULL,
  368. ai_move, 0, NULL,
  369. ai_move, 0, NULL,
  370. ai_move, 0, NULL,
  371. ai_move, 0, NULL,
  372. ai_move, 0, NULL,
  373. ai_move, 0, NULL,
  374. ai_move, 0, NULL
  375. };
  376. mmove_t insane_move_cross = {FRAME_cross1, FRAME_cross15, insane_frames_cross, insane_cross};
  377. mframe_t insane_frames_struggle_cross [] =
  378. {
  379. ai_move, 0, insane_scream,
  380. ai_move, 0, NULL,
  381. ai_move, 0, NULL,
  382. ai_move, 0, NULL,
  383. ai_move, 0, NULL,
  384. ai_move, 0, NULL,
  385. ai_move, 0, NULL,
  386. ai_move, 0, NULL,
  387. ai_move, 0, NULL,
  388. ai_move, 0, NULL,
  389. ai_move, 0, NULL,
  390. ai_move, 0, NULL,
  391. ai_move, 0, NULL,
  392. ai_move, 0, NULL,
  393. ai_move, 0, NULL
  394. };
  395. mmove_t insane_move_struggle_cross = {FRAME_cross16, FRAME_cross30, insane_frames_struggle_cross, insane_cross};
  396. void insane_cross (edict_t *self)
  397. {
  398. if (random() < 0.8)
  399. self->monsterinfo.currentmove = &insane_move_cross;
  400. else
  401. self->monsterinfo.currentmove = &insane_move_struggle_cross;
  402. }
  403. void insane_walk (edict_t *self)
  404. {
  405. if ( self->spawnflags & 16 ) // Hold Ground?
  406. if (self->s.frame == FRAME_cr_pain10)
  407. {
  408. self->monsterinfo.currentmove = &insane_move_down;
  409. return;
  410. }
  411. if (self->spawnflags & 4)
  412. self->monsterinfo.currentmove = &insane_move_crawl;
  413. else
  414. if (random() <= 0.5)
  415. self->monsterinfo.currentmove = &insane_move_walk_normal;
  416. else
  417. self->monsterinfo.currentmove = &insane_move_walk_insane;
  418. }
  419. void insane_run (edict_t *self)
  420. {
  421. if ( self->spawnflags & 16 ) // Hold Ground?
  422. if (self->s.frame == FRAME_cr_pain10)
  423. {
  424. self->monsterinfo.currentmove = &insane_move_down;
  425. return;
  426. }
  427. if (self->spawnflags & 4) // Crawling?
  428. self->monsterinfo.currentmove = &insane_move_runcrawl;
  429. else
  430. if (random() <= 0.5) // Else, mix it up
  431. self->monsterinfo.currentmove = &insane_move_run_normal;
  432. else
  433. self->monsterinfo.currentmove = &insane_move_run_insane;
  434. }
  435. void insane_pain (edict_t *self, edict_t *other, float kick, int damage)
  436. {
  437. int l,r;
  438. // if (self->health < (self->max_health / 2))
  439. // self->s.skinnum = 1;
  440. if (level.time < self->pain_debounce_time)
  441. return;
  442. self->pain_debounce_time = level.time + 3;
  443. r = 1 + (rand()&1);
  444. if (self->health < 25)
  445. l = 25;
  446. else if (self->health < 50)
  447. l = 50;
  448. else if (self->health < 75)
  449. l = 75;
  450. else
  451. l = 100;
  452. gi.sound (self, CHAN_VOICE, gi.soundindex (va("player/male/pain%i_%i.wav", l, r)), 1, ATTN_IDLE, 0);
  453. if (skill->value == 3)
  454. return; // no pain anims in nightmare
  455. // Don't go into pain frames if crucified.
  456. if (self->spawnflags & 8)
  457. {
  458. self->monsterinfo.currentmove = &insane_move_struggle_cross;
  459. return;
  460. }
  461. if ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )
  462. {
  463. self->monsterinfo.currentmove = &insane_move_crawl_pain;
  464. }
  465. else
  466. self->monsterinfo.currentmove = &insane_move_stand_pain;
  467. }
  468. void insane_onground (edict_t *self)
  469. {
  470. self->monsterinfo.currentmove = &insane_move_down;
  471. }
  472. void insane_checkdown (edict_t *self)
  473. {
  474. // if ( (self->s.frame == FRAME_stand94) || (self->s.frame == FRAME_stand65) )
  475. if (self->spawnflags & 32) // Always stand
  476. return;
  477. if (random() < 0.3)
  478. if (random() < 0.5)
  479. self->monsterinfo.currentmove = &insane_move_uptodown;
  480. else
  481. self->monsterinfo.currentmove = &insane_move_jumpdown;
  482. }
  483. void insane_checkup (edict_t *self)
  484. {
  485. // If Hold_Ground and Crawl are set
  486. if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
  487. return;
  488. if (random() < 0.5)
  489. self->monsterinfo.currentmove = &insane_move_downtoup;
  490. }
  491. void insane_stand (edict_t *self)
  492. {
  493. if (self->spawnflags & 8) // If crucified
  494. {
  495. self->monsterinfo.currentmove = &insane_move_cross;
  496. self->monsterinfo.aiflags |= AI_STAND_GROUND;
  497. }
  498. // If Hold_Ground and Crawl are set
  499. else if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
  500. self->monsterinfo.currentmove = &insane_move_down;
  501. else
  502. if (random() < 0.5)
  503. self->monsterinfo.currentmove = &insane_move_stand_normal;
  504. else
  505. self->monsterinfo.currentmove = &insane_move_stand_insane;
  506. }
  507. void insane_dead (edict_t *self)
  508. {
  509. if (self->spawnflags & 8)
  510. {
  511. self->flags |= FL_FLY;
  512. }
  513. else
  514. {
  515. VectorSet (self->mins, -16, -16, -24);
  516. VectorSet (self->maxs, 16, 16, -8);
  517. self->movetype = MOVETYPE_TOSS;
  518. }
  519. self->svflags |= SVF_DEADMONSTER;
  520. self->nextthink = 0;
  521. gi.linkentity (self);
  522. }
  523. void insane_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  524. {
  525. int n;
  526. if (self->health <= self->gib_health)
  527. {
  528. gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_IDLE, 0);
  529. for (n= 0; n < 2; n++)
  530. ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
  531. for (n= 0; n < 4; n++)
  532. ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
  533. ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
  534. self->deadflag = DEAD_DEAD;
  535. return;
  536. }
  537. if (self->deadflag == DEAD_DEAD)
  538. return;
  539. gi.sound (self, CHAN_VOICE, gi.soundindex(va("player/male/death%i.wav", (rand()%4)+1)), 1, ATTN_IDLE, 0);
  540. self->deadflag = DEAD_DEAD;
  541. self->takedamage = DAMAGE_YES;
  542. if (self->spawnflags & 8)
  543. {
  544. insane_dead (self);
  545. }
  546. else
  547. {
  548. if ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )
  549. self->monsterinfo.currentmove = &insane_move_crawl_death;
  550. else
  551. self->monsterinfo.currentmove = &insane_move_stand_death;
  552. }
  553. }
  554. /*QUAKED misc_insane (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn CRAWL CRUCIFIED STAND_GROUND ALWAYS_STAND
  555. */
  556. void SP_misc_insane (edict_t *self)
  557. {
  558. // static int skin = 0; //@@
  559. if (deathmatch->value)
  560. {
  561. G_FreeEdict (self);
  562. return;
  563. }
  564. sound_fist = gi.soundindex ("insane/insane11.wav");
  565. sound_shake = gi.soundindex ("insane/insane5.wav");
  566. sound_moan = gi.soundindex ("insane/insane7.wav");
  567. sound_scream[0] = gi.soundindex ("insane/insane1.wav");
  568. sound_scream[1] = gi.soundindex ("insane/insane2.wav");
  569. sound_scream[2] = gi.soundindex ("insane/insane3.wav");
  570. sound_scream[3] = gi.soundindex ("insane/insane4.wav");
  571. sound_scream[4] = gi.soundindex ("insane/insane6.wav");
  572. sound_scream[5] = gi.soundindex ("insane/insane8.wav");
  573. sound_scream[6] = gi.soundindex ("insane/insane9.wav");
  574. sound_scream[7] = gi.soundindex ("insane/insane10.wav");
  575. self->movetype = MOVETYPE_STEP;
  576. self->solid = SOLID_BBOX;
  577. self->s.modelindex = gi.modelindex("models/monsters/insane/tris.md2");
  578. VectorSet (self->mins, -16, -16, -24);
  579. VectorSet (self->maxs, 16, 16, 32);
  580. self->health = 100;
  581. self->gib_health = -50;
  582. self->mass = 300;
  583. self->pain = insane_pain;
  584. self->die = insane_die;
  585. self->monsterinfo.stand = insane_stand;
  586. self->monsterinfo.walk = insane_walk;
  587. self->monsterinfo.run = insane_run;
  588. self->monsterinfo.dodge = NULL;
  589. self->monsterinfo.attack = NULL;
  590. self->monsterinfo.melee = NULL;
  591. self->monsterinfo.sight = NULL;
  592. self->monsterinfo.aiflags |= AI_GOOD_GUY;
  593. //@@
  594. // self->s.skinnum = skin;
  595. // skin++;
  596. // if (skin > 12)
  597. // skin = 0;
  598. gi.linkentity (self);
  599. if (self->spawnflags & 16) // Stand Ground
  600. self->monsterinfo.aiflags |= AI_STAND_GROUND;
  601. self->monsterinfo.currentmove = &insane_move_stand_normal;
  602. self->monsterinfo.scale = MODEL_SCALE;
  603. if (self->spawnflags & 8) // Crucified ?
  604. {
  605. VectorSet (self->mins, -16, 0, 0);
  606. VectorSet (self->maxs, 16, 8, 32);
  607. self->flags |= FL_NO_KNOCKBACK;
  608. flymonster_start (self);
  609. }
  610. else
  611. {
  612. walkmonster_start (self);
  613. self->s.skinnum = rand()%3;
  614. }
  615. }