m_rogue_carrier.cpp 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. /*
  4. ==============================================================================
  5. carrier
  6. ==============================================================================
  7. */
  8. // self->timestamp used for frame calculations in grenade & spawn code
  9. // self->monsterinfo.fire_wait used to prevent rapid refire of rocket launcher
  10. #include "../g_local.h"
  11. #include "m_rogue_carrier.h"
  12. #include "../m_flash.h"
  13. // nb: specifying flyer multiple times so it has a higher chance
  14. constexpr const char *default_reinforcements = "monster_flyer 1;monster_flyer 1;monster_flyer 1;monster_kamikaze 1";
  15. constexpr int32_t default_monster_slots_base = 3;
  16. constexpr gtime_t CARRIER_ROCKET_TIME = 2_sec; // number of seconds between rocket shots
  17. constexpr int32_t CARRIER_ROCKET_SPEED = 750;
  18. constexpr gtime_t RAIL_FIRE_TIME = 3_sec;
  19. bool infront(edict_t *self, edict_t *other);
  20. bool inback(edict_t *self, edict_t *other);
  21. bool below(edict_t *self, edict_t *other);
  22. void drawbbox(edict_t *self);
  23. void ED_CallSpawn(edict_t *ent);
  24. static cached_soundindex sound_pain1;
  25. static cached_soundindex sound_pain2;
  26. static cached_soundindex sound_pain3;
  27. static cached_soundindex sound_death;
  28. static cached_soundindex sound_sight;
  29. static cached_soundindex sound_rail;
  30. static cached_soundindex sound_spawn;
  31. static cached_soundindex sound_cg_down, sound_cg_loop, sound_cg_up;
  32. float orig_yaw_speed;
  33. void M_SetupReinforcements(const char *reinforcements, reinforcement_list_t &list);
  34. std::array<uint8_t, MAX_REINFORCEMENTS> M_PickReinforcements(edict_t *self, int32_t &num_chosen, int32_t max_slots);
  35. extern const mmove_t flyer_move_attack2, flyer_move_attack3, flyer_move_kamikaze;
  36. void carrier_run(edict_t *self);
  37. void carrier_dead(edict_t *self);
  38. void carrier_attack_mg(edict_t *self);
  39. void carrier_reattack_mg(edict_t *self);
  40. void carrier_attack_gren(edict_t *self);
  41. void carrier_reattack_gren(edict_t *self);
  42. void carrier_start_spawn(edict_t *self);
  43. void carrier_spawn_check(edict_t *self);
  44. void carrier_prep_spawn(edict_t *self);
  45. void CarrierMachineGunHold(edict_t *self);
  46. void CarrierRocket(edict_t *self);
  47. MONSTERINFO_SIGHT(carrier_sight) (edict_t *self, edict_t *other) -> void
  48. {
  49. gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
  50. }
  51. //
  52. // this is the smarts for the rocket launcher in coop
  53. //
  54. // if there is a player behind/below the carrier, and we can shoot, and we can trace a LOS to them ..
  55. // pick one of the group, and let it rip
  56. void CarrierCoopCheck(edict_t *self)
  57. {
  58. // no more than 8 players in coop, so..
  59. std::array<edict_t *, MAX_SPLIT_PLAYERS> targets;
  60. uint32_t num_targets = 0;
  61. int32_t target;
  62. edict_t *ent;
  63. trace_t tr;
  64. // if we're not in coop, this is a noop
  65. // [Paril-KEX] might as well let this work in SP too, so he fires it
  66. // if you get below him
  67. //if (!coop->integer)
  68. // return;
  69. // if we are, and we have recently fired, bail
  70. if (self->monsterinfo.fire_wait > level.time)
  71. return;
  72. targets = {};
  73. // cycle through players
  74. for (uint32_t player = 1; player <= game.maxclients; player++)
  75. {
  76. ent = &g_edicts[player];
  77. if (!ent->inuse)
  78. continue;
  79. if (!ent->client)
  80. continue;
  81. if (inback(self, ent) || below(self, ent))
  82. {
  83. tr = gi.traceline(self->s.origin, ent->s.origin, self, MASK_SOLID);
  84. if (tr.fraction == 1.0f)
  85. targets[num_targets++] = ent;
  86. }
  87. }
  88. if (!num_targets)
  89. return;
  90. // get a number from 0 to (num_targets-1)
  91. target = irandom(num_targets);
  92. // make sure to prevent rapid fire rockets
  93. self->monsterinfo.fire_wait = level.time + CARRIER_ROCKET_TIME;
  94. // save off the real enemy
  95. ent = self->enemy;
  96. // set the new guy as temporary enemy
  97. self->enemy = targets[target];
  98. CarrierRocket(self);
  99. // put the real enemy back
  100. self->enemy = ent;
  101. // we're done
  102. return;
  103. }
  104. void CarrierGrenade(edict_t *self)
  105. {
  106. vec3_t start;
  107. vec3_t forward, right, up;
  108. vec3_t aim;
  109. monster_muzzleflash_id_t flash_number;
  110. float direction; // from lower left to upper right, or lower right to upper left
  111. float spreadR, spreadU;
  112. int mytime;
  113. CarrierCoopCheck(self);
  114. if (!self->enemy)
  115. return;
  116. if (frandom() < 0.5f)
  117. direction = -1.0f;
  118. else
  119. direction = 1.0f;
  120. mytime = (int) ((level.time - self->timestamp) / 0.4f).seconds();
  121. if (mytime == 0)
  122. {
  123. spreadR = 0.15f * direction;
  124. spreadU = 0.1f - 0.1f * direction;
  125. }
  126. else if (mytime == 1)
  127. {
  128. spreadR = 0;
  129. spreadU = 0.1f;
  130. }
  131. else if (mytime == 2)
  132. {
  133. spreadR = -0.15f * direction;
  134. spreadU = 0.1f - -0.1f * direction;
  135. }
  136. else if (mytime == 3)
  137. {
  138. spreadR = 0;
  139. spreadU = 0.1f;
  140. }
  141. else
  142. {
  143. // error, shoot straight
  144. spreadR = 0;
  145. spreadU = 0;
  146. }
  147. AngleVectors(self->s.angles, forward, right, up);
  148. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_GRENADE], forward, right);
  149. aim = self->enemy->s.origin - start;
  150. aim.normalize();
  151. aim += (right * spreadR);
  152. aim += (up * spreadU);
  153. if (aim[2] > 0.15f)
  154. aim[2] = 0.15f;
  155. else if (aim[2] < -0.5f)
  156. aim[2] = -0.5f;
  157. flash_number = MZ2_GUNNER_GRENADE_1;
  158. monster_fire_grenade(self, start, aim, 50, 600, flash_number, (crandom_open() * 10.0f), 200.f + (crandom_open() * 10.0f));
  159. }
  160. void CarrierPredictiveRocket(edict_t *self)
  161. {
  162. vec3_t forward, right;
  163. vec3_t start;
  164. vec3_t dir;
  165. AngleVectors(self->s.angles, forward, right, nullptr);
  166. // 1
  167. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_1], forward, right);
  168. PredictAim(self, self->enemy, start, CARRIER_ROCKET_SPEED, false, -0.3f, &dir, nullptr);
  169. monster_fire_rocket(self, start, dir, 50, CARRIER_ROCKET_SPEED, MZ2_CARRIER_ROCKET_1);
  170. // 2
  171. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_2], forward, right);
  172. PredictAim(self, self->enemy, start, CARRIER_ROCKET_SPEED, false, -0.15f, &dir, nullptr);
  173. monster_fire_rocket(self, start, dir, 50, CARRIER_ROCKET_SPEED, MZ2_CARRIER_ROCKET_2);
  174. // 3
  175. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_3], forward, right);
  176. PredictAim(self, self->enemy, start, CARRIER_ROCKET_SPEED, false, 0, &dir, nullptr);
  177. monster_fire_rocket(self, start, dir, 50, CARRIER_ROCKET_SPEED, MZ2_CARRIER_ROCKET_3);
  178. // 4
  179. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_4], forward, right);
  180. PredictAim(self, self->enemy, start, CARRIER_ROCKET_SPEED, false, 0.15f, &dir, nullptr);
  181. monster_fire_rocket(self, start, dir, 50, CARRIER_ROCKET_SPEED, MZ2_CARRIER_ROCKET_4);
  182. }
  183. void CarrierRocket(edict_t *self)
  184. {
  185. vec3_t forward, right;
  186. vec3_t start;
  187. vec3_t dir;
  188. vec3_t vec;
  189. if (self->enemy)
  190. {
  191. if (self->enemy->client && frandom() < 0.5f)
  192. {
  193. CarrierPredictiveRocket(self);
  194. return;
  195. }
  196. }
  197. else
  198. return;
  199. AngleVectors(self->s.angles, forward, right, nullptr);
  200. // 1
  201. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_1], forward, right);
  202. vec = self->enemy->s.origin;
  203. vec[2] -= 15;
  204. dir = vec - start;
  205. dir.normalize();
  206. dir += (right * 0.4f);
  207. dir.normalize();
  208. monster_fire_rocket(self, start, dir, 50, 500, MZ2_CARRIER_ROCKET_1);
  209. // 2
  210. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_2], forward, right);
  211. vec = self->enemy->s.origin;
  212. dir = vec - start;
  213. dir.normalize();
  214. dir += (right * 0.025f);
  215. dir.normalize();
  216. monster_fire_rocket(self, start, dir, 50, 500, MZ2_CARRIER_ROCKET_2);
  217. // 3
  218. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_3], forward, right);
  219. vec = self->enemy->s.origin;
  220. dir = vec - start;
  221. dir.normalize();
  222. dir += (right * -0.025f);
  223. dir.normalize();
  224. monster_fire_rocket(self, start, dir, 50, 500, MZ2_CARRIER_ROCKET_3);
  225. // 4
  226. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_ROCKET_4], forward, right);
  227. vec = self->enemy->s.origin;
  228. vec[2] -= 15;
  229. dir = vec - start;
  230. dir.normalize();
  231. dir += (right * -0.4f);
  232. dir.normalize();
  233. monster_fire_rocket(self, start, dir, 50, 500, MZ2_CARRIER_ROCKET_4);
  234. }
  235. void carrier_firebullet_right(edict_t *self)
  236. {
  237. vec3_t forward, right, start;
  238. monster_muzzleflash_id_t flashnum;
  239. // if we're in manual steering mode, it means we're leaning down .. use the lower shot
  240. if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
  241. flashnum = MZ2_CARRIER_MACHINEGUN_R2;
  242. else
  243. flashnum = MZ2_CARRIER_MACHINEGUN_R1;
  244. AngleVectors(self->s.angles, forward, right, nullptr);
  245. start = M_ProjectFlashSource(self, monster_flash_offset[flashnum], forward, right);
  246. PredictAim(self, self->enemy, start, 0, true, -0.3f, &forward, nullptr);
  247. monster_fire_bullet(self, start, forward, 6, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flashnum);
  248. }
  249. void carrier_firebullet_left(edict_t *self)
  250. {
  251. vec3_t forward, right, start;
  252. monster_muzzleflash_id_t flashnum;
  253. // if we're in manual steering mode, it means we're leaning down .. use the lower shot
  254. if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
  255. flashnum = MZ2_CARRIER_MACHINEGUN_L2;
  256. else
  257. flashnum = MZ2_CARRIER_MACHINEGUN_L1;
  258. AngleVectors(self->s.angles, forward, right, nullptr);
  259. start = M_ProjectFlashSource(self, monster_flash_offset[flashnum], forward, right);
  260. PredictAim(self, self->enemy, start, 0, true, -0.3f, &forward, nullptr);
  261. monster_fire_bullet(self, start, forward, 6, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flashnum);
  262. }
  263. void CarrierMachineGun(edict_t *self)
  264. {
  265. CarrierCoopCheck(self);
  266. if (self->enemy)
  267. carrier_firebullet_left(self);
  268. if (self->enemy)
  269. carrier_firebullet_right(self);
  270. }
  271. void CarrierSpawn(edict_t *self)
  272. {
  273. vec3_t f, r, offset, startpoint, spawnpoint;
  274. edict_t *ent;
  275. // offset = { 105, 0, -30 }; // real distance needed is (sqrt (56*56*2) + sqrt(16*16*2)) or 101.8
  276. offset = { 105, 0, -58 }; // real distance needed is (sqrt (56*56*2) + sqrt(16*16*2)) or 101.8
  277. AngleVectors(self->s.angles, f, r, nullptr);
  278. startpoint = M_ProjectFlashSource(self, offset, f, r);
  279. if (self->monsterinfo.chosen_reinforcements[0] == 255)
  280. return;
  281. auto &reinforcement = self->monsterinfo.reinforcements.reinforcements[self->monsterinfo.chosen_reinforcements[0]];
  282. if (FindSpawnPoint(startpoint, reinforcement.mins, reinforcement.maxs, spawnpoint, 32, false))
  283. {
  284. ent = CreateFlyMonster(spawnpoint, self->s.angles, reinforcement.mins, reinforcement.maxs, reinforcement.classname);
  285. if (!ent)
  286. return;
  287. gi.sound(self, CHAN_BODY, sound_spawn, 1, ATTN_NONE, 0);
  288. ent->nextthink = level.time;
  289. ent->think(ent);
  290. ent->monsterinfo.aiflags |= AI_SPAWNED_CARRIER | AI_DO_NOT_COUNT | AI_IGNORE_SHOTS;
  291. ent->monsterinfo.commander = self;
  292. ent->monsterinfo.monster_slots = reinforcement.strength;
  293. self->monsterinfo.monster_used += reinforcement.strength;
  294. if ((self->enemy->inuse) && (self->enemy->health > 0))
  295. {
  296. ent->enemy = self->enemy;
  297. FoundTarget(ent);
  298. if (!strcmp(ent->classname, "monster_kamikaze"))
  299. {
  300. ent->monsterinfo.lefty = false;
  301. ent->monsterinfo.attack_state = AS_STRAIGHT;
  302. M_SetAnimation(ent, &flyer_move_kamikaze);
  303. ent->monsterinfo.aiflags |= AI_CHARGING;
  304. ent->owner = self;
  305. }
  306. else if (!strcmp(ent->classname, "monster_flyer"))
  307. {
  308. if (brandom())
  309. {
  310. ent->monsterinfo.lefty = false;
  311. ent->monsterinfo.attack_state = AS_SLIDING;
  312. M_SetAnimation(ent, &flyer_move_attack3);
  313. }
  314. else
  315. {
  316. ent->monsterinfo.lefty = true;
  317. ent->monsterinfo.attack_state = AS_SLIDING;
  318. M_SetAnimation(ent, &flyer_move_attack3);
  319. }
  320. }
  321. }
  322. }
  323. }
  324. void carrier_prep_spawn(edict_t *self)
  325. {
  326. CarrierCoopCheck(self);
  327. self->monsterinfo.aiflags |= AI_MANUAL_STEERING;
  328. self->timestamp = level.time;
  329. self->yaw_speed = 10;
  330. }
  331. void carrier_spawn_check(edict_t *self)
  332. {
  333. CarrierCoopCheck(self);
  334. CarrierSpawn(self);
  335. if (level.time > (self->timestamp + 2.0_sec)) // 0.5 seconds per flyer. this gets three
  336. {
  337. self->monsterinfo.aiflags &= ~AI_MANUAL_STEERING;
  338. self->yaw_speed = orig_yaw_speed;
  339. }
  340. else
  341. self->monsterinfo.nextframe = FRAME_spawn08;
  342. }
  343. void carrier_ready_spawn(edict_t *self)
  344. {
  345. float current_yaw;
  346. vec3_t offset, f, r, startpoint, spawnpoint;
  347. CarrierCoopCheck(self);
  348. current_yaw = anglemod(self->s.angles[YAW]);
  349. if (fabsf(current_yaw - self->ideal_yaw) > 0.1f)
  350. {
  351. self->monsterinfo.aiflags |= AI_HOLD_FRAME;
  352. self->timestamp += FRAME_TIME_S;
  353. return;
  354. }
  355. self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  356. int num_summoned;
  357. self->monsterinfo.chosen_reinforcements = M_PickReinforcements(self, num_summoned, 1);
  358. if (!num_summoned)
  359. return;
  360. auto &reinforcement = self->monsterinfo.reinforcements.reinforcements[self->monsterinfo.chosen_reinforcements[0]];
  361. offset = { 105, 0, -58 };
  362. AngleVectors(self->s.angles, f, r, nullptr);
  363. startpoint = M_ProjectFlashSource(self, offset, f, r);
  364. if (FindSpawnPoint(startpoint, reinforcement.mins, reinforcement.maxs, spawnpoint, 32, false))
  365. {
  366. float radius = (reinforcement.maxs - reinforcement.mins).length() * 0.5f;
  367. SpawnGrow_Spawn(spawnpoint + (reinforcement.mins + reinforcement.maxs), radius, radius * 2.f);
  368. }
  369. }
  370. void carrier_start_spawn(edict_t *self)
  371. {
  372. int mytime;
  373. float enemy_yaw;
  374. vec3_t temp;
  375. CarrierCoopCheck(self);
  376. if (!orig_yaw_speed)
  377. orig_yaw_speed = self->yaw_speed;
  378. if (!self->enemy)
  379. return;
  380. mytime = (int) ((level.time - self->timestamp) / 0.5).seconds();
  381. temp = self->enemy->s.origin - self->s.origin;
  382. enemy_yaw = vectoyaw(temp);
  383. // note that the offsets are based on a forward of 105 from the end angle
  384. if (mytime == 0)
  385. self->ideal_yaw = anglemod(enemy_yaw - 30);
  386. else if (mytime == 1)
  387. self->ideal_yaw = anglemod(enemy_yaw);
  388. else if (mytime == 2)
  389. self->ideal_yaw = anglemod(enemy_yaw + 30);
  390. }
  391. mframe_t carrier_frames_stand[] = {
  392. { ai_stand },
  393. { ai_stand },
  394. { ai_stand },
  395. { ai_stand },
  396. { ai_stand },
  397. { ai_stand },
  398. { ai_stand },
  399. { ai_stand },
  400. { ai_stand },
  401. { ai_stand },
  402. { ai_stand },
  403. { ai_stand },
  404. { ai_stand }
  405. };
  406. MMOVE_T(carrier_move_stand) = { FRAME_search01, FRAME_search13, carrier_frames_stand, nullptr };
  407. mframe_t carrier_frames_walk[] = {
  408. { ai_walk, 4 },
  409. { ai_walk, 4 },
  410. { ai_walk, 4 },
  411. { ai_walk, 4 },
  412. { ai_walk, 4 },
  413. { ai_walk, 4 },
  414. { ai_walk, 4 },
  415. { ai_walk, 4 },
  416. { ai_walk, 4 },
  417. { ai_walk, 4 },
  418. { ai_walk, 4 },
  419. { ai_walk, 4 },
  420. { ai_walk, 4 }
  421. };
  422. MMOVE_T(carrier_move_walk) = { FRAME_search01, FRAME_search13, carrier_frames_walk, nullptr };
  423. mframe_t carrier_frames_run[] = {
  424. { ai_run, 6, CarrierCoopCheck },
  425. { ai_run, 6, CarrierCoopCheck },
  426. { ai_run, 6, CarrierCoopCheck },
  427. { ai_run, 6, CarrierCoopCheck },
  428. { ai_run, 6, CarrierCoopCheck },
  429. { ai_run, 6, CarrierCoopCheck },
  430. { ai_run, 6, CarrierCoopCheck },
  431. { ai_run, 6, CarrierCoopCheck },
  432. { ai_run, 6, CarrierCoopCheck },
  433. { ai_run, 6, CarrierCoopCheck },
  434. { ai_run, 6, CarrierCoopCheck },
  435. { ai_run, 6, CarrierCoopCheck },
  436. { ai_run, 6, CarrierCoopCheck }
  437. };
  438. MMOVE_T(carrier_move_run) = { FRAME_search01, FRAME_search13, carrier_frames_run, nullptr };
  439. static void CarrierSpool(edict_t *self)
  440. {
  441. CarrierCoopCheck(self);
  442. gi.sound(self, CHAN_BODY, sound_cg_up, 1, 0.5f, 0);
  443. self->monsterinfo.weapon_sound = sound_cg_loop;
  444. }
  445. mframe_t carrier_frames_attack_pre_mg[] = {
  446. { ai_charge, 4, CarrierSpool },
  447. { ai_charge, 4, CarrierCoopCheck },
  448. { ai_charge, 4, CarrierCoopCheck },
  449. { ai_charge, 4, CarrierCoopCheck },
  450. { ai_charge, 4, CarrierCoopCheck },
  451. { ai_charge, 4, CarrierCoopCheck },
  452. { ai_charge, 4, CarrierCoopCheck },
  453. { ai_charge, 4, carrier_attack_mg }
  454. };
  455. MMOVE_T(carrier_move_attack_pre_mg) = { FRAME_firea01, FRAME_firea08, carrier_frames_attack_pre_mg, nullptr };
  456. // Loop this
  457. mframe_t carrier_frames_attack_mg[] = {
  458. { ai_charge, -2, CarrierMachineGun },
  459. { ai_charge, -2, CarrierMachineGun },
  460. { ai_charge, -2, carrier_reattack_mg }
  461. };
  462. MMOVE_T(carrier_move_attack_mg) = { FRAME_firea09, FRAME_firea11, carrier_frames_attack_mg, nullptr };
  463. mframe_t carrier_frames_attack_post_mg[] = {
  464. { ai_charge, 4, CarrierCoopCheck },
  465. { ai_charge, 4, CarrierCoopCheck },
  466. { ai_charge, 4, CarrierCoopCheck },
  467. { ai_charge, 4, CarrierCoopCheck }
  468. };
  469. MMOVE_T(carrier_move_attack_post_mg) = { FRAME_firea12, FRAME_firea15, carrier_frames_attack_post_mg, carrier_run };
  470. mframe_t carrier_frames_attack_pre_gren[] = {
  471. { ai_charge, 4, CarrierCoopCheck },
  472. { ai_charge, 4, CarrierCoopCheck },
  473. { ai_charge, 4, CarrierCoopCheck },
  474. { ai_charge, 4, CarrierCoopCheck },
  475. { ai_charge, 4, CarrierCoopCheck },
  476. { ai_charge, 4, carrier_attack_gren }
  477. };
  478. MMOVE_T(carrier_move_attack_pre_gren) = { FRAME_fireb01, FRAME_fireb06, carrier_frames_attack_pre_gren, nullptr };
  479. mframe_t carrier_frames_attack_gren[] = {
  480. { ai_charge, -15, CarrierGrenade },
  481. { ai_charge, 4, CarrierCoopCheck },
  482. { ai_charge, 4, CarrierCoopCheck },
  483. { ai_charge, 4, carrier_reattack_gren }
  484. };
  485. MMOVE_T(carrier_move_attack_gren) = { FRAME_fireb07, FRAME_fireb10, carrier_frames_attack_gren, nullptr };
  486. mframe_t carrier_frames_attack_post_gren[] = {
  487. { ai_charge, 4, CarrierCoopCheck },
  488. { ai_charge, 4, CarrierCoopCheck },
  489. { ai_charge, 4, CarrierCoopCheck },
  490. { ai_charge, 4, CarrierCoopCheck },
  491. { ai_charge, 4, CarrierCoopCheck },
  492. { ai_charge, 4, CarrierCoopCheck }
  493. };
  494. MMOVE_T(carrier_move_attack_post_gren) = { FRAME_fireb11, FRAME_fireb16, carrier_frames_attack_post_gren, carrier_run };
  495. mframe_t carrier_frames_attack_rocket[] = {
  496. { ai_charge, 15, CarrierRocket }
  497. };
  498. MMOVE_T(carrier_move_attack_rocket) = { FRAME_fireb01, FRAME_fireb01, carrier_frames_attack_rocket, carrier_run };
  499. void CarrierRail(edict_t *self)
  500. {
  501. vec3_t start;
  502. vec3_t dir;
  503. vec3_t forward, right;
  504. CarrierCoopCheck(self);
  505. AngleVectors(self->s.angles, forward, right, nullptr);
  506. start = M_ProjectFlashSource(self, monster_flash_offset[MZ2_CARRIER_RAILGUN], forward, right);
  507. // calc direction to where we targeted
  508. dir = self->pos1 - start;
  509. dir.normalize();
  510. monster_fire_railgun(self, start, dir, 50, 100, MZ2_CARRIER_RAILGUN);
  511. self->monsterinfo.attack_finished = level.time + RAIL_FIRE_TIME;
  512. }
  513. void CarrierSaveLoc(edict_t *self)
  514. {
  515. CarrierCoopCheck(self);
  516. self->pos1 = self->enemy->s.origin; // save for aiming the shot
  517. self->pos1[2] += self->enemy->viewheight;
  518. };
  519. mframe_t carrier_frames_attack_rail[] = {
  520. { ai_charge, 2, CarrierCoopCheck },
  521. { ai_charge, 2, CarrierSaveLoc },
  522. { ai_charge, 2, CarrierCoopCheck },
  523. { ai_charge, -20, CarrierRail },
  524. { ai_charge, 2, CarrierCoopCheck },
  525. { ai_charge, 2, CarrierCoopCheck },
  526. { ai_charge, 2, CarrierCoopCheck },
  527. { ai_charge, 2, CarrierCoopCheck },
  528. { ai_charge, 2, CarrierCoopCheck }
  529. };
  530. MMOVE_T(carrier_move_attack_rail) = { FRAME_search01, FRAME_search09, carrier_frames_attack_rail, carrier_run };
  531. mframe_t carrier_frames_spawn[] = {
  532. { ai_charge, -2 },
  533. { ai_charge, -2 },
  534. { ai_charge, -2 },
  535. { ai_charge, -2 },
  536. { ai_charge, -2 },
  537. { ai_charge, -2 },
  538. { ai_charge, -2, carrier_prep_spawn }, // 7 - end of wind down
  539. { ai_charge, -2, carrier_start_spawn }, // 8 - start of spawn
  540. { ai_charge, -2, carrier_ready_spawn },
  541. { ai_charge, -2 },
  542. { ai_charge, -2 },
  543. { ai_charge, -10, carrier_spawn_check }, // 12 - actual spawn
  544. { ai_charge, -2 }, // 13 - begin of wind down
  545. { ai_charge, -2 },
  546. { ai_charge, -2 },
  547. { ai_charge, -2 },
  548. { ai_charge, -2 },
  549. { ai_charge, -2 } // 18 - end of wind down
  550. };
  551. MMOVE_T(carrier_move_spawn) = { FRAME_spawn01, FRAME_spawn18, carrier_frames_spawn, carrier_run };
  552. mframe_t carrier_frames_pain_heavy[] = {
  553. { ai_move },
  554. { ai_move },
  555. { ai_move },
  556. { ai_move },
  557. { ai_move },
  558. { ai_move },
  559. { ai_move },
  560. { ai_move },
  561. { ai_move },
  562. { ai_move }
  563. };
  564. MMOVE_T(carrier_move_pain_heavy) = { FRAME_death01, FRAME_death10, carrier_frames_pain_heavy, carrier_run };
  565. mframe_t carrier_frames_pain_light[] = {
  566. { ai_move },
  567. { ai_move },
  568. { ai_move },
  569. { ai_move }
  570. };
  571. MMOVE_T(carrier_move_pain_light) = { FRAME_spawn01, FRAME_spawn04, carrier_frames_pain_light, carrier_run };
  572. mframe_t carrier_frames_death[] = {
  573. { ai_move, 0, BossExplode },
  574. { ai_move },
  575. { ai_move },
  576. { ai_move },
  577. { ai_move },
  578. { ai_move },
  579. { ai_move },
  580. { ai_move },
  581. { ai_move },
  582. { ai_move },
  583. { ai_move },
  584. { ai_move },
  585. { ai_move },
  586. { ai_move },
  587. { ai_move },
  588. { ai_move }
  589. };
  590. MMOVE_T(carrier_move_death) = { FRAME_death01, FRAME_death16, carrier_frames_death, carrier_dead };
  591. MONSTERINFO_STAND(carrier_stand) (edict_t *self) -> void
  592. {
  593. M_SetAnimation(self, &carrier_move_stand);
  594. }
  595. MONSTERINFO_RUN(carrier_run) (edict_t *self) -> void
  596. {
  597. self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  598. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  599. M_SetAnimation(self, &carrier_move_stand);
  600. else
  601. M_SetAnimation(self, &carrier_move_run);
  602. }
  603. MONSTERINFO_WALK(carrier_walk) (edict_t *self) -> void
  604. {
  605. M_SetAnimation(self, &carrier_move_walk);
  606. }
  607. void CarrierMachineGunHold(edict_t *self)
  608. {
  609. CarrierMachineGun(self);
  610. }
  611. MONSTERINFO_ATTACK(carrier_attack) (edict_t *self) -> void
  612. {
  613. vec3_t vec;
  614. float range, luck;
  615. bool enemy_inback, enemy_infront, enemy_below;
  616. self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  617. if ((!self->enemy) || (!self->enemy->inuse))
  618. return;
  619. enemy_inback = inback(self, self->enemy);
  620. enemy_infront = infront(self, self->enemy);
  621. enemy_below = below(self, self->enemy);
  622. if (self->bad_area)
  623. {
  624. if ((enemy_inback) || (enemy_below))
  625. M_SetAnimation(self, &carrier_move_attack_rocket);
  626. else if ((frandom() < 0.1f) || (level.time < self->monsterinfo.attack_finished))
  627. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  628. else
  629. {
  630. gi.sound(self, CHAN_WEAPON, sound_rail, 1, ATTN_NORM, 0);
  631. M_SetAnimation(self, &carrier_move_attack_rail);
  632. }
  633. return;
  634. }
  635. if (self->monsterinfo.attack_state == AS_BLIND)
  636. {
  637. M_SetAnimation(self, &carrier_move_spawn);
  638. return;
  639. }
  640. if (!enemy_inback && !enemy_infront && !enemy_below) // to side and not under
  641. {
  642. if ((frandom() < 0.1f) || (level.time < self->monsterinfo.attack_finished))
  643. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  644. else
  645. {
  646. gi.sound(self, CHAN_WEAPON, sound_rail, 1, ATTN_NORM, 0);
  647. M_SetAnimation(self, &carrier_move_attack_rail);
  648. }
  649. return;
  650. }
  651. if (enemy_infront)
  652. {
  653. vec = self->enemy->s.origin - self->s.origin;
  654. range = vec.length();
  655. if (range <= 125)
  656. {
  657. if ((frandom() < 0.8f) || (level.time < self->monsterinfo.attack_finished))
  658. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  659. else
  660. {
  661. gi.sound(self, CHAN_WEAPON, sound_rail, 1, ATTN_NORM, 0);
  662. M_SetAnimation(self, &carrier_move_attack_rail);
  663. }
  664. }
  665. else if (range < 600)
  666. {
  667. luck = frandom();
  668. if (M_SlotsLeft(self) > 2)
  669. {
  670. if (luck <= 0.20f)
  671. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  672. else if (luck <= 0.40f)
  673. M_SetAnimation(self, &carrier_move_attack_pre_gren);
  674. else if ((luck <= 0.7f) && !(level.time < self->monsterinfo.attack_finished))
  675. {
  676. gi.sound(self, CHAN_WEAPON, sound_rail, 1, ATTN_NORM, 0);
  677. M_SetAnimation(self, &carrier_move_attack_rail);
  678. }
  679. else
  680. M_SetAnimation(self, &carrier_move_spawn);
  681. }
  682. else
  683. {
  684. if (luck <= 0.30f)
  685. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  686. else if (luck <= 0.65f)
  687. M_SetAnimation(self, &carrier_move_attack_pre_gren);
  688. else if (level.time >= self->monsterinfo.attack_finished)
  689. {
  690. gi.sound(self, CHAN_WEAPON, sound_rail, 1, ATTN_NORM, 0);
  691. M_SetAnimation(self, &carrier_move_attack_rail);
  692. }
  693. else
  694. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  695. }
  696. }
  697. else // won't use grenades at this range
  698. {
  699. luck = frandom();
  700. if (M_SlotsLeft(self) > 2)
  701. {
  702. if (luck < 0.3f)
  703. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  704. else if ((luck < 0.65f) && !(level.time < self->monsterinfo.attack_finished))
  705. {
  706. gi.sound(self, CHAN_WEAPON, sound_rail, 1, ATTN_NORM, 0);
  707. self->pos1 = self->enemy->s.origin; // save for aiming the shot
  708. self->pos1[2] += self->enemy->viewheight;
  709. M_SetAnimation(self, &carrier_move_attack_rail);
  710. }
  711. else
  712. M_SetAnimation(self, &carrier_move_spawn);
  713. }
  714. else
  715. {
  716. if ((luck < 0.45f) || (level.time < self->monsterinfo.attack_finished))
  717. M_SetAnimation(self, &carrier_move_attack_pre_mg);
  718. else
  719. {
  720. gi.sound(self, CHAN_WEAPON, sound_rail, 1, ATTN_NORM, 0);
  721. M_SetAnimation(self, &carrier_move_attack_rail);
  722. }
  723. }
  724. }
  725. }
  726. else if ((enemy_below) || (enemy_inback))
  727. {
  728. M_SetAnimation(self, &carrier_move_attack_rocket);
  729. }
  730. }
  731. void carrier_attack_mg(edict_t *self)
  732. {
  733. CarrierCoopCheck(self);
  734. M_SetAnimation(self, &carrier_move_attack_mg);
  735. self->monsterinfo.melee_debounce_time = level.time + random_time(1.2_sec, 2_sec);
  736. }
  737. void carrier_reattack_mg(edict_t *self)
  738. {
  739. CarrierMachineGun(self);
  740. CarrierCoopCheck(self);
  741. if (visible(self, self->enemy) && infront(self, self->enemy))
  742. {
  743. if (frandom() < 0.6f)
  744. {
  745. self->monsterinfo.melee_debounce_time += random_time(250_ms, 500_ms);
  746. M_SetAnimation(self, &carrier_move_attack_mg);
  747. return;
  748. }
  749. else if (self->monsterinfo.melee_debounce_time > level.time)
  750. {
  751. M_SetAnimation(self, &carrier_move_attack_mg);
  752. return;
  753. }
  754. }
  755. M_SetAnimation(self, &carrier_move_attack_post_mg);
  756. self->monsterinfo.weapon_sound = 0;
  757. gi.sound(self, CHAN_BODY, sound_cg_down, 1, 0.5f, 0);
  758. }
  759. void carrier_attack_gren(edict_t *self)
  760. {
  761. CarrierCoopCheck(self);
  762. self->timestamp = level.time;
  763. M_SetAnimation(self, &carrier_move_attack_gren);
  764. }
  765. void carrier_reattack_gren(edict_t *self)
  766. {
  767. CarrierCoopCheck(self);
  768. if (infront(self, self->enemy))
  769. if (self->timestamp + 1.3_sec > level.time) // four grenades
  770. {
  771. M_SetAnimation(self, &carrier_move_attack_gren);
  772. return;
  773. }
  774. M_SetAnimation(self, &carrier_move_attack_post_gren);
  775. }
  776. PAIN(carrier_pain) (edict_t *self, edict_t *other, float kick, int damage, const mod_t &mod) -> void
  777. {
  778. bool changed = false;
  779. if (level.time < self->pain_debounce_time)
  780. return;
  781. self->pain_debounce_time = level.time + 5_sec;
  782. if (damage < 10)
  783. gi.sound(self, CHAN_VOICE, sound_pain3, 1, ATTN_NONE, 0);
  784. else if (damage < 30)
  785. gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NONE, 0);
  786. else
  787. gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NONE, 0);
  788. if (!M_ShouldReactToPain(self, mod))
  789. return; // no pain anims in nightmare
  790. self->monsterinfo.weapon_sound = 0;
  791. if (damage >= 10)
  792. {
  793. if (damage < 30)
  794. {
  795. if (mod.id == MOD_CHAINFIST || frandom() < 0.5f)
  796. {
  797. changed = true;
  798. M_SetAnimation(self, &carrier_move_pain_light);
  799. }
  800. }
  801. else
  802. {
  803. M_SetAnimation(self, &carrier_move_pain_heavy);
  804. changed = true;
  805. }
  806. }
  807. // if we changed frames, clean up our little messes
  808. if (changed)
  809. {
  810. self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  811. self->monsterinfo.aiflags &= ~AI_MANUAL_STEERING;
  812. self->yaw_speed = orig_yaw_speed;
  813. }
  814. }
  815. MONSTERINFO_SETSKIN(carrier_setskin) (edict_t *self) -> void
  816. {
  817. if (self->health < (self->max_health / 2))
  818. self->s.skinnum = 1;
  819. else
  820. self->s.skinnum = 0;
  821. }
  822. void carrier_dead(edict_t *self)
  823. {
  824. gi.WriteByte(svc_temp_entity);
  825. gi.WriteByte(TE_EXPLOSION1_BIG);
  826. gi.WritePosition(self->s.origin);
  827. gi.multicast(self->s.origin, MULTICAST_PHS, false);
  828. self->s.sound = 0;
  829. self->s.skinnum /= 2;
  830. self->gravityVector.z = -1.0f;
  831. ThrowGibs(self, 500, {
  832. { 2, "models/objects/gibs/sm_meat/tris.md2" },
  833. { 3, "models/objects/gibs/sm_metal/tris.md2", GIB_METALLIC },
  834. { "models/monsters/carrier/gibs/base.md2", GIB_SKINNED },
  835. { "models/monsters/carrier/gibs/chest.md2", GIB_SKINNED | GIB_UPRIGHT },
  836. { "models/monsters/carrier/gibs/gl.md2", GIB_SKINNED },
  837. { "models/monsters/carrier/gibs/lcg.md2", GIB_SKINNED | GIB_UPRIGHT },
  838. { "models/monsters/carrier/gibs/lwing.md2", GIB_SKINNED | GIB_UPRIGHT },
  839. { "models/monsters/carrier/gibs/rcg.md2", GIB_SKINNED | GIB_UPRIGHT },
  840. { "models/monsters/carrier/gibs/rwing.md2", GIB_SKINNED | GIB_UPRIGHT },
  841. { 2, "models/monsters/carrier/gibs/spawner.md2", GIB_SKINNED },
  842. { 2, "models/monsters/carrier/gibs/thigh.md2", GIB_SKINNED },
  843. { "models/monsters/carrier/gibs/head.md2", GIB_SKINNED | GIB_METALLIC | GIB_HEAD }
  844. });
  845. }
  846. DIE(carrier_die) (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, const vec3_t &point, const mod_t &mod) -> void
  847. {
  848. gi.sound(self, CHAN_VOICE, sound_death, 1, ATTN_NONE, 0);
  849. self->deadflag = true;
  850. self->takedamage = false;
  851. self->count = 0;
  852. M_SetAnimation(self, &carrier_move_death);
  853. self->velocity = {};
  854. self->gravityVector.z *= 0.01f;
  855. self->monsterinfo.weapon_sound = 0;
  856. }
  857. MONSTERINFO_CHECKATTACK(Carrier_CheckAttack) (edict_t *self) -> bool
  858. {
  859. bool enemy_infront = infront(self, self->enemy);
  860. bool enemy_inback = inback(self, self->enemy);
  861. bool enemy_below = below(self, self->enemy);
  862. // PMM - shoot out the back if appropriate
  863. if ((enemy_inback) || (!enemy_infront && enemy_below))
  864. {
  865. // this is using wait because the attack is supposed to be independent
  866. if (level.time >= self->monsterinfo.fire_wait)
  867. {
  868. self->monsterinfo.fire_wait = level.time + CARRIER_ROCKET_TIME;
  869. self->monsterinfo.attack(self);
  870. if (frandom() < 0.6f)
  871. self->monsterinfo.attack_state = AS_SLIDING;
  872. else
  873. self->monsterinfo.attack_state = AS_STRAIGHT;
  874. return true;
  875. }
  876. }
  877. return M_CheckAttack_Base(self, 0.4f, 0.8f, 0.8f, 0.8f, 0.5f, 0.f);
  878. }
  879. void CarrierPrecache()
  880. {
  881. gi.soundindex("flyer/flysght1.wav");
  882. gi.soundindex("flyer/flysrch1.wav");
  883. gi.soundindex("flyer/flypain1.wav");
  884. gi.soundindex("flyer/flypain2.wav");
  885. gi.soundindex("flyer/flyatck2.wav");
  886. gi.soundindex("flyer/flyatck1.wav");
  887. gi.soundindex("flyer/flydeth1.wav");
  888. gi.soundindex("flyer/flyatck3.wav");
  889. gi.soundindex("flyer/flyidle1.wav");
  890. gi.soundindex("weapons/rockfly.wav");
  891. gi.soundindex("infantry/infatck1.wav");
  892. gi.soundindex("gunner/gunatck3.wav");
  893. gi.soundindex("weapons/grenlb1b.wav");
  894. gi.soundindex("tank/rocket.wav");
  895. gi.modelindex("models/monsters/flyer/tris.md2");
  896. gi.modelindex("models/objects/rocket/tris.md2");
  897. gi.modelindex("models/objects/debris2/tris.md2");
  898. gi.modelindex("models/objects/grenade/tris.md2");
  899. gi.modelindex("models/items/spawngro3/tris.md2");
  900. gi.modelindex("models/objects/gibs/sm_metal/tris.md2");
  901. gi.modelindex("models/objects/gibs/gear/tris.md2");
  902. }
  903. /*QUAKED monster_carrier (1 .5 0) (-56 -56 -44) (56 56 44) Ambush Trigger_Spawn Sight
  904. */
  905. void SP_monster_carrier(edict_t *self)
  906. {
  907. if ( !M_AllowSpawn( self ) ) {
  908. G_FreeEdict( self );
  909. return;
  910. }
  911. sound_pain1.assign("carrier/pain_md.wav");
  912. sound_pain2.assign("carrier/pain_lg.wav");
  913. sound_pain3.assign("carrier/pain_sm.wav");
  914. sound_death.assign("carrier/death.wav");
  915. sound_rail.assign("gladiator/railgun.wav");
  916. sound_sight.assign("carrier/sight.wav");
  917. sound_spawn.assign("medic_commander/monsterspawn1.wav");
  918. sound_cg_down.assign("weapons/chngnd1a.wav");
  919. sound_cg_loop.assign("weapons/chngnl1a.wav");
  920. sound_cg_up.assign("weapons/chngnu1a.wav");
  921. self->monsterinfo.engine_sound = gi.soundindex("bosshovr/bhvengn1.wav");
  922. self->movetype = MOVETYPE_STEP;
  923. self->solid = SOLID_BBOX;
  924. self->s.modelindex = gi.modelindex("models/monsters/carrier/tris.md2");
  925. gi.modelindex("models/monsters/carrier/gibs/base.md2");
  926. gi.modelindex("models/monsters/carrier/gibs/chest.md2");
  927. gi.modelindex("models/monsters/carrier/gibs/gl.md2");
  928. gi.modelindex("models/monsters/carrier/gibs/head.md2");
  929. gi.modelindex("models/monsters/carrier/gibs/lcg.md2");
  930. gi.modelindex("models/monsters/carrier/gibs/lwing.md2");
  931. gi.modelindex("models/monsters/carrier/gibs/rcg.md2");
  932. gi.modelindex("models/monsters/carrier/gibs/rwing.md2");
  933. gi.modelindex("models/monsters/carrier/gibs/spawner.md2");
  934. gi.modelindex("models/monsters/carrier/gibs/thigh.md2");
  935. self->mins = { -56, -56, -44 };
  936. self->maxs = { 56, 56, 44 };
  937. // 2000 - 4000 health
  938. self->health = max(2000, 2000 + 1000 * (skill->integer - 1)) * st.health_multiplier;
  939. // add health in coop (500 * skill)
  940. if (coop->integer)
  941. self->health += 500 * skill->integer;
  942. self->gib_health = -200;
  943. self->mass = 1000;
  944. self->yaw_speed = 15;
  945. orig_yaw_speed = self->yaw_speed;
  946. self->flags |= FL_IMMUNE_LASER;
  947. self->monsterinfo.aiflags |= AI_IGNORE_SHOTS;
  948. self->pain = carrier_pain;
  949. self->die = carrier_die;
  950. self->monsterinfo.melee = nullptr;
  951. self->monsterinfo.stand = carrier_stand;
  952. self->monsterinfo.walk = carrier_walk;
  953. self->monsterinfo.run = carrier_run;
  954. self->monsterinfo.attack = carrier_attack;
  955. self->monsterinfo.sight = carrier_sight;
  956. self->monsterinfo.checkattack = Carrier_CheckAttack;
  957. self->monsterinfo.setskin = carrier_setskin;
  958. gi.linkentity(self);
  959. M_SetAnimation(self, &carrier_move_stand);
  960. self->monsterinfo.scale = MODEL_SCALE;
  961. CarrierPrecache();
  962. flymonster_start(self);
  963. self->monsterinfo.attack_finished = 0_ms;
  964. const char *reinforcements = default_reinforcements;
  965. if (!st.was_key_specified("monster_slots"))
  966. self->monsterinfo.monster_slots = default_monster_slots_base;
  967. if (st.was_key_specified("reinforcements"))
  968. reinforcements = st.reinforcements;
  969. if (self->monsterinfo.monster_slots && reinforcements && *reinforcements)
  970. {
  971. if (skill->integer)
  972. self->monsterinfo.monster_slots += floor(self->monsterinfo.monster_slots * (skill->value / 2.f));
  973. M_SetupReinforcements(reinforcements, self->monsterinfo.reinforcements);
  974. }
  975. self->monsterinfo.aiflags |= AI_ALTERNATE_FLY;
  976. self->monsterinfo.fly_acceleration = 5.f;
  977. self->monsterinfo.fly_speed = 50.f;
  978. self->monsterinfo.fly_above = true;
  979. self->monsterinfo.fly_min_distance = 1000.f;
  980. self->monsterinfo.fly_max_distance = 1000.f;
  981. }