m_boss2.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /*
  16. ==============================================================================
  17. boss2
  18. ==============================================================================
  19. */
  20. #include "g_local.h"
  21. #include "m_boss2.h"
  22. void BossExplode (edict_t *self);
  23. qboolean infront (edict_t *self, edict_t *other);
  24. static int sound_pain1;
  25. static int sound_pain2;
  26. static int sound_pain3;
  27. static int sound_death;
  28. static int sound_search1;
  29. void boss2_search (edict_t *self)
  30. {
  31. if (random() < 0.5)
  32. gi.sound (self, CHAN_VOICE, sound_search1, 1, ATTN_NONE, 0);
  33. }
  34. void boss2_run (edict_t *self);
  35. void boss2_stand (edict_t *self);
  36. void boss2_dead (edict_t *self);
  37. void boss2_attack (edict_t *self);
  38. void boss2_attack_mg (edict_t *self);
  39. void boss2_reattack_mg (edict_t *self);
  40. void boss2_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point);
  41. void Boss2Rocket (edict_t *self)
  42. {
  43. vec3_t forward, right;
  44. vec3_t start;
  45. vec3_t dir;
  46. vec3_t vec;
  47. AngleVectors (self->s.angles, forward, right, NULL);
  48. //1
  49. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_BOSS2_ROCKET_1], forward, right, start);
  50. VectorCopy (self->enemy->s.origin, vec);
  51. vec[2] += self->enemy->viewheight;
  52. VectorSubtract (vec, start, dir);
  53. VectorNormalize (dir);
  54. monster_fire_rocket (self, start, dir, 50, 500, MZ2_BOSS2_ROCKET_1);
  55. //2
  56. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_BOSS2_ROCKET_2], forward, right, start);
  57. VectorCopy (self->enemy->s.origin, vec);
  58. vec[2] += self->enemy->viewheight;
  59. VectorSubtract (vec, start, dir);
  60. VectorNormalize (dir);
  61. monster_fire_rocket (self, start, dir, 50, 500, MZ2_BOSS2_ROCKET_2);
  62. //3
  63. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_BOSS2_ROCKET_3], forward, right, start);
  64. VectorCopy (self->enemy->s.origin, vec);
  65. vec[2] += self->enemy->viewheight;
  66. VectorSubtract (vec, start, dir);
  67. VectorNormalize (dir);
  68. monster_fire_rocket (self, start, dir, 50, 500, MZ2_BOSS2_ROCKET_3);
  69. //4
  70. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_BOSS2_ROCKET_4], forward, right, start);
  71. VectorCopy (self->enemy->s.origin, vec);
  72. vec[2] += self->enemy->viewheight;
  73. VectorSubtract (vec, start, dir);
  74. VectorNormalize (dir);
  75. monster_fire_rocket (self, start, dir, 50, 500, MZ2_BOSS2_ROCKET_4);
  76. }
  77. void boss2_firebullet_right (edict_t *self)
  78. {
  79. vec3_t forward, right, target;
  80. vec3_t start;
  81. AngleVectors (self->s.angles, forward, right, NULL);
  82. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_BOSS2_MACHINEGUN_R1], forward, right, start);
  83. VectorMA (self->enemy->s.origin, -0.2, self->enemy->velocity, target);
  84. target[2] += self->enemy->viewheight;
  85. VectorSubtract (target, start, forward);
  86. VectorNormalize (forward);
  87. monster_fire_bullet (self, start, forward, 6, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MZ2_BOSS2_MACHINEGUN_R1);
  88. }
  89. void boss2_firebullet_left (edict_t *self)
  90. {
  91. vec3_t forward, right, target;
  92. vec3_t start;
  93. AngleVectors (self->s.angles, forward, right, NULL);
  94. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_BOSS2_MACHINEGUN_L1], forward, right, start);
  95. VectorMA (self->enemy->s.origin, -0.2, self->enemy->velocity, target);
  96. target[2] += self->enemy->viewheight;
  97. VectorSubtract (target, start, forward);
  98. VectorNormalize (forward);
  99. monster_fire_bullet (self, start, forward, 6, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MZ2_BOSS2_MACHINEGUN_L1);
  100. }
  101. void Boss2MachineGun (edict_t *self)
  102. {
  103. /* vec3_t forward, right;
  104. vec3_t start;
  105. vec3_t dir;
  106. vec3_t vec;
  107. int flash_number;
  108. AngleVectors (self->s.angles, forward, right, NULL);
  109. flash_number = MZ2_BOSS2_MACHINEGUN_1 + (self->s.frame - FRAME_attack10);
  110. G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
  111. VectorCopy (self->enemy->s.origin, vec);
  112. vec[2] += self->enemy->viewheight;
  113. VectorSubtract (vec, start, dir);
  114. VectorNormalize (dir);
  115. monster_fire_bullet (self, start, dir, 3, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flash_number);
  116. */
  117. boss2_firebullet_left(self);
  118. boss2_firebullet_right(self);
  119. }
  120. mframe_t boss2_frames_stand [] =
  121. {
  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. };
  144. mmove_t boss2_move_stand = {FRAME_stand30, FRAME_stand50, boss2_frames_stand, NULL};
  145. mframe_t boss2_frames_fidget [] =
  146. {
  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. ai_stand, 0, NULL,
  162. ai_stand, 0, NULL,
  163. ai_stand, 0, NULL,
  164. ai_stand, 0, NULL,
  165. ai_stand, 0, NULL,
  166. ai_stand, 0, NULL,
  167. ai_stand, 0, NULL,
  168. ai_stand, 0, NULL,
  169. ai_stand, 0, NULL,
  170. ai_stand, 0, NULL,
  171. ai_stand, 0, NULL,
  172. ai_stand, 0, NULL,
  173. ai_stand, 0, NULL,
  174. ai_stand, 0, NULL,
  175. ai_stand, 0, NULL,
  176. ai_stand, 0, NULL
  177. };
  178. mmove_t boss2_move_fidget = {FRAME_stand1, FRAME_stand30, boss2_frames_fidget, NULL};
  179. mframe_t boss2_frames_walk [] =
  180. {
  181. ai_walk, 8, NULL,
  182. ai_walk, 8, NULL,
  183. ai_walk, 8, NULL,
  184. ai_walk, 8, NULL,
  185. ai_walk, 8, NULL,
  186. ai_walk, 8, NULL,
  187. ai_walk, 8, NULL,
  188. ai_walk, 8, NULL,
  189. ai_walk, 8, NULL,
  190. ai_walk, 8, NULL,
  191. ai_walk, 8, NULL,
  192. ai_walk, 8, NULL,
  193. ai_walk, 8, NULL,
  194. ai_walk, 8, NULL,
  195. ai_walk, 8, NULL,
  196. ai_walk, 8, NULL,
  197. ai_walk, 8, NULL,
  198. ai_walk, 8, NULL,
  199. ai_walk, 8, NULL,
  200. ai_walk, 8, NULL
  201. };
  202. mmove_t boss2_move_walk = {FRAME_walk1, FRAME_walk20, boss2_frames_walk, NULL};
  203. mframe_t boss2_frames_run [] =
  204. {
  205. ai_run, 8, NULL,
  206. ai_run, 8, NULL,
  207. ai_run, 8, NULL,
  208. ai_run, 8, NULL,
  209. ai_run, 8, NULL,
  210. ai_run, 8, NULL,
  211. ai_run, 8, NULL,
  212. ai_run, 8, NULL,
  213. ai_run, 8, NULL,
  214. ai_run, 8, NULL,
  215. ai_run, 8, NULL,
  216. ai_run, 8, NULL,
  217. ai_run, 8, NULL,
  218. ai_run, 8, NULL,
  219. ai_run, 8, NULL,
  220. ai_run, 8, NULL,
  221. ai_run, 8, NULL,
  222. ai_run, 8, NULL,
  223. ai_run, 8, NULL,
  224. ai_run, 8, NULL
  225. };
  226. mmove_t boss2_move_run = {FRAME_walk1, FRAME_walk20, boss2_frames_run, NULL};
  227. mframe_t boss2_frames_attack_pre_mg [] =
  228. {
  229. ai_charge, 1, NULL,
  230. ai_charge, 1, NULL,
  231. ai_charge, 1, NULL,
  232. ai_charge, 1, NULL,
  233. ai_charge, 1, NULL,
  234. ai_charge, 1, NULL,
  235. ai_charge, 1, NULL,
  236. ai_charge, 1, NULL,
  237. ai_charge, 1, boss2_attack_mg
  238. };
  239. mmove_t boss2_move_attack_pre_mg = {FRAME_attack1, FRAME_attack9, boss2_frames_attack_pre_mg, NULL};
  240. // Loop this
  241. mframe_t boss2_frames_attack_mg [] =
  242. {
  243. ai_charge, 1, Boss2MachineGun,
  244. ai_charge, 1, Boss2MachineGun,
  245. ai_charge, 1, Boss2MachineGun,
  246. ai_charge, 1, Boss2MachineGun,
  247. ai_charge, 1, Boss2MachineGun,
  248. ai_charge, 1, boss2_reattack_mg
  249. };
  250. mmove_t boss2_move_attack_mg = {FRAME_attack10, FRAME_attack15, boss2_frames_attack_mg, NULL};
  251. mframe_t boss2_frames_attack_post_mg [] =
  252. {
  253. ai_charge, 1, NULL,
  254. ai_charge, 1, NULL,
  255. ai_charge, 1, NULL,
  256. ai_charge, 1, NULL
  257. };
  258. mmove_t boss2_move_attack_post_mg = {FRAME_attack16, FRAME_attack19, boss2_frames_attack_post_mg, boss2_run};
  259. mframe_t boss2_frames_attack_rocket [] =
  260. {
  261. ai_charge, 1, NULL,
  262. ai_charge, 1, NULL,
  263. ai_charge, 1, NULL,
  264. ai_charge, 1, NULL,
  265. ai_charge, 1, NULL,
  266. ai_charge, 1, NULL,
  267. ai_charge, 1, NULL,
  268. ai_charge, 1, NULL,
  269. ai_charge, 1, NULL,
  270. ai_charge, 1, NULL,
  271. ai_charge, 1, NULL,
  272. ai_charge, 1, NULL,
  273. ai_move, -20, Boss2Rocket,
  274. ai_charge, 1, NULL,
  275. ai_charge, 1, NULL,
  276. ai_charge, 1, NULL,
  277. ai_charge, 1, NULL,
  278. ai_charge, 1, NULL,
  279. ai_charge, 1, NULL,
  280. ai_charge, 1, NULL,
  281. ai_charge, 1, NULL
  282. };
  283. mmove_t boss2_move_attack_rocket = {FRAME_attack20, FRAME_attack40, boss2_frames_attack_rocket, boss2_run};
  284. mframe_t boss2_frames_pain_heavy [] =
  285. {
  286. ai_move, 0, NULL,
  287. ai_move, 0, NULL,
  288. ai_move, 0, NULL,
  289. ai_move, 0, NULL,
  290. ai_move, 0, NULL,
  291. ai_move, 0, NULL,
  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, NULL,
  298. ai_move, 0, NULL,
  299. ai_move, 0, NULL,
  300. ai_move, 0, NULL,
  301. ai_move, 0, NULL,
  302. ai_move, 0, NULL,
  303. ai_move, 0, NULL
  304. };
  305. mmove_t boss2_move_pain_heavy = {FRAME_pain2, FRAME_pain19, boss2_frames_pain_heavy, boss2_run};
  306. mframe_t boss2_frames_pain_light [] =
  307. {
  308. ai_move, 0, NULL,
  309. ai_move, 0, NULL,
  310. ai_move, 0, NULL,
  311. ai_move, 0, NULL
  312. };
  313. mmove_t boss2_move_pain_light = {FRAME_pain20, FRAME_pain23, boss2_frames_pain_light, boss2_run};
  314. mframe_t boss2_frames_death [] =
  315. {
  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. 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. 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. 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. ai_move, 0, NULL,
  344. ai_move, 0, NULL,
  345. ai_move, 0, NULL,
  346. ai_move, 0, NULL,
  347. ai_move, 0, NULL,
  348. ai_move, 0, NULL,
  349. ai_move, 0, NULL,
  350. ai_move, 0, NULL,
  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. ai_move, 0, NULL,
  364. ai_move, 0, BossExplode
  365. };
  366. mmove_t boss2_move_death = {FRAME_death2, FRAME_death50, boss2_frames_death, boss2_dead};
  367. void boss2_stand (edict_t *self)
  368. {
  369. self->monsterinfo.currentmove = &boss2_move_stand;
  370. }
  371. void boss2_run (edict_t *self)
  372. {
  373. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  374. self->monsterinfo.currentmove = &boss2_move_stand;
  375. else
  376. self->monsterinfo.currentmove = &boss2_move_run;
  377. }
  378. void boss2_walk (edict_t *self)
  379. {
  380. self->monsterinfo.currentmove = &boss2_move_walk;
  381. }
  382. void boss2_attack (edict_t *self)
  383. {
  384. vec3_t vec;
  385. float range;
  386. VectorSubtract (self->enemy->s.origin, self->s.origin, vec);
  387. range = VectorLength (vec);
  388. if (range <= 125)
  389. {
  390. self->monsterinfo.currentmove = &boss2_move_attack_pre_mg;
  391. }
  392. else
  393. {
  394. if (random() <= 0.6)
  395. self->monsterinfo.currentmove = &boss2_move_attack_pre_mg;
  396. else
  397. self->monsterinfo.currentmove = &boss2_move_attack_rocket;
  398. }
  399. }
  400. void boss2_attack_mg (edict_t *self)
  401. {
  402. self->monsterinfo.currentmove = &boss2_move_attack_mg;
  403. }
  404. void boss2_reattack_mg (edict_t *self)
  405. {
  406. if ( infront(self, self->enemy) )
  407. if (random() <= 0.7)
  408. self->monsterinfo.currentmove = &boss2_move_attack_mg;
  409. else
  410. self->monsterinfo.currentmove = &boss2_move_attack_post_mg;
  411. else
  412. self->monsterinfo.currentmove = &boss2_move_attack_post_mg;
  413. }
  414. void boss2_pain (edict_t *self, edict_t *other, float kick, int damage)
  415. {
  416. if (self->health < (self->max_health / 2))
  417. self->s.skinnum = 1;
  418. if (level.time < self->pain_debounce_time)
  419. return;
  420. self->pain_debounce_time = level.time + 3;
  421. // American wanted these at no attenuation
  422. if (damage < 10)
  423. {
  424. gi.sound (self, CHAN_VOICE, sound_pain3, 1, ATTN_NONE, 0);
  425. self->monsterinfo.currentmove = &boss2_move_pain_light;
  426. }
  427. else if (damage < 30)
  428. {
  429. gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NONE, 0);
  430. self->monsterinfo.currentmove = &boss2_move_pain_light;
  431. }
  432. else
  433. {
  434. gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NONE, 0);
  435. self->monsterinfo.currentmove = &boss2_move_pain_heavy;
  436. }
  437. }
  438. void boss2_dead (edict_t *self)
  439. {
  440. VectorSet (self->mins, -56, -56, 0);
  441. VectorSet (self->maxs, 56, 56, 80);
  442. self->movetype = MOVETYPE_TOSS;
  443. self->svflags |= SVF_DEADMONSTER;
  444. self->nextthink = 0;
  445. gi.linkentity (self);
  446. }
  447. void boss2_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  448. {
  449. gi.sound (self, CHAN_VOICE, sound_death, 1, ATTN_NONE, 0);
  450. self->deadflag = DEAD_DEAD;
  451. self->takedamage = DAMAGE_NO;
  452. self->count = 0;
  453. self->monsterinfo.currentmove = &boss2_move_death;
  454. #if 0
  455. int n;
  456. self->s.sound = 0;
  457. // check for gib
  458. if (self->health <= self->gib_health)
  459. {
  460. gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
  461. for (n= 0; n < 2; n++)
  462. ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
  463. for (n= 0; n < 4; n++)
  464. ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
  465. ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
  466. self->deadflag = DEAD_DEAD;
  467. return;
  468. }
  469. if (self->deadflag == DEAD_DEAD)
  470. return;
  471. self->deadflag = DEAD_DEAD;
  472. self->takedamage = DAMAGE_YES;
  473. self->monsterinfo.currentmove = &boss2_move_death;
  474. #endif
  475. }
  476. qboolean Boss2_CheckAttack (edict_t *self)
  477. {
  478. vec3_t spot1, spot2;
  479. vec3_t temp;
  480. float chance;
  481. trace_t tr;
  482. qboolean enemy_infront;
  483. int enemy_range;
  484. float enemy_yaw;
  485. if (self->enemy->health > 0)
  486. {
  487. // see if any entities are in the way of the shot
  488. VectorCopy (self->s.origin, spot1);
  489. spot1[2] += self->viewheight;
  490. VectorCopy (self->enemy->s.origin, spot2);
  491. spot2[2] += self->enemy->viewheight;
  492. tr = gi.trace (spot1, NULL, NULL, spot2, self, CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_SLIME|CONTENTS_LAVA);
  493. // do we have a clear shot?
  494. if (tr.ent != self->enemy)
  495. return false;
  496. }
  497. enemy_infront = infront(self, self->enemy);
  498. enemy_range = range(self, self->enemy);
  499. VectorSubtract (self->enemy->s.origin, self->s.origin, temp);
  500. enemy_yaw = vectoyaw(temp);
  501. self->ideal_yaw = enemy_yaw;
  502. // melee attack
  503. if (enemy_range == RANGE_MELEE)
  504. {
  505. if (self->monsterinfo.melee)
  506. self->monsterinfo.attack_state = AS_MELEE;
  507. else
  508. self->monsterinfo.attack_state = AS_MISSILE;
  509. return true;
  510. }
  511. // missile attack
  512. if (!self->monsterinfo.attack)
  513. return false;
  514. if (level.time < self->monsterinfo.attack_finished)
  515. return false;
  516. if (enemy_range == RANGE_FAR)
  517. return false;
  518. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  519. {
  520. chance = 0.4;
  521. }
  522. else if (enemy_range == RANGE_MELEE)
  523. {
  524. chance = 0.8;
  525. }
  526. else if (enemy_range == RANGE_NEAR)
  527. {
  528. chance = 0.8;
  529. }
  530. else if (enemy_range == RANGE_MID)
  531. {
  532. chance = 0.8;
  533. }
  534. else
  535. {
  536. return false;
  537. }
  538. if (random () < chance)
  539. {
  540. self->monsterinfo.attack_state = AS_MISSILE;
  541. self->monsterinfo.attack_finished = level.time + 2*random();
  542. return true;
  543. }
  544. if (self->flags & FL_FLY)
  545. {
  546. if (random() < 0.3)
  547. self->monsterinfo.attack_state = AS_SLIDING;
  548. else
  549. self->monsterinfo.attack_state = AS_STRAIGHT;
  550. }
  551. return false;
  552. }
  553. /*QUAKED monster_boss2 (1 .5 0) (-56 -56 0) (56 56 80) Ambush Trigger_Spawn Sight
  554. */
  555. void SP_monster_boss2 (edict_t *self)
  556. {
  557. if (deathmatch->value)
  558. {
  559. G_FreeEdict (self);
  560. return;
  561. }
  562. sound_pain1 = gi.soundindex ("bosshovr/bhvpain1.wav");
  563. sound_pain2 = gi.soundindex ("bosshovr/bhvpain2.wav");
  564. sound_pain3 = gi.soundindex ("bosshovr/bhvpain3.wav");
  565. sound_death = gi.soundindex ("bosshovr/bhvdeth1.wav");
  566. sound_search1 = gi.soundindex ("bosshovr/bhvunqv1.wav");
  567. self->s.sound = gi.soundindex ("bosshovr/bhvengn1.wav");
  568. self->movetype = MOVETYPE_STEP;
  569. self->solid = SOLID_BBOX;
  570. self->s.modelindex = gi.modelindex ("models/monsters/boss2/tris.md2");
  571. VectorSet (self->mins, -56, -56, 0);
  572. VectorSet (self->maxs, 56, 56, 80);
  573. self->health = 2000;
  574. self->gib_health = -200;
  575. self->mass = 1000;
  576. self->flags |= FL_IMMUNE_LASER;
  577. self->pain = boss2_pain;
  578. self->die = boss2_die;
  579. self->monsterinfo.stand = boss2_stand;
  580. self->monsterinfo.walk = boss2_walk;
  581. self->monsterinfo.run = boss2_run;
  582. self->monsterinfo.attack = boss2_attack;
  583. self->monsterinfo.search = boss2_search;
  584. self->monsterinfo.checkattack = Boss2_CheckAttack;
  585. gi.linkentity (self);
  586. self->monsterinfo.currentmove = &boss2_move_stand;
  587. self->monsterinfo.scale = MODEL_SCALE;
  588. flymonster_start (self);
  589. }