g_monster.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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. #include "g_local.h"
  16. //
  17. // monster weapons
  18. //
  19. //FIXME mosnters should call these with a totally accurate direction
  20. // and we can mess it up based on skill. Spread should be for normal
  21. // and we can tighten or loosen based on skill. We could muck with
  22. // the damages too, but I'm not sure that's such a good idea.
  23. void monster_fire_bullet (edict_t *self, vec3_t start, vec3_t dir, int damage, int kick, int hspread, int vspread, int flashtype)
  24. {
  25. fire_bullet (self, start, dir, damage, kick, hspread, vspread, MOD_UNKNOWN);
  26. gi.WriteByte (svc_muzzleflash2);
  27. gi.WriteShort (self - g_edicts);
  28. gi.WriteByte (flashtype);
  29. gi.multicast (start, MULTICAST_PVS);
  30. }
  31. void monster_fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int flashtype)
  32. {
  33. fire_shotgun (self, start, aimdir, damage, kick, hspread, vspread, count, MOD_UNKNOWN);
  34. gi.WriteByte (svc_muzzleflash2);
  35. gi.WriteShort (self - g_edicts);
  36. gi.WriteByte (flashtype);
  37. gi.multicast (start, MULTICAST_PVS);
  38. }
  39. void monster_fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype, int effect)
  40. {
  41. fire_blaster (self, start, dir, damage, speed, effect, false);
  42. gi.WriteByte (svc_muzzleflash2);
  43. gi.WriteShort (self - g_edicts);
  44. gi.WriteByte (flashtype);
  45. gi.multicast (start, MULTICAST_PVS);
  46. }
  47. void monster_fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int flashtype)
  48. {
  49. fire_grenade (self, start, aimdir, damage, speed, 2.5, damage+40);
  50. gi.WriteByte (svc_muzzleflash2);
  51. gi.WriteShort (self - g_edicts);
  52. gi.WriteByte (flashtype);
  53. gi.multicast (start, MULTICAST_PVS);
  54. }
  55. void monster_fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype)
  56. {
  57. fire_rocket (self, start, dir, damage, speed, damage+20, damage);
  58. gi.WriteByte (svc_muzzleflash2);
  59. gi.WriteShort (self - g_edicts);
  60. gi.WriteByte (flashtype);
  61. gi.multicast (start, MULTICAST_PVS);
  62. }
  63. void monster_fire_railgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int flashtype)
  64. {
  65. fire_rail (self, start, aimdir, damage, kick);
  66. gi.WriteByte (svc_muzzleflash2);
  67. gi.WriteShort (self - g_edicts);
  68. gi.WriteByte (flashtype);
  69. gi.multicast (start, MULTICAST_PVS);
  70. }
  71. void monster_fire_bfg (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int kick, float damage_radius, int flashtype)
  72. {
  73. fire_bfg (self, start, aimdir, damage, speed, damage_radius);
  74. gi.WriteByte (svc_muzzleflash2);
  75. gi.WriteShort (self - g_edicts);
  76. gi.WriteByte (flashtype);
  77. gi.multicast (start, MULTICAST_PVS);
  78. }
  79. //
  80. // Monster utility functions
  81. //
  82. static void M_FliesOff (edict_t *self)
  83. {
  84. self->s.effects &= ~EF_FLIES;
  85. self->s.sound = 0;
  86. }
  87. static void M_FliesOn (edict_t *self)
  88. {
  89. if (self->waterlevel)
  90. return;
  91. self->s.effects |= EF_FLIES;
  92. self->s.sound = gi.soundindex ("infantry/inflies1.wav");
  93. self->think = M_FliesOff;
  94. self->nextthink = level.time + 60;
  95. }
  96. void M_FlyCheck (edict_t *self)
  97. {
  98. if (self->waterlevel)
  99. return;
  100. if (random() > 0.5)
  101. return;
  102. self->think = M_FliesOn;
  103. self->nextthink = level.time + 5 + 10 * random();
  104. }
  105. void AttackFinished (edict_t *self, float time)
  106. {
  107. self->monsterinfo.attack_finished = level.time + time;
  108. }
  109. void M_CheckGround (edict_t *ent)
  110. {
  111. vec3_t point;
  112. trace_t trace;
  113. if (ent->flags & (FL_SWIM|FL_FLY))
  114. return;
  115. if (ent->velocity[2] > 100)
  116. {
  117. ent->groundentity = NULL;
  118. return;
  119. }
  120. // if the hull point one-quarter unit down is solid the entity is on ground
  121. point[0] = ent->s.origin[0];
  122. point[1] = ent->s.origin[1];
  123. point[2] = ent->s.origin[2] - 0.25;
  124. trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, point, ent, MASK_MONSTERSOLID);
  125. // check steepness
  126. if ( trace.plane.normal[2] < 0.7 && !trace.startsolid)
  127. {
  128. ent->groundentity = NULL;
  129. return;
  130. }
  131. // ent->groundentity = trace.ent;
  132. // ent->groundentity_linkcount = trace.ent->linkcount;
  133. // if (!trace.startsolid && !trace.allsolid)
  134. // VectorCopy (trace.endpos, ent->s.origin);
  135. if (!trace.startsolid && !trace.allsolid)
  136. {
  137. VectorCopy (trace.endpos, ent->s.origin);
  138. ent->groundentity = trace.ent;
  139. ent->groundentity_linkcount = trace.ent->linkcount;
  140. ent->velocity[2] = 0;
  141. }
  142. }
  143. void M_CatagorizePosition (edict_t *ent)
  144. {
  145. vec3_t point;
  146. int cont;
  147. //
  148. // get waterlevel
  149. //
  150. point[0] = ent->s.origin[0];
  151. point[1] = ent->s.origin[1];
  152. point[2] = ent->s.origin[2] + ent->mins[2] + 1;
  153. cont = gi.pointcontents (point);
  154. if (!(cont & MASK_WATER))
  155. {
  156. ent->waterlevel = 0;
  157. ent->watertype = 0;
  158. return;
  159. }
  160. ent->watertype = cont;
  161. ent->waterlevel = 1;
  162. point[2] += 26;
  163. cont = gi.pointcontents (point);
  164. if (!(cont & MASK_WATER))
  165. return;
  166. ent->waterlevel = 2;
  167. point[2] += 22;
  168. cont = gi.pointcontents (point);
  169. if (cont & MASK_WATER)
  170. ent->waterlevel = 3;
  171. }
  172. void M_WorldEffects (edict_t *ent)
  173. {
  174. int dmg;
  175. if (ent->health > 0)
  176. {
  177. if (!(ent->flags & FL_SWIM))
  178. {
  179. if (ent->waterlevel < 3)
  180. {
  181. ent->air_finished = level.time + 12;
  182. }
  183. else if (ent->air_finished < level.time)
  184. { // drown!
  185. if (ent->pain_debounce_time < level.time)
  186. {
  187. dmg = 2 + 2 * floor(level.time - ent->air_finished);
  188. if (dmg > 15)
  189. dmg = 15;
  190. T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, dmg, 0, DAMAGE_NO_ARMOR, MOD_WATER);
  191. ent->pain_debounce_time = level.time + 1;
  192. }
  193. }
  194. }
  195. else
  196. {
  197. if (ent->waterlevel > 0)
  198. {
  199. ent->air_finished = level.time + 9;
  200. }
  201. else if (ent->air_finished < level.time)
  202. { // suffocate!
  203. if (ent->pain_debounce_time < level.time)
  204. {
  205. dmg = 2 + 2 * floor(level.time - ent->air_finished);
  206. if (dmg > 15)
  207. dmg = 15;
  208. T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, dmg, 0, DAMAGE_NO_ARMOR, MOD_WATER);
  209. ent->pain_debounce_time = level.time + 1;
  210. }
  211. }
  212. }
  213. }
  214. if (ent->waterlevel == 0)
  215. {
  216. if (ent->flags & FL_INWATER)
  217. {
  218. gi.sound (ent, CHAN_BODY, gi.soundindex("player/watr_out.wav"), 1, ATTN_NORM, 0);
  219. ent->flags &= ~FL_INWATER;
  220. }
  221. return;
  222. }
  223. if ((ent->watertype & CONTENTS_LAVA) && !(ent->flags & FL_IMMUNE_LAVA))
  224. {
  225. if (ent->damage_debounce_time < level.time)
  226. {
  227. ent->damage_debounce_time = level.time + 0.2;
  228. T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, 10*ent->waterlevel, 0, 0, MOD_LAVA);
  229. }
  230. }
  231. if ((ent->watertype & CONTENTS_SLIME) && !(ent->flags & FL_IMMUNE_SLIME))
  232. {
  233. if (ent->damage_debounce_time < level.time)
  234. {
  235. ent->damage_debounce_time = level.time + 1;
  236. T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, 4*ent->waterlevel, 0, 0, MOD_SLIME);
  237. }
  238. }
  239. if ( !(ent->flags & FL_INWATER) )
  240. {
  241. if (!(ent->svflags & SVF_DEADMONSTER))
  242. {
  243. if (ent->watertype & CONTENTS_LAVA)
  244. if (random() <= 0.5)
  245. gi.sound (ent, CHAN_BODY, gi.soundindex("player/lava1.wav"), 1, ATTN_NORM, 0);
  246. else
  247. gi.sound (ent, CHAN_BODY, gi.soundindex("player/lava2.wav"), 1, ATTN_NORM, 0);
  248. else if (ent->watertype & CONTENTS_SLIME)
  249. gi.sound (ent, CHAN_BODY, gi.soundindex("player/watr_in.wav"), 1, ATTN_NORM, 0);
  250. else if (ent->watertype & CONTENTS_WATER)
  251. gi.sound (ent, CHAN_BODY, gi.soundindex("player/watr_in.wav"), 1, ATTN_NORM, 0);
  252. }
  253. ent->flags |= FL_INWATER;
  254. ent->damage_debounce_time = 0;
  255. }
  256. }
  257. void M_droptofloor (edict_t *ent)
  258. {
  259. vec3_t end;
  260. trace_t trace;
  261. ent->s.origin[2] += 1;
  262. VectorCopy (ent->s.origin, end);
  263. end[2] -= 256;
  264. trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);
  265. if (trace.fraction == 1 || trace.allsolid)
  266. return;
  267. VectorCopy (trace.endpos, ent->s.origin);
  268. gi.linkentity (ent);
  269. M_CheckGround (ent);
  270. M_CatagorizePosition (ent);
  271. }
  272. void M_SetEffects (edict_t *ent)
  273. {
  274. ent->s.effects &= ~(EF_COLOR_SHELL|EF_POWERSCREEN);
  275. ent->s.renderfx &= ~(RF_SHELL_RED|RF_SHELL_GREEN|RF_SHELL_BLUE);
  276. if (ent->monsterinfo.aiflags & AI_RESURRECTING)
  277. {
  278. ent->s.effects |= EF_COLOR_SHELL;
  279. ent->s.renderfx |= RF_SHELL_RED;
  280. }
  281. if (ent->health <= 0)
  282. return;
  283. if (ent->powerarmor_time > level.time)
  284. {
  285. if (ent->monsterinfo.power_armor_type == POWER_ARMOR_SCREEN)
  286. {
  287. ent->s.effects |= EF_POWERSCREEN;
  288. }
  289. else if (ent->monsterinfo.power_armor_type == POWER_ARMOR_SHIELD)
  290. {
  291. ent->s.effects |= EF_COLOR_SHELL;
  292. ent->s.renderfx |= RF_SHELL_GREEN;
  293. }
  294. }
  295. }
  296. void M_MoveFrame (edict_t *self)
  297. {
  298. mmove_t *move;
  299. int index;
  300. move = self->monsterinfo.currentmove;
  301. self->nextthink = level.time + FRAMETIME;
  302. if ((self->monsterinfo.nextframe) && (self->monsterinfo.nextframe >= move->firstframe) && (self->monsterinfo.nextframe <= move->lastframe))
  303. {
  304. self->s.frame = self->monsterinfo.nextframe;
  305. self->monsterinfo.nextframe = 0;
  306. }
  307. else
  308. {
  309. if (self->s.frame == move->lastframe)
  310. {
  311. if (move->endfunc)
  312. {
  313. move->endfunc (self);
  314. // regrab move, endfunc is very likely to change it
  315. move = self->monsterinfo.currentmove;
  316. // check for death
  317. if (self->svflags & SVF_DEADMONSTER)
  318. return;
  319. }
  320. }
  321. if (self->s.frame < move->firstframe || self->s.frame > move->lastframe)
  322. {
  323. self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  324. self->s.frame = move->firstframe;
  325. }
  326. else
  327. {
  328. if (!(self->monsterinfo.aiflags & AI_HOLD_FRAME))
  329. {
  330. self->s.frame++;
  331. if (self->s.frame > move->lastframe)
  332. self->s.frame = move->firstframe;
  333. }
  334. }
  335. }
  336. index = self->s.frame - move->firstframe;
  337. if (move->frame[index].aifunc)
  338. if (!(self->monsterinfo.aiflags & AI_HOLD_FRAME))
  339. move->frame[index].aifunc (self, move->frame[index].dist * self->monsterinfo.scale);
  340. else
  341. move->frame[index].aifunc (self, 0);
  342. if (move->frame[index].thinkfunc)
  343. move->frame[index].thinkfunc (self);
  344. }
  345. void monster_think (edict_t *self)
  346. {
  347. M_MoveFrame (self);
  348. if (self->linkcount != self->monsterinfo.linkcount)
  349. {
  350. self->monsterinfo.linkcount = self->linkcount;
  351. M_CheckGround (self);
  352. }
  353. M_CatagorizePosition (self);
  354. M_WorldEffects (self);
  355. M_SetEffects (self);
  356. }
  357. /*
  358. ================
  359. monster_use
  360. Using a monster makes it angry at the current activator
  361. ================
  362. */
  363. void monster_use (edict_t *self, edict_t *other, edict_t *activator)
  364. {
  365. if (self->enemy)
  366. return;
  367. if (self->health <= 0)
  368. return;
  369. if (activator->flags & FL_NOTARGET)
  370. return;
  371. if (!(activator->client) && !(activator->monsterinfo.aiflags & AI_GOOD_GUY))
  372. return;
  373. // delay reaction so if the monster is teleported, its sound is still heard
  374. self->enemy = activator;
  375. FoundTarget (self);
  376. }
  377. void monster_start_go (edict_t *self);
  378. void monster_triggered_spawn (edict_t *self)
  379. {
  380. self->s.origin[2] += 1;
  381. KillBox (self);
  382. self->solid = SOLID_BBOX;
  383. self->movetype = MOVETYPE_STEP;
  384. self->svflags &= ~SVF_NOCLIENT;
  385. self->air_finished = level.time + 12;
  386. gi.linkentity (self);
  387. monster_start_go (self);
  388. if (self->enemy && !(self->spawnflags & 1) && !(self->enemy->flags & FL_NOTARGET))
  389. {
  390. FoundTarget (self);
  391. }
  392. else
  393. {
  394. self->enemy = NULL;
  395. }
  396. }
  397. void monster_triggered_spawn_use (edict_t *self, edict_t *other, edict_t *activator)
  398. {
  399. // we have a one frame delay here so we don't telefrag the guy who activated us
  400. self->think = monster_triggered_spawn;
  401. self->nextthink = level.time + FRAMETIME;
  402. if (activator->client)
  403. self->enemy = activator;
  404. self->use = monster_use;
  405. }
  406. void monster_triggered_start (edict_t *self)
  407. {
  408. self->solid = SOLID_NOT;
  409. self->movetype = MOVETYPE_NONE;
  410. self->svflags |= SVF_NOCLIENT;
  411. self->nextthink = 0;
  412. self->use = monster_triggered_spawn_use;
  413. }
  414. /*
  415. ================
  416. monster_death_use
  417. When a monster dies, it fires all of its targets with the current
  418. enemy as activator.
  419. ================
  420. */
  421. void monster_death_use (edict_t *self)
  422. {
  423. self->flags &= ~(FL_FLY|FL_SWIM);
  424. self->monsterinfo.aiflags &= AI_GOOD_GUY;
  425. if (self->item)
  426. {
  427. Drop_Item (self, self->item);
  428. self->item = NULL;
  429. }
  430. if (self->deathtarget)
  431. self->target = self->deathtarget;
  432. if (!self->target)
  433. return;
  434. G_UseTargets (self, self->enemy);
  435. }
  436. //============================================================================
  437. qboolean monster_start (edict_t *self)
  438. {
  439. if (deathmatch->value)
  440. {
  441. G_FreeEdict (self);
  442. return false;
  443. }
  444. if ((self->spawnflags & 4) && !(self->monsterinfo.aiflags & AI_GOOD_GUY))
  445. {
  446. self->spawnflags &= ~4;
  447. self->spawnflags |= 1;
  448. // gi.dprintf("fixed spawnflags on %s at %s\n", self->classname, vtos(self->s.origin));
  449. }
  450. if (!(self->monsterinfo.aiflags & AI_GOOD_GUY))
  451. level.total_monsters++;
  452. self->nextthink = level.time + FRAMETIME;
  453. self->svflags |= SVF_MONSTER;
  454. self->s.renderfx |= RF_FRAMELERP;
  455. self->takedamage = DAMAGE_AIM;
  456. self->air_finished = level.time + 12;
  457. self->use = monster_use;
  458. self->max_health = self->health;
  459. self->clipmask = MASK_MONSTERSOLID;
  460. self->s.skinnum = 0;
  461. self->deadflag = DEAD_NO;
  462. self->svflags &= ~SVF_DEADMONSTER;
  463. if (!self->monsterinfo.checkattack)
  464. self->monsterinfo.checkattack = M_CheckAttack;
  465. VectorCopy (self->s.origin, self->s.old_origin);
  466. if (st.item)
  467. {
  468. self->item = FindItemByClassname (st.item);
  469. if (!self->item)
  470. gi.dprintf("%s at %s has bad item: %s\n", self->classname, vtos(self->s.origin), st.item);
  471. }
  472. // randomize what frame they start on
  473. if (self->monsterinfo.currentmove)
  474. self->s.frame = self->monsterinfo.currentmove->firstframe + (rand() % (self->monsterinfo.currentmove->lastframe - self->monsterinfo.currentmove->firstframe + 1));
  475. return true;
  476. }
  477. void monster_start_go (edict_t *self)
  478. {
  479. vec3_t v;
  480. if (self->health <= 0)
  481. return;
  482. // check for target to combat_point and change to combattarget
  483. if (self->target)
  484. {
  485. qboolean notcombat;
  486. qboolean fixup;
  487. edict_t *target;
  488. target = NULL;
  489. notcombat = false;
  490. fixup = false;
  491. while ((target = G_Find (target, FOFS(targetname), self->target)) != NULL)
  492. {
  493. if (strcmp(target->classname, "point_combat") == 0)
  494. {
  495. self->combattarget = self->target;
  496. fixup = true;
  497. }
  498. else
  499. {
  500. notcombat = true;
  501. }
  502. }
  503. if (notcombat && self->combattarget)
  504. gi.dprintf("%s at %s has target with mixed types\n", self->classname, vtos(self->s.origin));
  505. if (fixup)
  506. self->target = NULL;
  507. }
  508. // validate combattarget
  509. if (self->combattarget)
  510. {
  511. edict_t *target;
  512. target = NULL;
  513. while ((target = G_Find (target, FOFS(targetname), self->combattarget)) != NULL)
  514. {
  515. if (strcmp(target->classname, "point_combat") != 0)
  516. {
  517. gi.dprintf("%s at (%i %i %i) has a bad combattarget %s : %s at (%i %i %i)\n",
  518. self->classname, (int)self->s.origin[0], (int)self->s.origin[1], (int)self->s.origin[2],
  519. self->combattarget, target->classname, (int)target->s.origin[0], (int)target->s.origin[1],
  520. (int)target->s.origin[2]);
  521. }
  522. }
  523. }
  524. if (self->target)
  525. {
  526. self->goalentity = self->movetarget = G_PickTarget(self->target);
  527. if (!self->movetarget)
  528. {
  529. gi.dprintf ("%s can't find target %s at %s\n", self->classname, self->target, vtos(self->s.origin));
  530. self->target = NULL;
  531. self->monsterinfo.pausetime = 100000000;
  532. self->monsterinfo.stand (self);
  533. }
  534. else if (strcmp (self->movetarget->classname, "path_corner") == 0)
  535. {
  536. VectorSubtract (self->goalentity->s.origin, self->s.origin, v);
  537. self->ideal_yaw = self->s.angles[YAW] = vectoyaw(v);
  538. self->monsterinfo.walk (self);
  539. self->target = NULL;
  540. }
  541. else
  542. {
  543. self->goalentity = self->movetarget = NULL;
  544. self->monsterinfo.pausetime = 100000000;
  545. self->monsterinfo.stand (self);
  546. }
  547. }
  548. else
  549. {
  550. self->monsterinfo.pausetime = 100000000;
  551. self->monsterinfo.stand (self);
  552. }
  553. self->think = monster_think;
  554. self->nextthink = level.time + FRAMETIME;
  555. }
  556. void walkmonster_start_go (edict_t *self)
  557. {
  558. if (!(self->spawnflags & 2) && level.time < 1)
  559. {
  560. M_droptofloor (self);
  561. if (self->groundentity)
  562. if (!M_walkmove (self, 0, 0))
  563. gi.dprintf ("%s in solid at %s\n", self->classname, vtos(self->s.origin));
  564. }
  565. if (!self->yaw_speed)
  566. self->yaw_speed = 20;
  567. self->viewheight = 25;
  568. monster_start_go (self);
  569. if (self->spawnflags & 2)
  570. monster_triggered_start (self);
  571. }
  572. void walkmonster_start (edict_t *self)
  573. {
  574. self->think = walkmonster_start_go;
  575. monster_start (self);
  576. }
  577. void flymonster_start_go (edict_t *self)
  578. {
  579. if (!M_walkmove (self, 0, 0))
  580. gi.dprintf ("%s in solid at %s\n", self->classname, vtos(self->s.origin));
  581. if (!self->yaw_speed)
  582. self->yaw_speed = 10;
  583. self->viewheight = 25;
  584. monster_start_go (self);
  585. if (self->spawnflags & 2)
  586. monster_triggered_start (self);
  587. }
  588. void flymonster_start (edict_t *self)
  589. {
  590. self->flags |= FL_FLY;
  591. self->think = flymonster_start_go;
  592. monster_start (self);
  593. }
  594. void swimmonster_start_go (edict_t *self)
  595. {
  596. if (!self->yaw_speed)
  597. self->yaw_speed = 10;
  598. self->viewheight = 10;
  599. monster_start_go (self);
  600. if (self->spawnflags & 2)
  601. monster_triggered_start (self);
  602. }
  603. void swimmonster_start (edict_t *self)
  604. {
  605. self->flags |= FL_SWIM;
  606. self->think = swimmonster_start_go;
  607. monster_start (self);
  608. }