m_float.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. /*
  4. ==============================================================================
  5. floater
  6. ==============================================================================
  7. */
  8. #include "g_local.h"
  9. #include "m_float.h"
  10. static int sound_attack2;
  11. static int sound_attack3;
  12. static int sound_death1;
  13. static int sound_idle;
  14. static int sound_pain1;
  15. static int sound_pain2;
  16. static int sound_sight;
  17. void floater_sight (edict_t *self, edict_t *other)
  18. {
  19. gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
  20. }
  21. void floater_idle (edict_t *self)
  22. {
  23. gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
  24. }
  25. //void floater_stand1 (edict_t *self);
  26. void floater_dead (edict_t *self);
  27. void floater_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point);
  28. void floater_run (edict_t *self);
  29. void floater_wham (edict_t *self);
  30. void floater_zap (edict_t *self);
  31. void floater_fire_blaster (edict_t *self)
  32. {
  33. vec3_t start;
  34. vec3_t forward, right;
  35. vec3_t end;
  36. vec3_t dir;
  37. int effect;
  38. if(!self->enemy || !self->enemy->inuse) //PGM
  39. return; //PGM
  40. if ((self->s.frame == FRAME_attak104) || (self->s.frame == FRAME_attak107))
  41. effect = EF_HYPERBLASTER;
  42. else
  43. effect = 0;
  44. AngleVectors (self->s.angles, forward, right, NULL);
  45. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_FLOAT_BLASTER_1], forward, right, start);
  46. VectorCopy (self->enemy->s.origin, end);
  47. end[2] += self->enemy->viewheight;
  48. VectorSubtract (end, start, dir);
  49. monster_fire_blaster (self, start, dir, 1, 1000, MZ2_FLOAT_BLASTER_1, effect);
  50. }
  51. mframe_t floater_frames_stand1 [] =
  52. {
  53. ai_stand, 0, NULL,
  54. ai_stand, 0, NULL,
  55. ai_stand, 0, NULL,
  56. ai_stand, 0, NULL,
  57. ai_stand, 0, NULL,
  58. ai_stand, 0, NULL,
  59. ai_stand, 0, NULL,
  60. ai_stand, 0, NULL,
  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. };
  106. mmove_t floater_move_stand1 = {FRAME_stand101, FRAME_stand152, floater_frames_stand1, NULL};
  107. mframe_t floater_frames_stand2 [] =
  108. {
  109. ai_stand, 0, NULL,
  110. ai_stand, 0, NULL,
  111. ai_stand, 0, NULL,
  112. ai_stand, 0, NULL,
  113. ai_stand, 0, NULL,
  114. ai_stand, 0, NULL,
  115. ai_stand, 0, NULL,
  116. ai_stand, 0, NULL,
  117. ai_stand, 0, NULL,
  118. ai_stand, 0, NULL,
  119. ai_stand, 0, NULL,
  120. ai_stand, 0, NULL,
  121. ai_stand, 0, NULL,
  122. ai_stand, 0, NULL,
  123. ai_stand, 0, NULL,
  124. ai_stand, 0, NULL,
  125. ai_stand, 0, NULL,
  126. ai_stand, 0, NULL,
  127. ai_stand, 0, NULL,
  128. ai_stand, 0, NULL,
  129. ai_stand, 0, NULL,
  130. ai_stand, 0, NULL,
  131. ai_stand, 0, NULL,
  132. ai_stand, 0, NULL,
  133. ai_stand, 0, NULL,
  134. ai_stand, 0, NULL,
  135. ai_stand, 0, NULL,
  136. ai_stand, 0, NULL,
  137. ai_stand, 0, NULL,
  138. ai_stand, 0, NULL,
  139. ai_stand, 0, NULL,
  140. ai_stand, 0, NULL,
  141. ai_stand, 0, NULL,
  142. ai_stand, 0, NULL,
  143. ai_stand, 0, NULL,
  144. ai_stand, 0, NULL,
  145. ai_stand, 0, NULL,
  146. ai_stand, 0, NULL,
  147. ai_stand, 0, NULL,
  148. ai_stand, 0, NULL,
  149. ai_stand, 0, NULL,
  150. ai_stand, 0, NULL,
  151. ai_stand, 0, NULL,
  152. ai_stand, 0, NULL,
  153. ai_stand, 0, NULL,
  154. ai_stand, 0, NULL,
  155. ai_stand, 0, NULL,
  156. ai_stand, 0, NULL,
  157. ai_stand, 0, NULL,
  158. ai_stand, 0, NULL,
  159. ai_stand, 0, NULL,
  160. ai_stand, 0, NULL
  161. };
  162. mmove_t floater_move_stand2 = {FRAME_stand201, FRAME_stand252, floater_frames_stand2, NULL};
  163. void floater_stand (edict_t *self)
  164. {
  165. if (random() <= 0.5)
  166. self->monsterinfo.currentmove = &floater_move_stand1;
  167. else
  168. self->monsterinfo.currentmove = &floater_move_stand2;
  169. }
  170. mframe_t floater_frames_activate [] =
  171. {
  172. ai_move, 0, NULL,
  173. ai_move, 0, NULL,
  174. ai_move, 0, NULL,
  175. ai_move, 0, NULL,
  176. ai_move, 0, NULL,
  177. ai_move, 0, NULL,
  178. ai_move, 0, NULL,
  179. ai_move, 0, NULL,
  180. ai_move, 0, NULL,
  181. ai_move, 0, NULL,
  182. ai_move, 0, NULL,
  183. ai_move, 0, NULL,
  184. ai_move, 0, NULL,
  185. ai_move, 0, NULL,
  186. ai_move, 0, NULL,
  187. ai_move, 0, NULL,
  188. ai_move, 0, NULL,
  189. ai_move, 0, NULL,
  190. ai_move, 0, NULL,
  191. ai_move, 0, NULL,
  192. ai_move, 0, NULL,
  193. ai_move, 0, NULL,
  194. ai_move, 0, NULL,
  195. ai_move, 0, NULL,
  196. ai_move, 0, NULL,
  197. ai_move, 0, NULL,
  198. ai_move, 0, NULL,
  199. ai_move, 0, NULL,
  200. ai_move, 0, NULL,
  201. ai_move, 0, NULL
  202. };
  203. mmove_t floater_move_activate = {FRAME_actvat01, FRAME_actvat31, floater_frames_activate, NULL};
  204. mframe_t floater_frames_attack1 [] =
  205. {
  206. ai_charge, 0, NULL, // Blaster attack
  207. ai_charge, 0, NULL,
  208. ai_charge, 0, NULL,
  209. ai_charge, 0, floater_fire_blaster, // BOOM (0, -25.8, 32.5) -- LOOP Starts
  210. ai_charge, 0, floater_fire_blaster,
  211. ai_charge, 0, floater_fire_blaster,
  212. ai_charge, 0, floater_fire_blaster,
  213. ai_charge, 0, floater_fire_blaster,
  214. ai_charge, 0, floater_fire_blaster,
  215. ai_charge, 0, floater_fire_blaster,
  216. ai_charge, 0, NULL,
  217. ai_charge, 0, NULL,
  218. ai_charge, 0, NULL,
  219. ai_charge, 0, NULL // -- LOOP Ends
  220. };
  221. mmove_t floater_move_attack1 = {FRAME_attak101, FRAME_attak114, floater_frames_attack1, floater_run};
  222. // PMM - circle strafe frames
  223. mframe_t floater_frames_attack1a [] =
  224. {
  225. ai_charge, 10, NULL, // Blaster attack
  226. ai_charge, 10, NULL,
  227. ai_charge, 10, NULL,
  228. ai_charge, 10, floater_fire_blaster, // BOOM (0, -25.8, 32.5) -- LOOP Starts
  229. ai_charge, 10, floater_fire_blaster,
  230. ai_charge, 10, floater_fire_blaster,
  231. ai_charge, 10, floater_fire_blaster,
  232. ai_charge, 10, floater_fire_blaster,
  233. ai_charge, 10, floater_fire_blaster,
  234. ai_charge, 10, floater_fire_blaster,
  235. ai_charge, 10, NULL,
  236. ai_charge, 10, NULL,
  237. ai_charge, 10, NULL,
  238. ai_charge, 10, NULL // -- LOOP Ends
  239. };
  240. mmove_t floater_move_attack1a = {FRAME_attak101, FRAME_attak114, floater_frames_attack1a, floater_run};
  241. //pmm
  242. mframe_t floater_frames_attack2 [] =
  243. {
  244. ai_charge, 0, NULL, // Claws
  245. ai_charge, 0, NULL,
  246. ai_charge, 0, NULL,
  247. ai_charge, 0, NULL,
  248. ai_charge, 0, NULL,
  249. ai_charge, 0, NULL,
  250. ai_charge, 0, NULL,
  251. ai_charge, 0, NULL,
  252. ai_charge, 0, NULL,
  253. ai_charge, 0, NULL,
  254. ai_charge, 0, NULL,
  255. ai_charge, 0, floater_wham, // WHAM (0, -45, 29.6) -- LOOP Starts
  256. ai_charge, 0, NULL,
  257. ai_charge, 0, NULL,
  258. ai_charge, 0, NULL,
  259. ai_charge, 0, NULL,
  260. ai_charge, 0, NULL,
  261. ai_charge, 0, NULL,
  262. ai_charge, 0, NULL, // -- LOOP Ends
  263. ai_charge, 0, NULL,
  264. ai_charge, 0, NULL,
  265. ai_charge, 0, NULL,
  266. ai_charge, 0, NULL,
  267. ai_charge, 0, NULL,
  268. ai_charge, 0, NULL
  269. };
  270. mmove_t floater_move_attack2 = {FRAME_attak201, FRAME_attak225, floater_frames_attack2, floater_run};
  271. mframe_t floater_frames_attack3 [] =
  272. {
  273. ai_charge, 0, NULL,
  274. ai_charge, 0, NULL,
  275. ai_charge, 0, NULL,
  276. ai_charge, 0, NULL,
  277. ai_charge, 0, NULL,
  278. ai_charge, 0, NULL,
  279. ai_charge, 0, NULL,
  280. ai_charge, 0, NULL,
  281. ai_charge, 0, floater_zap, // -- LOOP Starts
  282. ai_charge, 0, NULL,
  283. ai_charge, 0, NULL,
  284. ai_charge, 0, NULL,
  285. ai_charge, 0, NULL,
  286. ai_charge, 0, NULL,
  287. ai_charge, 0, NULL,
  288. ai_charge, 0, NULL,
  289. ai_charge, 0, NULL,
  290. ai_charge, 0, NULL,
  291. ai_charge, 0, NULL,
  292. ai_charge, 0, NULL,
  293. ai_charge, 0, NULL,
  294. ai_charge, 0, NULL,
  295. ai_charge, 0, NULL,
  296. ai_charge, 0, NULL,
  297. ai_charge, 0, NULL,
  298. ai_charge, 0, NULL,
  299. ai_charge, 0, NULL,
  300. ai_charge, 0, NULL,
  301. ai_charge, 0, NULL, // -- LOOP Ends
  302. ai_charge, 0, NULL,
  303. ai_charge, 0, NULL,
  304. ai_charge, 0, NULL,
  305. ai_charge, 0, NULL,
  306. ai_charge, 0, NULL
  307. };
  308. mmove_t floater_move_attack3 = {FRAME_attak301, FRAME_attak334, floater_frames_attack3, floater_run};
  309. mframe_t floater_frames_death [] =
  310. {
  311. ai_move, 0, NULL,
  312. ai_move, 0, NULL,
  313. ai_move, 0, NULL,
  314. ai_move, 0, NULL,
  315. ai_move, 0, NULL,
  316. ai_move, 0, NULL,
  317. ai_move, 0, NULL,
  318. ai_move, 0, NULL,
  319. ai_move, 0, NULL,
  320. ai_move, 0, NULL,
  321. ai_move, 0, NULL,
  322. ai_move, 0, NULL,
  323. ai_move, 0, NULL
  324. };
  325. mmove_t floater_move_death = {FRAME_death01, FRAME_death13, floater_frames_death, floater_dead};
  326. mframe_t floater_frames_pain1 [] =
  327. {
  328. ai_move, 0, NULL,
  329. ai_move, 0, NULL,
  330. ai_move, 0, NULL,
  331. ai_move, 0, NULL,
  332. ai_move, 0, NULL,
  333. ai_move, 0, NULL,
  334. ai_move, 0, NULL
  335. };
  336. mmove_t floater_move_pain1 = {FRAME_pain101, FRAME_pain107, floater_frames_pain1, floater_run};
  337. mframe_t floater_frames_pain2 [] =
  338. {
  339. ai_move, 0, NULL,
  340. ai_move, 0, NULL,
  341. ai_move, 0, NULL,
  342. ai_move, 0, NULL,
  343. ai_move, 0, NULL,
  344. ai_move, 0, NULL,
  345. ai_move, 0, NULL,
  346. ai_move, 0, NULL
  347. };
  348. mmove_t floater_move_pain2 = {FRAME_pain201, FRAME_pain208, floater_frames_pain2, floater_run};
  349. mframe_t floater_frames_pain3 [] =
  350. {
  351. ai_move, 0, NULL,
  352. ai_move, 0, NULL,
  353. ai_move, 0, NULL,
  354. ai_move, 0, NULL,
  355. ai_move, 0, NULL,
  356. ai_move, 0, NULL,
  357. ai_move, 0, NULL,
  358. ai_move, 0, NULL,
  359. ai_move, 0, NULL,
  360. ai_move, 0, NULL,
  361. ai_move, 0, NULL,
  362. ai_move, 0, NULL
  363. };
  364. mmove_t floater_move_pain3 = {FRAME_pain301, FRAME_pain312, floater_frames_pain3, floater_run};
  365. mframe_t floater_frames_walk [] =
  366. {
  367. ai_walk, 5, NULL,
  368. ai_walk, 5, NULL,
  369. ai_walk, 5, NULL,
  370. ai_walk, 5, NULL,
  371. ai_walk, 5, NULL,
  372. ai_walk, 5, NULL,
  373. ai_walk, 5, NULL,
  374. ai_walk, 5, NULL,
  375. ai_walk, 5, NULL,
  376. ai_walk, 5, NULL,
  377. ai_walk, 5, NULL,
  378. ai_walk, 5, NULL,
  379. ai_walk, 5, NULL,
  380. ai_walk, 5, NULL,
  381. ai_walk, 5, NULL,
  382. ai_walk, 5, NULL,
  383. ai_walk, 5, NULL,
  384. ai_walk, 5, NULL,
  385. ai_walk, 5, NULL,
  386. ai_walk, 5, NULL,
  387. ai_walk, 5, NULL,
  388. ai_walk, 5, NULL,
  389. ai_walk, 5, NULL,
  390. ai_walk, 5, NULL,
  391. ai_walk, 5, NULL,
  392. ai_walk, 5, NULL,
  393. ai_walk, 5, NULL,
  394. ai_walk, 5, NULL,
  395. ai_walk, 5, NULL,
  396. ai_walk, 5, NULL,
  397. ai_walk, 5, NULL,
  398. ai_walk, 5, NULL,
  399. ai_walk, 5, NULL,
  400. ai_walk, 5, NULL,
  401. ai_walk, 5, NULL,
  402. ai_walk, 5, NULL,
  403. ai_walk, 5, NULL,
  404. ai_walk, 5, NULL,
  405. ai_walk, 5, NULL,
  406. ai_walk, 5, NULL,
  407. ai_walk, 5, NULL,
  408. ai_walk, 5, NULL,
  409. ai_walk, 5, NULL,
  410. ai_walk, 5, NULL,
  411. ai_walk, 5, NULL,
  412. ai_walk, 5, NULL,
  413. ai_walk, 5, NULL,
  414. ai_walk, 5, NULL,
  415. ai_walk, 5, NULL,
  416. ai_walk, 5, NULL,
  417. ai_walk, 5, NULL,
  418. ai_walk, 5, NULL
  419. };
  420. mmove_t floater_move_walk = {FRAME_stand101, FRAME_stand152, floater_frames_walk, NULL};
  421. mframe_t floater_frames_run [] =
  422. {
  423. ai_run, 13, NULL,
  424. ai_run, 13, NULL,
  425. ai_run, 13, NULL,
  426. ai_run, 13, NULL,
  427. ai_run, 13, NULL,
  428. ai_run, 13, NULL,
  429. ai_run, 13, NULL,
  430. ai_run, 13, NULL,
  431. ai_run, 13, NULL,
  432. ai_run, 13, NULL,
  433. ai_run, 13, NULL,
  434. ai_run, 13, NULL,
  435. ai_run, 13, NULL,
  436. ai_run, 13, NULL,
  437. ai_run, 13, NULL,
  438. ai_run, 13, NULL,
  439. ai_run, 13, NULL,
  440. ai_run, 13, NULL,
  441. ai_run, 13, NULL,
  442. ai_run, 13, NULL,
  443. ai_run, 13, NULL,
  444. ai_run, 13, NULL,
  445. ai_run, 13, NULL,
  446. ai_run, 13, NULL,
  447. ai_run, 13, NULL,
  448. ai_run, 13, NULL,
  449. ai_run, 13, NULL,
  450. ai_run, 13, NULL,
  451. ai_run, 13, NULL,
  452. ai_run, 13, NULL,
  453. ai_run, 13, NULL,
  454. ai_run, 13, NULL,
  455. ai_run, 13, NULL,
  456. ai_run, 13, NULL,
  457. ai_run, 13, NULL,
  458. ai_run, 13, NULL,
  459. ai_run, 13, NULL,
  460. ai_run, 13, NULL,
  461. ai_run, 13, NULL,
  462. ai_run, 13, NULL,
  463. ai_run, 13, NULL,
  464. ai_run, 13, NULL,
  465. ai_run, 13, NULL,
  466. ai_run, 13, NULL,
  467. ai_run, 13, NULL,
  468. ai_run, 13, NULL,
  469. ai_run, 13, NULL,
  470. ai_run, 13, NULL,
  471. ai_run, 13, NULL,
  472. ai_run, 13, NULL,
  473. ai_run, 13, NULL,
  474. ai_run, 13, NULL
  475. };
  476. mmove_t floater_move_run = {FRAME_stand101, FRAME_stand152, floater_frames_run, NULL};
  477. void floater_run (edict_t *self)
  478. {
  479. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  480. self->monsterinfo.currentmove = &floater_move_stand1;
  481. else
  482. self->monsterinfo.currentmove = &floater_move_run;
  483. }
  484. void floater_walk (edict_t *self)
  485. {
  486. self->monsterinfo.currentmove = &floater_move_walk;
  487. }
  488. void floater_wham (edict_t *self)
  489. {
  490. static vec3_t aim = {MELEE_DISTANCE, 0, 0};
  491. gi.sound (self, CHAN_WEAPON, sound_attack3, 1, ATTN_NORM, 0);
  492. fire_hit (self, aim, 5 + rand() % 6, -50);
  493. }
  494. void floater_zap (edict_t *self)
  495. {
  496. vec3_t forward, right;
  497. vec3_t origin;
  498. vec3_t dir;
  499. vec3_t offset;
  500. VectorSubtract (self->enemy->s.origin, self->s.origin, dir);
  501. AngleVectors (self->s.angles, forward, right, NULL);
  502. //FIXME use a flash and replace these two lines with the commented one
  503. VectorSet (offset, 18.5, -0.9, 10);
  504. G_ProjectSource (self->s.origin, offset, forward, right, origin);
  505. // G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, origin);
  506. gi.sound (self, CHAN_WEAPON, sound_attack2, 1, ATTN_NORM, 0);
  507. //FIXME use the flash, Luke
  508. gi.WriteByte (svc_temp_entity);
  509. gi.WriteByte (TE_SPLASH);
  510. gi.WriteByte (32);
  511. gi.WritePosition (origin);
  512. gi.WriteDir (dir);
  513. gi.WriteByte (1); //sparks
  514. gi.multicast (origin, MULTICAST_PVS);
  515. T_Damage (self->enemy, self, self, dir, self->enemy->s.origin, vec3_origin, 5 + rand() % 6, -10, DAMAGE_ENERGY, MOD_UNKNOWN);
  516. }
  517. void floater_attack(edict_t *self)
  518. {
  519. float chance;
  520. /* if (random() <= 0.5)
  521. self->monsterinfo.currentmove = &flyer_move_attack1;
  522. else */
  523. // 0% chance of circle in easy
  524. // 50% chance in normal
  525. // 75% chance in hard
  526. // 86.67% chance in nightmare
  527. if (!skill->value)
  528. chance = 0;
  529. else
  530. chance = 1.0 - (0.5/(float)(skill->value));
  531. if (random() > chance)
  532. {
  533. self->monsterinfo.attack_state = AS_STRAIGHT;
  534. self->monsterinfo.currentmove = &floater_move_attack1;
  535. }
  536. else // circle strafe
  537. {
  538. if (random () <= 0.5) // switch directions
  539. self->monsterinfo.lefty = 1 - self->monsterinfo.lefty;
  540. self->monsterinfo.attack_state = AS_SLIDING;
  541. self->monsterinfo.currentmove = &floater_move_attack1a;
  542. }
  543. }
  544. void floater_melee(edict_t *self)
  545. {
  546. if (random() < 0.5)
  547. self->monsterinfo.currentmove = &floater_move_attack3;
  548. else
  549. self->monsterinfo.currentmove = &floater_move_attack2;
  550. }
  551. void floater_pain (edict_t *self, edict_t *other, float kick, int damage)
  552. {
  553. int n;
  554. if (self->health < (self->max_health / 2))
  555. self->s.skinnum = 1;
  556. if (level.time < self->pain_debounce_time)
  557. return;
  558. self->pain_debounce_time = level.time + 3;
  559. if (skill->value == 3)
  560. return; // no pain anims in nightmare
  561. n = (rand() + 1) % 3;
  562. if (n == 0)
  563. {
  564. gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
  565. self->monsterinfo.currentmove = &floater_move_pain1;
  566. }
  567. else
  568. {
  569. gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
  570. self->monsterinfo.currentmove = &floater_move_pain2;
  571. }
  572. }
  573. void floater_dead (edict_t *self)
  574. {
  575. VectorSet (self->mins, -16, -16, -24);
  576. VectorSet (self->maxs, 16, 16, -8);
  577. self->movetype = MOVETYPE_TOSS;
  578. self->svflags |= SVF_DEADMONSTER;
  579. self->nextthink = 0;
  580. gi.linkentity (self);
  581. }
  582. void floater_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  583. {
  584. gi.sound (self, CHAN_VOICE, sound_death1, 1, ATTN_NORM, 0);
  585. BecomeExplosion1(self);
  586. }
  587. //===========
  588. //PGM
  589. qboolean floater_blocked (edict_t *self, float dist)
  590. {
  591. if(blocked_checkshot (self, 0.25 + (0.05 * skill->value) ))
  592. return true;
  593. return false;
  594. }
  595. //PGM
  596. //===========
  597. /*QUAKED monster_floater (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  598. */
  599. void SP_monster_floater (edict_t *self)
  600. {
  601. if (deathmatch->value)
  602. {
  603. G_FreeEdict (self);
  604. return;
  605. }
  606. sound_attack2 = gi.soundindex ("floater/fltatck2.wav");
  607. sound_attack3 = gi.soundindex ("floater/fltatck3.wav");
  608. sound_death1 = gi.soundindex ("floater/fltdeth1.wav");
  609. sound_idle = gi.soundindex ("floater/fltidle1.wav");
  610. sound_pain1 = gi.soundindex ("floater/fltpain1.wav");
  611. sound_pain2 = gi.soundindex ("floater/fltpain2.wav");
  612. sound_sight = gi.soundindex ("floater/fltsght1.wav");
  613. gi.soundindex ("floater/fltatck1.wav");
  614. self->s.sound = gi.soundindex ("floater/fltsrch1.wav");
  615. self->movetype = MOVETYPE_STEP;
  616. self->solid = SOLID_BBOX;
  617. self->s.modelindex = gi.modelindex ("models/monsters/float/tris.md2");
  618. VectorSet (self->mins, -24, -24, -24);
  619. VectorSet (self->maxs, 24, 24, 32);
  620. self->health = 200;
  621. self->gib_health = -80;
  622. self->mass = 300;
  623. self->pain = floater_pain;
  624. self->die = floater_die;
  625. self->monsterinfo.stand = floater_stand;
  626. self->monsterinfo.walk = floater_walk;
  627. self->monsterinfo.run = floater_run;
  628. // self->monsterinfo.dodge = floater_dodge;
  629. self->monsterinfo.attack = floater_attack;
  630. self->monsterinfo.melee = floater_melee;
  631. self->monsterinfo.sight = floater_sight;
  632. self->monsterinfo.idle = floater_idle;
  633. self->monsterinfo.blocked = floater_blocked; // PGM
  634. gi.linkentity (self);
  635. if (random() <= 0.5)
  636. self->monsterinfo.currentmove = &floater_move_stand1;
  637. else
  638. self->monsterinfo.currentmove = &floater_move_stand2;
  639. self->monsterinfo.scale = MODEL_SCALE;
  640. flymonster_start (self);
  641. }