m_chick.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. /*
  4. ==============================================================================
  5. chick
  6. ==============================================================================
  7. */
  8. #include "g_local.h"
  9. #include "m_chick.h"
  10. #include "m_flash.h"
  11. void chick_stand(edict_t *self);
  12. void chick_run(edict_t *self);
  13. void chick_reslash(edict_t *self);
  14. void chick_rerocket(edict_t *self);
  15. void chick_attack1(edict_t *self);
  16. static cached_soundindex sound_missile_prelaunch;
  17. static cached_soundindex sound_missile_launch;
  18. static cached_soundindex sound_melee_swing;
  19. static cached_soundindex sound_melee_hit;
  20. static cached_soundindex sound_missile_reload;
  21. static cached_soundindex sound_death1;
  22. static cached_soundindex sound_death2;
  23. static cached_soundindex sound_fall_down;
  24. static cached_soundindex sound_idle1;
  25. static cached_soundindex sound_idle2;
  26. static cached_soundindex sound_pain1;
  27. static cached_soundindex sound_pain2;
  28. static cached_soundindex sound_pain3;
  29. static cached_soundindex sound_sight;
  30. static cached_soundindex sound_search;
  31. void ChickMoan(edict_t *self)
  32. {
  33. if (frandom() < 0.5f)
  34. gi.sound(self, CHAN_VOICE, sound_idle1, 1, ATTN_IDLE, 0);
  35. else
  36. gi.sound(self, CHAN_VOICE, sound_idle2, 1, ATTN_IDLE, 0);
  37. }
  38. mframe_t chick_frames_fidget[] = {
  39. { ai_stand },
  40. { ai_stand },
  41. { ai_stand },
  42. { ai_stand },
  43. { ai_stand },
  44. { ai_stand },
  45. { ai_stand },
  46. { ai_stand },
  47. { ai_stand, 0, ChickMoan },
  48. { ai_stand },
  49. { ai_stand },
  50. { ai_stand },
  51. { ai_stand },
  52. { ai_stand },
  53. { ai_stand },
  54. { ai_stand },
  55. { ai_stand },
  56. { ai_stand },
  57. { ai_stand },
  58. { ai_stand },
  59. { ai_stand },
  60. { ai_stand },
  61. { ai_stand },
  62. { ai_stand },
  63. { ai_stand },
  64. { ai_stand },
  65. { ai_stand },
  66. { ai_stand },
  67. { ai_stand },
  68. { ai_stand }
  69. };
  70. MMOVE_T(chick_move_fidget) = { FRAME_stand201, FRAME_stand230, chick_frames_fidget, chick_stand };
  71. void chick_fidget(edict_t *self)
  72. {
  73. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  74. return;
  75. else if (self->enemy)
  76. return;
  77. if (frandom() <= 0.3f)
  78. M_SetAnimation(self, &chick_move_fidget);
  79. }
  80. mframe_t chick_frames_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 },
  107. { ai_stand },
  108. { ai_stand },
  109. { ai_stand },
  110. { ai_stand, 0, chick_fidget },
  111. };
  112. MMOVE_T(chick_move_stand) = { FRAME_stand101, FRAME_stand130, chick_frames_stand, nullptr };
  113. MONSTERINFO_STAND(chick_stand) (edict_t *self) -> void
  114. {
  115. M_SetAnimation(self, &chick_move_stand);
  116. }
  117. mframe_t chick_frames_start_run[] = {
  118. { ai_run, 1 },
  119. { ai_run },
  120. { ai_run, 0, monster_footstep },
  121. { ai_run, -1 },
  122. { ai_run, -1, monster_footstep },
  123. { ai_run },
  124. { ai_run, 1 },
  125. { ai_run, 3 },
  126. { ai_run, 6 },
  127. { ai_run, 3 }
  128. };
  129. MMOVE_T(chick_move_start_run) = { FRAME_walk01, FRAME_walk10, chick_frames_start_run, chick_run };
  130. mframe_t chick_frames_run[] = {
  131. { ai_run, 6 },
  132. { ai_run, 8, monster_footstep },
  133. { ai_run, 13 },
  134. { ai_run, 5, monster_done_dodge }, // make sure to clear dodge bit
  135. { ai_run, 7 },
  136. { ai_run, 4 },
  137. { ai_run, 11, monster_footstep },
  138. { ai_run, 5 },
  139. { ai_run, 9 },
  140. { ai_run, 7 }
  141. };
  142. MMOVE_T(chick_move_run) = { FRAME_walk11, FRAME_walk20, chick_frames_run, nullptr };
  143. mframe_t chick_frames_walk[] = {
  144. { ai_walk, 6 },
  145. { ai_walk, 8, monster_footstep },
  146. { ai_walk, 13 },
  147. { ai_walk, 5 },
  148. { ai_walk, 7 },
  149. { ai_walk, 4 },
  150. { ai_walk, 11, monster_footstep },
  151. { ai_walk, 5 },
  152. { ai_walk, 9 },
  153. { ai_walk, 7 }
  154. };
  155. MMOVE_T(chick_move_walk) = { FRAME_walk11, FRAME_walk20, chick_frames_walk, nullptr };
  156. MONSTERINFO_WALK(chick_walk) (edict_t *self) -> void
  157. {
  158. M_SetAnimation(self, &chick_move_walk);
  159. }
  160. MONSTERINFO_RUN(chick_run) (edict_t *self) -> void
  161. {
  162. monster_done_dodge(self);
  163. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  164. {
  165. M_SetAnimation(self, &chick_move_stand);
  166. return;
  167. }
  168. if (self->monsterinfo.active_move == &chick_move_walk ||
  169. self->monsterinfo.active_move == &chick_move_start_run)
  170. {
  171. M_SetAnimation(self, &chick_move_run);
  172. }
  173. else
  174. {
  175. M_SetAnimation(self, &chick_move_start_run);
  176. }
  177. }
  178. mframe_t chick_frames_pain1[] = {
  179. { ai_move },
  180. { ai_move },
  181. { ai_move },
  182. { ai_move },
  183. { ai_move }
  184. };
  185. MMOVE_T(chick_move_pain1) = { FRAME_pain101, FRAME_pain105, chick_frames_pain1, chick_run };
  186. mframe_t chick_frames_pain2[] = {
  187. { ai_move },
  188. { ai_move },
  189. { ai_move },
  190. { ai_move },
  191. { ai_move }
  192. };
  193. MMOVE_T(chick_move_pain2) = { FRAME_pain201, FRAME_pain205, chick_frames_pain2, chick_run };
  194. mframe_t chick_frames_pain3[] = {
  195. { ai_move },
  196. { ai_move, 0, monster_footstep },
  197. { ai_move, -6 },
  198. { ai_move, 3, monster_footstep },
  199. { ai_move, 11 },
  200. { ai_move, 3, monster_footstep },
  201. { ai_move },
  202. { ai_move },
  203. { ai_move, 4 },
  204. { ai_move, 1 },
  205. { ai_move },
  206. { ai_move, -3 },
  207. { ai_move, -4 },
  208. { ai_move, 5 },
  209. { ai_move, 7 },
  210. { ai_move, -2 },
  211. { ai_move, 3 },
  212. { ai_move, -5 },
  213. { ai_move, -2 },
  214. { ai_move, -8 },
  215. { ai_move, 2, monster_footstep }
  216. };
  217. MMOVE_T(chick_move_pain3) = { FRAME_pain301, FRAME_pain321, chick_frames_pain3, chick_run };
  218. PAIN(chick_pain) (edict_t *self, edict_t *other, float kick, int damage, const mod_t &mod) -> void
  219. {
  220. float r;
  221. monster_done_dodge(self);
  222. if (level.time < self->pain_debounce_time)
  223. return;
  224. self->pain_debounce_time = level.time + 3_sec;
  225. r = frandom();
  226. if (r < 0.33f)
  227. gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
  228. else if (r < 0.66f)
  229. gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
  230. else
  231. gi.sound(self, CHAN_VOICE, sound_pain3, 1, ATTN_NORM, 0);
  232. if (!M_ShouldReactToPain(self, mod))
  233. return; // no pain anims in nightmare
  234. // PMM - clear this from blindfire
  235. self->monsterinfo.aiflags &= ~AI_MANUAL_STEERING;
  236. if (damage <= 10)
  237. M_SetAnimation(self, &chick_move_pain1);
  238. else if (damage <= 25)
  239. M_SetAnimation(self, &chick_move_pain2);
  240. else
  241. M_SetAnimation(self, &chick_move_pain3);
  242. // PMM - clear duck flag
  243. if (self->monsterinfo.aiflags & AI_DUCKED)
  244. monster_duck_up(self);
  245. }
  246. MONSTERINFO_SETSKIN(chick_setpain) (edict_t *self) -> void
  247. {
  248. if (self->health < (self->max_health / 2))
  249. self->s.skinnum |= 1;
  250. else
  251. self->s.skinnum &= ~1;
  252. }
  253. void chick_dead(edict_t *self)
  254. {
  255. self->mins = { -16, -16, 0 };
  256. self->maxs = { 16, 16, 8 };
  257. monster_dead(self);
  258. }
  259. static void chick_shrink(edict_t *self)
  260. {
  261. self->maxs[2] = 12;
  262. self->svflags |= SVF_DEADMONSTER;
  263. gi.linkentity(self);
  264. }
  265. mframe_t chick_frames_death2[] = {
  266. { ai_move, -6 },
  267. { ai_move },
  268. { ai_move, -1 },
  269. { ai_move, -5, monster_footstep },
  270. { ai_move },
  271. { ai_move, -1 },
  272. { ai_move, -2 },
  273. { ai_move, 1 },
  274. { ai_move, 10 },
  275. { ai_move, 2 },
  276. { ai_move, 3, monster_footstep },
  277. { ai_move, 1 },
  278. { ai_move, 2 },
  279. { ai_move },
  280. { ai_move, 3 },
  281. { ai_move, 3 },
  282. { ai_move, 1, monster_footstep },
  283. { ai_move, -3 },
  284. { ai_move, -5 },
  285. { ai_move, 4 },
  286. { ai_move, 15, chick_shrink },
  287. { ai_move, 14, monster_footstep },
  288. { ai_move, 1 }
  289. };
  290. MMOVE_T(chick_move_death2) = { FRAME_death201, FRAME_death223, chick_frames_death2, chick_dead };
  291. mframe_t chick_frames_death1[] = {
  292. { ai_move },
  293. { ai_move, 0, monster_footstep },
  294. { ai_move, -7 },
  295. { ai_move, 4, monster_footstep },
  296. { ai_move, 11, chick_shrink },
  297. { ai_move },
  298. { ai_move, 0, monster_footstep },
  299. { ai_move },
  300. { ai_move },
  301. { ai_move },
  302. { ai_move, 0, monster_footstep },
  303. { ai_move }
  304. };
  305. MMOVE_T(chick_move_death1) = { FRAME_death101, FRAME_death112, chick_frames_death1, chick_dead };
  306. DIE(chick_die) (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, const vec3_t &point, const mod_t &mod) -> void
  307. {
  308. int n;
  309. // check for gib
  310. if (M_CheckGib(self, mod))
  311. {
  312. gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
  313. self->s.skinnum /= 2;
  314. ThrowGibs(self, damage, {
  315. { 2, "models/objects/gibs/bone/tris.md2" },
  316. { 3, "models/objects/gibs/sm_meat/tris.md2" },
  317. { "models/monsters/bitch/gibs/arm.md2", GIB_SKINNED | GIB_UPRIGHT },
  318. { "models/monsters/bitch/gibs/foot.md2", GIB_SKINNED | GIB_UPRIGHT },
  319. { "models/monsters/bitch/gibs/tube.md2", GIB_SKINNED | GIB_UPRIGHT },
  320. { "models/monsters/bitch/gibs/chest.md2", GIB_SKINNED },
  321. { "models/monsters/bitch/gibs/head.md2", GIB_HEAD | GIB_SKINNED }
  322. });
  323. self->deadflag = true;
  324. return;
  325. }
  326. if (self->deadflag)
  327. return;
  328. // regular death
  329. self->deadflag = true;
  330. self->takedamage = true;
  331. n = brandom();
  332. if (n == 0)
  333. {
  334. M_SetAnimation(self, &chick_move_death1);
  335. gi.sound(self, CHAN_VOICE, sound_death1, 1, ATTN_NORM, 0);
  336. }
  337. else
  338. {
  339. M_SetAnimation(self, &chick_move_death2);
  340. gi.sound(self, CHAN_VOICE, sound_death2, 1, ATTN_NORM, 0);
  341. }
  342. }
  343. // PMM - changes to duck code for new dodge
  344. mframe_t chick_frames_duck[] = {
  345. { ai_move, 0, monster_duck_down },
  346. { ai_move, 1 },
  347. { ai_move, 4, monster_duck_hold },
  348. { ai_move, -4 },
  349. { ai_move, -5, monster_duck_up },
  350. { ai_move, 3 },
  351. { ai_move, 1 }
  352. };
  353. MMOVE_T(chick_move_duck) = { FRAME_duck01, FRAME_duck07, chick_frames_duck, chick_run };
  354. void ChickSlash(edict_t *self)
  355. {
  356. vec3_t aim = { MELEE_DISTANCE, self->mins[0], 10 };
  357. gi.sound(self, CHAN_WEAPON, sound_melee_swing, 1, ATTN_NORM, 0);
  358. fire_hit(self, aim, irandom(10, 16), 100);
  359. }
  360. void ChickRocket(edict_t *self)
  361. {
  362. vec3_t forward, right;
  363. vec3_t start;
  364. vec3_t dir;
  365. vec3_t vec;
  366. trace_t trace; // PMM - check target
  367. int rocketSpeed;
  368. // pmm - blindfire
  369. vec3_t target;
  370. bool blindfire = false;
  371. if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
  372. blindfire = true;
  373. else
  374. blindfire = false;
  375. if (!self->enemy || !self->enemy->inuse) // PGM
  376. return; // PGM
  377. AngleVectors(self->s.angles, forward, right, nullptr);
  378. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CHICK_ROCKET_1], forward, right);
  379. // [Paril-KEX]
  380. if (self->s.skinnum > 1)
  381. rocketSpeed = 500;
  382. else
  383. rocketSpeed = 650;
  384. // PMM
  385. if (blindfire)
  386. target = self->monsterinfo.blind_fire_target;
  387. else
  388. target = self->enemy->s.origin;
  389. // pmm
  390. // PGM
  391. // PMM - blindfire shooting
  392. if (blindfire)
  393. {
  394. vec = target;
  395. dir = vec - start;
  396. }
  397. // pmm
  398. // don't shoot at feet if they're above where i'm shooting from.
  399. else if (frandom() < 0.33f || (start[2] < self->enemy->absmin[2]))
  400. {
  401. vec = target;
  402. vec[2] += self->enemy->viewheight;
  403. dir = vec - start;
  404. }
  405. else
  406. {
  407. vec = target;
  408. vec[2] = self->enemy->absmin[2] + 1;
  409. dir = vec - start;
  410. }
  411. // PGM
  412. //======
  413. // PMM - lead target (not when blindfiring)
  414. // 20, 35, 50, 65 chance of leading
  415. if ((!blindfire) && (frandom() < 0.35f))
  416. PredictAim(self, self->enemy, start, rocketSpeed, false, 0.f, &dir, &vec);
  417. // PMM - lead target
  418. //======
  419. dir.normalize();
  420. // pmm blindfire doesn't check target (done in checkattack)
  421. // paranoia, make sure we're not shooting a target right next to us
  422. trace = gi.traceline(start, vec, self, MASK_PROJECTILE);
  423. if (blindfire)
  424. {
  425. // blindfire has different fail criteria for the trace
  426. if (!(trace.startsolid || trace.allsolid || (trace.fraction < 0.5f)))
  427. {
  428. // RAFAEL
  429. if (self->s.skinnum > 1)
  430. monster_fire_heat(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1, 0.075f);
  431. else
  432. // RAFAEL
  433. monster_fire_rocket(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1);
  434. }
  435. else
  436. {
  437. // geez, this is bad. she's avoiding about 80% of her blindfires due to hitting things.
  438. // hunt around for a good shot
  439. // try shifting the target to the left a little (to help counter her large offset)
  440. vec = target;
  441. vec += (right * -10);
  442. dir = vec - start;
  443. dir.normalize();
  444. trace = gi.traceline(start, vec, self, MASK_PROJECTILE);
  445. if (!(trace.startsolid || trace.allsolid || (trace.fraction < 0.5f)))
  446. {
  447. // RAFAEL
  448. if (self->s.skinnum > 1)
  449. monster_fire_heat(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1, 0.075f);
  450. else
  451. // RAFAEL
  452. monster_fire_rocket(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1);
  453. }
  454. else
  455. {
  456. // ok, that failed. try to the right
  457. vec = target;
  458. vec += (right * 10);
  459. dir = vec - start;
  460. dir.normalize();
  461. trace = gi.traceline(start, vec, self, MASK_PROJECTILE);
  462. if (!(trace.startsolid || trace.allsolid || (trace.fraction < 0.5f)))
  463. {
  464. // RAFAEL
  465. if (self->s.skinnum > 1)
  466. monster_fire_heat(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1, 0.075f);
  467. else
  468. // RAFAEL
  469. monster_fire_rocket(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1);
  470. }
  471. }
  472. }
  473. }
  474. else
  475. {
  476. if (trace.fraction > 0.5f || trace.ent->solid != SOLID_BSP)
  477. {
  478. // RAFAEL
  479. if (self->s.skinnum > 1)
  480. monster_fire_heat(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1, 0.15f);
  481. else
  482. // RAFAEL
  483. monster_fire_rocket(self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1);
  484. }
  485. }
  486. }
  487. void Chick_PreAttack1(edict_t *self)
  488. {
  489. gi.sound(self, CHAN_VOICE, sound_missile_prelaunch, 1, ATTN_NORM, 0);
  490. if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
  491. {
  492. vec3_t aim = self->monsterinfo.blind_fire_target - self->s.origin;
  493. self->ideal_yaw = vectoyaw(aim);
  494. }
  495. }
  496. void ChickReload(edict_t *self)
  497. {
  498. gi.sound(self, CHAN_VOICE, sound_missile_reload, 1, ATTN_NORM, 0);
  499. }
  500. mframe_t chick_frames_start_attack1[] = {
  501. { ai_charge, 0, Chick_PreAttack1 },
  502. { ai_charge },
  503. { ai_charge },
  504. { ai_charge, 4 },
  505. { ai_charge },
  506. { ai_charge, -3 },
  507. { ai_charge, 3 },
  508. { ai_charge, 5 },
  509. { ai_charge, 7, monster_footstep },
  510. { ai_charge },
  511. { ai_charge },
  512. { ai_charge },
  513. { ai_charge, 0, chick_attack1 }
  514. };
  515. MMOVE_T(chick_move_start_attack1) = { FRAME_attak101, FRAME_attak113, chick_frames_start_attack1, nullptr };
  516. mframe_t chick_frames_attack1[] = {
  517. { ai_charge, 19, ChickRocket },
  518. { ai_charge, -6, monster_footstep },
  519. { ai_charge, -5 },
  520. { ai_charge, -2 },
  521. { ai_charge, -7, monster_footstep },
  522. { ai_charge },
  523. { ai_charge, 1 },
  524. { ai_charge, 10, ChickReload },
  525. { ai_charge, 4 },
  526. { ai_charge, 5, monster_footstep },
  527. { ai_charge, 6 },
  528. { ai_charge, 6 },
  529. { ai_charge, 4 },
  530. { ai_charge, 3, [](edict_t *self) { chick_rerocket(self); monster_footstep(self); } }
  531. };
  532. MMOVE_T(chick_move_attack1) = { FRAME_attak114, FRAME_attak127, chick_frames_attack1, nullptr };
  533. mframe_t chick_frames_end_attack1[] = {
  534. { ai_charge, -3 },
  535. { ai_charge },
  536. { ai_charge, -6 },
  537. { ai_charge, -4 },
  538. { ai_charge, -2, monster_footstep }
  539. };
  540. MMOVE_T(chick_move_end_attack1) = { FRAME_attak128, FRAME_attak132, chick_frames_end_attack1, chick_run };
  541. void chick_rerocket(edict_t *self)
  542. {
  543. if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
  544. {
  545. self->monsterinfo.aiflags &= ~AI_MANUAL_STEERING;
  546. M_SetAnimation(self, &chick_move_end_attack1);
  547. return;
  548. }
  549. if (!M_CheckClearShot(self, monster_flash_offset[MZ2_CHICK_ROCKET_1]))
  550. {
  551. M_SetAnimation(self, &chick_move_end_attack1);
  552. return;
  553. }
  554. if (self->enemy->health > 0)
  555. {
  556. if (range_to(self, self->enemy) > RANGE_MELEE)
  557. if (visible(self, self->enemy))
  558. if (frandom() <= 0.7f)
  559. {
  560. M_SetAnimation(self, &chick_move_attack1);
  561. return;
  562. }
  563. }
  564. M_SetAnimation(self, &chick_move_end_attack1);
  565. }
  566. void chick_attack1(edict_t *self)
  567. {
  568. M_SetAnimation(self, &chick_move_attack1);
  569. }
  570. mframe_t chick_frames_slash[] = {
  571. { ai_charge, 1 },
  572. { ai_charge, 7, ChickSlash },
  573. { ai_charge, -7, monster_footstep },
  574. { ai_charge, 1 },
  575. { ai_charge, -1 },
  576. { ai_charge, 1 },
  577. { ai_charge },
  578. { ai_charge, 1 },
  579. { ai_charge, -2, chick_reslash }
  580. };
  581. MMOVE_T(chick_move_slash) = { FRAME_attak204, FRAME_attak212, chick_frames_slash, nullptr };
  582. mframe_t chick_frames_end_slash[] = {
  583. { ai_charge, -6 },
  584. { ai_charge, -1 },
  585. { ai_charge, -6 },
  586. { ai_charge, 0, monster_footstep }
  587. };
  588. MMOVE_T(chick_move_end_slash) = { FRAME_attak213, FRAME_attak216, chick_frames_end_slash, chick_run };
  589. void chick_reslash(edict_t *self)
  590. {
  591. if (self->enemy->health > 0)
  592. {
  593. if (range_to(self, self->enemy) <= RANGE_MELEE)
  594. {
  595. if (frandom() <= 0.9f)
  596. {
  597. M_SetAnimation(self, &chick_move_slash);
  598. return;
  599. }
  600. else
  601. {
  602. M_SetAnimation(self, &chick_move_end_slash);
  603. return;
  604. }
  605. }
  606. }
  607. M_SetAnimation(self, &chick_move_end_slash);
  608. }
  609. void chick_slash(edict_t *self)
  610. {
  611. M_SetAnimation(self, &chick_move_slash);
  612. }
  613. mframe_t chick_frames_start_slash[] = {
  614. { ai_charge, 1 },
  615. { ai_charge, 8 },
  616. { ai_charge, 3 }
  617. };
  618. MMOVE_T(chick_move_start_slash) = { FRAME_attak201, FRAME_attak203, chick_frames_start_slash, chick_slash };
  619. MONSTERINFO_MELEE(chick_melee) (edict_t *self) -> void
  620. {
  621. M_SetAnimation(self, &chick_move_start_slash);
  622. }
  623. MONSTERINFO_ATTACK(chick_attack) (edict_t *self) -> void
  624. {
  625. if (!M_CheckClearShot(self, monster_flash_offset[MZ2_CHICK_ROCKET_1]))
  626. return;
  627. float r, chance;
  628. monster_done_dodge(self);
  629. // PMM
  630. if (self->monsterinfo.attack_state == AS_BLIND)
  631. {
  632. // setup shot probabilities
  633. if (self->monsterinfo.blind_fire_delay < 1.0_sec)
  634. chance = 1.0;
  635. else if (self->monsterinfo.blind_fire_delay < 7.5_sec)
  636. chance = 0.4f;
  637. else
  638. chance = 0.1f;
  639. r = frandom();
  640. // minimum of 5.5 seconds, plus 0-1, after the shots are done
  641. self->monsterinfo.blind_fire_delay += random_time(5.5_sec, 6.5_sec);
  642. // don't shoot at the origin
  643. if (!self->monsterinfo.blind_fire_target)
  644. return;
  645. // don't shoot if the dice say not to
  646. if (r > chance)
  647. return;
  648. // turn on manual steering to signal both manual steering and blindfire
  649. self->monsterinfo.aiflags |= AI_MANUAL_STEERING;
  650. M_SetAnimation(self, &chick_move_start_attack1);
  651. self->monsterinfo.attack_finished = level.time + random_time(2_sec);
  652. return;
  653. }
  654. // pmm
  655. M_SetAnimation(self, &chick_move_start_attack1);
  656. }
  657. MONSTERINFO_SIGHT(chick_sight) (edict_t *self, edict_t *other) -> void
  658. {
  659. gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
  660. }
  661. //===========
  662. // PGM
  663. MONSTERINFO_BLOCKED(chick_blocked) (edict_t *self, float dist) -> bool
  664. {
  665. if (blocked_checkplat(self, dist))
  666. return true;
  667. return false;
  668. }
  669. // PGM
  670. //===========
  671. MONSTERINFO_DUCK(chick_duck) (edict_t *self, gtime_t eta) -> bool
  672. {
  673. if ((self->monsterinfo.active_move == &chick_move_start_attack1) ||
  674. (self->monsterinfo.active_move == &chick_move_attack1))
  675. {
  676. // if we're shooting don't dodge
  677. self->monsterinfo.unduck(self);
  678. return false;
  679. }
  680. M_SetAnimation(self, &chick_move_duck);
  681. return true;
  682. }
  683. MONSTERINFO_SIDESTEP(chick_sidestep) (edict_t *self) -> bool
  684. {
  685. if ((self->monsterinfo.active_move == &chick_move_start_attack1) ||
  686. (self->monsterinfo.active_move == &chick_move_attack1) ||
  687. (self->monsterinfo.active_move == &chick_move_pain3))
  688. {
  689. // if we're shooting, don't dodge
  690. return false;
  691. }
  692. if (self->monsterinfo.active_move != &chick_move_run)
  693. M_SetAnimation(self, &chick_move_run);
  694. return true;
  695. }
  696. /*QUAKED monster_chick (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  697. */
  698. void SP_monster_chick(edict_t *self)
  699. {
  700. if ( !M_AllowSpawn( self ) ) {
  701. G_FreeEdict( self );
  702. return;
  703. }
  704. sound_missile_prelaunch.assign("chick/chkatck1.wav");
  705. sound_missile_launch.assign("chick/chkatck2.wav");
  706. sound_melee_swing.assign("chick/chkatck3.wav");
  707. sound_melee_hit.assign("chick/chkatck4.wav");
  708. sound_missile_reload.assign("chick/chkatck5.wav");
  709. sound_death1.assign("chick/chkdeth1.wav");
  710. sound_death2.assign("chick/chkdeth2.wav");
  711. sound_fall_down.assign("chick/chkfall1.wav");
  712. sound_idle1.assign("chick/chkidle1.wav");
  713. sound_idle2.assign("chick/chkidle2.wav");
  714. sound_pain1.assign("chick/chkpain1.wav");
  715. sound_pain2.assign("chick/chkpain2.wav");
  716. sound_pain3.assign("chick/chkpain3.wav");
  717. sound_sight.assign("chick/chksght1.wav");
  718. sound_search.assign("chick/chksrch1.wav");
  719. self->movetype = MOVETYPE_STEP;
  720. self->solid = SOLID_BBOX;
  721. self->s.modelindex = gi.modelindex("models/monsters/bitch/tris.md2");
  722. gi.modelindex("models/monsters/bitch/gibs/arm.md2");
  723. gi.modelindex("models/monsters/bitch/gibs/chest.md2");
  724. gi.modelindex("models/monsters/bitch/gibs/foot.md2");
  725. gi.modelindex("models/monsters/bitch/gibs/head.md2");
  726. gi.modelindex("models/monsters/bitch/gibs/tube.md2");
  727. self->mins = { -16, -16, 0 };
  728. self->maxs = { 16, 16, 56 };
  729. self->health = 175 * st.health_multiplier;
  730. self->gib_health = -70;
  731. self->mass = 200;
  732. self->pain = chick_pain;
  733. self->die = chick_die;
  734. self->monsterinfo.stand = chick_stand;
  735. self->monsterinfo.walk = chick_walk;
  736. self->monsterinfo.run = chick_run;
  737. // pmm
  738. self->monsterinfo.dodge = M_MonsterDodge;
  739. self->monsterinfo.duck = chick_duck;
  740. self->monsterinfo.unduck = monster_duck_up;
  741. self->monsterinfo.sidestep = chick_sidestep;
  742. self->monsterinfo.blocked = chick_blocked; // PGM
  743. // pmm
  744. self->monsterinfo.attack = chick_attack;
  745. self->monsterinfo.melee = chick_melee;
  746. self->monsterinfo.sight = chick_sight;
  747. self->monsterinfo.setskin = chick_setpain;
  748. gi.linkentity(self);
  749. M_SetAnimation(self, &chick_move_stand);
  750. self->monsterinfo.scale = MODEL_SCALE;
  751. // PMM
  752. self->monsterinfo.blindfire = true;
  753. // pmm
  754. walkmonster_start(self);
  755. }
  756. // RAFAEL
  757. /*QUAKED monster_chick_heat (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  758. */
  759. void SP_monster_chick_heat(edict_t *self)
  760. {
  761. SP_monster_chick(self);
  762. self->s.skinnum = 2;
  763. gi.soundindex("weapons/railgr1a.wav");
  764. }
  765. // RAFAEL