m_infantry.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. /*
  4. ==============================================================================
  5. INFANTRY
  6. ==============================================================================
  7. */
  8. #include "g_local.h"
  9. #include "m_infantry.h"
  10. void InfantryMachineGun (edict_t *self);
  11. static int sound_pain1;
  12. static int sound_pain2;
  13. static int sound_die1;
  14. static int sound_die2;
  15. static int sound_gunshot;
  16. static int sound_weapon_cock;
  17. static int sound_punch_swing;
  18. static int sound_punch_hit;
  19. static int sound_sight;
  20. static int sound_search;
  21. static int sound_idle;
  22. mframe_t infantry_frames_stand [] =
  23. {
  24. ai_stand, 0, NULL,
  25. ai_stand, 0, NULL,
  26. ai_stand, 0, NULL,
  27. ai_stand, 0, NULL,
  28. ai_stand, 0, NULL,
  29. ai_stand, 0, NULL,
  30. ai_stand, 0, NULL,
  31. ai_stand, 0, NULL,
  32. ai_stand, 0, NULL,
  33. ai_stand, 0, NULL,
  34. ai_stand, 0, NULL,
  35. ai_stand, 0, NULL,
  36. ai_stand, 0, NULL,
  37. ai_stand, 0, NULL,
  38. ai_stand, 0, NULL,
  39. ai_stand, 0, NULL,
  40. ai_stand, 0, NULL,
  41. ai_stand, 0, NULL,
  42. ai_stand, 0, NULL,
  43. ai_stand, 0, NULL,
  44. ai_stand, 0, NULL,
  45. ai_stand, 0, NULL
  46. };
  47. mmove_t infantry_move_stand = {FRAME_stand50, FRAME_stand71, infantry_frames_stand, NULL};
  48. void infantry_stand (edict_t *self)
  49. {
  50. self->monsterinfo.currentmove = &infantry_move_stand;
  51. }
  52. mframe_t infantry_frames_fidget [] =
  53. {
  54. ai_stand, 1, NULL,
  55. ai_stand, 0, NULL,
  56. ai_stand, 1, NULL,
  57. ai_stand, 3, NULL,
  58. ai_stand, 6, NULL,
  59. ai_stand, 3, NULL,
  60. ai_stand, 0, NULL,
  61. ai_stand, 0, NULL,
  62. ai_stand, 0, NULL,
  63. ai_stand, 0, NULL,
  64. ai_stand, 1, NULL,
  65. ai_stand, 0, NULL,
  66. ai_stand, 0, NULL,
  67. ai_stand, 0, NULL,
  68. ai_stand, 0, NULL,
  69. ai_stand, 1, NULL,
  70. ai_stand, 0, NULL,
  71. ai_stand, -1, NULL,
  72. ai_stand, 0, NULL,
  73. ai_stand, 0, NULL,
  74. ai_stand, 1, NULL,
  75. ai_stand, 0, NULL,
  76. ai_stand, -2, NULL,
  77. ai_stand, 1, NULL,
  78. ai_stand, 1, NULL,
  79. ai_stand, 1, NULL,
  80. ai_stand, -1, NULL,
  81. ai_stand, 0, NULL,
  82. ai_stand, 0, NULL,
  83. ai_stand, -1, 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, -1, NULL,
  90. ai_stand, 0, NULL,
  91. ai_stand, 0, NULL,
  92. ai_stand, 1, NULL,
  93. ai_stand, 0, NULL,
  94. ai_stand, 0, NULL,
  95. ai_stand, -1, NULL,
  96. ai_stand, -1, NULL,
  97. ai_stand, 0, NULL,
  98. ai_stand, -3, NULL,
  99. ai_stand, -2, NULL,
  100. ai_stand, -3, NULL,
  101. ai_stand, -3, NULL,
  102. ai_stand, -2, NULL
  103. };
  104. mmove_t infantry_move_fidget = {FRAME_stand01, FRAME_stand49, infantry_frames_fidget, infantry_stand};
  105. void infantry_fidget (edict_t *self)
  106. {
  107. self->monsterinfo.currentmove = &infantry_move_fidget;
  108. gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
  109. }
  110. mframe_t infantry_frames_walk [] =
  111. {
  112. ai_walk, 5, NULL,
  113. ai_walk, 4, NULL,
  114. ai_walk, 4, NULL,
  115. ai_walk, 5, NULL,
  116. ai_walk, 4, NULL,
  117. ai_walk, 5, NULL,
  118. ai_walk, 6, NULL,
  119. ai_walk, 4, NULL,
  120. ai_walk, 4, NULL,
  121. ai_walk, 4, NULL,
  122. ai_walk, 4, NULL,
  123. ai_walk, 5, NULL
  124. };
  125. mmove_t infantry_move_walk = {FRAME_walk03, FRAME_walk14, infantry_frames_walk, NULL};
  126. void infantry_walk (edict_t *self)
  127. {
  128. self->monsterinfo.currentmove = &infantry_move_walk;
  129. }
  130. mframe_t infantry_frames_run [] =
  131. {
  132. ai_run, 10, NULL,
  133. ai_run, 20, NULL,
  134. ai_run, 5, NULL,
  135. ai_run, 7, monster_done_dodge,
  136. ai_run, 30, NULL,
  137. ai_run, 35, NULL,
  138. ai_run, 2, NULL,
  139. ai_run, 6, NULL
  140. };
  141. mmove_t infantry_move_run = {FRAME_run01, FRAME_run08, infantry_frames_run, NULL};
  142. void infantry_run (edict_t *self)
  143. {
  144. monster_done_dodge (self);
  145. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  146. self->monsterinfo.currentmove = &infantry_move_stand;
  147. else
  148. self->monsterinfo.currentmove = &infantry_move_run;
  149. }
  150. mframe_t infantry_frames_pain1 [] =
  151. {
  152. ai_move, -3, NULL,
  153. ai_move, -2, NULL,
  154. ai_move, -1, NULL,
  155. ai_move, -2, NULL,
  156. ai_move, -1, NULL,
  157. ai_move, 1, NULL,
  158. ai_move, -1, NULL,
  159. ai_move, 1, NULL,
  160. ai_move, 6, NULL,
  161. ai_move, 2, NULL
  162. };
  163. mmove_t infantry_move_pain1 = {FRAME_pain101, FRAME_pain110, infantry_frames_pain1, infantry_run};
  164. mframe_t infantry_frames_pain2 [] =
  165. {
  166. ai_move, -3, NULL,
  167. ai_move, -3, NULL,
  168. ai_move, 0, NULL,
  169. ai_move, -1, NULL,
  170. ai_move, -2, NULL,
  171. ai_move, 0, NULL,
  172. ai_move, 0, NULL,
  173. ai_move, 2, NULL,
  174. ai_move, 5, NULL,
  175. ai_move, 2, NULL
  176. };
  177. mmove_t infantry_move_pain2 = {FRAME_pain201, FRAME_pain210, infantry_frames_pain2, infantry_run};
  178. void infantry_pain (edict_t *self, edict_t *other, float kick, int damage)
  179. {
  180. int n;
  181. if (self->health < (self->max_health / 2))
  182. self->s.skinnum = 1;
  183. if (!self->groundentity)
  184. {
  185. // if ((g_showlogic) && (g_showlogic->value))
  186. // gi.dprintf ("infantry: pain avoided due to no ground\n");
  187. return;
  188. }
  189. monster_done_dodge (self);
  190. if (level.time < self->pain_debounce_time)
  191. return;
  192. self->pain_debounce_time = level.time + 3;
  193. if (skill->value == 3)
  194. return; // no pain anims in nightmare
  195. n = rand() % 2;
  196. if (n == 0)
  197. {
  198. self->monsterinfo.currentmove = &infantry_move_pain1;
  199. gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
  200. }
  201. else
  202. {
  203. self->monsterinfo.currentmove = &infantry_move_pain2;
  204. gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
  205. }
  206. // PMM - clear duck flag
  207. if (self->monsterinfo.aiflags & AI_DUCKED)
  208. monster_duck_up(self);
  209. }
  210. vec3_t aimangles[] =
  211. {
  212. 0.0, 5.0, 0.0,
  213. 10.0, 15.0, 0.0,
  214. 20.0, 25.0, 0.0,
  215. 25.0, 35.0, 0.0,
  216. 30.0, 40.0, 0.0,
  217. 30.0, 45.0, 0.0,
  218. 25.0, 50.0, 0.0,
  219. 20.0, 40.0, 0.0,
  220. 15.0, 35.0, 0.0,
  221. 40.0, 35.0, 0.0,
  222. 70.0, 35.0, 0.0,
  223. 90.0, 35.0, 0.0
  224. };
  225. void InfantryMachineGun (edict_t *self)
  226. {
  227. vec3_t start, target;
  228. vec3_t forward, right;
  229. vec3_t vec;
  230. int flash_number;
  231. if(!self->enemy || !self->enemy->inuse) //PGM
  232. return; //PGM
  233. // pmm - new attack start frame
  234. if (self->s.frame == FRAME_attak104)
  235. {
  236. flash_number = MZ2_INFANTRY_MACHINEGUN_1;
  237. AngleVectors (self->s.angles, forward, right, NULL);
  238. G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
  239. if (self->enemy)
  240. {
  241. VectorMA (self->enemy->s.origin, -0.2, self->enemy->velocity, target);
  242. target[2] += self->enemy->viewheight;
  243. VectorSubtract (target, start, forward);
  244. VectorNormalize (forward);
  245. }
  246. else
  247. {
  248. AngleVectors (self->s.angles, forward, right, NULL);
  249. }
  250. }
  251. else
  252. {
  253. flash_number = MZ2_INFANTRY_MACHINEGUN_2 + (self->s.frame - FRAME_death211);
  254. AngleVectors (self->s.angles, forward, right, NULL);
  255. G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
  256. VectorSubtract (self->s.angles, aimangles[flash_number-MZ2_INFANTRY_MACHINEGUN_2], vec);
  257. AngleVectors (vec, forward, NULL, NULL);
  258. }
  259. monster_fire_bullet (self, start, forward, 3, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flash_number);
  260. }
  261. void infantry_sight (edict_t *self, edict_t *other)
  262. {
  263. gi.sound (self, CHAN_BODY, sound_sight, 1, ATTN_NORM, 0);
  264. }
  265. void infantry_dead (edict_t *self)
  266. {
  267. VectorSet (self->mins, -16, -16, -24);
  268. VectorSet (self->maxs, 16, 16, -8);
  269. self->movetype = MOVETYPE_TOSS;
  270. self->svflags |= SVF_DEADMONSTER;
  271. gi.linkentity (self);
  272. M_FlyCheck (self);
  273. }
  274. mframe_t infantry_frames_death1 [] =
  275. {
  276. ai_move, -4, NULL,
  277. ai_move, 0, NULL,
  278. ai_move, 0, NULL,
  279. ai_move, -1, NULL,
  280. ai_move, -4, NULL,
  281. ai_move, 0, NULL,
  282. ai_move, 0, NULL,
  283. ai_move, 0, NULL,
  284. ai_move, -1, NULL,
  285. ai_move, 3, NULL,
  286. ai_move, 1, NULL,
  287. ai_move, 1, NULL,
  288. ai_move, -2, NULL,
  289. ai_move, 2, NULL,
  290. ai_move, 2, NULL,
  291. ai_move, 9, NULL,
  292. ai_move, 9, NULL,
  293. ai_move, 5, NULL,
  294. ai_move, -3, NULL,
  295. ai_move, -3, NULL
  296. };
  297. mmove_t infantry_move_death1 = {FRAME_death101, FRAME_death120, infantry_frames_death1, infantry_dead};
  298. // Off with his head
  299. mframe_t infantry_frames_death2 [] =
  300. {
  301. ai_move, 0, NULL,
  302. ai_move, 1, NULL,
  303. ai_move, 5, NULL,
  304. ai_move, -1, NULL,
  305. ai_move, 0, NULL,
  306. ai_move, 1, NULL,
  307. ai_move, 1, NULL,
  308. ai_move, 4, NULL,
  309. ai_move, 3, NULL,
  310. ai_move, 0, NULL,
  311. ai_move, -2, InfantryMachineGun,
  312. ai_move, -2, InfantryMachineGun,
  313. ai_move, -3, InfantryMachineGun,
  314. ai_move, -1, InfantryMachineGun,
  315. ai_move, -2, InfantryMachineGun,
  316. ai_move, 0, InfantryMachineGun,
  317. ai_move, 2, InfantryMachineGun,
  318. ai_move, 2, InfantryMachineGun,
  319. ai_move, 3, InfantryMachineGun,
  320. ai_move, -10, InfantryMachineGun,
  321. ai_move, -7, InfantryMachineGun,
  322. ai_move, -8, InfantryMachineGun,
  323. ai_move, -6, NULL,
  324. ai_move, 4, NULL,
  325. ai_move, 0, NULL
  326. };
  327. mmove_t infantry_move_death2 = {FRAME_death201, FRAME_death225, infantry_frames_death2, infantry_dead};
  328. mframe_t infantry_frames_death3 [] =
  329. {
  330. ai_move, 0, NULL,
  331. ai_move, 0, NULL,
  332. ai_move, 0, NULL,
  333. ai_move, -6, NULL,
  334. ai_move, -11, NULL,
  335. ai_move, -3, NULL,
  336. ai_move, -11, NULL,
  337. ai_move, 0, NULL,
  338. ai_move, 0, NULL
  339. };
  340. mmove_t infantry_move_death3 = {FRAME_death301, FRAME_death309, infantry_frames_death3, infantry_dead};
  341. void infantry_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  342. {
  343. int n;
  344. // check for gib
  345. if (self->health <= self->gib_health)
  346. {
  347. gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
  348. for (n= 0; n < 2; n++)
  349. ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
  350. for (n= 0; n < 4; n++)
  351. ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
  352. ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
  353. self->deadflag = DEAD_DEAD;
  354. return;
  355. }
  356. if (self->deadflag == DEAD_DEAD)
  357. return;
  358. // regular death
  359. self->deadflag = DEAD_DEAD;
  360. self->takedamage = DAMAGE_YES;
  361. n = rand() % 3;
  362. if (n == 0)
  363. {
  364. self->monsterinfo.currentmove = &infantry_move_death1;
  365. gi.sound (self, CHAN_VOICE, sound_die2, 1, ATTN_NORM, 0);
  366. }
  367. else if (n == 1)
  368. {
  369. self->monsterinfo.currentmove = &infantry_move_death2;
  370. gi.sound (self, CHAN_VOICE, sound_die1, 1, ATTN_NORM, 0);
  371. }
  372. else
  373. {
  374. self->monsterinfo.currentmove = &infantry_move_death3;
  375. gi.sound (self, CHAN_VOICE, sound_die2, 1, ATTN_NORM, 0);
  376. }
  377. }
  378. mframe_t infantry_frames_duck [] =
  379. {
  380. ai_move, -2, monster_duck_down,
  381. ai_move, -5, monster_duck_hold,
  382. ai_move, 3, NULL,
  383. ai_move, 4, monster_duck_up,
  384. ai_move, 0, NULL
  385. };
  386. mmove_t infantry_move_duck = {FRAME_duck01, FRAME_duck05, infantry_frames_duck, infantry_run};
  387. // PMM - dodge code moved below so I can see the attack frames
  388. void infantry_cock_gun (edict_t *self)
  389. {
  390. // pmm .. code that was here no longer needed
  391. gi.sound (self, CHAN_WEAPON, sound_weapon_cock, 1, ATTN_NORM, 0);
  392. }
  393. void infantry_fire (edict_t *self)
  394. {
  395. InfantryMachineGun (self);
  396. if (level.time >= self->monsterinfo.pausetime)
  397. self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  398. else
  399. self->monsterinfo.aiflags |= AI_HOLD_FRAME;
  400. }
  401. // this is here instead of cock_gun
  402. void infantry_fire_prep (edict_t *self)
  403. {
  404. int n;
  405. n = (rand() & 15) + 3 + 1;
  406. self->monsterinfo.pausetime = level.time + n*FRAMETIME;
  407. }
  408. // pmm
  409. // frames reordered, tweaked for new frames
  410. mframe_t infantry_frames_attack1 [] =
  411. {
  412. ai_charge, -3, NULL, //101
  413. ai_charge, -2, NULL, //102
  414. ai_charge, -1, infantry_fire_prep, //103
  415. ai_charge, 5, infantry_fire, //104
  416. ai_charge, 1, NULL, //105
  417. ai_charge, -3, NULL, //106
  418. ai_charge, -2, NULL, //107
  419. ai_charge, 2, infantry_cock_gun, //108
  420. ai_charge, 1, NULL, //109
  421. ai_charge, 1, NULL, //110
  422. ai_charge, -1, NULL, //111
  423. ai_charge, 0, NULL, //112
  424. ai_charge, -1, NULL, //113
  425. ai_charge, -1, NULL, //114
  426. ai_charge, 4, NULL //115
  427. };
  428. mmove_t infantry_move_attack1 = {FRAME_attak101, FRAME_attak115, infantry_frames_attack1, infantry_run};
  429. void infantry_swing (edict_t *self)
  430. {
  431. gi.sound (self, CHAN_WEAPON, sound_punch_swing, 1, ATTN_NORM, 0);
  432. }
  433. void infantry_smack (edict_t *self)
  434. {
  435. vec3_t aim;
  436. VectorSet (aim, MELEE_DISTANCE, 0, 0);
  437. if (fire_hit (self, aim, (5 + (rand() % 5)), 50))
  438. gi.sound (self, CHAN_WEAPON, sound_punch_hit, 1, ATTN_NORM, 0);
  439. }
  440. mframe_t infantry_frames_attack2 [] =
  441. {
  442. ai_charge, 3, NULL,
  443. ai_charge, 6, NULL,
  444. ai_charge, 0, infantry_swing,
  445. ai_charge, 8, NULL,
  446. ai_charge, 5, NULL,
  447. ai_charge, 8, infantry_smack,
  448. ai_charge, 6, NULL,
  449. ai_charge, 3, NULL,
  450. };
  451. mmove_t infantry_move_attack2 = {FRAME_attak201, FRAME_attak208, infantry_frames_attack2, infantry_run};
  452. void infantry_attack(edict_t *self)
  453. {
  454. monster_done_dodge (self);
  455. if (range (self, self->enemy) == RANGE_MELEE)
  456. self->monsterinfo.currentmove = &infantry_move_attack2;
  457. else
  458. self->monsterinfo.currentmove = &infantry_move_attack1;
  459. }
  460. //===========
  461. //PGM
  462. void infantry_jump_now (edict_t *self)
  463. {
  464. vec3_t forward,up;
  465. monster_jump_start (self);
  466. AngleVectors (self->s.angles, forward, NULL, up);
  467. VectorMA(self->velocity, 100, forward, self->velocity);
  468. VectorMA(self->velocity, 300, up, self->velocity);
  469. }
  470. void infantry_jump2_now (edict_t *self)
  471. {
  472. vec3_t forward,up;
  473. monster_jump_start (self);
  474. AngleVectors (self->s.angles, forward, NULL, up);
  475. VectorMA(self->velocity, 150, forward, self->velocity);
  476. VectorMA(self->velocity, 400, up, self->velocity);
  477. }
  478. void infantry_jump_wait_land (edict_t *self)
  479. {
  480. if(self->groundentity == NULL)
  481. {
  482. self->monsterinfo.nextframe = self->s.frame;
  483. if(monster_jump_finished (self))
  484. self->monsterinfo.nextframe = self->s.frame + 1;
  485. }
  486. else
  487. self->monsterinfo.nextframe = self->s.frame + 1;
  488. }
  489. mframe_t infantry_frames_jump [] =
  490. {
  491. ai_move, 0, NULL,
  492. ai_move, 0, NULL,
  493. ai_move, 0, NULL,
  494. ai_move, 0, infantry_jump_now,
  495. ai_move, 0, NULL,
  496. ai_move, 0, NULL,
  497. ai_move, 0, NULL,
  498. ai_move, 0, infantry_jump_wait_land,
  499. ai_move, 0, NULL,
  500. ai_move, 0, NULL
  501. };
  502. mmove_t infantry_move_jump = { FRAME_jump01, FRAME_jump10, infantry_frames_jump, infantry_run };
  503. mframe_t infantry_frames_jump2 [] =
  504. {
  505. ai_move, -8, NULL,
  506. ai_move, -4, NULL,
  507. ai_move, -4, NULL,
  508. ai_move, 0, infantry_jump_now,
  509. ai_move, 0, NULL,
  510. ai_move, 0, NULL,
  511. ai_move, 0, NULL,
  512. ai_move, 0, infantry_jump_wait_land,
  513. ai_move, 0, NULL,
  514. ai_move, 0, NULL
  515. };
  516. mmove_t infantry_move_jump2 = { FRAME_jump01, FRAME_jump10, infantry_frames_jump2, infantry_run };
  517. void infantry_jump (edict_t *self)
  518. {
  519. if(!self->enemy)
  520. return;
  521. monster_done_dodge(self);
  522. if(self->enemy->s.origin[2] > self->s.origin[2])
  523. self->monsterinfo.currentmove = &infantry_move_jump2;
  524. else
  525. self->monsterinfo.currentmove = &infantry_move_jump;
  526. }
  527. qboolean infantry_blocked (edict_t *self, float dist)
  528. {
  529. if(blocked_checkshot (self, 0.25 + (0.05 * skill->value) ))
  530. return true;
  531. if(blocked_checkjump (self, dist, 192, 40))
  532. {
  533. infantry_jump(self);
  534. return true;
  535. }
  536. if(blocked_checkplat (self, dist))
  537. return true;
  538. return false;
  539. }
  540. //PGM
  541. //===========
  542. /*
  543. void infantry_dodge (edict_t *self, edict_t *attacker, float eta, trace_t *tr)
  544. {
  545. //===========
  546. //PMM - rogue rewrite of gunner dodge code.
  547. float r;
  548. float height;
  549. int shooting = 0;
  550. if (!self->enemy)
  551. {
  552. self->enemy = attacker;
  553. FoundTarget (self);
  554. }
  555. // PMM - don't bother if it's going to hit anyway; fix for weird in-your-face etas (I was
  556. // seeing numbers like 13 and 14)
  557. if ((eta < 0.1) || (eta > 5))
  558. return;
  559. r = random();
  560. if (r > (0.25*((skill->value)+1)))
  561. return;
  562. if ((self->monsterinfo.currentmove == &infantry_move_attack1) ||
  563. (self->monsterinfo.currentmove == &infantry_move_attack2))
  564. {
  565. shooting = 1;
  566. }
  567. if (self->monsterinfo.aiflags & AI_DODGING)
  568. {
  569. height = self->absmax[2];
  570. }
  571. else
  572. {
  573. height = self->absmax[2]-32-1; // the -1 is because the absmax is s.origin + maxs + 1
  574. }
  575. // check to see if it makes sense to duck
  576. if (tr->endpos[2] <= height)
  577. {
  578. vec3_t right,diff;
  579. if (shooting)
  580. {
  581. self->monsterinfo.attack_state = AS_SLIDING;
  582. return;
  583. }
  584. AngleVectors (self->s.angles, NULL, right, NULL);
  585. VectorSubtract (tr->endpos, self->s.origin, diff);
  586. if (DotProduct (right, diff) < 0)
  587. {
  588. self->monsterinfo.lefty = 1;
  589. }
  590. // if it doesn't sense to duck, try to strafe away
  591. monster_done_dodge (self);
  592. self->monsterinfo.currentmove = &infantry_move_run;
  593. self->monsterinfo.attack_state = AS_SLIDING;
  594. return;
  595. }
  596. if (skill->value == 0)
  597. {
  598. self->monsterinfo.currentmove = &infantry_move_duck;
  599. // PMM - stupid dodge
  600. self->monsterinfo.duck_wait_time = level.time + eta + 1;
  601. self->monsterinfo.aiflags |= AI_DODGING;
  602. return;
  603. }
  604. if (!shooting)
  605. {
  606. self->monsterinfo.currentmove = &infantry_move_duck;
  607. self->monsterinfo.duck_wait_time = level.time + eta + (0.1 * (3 - skill->value));
  608. self->monsterinfo.aiflags |= AI_DODGING;
  609. }
  610. return;
  611. //PMM
  612. //===========
  613. */
  614. void infantry_duck (edict_t *self, float eta)
  615. {
  616. // if we're jumping, don't dodge
  617. if ((self->monsterinfo.currentmove == &infantry_move_jump) ||
  618. (self->monsterinfo.currentmove == &infantry_move_jump2))
  619. {
  620. return;
  621. }
  622. if ((self->monsterinfo.currentmove == &infantry_move_attack1) ||
  623. (self->monsterinfo.currentmove == &infantry_move_attack2))
  624. {
  625. // if we're shooting, and not on easy, don't dodge
  626. if (skill->value)
  627. {
  628. self->monsterinfo.aiflags &= ~AI_DUCKED;
  629. return;
  630. }
  631. }
  632. if (skill->value == 0)
  633. // PMM - stupid dodge
  634. self->monsterinfo.duck_wait_time = level.time + eta + 1;
  635. else
  636. self->monsterinfo.duck_wait_time = level.time + eta + (0.1 * (3 - skill->value));
  637. // has to be done immediately otherwise he can get stuck
  638. monster_duck_down(self);
  639. self->monsterinfo.nextframe = FRAME_duck01;
  640. self->monsterinfo.currentmove = &infantry_move_duck;
  641. return;
  642. }
  643. void infantry_sidestep (edict_t *self)
  644. {
  645. // if we're jumping, don't dodge
  646. if ((self->monsterinfo.currentmove == &infantry_move_jump) ||
  647. (self->monsterinfo.currentmove == &infantry_move_jump2))
  648. {
  649. return;
  650. }
  651. if ((self->monsterinfo.currentmove == &infantry_move_attack1) ||
  652. (self->monsterinfo.currentmove == &infantry_move_attack2))
  653. {
  654. // if we're shooting, and not on easy, don't dodge
  655. if (skill->value)
  656. {
  657. self->monsterinfo.aiflags &= ~AI_DODGING;
  658. return;
  659. }
  660. }
  661. if (self->monsterinfo.currentmove != &infantry_move_run)
  662. self->monsterinfo.currentmove = &infantry_move_run;
  663. }
  664. /*QUAKED monster_infantry (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  665. */
  666. void SP_monster_infantry (edict_t *self)
  667. {
  668. if (deathmatch->value)
  669. {
  670. G_FreeEdict (self);
  671. return;
  672. }
  673. sound_pain1 = gi.soundindex ("infantry/infpain1.wav");
  674. sound_pain2 = gi.soundindex ("infantry/infpain2.wav");
  675. sound_die1 = gi.soundindex ("infantry/infdeth1.wav");
  676. sound_die2 = gi.soundindex ("infantry/infdeth2.wav");
  677. sound_gunshot = gi.soundindex ("infantry/infatck1.wav");
  678. sound_weapon_cock = gi.soundindex ("infantry/infatck3.wav");
  679. sound_punch_swing = gi.soundindex ("infantry/infatck2.wav");
  680. sound_punch_hit = gi.soundindex ("infantry/melee2.wav");
  681. sound_sight = gi.soundindex ("infantry/infsght1.wav");
  682. sound_search = gi.soundindex ("infantry/infsrch1.wav");
  683. sound_idle = gi.soundindex ("infantry/infidle1.wav");
  684. self->movetype = MOVETYPE_STEP;
  685. self->solid = SOLID_BBOX;
  686. self->s.modelindex = gi.modelindex("models/monsters/infantry/tris.md2");
  687. VectorSet (self->mins, -16, -16, -24);
  688. VectorSet (self->maxs, 16, 16, 32);
  689. self->health = 100;
  690. self->gib_health = -40;
  691. self->mass = 200;
  692. self->pain = infantry_pain;
  693. self->die = infantry_die;
  694. self->monsterinfo.stand = infantry_stand;
  695. self->monsterinfo.walk = infantry_walk;
  696. self->monsterinfo.run = infantry_run;
  697. // pmm
  698. self->monsterinfo.dodge = M_MonsterDodge;
  699. self->monsterinfo.duck = infantry_duck;
  700. self->monsterinfo.unduck = monster_duck_up;
  701. self->monsterinfo.sidestep = infantry_sidestep;
  702. // self->monsterinfo.dodge = infantry_dodge;
  703. // pmm
  704. self->monsterinfo.attack = infantry_attack;
  705. self->monsterinfo.melee = NULL;
  706. self->monsterinfo.sight = infantry_sight;
  707. self->monsterinfo.idle = infantry_fidget;
  708. self->monsterinfo.blocked = infantry_blocked;
  709. gi.linkentity (self);
  710. self->monsterinfo.currentmove = &infantry_move_stand;
  711. self->monsterinfo.scale = MODEL_SCALE;
  712. walkmonster_start (self);
  713. }