m_flyer.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. /*
  4. ==============================================================================
  5. flyer
  6. ==============================================================================
  7. */
  8. #include "g_local.h"
  9. #include "m_flyer.h"
  10. qboolean visible (edict_t *self, edict_t *other);
  11. static int nextmove; // Used for start/stop frames
  12. static int sound_sight;
  13. static int sound_idle;
  14. static int sound_pain1;
  15. static int sound_pain2;
  16. static int sound_slash;
  17. static int sound_sproing;
  18. static int sound_die;
  19. void flyer_check_melee(edict_t *self);
  20. void flyer_loop_melee (edict_t *self);
  21. void flyer_melee (edict_t *self);
  22. void flyer_setstart (edict_t *self);
  23. void flyer_stand (edict_t *self);
  24. void flyer_nextmove (edict_t *self);
  25. // ROGUE - kamikaze stuff
  26. void flyer_kamikaze (edict_t *self);
  27. void flyer_kamikaze_check (edict_t *self);
  28. void flyer_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point);
  29. /*
  30. void showme1 (edict_t *self)
  31. {
  32. if (!self->dmg)
  33. {
  34. gi.dprintf ("straight - %d\n", self->monsterinfo.lefty);
  35. self->dmg = 1;
  36. }
  37. }
  38. void showme2 (edict_t *self)
  39. {
  40. if (!self->dmg)
  41. {
  42. gi.dprintf ("strafe - %d\n", self->monsterinfo.lefty);
  43. self->dmg = 1;
  44. }
  45. }
  46. */
  47. void flyer_sight (edict_t *self, edict_t *other)
  48. {
  49. gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
  50. }
  51. void flyer_idle (edict_t *self)
  52. {
  53. gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
  54. }
  55. void flyer_pop_blades (edict_t *self)
  56. {
  57. gi.sound (self, CHAN_VOICE, sound_sproing, 1, ATTN_NORM, 0);
  58. }
  59. mframe_t flyer_frames_stand [] =
  60. {
  61. ai_stand, 0, NULL,
  62. ai_stand, 0, NULL,
  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, NULL,
  92. ai_stand, 0, NULL,
  93. ai_stand, 0, NULL,
  94. ai_stand, 0, NULL,
  95. ai_stand, 0, NULL,
  96. ai_stand, 0, NULL,
  97. ai_stand, 0, NULL,
  98. ai_stand, 0, NULL,
  99. ai_stand, 0, NULL,
  100. ai_stand, 0, NULL,
  101. ai_stand, 0, NULL,
  102. ai_stand, 0, NULL,
  103. ai_stand, 0, NULL,
  104. ai_stand, 0, NULL,
  105. ai_stand, 0, NULL
  106. };
  107. mmove_t flyer_move_stand = {FRAME_stand01, FRAME_stand45, flyer_frames_stand, NULL};
  108. mframe_t flyer_frames_walk [] =
  109. {
  110. ai_walk, 5, NULL,
  111. ai_walk, 5, NULL,
  112. ai_walk, 5, NULL,
  113. ai_walk, 5, NULL,
  114. ai_walk, 5, NULL,
  115. ai_walk, 5, NULL,
  116. ai_walk, 5, NULL,
  117. ai_walk, 5, NULL,
  118. ai_walk, 5, NULL,
  119. ai_walk, 5, NULL,
  120. ai_walk, 5, NULL,
  121. ai_walk, 5, NULL,
  122. ai_walk, 5, NULL,
  123. ai_walk, 5, NULL,
  124. ai_walk, 5, NULL,
  125. ai_walk, 5, NULL,
  126. ai_walk, 5, NULL,
  127. ai_walk, 5, NULL,
  128. ai_walk, 5, NULL,
  129. ai_walk, 5, NULL,
  130. ai_walk, 5, NULL,
  131. ai_walk, 5, NULL,
  132. ai_walk, 5, NULL,
  133. ai_walk, 5, NULL,
  134. ai_walk, 5, NULL,
  135. ai_walk, 5, NULL,
  136. ai_walk, 5, NULL,
  137. ai_walk, 5, NULL,
  138. ai_walk, 5, NULL,
  139. ai_walk, 5, NULL,
  140. ai_walk, 5, NULL,
  141. ai_walk, 5, NULL,
  142. ai_walk, 5, NULL,
  143. ai_walk, 5, NULL,
  144. ai_walk, 5, NULL,
  145. ai_walk, 5, NULL,
  146. ai_walk, 5, NULL,
  147. ai_walk, 5, NULL,
  148. ai_walk, 5, NULL,
  149. ai_walk, 5, NULL,
  150. ai_walk, 5, NULL,
  151. ai_walk, 5, NULL,
  152. ai_walk, 5, NULL,
  153. ai_walk, 5, NULL,
  154. ai_walk, 5, NULL
  155. };
  156. mmove_t flyer_move_walk = {FRAME_stand01, FRAME_stand45, flyer_frames_walk, NULL};
  157. mframe_t flyer_frames_run [] =
  158. {
  159. ai_run, 10, NULL,
  160. ai_run, 10, NULL,
  161. ai_run, 10, NULL,
  162. ai_run, 10, NULL,
  163. ai_run, 10, NULL,
  164. ai_run, 10, NULL,
  165. ai_run, 10, NULL,
  166. ai_run, 10, NULL,
  167. ai_run, 10, NULL,
  168. ai_run, 10, NULL,
  169. ai_run, 10, NULL,
  170. ai_run, 10, NULL,
  171. ai_run, 10, NULL,
  172. ai_run, 10, NULL,
  173. ai_run, 10, NULL,
  174. ai_run, 10, NULL,
  175. ai_run, 10, NULL,
  176. ai_run, 10, NULL,
  177. ai_run, 10, NULL,
  178. ai_run, 10, NULL,
  179. ai_run, 10, NULL,
  180. ai_run, 10, NULL,
  181. ai_run, 10, NULL,
  182. ai_run, 10, NULL,
  183. ai_run, 10, NULL,
  184. ai_run, 10, NULL,
  185. ai_run, 10, NULL,
  186. ai_run, 10, NULL,
  187. ai_run, 10, NULL,
  188. ai_run, 10, NULL,
  189. ai_run, 10, NULL,
  190. ai_run, 10, NULL,
  191. ai_run, 10, NULL,
  192. ai_run, 10, NULL,
  193. ai_run, 10, NULL,
  194. ai_run, 10, NULL,
  195. ai_run, 10, NULL,
  196. ai_run, 10, NULL,
  197. ai_run, 10, NULL,
  198. ai_run, 10, NULL,
  199. ai_run, 10, NULL,
  200. ai_run, 10, NULL,
  201. ai_run, 10, NULL,
  202. ai_run, 10, NULL,
  203. ai_run, 10, NULL
  204. };
  205. mmove_t flyer_move_run = {FRAME_stand01, FRAME_stand45, flyer_frames_run, NULL};
  206. mframe_t flyer_frames_kamizake [] =
  207. {
  208. ai_charge, 40, flyer_kamikaze_check,
  209. ai_charge, 40, flyer_kamikaze_check,
  210. ai_charge, 40, flyer_kamikaze_check,
  211. ai_charge, 40, flyer_kamikaze_check,
  212. ai_charge, 40, flyer_kamikaze_check
  213. };
  214. mmove_t flyer_move_kamikaze = {FRAME_rollr02, FRAME_rollr06, flyer_frames_kamizake, flyer_kamikaze};
  215. void flyer_run (edict_t *self)
  216. {
  217. if (self->mass > 50)
  218. self->monsterinfo.currentmove = &flyer_move_kamikaze;
  219. else
  220. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  221. self->monsterinfo.currentmove = &flyer_move_stand;
  222. else
  223. self->monsterinfo.currentmove = &flyer_move_run;
  224. }
  225. void flyer_walk (edict_t *self)
  226. {
  227. if (self->mass > 50)
  228. flyer_run (self);
  229. else
  230. self->monsterinfo.currentmove = &flyer_move_walk;
  231. }
  232. void flyer_stand (edict_t *self)
  233. {
  234. if (self->mass > 50)
  235. flyer_run (self);
  236. else
  237. self->monsterinfo.currentmove = &flyer_move_stand;
  238. }
  239. // ROGUE - kamikaze stuff
  240. void flyer_kamikaze_explode (edict_t *self)
  241. {
  242. vec3_t dir;
  243. if (self->monsterinfo.commander && self->monsterinfo.commander->inuse &&
  244. !strcmp(self->monsterinfo.commander->classname, "monster_carrier"))
  245. {
  246. self->monsterinfo.commander->monsterinfo.monster_slots++;
  247. // if ((g_showlogic) && (g_showlogic->value))
  248. // gi.dprintf ("suicide hit!. %d slots left\n", self->monsterinfo.commander->monsterinfo.monster_slots);
  249. }
  250. // gi.dprintf ("boom!\n");
  251. // T_RadiusDamage(self, self->owner, 125, self, self->dmg_radius, MOD_NUKE);
  252. // T_RadiusDamage(self, self->owner, 125, self, 150, MOD_NUKE);
  253. if (self->enemy)
  254. {
  255. VectorSubtract (self->enemy->s.origin, self->s.origin, dir);
  256. //void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir, vec3_t point,
  257. // vec3_t normal, int damage, int knockback, int dflags, int mod)
  258. T_Damage (self->enemy, self, self, dir, self->s.origin, vec3_origin, (int)50, (int)50, DAMAGE_RADIUS, MOD_UNKNOWN);
  259. }
  260. flyer_die (self, NULL, NULL, 0, dir);
  261. /* VectorMA (self->s.origin, -0.02, self->velocity, origin);
  262. gi.WriteByte (svc_temp_entity);
  263. gi.WriteByte (TE_ROCKET_EXPLOSION);
  264. gi.WritePosition (origin);
  265. gi.multicast (self->s.origin, MULTICAST_PHS);
  266. G_FreeEdict (self);
  267. */
  268. }
  269. void flyer_kamikaze (edict_t *self)
  270. {
  271. self->monsterinfo.currentmove = &flyer_move_kamikaze;
  272. }
  273. void flyer_kamikaze_check (edict_t *self)
  274. {
  275. float dist;
  276. // PMM - this needed because we could have gone away before we get here (blocked code)
  277. if (!self->inuse)
  278. return;
  279. if ((!self->enemy) || (!self->enemy->inuse))
  280. {
  281. flyer_kamikaze_explode (self);
  282. return;
  283. }
  284. self->goalentity = self->enemy;
  285. dist = realrange (self, self->enemy);
  286. if (dist < 90)
  287. flyer_kamikaze_explode (self);
  288. }
  289. // rogue - kamikaze
  290. mframe_t flyer_frames_start [] =
  291. {
  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. ai_move, 0, flyer_nextmove
  298. };
  299. mmove_t flyer_move_start = {FRAME_start01, FRAME_start06, flyer_frames_start, NULL};
  300. mframe_t flyer_frames_stop [] =
  301. {
  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, flyer_nextmove
  309. };
  310. mmove_t flyer_move_stop = {FRAME_stop01, FRAME_stop07, flyer_frames_stop, NULL};
  311. void flyer_stop (edict_t *self)
  312. {
  313. self->monsterinfo.currentmove = &flyer_move_stop;
  314. }
  315. void flyer_start (edict_t *self)
  316. {
  317. self->monsterinfo.currentmove = &flyer_move_start;
  318. }
  319. mframe_t flyer_frames_rollright [] =
  320. {
  321. ai_move, 0, NULL,
  322. ai_move, 0, NULL,
  323. ai_move, 0, NULL,
  324. ai_move, 0, NULL,
  325. ai_move, 0, NULL,
  326. ai_move, 0, NULL,
  327. ai_move, 0, NULL,
  328. ai_move, 0, NULL,
  329. ai_move, 0, NULL
  330. };
  331. mmove_t flyer_move_rollright = {FRAME_rollr01, FRAME_rollr09, flyer_frames_rollright, NULL};
  332. mframe_t flyer_frames_rollleft [] =
  333. {
  334. ai_move, 0, NULL,
  335. ai_move, 0, NULL,
  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. };
  344. mmove_t flyer_move_rollleft = {FRAME_rollf01, FRAME_rollf09, flyer_frames_rollleft, NULL};
  345. mframe_t flyer_frames_pain3 [] =
  346. {
  347. ai_move, 0, NULL,
  348. ai_move, 0, NULL,
  349. ai_move, 0, NULL,
  350. ai_move, 0, NULL
  351. };
  352. mmove_t flyer_move_pain3 = {FRAME_pain301, FRAME_pain304, flyer_frames_pain3, flyer_run};
  353. mframe_t flyer_frames_pain2 [] =
  354. {
  355. ai_move, 0, NULL,
  356. ai_move, 0, NULL,
  357. ai_move, 0, NULL,
  358. ai_move, 0, NULL
  359. };
  360. mmove_t flyer_move_pain2 = {FRAME_pain201, FRAME_pain204, flyer_frames_pain2, flyer_run};
  361. mframe_t flyer_frames_pain1 [] =
  362. {
  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. };
  373. mmove_t flyer_move_pain1 = {FRAME_pain101, FRAME_pain109, flyer_frames_pain1, flyer_run};
  374. mframe_t flyer_frames_defense [] =
  375. {
  376. ai_move, 0, NULL,
  377. ai_move, 0, NULL,
  378. ai_move, 0, NULL, // Hold this frame
  379. ai_move, 0, NULL,
  380. ai_move, 0, NULL,
  381. ai_move, 0, NULL
  382. };
  383. mmove_t flyer_move_defense = {FRAME_defens01, FRAME_defens06, flyer_frames_defense, NULL};
  384. mframe_t flyer_frames_bankright [] =
  385. {
  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. };
  394. mmove_t flyer_move_bankright = {FRAME_bankr01, FRAME_bankr07, flyer_frames_bankright, NULL};
  395. mframe_t flyer_frames_bankleft [] =
  396. {
  397. ai_move, 0, NULL,
  398. ai_move, 0, NULL,
  399. ai_move, 0, NULL,
  400. ai_move, 0, NULL,
  401. ai_move, 0, NULL,
  402. ai_move, 0, NULL,
  403. ai_move, 0, NULL
  404. };
  405. mmove_t flyer_move_bankleft = {FRAME_bankl01, FRAME_bankl07, flyer_frames_bankleft, NULL};
  406. void flyer_fire (edict_t *self, int flash_number)
  407. {
  408. vec3_t start;
  409. vec3_t forward, right;
  410. vec3_t end;
  411. vec3_t dir;
  412. int effect;
  413. if(!self->enemy || !self->enemy->inuse) //PGM
  414. return; //PGM
  415. if ((self->s.frame == FRAME_attak204) || (self->s.frame == FRAME_attak207) || (self->s.frame == FRAME_attak210))
  416. effect = EF_HYPERBLASTER;
  417. else
  418. effect = 0;
  419. AngleVectors (self->s.angles, forward, right, NULL);
  420. G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
  421. VectorCopy (self->enemy->s.origin, end);
  422. end[2] += self->enemy->viewheight;
  423. VectorSubtract (end, start, dir);
  424. monster_fire_blaster (self, start, dir, 1, 1000, flash_number, effect);
  425. }
  426. void flyer_fireleft (edict_t *self)
  427. {
  428. flyer_fire (self, MZ2_FLYER_BLASTER_1);
  429. }
  430. void flyer_fireright (edict_t *self)
  431. {
  432. flyer_fire (self, MZ2_FLYER_BLASTER_2);
  433. }
  434. mframe_t flyer_frames_attack2 [] =
  435. {
  436. ai_charge, 0, NULL,
  437. ai_charge, 0, NULL,
  438. ai_charge, 0, NULL,
  439. ai_charge, -10, flyer_fireleft, // left gun
  440. ai_charge, -10, flyer_fireright, // right gun
  441. ai_charge, -10, flyer_fireleft, // left gun
  442. ai_charge, -10, flyer_fireright, // right gun
  443. ai_charge, -10, flyer_fireleft, // left gun
  444. ai_charge, -10, flyer_fireright, // right gun
  445. ai_charge, -10, flyer_fireleft, // left gun
  446. ai_charge, -10, flyer_fireright, // right gun
  447. ai_charge, 0, NULL,
  448. ai_charge, 0, NULL,
  449. ai_charge, 0, NULL,
  450. ai_charge, 0, NULL,
  451. ai_charge, 0, NULL,
  452. ai_charge, 0, NULL
  453. };
  454. mmove_t flyer_move_attack2 = {FRAME_attak201, FRAME_attak217, flyer_frames_attack2, flyer_run};
  455. // PMM
  456. // circle strafe frames
  457. mframe_t flyer_frames_attack3 [] =
  458. {
  459. ai_charge, 10, NULL,
  460. ai_charge, 10, NULL,
  461. ai_charge, 10, NULL,
  462. ai_charge, 10, flyer_fireleft, // left gun
  463. ai_charge, 10, flyer_fireright, // right gun
  464. ai_charge, 10, flyer_fireleft, // left gun
  465. ai_charge, 10, flyer_fireright, // right gun
  466. ai_charge, 10, flyer_fireleft, // left gun
  467. ai_charge, 10, flyer_fireright, // right gun
  468. ai_charge, 10, flyer_fireleft, // left gun
  469. ai_charge, 10, flyer_fireright, // right gun
  470. ai_charge, 10, NULL,
  471. ai_charge, 10, NULL,
  472. ai_charge, 10, NULL,
  473. ai_charge, 10, NULL,
  474. ai_charge, 10, NULL,
  475. ai_charge, 10, NULL
  476. };
  477. mmove_t flyer_move_attack3 = {FRAME_attak201, FRAME_attak217, flyer_frames_attack3, flyer_run};
  478. // pmm
  479. void flyer_slash_left (edict_t *self)
  480. {
  481. vec3_t aim;
  482. VectorSet (aim, MELEE_DISTANCE, self->mins[0], 0);
  483. fire_hit (self, aim, 5, 0);
  484. gi.sound (self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0);
  485. }
  486. void flyer_slash_right (edict_t *self)
  487. {
  488. vec3_t aim;
  489. VectorSet (aim, MELEE_DISTANCE, self->maxs[0], 0);
  490. fire_hit (self, aim, 5, 0);
  491. gi.sound (self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0);
  492. }
  493. mframe_t flyer_frames_start_melee [] =
  494. {
  495. ai_charge, 0, flyer_pop_blades,
  496. ai_charge, 0, NULL,
  497. ai_charge, 0, NULL,
  498. ai_charge, 0, NULL,
  499. ai_charge, 0, NULL,
  500. ai_charge, 0, NULL
  501. };
  502. mmove_t flyer_move_start_melee = {FRAME_attak101, FRAME_attak106, flyer_frames_start_melee, flyer_loop_melee};
  503. mframe_t flyer_frames_end_melee [] =
  504. {
  505. ai_charge, 0, NULL,
  506. ai_charge, 0, NULL,
  507. ai_charge, 0, NULL
  508. };
  509. mmove_t flyer_move_end_melee = {FRAME_attak119, FRAME_attak121, flyer_frames_end_melee, flyer_run};
  510. mframe_t flyer_frames_loop_melee [] =
  511. {
  512. ai_charge, 0, NULL, // Loop Start
  513. ai_charge, 0, NULL,
  514. ai_charge, 0, flyer_slash_left, // Left Wing Strike
  515. ai_charge, 0, NULL,
  516. ai_charge, 0, NULL,
  517. ai_charge, 0, NULL,
  518. ai_charge, 0, NULL,
  519. ai_charge, 0, flyer_slash_right, // Right Wing Strike
  520. ai_charge, 0, NULL,
  521. ai_charge, 0, NULL,
  522. ai_charge, 0, NULL,
  523. ai_charge, 0, NULL // Loop Ends
  524. };
  525. mmove_t flyer_move_loop_melee = {FRAME_attak107, FRAME_attak118, flyer_frames_loop_melee, flyer_check_melee};
  526. void flyer_loop_melee (edict_t *self)
  527. {
  528. /* if (random() <= 0.5)
  529. self->monsterinfo.currentmove = &flyer_move_attack1;
  530. else */
  531. self->monsterinfo.currentmove = &flyer_move_loop_melee;
  532. }
  533. void flyer_attack (edict_t *self)
  534. {
  535. float chance;
  536. /* if (random() <= 0.5)
  537. self->monsterinfo.currentmove = &flyer_move_attack1;
  538. else */
  539. // 0% chance of circle in easy
  540. // 50% chance in normal
  541. // 75% chance in hard
  542. // 86.67% chance in nightmare
  543. if (self->mass > 50)
  544. {
  545. flyer_run (self);
  546. return;
  547. }
  548. if (!skill->value)
  549. chance = 0;
  550. else
  551. chance = 1.0 - (0.5/(float)(skill->value));
  552. if (random() > chance)
  553. {
  554. self->monsterinfo.attack_state = AS_STRAIGHT;
  555. self->monsterinfo.currentmove = &flyer_move_attack2;
  556. }
  557. else // circle strafe
  558. {
  559. if (random () <= 0.5) // switch directions
  560. self->monsterinfo.lefty = 1 - self->monsterinfo.lefty;
  561. self->monsterinfo.attack_state = AS_SLIDING;
  562. self->monsterinfo.currentmove = &flyer_move_attack3;
  563. }
  564. }
  565. void flyer_setstart (edict_t *self)
  566. {
  567. nextmove = ACTION_run;
  568. self->monsterinfo.currentmove = &flyer_move_start;
  569. }
  570. void flyer_nextmove (edict_t *self)
  571. {
  572. if (nextmove == ACTION_attack1)
  573. self->monsterinfo.currentmove = &flyer_move_start_melee;
  574. else if (nextmove == ACTION_attack2)
  575. self->monsterinfo.currentmove = &flyer_move_attack2;
  576. else if (nextmove == ACTION_run)
  577. self->monsterinfo.currentmove = &flyer_move_run;
  578. }
  579. void flyer_melee (edict_t *self)
  580. {
  581. // flyer.nextmove = ACTION_attack1;
  582. // self->monsterinfo.currentmove = &flyer_move_stop;
  583. if (self->mass > 50)
  584. flyer_run (self);
  585. else
  586. self->monsterinfo.currentmove = &flyer_move_start_melee;
  587. }
  588. void flyer_check_melee(edict_t *self)
  589. {
  590. if (range (self, self->enemy) == RANGE_MELEE)
  591. if (random() <= 0.8)
  592. self->monsterinfo.currentmove = &flyer_move_loop_melee;
  593. else
  594. self->monsterinfo.currentmove = &flyer_move_end_melee;
  595. else
  596. self->monsterinfo.currentmove = &flyer_move_end_melee;
  597. }
  598. void flyer_pain (edict_t *self, edict_t *other, float kick, int damage)
  599. {
  600. int n;
  601. // pmm - kamikaze's don't feel pain
  602. if (self->mass != 50)
  603. return;
  604. // pmm
  605. if (self->health < (self->max_health / 2))
  606. self->s.skinnum = 1;
  607. if (level.time < self->pain_debounce_time)
  608. return;
  609. self->pain_debounce_time = level.time + 3;
  610. if (skill->value == 3)
  611. return; // no pain anims in nightmare
  612. n = rand() % 3;
  613. if (n == 0)
  614. {
  615. gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
  616. self->monsterinfo.currentmove = &flyer_move_pain1;
  617. }
  618. else if (n == 1)
  619. {
  620. gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
  621. self->monsterinfo.currentmove = &flyer_move_pain2;
  622. }
  623. else
  624. {
  625. gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
  626. self->monsterinfo.currentmove = &flyer_move_pain3;
  627. }
  628. }
  629. void flyer_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  630. {
  631. gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
  632. BecomeExplosion1(self);
  633. }
  634. // PMM - kamikaze code .. blow up if blocked
  635. int flyer_blocked (edict_t *self, float dist)
  636. {
  637. vec3_t origin;
  638. // kamikaze = 100, normal = 50
  639. if (self->mass == 100)
  640. {
  641. flyer_kamikaze_check(self);
  642. // if the above didn't blow us up (i.e. I got blocked by the player)
  643. if (self->inuse)
  644. {
  645. if (self->monsterinfo.commander && self->monsterinfo.commander->inuse &&
  646. !strcmp(self->monsterinfo.commander->classname, "monster_carrier"))
  647. {
  648. self->monsterinfo.commander->monsterinfo.monster_slots++;
  649. // if ((g_showlogic) && (g_showlogic->value))
  650. // gi.dprintf ("suicide blocked, exploding. %d slots left\n", self->monsterinfo.commander->monsterinfo.monster_slots);
  651. }
  652. VectorMA (self->s.origin, -0.02, self->velocity, origin);
  653. gi.WriteByte (svc_temp_entity);
  654. gi.WriteByte (TE_ROCKET_EXPLOSION);
  655. gi.WritePosition (origin);
  656. gi.multicast (self->s.origin, MULTICAST_PHS);
  657. G_FreeEdict (self);
  658. }
  659. return true;
  660. }
  661. // we're a normal flyer
  662. if(blocked_checkshot (self, 0.25 + (0.05 * skill->value) ))
  663. return true;
  664. return false;
  665. }
  666. /*QUAKED monster_flyer (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  667. */
  668. void SP_monster_flyer (edict_t *self)
  669. {
  670. if (deathmatch->value)
  671. {
  672. G_FreeEdict (self);
  673. return;
  674. }
  675. // fix a map bug in jail5.bsp
  676. if (!Q_stricmp(level.mapname, "jail5") && (self->s.origin[2] == -104))
  677. {
  678. self->targetname = self->target;
  679. self->target = NULL;
  680. }
  681. sound_sight = gi.soundindex ("flyer/flysght1.wav");
  682. sound_idle = gi.soundindex ("flyer/flysrch1.wav");
  683. sound_pain1 = gi.soundindex ("flyer/flypain1.wav");
  684. sound_pain2 = gi.soundindex ("flyer/flypain2.wav");
  685. sound_slash = gi.soundindex ("flyer/flyatck2.wav");
  686. sound_sproing = gi.soundindex ("flyer/flyatck1.wav");
  687. sound_die = gi.soundindex ("flyer/flydeth1.wav");
  688. gi.soundindex ("flyer/flyatck3.wav");
  689. self->s.modelindex = gi.modelindex ("models/monsters/flyer/tris.md2");
  690. VectorSet (self->mins, -16, -16, -24);
  691. // PMM - shortened to 16 from 32
  692. VectorSet (self->maxs, 16, 16, 16);
  693. self->movetype = MOVETYPE_STEP;
  694. self->solid = SOLID_BBOX;
  695. self->s.sound = gi.soundindex ("flyer/flyidle1.wav");
  696. self->health = 50;
  697. self->mass = 50;
  698. self->pain = flyer_pain;
  699. self->die = flyer_die;
  700. self->monsterinfo.stand = flyer_stand;
  701. self->monsterinfo.walk = flyer_walk;
  702. self->monsterinfo.run = flyer_run;
  703. self->monsterinfo.attack = flyer_attack;
  704. self->monsterinfo.melee = flyer_melee;
  705. self->monsterinfo.sight = flyer_sight;
  706. self->monsterinfo.idle = flyer_idle;
  707. self->monsterinfo.blocked = flyer_blocked;
  708. gi.linkentity (self);
  709. self->monsterinfo.currentmove = &flyer_move_stand;
  710. self->monsterinfo.scale = MODEL_SCALE;
  711. flymonster_start (self);
  712. }
  713. // PMM - suicide fliers
  714. void SP_monster_kamikaze (edict_t *self)
  715. {
  716. if (deathmatch->value)
  717. {
  718. G_FreeEdict (self);
  719. return;
  720. }
  721. sound_sight = gi.soundindex ("flyer/flysght1.wav");
  722. sound_idle = gi.soundindex ("flyer/flysrch1.wav");
  723. sound_pain1 = gi.soundindex ("flyer/flypain1.wav");
  724. sound_pain2 = gi.soundindex ("flyer/flypain2.wav");
  725. sound_slash = gi.soundindex ("flyer/flyatck2.wav");
  726. sound_sproing = gi.soundindex ("flyer/flyatck1.wav");
  727. sound_die = gi.soundindex ("flyer/flydeth1.wav");
  728. gi.soundindex ("flyer/flyatck3.wav");
  729. self->s.modelindex = gi.modelindex ("models/monsters/flyer/tris.md2");
  730. VectorSet (self->mins, -16, -16, -24);
  731. // used to be 32 tall .. was WAY too big
  732. VectorSet (self->maxs, 16, 16, 16);
  733. self->movetype = MOVETYPE_STEP;
  734. self->solid = SOLID_BBOX;
  735. self->s.sound = gi.soundindex ("flyer/flyidle1.wav");
  736. self->s.effects |= EF_ROCKET;
  737. self->health = 50;
  738. // PMM - normal flyer has mass of 50
  739. self->mass = 100;
  740. self->pain = flyer_pain;
  741. self->die = flyer_die;
  742. self->monsterinfo.stand = flyer_stand;
  743. self->monsterinfo.walk = flyer_walk;
  744. self->monsterinfo.run = flyer_run;
  745. self->monsterinfo.attack = flyer_attack;
  746. self->monsterinfo.melee = flyer_melee;
  747. self->monsterinfo.sight = flyer_sight;
  748. self->monsterinfo.idle = flyer_idle;
  749. self->monsterinfo.blocked = flyer_blocked;
  750. gi.linkentity (self);
  751. self->monsterinfo.currentmove = &flyer_move_stand;
  752. self->monsterinfo.scale = MODEL_SCALE;
  753. flymonster_start (self);
  754. }