m_insane.cpp 17 KB

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