| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2000,2002 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* Enemy thinking, AI. |
| 31 |
* Action Pointer Functions |
| 32 |
* that are associated with states/frames. |
| 33 |
* |
| 34 |
*-----------------------------------------------------------------------------*/ |
| 35 |
|
| 36 |
#include "doomstat.h" |
| 37 |
#include "m_random.h" |
| 38 |
#include "r_main.h" |
| 39 |
#include "p_maputl.h" |
| 40 |
#include "p_map.h" |
| 41 |
#include "p_setup.h" |
| 42 |
#include "p_spec.h" |
| 43 |
#include "s_sound.h" |
| 44 |
#include "sounds.h" |
| 45 |
#include "p_inter.h" |
| 46 |
#include "g_game.h" |
| 47 |
#include "p_enemy.h" |
| 48 |
#include "p_tick.h" |
| 49 |
#include "i_sound.h" |
| 50 |
#include "m_bbox.h" |
| 51 |
#include "hu_stuff.h" |
| 52 |
#include "lprintf.h" |
| 53 |
#include "e6y.h"//e6y |
| 54 |
|
| 55 |
#include "dsda.h" |
| 56 |
#include "dsda/configuration.h" |
| 57 |
#include "dsda/id_list.h" |
| 58 |
#include "dsda/map_format.h" |
| 59 |
#include "dsda/mapinfo.h" |
| 60 |
#include "dsda/skill_info.h" |
| 61 |
|
| 62 |
static mobj_t *current_actor; |
| 63 |
|
| 64 |
typedef enum { |
| 65 |
DI_EAST, |
| 66 |
DI_NORTHEAST, |
| 67 |
DI_NORTH, |
| 68 |
DI_NORTHWEST, |
| 69 |
DI_WEST, |
| 70 |
DI_SOUTHWEST, |
| 71 |
DI_SOUTH, |
| 72 |
DI_SOUTHEAST, |
| 73 |
DI_NODIR, |
| 74 |
NUMDIRS |
| 75 |
} dirtype_e; |
| 76 |
|
| 77 |
typedef int dirtype_t; |
| 78 |
|
| 79 |
static void P_NewChaseDir(mobj_t *actor); |
| 80 |
void P_ZBumpCheck(mobj_t *); // phares |
| 81 |
|
| 82 |
// |
| 83 |
// ENEMY THINKING |
| 84 |
// Enemies are allways spawned |
| 85 |
// with targetplayer = -1, threshold = 0 |
| 86 |
// Most monsters are spawned unaware of all players, |
| 87 |
// but some can be made preaware |
| 88 |
// |
| 89 |
|
| 90 |
// |
| 91 |
// Called by P_NoiseAlert. |
| 92 |
// Recursively traverse adjacent sectors, |
| 93 |
// sound blocking lines cut off traversal. |
| 94 |
// |
| 95 |
// killough 5/5/98: reformatted, cleaned up |
| 96 |
|
| 97 |
static void P_RecursiveSound(sector_t *sec, int soundblocks, mobj_t *soundtarget) |
| 98 |
{ |
| 99 |
int i; |
| 100 |
|
| 101 |
// wake up all monsters in this sector |
| 102 |
if (sec->validcount == validcount && sec->soundtraversed <= soundblocks+1) |
| 103 |
return; // already flooded |
| 104 |
|
| 105 |
sec->validcount = validcount; |
| 106 |
sec->soundtraversed = soundblocks+1; |
| 107 |
P_SetTarget(&sec->soundtarget, soundtarget); |
| 108 |
|
| 109 |
for (i=0; i<sec->linecount; i++) |
| 110 |
{ |
| 111 |
sector_t *other; |
| 112 |
line_t *check = sec->lines[i]; |
| 113 |
|
| 114 |
if (!(check->flags & ML_TWOSIDED)) |
| 115 |
continue; |
| 116 |
|
| 117 |
P_LineOpening(check, NULL); |
| 118 |
|
| 119 |
if (line_opening.range <= 0) |
| 120 |
continue; // closed door |
| 121 |
|
| 122 |
other=sides[check->sidenum[sides[check->sidenum[0]].sector==sec]].sector; |
| 123 |
|
| 124 |
if (!(check->flags & ML_SOUNDBLOCK)) |
| 125 |
P_RecursiveSound(other, soundblocks, soundtarget); |
| 126 |
else |
| 127 |
if (!soundblocks) |
| 128 |
P_RecursiveSound(other, 1, soundtarget); |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
// |
| 133 |
// P_NoiseAlert |
| 134 |
// If a monster yells at a player, |
| 135 |
// it will alert other monsters to the player. |
| 136 |
// |
| 137 |
void P_NoiseAlert(mobj_t *target, mobj_t *emitter) |
| 138 |
{ |
| 139 |
if (target != NULL && target->player && (target->player->cheats & CF_NOTARGET)) |
| 140 |
return; |
| 141 |
|
| 142 |
validcount++; |
| 143 |
P_RecursiveSound(emitter->subsector->sector, 0, target); |
| 144 |
} |
| 145 |
|
| 146 |
// |
| 147 |
// P_CheckRange |
| 148 |
// |
| 149 |
|
| 150 |
static dboolean P_CheckRange(mobj_t *actor, fixed_t range) |
| 151 |
{ |
| 152 |
mobj_t *pl = actor->target; |
| 153 |
|
| 154 |
return // killough 7/18/98: friendly monsters don't attack other friends |
| 155 |
pl && |
| 156 |
!(actor->flags & pl->flags & MF_FRIEND) && |
| 157 |
P_AproxDistance(pl->x-actor->x, pl->y-actor->y) < range && |
| 158 |
P_CheckSight(actor, actor->target) && |
| 159 |
( // finite height! |
| 160 |
!(raven || map_info.flags & MI_PASSOVER) || |
| 161 |
( |
| 162 |
pl->z <= actor->z + actor->height && |
| 163 |
actor->z <= pl->z + pl->height |
| 164 |
) |
| 165 |
); |
| 166 |
} |
| 167 |
|
| 168 |
// |
| 169 |
// P_CheckMeleeRange |
| 170 |
// |
| 171 |
|
| 172 |
static dboolean P_CheckMeleeRange(mobj_t *actor) |
| 173 |
{ |
| 174 |
int range; |
| 175 |
|
| 176 |
if (actor->subsector->sector->flags & SECF_NOATTACK) |
| 177 |
return false; |
| 178 |
|
| 179 |
range = actor->info->meleerange; |
| 180 |
|
| 181 |
if (compatibility_level != doom_12_compatibility) |
| 182 |
range += actor->target->info->radius - 20 * FRACUNIT; |
| 183 |
|
| 184 |
return P_CheckRange(actor, range); |
| 185 |
} |
| 186 |
|
| 187 |
// |
| 188 |
// P_HitFriend() |
| 189 |
// |
| 190 |
// killough 12/98 |
| 191 |
// This function tries to prevent shooting at friends |
| 192 |
|
| 193 |
static dboolean P_HitFriend(mobj_t *actor) |
| 194 |
{ |
| 195 |
return actor->flags & MF_FRIEND && actor->target && |
| 196 |
(P_AimLineAttack(actor, |
| 197 |
R_PointToAngle2(actor->x, actor->y, |
| 198 |
actor->target->x, actor->target->y), |
| 199 |
P_AproxDistance(actor->x-actor->target->x, |
| 200 |
actor->y-actor->target->y), 0), |
| 201 |
linetarget) && linetarget != actor->target && |
| 202 |
!((linetarget->flags ^ actor->flags) & MF_FRIEND); |
| 203 |
} |
| 204 |
|
| 205 |
// |
| 206 |
// P_CheckMissileRange |
| 207 |
// |
| 208 |
static dboolean P_CheckMissileRange(mobj_t *actor) |
| 209 |
{ |
| 210 |
fixed_t dist; |
| 211 |
|
| 212 |
if (actor->subsector->sector->flags & SECF_NOATTACK) |
| 213 |
return false; |
| 214 |
|
| 215 |
if (!P_CheckSight(actor, actor->target)) |
| 216 |
return false; |
| 217 |
|
| 218 |
if (actor->flags & MF_JUSTHIT) |
| 219 |
{ // the target just hit the enemy, so fight back! |
| 220 |
actor->flags &= ~MF_JUSTHIT; |
| 221 |
|
| 222 |
/* killough 7/18/98: no friendly fire at corpses |
| 223 |
* killough 11/98: prevent too much infighting among friends |
| 224 |
* cph - yikes, talk about fitting everything on one line... */ |
| 225 |
|
| 226 |
return |
| 227 |
!(actor->flags & MF_FRIEND) || |
| 228 |
(actor->target->health > 0 && |
| 229 |
(!(actor->target->flags & MF_FRIEND) || |
| 230 |
(actor->target->player ? |
| 231 |
monster_infighting || P_Random(pr_defect) >128 : |
| 232 |
!(actor->target->flags & MF_JUSTHIT) && P_Random(pr_defect) >128))); |
| 233 |
} |
| 234 |
|
| 235 |
/* killough 7/18/98: friendly monsters don't attack other friendly |
| 236 |
* monsters or players (except when attacked, and then only once) |
| 237 |
*/ |
| 238 |
if (actor->flags & actor->target->flags & MF_FRIEND) |
| 239 |
return false; |
| 240 |
|
| 241 |
if (actor->reactiontime) |
| 242 |
return false; // do not attack yet |
| 243 |
|
| 244 |
// OPTIMIZE: get this from a global checksight |
| 245 |
dist = P_AproxDistance ( actor->x-actor->target->x, |
| 246 |
actor->y-actor->target->y) - 64*FRACUNIT; |
| 247 |
|
| 248 |
if (!actor->info->meleestate) |
| 249 |
dist -= 128*FRACUNIT; // no melee attack, so fire more |
| 250 |
|
| 251 |
dist >>= FRACBITS; |
| 252 |
|
| 253 |
if (actor->flags2 & MF2_SHORTMRANGE) |
| 254 |
if (dist > 14*64) |
| 255 |
return false; // too far away |
| 256 |
|
| 257 |
if (actor->flags2 & MF2_LONGMELEE) |
| 258 |
{ |
| 259 |
if (dist < 196) |
| 260 |
return false; // close for fist attack |
| 261 |
} |
| 262 |
|
| 263 |
if (actor->flags2 & MF2_RANGEHALF) |
| 264 |
dist >>= 1; |
| 265 |
|
| 266 |
if (dist > 200) |
| 267 |
dist = 200; |
| 268 |
|
| 269 |
if (actor->flags2 & MF2_HIGHERMPROB && dist > 160) |
| 270 |
dist = 160; |
| 271 |
|
| 272 |
if (P_Random(pr_missrange) < dist) |
| 273 |
return false; |
| 274 |
|
| 275 |
if (P_HitFriend(actor)) |
| 276 |
return false; |
| 277 |
|
| 278 |
return true; |
| 279 |
} |
| 280 |
|
| 281 |
/* |
| 282 |
* P_IsOnLift |
| 283 |
* |
| 284 |
* killough 9/9/98: |
| 285 |
* |
| 286 |
* Returns true if the object is on a lift. Used for AI, |
| 287 |
* since it may indicate the need for crowded conditions, |
| 288 |
* or that a monster should stay on the lift for a while |
| 289 |
* while it goes up or down. |
| 290 |
*/ |
| 291 |
|
| 292 |
static dboolean P_IsOnLift(const mobj_t *actor) |
| 293 |
{ |
| 294 |
const sector_t *sec = actor->subsector->sector; |
| 295 |
const int *l; |
| 296 |
|
| 297 |
// Short-circuit: it's on a lift which is active. |
| 298 |
if (sec->floordata && ((thinker_t *) sec->floordata)->function==T_PlatRaise) |
| 299 |
return true; |
| 300 |
|
| 301 |
// Check to see if it's in a sector which can be activated as a lift. |
| 302 |
if (sec->tag) |
| 303 |
for (l = dsda_FindLinesFromID(sec->tag); *l >= 0; l++) |
| 304 |
switch (lines[*l].special) |
| 305 |
{ |
| 306 |
case 10: case 14: case 15: case 20: case 21: case 22: |
| 307 |
case 47: case 53: case 62: case 66: case 67: case 68: |
| 308 |
case 87: case 88: case 95: case 120: case 121: case 122: |
| 309 |
case 123: case 143: case 162: case 163: case 181: case 182: |
| 310 |
case 144: case 148: case 149: case 211: case 227: case 228: |
| 311 |
case 231: case 232: case 235: case 236: |
| 312 |
return true; |
| 313 |
} |
| 314 |
|
| 315 |
return false; |
| 316 |
} |
| 317 |
|
| 318 |
/* |
| 319 |
* P_IsUnderDamage |
| 320 |
* |
| 321 |
* killough 9/9/98: |
| 322 |
* |
| 323 |
* Returns nonzero if the object is under damage based on |
| 324 |
* their current position. Returns 1 if the damage is moderate, |
| 325 |
* -1 if it is serious. Used for AI. |
| 326 |
*/ |
| 327 |
|
| 328 |
static int P_IsUnderDamage(mobj_t *actor) |
| 329 |
{ |
| 330 |
const struct msecnode_s *seclist; |
| 331 |
const ceiling_t *cl; // Crushing ceiling |
| 332 |
int dir = 0; |
| 333 |
for (seclist=actor->touching_sectorlist; seclist; seclist=seclist->m_tnext) |
| 334 |
if ((cl = seclist->m_sector->ceilingdata) && |
| 335 |
cl->thinker.function == T_MoveCeiling) |
| 336 |
dir |= cl->direction; |
| 337 |
return dir; |
| 338 |
} |
| 339 |
|
| 340 |
// |
| 341 |
// P_Move |
| 342 |
// Move in the current direction, |
| 343 |
// returns false if the move is blocked. |
| 344 |
// |
| 345 |
|
| 346 |
static fixed_t xspeed[8] = {FRACUNIT,47000,0,-47000,-FRACUNIT,-47000,0,47000}; |
| 347 |
static fixed_t yspeed[8] = {0,47000,FRACUNIT,47000,0,-47000,-FRACUNIT,-47000}; |
| 348 |
|
| 349 |
// 1/11/98 killough: Limit removed on special lines crossed |
| 350 |
extern line_t **spechit; // New code -- killough |
| 351 |
extern int numspechit; |
| 352 |
|
| 353 |
static dboolean P_Move(mobj_t *actor, dboolean dropoff) /* killough 9/12/98 */ |
| 354 |
{ |
| 355 |
fixed_t tryx, tryy, deltax, deltay, origx, origy; |
| 356 |
dboolean try_ok; |
| 357 |
int movefactor = ORIG_FRICTION_FACTOR; // killough 10/98 |
| 358 |
int friction = ORIG_FRICTION; |
| 359 |
int speed; |
| 360 |
|
| 361 |
if (actor->flags2 & MF2_BLASTED) |
| 362 |
return true; |
| 363 |
if (actor->movedir == DI_NODIR) |
| 364 |
return false; |
| 365 |
|
| 366 |
#ifdef RANGECHECK |
| 367 |
if ((unsigned)actor->movedir >= 8) |
| 368 |
I_Error ("P_Move: Weird actor->movedir!"); |
| 369 |
#endif |
| 370 |
|
| 371 |
// killough 10/98: make monsters get affected by ice and sludge too: |
| 372 |
|
| 373 |
if (monster_friction) |
| 374 |
movefactor = P_GetMoveFactor(actor, &friction); |
| 375 |
|
| 376 |
speed = actor->info->speed; |
| 377 |
|
| 378 |
if (friction < ORIG_FRICTION && // sludge |
| 379 |
!(speed = ((ORIG_FRICTION_FACTOR - (ORIG_FRICTION_FACTOR-movefactor)/2) |
| 380 |
* speed) / ORIG_FRICTION_FACTOR)) |
| 381 |
speed = 1; // always give the monster a little bit of speed |
| 382 |
|
| 383 |
tryx = (origx = actor->x) + (deltax = speed * xspeed[actor->movedir]); |
| 384 |
tryy = (origy = actor->y) + (deltay = speed * yspeed[actor->movedir]); |
| 385 |
|
| 386 |
try_ok = P_TryMove(actor, tryx, tryy, dropoff); |
| 387 |
|
| 388 |
// killough 10/98: |
| 389 |
// Let normal momentum carry them, instead of steptoeing them across ice. |
| 390 |
|
| 391 |
if (try_ok && friction > ORIG_FRICTION) |
| 392 |
{ |
| 393 |
actor->x = origx; |
| 394 |
actor->y = origy; |
| 395 |
movefactor *= FRACUNIT / ORIG_FRICTION_FACTOR / 4; |
| 396 |
actor->momx += FixedMul(deltax, movefactor); |
| 397 |
actor->momy += FixedMul(deltay, movefactor); |
| 398 |
} |
| 399 |
|
| 400 |
// [RH] If a walking monster is no longer on the floor, move it down |
| 401 |
// to the floor if it is within MaxStepHeight, presuming that it is |
| 402 |
// actually walking down a step. |
| 403 |
if ( |
| 404 |
try_ok && |
| 405 |
map_format.zdoom && |
| 406 |
actor->z > actor->floorz && |
| 407 |
actor->z <= actor->floorz + (24 << FRACBITS) && |
| 408 |
!(actor->flags & MF_NOGRAVITY) && |
| 409 |
!(actor->flags2 & MF2_ONMOBJ)) |
| 410 |
{ |
| 411 |
fixed_t saved_z = actor->z; |
| 412 |
|
| 413 |
actor->z = actor->floorz; |
| 414 |
|
| 415 |
// Make sure that there isn't some other actor between us and |
| 416 |
// the floor we could get stuck in. The old code did not do this. |
| 417 |
if (!P_CheckPosition(actor, actor->x, actor->y)) |
| 418 |
{ |
| 419 |
actor->z = saved_z; |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
if (!try_ok) |
| 424 |
{ // open any specials |
| 425 |
int good; |
| 426 |
|
| 427 |
if (actor->flags & MF_FLOAT && floatok) |
| 428 |
{ |
| 429 |
if (actor->z < tmfloorz) // must adjust height |
| 430 |
actor->z += FLOATSPEED; |
| 431 |
else |
| 432 |
actor->z -= FLOATSPEED; |
| 433 |
|
| 434 |
actor->flags |= MF_INFLOAT; |
| 435 |
|
| 436 |
return true; |
| 437 |
} |
| 438 |
|
| 439 |
if (!numspechit) |
| 440 |
return false; |
| 441 |
|
| 442 |
actor->movedir = DI_NODIR; |
| 443 |
|
| 444 |
/* if the special is not a door that can be opened, return false |
| 445 |
* |
| 446 |
* killough 8/9/98: this is what caused monsters to get stuck in |
| 447 |
* doortracks, because it thought that the monster freed itself |
| 448 |
* by opening a door, even if it was moving towards the doortrack, |
| 449 |
* and not the door itself. |
| 450 |
* |
| 451 |
* killough 9/9/98: If a line blocking the monster is activated, |
| 452 |
* return true 90% of the time. If a line blocking the monster is |
| 453 |
* not activated, but some other line is, return false 90% of the |
| 454 |
* time. A bit of randomness is needed to ensure it's free from |
| 455 |
* lockups, but for most cases, it returns the correct result. |
| 456 |
* |
| 457 |
* Do NOT simply return false 1/4th of the time (causes monsters to |
| 458 |
* back out when they shouldn't, and creates secondary stickiness). |
| 459 |
*/ |
| 460 |
|
| 461 |
for (good = false; numspechit--; ) |
| 462 |
if (P_UseSpecialLine(actor, spechit[numspechit], 0, false)) |
| 463 |
good |= spechit[numspechit] == blockline ? 1 : 2; |
| 464 |
|
| 465 |
if (raven) return good > 0; |
| 466 |
|
| 467 |
/* cph - compatibility maze here |
| 468 |
* Boom v2.01 and orig. Doom return "good" |
| 469 |
* Boom v2.02 and LxDoom return good && (P_Random(pr_trywalk)&3) |
| 470 |
* MBF plays even more games |
| 471 |
*/ |
| 472 |
if (!good || comp[comp_doorstuck]) return good; |
| 473 |
if (!mbf_features) |
| 474 |
return (P_Random(pr_trywalk)&3); /* jff 8/13/98 */ |
| 475 |
else /* finally, MBF code */ |
| 476 |
return ((P_Random(pr_opendoor) >= 230) ^ (good & 1)); |
| 477 |
} |
| 478 |
else |
| 479 |
actor->flags &= ~MF_INFLOAT; |
| 480 |
|
| 481 |
/* killough 11/98: fall more slowly, under gravity, if felldown==true */ |
| 482 |
if (!map_format.zdoom && !(actor->flags & MF_FLOAT) && (!felldown || !mbf_features)) { |
| 483 |
if (raven && actor->z > actor->floorz) |
| 484 |
{ |
| 485 |
P_HitFloor(actor); |
| 486 |
} |
| 487 |
actor->z = actor->floorz; |
| 488 |
} |
| 489 |
|
| 490 |
return true; |
| 491 |
} |
| 492 |
|
| 493 |
/* |
| 494 |
* P_SmartMove |
| 495 |
* |
| 496 |
* killough 9/12/98: Same as P_Move, except smarter |
| 497 |
*/ |
| 498 |
|
| 499 |
static dboolean P_SmartMove(mobj_t *actor) |
| 500 |
{ |
| 501 |
mobj_t *target = actor->target; |
| 502 |
int on_lift, dropoff = false, under_damage; |
| 503 |
int tmp_monster_avoid_hazards = (prboom_comp[PC_MONSTER_AVOID_HAZARDS].state ? |
| 504 |
true : (demo_compatibility ? false : monster_avoid_hazards));//e6y |
| 505 |
|
| 506 |
/* killough 9/12/98: Stay on a lift if target is on one */ |
| 507 |
on_lift = !comp[comp_staylift] |
| 508 |
&& target && target->health > 0 |
| 509 |
&& target->subsector->sector->tag==actor->subsector->sector->tag && |
| 510 |
P_IsOnLift(actor); |
| 511 |
|
| 512 |
under_damage = tmp_monster_avoid_hazards && P_IsUnderDamage(actor);//e6y |
| 513 |
|
| 514 |
// killough 10/98: allow dogs to drop off of taller ledges sometimes. |
| 515 |
// dropoff==1 means always allow it, dropoff==2 means only up to 128 high, |
| 516 |
// and only if the target is immediately on the other side of the line. |
| 517 |
|
| 518 |
// haleyjd: allow all friends of HelperType to also jump down |
| 519 |
|
| 520 |
if ((actor->type == MT_DOGS || (actor->type == (HelperThing-1) && actor->flags&MF_FRIEND)) |
| 521 |
&& target && dog_jumping && |
| 522 |
!((target->flags ^ actor->flags) & MF_FRIEND) && |
| 523 |
P_AproxDistance(actor->x - target->x, |
| 524 |
actor->y - target->y) < FRACUNIT*144 && |
| 525 |
P_Random(pr_dropoff) < 235) |
| 526 |
dropoff = 2; |
| 527 |
|
| 528 |
if (!P_Move(actor, dropoff)) |
| 529 |
return false; |
| 530 |
|
| 531 |
// killough 9/9/98: avoid crushing ceilings or other damaging areas |
| 532 |
if ( |
| 533 |
(on_lift && P_Random(pr_stayonlift) < 230 && // Stay on lift |
| 534 |
!P_IsOnLift(actor)) |
| 535 |
|| |
| 536 |
(tmp_monster_avoid_hazards && !under_damage &&//e6y // Get away from damage |
| 537 |
(under_damage = P_IsUnderDamage(actor)) && |
| 538 |
(under_damage < 0 || P_Random(pr_avoidcrush) < 200)) |
| 539 |
) |
| 540 |
actor->movedir = DI_NODIR; // avoid the area (most of the time anyway) |
| 541 |
|
| 542 |
return true; |
| 543 |
} |
| 544 |
|
| 545 |
// |
| 546 |
// TryWalk |
| 547 |
// Attempts to move actor on |
| 548 |
// in its current (ob->moveangle) direction. |
| 549 |
// If blocked by either a wall or an actor |
| 550 |
// returns FALSE |
| 551 |
// If move is either clear or blocked only by a door, |
| 552 |
// returns TRUE and sets... |
| 553 |
// If a door is in the way, |
| 554 |
// an OpenDoor call is made to start it opening. |
| 555 |
// |
| 556 |
|
| 557 |
// HERETIC_NOTE: Quite sure P_SmartMove == P_Move for heretic |
| 558 |
static dboolean P_TryWalk(mobj_t *actor) |
| 559 |
{ |
| 560 |
if (!P_SmartMove(actor)) |
| 561 |
return false; |
| 562 |
actor->movecount = P_Random(pr_trywalk)&15; |
| 563 |
return true; |
| 564 |
} |
| 565 |
|
| 566 |
// |
| 567 |
// P_DoNewChaseDir |
| 568 |
// |
| 569 |
// killough 9/8/98: |
| 570 |
// |
| 571 |
// Most of P_NewChaseDir(), except for what |
| 572 |
// determines the new direction to take |
| 573 |
// |
| 574 |
|
| 575 |
static void P_DoNewChaseDir(mobj_t *actor, fixed_t deltax, fixed_t deltay) |
| 576 |
{ |
| 577 |
dirtype_t xdir, ydir, tdir; |
| 578 |
dirtype_t olddir = actor->movedir; |
| 579 |
dirtype_t turnaround = olddir; |
| 580 |
|
| 581 |
if (turnaround != DI_NODIR) // find reverse direction |
| 582 |
turnaround ^= 4; |
| 583 |
|
| 584 |
xdir = |
| 585 |
deltax > 10*FRACUNIT ? DI_EAST : |
| 586 |
deltax < -10*FRACUNIT ? DI_WEST : DI_NODIR; |
| 587 |
|
| 588 |
ydir = |
| 589 |
deltay < -10*FRACUNIT ? DI_SOUTH : |
| 590 |
deltay > 10*FRACUNIT ? DI_NORTH : DI_NODIR; |
| 591 |
|
| 592 |
// try direct route |
| 593 |
if (xdir != DI_NODIR && ydir != DI_NODIR && turnaround != |
| 594 |
(actor->movedir = deltay < 0 ? deltax > 0 ? DI_SOUTHEAST : DI_SOUTHWEST : |
| 595 |
deltax > 0 ? DI_NORTHEAST : DI_NORTHWEST) && P_TryWalk(actor)) |
| 596 |
return; |
| 597 |
|
| 598 |
// try other directions |
| 599 |
if (P_Random(pr_newchase) > 200 || D_abs(deltay)>D_abs(deltax)) |
| 600 |
tdir = xdir, xdir = ydir, ydir = tdir; |
| 601 |
|
| 602 |
if ((xdir == turnaround ? xdir = DI_NODIR : xdir) != DI_NODIR && |
| 603 |
(actor->movedir = xdir, P_TryWalk(actor))) |
| 604 |
return; // either moved forward or attacked |
| 605 |
|
| 606 |
if ((ydir == turnaround ? ydir = DI_NODIR : ydir) != DI_NODIR && |
| 607 |
(actor->movedir = ydir, P_TryWalk(actor))) |
| 608 |
return; |
| 609 |
|
| 610 |
// there is no direct path to the player, so pick another direction. |
| 611 |
if (olddir != DI_NODIR && (actor->movedir = olddir, P_TryWalk(actor))) |
| 612 |
return; |
| 613 |
|
| 614 |
// randomly determine direction of search |
| 615 |
if (P_Random(pr_newchasedir) & 1) |
| 616 |
{ |
| 617 |
for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; tdir++) |
| 618 |
if (tdir != turnaround && (actor->movedir = tdir, P_TryWalk(actor))) |
| 619 |
return; |
| 620 |
} |
| 621 |
else |
| 622 |
for (tdir = DI_SOUTHEAST; tdir != DI_EAST-1; tdir--) |
| 623 |
if (tdir != turnaround && (actor->movedir = tdir, P_TryWalk(actor))) |
| 624 |
return; |
| 625 |
|
| 626 |
if ((actor->movedir = turnaround) != DI_NODIR && !P_TryWalk(actor)) |
| 627 |
actor->movedir = DI_NODIR; |
| 628 |
} |
| 629 |
|
| 630 |
// |
| 631 |
// killough 11/98: |
| 632 |
// |
| 633 |
// Monsters try to move away from tall dropoffs. |
| 634 |
// |
| 635 |
// In Doom, they were never allowed to hang over dropoffs, |
| 636 |
// and would remain stuck if involuntarily forced over one. |
| 637 |
// This logic, combined with p_map.c (P_TryMove), allows |
| 638 |
// monsters to free themselves without making them tend to |
| 639 |
// hang over dropoffs. |
| 640 |
|
| 641 |
static fixed_t dropoff_deltax, dropoff_deltay, floorz; |
| 642 |
|
| 643 |
static dboolean PIT_AvoidDropoff(line_t *line) |
| 644 |
{ |
| 645 |
if (line->backsector && // Ignore one-sided linedefs |
| 646 |
tmbbox[BOXRIGHT] > line->bbox[BOXLEFT] && |
| 647 |
tmbbox[BOXLEFT] < line->bbox[BOXRIGHT] && |
| 648 |
tmbbox[BOXTOP] > line->bbox[BOXBOTTOM] && // Linedef must be contacted |
| 649 |
tmbbox[BOXBOTTOM] < line->bbox[BOXTOP] && |
| 650 |
P_BoxOnLineSide(tmbbox, line) == -1) |
| 651 |
{ |
| 652 |
fixed_t front = line->frontsector->floorheight; |
| 653 |
fixed_t back = line->backsector->floorheight; |
| 654 |
angle_t angle; |
| 655 |
|
| 656 |
// The monster must contact one of the two floors, |
| 657 |
// and the other must be a tall dropoff (more than 24). |
| 658 |
|
| 659 |
if (back == floorz && front < floorz - FRACUNIT*24) |
| 660 |
angle = R_PointToAngle2(0,0,line->dx,line->dy); // front side dropoff |
| 661 |
else |
| 662 |
if (front == floorz && back < floorz - FRACUNIT*24) |
| 663 |
angle = R_PointToAngle2(line->dx,line->dy,0,0); // back side dropoff |
| 664 |
else |
| 665 |
return true; |
| 666 |
|
| 667 |
// Move away from dropoff at a standard speed. |
| 668 |
// Multiple contacted linedefs are cumulative (e.g. hanging over corner) |
| 669 |
dropoff_deltax -= finesine[angle >> ANGLETOFINESHIFT]*32; |
| 670 |
dropoff_deltay += finecosine[angle >> ANGLETOFINESHIFT]*32; |
| 671 |
} |
| 672 |
return true; |
| 673 |
} |
| 674 |
|
| 675 |
// |
| 676 |
// Driver for above |
| 677 |
// |
| 678 |
|
| 679 |
static fixed_t P_AvoidDropoff(mobj_t *actor) |
| 680 |
{ |
| 681 |
int yh=P_GetSafeBlockY((tmbbox[BOXTOP] = actor->y+actor->radius)-bmaporgy); |
| 682 |
int yl=P_GetSafeBlockY((tmbbox[BOXBOTTOM]= actor->y-actor->radius)-bmaporgy); |
| 683 |
int xh=P_GetSafeBlockX((tmbbox[BOXRIGHT] = actor->x+actor->radius)-bmaporgx); |
| 684 |
int xl=P_GetSafeBlockX((tmbbox[BOXLEFT] = actor->x-actor->radius)-bmaporgx); |
| 685 |
int bx, by; |
| 686 |
|
| 687 |
floorz = actor->z; // remember floor height |
| 688 |
|
| 689 |
dropoff_deltax = dropoff_deltay = 0; |
| 690 |
|
| 691 |
// check lines |
| 692 |
|
| 693 |
validcount++; |
| 694 |
for (bx=xl ; bx<=xh ; bx++) |
| 695 |
for (by=yl ; by<=yh ; by++) |
| 696 |
P_BlockLinesIterator(bx, by, PIT_AvoidDropoff); // all contacted lines |
| 697 |
|
| 698 |
return dropoff_deltax | dropoff_deltay; // Non-zero if movement prescribed |
| 699 |
} |
| 700 |
|
| 701 |
// |
| 702 |
// P_NewChaseDir |
| 703 |
// |
| 704 |
// killough 9/8/98: Split into two functions |
| 705 |
// |
| 706 |
|
| 707 |
static void P_NewChaseDir(mobj_t *actor) |
| 708 |
{ |
| 709 |
mobj_t *target = actor->target; |
| 710 |
fixed_t deltax = target->x - actor->x; |
| 711 |
fixed_t deltay = target->y - actor->y; |
| 712 |
|
| 713 |
// killough 8/8/98: sometimes move away from target, keeping distance |
| 714 |
// |
| 715 |
// 1) Stay a certain distance away from a friend, to avoid being in their way |
| 716 |
// 2) Take advantage over an enemy without missiles, by keeping distance |
| 717 |
|
| 718 |
actor->strafecount = 0; |
| 719 |
|
| 720 |
if (mbf_features) { |
| 721 |
if ( |
| 722 |
actor->floorz - actor->dropoffz > FRACUNIT*24 && |
| 723 |
actor->z <= actor->floorz && |
| 724 |
!(actor->flags & (MF_DROPOFF|MF_FLOAT)) && |
| 725 |
!comp[comp_dropoff] && |
| 726 |
P_AvoidDropoff(actor) |
| 727 |
) /* Move away from dropoff */ |
| 728 |
{ |
| 729 |
P_DoNewChaseDir(actor, dropoff_deltax, dropoff_deltay); |
| 730 |
|
| 731 |
// If moving away from dropoff, set movecount to 1 so that |
| 732 |
// small steps are taken to get monster away from dropoff. |
| 733 |
|
| 734 |
actor->movecount = 1; |
| 735 |
return; |
| 736 |
} |
| 737 |
else |
| 738 |
{ |
| 739 |
fixed_t dist = P_AproxDistance(deltax, deltay); |
| 740 |
|
| 741 |
// Move away from friends when too close, except |
| 742 |
// in certain situations (e.g. a crowded lift) |
| 743 |
|
| 744 |
if (actor->flags & target->flags & MF_FRIEND && |
| 745 |
distfriend << FRACBITS > dist && |
| 746 |
!P_IsOnLift(target) && !P_IsUnderDamage(actor)) |
| 747 |
{ |
| 748 |
deltax = -deltax, deltay = -deltay; |
| 749 |
} |
| 750 |
else if (target->health > 0 && (actor->flags ^ target->flags) & MF_FRIEND) |
| 751 |
{ // Live enemy target |
| 752 |
if ( |
| 753 |
monster_backing && |
| 754 |
actor->info->missilestate && |
| 755 |
actor->type != MT_SKULL && |
| 756 |
( |
| 757 |
(!target->info->missilestate && dist < target->info->meleerange*2) || |
| 758 |
( |
| 759 |
target->player && dist < target->player->mo->info->meleerange*3 && |
| 760 |
weaponinfo[target->player->readyweapon].flags & WPF_FLEEMELEE |
| 761 |
) |
| 762 |
) |
| 763 |
) |
| 764 |
{ // Back away from melee attacker |
| 765 |
actor->strafecount = P_Random(pr_enemystrafe) & 15; |
| 766 |
deltax = -deltax, deltay = -deltay; |
| 767 |
} |
| 768 |
} |
| 769 |
} |
| 770 |
} |
| 771 |
|
| 772 |
P_DoNewChaseDir(actor, deltax, deltay); |
| 773 |
|
| 774 |
// If strafing, set movecount to strafecount so that old Doom |
| 775 |
// logic still works the same, except in the strafing part |
| 776 |
|
| 777 |
if (actor->strafecount) |
| 778 |
actor->movecount = actor->strafecount; |
| 779 |
} |
| 780 |
|
| 781 |
// |
| 782 |
// P_IsVisible |
| 783 |
// |
| 784 |
// killough 9/9/98: whether a target is visible to a monster |
| 785 |
// |
| 786 |
|
| 787 |
static dboolean P_IsVisible(mobj_t *actor, mobj_t *mo, dboolean allaround) |
| 788 |
{ |
| 789 |
if (!allaround) |
| 790 |
{ |
| 791 |
angle_t an = R_PointToAngle2(actor->x, actor->y, |
| 792 |
mo->x, mo->y) - actor->angle; |
| 793 |
if (an > ANG90 && an < ANG270 && |
| 794 |
P_AproxDistance(mo->x-actor->x, mo->y-actor->y) > WAKEUPRANGE) |
| 795 |
return false; |
| 796 |
} |
| 797 |
return P_CheckSight(actor, mo); |
| 798 |
} |
| 799 |
|
| 800 |
// |
| 801 |
// PIT_FindTarget |
| 802 |
// |
| 803 |
// killough 9/5/98 |
| 804 |
// |
| 805 |
// Finds monster targets for other monsters |
| 806 |
// |
| 807 |
|
| 808 |
static int current_allaround; |
| 809 |
|
| 810 |
static dboolean PIT_FindTarget(mobj_t *mo) |
| 811 |
{ |
| 812 |
mobj_t *actor = current_actor; |
| 813 |
|
| 814 |
if (!((mo->flags ^ actor->flags) & MF_FRIEND && // Invalid target |
| 815 |
mo->health > 0 && (mo->flags & MF_COUNTKILL || mo->type == MT_SKULL))) |
| 816 |
return true; |
| 817 |
|
| 818 |
// If the monster is already engaged in a one-on-one attack |
| 819 |
// with a healthy friend, don't attack around 60% the time |
| 820 |
{ |
| 821 |
const mobj_t *targ = mo->target; |
| 822 |
if (targ && targ->target == mo && |
| 823 |
P_Random(pr_skiptarget) > 100 && |
| 824 |
(targ->flags ^ mo->flags) & MF_FRIEND && |
| 825 |
targ->health*2 >= P_MobjSpawnHealth(targ)) |
| 826 |
return true; |
| 827 |
} |
| 828 |
|
| 829 |
if (!P_IsVisible(actor, mo, current_allaround)) |
| 830 |
return true; |
| 831 |
|
| 832 |
P_SetTarget(&actor->lastenemy, actor->target); // Remember previous target |
| 833 |
P_SetTarget(&actor->target, mo); // Found target |
| 834 |
|
| 835 |
// Move the selected monster to the end of its associated |
| 836 |
// list, so that it gets searched last next time. |
| 837 |
|
| 838 |
{ |
| 839 |
thinker_t *cap = &thinkerclasscap[mo->flags & MF_FRIEND ? |
| 840 |
th_friends : th_enemies]; |
| 841 |
(mo->thinker.cprev->cnext = mo->thinker.cnext)->cprev = mo->thinker.cprev; |
| 842 |
(mo->thinker.cprev = cap->cprev)->cnext = &mo->thinker; |
| 843 |
(mo->thinker.cnext = cap)->cprev = &mo->thinker; |
| 844 |
} |
| 845 |
|
| 846 |
return false; |
| 847 |
} |
| 848 |
|
| 849 |
// |
| 850 |
// P_LookForPlayers |
| 851 |
// If allaround is false, only look 180 degrees in front. |
| 852 |
// Returns true if a player is targeted. |
| 853 |
// |
| 854 |
|
| 855 |
static dboolean P_LookForPlayers(mobj_t *actor, dboolean allaround) |
| 856 |
{ |
| 857 |
player_t *player; |
| 858 |
int stop, stopc, c; |
| 859 |
dboolean unseen[MAX_MAXPLAYERS] = {0}; |
| 860 |
|
| 861 |
if (raven) return Raven_P_LookForPlayers(actor, allaround); |
| 862 |
|
| 863 |
if (actor->flags & MF_FRIEND) |
| 864 |
{ // killough 9/9/98: friendly monsters go about players differently |
| 865 |
int anyone; |
| 866 |
|
| 867 |
// Go back to a player, no matter whether it's visible or not |
| 868 |
for (anyone=0; anyone<=1; anyone++) |
| 869 |
for (c=0; c<g_maxplayers; c++) |
| 870 |
if (playeringame[c] && players[c].playerstate==PST_LIVE && |
| 871 |
(anyone || P_IsVisible(actor, players[c].mo, allaround))) |
| 872 |
{ |
| 873 |
P_SetTarget(&actor->target, players[c].mo); |
| 874 |
|
| 875 |
// killough 12/98: |
| 876 |
// get out of refiring loop, to avoid hitting player accidentally |
| 877 |
|
| 878 |
if (actor->info->missilestate) |
| 879 |
{ |
| 880 |
P_SetMobjState(actor, actor->info->seestate); |
| 881 |
actor->flags &= ~MF_JUSTHIT; |
| 882 |
} |
| 883 |
|
| 884 |
return true; |
| 885 |
} |
| 886 |
|
| 887 |
return false; |
| 888 |
} |
| 889 |
|
| 890 |
// Change mask of 3 to (g_maxplayers-1) -- killough 2/15/98: |
| 891 |
stop = (actor->lastlook-1)&(g_maxplayers-1); |
| 892 |
|
| 893 |
c = 0; |
| 894 |
|
| 895 |
stopc = !mbf_features && |
| 896 |
!demo_compatibility && monsters_remember ? |
| 897 |
g_maxplayers : 2; // killough 9/9/98 |
| 898 |
|
| 899 |
for (;; actor->lastlook = (actor->lastlook+1)&(g_maxplayers-1)) |
| 900 |
{ |
| 901 |
if (!playeringame[actor->lastlook]) |
| 902 |
continue; |
| 903 |
|
| 904 |
// killough 2/15/98, 9/9/98: |
| 905 |
if (c++ == stopc || actor->lastlook == stop) // done looking |
| 906 |
{ |
| 907 |
// e6y |
| 908 |
// Fixed Boom incompatibilities. The following code was missed. |
| 909 |
// There are no more desyncs on Donce's demos on horror.wad |
| 910 |
|
| 911 |
// Use last known enemy if no players sighted -- killough 2/15/98: |
| 912 |
if (!mbf_features && !demo_compatibility && monsters_remember) |
| 913 |
{ |
| 914 |
if (actor->lastenemy && actor->lastenemy->health > 0) |
| 915 |
{ |
| 916 |
actor->target = actor->lastenemy; |
| 917 |
actor->lastenemy = NULL; |
| 918 |
return true; |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
return false; |
| 923 |
} |
| 924 |
|
| 925 |
player = &players[actor->lastlook]; |
| 926 |
|
| 927 |
if (player->cheats & CF_NOTARGET) |
| 928 |
continue; // no target |
| 929 |
|
| 930 |
if (player->health <= 0) |
| 931 |
continue; // dead |
| 932 |
|
| 933 |
if (unseen[actor->lastlook] || !P_IsVisible(actor, player->mo, allaround)) |
| 934 |
{ |
| 935 |
unseen[actor->lastlook] = true; |
| 936 |
continue; |
| 937 |
} |
| 938 |
|
| 939 |
P_SetTarget(&actor->target, player->mo); |
| 940 |
|
| 941 |
/* killough 9/9/98: give monsters a threshold towards getting players |
| 942 |
* (we don't want it to be too easy for a player with dogs :) |
| 943 |
*/ |
| 944 |
if (!comp[comp_pursuit]) |
| 945 |
actor->threshold = 60; |
| 946 |
|
| 947 |
return true; |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
// |
| 952 |
// Friendly monsters, by Lee Killough 7/18/98 |
| 953 |
// |
| 954 |
// Friendly monsters go after other monsters first, but |
| 955 |
// also return to owner if they cannot find any targets. |
| 956 |
// A marine's best friend :) killough 7/18/98, 9/98 |
| 957 |
// |
| 958 |
|
| 959 |
static dboolean P_LookForMonsters(mobj_t *actor, dboolean allaround) |
| 960 |
{ |
| 961 |
thinker_t *cap, *th; |
| 962 |
|
| 963 |
if (demo_compatibility) |
| 964 |
return false; |
| 965 |
|
| 966 |
if (actor->lastenemy && actor->lastenemy->health > 0 && monsters_remember && |
| 967 |
!(actor->lastenemy->flags & actor->flags & MF_FRIEND)) // not friends |
| 968 |
{ |
| 969 |
P_SetTarget(&actor->target, actor->lastenemy); |
| 970 |
P_SetTarget(&actor->lastenemy, NULL); |
| 971 |
return true; |
| 972 |
} |
| 973 |
|
| 974 |
/* Old demos do not support monster-seeking bots */ |
| 975 |
if (!mbf_features) |
| 976 |
return false; |
| 977 |
|
| 978 |
// Search the threaded list corresponding to this object's potential targets |
| 979 |
cap = &thinkerclasscap[actor->flags & MF_FRIEND ? th_enemies : th_friends]; |
| 980 |
|
| 981 |
// Search for new enemy |
| 982 |
|
| 983 |
if (cap->cnext != cap) // Empty list? bail out early |
| 984 |
{ |
| 985 |
int x = P_GetSafeBlockX(actor->x - bmaporgx); |
| 986 |
int y = P_GetSafeBlockY(actor->y - bmaporgy); |
| 987 |
int d; |
| 988 |
|
| 989 |
current_actor = actor; |
| 990 |
current_allaround = allaround; |
| 991 |
|
| 992 |
// There is a bug in cl11+ that causes the player to get added |
| 993 |
// to the monster friend list when damaged to below 50% health. |
| 994 |
// This causes all monsters to believe friend monsters exist. |
| 995 |
// The search algorithm is expensive and massively so on maps with many monsters. |
| 996 |
// We still need to match rng calls for demo sync, but PIT_FindTarget is a no op. |
| 997 |
if (((mobj_t *) cap->cnext)->player && cap->cnext == cap->cprev) |
| 998 |
{ |
| 999 |
P_Random(pr_friends); |
| 1000 |
return false; |
| 1001 |
} |
| 1002 |
|
| 1003 |
// Search first in the immediate vicinity. |
| 1004 |
|
| 1005 |
if (!P_BlockThingsIterator(x, y, PIT_FindTarget)) |
| 1006 |
return true; |
| 1007 |
|
| 1008 |
for (d = 1; d < 5; d++) |
| 1009 |
{ |
| 1010 |
int i = 1 - d; |
| 1011 |
do |
| 1012 |
if (!P_BlockThingsIterator(x + i, y - d, PIT_FindTarget) || |
| 1013 |
!P_BlockThingsIterator(x + i, y + d, PIT_FindTarget)) |
| 1014 |
return true; |
| 1015 |
while (++i < d); |
| 1016 |
|
| 1017 |
do |
| 1018 |
if (!P_BlockThingsIterator(x - d, y + i, PIT_FindTarget) || |
| 1019 |
!P_BlockThingsIterator(x + d, y + i, PIT_FindTarget)) |
| 1020 |
return true; |
| 1021 |
while (--i + d >= 0); |
| 1022 |
} |
| 1023 |
|
| 1024 |
{ // Random number of monsters, to prevent patterns from forming |
| 1025 |
int n = (P_Random(pr_friends) & 31) + 15; |
| 1026 |
|
| 1027 |
for (th = cap->cnext; th != cap; th = th->cnext) |
| 1028 |
if (--n < 0) |
| 1029 |
{ |
| 1030 |
// Only a subset of the monsters were searched. Move all of |
| 1031 |
// the ones which were searched so far, to the end of the list. |
| 1032 |
|
| 1033 |
(cap->cnext->cprev = cap->cprev)->cnext = cap->cnext; |
| 1034 |
(cap->cprev = th->cprev)->cnext = cap; |
| 1035 |
(th->cprev = cap)->cnext = th; |
| 1036 |
break; |
| 1037 |
} |
| 1038 |
else |
| 1039 |
if (!PIT_FindTarget((mobj_t *) th)) // If target sighted |
| 1040 |
return true; |
| 1041 |
} |
| 1042 |
} |
| 1043 |
|
| 1044 |
return false; // No monster found |
| 1045 |
} |
| 1046 |
|
| 1047 |
// |
| 1048 |
// P_LookForTargets |
| 1049 |
// |
| 1050 |
// killough 9/5/98: look for targets to go after, depending on kind of monster |
| 1051 |
// |
| 1052 |
|
| 1053 |
static dboolean P_LookForTargets(mobj_t *actor, int allaround) |
| 1054 |
{ |
| 1055 |
return actor->flags & MF_FRIEND ? |
| 1056 |
P_LookForMonsters(actor, allaround) || P_LookForPlayers (actor, allaround): |
| 1057 |
P_LookForPlayers (actor, allaround) || P_LookForMonsters(actor, allaround); |
| 1058 |
} |
| 1059 |
|
| 1060 |
// |
| 1061 |
// P_HelpFriend |
| 1062 |
// |
| 1063 |
// killough 9/8/98: Help friends in danger of dying |
| 1064 |
// |
| 1065 |
|
| 1066 |
static dboolean P_HelpFriend(mobj_t *actor) |
| 1067 |
{ |
| 1068 |
thinker_t *cap, *th; |
| 1069 |
|
| 1070 |
// If less than 33% health, self-preservation rules |
| 1071 |
if (actor->health*3 < P_MobjSpawnHealth(actor)) |
| 1072 |
return false; |
| 1073 |
|
| 1074 |
current_actor = actor; |
| 1075 |
current_allaround = true; |
| 1076 |
|
| 1077 |
// Possibly help a friend under 50% health |
| 1078 |
cap = &thinkerclasscap[actor->flags & MF_FRIEND ? th_friends : th_enemies]; |
| 1079 |
|
| 1080 |
for (th = cap->cnext; th != cap; th = th->cnext) |
| 1081 |
if (((mobj_t *) th)->health*2 >= P_MobjSpawnHealth((mobj_t *) th)) |
| 1082 |
{ |
| 1083 |
if (P_Random(pr_helpfriend) < 180) |
| 1084 |
break; |
| 1085 |
} |
| 1086 |
else |
| 1087 |
if (((mobj_t *) th)->flags & MF_JUSTHIT && |
| 1088 |
((mobj_t *) th)->target && |
| 1089 |
((mobj_t *) th)->target != actor->target && |
| 1090 |
!PIT_FindTarget(((mobj_t *) th)->target)) |
| 1091 |
{ |
| 1092 |
// Ignore any attacking monsters, while searching for friend |
| 1093 |
actor->threshold = BASETHRESHOLD; |
| 1094 |
return true; |
| 1095 |
} |
| 1096 |
|
| 1097 |
return false; |
| 1098 |
} |
| 1099 |
|
| 1100 |
// |
| 1101 |
// A_KeenDie |
| 1102 |
// DOOM II special, map 32. |
| 1103 |
// Uses special tag 666. |
| 1104 |
// |
| 1105 |
void A_KeenDie(mobj_t* mo) |
| 1106 |
{ |
| 1107 |
thinker_t *th; |
| 1108 |
line_t junk; |
| 1109 |
|
| 1110 |
A_Fall(mo); |
| 1111 |
|
| 1112 |
// scan the remaining thinkers to see if all Keens are dead |
| 1113 |
|
| 1114 |
for (th = thinkercap.next ; th != &thinkercap ; th=th->next) |
| 1115 |
if (th->function == P_MobjThinker) |
| 1116 |
{ |
| 1117 |
mobj_t *mo2 = (mobj_t *) th; |
| 1118 |
if (mo2 != mo && mo2->type == mo->type && mo2->health > 0) |
| 1119 |
return; // other Keen not dead |
| 1120 |
} |
| 1121 |
|
| 1122 |
junk.tag = 666; |
| 1123 |
EV_DoDoor(&junk,openDoor); |
| 1124 |
} |
| 1125 |
|
| 1126 |
|
| 1127 |
// |
| 1128 |
// ACTION ROUTINES |
| 1129 |
// |
| 1130 |
|
| 1131 |
// |
| 1132 |
// A_Look |
| 1133 |
// Stay in state until a player is sighted. |
| 1134 |
// |
| 1135 |
|
| 1136 |
void A_Look(mobj_t *actor) |
| 1137 |
{ |
| 1138 |
mobj_t *targ = actor->subsector->sector->soundtarget; |
| 1139 |
actor->threshold = 0; // any shot will wake up |
| 1140 |
|
| 1141 |
if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) |
| 1142 |
return; |
| 1143 |
|
| 1144 |
/* killough 7/18/98: |
| 1145 |
* Friendly monsters go after other monsters first, but |
| 1146 |
* also return to player, without attacking them, if they |
| 1147 |
* cannot find any targets. A marine's best friend :) |
| 1148 |
*/ |
| 1149 |
actor->pursuecount = 0; |
| 1150 |
|
| 1151 |
if ( |
| 1152 |
!(actor->flags & MF_FRIEND && P_LookForTargets(actor, false)) && |
| 1153 |
!( |
| 1154 |
(targ = actor->subsector->sector->soundtarget) && |
| 1155 |
targ->flags & MF_SHOOTABLE && |
| 1156 |
( |
| 1157 |
P_SetTarget(&actor->target, targ), |
| 1158 |
!(actor->flags & MF_AMBUSH) || |
| 1159 |
P_CheckSight(actor, targ) |
| 1160 |
) |
| 1161 |
) && |
| 1162 |
( |
| 1163 |
actor->flags & MF_FRIEND || !P_LookForTargets(actor, false) |
| 1164 |
) |
| 1165 |
) |
| 1166 |
return; |
| 1167 |
|
| 1168 |
// go into chase state |
| 1169 |
|
| 1170 |
if (actor->info->seesound) |
| 1171 |
{ |
| 1172 |
int sound; |
| 1173 |
sound = actor->info->seesound; |
| 1174 |
|
| 1175 |
if (!raven) |
| 1176 |
switch (sound) |
| 1177 |
{ |
| 1178 |
case sfx_posit1: |
| 1179 |
case sfx_posit2: |
| 1180 |
case sfx_posit3: |
| 1181 |
sound = sfx_posit1 + P_Random(pr_see) % 3; |
| 1182 |
break; |
| 1183 |
|
| 1184 |
case sfx_bgsit1: |
| 1185 |
case sfx_bgsit2: |
| 1186 |
sound = sfx_bgsit1 + P_Random(pr_see) % 2; |
| 1187 |
break; |
| 1188 |
|
| 1189 |
default: |
| 1190 |
break; |
| 1191 |
} |
| 1192 |
|
| 1193 |
if (actor->flags2 & (MF2_BOSS | MF2_FULLVOLSOUNDS)) |
| 1194 |
S_StartVoidSound(sound); // full volume |
| 1195 |
else |
| 1196 |
{ |
| 1197 |
S_StartMobjSound(actor, sound); |
| 1198 |
|
| 1199 |
// [FG] make seesounds uninterruptible |
| 1200 |
if (full_sounds) |
| 1201 |
S_UnlinkSound(actor); |
| 1202 |
} |
| 1203 |
} |
| 1204 |
P_SetMobjState(actor, actor->info->seestate); |
| 1205 |
} |
| 1206 |
|
| 1207 |
// |
| 1208 |
// A_KeepChasing |
| 1209 |
// |
| 1210 |
// killough 10/98: |
| 1211 |
// Allows monsters to continue movement while attacking |
| 1212 |
// |
| 1213 |
|
| 1214 |
static void A_KeepChasing(mobj_t *actor) |
| 1215 |
{ |
| 1216 |
if (actor->movecount) |
| 1217 |
{ |
| 1218 |
actor->movecount--; |
| 1219 |
if (actor->strafecount) |
| 1220 |
actor->strafecount--; |
| 1221 |
P_SmartMove(actor); |
| 1222 |
} |
| 1223 |
} |
| 1224 |
|
| 1225 |
// |
| 1226 |
// A_Chase |
| 1227 |
// Actor has a melee attack, |
| 1228 |
// so it tries to close as fast as possible |
| 1229 |
// |
| 1230 |
|
| 1231 |
void A_Chase(mobj_t *actor) |
| 1232 |
{ |
| 1233 |
if (actor->reactiontime) |
| 1234 |
actor->reactiontime--; |
| 1235 |
|
| 1236 |
if (actor->threshold) { /* modify target threshold */ |
| 1237 |
if (compatibility_level == doom_12_compatibility) |
| 1238 |
{ |
| 1239 |
actor->threshold--; |
| 1240 |
} |
| 1241 |
else |
| 1242 |
{ |
| 1243 |
if (!actor->target || actor->target->health <= 0) |
| 1244 |
actor->threshold = 0; |
| 1245 |
else |
| 1246 |
actor->threshold--; |
| 1247 |
} |
| 1248 |
} |
| 1249 |
|
| 1250 |
if (raven && skill_info.flags & SI_FAST_MONSTERS) |
| 1251 |
{ // Monsters move faster in nightmare mode |
| 1252 |
actor->tics -= actor->tics / 2; |
| 1253 |
if (actor->tics < 3) |
| 1254 |
{ |
| 1255 |
actor->tics = 3; |
| 1256 |
} |
| 1257 |
} |
| 1258 |
|
| 1259 |
/* turn towards movement direction if not there yet |
| 1260 |
* killough 9/7/98: keep facing towards target if strafing or backing out |
| 1261 |
*/ |
| 1262 |
|
| 1263 |
if (actor->strafecount) |
| 1264 |
A_FaceTarget(actor); |
| 1265 |
else if (actor->movedir < 8) |
| 1266 |
{ |
| 1267 |
int delta = (actor->angle &= (7<<29)) - (actor->movedir << 29); |
| 1268 |
if (delta > 0) |
| 1269 |
actor->angle -= ANG90/2; |
| 1270 |
else |
| 1271 |
if (delta < 0) |
| 1272 |
actor->angle += ANG90/2; |
| 1273 |
} |
| 1274 |
|
| 1275 |
if (!actor->target || !(actor->target->flags&MF_SHOOTABLE)) |
| 1276 |
{ |
| 1277 |
if (!P_LookForTargets(actor,true)) // look for a new target |
| 1278 |
P_SetMobjState(actor, actor->info->spawnstate); // no new target |
| 1279 |
return; |
| 1280 |
} |
| 1281 |
|
| 1282 |
// do not attack twice in a row |
| 1283 |
if (actor->flags & MF_JUSTATTACKED) |
| 1284 |
{ |
| 1285 |
actor->flags &= ~MF_JUSTATTACKED; |
| 1286 |
if (!(skill_info.flags & SI_FAST_MONSTERS)) |
| 1287 |
P_NewChaseDir(actor); |
| 1288 |
return; |
| 1289 |
} |
| 1290 |
|
| 1291 |
// check for melee attack |
| 1292 |
if (actor->info->meleestate && P_CheckMeleeRange(actor)) |
| 1293 |
{ |
| 1294 |
if (actor->info->attacksound) |
| 1295 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 1296 |
P_SetMobjState(actor, actor->info->meleestate); |
| 1297 |
/* killough 8/98: remember an attack |
| 1298 |
* cph - DEMOSYNC? */ |
| 1299 |
if (!actor->info->missilestate && !raven) |
| 1300 |
actor->flags |= MF_JUSTHIT; |
| 1301 |
return; |
| 1302 |
} |
| 1303 |
|
| 1304 |
// check for missile attack |
| 1305 |
if (actor->info->missilestate) |
| 1306 |
if (!(!(skill_info.flags & SI_FAST_MONSTERS) && actor->movecount)) |
| 1307 |
if (P_CheckMissileRange(actor)) |
| 1308 |
{ |
| 1309 |
P_SetMobjState(actor, actor->info->missilestate); |
| 1310 |
actor->flags |= MF_JUSTATTACKED; |
| 1311 |
return; |
| 1312 |
} |
| 1313 |
|
| 1314 |
if (!actor->threshold) { |
| 1315 |
if (!mbf_features) |
| 1316 |
{ /* killough 9/9/98: for backward demo compatibility */ |
| 1317 |
if (netgame && !P_CheckSight(actor, actor->target) && |
| 1318 |
P_LookForPlayers(actor, true)) |
| 1319 |
return; |
| 1320 |
} |
| 1321 |
/* killough 7/18/98, 9/9/98: new monster AI */ |
| 1322 |
else if (help_friends && P_HelpFriend(actor)) |
| 1323 |
return; /* killough 9/8/98: Help friends in need */ |
| 1324 |
/* Look for new targets if current one is bad or is out of view */ |
| 1325 |
else if (actor->pursuecount) |
| 1326 |
actor->pursuecount--; |
| 1327 |
else { |
| 1328 |
/* Our pursuit time has expired. We're going to think about |
| 1329 |
* changing targets */ |
| 1330 |
actor->pursuecount = BASETHRESHOLD; |
| 1331 |
|
| 1332 |
// look for new target, unless conditions are met |
| 1333 |
if ( |
| 1334 |
!( |
| 1335 |
actor->target && // have a target |
| 1336 |
actor->target->health > 0 && // and the target is alive |
| 1337 |
( |
| 1338 |
(comp[comp_pursuit] && !netgame) || // and using old pursuit behaviour |
| 1339 |
( |
| 1340 |
( // or the target is not friendly |
| 1341 |
(actor->target->flags ^ actor->flags) & MF_FRIEND || |
| 1342 |
(!(actor->flags & MF_FRIEND) && monster_infighting) |
| 1343 |
) && |
| 1344 |
P_CheckSight(actor, actor->target) // and we can see it |
| 1345 |
) |
| 1346 |
) |
| 1347 |
) && |
| 1348 |
P_LookForTargets(actor, true) |
| 1349 |
) |
| 1350 |
return; |
| 1351 |
|
| 1352 |
/* (Current target was good, or no new target was found.) |
| 1353 |
* |
| 1354 |
* If monster is a missile-less friend, give up pursuit and |
| 1355 |
* return to player, if no attacks have occurred recently. |
| 1356 |
*/ |
| 1357 |
|
| 1358 |
if (!actor->info->missilestate && actor->flags & MF_FRIEND) { |
| 1359 |
if (actor->flags & MF_JUSTHIT) /* if recent action, */ |
| 1360 |
actor->flags &= ~MF_JUSTHIT; /* keep fighting */ |
| 1361 |
else if (P_LookForPlayers(actor, true)) /* else return to player */ |
| 1362 |
return; |
| 1363 |
} |
| 1364 |
} |
| 1365 |
} |
| 1366 |
|
| 1367 |
if (actor->strafecount) |
| 1368 |
actor->strafecount--; |
| 1369 |
|
| 1370 |
// chase towards player |
| 1371 |
if (--actor->movecount < 0 || !P_SmartMove(actor)) |
| 1372 |
P_NewChaseDir(actor); |
| 1373 |
|
| 1374 |
// make active sound |
| 1375 |
if (actor->info->activesound && P_Random(pr_see) < 3) |
| 1376 |
{ |
| 1377 |
if (heretic && actor->type == HERETIC_MT_WIZARD && P_Random(pr_heretic) < 128) |
| 1378 |
{ |
| 1379 |
S_StartMobjSound(actor, actor->info->seesound); |
| 1380 |
} |
| 1381 |
else if (heretic && actor->type == HERETIC_MT_SORCERER2) |
| 1382 |
{ |
| 1383 |
S_StartVoidSound(actor->info->activesound); |
| 1384 |
} |
| 1385 |
else if (hexen && actor->type == HEXEN_MT_BISHOP && P_Random(pr_hexen) < 128) |
| 1386 |
{ |
| 1387 |
S_StartMobjSound(actor, actor->info->seesound); |
| 1388 |
} |
| 1389 |
else if (hexen && actor->type == HEXEN_MT_PIG) |
| 1390 |
{ |
| 1391 |
S_StartMobjSound(actor, hexen_sfx_pig_active1 + (P_Random(pr_hexen) & 1)); |
| 1392 |
} |
| 1393 |
else if (hexen && actor->flags2 & MF2_BOSS) |
| 1394 |
{ |
| 1395 |
S_StartVoidSound(actor->info->activesound); |
| 1396 |
} |
| 1397 |
else |
| 1398 |
{ |
| 1399 |
S_StartMobjSound(actor, actor->info->activesound); |
| 1400 |
} |
| 1401 |
} |
| 1402 |
} |
| 1403 |
|
| 1404 |
// |
| 1405 |
// A_FaceTarget |
| 1406 |
// |
| 1407 |
void A_FaceTarget(mobj_t *actor) |
| 1408 |
{ |
| 1409 |
if (!actor->target) |
| 1410 |
return; |
| 1411 |
actor->flags &= ~MF_AMBUSH; |
| 1412 |
actor->angle = R_PointToAngle2(actor->x, actor->y, |
| 1413 |
actor->target->x, actor->target->y); |
| 1414 |
if (actor->target->flags & MF_SHADOW) |
| 1415 |
{ // killough 5/5/98: remove dependence on order of evaluation: |
| 1416 |
int t = P_Random(pr_facetarget); |
| 1417 |
actor->angle += (t-P_Random(pr_facetarget))<<21; |
| 1418 |
} |
| 1419 |
} |
| 1420 |
|
| 1421 |
// |
| 1422 |
// A_PosAttack |
| 1423 |
// |
| 1424 |
|
| 1425 |
void A_PosAttack(mobj_t *actor) |
| 1426 |
{ |
| 1427 |
int angle, damage, slope, t; |
| 1428 |
|
| 1429 |
if (!actor->target) |
| 1430 |
return; |
| 1431 |
A_FaceTarget(actor); |
| 1432 |
angle = actor->angle; |
| 1433 |
slope = P_AimLineAttack(actor, angle, MISSILERANGE, 0); /* killough 8/2/98 */ |
| 1434 |
S_StartMobjSound(actor, sfx_pistol); |
| 1435 |
|
| 1436 |
// killough 5/5/98: remove dependence on order of evaluation: |
| 1437 |
t = P_Random(pr_posattack); |
| 1438 |
angle += (t - P_Random(pr_posattack))<<20; |
| 1439 |
damage = (P_Random(pr_posattack)%5 + 1)*3; |
| 1440 |
P_LineAttack(actor, angle, MISSILERANGE, slope, damage); |
| 1441 |
} |
| 1442 |
|
| 1443 |
void A_SPosAttack(mobj_t* actor) |
| 1444 |
{ |
| 1445 |
int i, bangle, slope; |
| 1446 |
|
| 1447 |
if (!actor->target) |
| 1448 |
return; |
| 1449 |
S_StartMobjSound(actor, sfx_shotgn); |
| 1450 |
A_FaceTarget(actor); |
| 1451 |
bangle = actor->angle; |
| 1452 |
slope = P_AimLineAttack(actor, bangle, MISSILERANGE, 0); /* killough 8/2/98 */ |
| 1453 |
for (i=0; i<3; i++) |
| 1454 |
{ // killough 5/5/98: remove dependence on order of evaluation: |
| 1455 |
int t = P_Random(pr_sposattack); |
| 1456 |
int angle = bangle + ((t - P_Random(pr_sposattack))<<20); |
| 1457 |
int damage = ((P_Random(pr_sposattack)%5)+1)*3; |
| 1458 |
P_LineAttack(actor, angle, MISSILERANGE, slope, damage); |
| 1459 |
} |
| 1460 |
} |
| 1461 |
|
| 1462 |
void A_CPosAttack(mobj_t *actor) |
| 1463 |
{ |
| 1464 |
int angle, bangle, damage, slope, t; |
| 1465 |
|
| 1466 |
if (!actor->target) |
| 1467 |
return; |
| 1468 |
S_StartMobjSound(actor, sfx_shotgn); |
| 1469 |
A_FaceTarget(actor); |
| 1470 |
bangle = actor->angle; |
| 1471 |
slope = P_AimLineAttack(actor, bangle, MISSILERANGE, 0); /* killough 8/2/98 */ |
| 1472 |
|
| 1473 |
// killough 5/5/98: remove dependence on order of evaluation: |
| 1474 |
t = P_Random(pr_cposattack); |
| 1475 |
angle = bangle + ((t - P_Random(pr_cposattack))<<20); |
| 1476 |
damage = ((P_Random(pr_cposattack)%5)+1)*3; |
| 1477 |
P_LineAttack(actor, angle, MISSILERANGE, slope, damage); |
| 1478 |
} |
| 1479 |
|
| 1480 |
void A_CPosRefire(mobj_t *actor) |
| 1481 |
{ |
| 1482 |
// keep firing unless target got out of sight |
| 1483 |
A_FaceTarget(actor); |
| 1484 |
|
| 1485 |
/* killough 12/98: Stop firing if a friend has gotten in the way */ |
| 1486 |
if (P_HitFriend(actor)) |
| 1487 |
goto stop; |
| 1488 |
|
| 1489 |
/* killough 11/98: prevent refiring on friends continuously */ |
| 1490 |
if (P_Random(pr_cposrefire) < 40) { |
| 1491 |
if (actor->target && actor->flags & actor->target->flags & MF_FRIEND) |
| 1492 |
goto stop; |
| 1493 |
else |
| 1494 |
return; |
| 1495 |
} |
| 1496 |
|
| 1497 |
if (!actor->target || actor->target->health <= 0 |
| 1498 |
|| !P_CheckSight(actor, actor->target)) |
| 1499 |
stop: P_SetMobjState(actor, actor->info->seestate); |
| 1500 |
} |
| 1501 |
|
| 1502 |
void A_SpidRefire(mobj_t* actor) |
| 1503 |
{ |
| 1504 |
// keep firing unless target got out of sight |
| 1505 |
A_FaceTarget(actor); |
| 1506 |
|
| 1507 |
/* killough 12/98: Stop firing if a friend has gotten in the way */ |
| 1508 |
if (P_HitFriend(actor)) |
| 1509 |
goto stop; |
| 1510 |
|
| 1511 |
if (P_Random(pr_spidrefire) < 10) |
| 1512 |
return; |
| 1513 |
|
| 1514 |
// killough 11/98: prevent refiring on friends continuously |
| 1515 |
if (!actor->target || actor->target->health <= 0 |
| 1516 |
|| actor->flags & actor->target->flags & MF_FRIEND |
| 1517 |
|| !P_CheckSight(actor, actor->target)) |
| 1518 |
stop: P_SetMobjState(actor, actor->info->seestate); |
| 1519 |
} |
| 1520 |
|
| 1521 |
void A_BspiAttack(mobj_t *actor) |
| 1522 |
{ |
| 1523 |
if (!actor->target) |
| 1524 |
return; |
| 1525 |
A_FaceTarget(actor); |
| 1526 |
P_SpawnMissile(actor, actor->target, MT_ARACHPLAZ); // launch a missile |
| 1527 |
} |
| 1528 |
|
| 1529 |
// |
| 1530 |
// A_TroopAttack |
| 1531 |
// |
| 1532 |
|
| 1533 |
void A_TroopAttack(mobj_t *actor) |
| 1534 |
{ |
| 1535 |
if (!actor->target) |
| 1536 |
return; |
| 1537 |
A_FaceTarget(actor); |
| 1538 |
if (P_CheckMeleeRange(actor)) |
| 1539 |
{ |
| 1540 |
int damage; |
| 1541 |
S_StartMobjSound(actor, sfx_claw); |
| 1542 |
damage = (P_Random(pr_troopattack)%8+1)*3; |
| 1543 |
P_DamageMobj(actor->target, actor, actor, damage); |
| 1544 |
return; |
| 1545 |
} |
| 1546 |
P_SpawnMissile(actor, actor->target, MT_TROOPSHOT); // launch a missile |
| 1547 |
} |
| 1548 |
|
| 1549 |
void A_SargAttack(mobj_t *actor) |
| 1550 |
{ |
| 1551 |
if (!actor->target) |
| 1552 |
return; |
| 1553 |
A_FaceTarget(actor); |
| 1554 |
if (compatibility_level == doom_12_compatibility) |
| 1555 |
{ |
| 1556 |
int damage = ((P_Random(pr_sargattack)%10)+1)*4; |
| 1557 |
P_LineAttack(actor, actor->angle, MELEERANGE, 0, damage); |
| 1558 |
} |
| 1559 |
else |
| 1560 |
{ |
| 1561 |
if (P_CheckMeleeRange(actor)) |
| 1562 |
{ |
| 1563 |
int damage = ((P_Random(pr_sargattack)%10)+1)*4; |
| 1564 |
P_DamageMobj(actor->target, actor, actor, damage); |
| 1565 |
} |
| 1566 |
} |
| 1567 |
} |
| 1568 |
|
| 1569 |
void A_HeadAttack(mobj_t * actor) |
| 1570 |
{ |
| 1571 |
int i; |
| 1572 |
mobj_t *fire; |
| 1573 |
mobj_t *baseFire; |
| 1574 |
mobj_t *mo; |
| 1575 |
mobj_t *target; |
| 1576 |
int randAttack; |
| 1577 |
static int atkResolve1[] = { 50, 150 }; |
| 1578 |
static int atkResolve2[] = { 150, 200 }; |
| 1579 |
int dist; |
| 1580 |
|
| 1581 |
// Ice ball (close 20% : far 60%) |
| 1582 |
// Fire column (close 40% : far 20%) |
| 1583 |
// Whirlwind (close 40% : far 20%) |
| 1584 |
// Distance threshold = 8 cells |
| 1585 |
|
| 1586 |
target = actor->target; |
| 1587 |
if (target == NULL) return; |
| 1588 |
|
| 1589 |
A_FaceTarget(actor); |
| 1590 |
|
| 1591 |
if (P_CheckMeleeRange(actor)) |
| 1592 |
{ |
| 1593 |
int damage = heretic ? HITDICE(6) : (P_Random(pr_headattack) % 6 + 1) * 10; |
| 1594 |
P_DamageMobj(target, actor, actor, damage); |
| 1595 |
return; |
| 1596 |
} |
| 1597 |
|
| 1598 |
if (!heretic) { |
| 1599 |
P_SpawnMissile(actor, target, MT_HEADSHOT); |
| 1600 |
return; |
| 1601 |
} |
| 1602 |
|
| 1603 |
dist = P_AproxDistance(actor->x - target->x, actor->y - target->y) |
| 1604 |
> 8 * 64 * FRACUNIT; |
| 1605 |
randAttack = P_Random(pr_heretic); |
| 1606 |
if (randAttack < atkResolve1[dist]) |
| 1607 |
{ // Ice ball |
| 1608 |
P_SpawnMissile(actor, target, HERETIC_MT_HEADFX1); |
| 1609 |
S_StartMobjSound(actor, heretic_sfx_hedat2); |
| 1610 |
} |
| 1611 |
else if (randAttack < atkResolve2[dist]) |
| 1612 |
{ // Fire column |
| 1613 |
baseFire = P_SpawnMissile(actor, target, HERETIC_MT_HEADFX3); |
| 1614 |
if (baseFire != NULL) |
| 1615 |
{ |
| 1616 |
P_SetMobjState(baseFire, HERETIC_S_HEADFX3_4); // Don't grow |
| 1617 |
for (i = 0; i < 5; i++) |
| 1618 |
{ |
| 1619 |
fire = P_SpawnMobj(baseFire->x, baseFire->y, |
| 1620 |
baseFire->z, HERETIC_MT_HEADFX3); |
| 1621 |
if (i == 0) |
| 1622 |
{ |
| 1623 |
S_StartMobjSound(actor, heretic_sfx_hedat1); |
| 1624 |
} |
| 1625 |
P_SetTarget(&fire->target, baseFire->target); |
| 1626 |
fire->angle = baseFire->angle; |
| 1627 |
fire->momx = baseFire->momx; |
| 1628 |
fire->momy = baseFire->momy; |
| 1629 |
fire->momz = baseFire->momz; |
| 1630 |
fire->damage = 0; |
| 1631 |
fire->health = (i + 1) * 2; |
| 1632 |
P_CheckMissileSpawn(fire); |
| 1633 |
} |
| 1634 |
} |
| 1635 |
} |
| 1636 |
else |
| 1637 |
{ // Whirlwind |
| 1638 |
mo = P_SpawnMissile(actor, target, HERETIC_MT_WHIRLWIND); |
| 1639 |
if (mo != NULL) |
| 1640 |
{ |
| 1641 |
mo->z -= 32 * FRACUNIT; |
| 1642 |
P_SetTarget(&mo->special1.m, target); |
| 1643 |
mo->special2.i = 50; // Timer for active sound |
| 1644 |
mo->health = 20 * TICRATE; // Duration |
| 1645 |
S_StartMobjSound(actor, heretic_sfx_hedat3); |
| 1646 |
} |
| 1647 |
} |
| 1648 |
} |
| 1649 |
|
| 1650 |
void A_CyberAttack(mobj_t *actor) |
| 1651 |
{ |
| 1652 |
if (!actor->target) |
| 1653 |
return; |
| 1654 |
A_FaceTarget(actor); |
| 1655 |
P_SpawnMissile(actor, actor->target, MT_ROCKET); |
| 1656 |
} |
| 1657 |
|
| 1658 |
void A_BruisAttack(mobj_t *actor) |
| 1659 |
{ |
| 1660 |
if (!actor->target) |
| 1661 |
return; |
| 1662 |
if (P_CheckMeleeRange(actor)) |
| 1663 |
{ |
| 1664 |
int damage; |
| 1665 |
S_StartMobjSound(actor, sfx_claw); |
| 1666 |
damage = (P_Random(pr_bruisattack)%8+1)*10; |
| 1667 |
P_DamageMobj(actor->target, actor, actor, damage); |
| 1668 |
return; |
| 1669 |
} |
| 1670 |
P_SpawnMissile(actor, actor->target, MT_BRUISERSHOT); // launch a missile |
| 1671 |
} |
| 1672 |
|
| 1673 |
// |
| 1674 |
// A_SkelMissile |
| 1675 |
// |
| 1676 |
|
| 1677 |
void A_SkelMissile(mobj_t *actor) |
| 1678 |
{ |
| 1679 |
mobj_t *mo; |
| 1680 |
|
| 1681 |
if (!actor->target) |
| 1682 |
return; |
| 1683 |
|
| 1684 |
A_FaceTarget (actor); |
| 1685 |
actor->z += 16*FRACUNIT; // so missile spawns higher |
| 1686 |
mo = P_SpawnMissile (actor, actor->target, MT_TRACER); |
| 1687 |
actor->z -= 16*FRACUNIT; // back to normal |
| 1688 |
|
| 1689 |
mo->x += mo->momx; |
| 1690 |
mo->y += mo->momy; |
| 1691 |
P_SetTarget(&mo->tracer, actor->target); |
| 1692 |
} |
| 1693 |
|
| 1694 |
int TRACEANGLE = 0xc000000; |
| 1695 |
|
| 1696 |
void A_Tracer(mobj_t *actor) |
| 1697 |
{ |
| 1698 |
angle_t exact; |
| 1699 |
fixed_t dist; |
| 1700 |
fixed_t slope; |
| 1701 |
mobj_t *dest; |
| 1702 |
mobj_t *th; |
| 1703 |
|
| 1704 |
/* killough 1/18/98: this is why some missiles do not have smoke |
| 1705 |
* and some do. Also, internal demos start at random gametics, thus |
| 1706 |
* the bug in which revenants cause internal demos to go out of sync. |
| 1707 |
* |
| 1708 |
* killough 3/6/98: fix revenant internal demo bug by subtracting |
| 1709 |
* levelstarttic from gametic. |
| 1710 |
* |
| 1711 |
* killough 9/29/98: use new "basetic" so that demos stay in sync |
| 1712 |
* during pauses and menu activations, while retaining old demo sync. |
| 1713 |
* |
| 1714 |
* leveltime would have been better to use to start with in Doom, but |
| 1715 |
* since old demos were recorded using gametic, we must stick with it, |
| 1716 |
* and improvise around it (using leveltime causes desync across levels). |
| 1717 |
*/ |
| 1718 |
|
| 1719 |
if (boom_logictic & 3) |
| 1720 |
return; |
| 1721 |
|
| 1722 |
// spawn a puff of smoke behind the rocket |
| 1723 |
P_SpawnPuff(actor->x, actor->y, actor->z); |
| 1724 |
|
| 1725 |
th = P_SpawnMobj (actor->x-actor->momx, |
| 1726 |
actor->y-actor->momy, |
| 1727 |
actor->z, MT_SMOKE); |
| 1728 |
|
| 1729 |
th->momz = FRACUNIT; |
| 1730 |
th->tics -= P_Random(pr_tracer) & 3; |
| 1731 |
if (th->tics < 1) |
| 1732 |
th->tics = 1; |
| 1733 |
|
| 1734 |
// adjust direction |
| 1735 |
dest = actor->tracer; |
| 1736 |
|
| 1737 |
if (!dest || dest->health <= 0) |
| 1738 |
return; |
| 1739 |
|
| 1740 |
// change angle |
| 1741 |
exact = R_PointToAngle2(actor->x, actor->y, dest->x, dest->y); |
| 1742 |
|
| 1743 |
if (exact != actor->angle) { |
| 1744 |
if (exact - actor->angle > 0x80000000) |
| 1745 |
{ |
| 1746 |
actor->angle -= TRACEANGLE; |
| 1747 |
if (exact - actor->angle < 0x80000000) |
| 1748 |
actor->angle = exact; |
| 1749 |
} |
| 1750 |
else |
| 1751 |
{ |
| 1752 |
actor->angle += TRACEANGLE; |
| 1753 |
if (exact - actor->angle > 0x80000000) |
| 1754 |
actor->angle = exact; |
| 1755 |
} |
| 1756 |
} |
| 1757 |
|
| 1758 |
exact = actor->angle>>ANGLETOFINESHIFT; |
| 1759 |
actor->momx = FixedMul(actor->info->speed, finecosine[exact]); |
| 1760 |
actor->momy = FixedMul(actor->info->speed, finesine[exact]); |
| 1761 |
|
| 1762 |
// change slope |
| 1763 |
dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); |
| 1764 |
|
| 1765 |
dist = dist / actor->info->speed; |
| 1766 |
|
| 1767 |
if (dist < 1) |
| 1768 |
dist = 1; |
| 1769 |
|
| 1770 |
slope = (dest->z+40*FRACUNIT - actor->z) / dist; |
| 1771 |
|
| 1772 |
if (slope < actor->momz) |
| 1773 |
actor->momz -= FRACUNIT/8; |
| 1774 |
else |
| 1775 |
actor->momz += FRACUNIT/8; |
| 1776 |
} |
| 1777 |
|
| 1778 |
void A_SkelWhoosh(mobj_t *actor) |
| 1779 |
{ |
| 1780 |
if (!actor->target) |
| 1781 |
return; |
| 1782 |
A_FaceTarget(actor); |
| 1783 |
S_StartMobjSound(actor,sfx_skeswg); |
| 1784 |
} |
| 1785 |
|
| 1786 |
void A_SkelFist(mobj_t *actor) |
| 1787 |
{ |
| 1788 |
if (!actor->target) |
| 1789 |
return; |
| 1790 |
A_FaceTarget(actor); |
| 1791 |
if (P_CheckMeleeRange(actor)) |
| 1792 |
{ |
| 1793 |
int damage = ((P_Random(pr_skelfist)%10)+1)*6; |
| 1794 |
S_StartMobjSound(actor, sfx_skepch); |
| 1795 |
P_DamageMobj(actor->target, actor, actor, damage); |
| 1796 |
} |
| 1797 |
} |
| 1798 |
|
| 1799 |
// |
| 1800 |
// PIT_VileCheck |
| 1801 |
// Detect a corpse that could be raised. |
| 1802 |
// |
| 1803 |
|
| 1804 |
mobj_t* corpsehit; |
| 1805 |
mobj_t* vileobj; |
| 1806 |
fixed_t viletryx; |
| 1807 |
fixed_t viletryy; |
| 1808 |
int viletryradius; |
| 1809 |
|
| 1810 |
static dboolean PIT_VileCheck(mobj_t *thing) |
| 1811 |
{ |
| 1812 |
int maxdist; |
| 1813 |
dboolean check; |
| 1814 |
|
| 1815 |
if (!(thing->flags & MF_CORPSE) ) |
| 1816 |
return true; // not a monster |
| 1817 |
|
| 1818 |
if (thing->tics != -1) |
| 1819 |
return true; // not lying still yet |
| 1820 |
|
| 1821 |
if (thing->info->raisestate == g_s_null) |
| 1822 |
return true; // monster doesn't have a raise state |
| 1823 |
|
| 1824 |
maxdist = thing->info->radius + viletryradius; |
| 1825 |
|
| 1826 |
if (D_abs(thing->x-viletryx) > maxdist || D_abs(thing->y-viletryy) > maxdist) |
| 1827 |
return true; // not actually touching |
| 1828 |
|
| 1829 |
// Check to see if the radius and height are zero. If they are // phares |
| 1830 |
// then this is a crushed monster that has been turned into a // | |
| 1831 |
// gib. One of the options may be to ignore this guy. // V |
| 1832 |
|
| 1833 |
// Option 1: the original, buggy method, -> ghost (compatibility) |
| 1834 |
// Option 2: ressurect the monster, but not as a ghost |
| 1835 |
// Option 3: ignore the gib |
| 1836 |
|
| 1837 |
// if (Option3) // ^ |
| 1838 |
// if ((thing->height == 0) && (thing->radius == 0)) // | |
| 1839 |
// return true; // phares |
| 1840 |
|
| 1841 |
corpsehit = thing; |
| 1842 |
corpsehit->momx = corpsehit->momy = 0; |
| 1843 |
if (comp[comp_vile]) // phares |
| 1844 |
{ // | |
| 1845 |
corpsehit->height <<= 2; // V |
| 1846 |
check = P_CheckPosition(corpsehit,corpsehit->x,corpsehit->y); |
| 1847 |
corpsehit->height >>= 2; |
| 1848 |
} |
| 1849 |
else |
| 1850 |
{ |
| 1851 |
int height,radius; |
| 1852 |
|
| 1853 |
height = corpsehit->height; // save temporarily |
| 1854 |
radius = corpsehit->radius; // save temporarily |
| 1855 |
corpsehit->height = corpsehit->info->height; |
| 1856 |
corpsehit->radius = corpsehit->info->radius; |
| 1857 |
corpsehit->flags |= MF_SOLID; |
| 1858 |
check = P_CheckPosition(corpsehit,corpsehit->x,corpsehit->y); |
| 1859 |
corpsehit->height = height; // restore |
| 1860 |
corpsehit->radius = radius; // restore // ^ |
| 1861 |
corpsehit->flags &= ~MF_SOLID; |
| 1862 |
} // | |
| 1863 |
// phares |
| 1864 |
if (!check) |
| 1865 |
return true; // doesn't fit here |
| 1866 |
return false; // got one, so stop checking |
| 1867 |
} |
| 1868 |
|
| 1869 |
dboolean P_RaiseThing(mobj_t *corpse, mobj_t *raiser) |
| 1870 |
{ |
| 1871 |
uint64_t oldflags; |
| 1872 |
fixed_t oldheight, oldradius; |
| 1873 |
mobjinfo_t *info; |
| 1874 |
|
| 1875 |
if (!(corpse->flags & MF_CORPSE)) |
| 1876 |
return false; |
| 1877 |
|
| 1878 |
info = corpse->info; |
| 1879 |
|
| 1880 |
if (info->raisestate == g_s_null) |
| 1881 |
return false; |
| 1882 |
|
| 1883 |
corpse->momx = 0; |
| 1884 |
corpse->momy = 0; |
| 1885 |
|
| 1886 |
oldheight = corpse->height; |
| 1887 |
oldradius = corpse->radius; |
| 1888 |
oldflags = corpse->flags; |
| 1889 |
|
| 1890 |
corpse->height = info->height; |
| 1891 |
corpse->radius = info->radius; |
| 1892 |
corpse->flags |= MF_SOLID; |
| 1893 |
|
| 1894 |
if (!P_CheckPosition(corpse, corpse->x, corpse->y)) |
| 1895 |
{ |
| 1896 |
corpse->height = oldheight; |
| 1897 |
corpse->radius = oldradius; |
| 1898 |
corpse->flags = oldflags; |
| 1899 |
return false; |
| 1900 |
} |
| 1901 |
|
| 1902 |
S_StartMobjSound(corpse, sfx_slop); |
| 1903 |
|
| 1904 |
P_SetMobjState(corpse, info->raisestate); |
| 1905 |
|
| 1906 |
corpse->flags = info->flags; |
| 1907 |
corpse->flags |= MF_RESSURECTED; |
| 1908 |
corpse->flags &= ~MF_JUSTHIT; |
| 1909 |
|
| 1910 |
if (raiser) |
| 1911 |
{ |
| 1912 |
corpse->flags = (corpse->flags & ~MF_FRIEND) | (raiser->flags & MF_FRIEND); |
| 1913 |
} |
| 1914 |
|
| 1915 |
dsda_WatchResurrection(corpse, raiser); |
| 1916 |
|
| 1917 |
// Allow ghost monsters to be rendered translucent |
| 1918 |
if (corpse->height == 0 && corpse->radius == 0 |
| 1919 |
&& dsda_IntConfig(dsda_config_translucent_ghosts)) |
| 1920 |
corpse->flags |= MF_TRANSLUCENT; |
| 1921 |
|
| 1922 |
if (!((corpse->flags ^ MF_COUNTKILL) & (MF_FRIEND | MF_COUNTKILL))) |
| 1923 |
totallive++; |
| 1924 |
|
| 1925 |
corpse->health = P_MobjSpawnHealth(corpse); |
| 1926 |
corpse->color = 0; |
| 1927 |
P_SetTarget(&corpse->target, NULL); |
| 1928 |
P_SetTarget(&corpse->lastenemy, NULL); |
| 1929 |
|
| 1930 |
P_UpdateThinker(&corpse->thinker); |
| 1931 |
|
| 1932 |
return true; |
| 1933 |
} |
| 1934 |
|
| 1935 |
// |
| 1936 |
// P_HealCorpse |
| 1937 |
// Check for ressurecting a body |
| 1938 |
// |
| 1939 |
|
| 1940 |
static dboolean P_HealCorpse(mobj_t* actor, int radius, statenum_t healstate, sfxenum_t healsound) |
| 1941 |
{ |
| 1942 |
int xl, xh; |
| 1943 |
int yl, yh; |
| 1944 |
int bx, by; |
| 1945 |
|
| 1946 |
if (actor->movedir != DI_NODIR) |
| 1947 |
{ |
| 1948 |
// check for corpses to raise |
| 1949 |
viletryx = |
| 1950 |
actor->x + actor->info->speed*xspeed[actor->movedir]; |
| 1951 |
viletryy = |
| 1952 |
actor->y + actor->info->speed*yspeed[actor->movedir]; |
| 1953 |
|
| 1954 |
xl = P_GetSafeBlockX(viletryx - bmaporgx - MAXRADIUS*2); |
| 1955 |
xh = P_GetSafeBlockX(viletryx - bmaporgx + MAXRADIUS*2); |
| 1956 |
yl = P_GetSafeBlockY(viletryy - bmaporgy - MAXRADIUS*2); |
| 1957 |
yh = P_GetSafeBlockY(viletryy - bmaporgy + MAXRADIUS*2); |
| 1958 |
|
| 1959 |
vileobj = actor; |
| 1960 |
viletryradius = radius; |
| 1961 |
for (bx=xl ; bx<=xh ; bx++) |
| 1962 |
{ |
| 1963 |
for (by=yl ; by<=yh ; by++) |
| 1964 |
{ |
| 1965 |
// Call PIT_VileCheck to check |
| 1966 |
// whether object is a corpse |
| 1967 |
// that canbe raised. |
| 1968 |
if (!P_BlockThingsIterator(bx,by,PIT_VileCheck)) |
| 1969 |
{ |
| 1970 |
mobjinfo_t *info; |
| 1971 |
|
| 1972 |
// got one! |
| 1973 |
mobj_t* temp = actor->target; |
| 1974 |
actor->target = corpsehit; |
| 1975 |
A_FaceTarget(actor); |
| 1976 |
actor->target = temp; |
| 1977 |
|
| 1978 |
P_SetMobjState(actor, healstate); |
| 1979 |
S_StartMobjSound(corpsehit, healsound); |
| 1980 |
info = corpsehit->info; |
| 1981 |
|
| 1982 |
P_SetMobjState(corpsehit,info->raisestate); |
| 1983 |
|
| 1984 |
if (comp[comp_vile]) // phares |
| 1985 |
corpsehit->height <<= 2; // | |
| 1986 |
else // V |
| 1987 |
{ |
| 1988 |
corpsehit->height = info->height; // fix Ghost bug |
| 1989 |
corpsehit->radius = info->radius; // fix Ghost bug |
| 1990 |
} // phares |
| 1991 |
|
| 1992 |
/* killough 7/18/98: |
| 1993 |
* friendliness is transferred from AV to raised corpse |
| 1994 |
*/ |
| 1995 |
corpsehit->flags = |
| 1996 |
(info->flags & ~MF_FRIEND) | (actor->flags & MF_FRIEND); |
| 1997 |
corpsehit->flags = corpsehit->flags | MF_RESSURECTED;//e6y |
| 1998 |
|
| 1999 |
dsda_WatchResurrection(corpsehit, actor); |
| 2000 |
|
| 2001 |
// Allow ghost monsters to be rendered translucent |
| 2002 |
if (corpsehit->height == 0 && corpsehit->radius == 0 |
| 2003 |
&& dsda_IntConfig(dsda_config_translucent_ghosts)) |
| 2004 |
corpsehit->flags |= MF_TRANSLUCENT; |
| 2005 |
|
| 2006 |
if (!((corpsehit->flags ^ MF_COUNTKILL) & (MF_FRIEND | MF_COUNTKILL))) |
| 2007 |
totallive++; |
| 2008 |
|
| 2009 |
corpsehit->health = P_MobjSpawnHealth(corpsehit); |
| 2010 |
corpsehit->color = 0; |
| 2011 |
P_SetTarget(&corpsehit->target, NULL); // killough 11/98 |
| 2012 |
|
| 2013 |
if (mbf_features) |
| 2014 |
{ /* kilough 9/9/98 */ |
| 2015 |
P_SetTarget(&corpsehit->lastenemy, NULL); |
| 2016 |
corpsehit->flags &= ~MF_JUSTHIT; |
| 2017 |
} |
| 2018 |
|
| 2019 |
/* killough 8/29/98: add to appropriate thread */ |
| 2020 |
P_UpdateThinker(&corpsehit->thinker); |
| 2021 |
|
| 2022 |
return true; |
| 2023 |
} |
| 2024 |
} |
| 2025 |
} |
| 2026 |
} |
| 2027 |
return false; |
| 2028 |
} |
| 2029 |
|
| 2030 |
// |
| 2031 |
// A_VileChase |
| 2032 |
// |
| 2033 |
|
| 2034 |
void A_VileChase(mobj_t* actor) |
| 2035 |
{ |
| 2036 |
if (!P_HealCorpse(actor, mobjinfo[MT_VILE].radius, S_VILE_HEAL1, sfx_slop)) |
| 2037 |
A_Chase(actor); // Return to normal attack. |
| 2038 |
} |
| 2039 |
|
| 2040 |
// |
| 2041 |
// A_VileStart |
| 2042 |
// |
| 2043 |
|
| 2044 |
void A_VileStart(mobj_t *actor) |
| 2045 |
{ |
| 2046 |
S_StartMobjSound(actor, sfx_vilatk); |
| 2047 |
} |
| 2048 |
|
| 2049 |
// |
| 2050 |
// A_Fire |
| 2051 |
// Keep fire in front of player unless out of sight |
| 2052 |
// |
| 2053 |
|
| 2054 |
void A_StartFire(mobj_t *actor) |
| 2055 |
{ |
| 2056 |
S_StartMobjSound(actor,sfx_flamst); |
| 2057 |
A_Fire(actor); |
| 2058 |
} |
| 2059 |
|
| 2060 |
void A_FireCrackle(mobj_t* actor) |
| 2061 |
{ |
| 2062 |
S_StartMobjSound(actor,sfx_flame); |
| 2063 |
A_Fire(actor); |
| 2064 |
} |
| 2065 |
|
| 2066 |
void A_Fire(mobj_t *actor) |
| 2067 |
{ |
| 2068 |
mobj_t* target; |
| 2069 |
unsigned an; |
| 2070 |
mobj_t *dest = actor->tracer; |
| 2071 |
|
| 2072 |
if (!dest) |
| 2073 |
return; |
| 2074 |
|
| 2075 |
target = P_SubstNullMobj(actor->target); |
| 2076 |
|
| 2077 |
// don't move it if the vile lost sight |
| 2078 |
if (!P_CheckSight(target, dest) ) |
| 2079 |
return; |
| 2080 |
|
| 2081 |
an = dest->angle >> ANGLETOFINESHIFT; |
| 2082 |
|
| 2083 |
P_UnsetThingPosition(actor); |
| 2084 |
actor->x = dest->x + FixedMul(24*FRACUNIT, finecosine[an]); |
| 2085 |
actor->y = dest->y + FixedMul(24*FRACUNIT, finesine[an]); |
| 2086 |
actor->z = dest->z; |
| 2087 |
P_SetThingPosition(actor); |
| 2088 |
} |
| 2089 |
|
| 2090 |
// |
| 2091 |
// A_VileTarget |
| 2092 |
// Spawn the hellfire |
| 2093 |
// |
| 2094 |
|
| 2095 |
void A_VileTarget(mobj_t *actor) |
| 2096 |
{ |
| 2097 |
mobj_t *fog; |
| 2098 |
|
| 2099 |
if (!actor->target) |
| 2100 |
return; |
| 2101 |
|
| 2102 |
A_FaceTarget(actor); |
| 2103 |
|
| 2104 |
// killough 12/98: fix Vile fog coordinates // CPhipps - compatibility optioned |
| 2105 |
fog = P_SpawnMobj(actor->target->x, |
| 2106 |
(compatibility_level < lxdoom_1_compatibility) ? actor->target->x : actor->target->y, |
| 2107 |
actor->target->z,MT_FIRE); |
| 2108 |
|
| 2109 |
P_SetTarget(&actor->tracer, fog); |
| 2110 |
P_SetTarget(&fog->target, actor); |
| 2111 |
P_SetTarget(&fog->tracer, actor->target); |
| 2112 |
A_Fire(fog); |
| 2113 |
} |
| 2114 |
|
| 2115 |
// |
| 2116 |
// A_VileAttack |
| 2117 |
// |
| 2118 |
|
| 2119 |
void A_VileAttack(mobj_t *actor) |
| 2120 |
{ |
| 2121 |
mobj_t *fire; |
| 2122 |
int an; |
| 2123 |
|
| 2124 |
if (!actor->target) |
| 2125 |
return; |
| 2126 |
|
| 2127 |
A_FaceTarget(actor); |
| 2128 |
|
| 2129 |
if (!P_CheckSight(actor, actor->target)) |
| 2130 |
return; |
| 2131 |
|
| 2132 |
S_StartMobjSound(actor, sfx_barexp); |
| 2133 |
P_DamageMobj(actor->target, actor, actor, 20); |
| 2134 |
actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; |
| 2135 |
|
| 2136 |
an = actor->angle >> ANGLETOFINESHIFT; |
| 2137 |
|
| 2138 |
fire = actor->tracer; |
| 2139 |
|
| 2140 |
if (!fire) |
| 2141 |
return; |
| 2142 |
|
| 2143 |
// move the fire between the vile and the player |
| 2144 |
fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]); |
| 2145 |
fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]); |
| 2146 |
P_RadiusAttack(fire, actor, 70, 70, BF_DAMAGESOURCE | BF_HORIZONTAL); |
| 2147 |
} |
| 2148 |
|
| 2149 |
// |
| 2150 |
// Mancubus attack, |
| 2151 |
// firing three missiles (bruisers) |
| 2152 |
// in three different directions? |
| 2153 |
// Doesn't look like it. |
| 2154 |
// |
| 2155 |
|
| 2156 |
#define FATSPREAD (ANG90/8) |
| 2157 |
|
| 2158 |
void A_FatRaise(mobj_t *actor) |
| 2159 |
{ |
| 2160 |
A_FaceTarget(actor); |
| 2161 |
S_StartMobjSound(actor, sfx_manatk); |
| 2162 |
} |
| 2163 |
|
| 2164 |
void A_FatAttack1(mobj_t *actor) |
| 2165 |
{ |
| 2166 |
mobj_t *mo; |
| 2167 |
mobj_t* target; |
| 2168 |
int an; |
| 2169 |
|
| 2170 |
if (!actor->target) |
| 2171 |
return; |
| 2172 |
|
| 2173 |
A_FaceTarget(actor); |
| 2174 |
|
| 2175 |
// Change direction to ... |
| 2176 |
actor->angle += FATSPREAD; |
| 2177 |
target = P_SubstNullMobj(actor->target); |
| 2178 |
P_SpawnMissile(actor, target, MT_FATSHOT); |
| 2179 |
|
| 2180 |
mo = P_SpawnMissile (actor, target, MT_FATSHOT); |
| 2181 |
mo->angle += FATSPREAD; |
| 2182 |
an = mo->angle >> ANGLETOFINESHIFT; |
| 2183 |
mo->momx = FixedMul(mo->info->speed, finecosine[an]); |
| 2184 |
mo->momy = FixedMul(mo->info->speed, finesine[an]); |
| 2185 |
} |
| 2186 |
|
| 2187 |
void A_FatAttack2(mobj_t *actor) |
| 2188 |
{ |
| 2189 |
mobj_t *mo; |
| 2190 |
mobj_t* target; |
| 2191 |
int an; |
| 2192 |
|
| 2193 |
if (!actor->target) |
| 2194 |
return; |
| 2195 |
|
| 2196 |
A_FaceTarget(actor); |
| 2197 |
// Now here choose opposite deviation. |
| 2198 |
actor->angle -= FATSPREAD; |
| 2199 |
target = P_SubstNullMobj(actor->target); |
| 2200 |
P_SpawnMissile(actor, target, MT_FATSHOT); |
| 2201 |
|
| 2202 |
mo = P_SpawnMissile(actor, target, MT_FATSHOT); |
| 2203 |
mo->angle -= FATSPREAD*2; |
| 2204 |
an = mo->angle >> ANGLETOFINESHIFT; |
| 2205 |
mo->momx = FixedMul(mo->info->speed, finecosine[an]); |
| 2206 |
mo->momy = FixedMul(mo->info->speed, finesine[an]); |
| 2207 |
} |
| 2208 |
|
| 2209 |
void A_FatAttack3(mobj_t *actor) |
| 2210 |
{ |
| 2211 |
mobj_t *mo; |
| 2212 |
mobj_t* target; |
| 2213 |
int an; |
| 2214 |
|
| 2215 |
if (!actor->target) |
| 2216 |
return; |
| 2217 |
|
| 2218 |
A_FaceTarget(actor); |
| 2219 |
|
| 2220 |
target = P_SubstNullMobj(actor->target); |
| 2221 |
|
| 2222 |
mo = P_SpawnMissile(actor, target, MT_FATSHOT); |
| 2223 |
mo->angle -= FATSPREAD/2; |
| 2224 |
an = mo->angle >> ANGLETOFINESHIFT; |
| 2225 |
mo->momx = FixedMul(mo->info->speed, finecosine[an]); |
| 2226 |
mo->momy = FixedMul(mo->info->speed, finesine[an]); |
| 2227 |
|
| 2228 |
mo = P_SpawnMissile(actor, target, MT_FATSHOT); |
| 2229 |
mo->angle += FATSPREAD/2; |
| 2230 |
an = mo->angle >> ANGLETOFINESHIFT; |
| 2231 |
mo->momx = FixedMul(mo->info->speed, finecosine[an]); |
| 2232 |
mo->momy = FixedMul(mo->info->speed, finesine[an]); |
| 2233 |
} |
| 2234 |
|
| 2235 |
|
| 2236 |
// |
| 2237 |
// SkullAttack |
| 2238 |
// Fly at the player like a missile. |
| 2239 |
// |
| 2240 |
#define SKULLSPEED (20*FRACUNIT) |
| 2241 |
|
| 2242 |
void A_SkullAttack(mobj_t *actor) |
| 2243 |
{ |
| 2244 |
mobj_t *dest; |
| 2245 |
angle_t an; |
| 2246 |
int dist; |
| 2247 |
|
| 2248 |
if (!actor->target) |
| 2249 |
return; |
| 2250 |
|
| 2251 |
dest = actor->target; |
| 2252 |
actor->flags |= MF_SKULLFLY; |
| 2253 |
|
| 2254 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 2255 |
A_FaceTarget(actor); |
| 2256 |
an = actor->angle >> ANGLETOFINESHIFT; |
| 2257 |
actor->momx = FixedMul(SKULLSPEED, finecosine[an]); |
| 2258 |
actor->momy = FixedMul(SKULLSPEED, finesine[an]); |
| 2259 |
dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); |
| 2260 |
dist = dist / SKULLSPEED; |
| 2261 |
|
| 2262 |
if (dist < 1) |
| 2263 |
dist = 1; |
| 2264 |
actor->momz = (dest->z+(dest->height>>1) - actor->z) / dist; |
| 2265 |
} |
| 2266 |
|
| 2267 |
void A_BetaSkullAttack(mobj_t *actor) |
| 2268 |
{ |
| 2269 |
int damage; |
| 2270 |
|
| 2271 |
if (compatibility_level < mbf_compatibility) |
| 2272 |
return; |
| 2273 |
|
| 2274 |
if (!actor->target || actor->target->type == MT_SKULL) |
| 2275 |
return; |
| 2276 |
|
| 2277 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 2278 |
A_FaceTarget(actor); |
| 2279 |
damage = (P_Random(pr_skullfly)%8+1)*actor->info->damage; |
| 2280 |
P_DamageMobj(actor->target, actor, actor, damage); |
| 2281 |
} |
| 2282 |
|
| 2283 |
void A_Stop(mobj_t *actor) |
| 2284 |
{ |
| 2285 |
if (compatibility_level < mbf_compatibility) |
| 2286 |
return; |
| 2287 |
|
| 2288 |
actor->momx = actor->momy = actor->momz = 0; |
| 2289 |
} |
| 2290 |
|
| 2291 |
// |
| 2292 |
// A_PainShootSkull |
| 2293 |
// Spawn a lost soul and launch it at the target |
| 2294 |
// |
| 2295 |
|
| 2296 |
static void A_PainShootSkull(mobj_t *actor, angle_t angle) |
| 2297 |
{ |
| 2298 |
fixed_t x,y,z; |
| 2299 |
mobj_t *newmobj; |
| 2300 |
angle_t an; |
| 2301 |
int prestep; |
| 2302 |
|
| 2303 |
// The original code checked for 20 skulls on the level, // phares |
| 2304 |
// and wouldn't spit another one if there were. If not in // phares |
| 2305 |
// compatibility mode, we remove the limit. // phares |
| 2306 |
// phares |
| 2307 |
if (comp[comp_pain]) /* killough 10/98: compatibility-optioned */ |
| 2308 |
{ |
| 2309 |
// count total number of skulls currently on the level |
| 2310 |
int count = 0; |
| 2311 |
thinker_t *currentthinker = NULL; |
| 2312 |
while ((currentthinker = P_NextThinker(currentthinker,th_all)) != NULL) |
| 2313 |
if ((currentthinker->function == P_MobjThinker) |
| 2314 |
&& ((mobj_t *)currentthinker)->type == MT_SKULL) |
| 2315 |
count++; |
| 2316 |
if (count > 20) // phares |
| 2317 |
return; // phares |
| 2318 |
} |
| 2319 |
|
| 2320 |
// okay, there's room for another one |
| 2321 |
|
| 2322 |
an = angle >> ANGLETOFINESHIFT; |
| 2323 |
|
| 2324 |
prestep = 4*FRACUNIT + 3*(actor->info->radius + mobjinfo[MT_SKULL].radius)/2; |
| 2325 |
|
| 2326 |
x = actor->x + FixedMul(prestep, finecosine[an]); |
| 2327 |
y = actor->y + FixedMul(prestep, finesine[an]); |
| 2328 |
z = actor->z + 8*FRACUNIT; |
| 2329 |
|
| 2330 |
if (comp[comp_skull]) /* killough 10/98: compatibility-optioned */ |
| 2331 |
newmobj = P_SpawnMobj(x, y, z, MT_SKULL); // phares |
| 2332 |
else // V |
| 2333 |
{ |
| 2334 |
// Check whether the Lost Soul is being fired through a 1-sided |
| 2335 |
// wall or an impassible line, or a "monsters can't cross" line. |
| 2336 |
// If it is, then we don't allow the spawn. This is a bug fix, but |
| 2337 |
// it should be considered an enhancement, since it may disturb |
| 2338 |
// existing demos, so don't do it in compatibility mode. |
| 2339 |
|
| 2340 |
if (Check_Sides(actor,x,y)) |
| 2341 |
return; |
| 2342 |
|
| 2343 |
newmobj = P_SpawnMobj(x, y, z, MT_SKULL); |
| 2344 |
|
| 2345 |
// Check to see if the new Lost Soul's z value is above the |
| 2346 |
// ceiling of its new sector, or below the floor. If so, kill it. |
| 2347 |
|
| 2348 |
if ((newmobj->z > |
| 2349 |
(newmobj->subsector->sector->ceilingheight - newmobj->height)) || |
| 2350 |
(newmobj->z < newmobj->subsector->sector->floorheight)) |
| 2351 |
{ |
| 2352 |
// kill it immediately |
| 2353 |
P_DamageMobj(newmobj,actor,actor,10000); |
| 2354 |
return; // ^ |
| 2355 |
} // | |
| 2356 |
} // phares |
| 2357 |
|
| 2358 |
/* killough 7/20/98: PEs shoot lost souls with the same friendliness */ |
| 2359 |
newmobj->flags = (newmobj->flags & ~MF_FRIEND) | (actor->flags & MF_FRIEND); |
| 2360 |
|
| 2361 |
/* killough 8/29/98: add to appropriate thread */ |
| 2362 |
P_UpdateThinker(&newmobj->thinker); |
| 2363 |
|
| 2364 |
// Check for movements. |
| 2365 |
// killough 3/15/98: don't jump over dropoffs: |
| 2366 |
|
| 2367 |
if (!P_TryMove(newmobj, newmobj->x, newmobj->y, false)) |
| 2368 |
{ |
| 2369 |
// kill it immediately |
| 2370 |
P_DamageMobj(newmobj, actor, actor, 10000); |
| 2371 |
return; |
| 2372 |
} |
| 2373 |
|
| 2374 |
P_SetTarget(&newmobj->target, actor->target); |
| 2375 |
A_SkullAttack(newmobj); |
| 2376 |
} |
| 2377 |
|
| 2378 |
// |
| 2379 |
// A_PainAttack |
| 2380 |
// Spawn a lost soul and launch it at the target |
| 2381 |
// |
| 2382 |
|
| 2383 |
void A_PainAttack(mobj_t *actor) |
| 2384 |
{ |
| 2385 |
if (!actor->target) |
| 2386 |
return; |
| 2387 |
A_FaceTarget(actor); |
| 2388 |
A_PainShootSkull(actor, actor->angle); |
| 2389 |
} |
| 2390 |
|
| 2391 |
void A_PainDie(mobj_t *actor) |
| 2392 |
{ |
| 2393 |
A_Fall(actor); |
| 2394 |
A_PainShootSkull(actor, actor->angle+ANG90); |
| 2395 |
A_PainShootSkull(actor, actor->angle+ANG180); |
| 2396 |
A_PainShootSkull(actor, actor->angle+ANG270); |
| 2397 |
} |
| 2398 |
|
| 2399 |
void Heretic_A_Scream(mobj_t *actor); |
| 2400 |
void Hexen_A_Scream(mobj_t *actor); |
| 2401 |
|
| 2402 |
void A_Scream(mobj_t *actor) |
| 2403 |
{ |
| 2404 |
int sound; |
| 2405 |
|
| 2406 |
if (heretic) return Heretic_A_Scream(actor); |
| 2407 |
if (hexen) return Hexen_A_Scream(actor); |
| 2408 |
|
| 2409 |
switch (actor->info->deathsound) |
| 2410 |
{ |
| 2411 |
case 0: |
| 2412 |
return; |
| 2413 |
|
| 2414 |
case sfx_podth1: |
| 2415 |
case sfx_podth2: |
| 2416 |
case sfx_podth3: |
| 2417 |
sound = sfx_podth1 + P_Random(pr_scream)%3; |
| 2418 |
break; |
| 2419 |
|
| 2420 |
case sfx_bgdth1: |
| 2421 |
case sfx_bgdth2: |
| 2422 |
sound = sfx_bgdth1 + P_Random(pr_scream)%2; |
| 2423 |
break; |
| 2424 |
|
| 2425 |
default: |
| 2426 |
sound = actor->info->deathsound; |
| 2427 |
break; |
| 2428 |
} |
| 2429 |
|
| 2430 |
// Check for bosses. |
| 2431 |
if (actor->flags2 & (MF2_BOSS | MF2_FULLVOLSOUNDS)) |
| 2432 |
S_StartVoidSound(sound); // full volume |
| 2433 |
else |
| 2434 |
S_StartMobjSound(actor, sound); |
| 2435 |
} |
| 2436 |
|
| 2437 |
void A_XScream(mobj_t *actor) |
| 2438 |
{ |
| 2439 |
S_StartMobjSound(actor, sfx_slop); |
| 2440 |
} |
| 2441 |
|
| 2442 |
void A_SkullPop(mobj_t *actor) |
| 2443 |
{ |
| 2444 |
mobj_t *mo; |
| 2445 |
player_t *player; |
| 2446 |
|
| 2447 |
if (hexen && !actor->player) |
| 2448 |
{ |
| 2449 |
return; |
| 2450 |
} |
| 2451 |
|
| 2452 |
actor->flags &= ~MF_SOLID; |
| 2453 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 48 * FRACUNIT, g_skullpop_mt); |
| 2454 |
//mo->target = actor; |
| 2455 |
mo->momx = P_SubRandom() << 9; |
| 2456 |
mo->momy = P_SubRandom() << 9; |
| 2457 |
mo->momz = FRACUNIT * 2 + (P_Random(pr_heretic) << 6); |
| 2458 |
// Attach player mobj to bloody skull |
| 2459 |
player = actor->player; |
| 2460 |
actor->player = NULL; |
| 2461 |
if (hexen) |
| 2462 |
actor->special1.i = player->pclass; |
| 2463 |
mo->player = player; |
| 2464 |
mo->health = actor->health; |
| 2465 |
mo->angle = actor->angle; |
| 2466 |
mo->pitch = 0; |
| 2467 |
if (player) |
| 2468 |
{ |
| 2469 |
player->mo = mo; |
| 2470 |
player->lookdir = 0; |
| 2471 |
player->damagecount = 32; |
| 2472 |
} |
| 2473 |
} |
| 2474 |
|
| 2475 |
void A_Pain(mobj_t *actor) |
| 2476 |
{ |
| 2477 |
if (actor->info->painsound) |
| 2478 |
S_StartMobjSound(actor, actor->info->painsound); |
| 2479 |
} |
| 2480 |
|
| 2481 |
void A_Fall(mobj_t *actor) |
| 2482 |
{ |
| 2483 |
// actor is on ground, it can be walked over |
| 2484 |
actor->flags &= ~MF_SOLID; |
| 2485 |
} |
| 2486 |
|
| 2487 |
// |
| 2488 |
// A_Explode |
| 2489 |
// |
| 2490 |
void A_Explode(mobj_t *thingy) |
| 2491 |
{ |
| 2492 |
int damage; |
| 2493 |
int distance; |
| 2494 |
int flags; |
| 2495 |
|
| 2496 |
damage = 128; |
| 2497 |
distance = 128; |
| 2498 |
flags = BF_DAMAGESOURCE; |
| 2499 |
|
| 2500 |
if (raven) |
| 2501 |
{ |
| 2502 |
switch (thingy->type) |
| 2503 |
{ |
| 2504 |
case HERETIC_MT_FIREBOMB: // Time Bombs |
| 2505 |
case HEXEN_MT_FIREBOMB: // Time Bombs |
| 2506 |
thingy->z += 32 * FRACUNIT; |
| 2507 |
thingy->flags &= ~MF_SHADOW; |
| 2508 |
break; |
| 2509 |
case HERETIC_MT_MNTRFX2: // Minotaur floor fire |
| 2510 |
damage = 24; |
| 2511 |
distance = damage; |
| 2512 |
break; |
| 2513 |
case HERETIC_MT_SOR2FX1: // D'Sparil missile |
| 2514 |
damage = 80 + (P_Random(pr_heretic) & 31); |
| 2515 |
distance = damage; |
| 2516 |
break; |
| 2517 |
case HEXEN_MT_MNTRFX2: // Minotaur floor fire |
| 2518 |
damage = 24; |
| 2519 |
break; |
| 2520 |
case HEXEN_MT_BISHOP: // Bishop radius death |
| 2521 |
damage = 25 + (P_Random(pr_hexen) & 15); |
| 2522 |
break; |
| 2523 |
case HEXEN_MT_HAMMER_MISSILE: // Fighter Hammer |
| 2524 |
damage = 128; |
| 2525 |
flags &= ~BF_DAMAGESOURCE; |
| 2526 |
break; |
| 2527 |
case HEXEN_MT_FSWORD_MISSILE: // Fighter Runesword |
| 2528 |
damage = 64; |
| 2529 |
flags &= ~BF_DAMAGESOURCE; |
| 2530 |
break; |
| 2531 |
case HEXEN_MT_CIRCLEFLAME: // Cleric Flame secondary flames |
| 2532 |
damage = 20; |
| 2533 |
flags &= ~BF_DAMAGESOURCE; |
| 2534 |
break; |
| 2535 |
case HEXEN_MT_SORCBALL1: // Sorcerer balls |
| 2536 |
case HEXEN_MT_SORCBALL2: |
| 2537 |
case HEXEN_MT_SORCBALL3: |
| 2538 |
distance = 255; |
| 2539 |
damage = 255; |
| 2540 |
thingy->special_args[0] = 1; // don't play bounce |
| 2541 |
break; |
| 2542 |
case HEXEN_MT_SORCFX1: // Sorcerer spell 1 |
| 2543 |
damage = 30; |
| 2544 |
break; |
| 2545 |
case HEXEN_MT_SORCFX4: // Sorcerer spell 4 |
| 2546 |
damage = 20; |
| 2547 |
break; |
| 2548 |
case HEXEN_MT_TREEDESTRUCTIBLE: |
| 2549 |
damage = 10; |
| 2550 |
break; |
| 2551 |
case HEXEN_MT_DRAGON_FX2: |
| 2552 |
damage = 80; |
| 2553 |
flags &= ~BF_DAMAGESOURCE; |
| 2554 |
break; |
| 2555 |
case HEXEN_MT_MSTAFF_FX: |
| 2556 |
damage = 64; |
| 2557 |
distance = 192; |
| 2558 |
flags &= ~BF_DAMAGESOURCE; |
| 2559 |
break; |
| 2560 |
case HEXEN_MT_MSTAFF_FX2: |
| 2561 |
damage = 80; |
| 2562 |
distance = 192; |
| 2563 |
flags &= ~BF_DAMAGESOURCE; |
| 2564 |
break; |
| 2565 |
case HEXEN_MT_POISONCLOUD: |
| 2566 |
damage = 4; |
| 2567 |
distance = 40; |
| 2568 |
break; |
| 2569 |
case HEXEN_MT_ZXMAS_TREE: |
| 2570 |
case HEXEN_MT_ZSHRUB2: |
| 2571 |
damage = 30; |
| 2572 |
distance = 64; |
| 2573 |
break; |
| 2574 |
default: |
| 2575 |
break; |
| 2576 |
} |
| 2577 |
} |
| 2578 |
|
| 2579 |
P_RadiusAttack(thingy, thingy->target, damage, distance, flags); |
| 2580 |
if ( |
| 2581 |
heretic || |
| 2582 |
( |
| 2583 |
hexen && |
| 2584 |
thingy->z <= thingy->floorz + (distance << FRACBITS) && |
| 2585 |
thingy->type != HEXEN_MT_POISONCLOUD |
| 2586 |
) |
| 2587 |
) P_HitFloor(thingy); |
| 2588 |
} |
| 2589 |
|
| 2590 |
// |
| 2591 |
// A_BossDeath |
| 2592 |
// Possibly trigger special effects |
| 2593 |
// if on first boss level |
| 2594 |
// |
| 2595 |
|
| 2596 |
dboolean P_CheckBossDeath(mobj_t *mo) |
| 2597 |
{ |
| 2598 |
int i; |
| 2599 |
thinker_t* th; |
| 2600 |
|
| 2601 |
// make sure there is a player alive for victory |
| 2602 |
for (i = 0; i < g_maxplayers; i++) |
| 2603 |
if (playeringame[i] && players[i].health > 0) |
| 2604 |
break; |
| 2605 |
|
| 2606 |
if (i == g_maxplayers) |
| 2607 |
return false; // no one left alive, so do not end game |
| 2608 |
|
| 2609 |
// scan the remaining thinkers to see |
| 2610 |
// if all bosses are dead |
| 2611 |
for (th = thinkercap.next ; th != &thinkercap ; th=th->next) |
| 2612 |
if (th->function == P_MobjThinker) { |
| 2613 |
mobj_t* mo2 = (mobj_t*) th; |
| 2614 |
|
| 2615 |
if (mo2 != mo && mo2->type == mo->type && mo2->health > 0) |
| 2616 |
return false; // other boss not dead |
| 2617 |
} |
| 2618 |
|
| 2619 |
return true; |
| 2620 |
} |
| 2621 |
|
| 2622 |
void A_BossDeath(mobj_t *mo) |
| 2623 |
{ |
| 2624 |
line_t junk; |
| 2625 |
|
| 2626 |
// heretic_note: probably we can adopt the clean heretic style and merge |
| 2627 |
if (heretic) return Heretic_A_BossDeath(mo); |
| 2628 |
|
| 2629 |
if (dsda_BossAction(mo)) |
| 2630 |
{ |
| 2631 |
return; |
| 2632 |
} |
| 2633 |
|
| 2634 |
if (gamemode == commercial) |
| 2635 |
{ |
| 2636 |
if (gamemap != 7) |
| 2637 |
return; |
| 2638 |
|
| 2639 |
if (!(mo->flags2 & (MF2_MAP07BOSS1 | MF2_MAP07BOSS2))) |
| 2640 |
return; |
| 2641 |
} |
| 2642 |
else |
| 2643 |
{ |
| 2644 |
// e6y |
| 2645 |
// Additional check of gameepisode is necessary, because |
| 2646 |
// there is no right or wrong solution for E4M6 in original EXEs, |
| 2647 |
// there's nothing to emulate. |
| 2648 |
if (comp[comp_666] && gameepisode < 4) |
| 2649 |
{ |
| 2650 |
// e6y |
| 2651 |
// Only following checks are present in doom2.exe ver. 1.666 and 1.9 |
| 2652 |
// instead of separate checks for each episode in doomult.exe, plutonia.exe and tnt.exe |
| 2653 |
// There is no more desync on doom.wad\episode3.lmp |
| 2654 |
// http://www.doomworld.com/idgames/index.php?id=6909 |
| 2655 |
if (gamemap != 8) |
| 2656 |
return; |
| 2657 |
if (mo->flags2 & MF2_E1M8BOSS && gameepisode != 1) |
| 2658 |
return; |
| 2659 |
} |
| 2660 |
else |
| 2661 |
{ |
| 2662 |
switch(gameepisode) |
| 2663 |
{ |
| 2664 |
case 1: |
| 2665 |
if (gamemap != 8) |
| 2666 |
return; |
| 2667 |
|
| 2668 |
if (!(mo->flags2 & MF2_E1M8BOSS)) |
| 2669 |
return; |
| 2670 |
break; |
| 2671 |
|
| 2672 |
case 2: |
| 2673 |
if (gamemap != 8) |
| 2674 |
return; |
| 2675 |
|
| 2676 |
if (!(mo->flags2 & MF2_E2M8BOSS)) |
| 2677 |
return; |
| 2678 |
break; |
| 2679 |
|
| 2680 |
case 3: |
| 2681 |
if (gamemap != 8) |
| 2682 |
return; |
| 2683 |
|
| 2684 |
if (!(mo->flags2 & MF2_E3M8BOSS)) |
| 2685 |
return; |
| 2686 |
|
| 2687 |
break; |
| 2688 |
|
| 2689 |
case 4: |
| 2690 |
switch(gamemap) |
| 2691 |
{ |
| 2692 |
case 6: |
| 2693 |
if (!(mo->flags2 & MF2_E4M6BOSS)) |
| 2694 |
return; |
| 2695 |
break; |
| 2696 |
|
| 2697 |
case 8: |
| 2698 |
if (!(mo->flags2 & MF2_E4M8BOSS)) |
| 2699 |
return; |
| 2700 |
break; |
| 2701 |
|
| 2702 |
default: |
| 2703 |
return; |
| 2704 |
break; |
| 2705 |
} |
| 2706 |
break; |
| 2707 |
|
| 2708 |
default: |
| 2709 |
if (gamemap != 8) |
| 2710 |
return; |
| 2711 |
break; |
| 2712 |
} |
| 2713 |
} |
| 2714 |
} |
| 2715 |
|
| 2716 |
if (!P_CheckBossDeath(mo)) |
| 2717 |
{ |
| 2718 |
return; |
| 2719 |
} |
| 2720 |
|
| 2721 |
// victory! |
| 2722 |
if ( gamemode == commercial) |
| 2723 |
{ |
| 2724 |
if (gamemap == 7) |
| 2725 |
{ |
| 2726 |
if (mo->flags2 & MF2_MAP07BOSS1) |
| 2727 |
{ |
| 2728 |
junk.tag = 666; |
| 2729 |
EV_DoFloor(&junk,lowerFloorToLowest); |
| 2730 |
return; |
| 2731 |
} |
| 2732 |
|
| 2733 |
if (mo->flags2 & MF2_MAP07BOSS2) |
| 2734 |
{ |
| 2735 |
junk.tag = 667; |
| 2736 |
EV_DoFloor(&junk,raiseToTexture); |
| 2737 |
return; |
| 2738 |
} |
| 2739 |
} |
| 2740 |
} |
| 2741 |
else |
| 2742 |
{ |
| 2743 |
switch(gameepisode) |
| 2744 |
{ |
| 2745 |
case 1: |
| 2746 |
junk.tag = 666; |
| 2747 |
EV_DoFloor(&junk, lowerFloorToLowest); |
| 2748 |
return; |
| 2749 |
break; |
| 2750 |
|
| 2751 |
case 4: |
| 2752 |
switch(gamemap) |
| 2753 |
{ |
| 2754 |
case 6: |
| 2755 |
junk.tag = 666; |
| 2756 |
EV_DoDoor(&junk, blazeOpen); |
| 2757 |
return; |
| 2758 |
break; |
| 2759 |
|
| 2760 |
case 8: |
| 2761 |
junk.tag = 666; |
| 2762 |
EV_DoFloor(&junk, lowerFloorToLowest); |
| 2763 |
return; |
| 2764 |
break; |
| 2765 |
} |
| 2766 |
} |
| 2767 |
} |
| 2768 |
G_ExitLevel(0); |
| 2769 |
} |
| 2770 |
|
| 2771 |
|
| 2772 |
void A_Hoof (mobj_t* mo) |
| 2773 |
{ |
| 2774 |
S_StartMobjSound(mo, sfx_hoof); |
| 2775 |
A_Chase(mo); |
| 2776 |
} |
| 2777 |
|
| 2778 |
void A_Metal(mobj_t *mo) |
| 2779 |
{ |
| 2780 |
S_StartMobjSound(mo, sfx_metal); |
| 2781 |
A_Chase(mo); |
| 2782 |
} |
| 2783 |
|
| 2784 |
void A_BabyMetal(mobj_t *mo) |
| 2785 |
{ |
| 2786 |
S_StartMobjSound(mo, sfx_bspwlk); |
| 2787 |
A_Chase(mo); |
| 2788 |
} |
| 2789 |
|
| 2790 |
void A_OpenShotgun2(player_t *player, pspdef_t *psp) |
| 2791 |
{ |
| 2792 |
S_StartMobjSound(player->mo, sfx_dbopn); |
| 2793 |
} |
| 2794 |
|
| 2795 |
void A_LoadShotgun2(player_t *player, pspdef_t *psp) |
| 2796 |
{ |
| 2797 |
S_StartMobjSound(player->mo, sfx_dbload); |
| 2798 |
} |
| 2799 |
|
| 2800 |
void A_CloseShotgun2(player_t *player, pspdef_t *psp) |
| 2801 |
{ |
| 2802 |
S_StartMobjSound(player->mo, sfx_dbcls); |
| 2803 |
A_ReFire(player,psp); |
| 2804 |
} |
| 2805 |
|
| 2806 |
// killough 2/7/98: Remove limit on icon landings: |
| 2807 |
mobj_t **braintargets; |
| 2808 |
int numbraintargets_alloc; |
| 2809 |
int numbraintargets; |
| 2810 |
|
| 2811 |
struct brain_s brain; // killough 3/26/98: global state of boss brain |
| 2812 |
|
| 2813 |
// killough 3/26/98: initialize icon landings at level startup, |
| 2814 |
// rather than at boss wakeup, to prevent savegame-related crashes |
| 2815 |
|
| 2816 |
void P_SpawnBrainTargets(void) // killough 3/26/98: renamed old function |
| 2817 |
{ |
| 2818 |
thinker_t *thinker; |
| 2819 |
|
| 2820 |
// find all the target spots |
| 2821 |
numbraintargets = 0; |
| 2822 |
brain.targeton = 0; |
| 2823 |
brain.easy = 0; // killough 3/26/98: always init easy to 0 |
| 2824 |
|
| 2825 |
for (thinker = thinkercap.next ; |
| 2826 |
thinker != &thinkercap ; |
| 2827 |
thinker = thinker->next) |
| 2828 |
if (thinker->function == P_MobjThinker) |
| 2829 |
{ |
| 2830 |
mobj_t *m = (mobj_t *) thinker; |
| 2831 |
|
| 2832 |
if (m->type == MT_BOSSTARGET ) |
| 2833 |
{ // killough 2/7/98: remove limit on icon landings: |
| 2834 |
if (numbraintargets >= numbraintargets_alloc) |
| 2835 |
braintargets = Z_Realloc(braintargets, |
| 2836 |
(numbraintargets_alloc = numbraintargets_alloc ? |
| 2837 |
numbraintargets_alloc*2 : 32) *sizeof *braintargets); |
| 2838 |
braintargets[numbraintargets++] = m; |
| 2839 |
} |
| 2840 |
} |
| 2841 |
} |
| 2842 |
|
| 2843 |
void A_BrainAwake(mobj_t *mo) |
| 2844 |
{ |
| 2845 |
//e6y |
| 2846 |
if (demo_compatibility && !prboom_comp[PC_BOOM_BRAINAWAKE].state) |
| 2847 |
{ |
| 2848 |
brain.targeton = 0; |
| 2849 |
brain.easy = 0; |
| 2850 |
} |
| 2851 |
|
| 2852 |
S_StartVoidSound(sfx_bossit); // killough 3/26/98: only generates sound now |
| 2853 |
} |
| 2854 |
|
| 2855 |
void A_BrainPain(mobj_t *mo) |
| 2856 |
{ |
| 2857 |
S_StartVoidSound(sfx_bospn); |
| 2858 |
} |
| 2859 |
|
| 2860 |
void A_BrainScream(mobj_t *mo) |
| 2861 |
{ |
| 2862 |
int x; |
| 2863 |
for (x=mo->x - 196*FRACUNIT ; x< mo->x + 320*FRACUNIT ; x+= FRACUNIT*8) |
| 2864 |
{ |
| 2865 |
int y = mo->y - 320*FRACUNIT; |
| 2866 |
int z = 128 + P_Random(pr_brainscream)*2*FRACUNIT; |
| 2867 |
mobj_t *th = P_SpawnMobj (x,y,z, MT_ROCKET); |
| 2868 |
th->momz = P_Random(pr_brainscream)*512; |
| 2869 |
P_SetMobjState(th, S_BRAINEXPLODE1); |
| 2870 |
th->tics -= P_Random(pr_brainscream)&7; |
| 2871 |
if (th->tics < 1) |
| 2872 |
th->tics = 1; |
| 2873 |
} |
| 2874 |
S_StartVoidSound(sfx_bosdth); |
| 2875 |
} |
| 2876 |
|
| 2877 |
void A_BrainExplode(mobj_t *mo) |
| 2878 |
{ // killough 5/5/98: remove dependence on order of evaluation: |
| 2879 |
int t = P_Random(pr_brainexp); |
| 2880 |
int x = mo->x + (t - P_Random(pr_brainexp))*2048; |
| 2881 |
int y = mo->y; |
| 2882 |
int z = 128 + P_Random(pr_brainexp)*2*FRACUNIT; |
| 2883 |
mobj_t *th = P_SpawnMobj(x,y,z, MT_ROCKET); |
| 2884 |
th->momz = P_Random(pr_brainexp)*512; |
| 2885 |
P_SetMobjState(th, S_BRAINEXPLODE1); |
| 2886 |
th->tics -= P_Random(pr_brainexp)&7; |
| 2887 |
if (th->tics < 1) |
| 2888 |
th->tics = 1; |
| 2889 |
} |
| 2890 |
|
| 2891 |
void A_BrainDie(mobj_t *mo) |
| 2892 |
{ |
| 2893 |
G_ExitLevel(0); |
| 2894 |
} |
| 2895 |
|
| 2896 |
void A_BrainSpit(mobj_t *mo) |
| 2897 |
{ |
| 2898 |
mobj_t *targ, *newmobj; |
| 2899 |
|
| 2900 |
if (!numbraintargets) // killough 4/1/98: ignore if no targets |
| 2901 |
return; |
| 2902 |
|
| 2903 |
brain.easy ^= 1; // killough 3/26/98: use brain struct |
| 2904 |
if (skill_info.flags & SI_EASY_BOSS_BRAIN && !brain.easy) |
| 2905 |
return; |
| 2906 |
|
| 2907 |
// shoot a cube at current target |
| 2908 |
targ = braintargets[brain.targeton++]; // killough 3/26/98: |
| 2909 |
brain.targeton %= numbraintargets; // Use brain struct for targets |
| 2910 |
|
| 2911 |
// spawn brain missile |
| 2912 |
newmobj = P_SpawnMissile(mo, targ, MT_SPAWNSHOT); |
| 2913 |
|
| 2914 |
// e6y: do not crash with 'incorrect' DEHs |
| 2915 |
if (!newmobj || !newmobj->state || newmobj->momy == 0 || newmobj->state->tics == 0) |
| 2916 |
I_Error("A_BrainSpit: can't spawn brain missile (incorrect DEH)"); |
| 2917 |
|
| 2918 |
P_SetTarget(&newmobj->target, targ); |
| 2919 |
newmobj->reactiontime = (short)(((targ->y-mo->y)/newmobj->momy)/newmobj->state->tics); |
| 2920 |
|
| 2921 |
// killough 7/18/98: brain friendliness is transferred |
| 2922 |
newmobj->flags = (newmobj->flags & ~MF_FRIEND) | (mo->flags & MF_FRIEND); |
| 2923 |
|
| 2924 |
// killough 8/29/98: add to appropriate thread |
| 2925 |
P_UpdateThinker(&newmobj->thinker); |
| 2926 |
|
| 2927 |
S_StartVoidSound(sfx_bospit); |
| 2928 |
} |
| 2929 |
|
| 2930 |
// travelling cube sound |
| 2931 |
void A_SpawnSound(mobj_t *mo) |
| 2932 |
{ |
| 2933 |
S_StartMobjSound(mo,sfx_boscub); |
| 2934 |
A_SpawnFly(mo); |
| 2935 |
} |
| 2936 |
|
| 2937 |
void A_SpawnFly(mobj_t *mo) |
| 2938 |
{ |
| 2939 |
mobj_t *newmobj; |
| 2940 |
mobj_t *fog; |
| 2941 |
mobj_t *targ; |
| 2942 |
int r; |
| 2943 |
mobjtype_t type; |
| 2944 |
|
| 2945 |
if (--mo->reactiontime) |
| 2946 |
return; // still flying |
| 2947 |
|
| 2948 |
targ = P_SubstNullMobj(mo->target); |
| 2949 |
|
| 2950 |
// First spawn teleport fog. |
| 2951 |
fog = P_SpawnMobj(targ->x, targ->y, targ->z, MT_SPAWNFIRE); |
| 2952 |
S_StartMobjSound(fog, sfx_telept); |
| 2953 |
|
| 2954 |
// Randomly select monster to spawn. |
| 2955 |
r = P_Random(pr_spawnfly); |
| 2956 |
|
| 2957 |
// Probability distribution (kind of :), decreasing likelihood. |
| 2958 |
if ( r<50 ) |
| 2959 |
type = MT_TROOP; |
| 2960 |
else if (r<90) |
| 2961 |
type = MT_SERGEANT; |
| 2962 |
else if (r<120) |
| 2963 |
type = MT_SHADOWS; |
| 2964 |
else if (r<130) |
| 2965 |
type = MT_PAIN; |
| 2966 |
else if (r<160) |
| 2967 |
type = MT_HEAD; |
| 2968 |
else if (r<162) |
| 2969 |
type = MT_VILE; |
| 2970 |
else if (r<172) |
| 2971 |
type = MT_UNDEAD; |
| 2972 |
else if (r<192) |
| 2973 |
type = MT_BABY; |
| 2974 |
else if (r<222) |
| 2975 |
type = MT_FATSO; |
| 2976 |
else if (r<246) |
| 2977 |
type = MT_KNIGHT; |
| 2978 |
else |
| 2979 |
type = MT_BRUISER; |
| 2980 |
|
| 2981 |
newmobj = P_SpawnMobj(targ->x, targ->y, targ->z, type); |
| 2982 |
|
| 2983 |
/* killough 7/18/98: brain friendliness is transferred */ |
| 2984 |
newmobj->flags = (newmobj->flags & ~MF_FRIEND) | (mo->flags & MF_FRIEND); |
| 2985 |
|
| 2986 |
//e6y: monsters spawned by Icon of Sin should not be countable for total killed. |
| 2987 |
newmobj->flags |= MF_RESSURECTED; |
| 2988 |
|
| 2989 |
dsda_WatchIconSpawn(newmobj); |
| 2990 |
|
| 2991 |
/* killough 8/29/98: add to appropriate thread */ |
| 2992 |
P_UpdateThinker(&newmobj->thinker); |
| 2993 |
|
| 2994 |
if (P_LookForTargets(newmobj,true)) /* killough 9/4/98 */ |
| 2995 |
P_SetMobjState(newmobj, newmobj->info->seestate); |
| 2996 |
|
| 2997 |
// telefrag anything in this spot |
| 2998 |
P_TeleportMove(newmobj, newmobj->x, newmobj->y, true); /* killough 8/9/98 */ |
| 2999 |
|
| 3000 |
// remove self (i.e., cube). |
| 3001 |
P_RemoveMobj(mo); |
| 3002 |
} |
| 3003 |
|
| 3004 |
void A_PlayerScream(mobj_t *mo) |
| 3005 |
{ |
| 3006 |
int sound = sfx_pldeth; // Default death sound. |
| 3007 |
if (gamemode != shareware && mo->health < -50) |
| 3008 |
sound = sfx_pdiehi; // IF THE PLAYER DIES LESS THAN -50% WITHOUT GIBBING |
| 3009 |
S_StartMobjSound(mo, sound); |
| 3010 |
} |
| 3011 |
|
| 3012 |
/* cph - MBF-added codepointer functions */ |
| 3013 |
|
| 3014 |
// killough 11/98: kill an object |
| 3015 |
void A_Die(mobj_t *actor) |
| 3016 |
{ |
| 3017 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3018 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3019 |
return; |
| 3020 |
|
| 3021 |
P_DamageMobj(actor, NULL, NULL, actor->health); |
| 3022 |
} |
| 3023 |
|
| 3024 |
// |
| 3025 |
// A_Detonate |
| 3026 |
// killough 8/9/98: same as A_Explode, except that the damage is variable |
| 3027 |
// |
| 3028 |
|
| 3029 |
void A_Detonate(mobj_t *mo) |
| 3030 |
{ |
| 3031 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3032 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3033 |
return; |
| 3034 |
|
| 3035 |
P_RadiusAttack(mo, mo->target, mo->info->damage, mo->info->damage, BF_DAMAGESOURCE); |
| 3036 |
} |
| 3037 |
|
| 3038 |
// |
| 3039 |
// killough 9/98: a mushroom explosion effect, sorta :) |
| 3040 |
// Original idea: Linguica |
| 3041 |
// |
| 3042 |
|
| 3043 |
void A_Mushroom(mobj_t *actor) |
| 3044 |
{ |
| 3045 |
int i, j, n; |
| 3046 |
|
| 3047 |
// Mushroom parameters are part of code pointer's state |
| 3048 |
dboolean use_misc; |
| 3049 |
fixed_t misc1, misc2; |
| 3050 |
|
| 3051 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3052 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3053 |
return; |
| 3054 |
|
| 3055 |
use_misc = mbf21 || ( |
| 3056 |
compatibility_level == mbf_compatibility && |
| 3057 |
!prboom_comp[PC_DO_NOT_USE_MISC12_FRAME_PARAMETERS_IN_A_MUSHROOM].state |
| 3058 |
); |
| 3059 |
misc1 = ((use_misc && actor->state->misc1) ? actor->state->misc1 : FRACUNIT * 4); |
| 3060 |
misc2 = ((use_misc && actor->state->misc2) ? actor->state->misc2 : FRACUNIT / 2); |
| 3061 |
n = actor->info->damage; |
| 3062 |
|
| 3063 |
A_Explode(actor); // First make normal explosion |
| 3064 |
|
| 3065 |
// Now launch mushroom cloud |
| 3066 |
for (i = -n; i <= n; i += 8) |
| 3067 |
for (j = -n; j <= n; j += 8) |
| 3068 |
{ |
| 3069 |
mobj_t target = *actor, *mo; |
| 3070 |
target.x += i << FRACBITS; // Aim in many directions from source |
| 3071 |
target.y += j << FRACBITS; |
| 3072 |
target.z += P_AproxDistance(i,j) * misc1; // Aim up fairly high |
| 3073 |
mo = P_SpawnMissile(actor, &target, MT_FATSHOT); // Launch fireball |
| 3074 |
mo->momx = FixedMul(mo->momx, misc2); |
| 3075 |
mo->momy = FixedMul(mo->momy, misc2); // Slow down a bit |
| 3076 |
mo->momz = FixedMul(mo->momz, misc2); |
| 3077 |
mo->flags &= ~MF_NOGRAVITY; // Make debris fall under gravity |
| 3078 |
} |
| 3079 |
} |
| 3080 |
|
| 3081 |
// |
| 3082 |
// killough 11/98 |
| 3083 |
// |
| 3084 |
// The following were inspired by Len Pitre |
| 3085 |
// |
| 3086 |
// A small set of highly-sought-after code pointers |
| 3087 |
// |
| 3088 |
|
| 3089 |
void A_Spawn(mobj_t *mo) |
| 3090 |
{ |
| 3091 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3092 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3093 |
return; |
| 3094 |
|
| 3095 |
if (mo->state->misc1) |
| 3096 |
{ |
| 3097 |
mobj_t *newmobj = |
| 3098 |
P_SpawnMobj(mo->x, mo->y, (mo->state->misc2 << FRACBITS) + mo->z, mo->state->misc1 - 1); |
| 3099 |
|
| 3100 |
if ( |
| 3101 |
mbf_features && |
| 3102 |
comp[comp_friendlyspawn] && |
| 3103 |
!prboom_comp[PC_DO_NOT_INHERIT_FRIENDLYNESS_FLAG_ON_SPAWN].state |
| 3104 |
) |
| 3105 |
newmobj->flags = (newmobj->flags & ~MF_FRIEND) | (mo->flags & MF_FRIEND); |
| 3106 |
} |
| 3107 |
} |
| 3108 |
|
| 3109 |
void A_Turn(mobj_t *mo) |
| 3110 |
{ |
| 3111 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3112 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3113 |
return; |
| 3114 |
|
| 3115 |
mo->angle += (unsigned int)(((uint64_t) mo->state->misc1 << 32) / 360); |
| 3116 |
} |
| 3117 |
|
| 3118 |
void A_Face(mobj_t *mo) |
| 3119 |
{ |
| 3120 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3121 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3122 |
return; |
| 3123 |
|
| 3124 |
mo->angle = (unsigned int)(((uint64_t) mo->state->misc1 << 32) / 360); |
| 3125 |
} |
| 3126 |
|
| 3127 |
void A_Scratch(mobj_t *mo) |
| 3128 |
{ |
| 3129 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3130 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3131 |
return; |
| 3132 |
|
| 3133 |
mo->target && (A_FaceTarget(mo), P_CheckMeleeRange(mo)) ? |
| 3134 |
mo->state->misc2 ? S_StartMobjSound(mo, mo->state->misc2) : (void) 0, |
| 3135 |
P_DamageMobj(mo->target, mo, mo, mo->state->misc1) : (void) 0; |
| 3136 |
} |
| 3137 |
|
| 3138 |
void A_PlaySound(mobj_t *mo) |
| 3139 |
{ |
| 3140 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3141 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3142 |
return; |
| 3143 |
|
| 3144 |
S_StartMobjSound(mo->state->misc2 ? NULL : mo, mo->state->misc1); |
| 3145 |
} |
| 3146 |
|
| 3147 |
void A_RandomJump(mobj_t *mo) |
| 3148 |
{ |
| 3149 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3150 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3151 |
return; |
| 3152 |
|
| 3153 |
if (P_Random(pr_randomjump) < mo->state->misc2) |
| 3154 |
P_SetMobjState(mo, mo->state->misc1); |
| 3155 |
} |
| 3156 |
|
| 3157 |
// |
| 3158 |
// This allows linedef effects to be activated inside deh frames. |
| 3159 |
// |
| 3160 |
|
| 3161 |
void A_LineEffect(mobj_t *mo) |
| 3162 |
{ |
| 3163 |
static line_t junk; |
| 3164 |
player_t player; |
| 3165 |
player_t *oldplayer; |
| 3166 |
|
| 3167 |
if (compatibility_level < lxdoom_1_compatibility && |
| 3168 |
!prboom_comp[PC_APPLY_MBF_CODEPOINTERS_TO_ANY_COMPLEVEL].state) |
| 3169 |
return; |
| 3170 |
|
| 3171 |
junk = *lines; |
| 3172 |
oldplayer = mo->player; |
| 3173 |
mo->player = &player; |
| 3174 |
player.health = 100; |
| 3175 |
junk.special = (short)mo->state->misc1; |
| 3176 |
if (!junk.special) |
| 3177 |
return; |
| 3178 |
junk.tag = (short)mo->state->misc2; |
| 3179 |
if (!P_UseSpecialLine(mo, &junk, 0, false)) |
| 3180 |
map_format.cross_special_line(&junk, 0, mo, false); |
| 3181 |
mo->state->misc1 = junk.special; |
| 3182 |
mo->player = oldplayer; |
| 3183 |
} |
| 3184 |
|
| 3185 |
// |
| 3186 |
// [XA] New mbf21 codepointers |
| 3187 |
// |
| 3188 |
|
| 3189 |
// |
| 3190 |
// A_SpawnObject |
| 3191 |
// Basically just A_Spawn with better behavior and more args. |
| 3192 |
// args[0]: Type of actor to spawn |
| 3193 |
// args[1]: Angle (degrees, in fixed point), relative to calling actor's angle |
| 3194 |
// args[2]: X spawn offset (fixed point), relative to calling actor |
| 3195 |
// args[3]: Y spawn offset (fixed point), relative to calling actor |
| 3196 |
// args[4]: Z spawn offset (fixed point), relative to calling actor |
| 3197 |
// args[5]: X velocity (fixed point) |
| 3198 |
// args[6]: Y velocity (fixed point) |
| 3199 |
// args[7]: Z velocity (fixed point) |
| 3200 |
// |
| 3201 |
void A_SpawnObject(mobj_t *actor) |
| 3202 |
{ |
| 3203 |
int type, angle, ofs_x, ofs_y, ofs_z, vel_x, vel_y, vel_z; |
| 3204 |
angle_t an; |
| 3205 |
int fan, dx, dy; |
| 3206 |
mobj_t *mo; |
| 3207 |
|
| 3208 |
if (!mbf21 || !actor->state->args[0]) |
| 3209 |
return; |
| 3210 |
|
| 3211 |
type = actor->state->args[0] - 1; |
| 3212 |
angle = actor->state->args[1]; |
| 3213 |
ofs_x = actor->state->args[2]; |
| 3214 |
ofs_y = actor->state->args[3]; |
| 3215 |
ofs_z = actor->state->args[4]; |
| 3216 |
vel_x = actor->state->args[5]; |
| 3217 |
vel_y = actor->state->args[6]; |
| 3218 |
vel_z = actor->state->args[7]; |
| 3219 |
|
| 3220 |
// calculate position offsets |
| 3221 |
an = actor->angle + (unsigned int)(((int64_t)angle << 16) / 360); |
| 3222 |
fan = an >> ANGLETOFINESHIFT; |
| 3223 |
dx = FixedMul(ofs_x, finecosine[fan]) - FixedMul(ofs_y, finesine[fan] ); |
| 3224 |
dy = FixedMul(ofs_x, finesine[fan] ) + FixedMul(ofs_y, finecosine[fan]); |
| 3225 |
|
| 3226 |
// spawn it, yo |
| 3227 |
mo = P_SpawnMobj(actor->x + dx, actor->y + dy, actor->z + ofs_z, type); |
| 3228 |
if (!mo) |
| 3229 |
return; |
| 3230 |
|
| 3231 |
// angle dangle |
| 3232 |
mo->angle = an; |
| 3233 |
|
| 3234 |
// set velocity |
| 3235 |
mo->momx = FixedMul(vel_x, finecosine[fan]) - FixedMul(vel_y, finesine[fan] ); |
| 3236 |
mo->momy = FixedMul(vel_x, finesine[fan] ) + FixedMul(vel_y, finecosine[fan]); |
| 3237 |
mo->momz = vel_z; |
| 3238 |
|
| 3239 |
// if spawned object is a missile, set target+tracer |
| 3240 |
if (mo->info->flags & (MF_MISSILE | MF_BOUNCES)) |
| 3241 |
{ |
| 3242 |
// if spawner is also a missile, copy 'em |
| 3243 |
if (actor->info->flags & (MF_MISSILE | MF_BOUNCES)) |
| 3244 |
{ |
| 3245 |
P_SetTarget(&mo->target, actor->target); |
| 3246 |
P_SetTarget(&mo->tracer, actor->tracer); |
| 3247 |
} |
| 3248 |
// otherwise, set 'em as if a monster fired 'em |
| 3249 |
else |
| 3250 |
{ |
| 3251 |
P_SetTarget(&mo->target, actor); |
| 3252 |
P_SetTarget(&mo->tracer, actor->target); |
| 3253 |
} |
| 3254 |
} |
| 3255 |
|
| 3256 |
// [XA] don't bother with the dont-inherit-friendliness hack |
| 3257 |
// that exists in A_Spawn, 'cause WTF is that about anyway? |
| 3258 |
} |
| 3259 |
|
| 3260 |
// |
| 3261 |
// A_MonsterProjectile |
| 3262 |
// A parameterized monster projectile attack. |
| 3263 |
// args[0]: Type of actor to spawn |
| 3264 |
// args[1]: Angle (degrees, in fixed point), relative to calling actor's angle |
| 3265 |
// args[2]: Pitch (degrees, in fixed point), relative to calling actor's pitch; approximated |
| 3266 |
// args[3]: X/Y spawn offset, relative to calling actor's angle |
| 3267 |
// args[4]: Z spawn offset, relative to actor's default projectile fire height |
| 3268 |
// |
| 3269 |
void A_MonsterProjectile(mobj_t *actor) |
| 3270 |
{ |
| 3271 |
int type, angle, pitch, spawnofs_xy, spawnofs_z; |
| 3272 |
mobj_t *mo; |
| 3273 |
int an; |
| 3274 |
|
| 3275 |
if (!mbf21 || !actor->target || !actor->state->args[0]) |
| 3276 |
return; |
| 3277 |
|
| 3278 |
type = actor->state->args[0] - 1; |
| 3279 |
angle = actor->state->args[1]; |
| 3280 |
pitch = actor->state->args[2]; |
| 3281 |
spawnofs_xy = actor->state->args[3]; |
| 3282 |
spawnofs_z = actor->state->args[4]; |
| 3283 |
|
| 3284 |
A_FaceTarget(actor); |
| 3285 |
mo = P_SpawnMissile(actor, actor->target, type); |
| 3286 |
if (!mo) |
| 3287 |
return; |
| 3288 |
|
| 3289 |
// adjust angle |
| 3290 |
mo->angle += (unsigned int)(((int64_t)angle << 16) / 360); |
| 3291 |
an = mo->angle >> ANGLETOFINESHIFT; |
| 3292 |
mo->momx = FixedMul(mo->info->speed, finecosine[an]); |
| 3293 |
mo->momy = FixedMul(mo->info->speed, finesine[an]); |
| 3294 |
|
| 3295 |
// adjust pitch (approximated, using Doom's ye olde |
| 3296 |
// finetangent table; same method as monster aim) |
| 3297 |
mo->momz += FixedMul(mo->info->speed, DegToSlope(pitch)); |
| 3298 |
|
| 3299 |
// adjust position |
| 3300 |
an = (actor->angle - ANG90) >> ANGLETOFINESHIFT; |
| 3301 |
mo->x += FixedMul(spawnofs_xy, finecosine[an]); |
| 3302 |
mo->y += FixedMul(spawnofs_xy, finesine[an]); |
| 3303 |
mo->z += spawnofs_z; |
| 3304 |
|
| 3305 |
// always set the 'tracer' field, so this pointer |
| 3306 |
// can be used to fire seeker missiles at will. |
| 3307 |
P_SetTarget(&mo->tracer, actor->target); |
| 3308 |
} |
| 3309 |
|
| 3310 |
// |
| 3311 |
// A_MonsterBulletAttack |
| 3312 |
// A parameterized monster bullet attack. |
| 3313 |
// args[0]: Horizontal spread (degrees, in fixed point) |
| 3314 |
// args[1]: Vertical spread (degrees, in fixed point) |
| 3315 |
// args[2]: Number of bullets to fire; if not set, defaults to 1 |
| 3316 |
// args[3]: Base damage of attack (e.g. for 3d5, customize the 3); if not set, defaults to 3 |
| 3317 |
// args[4]: Attack damage modulus (e.g. for 3d5, customize the 5); if not set, defaults to 5 |
| 3318 |
// |
| 3319 |
void A_MonsterBulletAttack(mobj_t *actor) |
| 3320 |
{ |
| 3321 |
int hspread, vspread, numbullets, damagebase, damagemod; |
| 3322 |
int aimslope, i, damage, angle, slope; |
| 3323 |
|
| 3324 |
if (!mbf21 || !actor->target) |
| 3325 |
return; |
| 3326 |
|
| 3327 |
hspread = actor->state->args[0]; |
| 3328 |
vspread = actor->state->args[1]; |
| 3329 |
numbullets = actor->state->args[2]; |
| 3330 |
damagebase = actor->state->args[3]; |
| 3331 |
damagemod = actor->state->args[4]; |
| 3332 |
|
| 3333 |
A_FaceTarget(actor); |
| 3334 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 3335 |
|
| 3336 |
aimslope = P_AimLineAttack(actor, actor->angle, MISSILERANGE, 0); |
| 3337 |
|
| 3338 |
for (i = 0; i < numbullets; i++) |
| 3339 |
{ |
| 3340 |
damage = (P_Random(pr_mbf21) % damagemod + 1) * damagebase; |
| 3341 |
angle = (int)actor->angle + P_RandomHitscanAngle(pr_mbf21, hspread); |
| 3342 |
slope = aimslope + P_RandomHitscanSlope(pr_mbf21, vspread); |
| 3343 |
|
| 3344 |
P_LineAttack(actor, angle, MISSILERANGE, slope, damage); |
| 3345 |
} |
| 3346 |
} |
| 3347 |
|
| 3348 |
// |
| 3349 |
// A_MonsterMeleeAttack |
| 3350 |
// A parameterized monster melee attack. |
| 3351 |
// args[0]: Base damage of attack (e.g. for 3d8, customize the 3); if not set, defaults to 3 |
| 3352 |
// args[1]: Attack damage modulus (e.g. for 3d8, customize the 8); if not set, defaults to 8 |
| 3353 |
// args[2]: Sound to play if attack hits |
| 3354 |
// args[3]: Range (fixed point); if not set, defaults to monster's melee range |
| 3355 |
// |
| 3356 |
void A_MonsterMeleeAttack(mobj_t *actor) |
| 3357 |
{ |
| 3358 |
int damagebase, damagemod, hitsound, range; |
| 3359 |
int damage; |
| 3360 |
|
| 3361 |
if (!mbf21 || !actor->target) |
| 3362 |
return; |
| 3363 |
|
| 3364 |
damagebase = actor->state->args[0]; |
| 3365 |
damagemod = actor->state->args[1]; |
| 3366 |
hitsound = actor->state->args[2]; |
| 3367 |
range = actor->state->args[3]; |
| 3368 |
|
| 3369 |
if (range == 0) |
| 3370 |
range = actor->info->meleerange; |
| 3371 |
|
| 3372 |
range += actor->target->info->radius - 20 * FRACUNIT; |
| 3373 |
|
| 3374 |
A_FaceTarget(actor); |
| 3375 |
if (!P_CheckRange(actor, range)) |
| 3376 |
return; |
| 3377 |
|
| 3378 |
S_StartMobjSound(actor, hitsound); |
| 3379 |
|
| 3380 |
damage = (P_Random(pr_mbf21) % damagemod + 1) * damagebase; |
| 3381 |
P_DamageMobj(actor->target, actor, actor, damage); |
| 3382 |
} |
| 3383 |
|
| 3384 |
// |
| 3385 |
// A_RadiusDamage |
| 3386 |
// A parameterized version of A_Explode. Friggin' finally. :P |
| 3387 |
// args[0]: Damage (int) |
| 3388 |
// args[1]: Radius (also int; no real need for fractional precision here) |
| 3389 |
// |
| 3390 |
void A_RadiusDamage(mobj_t *actor) |
| 3391 |
{ |
| 3392 |
if (!mbf21 || !actor->state) |
| 3393 |
return; |
| 3394 |
|
| 3395 |
P_RadiusAttack(actor, actor->target, actor->state->args[0], actor->state->args[1], BF_DAMAGESOURCE); |
| 3396 |
} |
| 3397 |
|
| 3398 |
// |
| 3399 |
// A_NoiseAlert |
| 3400 |
// Alerts nearby monsters (via sound) to the calling actor's target's presence. |
| 3401 |
// |
| 3402 |
void A_NoiseAlert(mobj_t *actor) |
| 3403 |
{ |
| 3404 |
if (!mbf21 || !actor->target) |
| 3405 |
return; |
| 3406 |
|
| 3407 |
P_NoiseAlert(actor->target, actor); |
| 3408 |
} |
| 3409 |
|
| 3410 |
// |
| 3411 |
// A_HealChase |
| 3412 |
// A parameterized version of A_VileChase. |
| 3413 |
// args[0]: State to jump to on the calling actor when resurrecting a corpse |
| 3414 |
// args[1]: Sound to play when resurrecting a corpse |
| 3415 |
// |
| 3416 |
void A_HealChase(mobj_t* actor) |
| 3417 |
{ |
| 3418 |
int state, sound; |
| 3419 |
|
| 3420 |
if (!mbf21 || !actor) |
| 3421 |
return; |
| 3422 |
|
| 3423 |
state = actor->state->args[0]; |
| 3424 |
sound = actor->state->args[1]; |
| 3425 |
|
| 3426 |
if (!P_HealCorpse(actor, actor->info->radius, state, sound)) |
| 3427 |
A_Chase(actor); |
| 3428 |
} |
| 3429 |
|
| 3430 |
// |
| 3431 |
// A_SeekTracer |
| 3432 |
// A parameterized seeker missile function. |
| 3433 |
// args[0]: direct-homing threshold angle (degrees, in fixed point) |
| 3434 |
// args[1]: maximum turn angle (degrees, in fixed point) |
| 3435 |
// |
| 3436 |
void A_SeekTracer(mobj_t *actor) |
| 3437 |
{ |
| 3438 |
angle_t threshold, maxturnangle; |
| 3439 |
|
| 3440 |
if (!mbf21 || !actor) |
| 3441 |
return; |
| 3442 |
|
| 3443 |
threshold = FixedToAngle(actor->state->args[0]); |
| 3444 |
maxturnangle = FixedToAngle(actor->state->args[1]); |
| 3445 |
|
| 3446 |
P_SeekerMissile(actor, &actor->tracer, threshold, maxturnangle, true); |
| 3447 |
} |
| 3448 |
|
| 3449 |
// |
| 3450 |
// A_FindTracer |
| 3451 |
// Search for a valid tracer (seek target), if the calling actor doesn't already have one. |
| 3452 |
// args[0]: field-of-view to search in (degrees, in fixed point); if zero, will search in all directions |
| 3453 |
// args[1]: distance to search (map blocks, i.e. 128 units) |
| 3454 |
// |
| 3455 |
void A_FindTracer(mobj_t *actor) |
| 3456 |
{ |
| 3457 |
angle_t fov; |
| 3458 |
int dist; |
| 3459 |
|
| 3460 |
if (!mbf21 || !actor || actor->tracer) |
| 3461 |
return; |
| 3462 |
|
| 3463 |
fov = FixedToAngle(actor->state->args[0]); |
| 3464 |
dist = (actor->state->args[1]); |
| 3465 |
|
| 3466 |
P_SetTarget(&actor->tracer, P_RoughTargetSearch(actor, fov, dist)); |
| 3467 |
} |
| 3468 |
|
| 3469 |
// |
| 3470 |
// A_ClearTracer |
| 3471 |
// Clear current tracer (seek target). |
| 3472 |
// |
| 3473 |
void A_ClearTracer(mobj_t *actor) |
| 3474 |
{ |
| 3475 |
if (!mbf21 || !actor) |
| 3476 |
return; |
| 3477 |
|
| 3478 |
P_SetTarget(&actor->tracer, NULL); |
| 3479 |
} |
| 3480 |
|
| 3481 |
// |
| 3482 |
// A_JumpIfHealthBelow |
| 3483 |
// Jumps to a state if caller's health is below the specified threshold. |
| 3484 |
// args[0]: State to jump to |
| 3485 |
// args[1]: Health threshold |
| 3486 |
// |
| 3487 |
void A_JumpIfHealthBelow(mobj_t* actor) |
| 3488 |
{ |
| 3489 |
int state, health; |
| 3490 |
|
| 3491 |
if (!mbf21 || !actor) |
| 3492 |
return; |
| 3493 |
|
| 3494 |
state = actor->state->args[0]; |
| 3495 |
health = actor->state->args[1]; |
| 3496 |
|
| 3497 |
if (actor->health < health) |
| 3498 |
P_SetMobjState(actor, state); |
| 3499 |
} |
| 3500 |
|
| 3501 |
// |
| 3502 |
// A_JumpIfTargetInSight |
| 3503 |
// Jumps to a state if caller's target is in line-of-sight. |
| 3504 |
// args[0]: State to jump to |
| 3505 |
// args[1]: Field-of-view to check (degrees, in fixed point); if zero, will check in all directions |
| 3506 |
// |
| 3507 |
void A_JumpIfTargetInSight(mobj_t* actor) |
| 3508 |
{ |
| 3509 |
int state; |
| 3510 |
angle_t fov; |
| 3511 |
|
| 3512 |
if (!mbf21 || !actor || !actor->target) |
| 3513 |
return; |
| 3514 |
|
| 3515 |
state = (actor->state->args[0]); |
| 3516 |
fov = FixedToAngle(actor->state->args[1]); |
| 3517 |
|
| 3518 |
// Check FOV first since it's faster |
| 3519 |
if (fov > 0 && !P_CheckFov(actor, actor->target, fov)) |
| 3520 |
return; |
| 3521 |
|
| 3522 |
if (P_CheckSight(actor, actor->target)) |
| 3523 |
P_SetMobjState(actor, state); |
| 3524 |
} |
| 3525 |
|
| 3526 |
// |
| 3527 |
// A_JumpIfTargetCloser |
| 3528 |
// Jumps to a state if caller's target is closer than the specified distance. |
| 3529 |
// args[0]: State to jump to |
| 3530 |
// args[1]: Distance threshold |
| 3531 |
// |
| 3532 |
void A_JumpIfTargetCloser(mobj_t* actor) |
| 3533 |
{ |
| 3534 |
int state, distance; |
| 3535 |
|
| 3536 |
if (!mbf21 || !actor || !actor->target) |
| 3537 |
return; |
| 3538 |
|
| 3539 |
state = actor->state->args[0]; |
| 3540 |
distance = actor->state->args[1]; |
| 3541 |
|
| 3542 |
if (distance > P_AproxDistance(actor->x - actor->target->x, |
| 3543 |
actor->y - actor->target->y)) |
| 3544 |
P_SetMobjState(actor, state); |
| 3545 |
} |
| 3546 |
|
| 3547 |
// |
| 3548 |
// A_JumpIfTracerInSight |
| 3549 |
// Jumps to a state if caller's tracer (seek target) is in line-of-sight. |
| 3550 |
// args[0]: State to jump to |
| 3551 |
// args[1]: Field-of-view to check (degrees, in fixed point); if zero, will check in all directions |
| 3552 |
// |
| 3553 |
void A_JumpIfTracerInSight(mobj_t* actor) |
| 3554 |
{ |
| 3555 |
angle_t fov; |
| 3556 |
int state; |
| 3557 |
|
| 3558 |
if (!mbf21 || !actor || !actor->tracer) |
| 3559 |
return; |
| 3560 |
|
| 3561 |
state = (actor->state->args[0]); |
| 3562 |
fov = FixedToAngle(actor->state->args[1]); |
| 3563 |
|
| 3564 |
// Check FOV first since it's faster |
| 3565 |
if (fov > 0 && !P_CheckFov(actor, actor->tracer, fov)) |
| 3566 |
return; |
| 3567 |
|
| 3568 |
if (P_CheckSight(actor, actor->tracer)) |
| 3569 |
P_SetMobjState(actor, state); |
| 3570 |
} |
| 3571 |
|
| 3572 |
// |
| 3573 |
// A_JumpIfTracerCloser |
| 3574 |
// Jumps to a state if caller's tracer (seek target) is closer than the specified distance. |
| 3575 |
// args[0]: State to jump to |
| 3576 |
// args[1]: Distance threshold (fixed point) |
| 3577 |
// |
| 3578 |
void A_JumpIfTracerCloser(mobj_t* actor) |
| 3579 |
{ |
| 3580 |
int state, distance; |
| 3581 |
|
| 3582 |
if (!mbf21 || !actor || !actor->tracer) |
| 3583 |
return; |
| 3584 |
|
| 3585 |
state = actor->state->args[0]; |
| 3586 |
distance = actor->state->args[1]; |
| 3587 |
|
| 3588 |
if (distance > P_AproxDistance(actor->x - actor->tracer->x, |
| 3589 |
actor->y - actor->tracer->y)) |
| 3590 |
P_SetMobjState(actor, state); |
| 3591 |
} |
| 3592 |
|
| 3593 |
// |
| 3594 |
// A_JumpIfFlagsSet |
| 3595 |
// Jumps to a state if caller has the specified thing flags set. |
| 3596 |
// args[0]: State to jump to |
| 3597 |
// args[1]: Standard Flag(s) to check |
| 3598 |
// args[2]: MBF21 Flag(s) to check |
| 3599 |
// |
| 3600 |
void A_JumpIfFlagsSet(mobj_t* actor) |
| 3601 |
{ |
| 3602 |
int state; |
| 3603 |
uint64_t flags, flags2; |
| 3604 |
|
| 3605 |
if (!mbf21 || !actor) |
| 3606 |
return; |
| 3607 |
|
| 3608 |
state = actor->state->args[0]; |
| 3609 |
flags = actor->state->args[1]; |
| 3610 |
flags2 = actor->state->args[2]; |
| 3611 |
|
| 3612 |
if ((actor->flags & flags) == flags && |
| 3613 |
(actor->flags2 & flags2) == flags2) |
| 3614 |
P_SetMobjState(actor, state); |
| 3615 |
} |
| 3616 |
|
| 3617 |
// |
| 3618 |
// A_AddFlags |
| 3619 |
// Adds the specified thing flags to the caller. |
| 3620 |
// args[0]: Standard Flag(s) to add |
| 3621 |
// args[1]: MBF21 Flag(s) to add |
| 3622 |
// |
| 3623 |
void A_AddFlags(mobj_t* actor) |
| 3624 |
{ |
| 3625 |
uint64_t flags, flags2; |
| 3626 |
dboolean update_blockmap; |
| 3627 |
|
| 3628 |
if (!mbf21 || !actor) |
| 3629 |
return; |
| 3630 |
|
| 3631 |
flags = actor->state->args[0]; |
| 3632 |
flags2 = actor->state->args[1]; |
| 3633 |
|
| 3634 |
// unlink/relink the thing from the blockmap if |
| 3635 |
// the NOBLOCKMAP or NOSECTOR flags are added |
| 3636 |
update_blockmap = ((flags & MF_NOBLOCKMAP) && !(actor->flags & MF_NOBLOCKMAP)) |
| 3637 |
|| ((flags & MF_NOSECTOR) && !(actor->flags & MF_NOSECTOR)); |
| 3638 |
|
| 3639 |
if (update_blockmap) |
| 3640 |
P_UnsetThingPosition(actor); |
| 3641 |
|
| 3642 |
actor->flags |= flags; |
| 3643 |
actor->flags2 |= flags2; |
| 3644 |
|
| 3645 |
if (update_blockmap) |
| 3646 |
P_SetThingPosition(actor); |
| 3647 |
} |
| 3648 |
|
| 3649 |
// |
| 3650 |
// A_RemoveFlags |
| 3651 |
// Removes the specified thing flags from the caller. |
| 3652 |
// args[0]: Flag(s) to remove |
| 3653 |
// args[1]: MBF21 Flag(s) to remove |
| 3654 |
// |
| 3655 |
void A_RemoveFlags(mobj_t* actor) |
| 3656 |
{ |
| 3657 |
uint64_t flags, flags2; |
| 3658 |
dboolean update_blockmap; |
| 3659 |
|
| 3660 |
if (!mbf21 || !actor) |
| 3661 |
return; |
| 3662 |
|
| 3663 |
flags = actor->state->args[0]; |
| 3664 |
flags2 = actor->state->args[1]; |
| 3665 |
|
| 3666 |
// unlink/relink the thing from the blockmap if |
| 3667 |
// the NOBLOCKMAP or NOSECTOR flags are removed |
| 3668 |
update_blockmap = ((flags & MF_NOBLOCKMAP) && (actor->flags & MF_NOBLOCKMAP)) |
| 3669 |
|| ((flags & MF_NOSECTOR) && (actor->flags & MF_NOSECTOR)); |
| 3670 |
|
| 3671 |
if (update_blockmap) |
| 3672 |
P_UnsetThingPosition(actor); |
| 3673 |
|
| 3674 |
actor->flags &= ~flags; |
| 3675 |
actor->flags2 &= ~flags2; |
| 3676 |
|
| 3677 |
if (update_blockmap) |
| 3678 |
P_SetThingPosition(actor); |
| 3679 |
} |
| 3680 |
|
| 3681 |
|
| 3682 |
|
| 3683 |
// heretic |
| 3684 |
|
| 3685 |
#include "heretic/def.h" |
| 3686 |
|
| 3687 |
#define MAX_BOSS_SPOTS 8 |
| 3688 |
|
| 3689 |
typedef struct |
| 3690 |
{ |
| 3691 |
fixed_t x; |
| 3692 |
fixed_t y; |
| 3693 |
angle_t angle; |
| 3694 |
} BossSpot_t; |
| 3695 |
|
| 3696 |
static int BossSpotCount; |
| 3697 |
static BossSpot_t BossSpots[MAX_BOSS_SPOTS]; |
| 3698 |
|
| 3699 |
void P_InitMonsters(void) |
| 3700 |
{ |
| 3701 |
BossSpotCount = 0; |
| 3702 |
} |
| 3703 |
|
| 3704 |
void P_AddBossSpot(fixed_t x, fixed_t y, angle_t angle) |
| 3705 |
{ |
| 3706 |
if (BossSpotCount == MAX_BOSS_SPOTS) |
| 3707 |
{ |
| 3708 |
I_Error("Too many boss spots."); |
| 3709 |
} |
| 3710 |
BossSpots[BossSpotCount].x = x; |
| 3711 |
BossSpots[BossSpotCount].y = y; |
| 3712 |
BossSpots[BossSpotCount].angle = angle; |
| 3713 |
BossSpotCount++; |
| 3714 |
} |
| 3715 |
|
| 3716 |
void A_DripBlood(mobj_t * actor) |
| 3717 |
{ |
| 3718 |
mobj_t *mo; |
| 3719 |
int r1,r2; |
| 3720 |
|
| 3721 |
r1 = P_SubRandom(); |
| 3722 |
r2 = P_SubRandom(); |
| 3723 |
|
| 3724 |
mo = P_SpawnMobj(actor->x + (r2 << 11), |
| 3725 |
actor->y + (r1 << 11), actor->z, |
| 3726 |
HERETIC_MT_BLOOD); |
| 3727 |
mo->momx = P_SubRandom() << 10; |
| 3728 |
mo->momy = P_SubRandom() << 10; |
| 3729 |
mo->flags2 |= MF2_LOGRAV; |
| 3730 |
} |
| 3731 |
|
| 3732 |
void A_KnightAttack(mobj_t * actor) |
| 3733 |
{ |
| 3734 |
if (!actor->target) |
| 3735 |
{ |
| 3736 |
return; |
| 3737 |
} |
| 3738 |
if (P_CheckMeleeRange(actor)) |
| 3739 |
{ |
| 3740 |
P_DamageMobj(actor->target, actor, actor, HITDICE(3)); |
| 3741 |
S_StartMobjSound(actor, heretic_sfx_kgtat2); |
| 3742 |
return; |
| 3743 |
} |
| 3744 |
// Throw axe |
| 3745 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 3746 |
if (actor->type == HERETIC_MT_KNIGHTGHOST || P_Random(pr_heretic) < 40) |
| 3747 |
{ // Red axe |
| 3748 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_REDAXE); |
| 3749 |
return; |
| 3750 |
} |
| 3751 |
// Green axe |
| 3752 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_KNIGHTAXE); |
| 3753 |
} |
| 3754 |
|
| 3755 |
void A_ImpExplode(mobj_t * actor) |
| 3756 |
{ |
| 3757 |
mobj_t *mo; |
| 3758 |
|
| 3759 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_IMPCHUNK1); |
| 3760 |
mo->momx = P_SubRandom() << 10; |
| 3761 |
mo->momy = P_SubRandom() << 10; |
| 3762 |
mo->momz = 9 * FRACUNIT; |
| 3763 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_IMPCHUNK2); |
| 3764 |
mo->momx = P_SubRandom() << 10; |
| 3765 |
mo->momy = P_SubRandom() << 10; |
| 3766 |
mo->momz = 9 * FRACUNIT; |
| 3767 |
if (actor->special1.i == 666) |
| 3768 |
{ // Extreme death crash |
| 3769 |
P_SetMobjState(actor, HERETIC_S_IMP_XCRASH1); |
| 3770 |
} |
| 3771 |
} |
| 3772 |
|
| 3773 |
void A_BeastPuff(mobj_t * actor) |
| 3774 |
{ |
| 3775 |
if (P_Random(pr_heretic) > 64) |
| 3776 |
{ |
| 3777 |
int r1,r2,r3; |
| 3778 |
r1 = P_SubRandom(); |
| 3779 |
r2 = P_SubRandom(); |
| 3780 |
r3 = P_SubRandom(); |
| 3781 |
P_SpawnMobj(actor->x + (r3 << 10), |
| 3782 |
actor->y + (r2 << 10), |
| 3783 |
actor->z + (r1 << 10), HERETIC_MT_PUFFY); |
| 3784 |
} |
| 3785 |
} |
| 3786 |
|
| 3787 |
void A_ImpMeAttack(mobj_t * actor) |
| 3788 |
{ |
| 3789 |
if (!actor->target) |
| 3790 |
{ |
| 3791 |
return; |
| 3792 |
} |
| 3793 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 3794 |
if (P_CheckMeleeRange(actor)) |
| 3795 |
{ |
| 3796 |
P_DamageMobj(actor->target, actor, actor, 5 + (P_Random(pr_heretic) & 7)); |
| 3797 |
} |
| 3798 |
} |
| 3799 |
|
| 3800 |
void A_ImpMsAttack(mobj_t * actor) |
| 3801 |
{ |
| 3802 |
mobj_t *dest; |
| 3803 |
angle_t an; |
| 3804 |
int dist; |
| 3805 |
|
| 3806 |
if (!actor->target || P_Random(pr_heretic) > 64) |
| 3807 |
{ |
| 3808 |
P_SetMobjState(actor, actor->info->seestate); |
| 3809 |
return; |
| 3810 |
} |
| 3811 |
dest = actor->target; |
| 3812 |
actor->flags |= MF_SKULLFLY; |
| 3813 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 3814 |
A_FaceTarget(actor); |
| 3815 |
an = actor->angle >> ANGLETOFINESHIFT; |
| 3816 |
actor->momx = FixedMul(12 * FRACUNIT, finecosine[an]); |
| 3817 |
actor->momy = FixedMul(12 * FRACUNIT, finesine[an]); |
| 3818 |
dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); |
| 3819 |
dist = dist / (12 * FRACUNIT); |
| 3820 |
if (dist < 1) |
| 3821 |
{ |
| 3822 |
dist = 1; |
| 3823 |
} |
| 3824 |
actor->momz = (dest->z + (dest->height >> 1) - actor->z) / dist; |
| 3825 |
} |
| 3826 |
|
| 3827 |
void A_ImpMsAttack2(mobj_t * actor) |
| 3828 |
{ |
| 3829 |
if (!actor->target) |
| 3830 |
{ |
| 3831 |
return; |
| 3832 |
} |
| 3833 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 3834 |
if (P_CheckMeleeRange(actor)) |
| 3835 |
{ |
| 3836 |
P_DamageMobj(actor->target, actor, actor, 5 + (P_Random(pr_heretic) & 7)); |
| 3837 |
return; |
| 3838 |
} |
| 3839 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_IMPBALL); |
| 3840 |
} |
| 3841 |
|
| 3842 |
void A_ImpDeath(mobj_t * actor) |
| 3843 |
{ |
| 3844 |
actor->flags &= ~MF_SOLID; |
| 3845 |
actor->flags2 |= MF2_FOOTCLIP; |
| 3846 |
if (actor->z <= actor->floorz) |
| 3847 |
{ |
| 3848 |
P_SetMobjState(actor, HERETIC_S_IMP_CRASH1); |
| 3849 |
} |
| 3850 |
} |
| 3851 |
|
| 3852 |
void A_ImpXDeath1(mobj_t * actor) |
| 3853 |
{ |
| 3854 |
actor->flags &= ~MF_SOLID; |
| 3855 |
actor->flags |= MF_NOGRAVITY; |
| 3856 |
actor->flags2 |= MF2_FOOTCLIP; |
| 3857 |
actor->special1.i = 666; // Flag the crash routine |
| 3858 |
} |
| 3859 |
|
| 3860 |
void A_ImpXDeath2(mobj_t * actor) |
| 3861 |
{ |
| 3862 |
actor->flags &= ~MF_NOGRAVITY; |
| 3863 |
if (actor->z <= actor->floorz) |
| 3864 |
{ |
| 3865 |
P_SetMobjState(actor, HERETIC_S_IMP_CRASH1); |
| 3866 |
} |
| 3867 |
} |
| 3868 |
|
| 3869 |
dboolean P_UpdateChicken(mobj_t * actor, int tics) |
| 3870 |
{ |
| 3871 |
mobj_t *fog; |
| 3872 |
fixed_t x; |
| 3873 |
fixed_t y; |
| 3874 |
fixed_t z; |
| 3875 |
mobjtype_t moType; |
| 3876 |
mobj_t *mo; |
| 3877 |
mobj_t oldChicken; |
| 3878 |
|
| 3879 |
actor->special1.i -= tics; |
| 3880 |
if (actor->special1.i > 0) |
| 3881 |
{ |
| 3882 |
return (false); |
| 3883 |
} |
| 3884 |
moType = actor->special2.i; |
| 3885 |
x = actor->x; |
| 3886 |
y = actor->y; |
| 3887 |
z = actor->z; |
| 3888 |
oldChicken = *actor; |
| 3889 |
P_SetMobjState(actor, HERETIC_S_FREETARGMOBJ); |
| 3890 |
mo = P_SpawnMobj(x, y, z, moType); |
| 3891 |
dsda_WatchUnMorph(mo); |
| 3892 |
if (P_TestMobjLocation(mo) == false) |
| 3893 |
{ // Didn't fit |
| 3894 |
P_RemoveMobj(mo); |
| 3895 |
mo = P_SpawnMobj(x, y, z, HERETIC_MT_CHICKEN); |
| 3896 |
mo->angle = oldChicken.angle; |
| 3897 |
mo->flags = oldChicken.flags; |
| 3898 |
mo->health = oldChicken.health; |
| 3899 |
P_SetTarget(&mo->target, oldChicken.target); |
| 3900 |
mo->special1.i = 5 * 35; // Next try in 5 seconds |
| 3901 |
mo->special2.i = moType; |
| 3902 |
dsda_WatchMorph(mo); |
| 3903 |
return (false); |
| 3904 |
} |
| 3905 |
mo->angle = oldChicken.angle; |
| 3906 |
P_SetTarget(&mo->target, oldChicken.target); |
| 3907 |
fog = P_SpawnMobj(x, y, z + TELEFOGHEIGHT, HERETIC_MT_TFOG); |
| 3908 |
S_StartMobjSound(fog, heretic_sfx_telept); |
| 3909 |
return (true); |
| 3910 |
} |
| 3911 |
|
| 3912 |
void A_ChicAttack(mobj_t * actor) |
| 3913 |
{ |
| 3914 |
if (P_UpdateChicken(actor, 18)) |
| 3915 |
{ |
| 3916 |
return; |
| 3917 |
} |
| 3918 |
if (!actor->target) |
| 3919 |
{ |
| 3920 |
return; |
| 3921 |
} |
| 3922 |
if (P_CheckMeleeRange(actor)) |
| 3923 |
{ |
| 3924 |
P_DamageMobj(actor->target, actor, actor, 1 + (P_Random(pr_heretic) & 1)); |
| 3925 |
} |
| 3926 |
} |
| 3927 |
|
| 3928 |
void A_ChicLook(mobj_t * actor) |
| 3929 |
{ |
| 3930 |
if (P_UpdateChicken(actor, 10)) |
| 3931 |
{ |
| 3932 |
return; |
| 3933 |
} |
| 3934 |
A_Look(actor); |
| 3935 |
} |
| 3936 |
|
| 3937 |
void A_ChicChase(mobj_t * actor) |
| 3938 |
{ |
| 3939 |
if (P_UpdateChicken(actor, 3)) |
| 3940 |
{ |
| 3941 |
return; |
| 3942 |
} |
| 3943 |
A_Chase(actor); |
| 3944 |
} |
| 3945 |
|
| 3946 |
void A_ChicPain(mobj_t * actor) |
| 3947 |
{ |
| 3948 |
if (P_UpdateChicken(actor, 10)) |
| 3949 |
{ |
| 3950 |
return; |
| 3951 |
} |
| 3952 |
S_StartMobjSound(actor, actor->info->painsound); |
| 3953 |
} |
| 3954 |
|
| 3955 |
void A_Feathers(mobj_t * actor) |
| 3956 |
{ |
| 3957 |
int i; |
| 3958 |
int count; |
| 3959 |
mobj_t *mo; |
| 3960 |
|
| 3961 |
if (actor->health > 0) |
| 3962 |
{ // Pain |
| 3963 |
count = P_Random(pr_heretic) < 32 ? 2 : 1; |
| 3964 |
} |
| 3965 |
else |
| 3966 |
{ // Death |
| 3967 |
count = 5 + (P_Random(pr_heretic) & 3); |
| 3968 |
} |
| 3969 |
for (i = 0; i < count; i++) |
| 3970 |
{ |
| 3971 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 20 * FRACUNIT, |
| 3972 |
HERETIC_MT_FEATHER); |
| 3973 |
P_SetTarget(&mo->target, actor); |
| 3974 |
mo->momx = P_SubRandom() << 8; |
| 3975 |
mo->momy = P_SubRandom() << 8; |
| 3976 |
mo->momz = FRACUNIT + (P_Random(pr_heretic) << 9); |
| 3977 |
P_SetMobjState(mo, HERETIC_S_FEATHER1 + (P_Random(pr_heretic) & 7)); |
| 3978 |
} |
| 3979 |
} |
| 3980 |
|
| 3981 |
void A_MummyAttack(mobj_t * actor) |
| 3982 |
{ |
| 3983 |
if (!actor->target) |
| 3984 |
{ |
| 3985 |
return; |
| 3986 |
} |
| 3987 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 3988 |
if (P_CheckMeleeRange(actor)) |
| 3989 |
{ |
| 3990 |
P_DamageMobj(actor->target, actor, actor, HITDICE(2)); |
| 3991 |
S_StartMobjSound(actor, heretic_sfx_mumat2); |
| 3992 |
return; |
| 3993 |
} |
| 3994 |
S_StartMobjSound(actor, heretic_sfx_mumat1); |
| 3995 |
} |
| 3996 |
|
| 3997 |
void A_MummyAttack2(mobj_t * actor) |
| 3998 |
{ |
| 3999 |
mobj_t *mo; |
| 4000 |
|
| 4001 |
if (!actor->target) |
| 4002 |
{ |
| 4003 |
return; |
| 4004 |
} |
| 4005 |
|
| 4006 |
if (P_CheckMeleeRange(actor)) |
| 4007 |
{ |
| 4008 |
P_DamageMobj(actor->target, actor, actor, HITDICE(2)); |
| 4009 |
return; |
| 4010 |
} |
| 4011 |
mo = P_SpawnMissile(actor, actor->target, HERETIC_MT_MUMMYFX1); |
| 4012 |
|
| 4013 |
if (mo != NULL) |
| 4014 |
{ |
| 4015 |
P_SetTarget(&mo->special1.m, actor->target); |
| 4016 |
} |
| 4017 |
} |
| 4018 |
|
| 4019 |
void A_MummyFX1Seek(mobj_t * actor) |
| 4020 |
{ |
| 4021 |
P_SeekerMissile(actor, &actor->special1.m, ANG1_X * 10, ANG1_X * 20, false); |
| 4022 |
} |
| 4023 |
|
| 4024 |
void A_MummySoul(mobj_t * mummy) |
| 4025 |
{ |
| 4026 |
mobj_t *mo; |
| 4027 |
|
| 4028 |
mo = P_SpawnMobj(mummy->x, mummy->y, mummy->z + 10 * FRACUNIT, |
| 4029 |
HERETIC_MT_MUMMYSOUL); |
| 4030 |
mo->momz = FRACUNIT; |
| 4031 |
} |
| 4032 |
|
| 4033 |
void A_Sor1Pain(mobj_t * actor) |
| 4034 |
{ |
| 4035 |
actor->special1.i = 20; // Number of steps to walk fast |
| 4036 |
A_Pain(actor); |
| 4037 |
} |
| 4038 |
|
| 4039 |
void A_Sor1Chase(mobj_t * actor) |
| 4040 |
{ |
| 4041 |
if (actor->special1.i) |
| 4042 |
{ |
| 4043 |
actor->special1.i--; |
| 4044 |
actor->tics -= 3; |
| 4045 |
} |
| 4046 |
A_Chase(actor); |
| 4047 |
} |
| 4048 |
|
| 4049 |
void A_Srcr1Attack(mobj_t * actor) |
| 4050 |
{ |
| 4051 |
mobj_t *mo; |
| 4052 |
fixed_t momz; |
| 4053 |
angle_t angle; |
| 4054 |
|
| 4055 |
if (!actor->target) |
| 4056 |
{ |
| 4057 |
return; |
| 4058 |
} |
| 4059 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 4060 |
if (P_CheckMeleeRange(actor)) |
| 4061 |
{ |
| 4062 |
P_DamageMobj(actor->target, actor, actor, HITDICE(8)); |
| 4063 |
return; |
| 4064 |
} |
| 4065 |
if (actor->health > (P_MobjSpawnHealth(actor) / 3) * 2) |
| 4066 |
{ // Spit one fireball |
| 4067 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_SRCRFX1); |
| 4068 |
} |
| 4069 |
else |
| 4070 |
{ // Spit three fireballs |
| 4071 |
mo = P_SpawnMissile(actor, actor->target, HERETIC_MT_SRCRFX1); |
| 4072 |
if (mo) |
| 4073 |
{ |
| 4074 |
momz = mo->momz; |
| 4075 |
angle = mo->angle; |
| 4076 |
P_SpawnMissileAngle(actor, HERETIC_MT_SRCRFX1, angle - ANG1_X * 3, momz); |
| 4077 |
P_SpawnMissileAngle(actor, HERETIC_MT_SRCRFX1, angle + ANG1_X * 3, momz); |
| 4078 |
} |
| 4079 |
if (actor->health < P_MobjSpawnHealth(actor) / 3) |
| 4080 |
{ // Maybe attack again |
| 4081 |
if (actor->special1.i) |
| 4082 |
{ // Just attacked, so don't attack again |
| 4083 |
actor->special1.i = 0; |
| 4084 |
} |
| 4085 |
else |
| 4086 |
{ // Set state to attack again |
| 4087 |
actor->special1.i = 1; |
| 4088 |
P_SetMobjState(actor, HERETIC_S_SRCR1_ATK4); |
| 4089 |
} |
| 4090 |
} |
| 4091 |
} |
| 4092 |
} |
| 4093 |
|
| 4094 |
void A_SorcererRise(mobj_t * actor) |
| 4095 |
{ |
| 4096 |
mobj_t *mo; |
| 4097 |
|
| 4098 |
actor->flags &= ~MF_SOLID; |
| 4099 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_SORCERER2); |
| 4100 |
P_SetMobjState(mo, HERETIC_S_SOR2_RISE1); |
| 4101 |
mo->angle = actor->angle; |
| 4102 |
P_SetTarget(&mo->target, actor->target); |
| 4103 |
} |
| 4104 |
|
| 4105 |
void P_DSparilTeleport(mobj_t * actor) |
| 4106 |
{ |
| 4107 |
int i; |
| 4108 |
fixed_t x; |
| 4109 |
fixed_t y; |
| 4110 |
fixed_t prevX; |
| 4111 |
fixed_t prevY; |
| 4112 |
fixed_t prevZ; |
| 4113 |
mobj_t *mo; |
| 4114 |
|
| 4115 |
if (!BossSpotCount) |
| 4116 |
{ // No spots |
| 4117 |
return; |
| 4118 |
} |
| 4119 |
i = P_Random(pr_heretic); |
| 4120 |
do |
| 4121 |
{ |
| 4122 |
i++; |
| 4123 |
x = BossSpots[i % BossSpotCount].x; |
| 4124 |
y = BossSpots[i % BossSpotCount].y; |
| 4125 |
} |
| 4126 |
while (P_AproxDistance(actor->x - x, actor->y - y) < 128 * FRACUNIT); |
| 4127 |
prevX = actor->x; |
| 4128 |
prevY = actor->y; |
| 4129 |
prevZ = actor->z; |
| 4130 |
if (P_TeleportMove(actor, x, y, false)) |
| 4131 |
{ |
| 4132 |
mo = P_SpawnMobj(prevX, prevY, prevZ, HERETIC_MT_SOR2TELEFADE); |
| 4133 |
S_StartMobjSound(mo, heretic_sfx_telept); |
| 4134 |
P_SetMobjState(actor, HERETIC_S_SOR2_TELE1); |
| 4135 |
S_StartMobjSound(actor, heretic_sfx_telept); |
| 4136 |
actor->z = actor->floorz; |
| 4137 |
actor->angle = BossSpots[i % BossSpotCount].angle; |
| 4138 |
actor->momx = actor->momy = actor->momz = 0; |
| 4139 |
} |
| 4140 |
} |
| 4141 |
|
| 4142 |
|
| 4143 |
void A_Srcr2Decide(mobj_t * actor) |
| 4144 |
{ |
| 4145 |
static int chance[] = { |
| 4146 |
192, 120, 120, 120, 64, 64, 32, 16, 0 |
| 4147 |
}; |
| 4148 |
|
| 4149 |
if (!BossSpotCount) |
| 4150 |
{ // No spots |
| 4151 |
return; |
| 4152 |
} |
| 4153 |
if (P_Random(pr_heretic) < chance[actor->health / (P_MobjSpawnHealth(actor) / 8)]) |
| 4154 |
{ |
| 4155 |
P_DSparilTeleport(actor); |
| 4156 |
} |
| 4157 |
} |
| 4158 |
|
| 4159 |
void A_Srcr2Attack(mobj_t * actor) |
| 4160 |
{ |
| 4161 |
int chance; |
| 4162 |
|
| 4163 |
if (!actor->target) |
| 4164 |
{ |
| 4165 |
return; |
| 4166 |
} |
| 4167 |
S_StartVoidSound(actor->info->attacksound); |
| 4168 |
if (P_CheckMeleeRange(actor)) |
| 4169 |
{ |
| 4170 |
P_DamageMobj(actor->target, actor, actor, HITDICE(20)); |
| 4171 |
return; |
| 4172 |
} |
| 4173 |
chance = actor->health < P_MobjSpawnHealth(actor) / 2 ? 96 : 48; |
| 4174 |
if (P_Random(pr_heretic) < chance) |
| 4175 |
{ // Wizard spawners |
| 4176 |
P_SpawnMissileAngle(actor, HERETIC_MT_SOR2FX2, |
| 4177 |
actor->angle - ANG45, FRACUNIT / 2); |
| 4178 |
P_SpawnMissileAngle(actor, HERETIC_MT_SOR2FX2, |
| 4179 |
actor->angle + ANG45, FRACUNIT / 2); |
| 4180 |
} |
| 4181 |
else |
| 4182 |
{ // Blue bolt |
| 4183 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_SOR2FX1); |
| 4184 |
} |
| 4185 |
} |
| 4186 |
|
| 4187 |
void A_BlueSpark(mobj_t * actor) |
| 4188 |
{ |
| 4189 |
int i; |
| 4190 |
mobj_t *mo; |
| 4191 |
|
| 4192 |
for (i = 0; i < 2; i++) |
| 4193 |
{ |
| 4194 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_SOR2FXSPARK); |
| 4195 |
mo->momx = P_SubRandom() << 9; |
| 4196 |
mo->momy = P_SubRandom() << 9; |
| 4197 |
mo->momz = FRACUNIT + (P_Random(pr_heretic) << 8); |
| 4198 |
} |
| 4199 |
} |
| 4200 |
|
| 4201 |
void A_GenWizard(mobj_t * actor) |
| 4202 |
{ |
| 4203 |
mobj_t *mo; |
| 4204 |
mobj_t *fog; |
| 4205 |
|
| 4206 |
mo = P_SpawnMobj(actor->x, actor->y, |
| 4207 |
actor->z - mobjinfo[HERETIC_MT_WIZARD].height / 2, HERETIC_MT_WIZARD); |
| 4208 |
if (P_TestMobjLocation(mo) == false) |
| 4209 |
{ // Didn't fit |
| 4210 |
P_RemoveMobj(mo); |
| 4211 |
return; |
| 4212 |
} |
| 4213 |
actor->momx = actor->momy = actor->momz = 0; |
| 4214 |
P_SetMobjState(actor, mobjinfo[actor->type].deathstate); |
| 4215 |
actor->flags &= ~MF_MISSILE; |
| 4216 |
fog = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_TFOG); |
| 4217 |
S_StartMobjSound(fog, heretic_sfx_telept); |
| 4218 |
} |
| 4219 |
|
| 4220 |
void P_Massacre(void) |
| 4221 |
{ |
| 4222 |
mobj_t *mo; |
| 4223 |
thinker_t *think; |
| 4224 |
|
| 4225 |
for (think = thinkercap.next; think != &thinkercap; think = think->next) |
| 4226 |
{ |
| 4227 |
if (think->function != P_MobjThinker) |
| 4228 |
{ // Not a mobj thinker |
| 4229 |
continue; |
| 4230 |
} |
| 4231 |
mo = (mobj_t *) think; |
| 4232 |
if ((mo->flags & MF_COUNTKILL) && (mo->health > 0)) |
| 4233 |
{ |
| 4234 |
if (hexen) |
| 4235 |
{ |
| 4236 |
mo->flags2 &= ~(MF2_NONSHOOTABLE + MF2_INVULNERABLE); |
| 4237 |
mo->flags |= MF_SHOOTABLE; |
| 4238 |
} |
| 4239 |
P_DamageMobj(mo, NULL, NULL, 10000); |
| 4240 |
} |
| 4241 |
} |
| 4242 |
} |
| 4243 |
|
| 4244 |
void A_Sor2DthInit(mobj_t * actor) |
| 4245 |
{ |
| 4246 |
actor->special1.i = 7; // Animation loop counter |
| 4247 |
P_Massacre(); // Kill monsters early |
| 4248 |
} |
| 4249 |
|
| 4250 |
void A_Sor2DthLoop(mobj_t * actor) |
| 4251 |
{ |
| 4252 |
if (--actor->special1.i) |
| 4253 |
{ // Need to loop |
| 4254 |
P_SetMobjState(actor, HERETIC_S_SOR2_DIE4); |
| 4255 |
} |
| 4256 |
} |
| 4257 |
|
| 4258 |
void A_SorZap(mobj_t * actor) |
| 4259 |
{ |
| 4260 |
S_StartVoidSound(heretic_sfx_sorzap); |
| 4261 |
} |
| 4262 |
|
| 4263 |
void A_SorRise(mobj_t * actor) |
| 4264 |
{ |
| 4265 |
S_StartVoidSound(heretic_sfx_sorrise); |
| 4266 |
} |
| 4267 |
|
| 4268 |
void A_SorDSph(mobj_t * actor) |
| 4269 |
{ |
| 4270 |
S_StartVoidSound(heretic_sfx_sordsph); |
| 4271 |
} |
| 4272 |
|
| 4273 |
void A_SorDExp(mobj_t * actor) |
| 4274 |
{ |
| 4275 |
S_StartVoidSound(heretic_sfx_sordexp); |
| 4276 |
} |
| 4277 |
|
| 4278 |
void A_SorDBon(mobj_t * actor) |
| 4279 |
{ |
| 4280 |
S_StartVoidSound(heretic_sfx_sordbon); |
| 4281 |
} |
| 4282 |
|
| 4283 |
void A_SorSightSnd(mobj_t * actor) |
| 4284 |
{ |
| 4285 |
S_StartVoidSound(heretic_sfx_sorsit); |
| 4286 |
} |
| 4287 |
|
| 4288 |
void A_MinotaurAtk1(mobj_t * actor) |
| 4289 |
{ |
| 4290 |
player_t *player; |
| 4291 |
|
| 4292 |
if (!actor->target) |
| 4293 |
{ |
| 4294 |
return; |
| 4295 |
} |
| 4296 |
S_StartMobjSound(actor, g_mntr_atk1_sfx); |
| 4297 |
if (P_CheckMeleeRange(actor)) |
| 4298 |
{ |
| 4299 |
P_DamageMobj(actor->target, actor, actor, HITDICE(4)); |
| 4300 |
if (heretic && (player = actor->target->player) != NULL) |
| 4301 |
{ // Squish the player |
| 4302 |
player->deltaviewheight = -16 * FRACUNIT; |
| 4303 |
} |
| 4304 |
} |
| 4305 |
} |
| 4306 |
|
| 4307 |
void A_MinotaurDecide(mobj_t * actor) |
| 4308 |
{ |
| 4309 |
angle_t angle; |
| 4310 |
mobj_t *target; |
| 4311 |
int dist; |
| 4312 |
|
| 4313 |
target = actor->target; |
| 4314 |
if (!target) |
| 4315 |
{ |
| 4316 |
return; |
| 4317 |
} |
| 4318 |
if (heretic) |
| 4319 |
S_StartMobjSound(actor, heretic_sfx_minsit); |
| 4320 |
dist = P_AproxDistance(actor->x - target->x, actor->y - target->y); |
| 4321 |
if (target->z + target->height > actor->z |
| 4322 |
&& target->z + target->height < actor->z + actor->height |
| 4323 |
&& dist < g_mntr_decide_range * 64 * FRACUNIT |
| 4324 |
&& dist > 1 * 64 * FRACUNIT && P_Random(pr_heretic) < g_mntr_charge_rng) |
| 4325 |
{ // Charge attack |
| 4326 |
// Don't call the state function right away |
| 4327 |
P_SetMobjStateNF(actor, g_mntr_charge_state); |
| 4328 |
actor->flags |= MF_SKULLFLY; |
| 4329 |
A_FaceTarget(actor); |
| 4330 |
angle = actor->angle >> ANGLETOFINESHIFT; |
| 4331 |
actor->momx = FixedMul(g_mntr_charge_speed, finecosine[angle]); |
| 4332 |
actor->momy = FixedMul(g_mntr_charge_speed, finesine[angle]); |
| 4333 |
// Charge duration |
| 4334 |
if (hexen) |
| 4335 |
actor->special_args[4] = 35 / 2; |
| 4336 |
else |
| 4337 |
actor->special1.i = 35 / 2; |
| 4338 |
} |
| 4339 |
else if (target->z == target->floorz |
| 4340 |
&& dist < 9 * 64 * FRACUNIT && P_Random(pr_heretic) < g_mntr_fire_rng) |
| 4341 |
{ // Floor fire attack |
| 4342 |
P_SetMobjState(actor, g_mntr_fire_state); |
| 4343 |
actor->special2.i = 0; |
| 4344 |
} |
| 4345 |
else |
| 4346 |
{ // Swing attack |
| 4347 |
A_FaceTarget(actor); |
| 4348 |
// Don't need to call P_SetMobjState because the current state |
| 4349 |
// falls through to the swing attack |
| 4350 |
} |
| 4351 |
} |
| 4352 |
|
| 4353 |
void A_MinotaurCharge(mobj_t * actor) |
| 4354 |
{ |
| 4355 |
mobj_t *puff; |
| 4356 |
|
| 4357 |
if (hexen && !actor->target) |
| 4358 |
return; |
| 4359 |
|
| 4360 |
if (hexen ? actor->special_args[4] > 0 : actor->special1.i) |
| 4361 |
{ |
| 4362 |
puff = P_SpawnMobj(actor->x, actor->y, actor->z, g_mntr_charge_puff); |
| 4363 |
puff->momz = 2 * FRACUNIT; |
| 4364 |
if (hexen) |
| 4365 |
actor->special_args[4]--; |
| 4366 |
else |
| 4367 |
actor->special1.i--; |
| 4368 |
} |
| 4369 |
else |
| 4370 |
{ |
| 4371 |
actor->flags &= ~MF_SKULLFLY; |
| 4372 |
P_SetMobjState(actor, actor->info->seestate); |
| 4373 |
} |
| 4374 |
} |
| 4375 |
|
| 4376 |
void A_MinotaurAtk2(mobj_t * actor) |
| 4377 |
{ |
| 4378 |
mobj_t *mo; |
| 4379 |
angle_t angle; |
| 4380 |
fixed_t momz; |
| 4381 |
|
| 4382 |
if (!actor->target) |
| 4383 |
{ |
| 4384 |
return; |
| 4385 |
} |
| 4386 |
S_StartMobjSound(actor, g_mntr_atk2_sfx); |
| 4387 |
if (P_CheckMeleeRange(actor)) |
| 4388 |
{ |
| 4389 |
P_DamageMobj(actor->target, actor, actor, HITDICE(g_mntr_atk2_dice)); |
| 4390 |
return; |
| 4391 |
} |
| 4392 |
mo = P_SpawnMissile(actor, actor->target, g_mntr_atk2_missile); |
| 4393 |
if (mo) |
| 4394 |
{ |
| 4395 |
if (heretic) |
| 4396 |
S_StartMobjSound(mo, g_mntr_atk2_sfx); |
| 4397 |
momz = mo->momz; |
| 4398 |
angle = mo->angle; |
| 4399 |
P_SpawnMissileAngle(actor, g_mntr_atk2_missile, angle - (ANG45 / 8), momz); |
| 4400 |
P_SpawnMissileAngle(actor, g_mntr_atk2_missile, angle + (ANG45 / 8), momz); |
| 4401 |
P_SpawnMissileAngle(actor, g_mntr_atk2_missile, angle - (ANG45 / 16), momz); |
| 4402 |
P_SpawnMissileAngle(actor, g_mntr_atk2_missile, angle + (ANG45 / 16), momz); |
| 4403 |
} |
| 4404 |
} |
| 4405 |
|
| 4406 |
void A_MinotaurAtk3(mobj_t * actor) |
| 4407 |
{ |
| 4408 |
mobj_t *mo; |
| 4409 |
player_t *player; |
| 4410 |
|
| 4411 |
if (!actor->target) |
| 4412 |
{ |
| 4413 |
return; |
| 4414 |
} |
| 4415 |
if (P_CheckMeleeRange(actor)) |
| 4416 |
{ |
| 4417 |
P_DamageMobj(actor->target, actor, actor, HITDICE(g_mntr_atk3_dice)); |
| 4418 |
if ((player = actor->target->player) != NULL) |
| 4419 |
{ // Squish the player |
| 4420 |
player->deltaviewheight = -16 * FRACUNIT; |
| 4421 |
} |
| 4422 |
} |
| 4423 |
else |
| 4424 |
{ |
| 4425 |
mo = P_SpawnMissile(actor, actor->target, g_mntr_atk3_missile); |
| 4426 |
if (mo != NULL) |
| 4427 |
{ |
| 4428 |
S_StartMobjSound(mo, g_mntr_atk3_sfx); |
| 4429 |
} |
| 4430 |
} |
| 4431 |
if (P_Random(pr_heretic) < 192 && actor->special2.i == 0) |
| 4432 |
{ |
| 4433 |
P_SetMobjState(actor, g_mntr_atk3_state); |
| 4434 |
actor->special2.i = 1; |
| 4435 |
} |
| 4436 |
} |
| 4437 |
|
| 4438 |
void A_MntrFloorFire(mobj_t * actor) |
| 4439 |
{ |
| 4440 |
mobj_t *mo; |
| 4441 |
int r1, r2; |
| 4442 |
|
| 4443 |
r1 = P_SubRandom(); |
| 4444 |
r2 = P_SubRandom(); |
| 4445 |
|
| 4446 |
actor->z = actor->floorz; |
| 4447 |
mo = P_SpawnMobj(actor->x + (r2 << 10), |
| 4448 |
actor->y + (r1 << 10), ONFLOORZ, |
| 4449 |
g_mntr_fire); |
| 4450 |
P_SetTarget(&mo->target, actor->target); |
| 4451 |
mo->momx = 1; // Force block checking |
| 4452 |
P_CheckMissileSpawn(mo); |
| 4453 |
} |
| 4454 |
|
| 4455 |
void A_BeastAttack(mobj_t * actor) |
| 4456 |
{ |
| 4457 |
if (!actor->target) |
| 4458 |
{ |
| 4459 |
return; |
| 4460 |
} |
| 4461 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 4462 |
if (P_CheckMeleeRange(actor)) |
| 4463 |
{ |
| 4464 |
P_DamageMobj(actor->target, actor, actor, HITDICE(3)); |
| 4465 |
return; |
| 4466 |
} |
| 4467 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_BEASTBALL); |
| 4468 |
} |
| 4469 |
|
| 4470 |
void A_WhirlwindSeek(mobj_t * actor) |
| 4471 |
{ |
| 4472 |
actor->health -= 3; |
| 4473 |
if (actor->health < 0) |
| 4474 |
{ |
| 4475 |
actor->momx = actor->momy = actor->momz = 0; |
| 4476 |
P_SetMobjState(actor, mobjinfo[actor->type].deathstate); |
| 4477 |
actor->flags &= ~MF_MISSILE; |
| 4478 |
return; |
| 4479 |
} |
| 4480 |
if ((actor->special2.i -= 3) < 0) |
| 4481 |
{ |
| 4482 |
actor->special2.i = 58 + (P_Random(pr_heretic) & 31); |
| 4483 |
S_StartMobjSound(actor, heretic_sfx_hedat3); |
| 4484 |
} |
| 4485 |
if (actor->special1.m |
| 4486 |
&& (((mobj_t *) (actor->special1.m))->flags & MF_SHADOW)) |
| 4487 |
{ |
| 4488 |
return; |
| 4489 |
} |
| 4490 |
P_SeekerMissile(actor, &actor->special1.m, ANG1_X * 10, ANG1_X * 30, false); |
| 4491 |
} |
| 4492 |
|
| 4493 |
void A_HeadIceImpact(mobj_t * ice) |
| 4494 |
{ |
| 4495 |
unsigned int i; |
| 4496 |
angle_t angle; |
| 4497 |
mobj_t *shard; |
| 4498 |
|
| 4499 |
for (i = 0; i < 8; i++) |
| 4500 |
{ |
| 4501 |
shard = P_SpawnMobj(ice->x, ice->y, ice->z, HERETIC_MT_HEADFX2); |
| 4502 |
angle = i * ANG45; |
| 4503 |
P_SetTarget(&shard->target, ice->target); |
| 4504 |
shard->angle = angle; |
| 4505 |
angle >>= ANGLETOFINESHIFT; |
| 4506 |
shard->momx = FixedMul(shard->info->speed, finecosine[angle]); |
| 4507 |
shard->momy = FixedMul(shard->info->speed, finesine[angle]); |
| 4508 |
shard->momz = (fixed_t)(-.6 * FRACUNIT); |
| 4509 |
P_CheckMissileSpawn(shard); |
| 4510 |
} |
| 4511 |
} |
| 4512 |
|
| 4513 |
void A_HeadFireGrow(mobj_t * fire) |
| 4514 |
{ |
| 4515 |
fire->health--; |
| 4516 |
fire->z += 9 * FRACUNIT; |
| 4517 |
if (fire->health == 0) |
| 4518 |
{ |
| 4519 |
fire->damage = fire->info->damage; |
| 4520 |
P_SetMobjState(fire, HERETIC_S_HEADFX3_4); |
| 4521 |
} |
| 4522 |
} |
| 4523 |
|
| 4524 |
void A_SnakeAttack(mobj_t * actor) |
| 4525 |
{ |
| 4526 |
if (!actor->target) |
| 4527 |
{ |
| 4528 |
P_SetMobjState(actor, HERETIC_S_SNAKE_WALK1); |
| 4529 |
return; |
| 4530 |
} |
| 4531 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 4532 |
A_FaceTarget(actor); |
| 4533 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_SNAKEPRO_A); |
| 4534 |
} |
| 4535 |
|
| 4536 |
void A_SnakeAttack2(mobj_t * actor) |
| 4537 |
{ |
| 4538 |
if (!actor->target) |
| 4539 |
{ |
| 4540 |
P_SetMobjState(actor, HERETIC_S_SNAKE_WALK1); |
| 4541 |
return; |
| 4542 |
} |
| 4543 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 4544 |
A_FaceTarget(actor); |
| 4545 |
P_SpawnMissile(actor, actor->target, HERETIC_MT_SNAKEPRO_B); |
| 4546 |
} |
| 4547 |
|
| 4548 |
void A_ClinkAttack(mobj_t * actor) |
| 4549 |
{ |
| 4550 |
int damage; |
| 4551 |
|
| 4552 |
if (!actor->target) |
| 4553 |
{ |
| 4554 |
return; |
| 4555 |
} |
| 4556 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 4557 |
if (P_CheckMeleeRange(actor)) |
| 4558 |
{ |
| 4559 |
damage = ((P_Random(pr_heretic) % 7) + 3); |
| 4560 |
P_DamageMobj(actor->target, actor, actor, damage); |
| 4561 |
} |
| 4562 |
} |
| 4563 |
|
| 4564 |
void A_GhostOff(mobj_t * actor) |
| 4565 |
{ |
| 4566 |
actor->flags &= ~MF_SHADOW; |
| 4567 |
} |
| 4568 |
|
| 4569 |
void A_WizAtk1(mobj_t * actor) |
| 4570 |
{ |
| 4571 |
A_FaceTarget(actor); |
| 4572 |
actor->flags &= ~MF_SHADOW; |
| 4573 |
} |
| 4574 |
|
| 4575 |
void A_WizAtk2(mobj_t * actor) |
| 4576 |
{ |
| 4577 |
A_FaceTarget(actor); |
| 4578 |
actor->flags |= MF_SHADOW; |
| 4579 |
} |
| 4580 |
|
| 4581 |
void A_WizAtk3(mobj_t * actor) |
| 4582 |
{ |
| 4583 |
mobj_t *mo; |
| 4584 |
angle_t angle; |
| 4585 |
fixed_t momz; |
| 4586 |
|
| 4587 |
actor->flags &= ~MF_SHADOW; |
| 4588 |
if (!actor->target) |
| 4589 |
{ |
| 4590 |
return; |
| 4591 |
} |
| 4592 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 4593 |
if (P_CheckMeleeRange(actor)) |
| 4594 |
{ |
| 4595 |
P_DamageMobj(actor->target, actor, actor, HITDICE(4)); |
| 4596 |
return; |
| 4597 |
} |
| 4598 |
mo = P_SpawnMissile(actor, actor->target, HERETIC_MT_WIZFX1); |
| 4599 |
if (mo) |
| 4600 |
{ |
| 4601 |
momz = mo->momz; |
| 4602 |
angle = mo->angle; |
| 4603 |
P_SpawnMissileAngle(actor, HERETIC_MT_WIZFX1, angle - (ANG45 / 8), momz); |
| 4604 |
P_SpawnMissileAngle(actor, HERETIC_MT_WIZFX1, angle + (ANG45 / 8), momz); |
| 4605 |
} |
| 4606 |
} |
| 4607 |
|
| 4608 |
void P_DropItem(mobj_t * source, mobjtype_t type, int special, int chance) |
| 4609 |
{ |
| 4610 |
mobj_t *mo; |
| 4611 |
|
| 4612 |
if (P_Random(pr_heretic) > chance) |
| 4613 |
{ |
| 4614 |
return; |
| 4615 |
} |
| 4616 |
mo = P_SpawnMobj(source->x, source->y, |
| 4617 |
source->z + (source->height >> 1), type); |
| 4618 |
mo->momx = P_SubRandom() << 8; |
| 4619 |
mo->momy = P_SubRandom() << 8; |
| 4620 |
mo->momz = FRACUNIT * 5 + (P_Random(pr_heretic) << 10); |
| 4621 |
mo->flags |= MF_DROPPED; |
| 4622 |
mo->health = special; |
| 4623 |
} |
| 4624 |
|
| 4625 |
void A_NoBlocking(mobj_t * actor) |
| 4626 |
{ |
| 4627 |
actor->flags &= ~MF_SOLID; |
| 4628 |
|
| 4629 |
if (hexen) |
| 4630 |
return; |
| 4631 |
|
| 4632 |
// Check for monsters dropping things |
| 4633 |
switch (actor->type) |
| 4634 |
{ |
| 4635 |
case HERETIC_MT_MUMMY: |
| 4636 |
case HERETIC_MT_MUMMYLEADER: |
| 4637 |
case HERETIC_MT_MUMMYGHOST: |
| 4638 |
case HERETIC_MT_MUMMYLEADERGHOST: |
| 4639 |
P_DropItem(actor, HERETIC_MT_AMGWNDWIMPY, 3, 84); |
| 4640 |
break; |
| 4641 |
case HERETIC_MT_KNIGHT: |
| 4642 |
case HERETIC_MT_KNIGHTGHOST: |
| 4643 |
P_DropItem(actor, HERETIC_MT_AMCBOWWIMPY, 5, 84); |
| 4644 |
break; |
| 4645 |
case HERETIC_MT_WIZARD: |
| 4646 |
P_DropItem(actor, HERETIC_MT_AMBLSRWIMPY, 10, 84); |
| 4647 |
P_DropItem(actor, HERETIC_MT_ARTITOMEOFPOWER, 0, 4); |
| 4648 |
break; |
| 4649 |
case HERETIC_MT_HEAD: |
| 4650 |
P_DropItem(actor, HERETIC_MT_AMBLSRWIMPY, 10, 84); |
| 4651 |
P_DropItem(actor, HERETIC_MT_ARTIEGG, 0, 51); |
| 4652 |
break; |
| 4653 |
case HERETIC_MT_BEAST: |
| 4654 |
P_DropItem(actor, HERETIC_MT_AMCBOWWIMPY, 10, 84); |
| 4655 |
break; |
| 4656 |
case HERETIC_MT_CLINK: |
| 4657 |
P_DropItem(actor, HERETIC_MT_AMSKRDWIMPY, 20, 84); |
| 4658 |
break; |
| 4659 |
case HERETIC_MT_SNAKE: |
| 4660 |
P_DropItem(actor, HERETIC_MT_AMPHRDWIMPY, 5, 84); |
| 4661 |
break; |
| 4662 |
case HERETIC_MT_MINOTAUR: |
| 4663 |
P_DropItem(actor, HERETIC_MT_ARTISUPERHEAL, 0, 51); |
| 4664 |
P_DropItem(actor, HERETIC_MT_AMPHRDWIMPY, 10, 84); |
| 4665 |
break; |
| 4666 |
default: |
| 4667 |
break; |
| 4668 |
} |
| 4669 |
} |
| 4670 |
|
| 4671 |
void A_PodPain(mobj_t * actor) |
| 4672 |
{ |
| 4673 |
int i; |
| 4674 |
int count; |
| 4675 |
int chance; |
| 4676 |
mobj_t *goo; |
| 4677 |
|
| 4678 |
chance = P_Random(pr_heretic); |
| 4679 |
if (chance < 128) |
| 4680 |
{ |
| 4681 |
return; |
| 4682 |
} |
| 4683 |
count = chance > 240 ? 2 : 1; |
| 4684 |
for (i = 0; i < count; i++) |
| 4685 |
{ |
| 4686 |
goo = P_SpawnMobj(actor->x, actor->y, |
| 4687 |
actor->z + 48 * FRACUNIT, HERETIC_MT_PODGOO); |
| 4688 |
P_SetTarget(&goo->target, actor); |
| 4689 |
goo->momx = P_SubRandom() << 9; |
| 4690 |
goo->momy = P_SubRandom() << 9; |
| 4691 |
goo->momz = FRACUNIT / 2 + (P_Random(pr_heretic) << 9); |
| 4692 |
} |
| 4693 |
} |
| 4694 |
|
| 4695 |
void A_RemovePod(mobj_t * actor) |
| 4696 |
{ |
| 4697 |
mobj_t *mo; |
| 4698 |
|
| 4699 |
if (actor->special2.m) |
| 4700 |
{ |
| 4701 |
mo = (mobj_t *) actor->special2.m; |
| 4702 |
if (mo->special1.i > 0) |
| 4703 |
{ |
| 4704 |
mo->special1.i--; |
| 4705 |
} |
| 4706 |
} |
| 4707 |
} |
| 4708 |
|
| 4709 |
#define MAX_GEN_PODS 16 |
| 4710 |
|
| 4711 |
void A_MakePod(mobj_t * actor) |
| 4712 |
{ |
| 4713 |
mobj_t *mo; |
| 4714 |
fixed_t x; |
| 4715 |
fixed_t y; |
| 4716 |
|
| 4717 |
if (actor->special1.i == MAX_GEN_PODS) |
| 4718 |
{ // Too many generated pods |
| 4719 |
return; |
| 4720 |
} |
| 4721 |
x = actor->x; |
| 4722 |
y = actor->y; |
| 4723 |
mo = P_SpawnMobj(x, y, ONFLOORZ, HERETIC_MT_POD); |
| 4724 |
if (P_CheckPosition(mo, x, y) == false) |
| 4725 |
{ // Didn't fit |
| 4726 |
P_RemoveMobj(mo); |
| 4727 |
return; |
| 4728 |
} |
| 4729 |
P_SetMobjState(mo, HERETIC_S_POD_GROW1); |
| 4730 |
P_ThrustMobj(mo, P_Random(pr_heretic) << 24, (fixed_t) (4.5 * FRACUNIT)); |
| 4731 |
S_StartMobjSound(mo, heretic_sfx_newpod); |
| 4732 |
actor->special1.i++; // Increment generated pod count |
| 4733 |
P_SetTarget(&mo->special2.m, actor); // Link the generator to the pod |
| 4734 |
return; |
| 4735 |
} |
| 4736 |
|
| 4737 |
void A_ESound(mobj_t * mo) |
| 4738 |
{ |
| 4739 |
int sound = heretic_sfx_None; |
| 4740 |
|
| 4741 |
switch (mo->type) |
| 4742 |
{ |
| 4743 |
case HERETIC_MT_SOUNDWATERFALL: |
| 4744 |
sound = heretic_sfx_waterfl; |
| 4745 |
break; |
| 4746 |
case HERETIC_MT_SOUNDWIND: |
| 4747 |
sound = heretic_sfx_wind; |
| 4748 |
break; |
| 4749 |
case HEXEN_MT_SOUNDWIND: |
| 4750 |
sound = hexen_sfx_wind; |
| 4751 |
break; |
| 4752 |
default: |
| 4753 |
break; |
| 4754 |
} |
| 4755 |
S_StartMobjSound(mo, sound); |
| 4756 |
} |
| 4757 |
|
| 4758 |
void A_SpawnTeleGlitter(mobj_t * actor) |
| 4759 |
{ |
| 4760 |
mobj_t *mo; |
| 4761 |
int r1, r2; |
| 4762 |
|
| 4763 |
r1 = P_Random(pr_heretic); |
| 4764 |
r2 = P_Random(pr_heretic); |
| 4765 |
mo = P_SpawnMobj(actor->x + ((r2 & 31) - 16) * FRACUNIT, |
| 4766 |
actor->y + ((r1 & 31) - 16) * FRACUNIT, |
| 4767 |
actor->subsector->sector->floorheight, HERETIC_MT_TELEGLITTER); |
| 4768 |
mo->momz = FRACUNIT / 4; |
| 4769 |
} |
| 4770 |
|
| 4771 |
void A_SpawnTeleGlitter2(mobj_t * actor) |
| 4772 |
{ |
| 4773 |
mobj_t *mo; |
| 4774 |
int r1, r2; |
| 4775 |
|
| 4776 |
r1 = P_Random(pr_heretic); |
| 4777 |
r2 = P_Random(pr_heretic); |
| 4778 |
mo = P_SpawnMobj(actor->x + ((r2 & 31) - 16) * FRACUNIT, |
| 4779 |
actor->y + ((r1 & 31) - 16) * FRACUNIT, |
| 4780 |
actor->subsector->sector->floorheight, HERETIC_MT_TELEGLITTER2); |
| 4781 |
mo->momz = FRACUNIT / 4; |
| 4782 |
} |
| 4783 |
|
| 4784 |
void A_AccTeleGlitter(mobj_t * actor) |
| 4785 |
{ |
| 4786 |
if (++actor->health > 35) |
| 4787 |
{ |
| 4788 |
actor->momz += actor->momz / 2; |
| 4789 |
} |
| 4790 |
} |
| 4791 |
|
| 4792 |
void A_InitKeyGizmo(mobj_t * gizmo) |
| 4793 |
{ |
| 4794 |
mobj_t *mo; |
| 4795 |
statenum_t state = g_s_null; |
| 4796 |
|
| 4797 |
switch (gizmo->type) |
| 4798 |
{ |
| 4799 |
case HERETIC_MT_KEYGIZMOBLUE: |
| 4800 |
state = HERETIC_S_KGZ_BLUEFLOAT1; |
| 4801 |
break; |
| 4802 |
case HERETIC_MT_KEYGIZMOGREEN: |
| 4803 |
state = HERETIC_S_KGZ_GREENFLOAT1; |
| 4804 |
break; |
| 4805 |
case HERETIC_MT_KEYGIZMOYELLOW: |
| 4806 |
state = HERETIC_S_KGZ_YELLOWFLOAT1; |
| 4807 |
break; |
| 4808 |
default: |
| 4809 |
break; |
| 4810 |
} |
| 4811 |
mo = P_SpawnMobj(gizmo->x, gizmo->y, gizmo->z + 60 * FRACUNIT, |
| 4812 |
HERETIC_MT_KEYGIZMOFLOAT); |
| 4813 |
P_SetMobjState(mo, state); |
| 4814 |
} |
| 4815 |
|
| 4816 |
void A_VolcanoSet(mobj_t * volcano) |
| 4817 |
{ |
| 4818 |
volcano->tics = 105 + (P_Random(pr_heretic) & 127); |
| 4819 |
} |
| 4820 |
|
| 4821 |
void A_VolcanoBlast(mobj_t * volcano) |
| 4822 |
{ |
| 4823 |
int i; |
| 4824 |
int count; |
| 4825 |
mobj_t *blast; |
| 4826 |
angle_t angle; |
| 4827 |
|
| 4828 |
count = 1 + (P_Random(pr_heretic) % 3); |
| 4829 |
for (i = 0; i < count; i++) |
| 4830 |
{ |
| 4831 |
blast = P_SpawnMobj(volcano->x, volcano->y, volcano->z + 44 * FRACUNIT, HERETIC_MT_VOLCANOBLAST); |
| 4832 |
P_SetTarget(&blast->target, volcano); |
| 4833 |
angle = P_Random(pr_heretic) << 24; |
| 4834 |
blast->angle = angle; |
| 4835 |
angle >>= ANGLETOFINESHIFT; |
| 4836 |
blast->momx = FixedMul(1 * FRACUNIT, finecosine[angle]); |
| 4837 |
blast->momy = FixedMul(1 * FRACUNIT, finesine[angle]); |
| 4838 |
blast->momz = (fixed_t)(2.5 * FRACUNIT) + (P_Random(pr_heretic) << 10); |
| 4839 |
S_StartMobjSound(blast, heretic_sfx_volsht); |
| 4840 |
P_CheckMissileSpawn(blast); |
| 4841 |
} |
| 4842 |
} |
| 4843 |
|
| 4844 |
void A_VolcBallImpact(mobj_t * ball) |
| 4845 |
{ |
| 4846 |
unsigned int i; |
| 4847 |
mobj_t *tiny; |
| 4848 |
angle_t angle; |
| 4849 |
|
| 4850 |
if (ball->z <= ball->floorz) |
| 4851 |
{ |
| 4852 |
ball->flags |= MF_NOGRAVITY; |
| 4853 |
ball->flags2 &= ~MF2_LOGRAV; |
| 4854 |
ball->z += 28 * FRACUNIT; |
| 4855 |
//ball->momz = 3*FRACUNIT; |
| 4856 |
} |
| 4857 |
P_RadiusAttack(ball, ball->target, 25, 25, BF_DAMAGESOURCE); |
| 4858 |
for (i = 0; i < 4; i++) |
| 4859 |
{ |
| 4860 |
tiny = P_SpawnMobj(ball->x, ball->y, ball->z, HERETIC_MT_VOLCANOTBLAST); |
| 4861 |
P_SetTarget(&tiny->target, ball); |
| 4862 |
angle = i * ANG90; |
| 4863 |
tiny->angle = angle; |
| 4864 |
angle >>= ANGLETOFINESHIFT; |
| 4865 |
tiny->momx = FixedMul((fixed_t)(FRACUNIT * .7), finecosine[angle]); |
| 4866 |
tiny->momy = FixedMul((fixed_t)(FRACUNIT * .7), finesine[angle]); |
| 4867 |
tiny->momz = FRACUNIT + (P_Random(pr_heretic) << 9); |
| 4868 |
P_CheckMissileSpawn(tiny); |
| 4869 |
} |
| 4870 |
} |
| 4871 |
|
| 4872 |
void A_CheckSkullFloor(mobj_t * actor) |
| 4873 |
{ |
| 4874 |
if (actor->z <= actor->floorz) |
| 4875 |
{ |
| 4876 |
P_SetMobjState(actor, g_s_bloodyskullx1); |
| 4877 |
if (hexen) |
| 4878 |
S_StartMobjSound(actor, hexen_sfx_drip); |
| 4879 |
} |
| 4880 |
} |
| 4881 |
|
| 4882 |
void A_CheckSkullDone(mobj_t * actor) |
| 4883 |
{ |
| 4884 |
if (actor->special2.i == 666) |
| 4885 |
{ |
| 4886 |
P_SetMobjState(actor, g_s_bloodyskullx2); |
| 4887 |
} |
| 4888 |
} |
| 4889 |
|
| 4890 |
void A_CheckBurnGone(mobj_t * actor) |
| 4891 |
{ |
| 4892 |
if (actor->special2.i == 666) |
| 4893 |
{ |
| 4894 |
P_SetMobjState(actor, g_s_play_fdth20); |
| 4895 |
} |
| 4896 |
} |
| 4897 |
|
| 4898 |
void A_FreeTargMobj(mobj_t * mo) |
| 4899 |
{ |
| 4900 |
mo->momx = mo->momy = mo->momz = 0; |
| 4901 |
mo->z = mo->ceilingz + 4 * FRACUNIT; |
| 4902 |
mo->flags &= ~(MF_SHOOTABLE | MF_FLOAT | MF_SKULLFLY | MF_SOLID); |
| 4903 |
mo->flags |= MF_CORPSE | MF_DROPOFF | MF_NOGRAVITY; |
| 4904 |
mo->flags2 &= ~(MF2_PASSMOBJ | MF2_LOGRAV); |
| 4905 |
mo->player = NULL; |
| 4906 |
|
| 4907 |
// hexen_note: can we do this in heretic too? |
| 4908 |
if (hexen) |
| 4909 |
{ |
| 4910 |
mo->flags &= ~(MF_COUNTKILL); |
| 4911 |
mo->flags2 |= MF2_DONTDRAW; |
| 4912 |
mo->health = -1000; // Don't resurrect |
| 4913 |
} |
| 4914 |
} |
| 4915 |
|
| 4916 |
static int bodyqueslot, bodyquesize; |
| 4917 |
static mobj_t** bodyque; |
| 4918 |
|
| 4919 |
void A_ResetPlayerCorpseQueue(void) |
| 4920 |
{ |
| 4921 |
bodyqueslot = 0; |
| 4922 |
bodyquesize = dsda_IntConfig(dsda_config_max_player_corpse); |
| 4923 |
} |
| 4924 |
|
| 4925 |
void A_AddPlayerCorpse(mobj_t * actor) |
| 4926 |
{ |
| 4927 |
if (bodyquesize > 0) |
| 4928 |
{ |
| 4929 |
static int queuesize; |
| 4930 |
|
| 4931 |
if (queuesize < bodyquesize) |
| 4932 |
{ |
| 4933 |
bodyque = Z_Realloc(bodyque, bodyquesize * sizeof(*bodyque)); |
| 4934 |
memset(bodyque + queuesize, 0, (bodyquesize - queuesize) * sizeof(*bodyque)); |
| 4935 |
queuesize = bodyquesize; |
| 4936 |
} |
| 4937 |
|
| 4938 |
if (bodyqueslot >= bodyquesize) |
| 4939 |
P_RemoveMobj(bodyque[bodyqueslot % bodyquesize]); |
| 4940 |
|
| 4941 |
bodyque[bodyqueslot++ % bodyquesize] = actor; |
| 4942 |
} |
| 4943 |
else if (!bodyquesize) |
| 4944 |
P_RemoveMobj(actor); |
| 4945 |
} |
| 4946 |
|
| 4947 |
void A_FlameSnd(mobj_t * actor) |
| 4948 |
{ |
| 4949 |
S_StartMobjSound(actor, heretic_sfx_hedat1); // Burn sound |
| 4950 |
} |
| 4951 |
|
| 4952 |
void A_HideThing(mobj_t * actor) |
| 4953 |
{ |
| 4954 |
//P_UnsetThingPosition(actor); |
| 4955 |
actor->flags2 |= MF2_DONTDRAW; |
| 4956 |
} |
| 4957 |
|
| 4958 |
void A_UnHideThing(mobj_t * actor) |
| 4959 |
{ |
| 4960 |
//P_SetThingPosition(actor); |
| 4961 |
actor->flags2 &= ~MF2_DONTDRAW; |
| 4962 |
} |
| 4963 |
|
| 4964 |
void Heretic_A_Scream(mobj_t * actor) |
| 4965 |
{ |
| 4966 |
switch (actor->type) |
| 4967 |
{ |
| 4968 |
case HERETIC_MT_CHICPLAYER: |
| 4969 |
case HERETIC_MT_SORCERER1: |
| 4970 |
case HERETIC_MT_MINOTAUR: |
| 4971 |
// Make boss death sounds full volume |
| 4972 |
S_StartVoidSound(actor->info->deathsound); |
| 4973 |
break; |
| 4974 |
case HERETIC_MT_PLAYER: |
| 4975 |
// Handle the different player death screams |
| 4976 |
if (actor->special1.i < 10) |
| 4977 |
{ // Wimpy death sound |
| 4978 |
S_StartMobjSound(actor, heretic_sfx_plrwdth); |
| 4979 |
} |
| 4980 |
else if (actor->health > -50) |
| 4981 |
{ // Normal death sound |
| 4982 |
S_StartMobjSound(actor, actor->info->deathsound); |
| 4983 |
} |
| 4984 |
else if (actor->health > -100) |
| 4985 |
{ // Crazy death sound |
| 4986 |
S_StartMobjSound(actor, heretic_sfx_plrcdth); |
| 4987 |
} |
| 4988 |
else |
| 4989 |
{ // Extreme death sound |
| 4990 |
S_StartMobjSound(actor, heretic_sfx_gibdth); |
| 4991 |
} |
| 4992 |
break; |
| 4993 |
default: |
| 4994 |
S_StartMobjSound(actor, actor->info->deathsound); |
| 4995 |
break; |
| 4996 |
} |
| 4997 |
} |
| 4998 |
|
| 4999 |
void Heretic_A_BossDeath(mobj_t * actor) |
| 5000 |
{ |
| 5001 |
mobj_t *mo; |
| 5002 |
thinker_t *think; |
| 5003 |
line_t dummyLine; |
| 5004 |
static mobjtype_t bossType[6] = { |
| 5005 |
HERETIC_MT_HEAD, |
| 5006 |
HERETIC_MT_MINOTAUR, |
| 5007 |
HERETIC_MT_SORCERER2, |
| 5008 |
HERETIC_MT_HEAD, |
| 5009 |
HERETIC_MT_MINOTAUR, |
| 5010 |
-1 |
| 5011 |
}; |
| 5012 |
|
| 5013 |
if (gamemap != 8) |
| 5014 |
{ // Not a boss level |
| 5015 |
return; |
| 5016 |
} |
| 5017 |
if (actor->type != bossType[gameepisode - 1]) |
| 5018 |
{ // Not considered a boss in this episode |
| 5019 |
return; |
| 5020 |
} |
| 5021 |
// Make sure all bosses are dead |
| 5022 |
for (think = thinkercap.next; think != &thinkercap; think = think->next) |
| 5023 |
{ |
| 5024 |
if (think->function != P_MobjThinker) |
| 5025 |
{ // Not a mobj thinker |
| 5026 |
continue; |
| 5027 |
} |
| 5028 |
mo = (mobj_t *) think; |
| 5029 |
if ((mo != actor) && (mo->type == actor->type) && (mo->health > 0)) |
| 5030 |
{ // Found a living boss |
| 5031 |
return; |
| 5032 |
} |
| 5033 |
} |
| 5034 |
if (gameepisode > 1) |
| 5035 |
{ // Kill any remaining monsters |
| 5036 |
P_Massacre(); |
| 5037 |
} |
| 5038 |
dummyLine.tag = 666; |
| 5039 |
EV_DoFloor(&dummyLine, lowerFloor); |
| 5040 |
} |
| 5041 |
|
| 5042 |
#define MONS_LOOK_LIMIT 64 |
| 5043 |
|
| 5044 |
// Not proxied by P_LookForMonsters - this is post-death brawling |
| 5045 |
dboolean Heretic_P_LookForMonsters(mobj_t * actor) |
| 5046 |
{ |
| 5047 |
int count; |
| 5048 |
mobj_t *mo; |
| 5049 |
thinker_t *think; |
| 5050 |
|
| 5051 |
if (!P_CheckSight(players[0].mo, actor)) |
| 5052 |
{ // Player can't see monster |
| 5053 |
return (false); |
| 5054 |
} |
| 5055 |
count = 0; |
| 5056 |
for (think = thinkercap.next; think != &thinkercap; think = think->next) |
| 5057 |
{ |
| 5058 |
if (think->function != P_MobjThinker) |
| 5059 |
{ // Not a mobj thinker |
| 5060 |
continue; |
| 5061 |
} |
| 5062 |
mo = (mobj_t *) think; |
| 5063 |
if (!(mo->flags & MF_COUNTKILL) || (mo == actor) || (mo->health <= 0)) |
| 5064 |
{ // Not a valid monster |
| 5065 |
continue; |
| 5066 |
} |
| 5067 |
if (P_AproxDistance(actor->x - mo->x, actor->y - mo->y) > g_mons_look_range) |
| 5068 |
{ // Out of range |
| 5069 |
continue; |
| 5070 |
} |
| 5071 |
if (P_Random(pr_heretic) < 16) |
| 5072 |
{ // Skip |
| 5073 |
continue; |
| 5074 |
} |
| 5075 |
if (count++ > MONS_LOOK_LIMIT) |
| 5076 |
{ // Stop searching |
| 5077 |
return (false); |
| 5078 |
} |
| 5079 |
if (!P_CheckSight(actor, mo)) |
| 5080 |
{ // Out of sight |
| 5081 |
continue; |
| 5082 |
} |
| 5083 |
if (actor->type == HEXEN_MT_MINOTAUR) |
| 5084 |
{ |
| 5085 |
// hexen_note: this is supposed to be mo->target != actor->special1.p->mo |
| 5086 |
// - hexen never actually set p (player_t *), so it's m (mobj_t *) (union) |
| 5087 |
// - mo is the first entry in player_t |
| 5088 |
// - thinker_t is the first entry in mobj_t, whose first entry is the previous thinker |
| 5089 |
// - this resolves to actor->special1.m->thinker.prev |
| 5090 |
if ((mo->type == HEXEN_MT_MINOTAUR) && |
| 5091 |
(mo->target != (mobj_t *) actor->special1.m->thinker.prev)) |
| 5092 |
{ |
| 5093 |
continue; |
| 5094 |
} |
| 5095 |
} |
| 5096 |
// Found a target monster |
| 5097 |
P_SetTarget(&actor->target, mo); |
| 5098 |
return (true); |
| 5099 |
} |
| 5100 |
return (false); |
| 5101 |
} |
| 5102 |
|
| 5103 |
dboolean Raven_P_LookForPlayers(mobj_t * actor, dboolean allaround) |
| 5104 |
{ |
| 5105 |
int c; |
| 5106 |
int stop; |
| 5107 |
player_t *player; |
| 5108 |
angle_t an; |
| 5109 |
fixed_t dist; |
| 5110 |
|
| 5111 |
if (!netgame && players[0].health <= 0) |
| 5112 |
{ // Single player game and player is dead, look for monsters |
| 5113 |
return (Heretic_P_LookForMonsters(actor)); |
| 5114 |
} |
| 5115 |
c = 0; |
| 5116 |
stop = (actor->lastlook - 1) & 3; |
| 5117 |
for (;; actor->lastlook = (actor->lastlook + 1) & 3) |
| 5118 |
{ |
| 5119 |
if (!playeringame[actor->lastlook]) |
| 5120 |
continue; |
| 5121 |
|
| 5122 |
if (c++ == 2 || actor->lastlook == stop) |
| 5123 |
return false; // done looking |
| 5124 |
|
| 5125 |
player = &players[actor->lastlook]; |
| 5126 |
|
| 5127 |
if (players->cheats & CF_NOTARGET) |
| 5128 |
continue; // no target |
| 5129 |
|
| 5130 |
if (player->health <= 0) |
| 5131 |
continue; // dead |
| 5132 |
if (!P_CheckSight(actor, player->mo)) |
| 5133 |
continue; // out of sight |
| 5134 |
|
| 5135 |
if (!allaround) |
| 5136 |
{ |
| 5137 |
an = R_PointToAngle2(actor->x, actor->y, |
| 5138 |
player->mo->x, player->mo->y) - actor->angle; |
| 5139 |
if (an > ANG90 && an < ANG270) |
| 5140 |
{ |
| 5141 |
dist = P_AproxDistance(player->mo->x - actor->x, |
| 5142 |
player->mo->y - actor->y); |
| 5143 |
// if real close, react anyway |
| 5144 |
if (dist > WAKEUPRANGE) |
| 5145 |
continue; // behind back |
| 5146 |
} |
| 5147 |
} |
| 5148 |
if (player->mo->flags & MF_SHADOW) |
| 5149 |
{ // Player is invisible |
| 5150 |
if ((P_AproxDistance(player->mo->x - actor->x, |
| 5151 |
player->mo->y - actor->y) > SNEAKRANGE) |
| 5152 |
&& P_AproxDistance(player->mo->momx, player->mo->momy) |
| 5153 |
< 5 * FRACUNIT) |
| 5154 |
{ // Player is sneaking - can't detect |
| 5155 |
return (false); |
| 5156 |
} |
| 5157 |
if (P_Random(pr_heretic) < 225) |
| 5158 |
{ // Player isn't sneaking, but still didn't detect |
| 5159 |
return (false); |
| 5160 |
} |
| 5161 |
} |
| 5162 |
if (actor->type == HEXEN_MT_MINOTAUR) |
| 5163 |
{ |
| 5164 |
// hexen_note: minotaur was intended to store the player_t* but doesn't |
| 5165 |
if (actor->special1.m == (mobj_t *) player) |
| 5166 |
{ |
| 5167 |
continue; // Don't target master |
| 5168 |
} |
| 5169 |
} |
| 5170 |
|
| 5171 |
P_SetTarget(&actor->target, player->mo); |
| 5172 |
return (true); |
| 5173 |
} |
| 5174 |
return (false); |
| 5175 |
} |
| 5176 |
|
| 5177 |
// hexen |
| 5178 |
|
| 5179 |
#include "hexen/a_action.h" |
| 5180 |
#include "hexen/p_acs.h" |
| 5181 |
|
| 5182 |
extern fixed_t FloatBobOffsets[64]; |
| 5183 |
|
| 5184 |
// Corpse queue for monsters - this should be saved out |
| 5185 |
#define CORPSEQUEUESIZE 64 |
| 5186 |
mobj_t *corpseQueue[CORPSEQUEUESIZE]; |
| 5187 |
int corpseQueueSlot; |
| 5188 |
|
| 5189 |
// throw another corpse on the queue |
| 5190 |
void A_QueueCorpse(mobj_t * actor) |
| 5191 |
{ |
| 5192 |
mobj_t *corpse; |
| 5193 |
|
| 5194 |
if (corpseQueueSlot >= CORPSEQUEUESIZE) |
| 5195 |
{ // Too many corpses - remove an old one |
| 5196 |
corpse = corpseQueue[corpseQueueSlot % CORPSEQUEUESIZE]; |
| 5197 |
if (corpse) |
| 5198 |
P_RemoveMobj(corpse); |
| 5199 |
} |
| 5200 |
corpseQueue[corpseQueueSlot % CORPSEQUEUESIZE] = actor; |
| 5201 |
corpseQueueSlot++; |
| 5202 |
} |
| 5203 |
|
| 5204 |
// Remove a mobj from the queue (for resurrection) |
| 5205 |
void A_DeQueueCorpse(mobj_t * actor) |
| 5206 |
{ |
| 5207 |
int slot; |
| 5208 |
|
| 5209 |
for (slot = 0; slot < CORPSEQUEUESIZE; slot++) |
| 5210 |
{ |
| 5211 |
if (corpseQueue[slot] == actor) |
| 5212 |
{ |
| 5213 |
corpseQueue[slot] = NULL; |
| 5214 |
break; |
| 5215 |
} |
| 5216 |
} |
| 5217 |
} |
| 5218 |
|
| 5219 |
void P_InitCreatureCorpseQueue(dboolean corpseScan) |
| 5220 |
{ |
| 5221 |
thinker_t *think; |
| 5222 |
mobj_t *mo; |
| 5223 |
|
| 5224 |
// Initialize queue |
| 5225 |
corpseQueueSlot = 0; |
| 5226 |
memset(corpseQueue, 0, sizeof(mobj_t *) * CORPSEQUEUESIZE); |
| 5227 |
|
| 5228 |
if (!corpseScan) |
| 5229 |
return; |
| 5230 |
|
| 5231 |
// Search mobj list for corpses and place them in this queue |
| 5232 |
for (think = thinkercap.next; think != &thinkercap; think = think->next) |
| 5233 |
{ |
| 5234 |
if (think->function != P_MobjThinker) |
| 5235 |
continue; |
| 5236 |
mo = (mobj_t *) think; |
| 5237 |
if (!(mo->flags & MF_CORPSE)) |
| 5238 |
continue; // Must be a corpse |
| 5239 |
if (mo->flags & MF_ICECORPSE) |
| 5240 |
continue; // Not ice corpses |
| 5241 |
// Only corpses that call A_QueueCorpse from death routine |
| 5242 |
switch (mo->type) |
| 5243 |
{ |
| 5244 |
case HEXEN_MT_CENTAUR: |
| 5245 |
case HEXEN_MT_CENTAURLEADER: |
| 5246 |
case HEXEN_MT_DEMON: |
| 5247 |
case HEXEN_MT_DEMON2: |
| 5248 |
case HEXEN_MT_WRAITH: |
| 5249 |
case HEXEN_MT_WRAITHB: |
| 5250 |
case HEXEN_MT_BISHOP: |
| 5251 |
case HEXEN_MT_ETTIN: |
| 5252 |
case HEXEN_MT_PIG: |
| 5253 |
case HEXEN_MT_CENTAUR_SHIELD: |
| 5254 |
case HEXEN_MT_CENTAUR_SWORD: |
| 5255 |
case HEXEN_MT_DEMONCHUNK1: |
| 5256 |
case HEXEN_MT_DEMONCHUNK2: |
| 5257 |
case HEXEN_MT_DEMONCHUNK3: |
| 5258 |
case HEXEN_MT_DEMONCHUNK4: |
| 5259 |
case HEXEN_MT_DEMONCHUNK5: |
| 5260 |
case HEXEN_MT_DEMON2CHUNK1: |
| 5261 |
case HEXEN_MT_DEMON2CHUNK2: |
| 5262 |
case HEXEN_MT_DEMON2CHUNK3: |
| 5263 |
case HEXEN_MT_DEMON2CHUNK4: |
| 5264 |
case HEXEN_MT_DEMON2CHUNK5: |
| 5265 |
case HEXEN_MT_FIREDEMON_SPLOTCH1: |
| 5266 |
case HEXEN_MT_FIREDEMON_SPLOTCH2: |
| 5267 |
A_QueueCorpse(mo); // Add corpse to queue |
| 5268 |
break; |
| 5269 |
default: |
| 5270 |
break; |
| 5271 |
} |
| 5272 |
} |
| 5273 |
} |
| 5274 |
|
| 5275 |
dboolean P_CheckMeleeRange2(mobj_t * actor) |
| 5276 |
{ |
| 5277 |
mobj_t *mo; |
| 5278 |
fixed_t dist; |
| 5279 |
|
| 5280 |
if (!actor->target) |
| 5281 |
{ |
| 5282 |
return (false); |
| 5283 |
} |
| 5284 |
mo = actor->target; |
| 5285 |
dist = P_AproxDistance(mo->x - actor->x, mo->y - actor->y); |
| 5286 |
if (dist >= MELEERANGE * 2 || dist < MELEERANGE) |
| 5287 |
{ |
| 5288 |
return (false); |
| 5289 |
} |
| 5290 |
if (!P_CheckSight(actor, mo)) |
| 5291 |
{ |
| 5292 |
return (false); |
| 5293 |
} |
| 5294 |
if (mo->z > actor->z + actor->height) |
| 5295 |
{ // Target is higher than the attacker |
| 5296 |
return (false); |
| 5297 |
} |
| 5298 |
else if (actor->z > mo->z + mo->height) |
| 5299 |
{ // Attacker is higher |
| 5300 |
return (false); |
| 5301 |
} |
| 5302 |
return (true); |
| 5303 |
} |
| 5304 |
|
| 5305 |
void A_SetInvulnerable(mobj_t * actor) |
| 5306 |
{ |
| 5307 |
actor->flags2 |= MF2_INVULNERABLE; |
| 5308 |
} |
| 5309 |
|
| 5310 |
void A_UnSetInvulnerable(mobj_t * actor) |
| 5311 |
{ |
| 5312 |
actor->flags2 &= ~MF2_INVULNERABLE; |
| 5313 |
} |
| 5314 |
|
| 5315 |
void A_SetReflective(mobj_t * actor) |
| 5316 |
{ |
| 5317 |
actor->flags2 |= MF2_REFLECTIVE; |
| 5318 |
|
| 5319 |
if ((actor->type == HEXEN_MT_CENTAUR) || (actor->type == HEXEN_MT_CENTAURLEADER)) |
| 5320 |
{ |
| 5321 |
A_SetInvulnerable(actor); |
| 5322 |
} |
| 5323 |
} |
| 5324 |
|
| 5325 |
void A_UnSetReflective(mobj_t * actor) |
| 5326 |
{ |
| 5327 |
actor->flags2 &= ~MF2_REFLECTIVE; |
| 5328 |
|
| 5329 |
if ((actor->type == HEXEN_MT_CENTAUR) || (actor->type == HEXEN_MT_CENTAURLEADER)) |
| 5330 |
{ |
| 5331 |
A_UnSetInvulnerable(actor); |
| 5332 |
} |
| 5333 |
} |
| 5334 |
|
| 5335 |
dboolean P_UpdateMorphedMonster(mobj_t * actor, int tics) |
| 5336 |
{ |
| 5337 |
mobj_t *fog; |
| 5338 |
fixed_t x; |
| 5339 |
fixed_t y; |
| 5340 |
fixed_t z; |
| 5341 |
mobjtype_t moType; |
| 5342 |
mobj_t *mo; |
| 5343 |
mobj_t oldMonster; |
| 5344 |
|
| 5345 |
actor->special1.i -= tics; |
| 5346 |
if (actor->special1.i > 0) |
| 5347 |
{ |
| 5348 |
return (false); |
| 5349 |
} |
| 5350 |
moType = actor->special2.i; |
| 5351 |
switch (moType) |
| 5352 |
{ |
| 5353 |
case HEXEN_MT_WRAITHB: // These must remain morphed |
| 5354 |
case HEXEN_MT_SERPENT: |
| 5355 |
case HEXEN_MT_SERPENTLEADER: |
| 5356 |
case HEXEN_MT_MINOTAUR: |
| 5357 |
return (false); |
| 5358 |
default: |
| 5359 |
break; |
| 5360 |
} |
| 5361 |
x = actor->x; |
| 5362 |
y = actor->y; |
| 5363 |
z = actor->z; |
| 5364 |
oldMonster = *actor; // Save pig vars |
| 5365 |
|
| 5366 |
map_format.remove_mobj_thing_id(actor); |
| 5367 |
P_SetMobjState(actor, HEXEN_S_FREETARGMOBJ); |
| 5368 |
mo = P_SpawnMobj(x, y, z, moType); |
| 5369 |
dsda_WatchUnMorph(mo); |
| 5370 |
if (P_TestMobjLocation(mo) == false) |
| 5371 |
{ // Didn't fit |
| 5372 |
P_RemoveMobj(mo); |
| 5373 |
mo = P_SpawnMobj(x, y, z, oldMonster.type); |
| 5374 |
mo->angle = oldMonster.angle; |
| 5375 |
mo->flags = oldMonster.flags; |
| 5376 |
mo->health = oldMonster.health; |
| 5377 |
P_SetTarget(&mo->target, oldMonster.target); |
| 5378 |
mo->special = oldMonster.special; |
| 5379 |
mo->special1.i = 5 * 35; // Next try in 5 seconds |
| 5380 |
mo->special2.i = moType; |
| 5381 |
mo->tid = oldMonster.tid; |
| 5382 |
memcpy(mo->special_args, oldMonster.special_args, SPECIAL_ARGS_SIZE); |
| 5383 |
map_format.add_mobj_thing_id(mo, oldMonster.tid); |
| 5384 |
dsda_WatchMorph(mo); |
| 5385 |
return (false); |
| 5386 |
} |
| 5387 |
mo->angle = oldMonster.angle; |
| 5388 |
P_SetTarget(&mo->target, oldMonster.target); |
| 5389 |
mo->tid = oldMonster.tid; |
| 5390 |
mo->special = oldMonster.special; |
| 5391 |
memcpy(mo->special_args, oldMonster.special_args, SPECIAL_ARGS_SIZE); |
| 5392 |
map_format.add_mobj_thing_id(mo, oldMonster.tid); |
| 5393 |
fog = P_SpawnMobj(x, y, z + TELEFOGHEIGHT, HEXEN_MT_TFOG); |
| 5394 |
S_StartMobjSound(fog, hexen_sfx_teleport); |
| 5395 |
return (true); |
| 5396 |
} |
| 5397 |
|
| 5398 |
void A_PigLook(mobj_t * actor) |
| 5399 |
{ |
| 5400 |
if (P_UpdateMorphedMonster(actor, 10)) |
| 5401 |
{ |
| 5402 |
return; |
| 5403 |
} |
| 5404 |
A_Look(actor); |
| 5405 |
} |
| 5406 |
|
| 5407 |
void A_PigChase(mobj_t * actor) |
| 5408 |
{ |
| 5409 |
if (P_UpdateMorphedMonster(actor, 3)) |
| 5410 |
{ |
| 5411 |
return; |
| 5412 |
} |
| 5413 |
A_Chase(actor); |
| 5414 |
} |
| 5415 |
|
| 5416 |
void A_PigAttack(mobj_t * actor) |
| 5417 |
{ |
| 5418 |
if (P_UpdateMorphedMonster(actor, 18)) |
| 5419 |
{ |
| 5420 |
return; |
| 5421 |
} |
| 5422 |
if (!actor->target) |
| 5423 |
{ |
| 5424 |
return; |
| 5425 |
} |
| 5426 |
if (P_CheckMeleeRange(actor)) |
| 5427 |
{ |
| 5428 |
P_DamageMobj(actor->target, actor, actor, 2 + (P_Random(pr_hexen) & 1)); |
| 5429 |
S_StartMobjSound(actor, hexen_sfx_pig_attack); |
| 5430 |
} |
| 5431 |
} |
| 5432 |
|
| 5433 |
void A_PigPain(mobj_t * actor) |
| 5434 |
{ |
| 5435 |
A_Pain(actor); |
| 5436 |
if (actor->z <= actor->floorz) |
| 5437 |
{ |
| 5438 |
actor->momz = 3.5 * FRACUNIT; |
| 5439 |
} |
| 5440 |
} |
| 5441 |
|
| 5442 |
void FaceMovementDirection(mobj_t * actor) |
| 5443 |
{ |
| 5444 |
switch (actor->movedir) |
| 5445 |
{ |
| 5446 |
case DI_EAST: |
| 5447 |
actor->angle = 0 << 24; |
| 5448 |
break; |
| 5449 |
case DI_NORTHEAST: |
| 5450 |
actor->angle = 32 << 24; |
| 5451 |
break; |
| 5452 |
case DI_NORTH: |
| 5453 |
actor->angle = 64 << 24; |
| 5454 |
break; |
| 5455 |
case DI_NORTHWEST: |
| 5456 |
actor->angle = 96 << 24; |
| 5457 |
break; |
| 5458 |
case DI_WEST: |
| 5459 |
actor->angle = 128 << 24; |
| 5460 |
break; |
| 5461 |
case DI_SOUTHWEST: |
| 5462 |
actor->angle = 160 << 24; |
| 5463 |
break; |
| 5464 |
case DI_SOUTH: |
| 5465 |
actor->angle = 192 << 24; |
| 5466 |
break; |
| 5467 |
case DI_SOUTHEAST: |
| 5468 |
actor->angle = 224 << 24; |
| 5469 |
break; |
| 5470 |
} |
| 5471 |
} |
| 5472 |
|
| 5473 |
//---------------------------------------------------------------------------- |
| 5474 |
// |
| 5475 |
// Minotaur variables |
| 5476 |
// |
| 5477 |
// special1 pointer to player that spawned it (mobj_t) |
| 5478 |
// special2 internal to minotaur AI |
| 5479 |
// args[0] args[0]-args[3] together make up minotaur start time |
| 5480 |
// args[1] | |
| 5481 |
// args[2] | |
| 5482 |
// args[3] V |
| 5483 |
// args[4] charge duration countdown |
| 5484 |
//---------------------------------------------------------------------------- |
| 5485 |
|
| 5486 |
void A_MinotaurFade0(mobj_t * actor) |
| 5487 |
{ |
| 5488 |
actor->flags &= ~MF_ALTSHADOW; |
| 5489 |
actor->flags |= MF_SHADOW; |
| 5490 |
} |
| 5491 |
|
| 5492 |
void A_MinotaurFade1(mobj_t * actor) |
| 5493 |
{ |
| 5494 |
// Second level of transparency |
| 5495 |
actor->flags &= ~MF_SHADOW; |
| 5496 |
actor->flags |= MF_ALTSHADOW; |
| 5497 |
} |
| 5498 |
|
| 5499 |
void A_MinotaurFade2(mobj_t * actor) |
| 5500 |
{ |
| 5501 |
// Make fully visible |
| 5502 |
actor->flags &= ~MF_SHADOW; |
| 5503 |
actor->flags &= ~MF_ALTSHADOW; |
| 5504 |
} |
| 5505 |
|
| 5506 |
void A_MinotaurLook(mobj_t * actor); |
| 5507 |
|
| 5508 |
// Check the age of the minotaur and stomp it after MAULATORTICS of time |
| 5509 |
// have passed. Returns false if killed. |
| 5510 |
static dboolean CheckMinotaurAge(mobj_t *mo) |
| 5511 |
{ |
| 5512 |
byte args[5]; |
| 5513 |
unsigned int starttime; |
| 5514 |
|
| 5515 |
COLLAPSE_SPECIAL_ARGS(args, mo->special_args); |
| 5516 |
memcpy(&starttime, args, sizeof(unsigned int)); |
| 5517 |
if (leveltime - LittleLong(starttime) >= MAULATORTICS) |
| 5518 |
{ |
| 5519 |
P_DamageMobj(mo, NULL, NULL, 10000); |
| 5520 |
return false; |
| 5521 |
} |
| 5522 |
|
| 5523 |
return true; |
| 5524 |
} |
| 5525 |
|
| 5526 |
void A_MinotaurRoam(mobj_t * actor) |
| 5527 |
{ |
| 5528 |
actor->flags &= ~MF_SHADOW; // In case pain caused him to |
| 5529 |
actor->flags &= ~MF_ALTSHADOW; // skip his fade in. |
| 5530 |
|
| 5531 |
if (!CheckMinotaurAge(actor)) |
| 5532 |
{ |
| 5533 |
return; |
| 5534 |
} |
| 5535 |
|
| 5536 |
if (P_Random(pr_hexen) < 30) |
| 5537 |
A_MinotaurLook(actor); // adjust to closest target |
| 5538 |
|
| 5539 |
if (P_Random(pr_hexen) < 6) |
| 5540 |
{ |
| 5541 |
//Choose new direction |
| 5542 |
actor->movedir = P_Random(pr_hexen) % 8; |
| 5543 |
FaceMovementDirection(actor); |
| 5544 |
} |
| 5545 |
if (!P_Move(actor, false)) |
| 5546 |
{ |
| 5547 |
// Turn |
| 5548 |
if (P_Random(pr_hexen) & 1) |
| 5549 |
actor->movedir = (actor->movedir + 1) % 8; |
| 5550 |
else |
| 5551 |
actor->movedir = (actor->movedir + 7) % 8; |
| 5552 |
FaceMovementDirection(actor); |
| 5553 |
} |
| 5554 |
} |
| 5555 |
|
| 5556 |
#define MINOTAUR_LOOK_DIST (16*54*FRACUNIT) |
| 5557 |
|
| 5558 |
void A_MinotaurLook(mobj_t * actor) |
| 5559 |
{ |
| 5560 |
mobj_t *mo = NULL; |
| 5561 |
player_t *player; |
| 5562 |
thinker_t *think; |
| 5563 |
fixed_t dist; |
| 5564 |
int i; |
| 5565 |
mobj_t *master = actor->special1.m; |
| 5566 |
|
| 5567 |
P_SetTarget(&actor->target, NULL); |
| 5568 |
if (deathmatch) // Quick search for players |
| 5569 |
{ |
| 5570 |
for (i = 0; i < g_maxplayers; i++) |
| 5571 |
{ |
| 5572 |
if (!playeringame[i]) |
| 5573 |
continue; |
| 5574 |
player = &players[i]; |
| 5575 |
mo = player->mo; |
| 5576 |
if (mo == master) |
| 5577 |
continue; |
| 5578 |
if (mo->health <= 0) |
| 5579 |
continue; |
| 5580 |
dist = P_AproxDistance(actor->x - mo->x, actor->y - mo->y); |
| 5581 |
if (dist > MINOTAUR_LOOK_DIST) |
| 5582 |
continue; |
| 5583 |
P_SetTarget(&actor->target, mo); |
| 5584 |
break; |
| 5585 |
} |
| 5586 |
} |
| 5587 |
|
| 5588 |
if (!actor->target) // Near player monster search |
| 5589 |
{ |
| 5590 |
if (master && (master->health > 0) && (master->player)) |
| 5591 |
mo = P_RoughTargetSearch(master, 0, 20); |
| 5592 |
else |
| 5593 |
mo = P_RoughTargetSearch(actor, 0, 20); |
| 5594 |
P_SetTarget(&actor->target, mo); |
| 5595 |
} |
| 5596 |
|
| 5597 |
if (!actor->target) // Normal monster search |
| 5598 |
{ |
| 5599 |
for (think = thinkercap.next; think != &thinkercap; |
| 5600 |
think = think->next) |
| 5601 |
{ |
| 5602 |
if (think->function != P_MobjThinker) |
| 5603 |
continue; |
| 5604 |
mo = (mobj_t *) think; |
| 5605 |
if (!(mo->flags & MF_COUNTKILL)) |
| 5606 |
continue; |
| 5607 |
if (mo->health <= 0) |
| 5608 |
continue; |
| 5609 |
if (!(mo->flags & MF_SHOOTABLE)) |
| 5610 |
continue; |
| 5611 |
dist = P_AproxDistance(actor->x - mo->x, actor->y - mo->y); |
| 5612 |
if (dist > MINOTAUR_LOOK_DIST) |
| 5613 |
continue; |
| 5614 |
if ((mo == master) || (mo == actor)) |
| 5615 |
continue; |
| 5616 |
if ((mo->type == HEXEN_MT_MINOTAUR) && |
| 5617 |
(mo->special1.m == actor->special1.m)) |
| 5618 |
continue; |
| 5619 |
P_SetTarget(&actor->target, mo); |
| 5620 |
break; // Found mobj to attack |
| 5621 |
} |
| 5622 |
} |
| 5623 |
|
| 5624 |
if (actor->target) |
| 5625 |
{ |
| 5626 |
P_SetMobjStateNF(actor, HEXEN_S_MNTR_WALK1); |
| 5627 |
} |
| 5628 |
else |
| 5629 |
{ |
| 5630 |
P_SetMobjStateNF(actor, HEXEN_S_MNTR_ROAM1); |
| 5631 |
} |
| 5632 |
} |
| 5633 |
|
| 5634 |
void A_MinotaurChase(mobj_t * actor) |
| 5635 |
{ |
| 5636 |
actor->flags &= ~MF_SHADOW; // In case pain caused him to |
| 5637 |
actor->flags &= ~MF_ALTSHADOW; // skip his fade in. |
| 5638 |
|
| 5639 |
if (!CheckMinotaurAge(actor)) |
| 5640 |
{ |
| 5641 |
return; |
| 5642 |
} |
| 5643 |
|
| 5644 |
if (P_Random(pr_hexen) < 30) |
| 5645 |
A_MinotaurLook(actor); // adjust to closest target |
| 5646 |
|
| 5647 |
if (!actor->target || (actor->target->health <= 0) || |
| 5648 |
!(actor->target->flags & MF_SHOOTABLE)) |
| 5649 |
{ // look for a new target |
| 5650 |
P_SetMobjState(actor, HEXEN_S_MNTR_LOOK1); |
| 5651 |
return; |
| 5652 |
} |
| 5653 |
|
| 5654 |
FaceMovementDirection(actor); |
| 5655 |
actor->reactiontime = 0; |
| 5656 |
|
| 5657 |
// Melee attack |
| 5658 |
if (actor->info->meleestate && P_CheckMeleeRange(actor)) |
| 5659 |
{ |
| 5660 |
if (actor->info->attacksound) |
| 5661 |
{ |
| 5662 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 5663 |
} |
| 5664 |
P_SetMobjState(actor, actor->info->meleestate); |
| 5665 |
return; |
| 5666 |
} |
| 5667 |
|
| 5668 |
// Missile attack |
| 5669 |
if (actor->info->missilestate && P_CheckMissileRange(actor)) |
| 5670 |
{ |
| 5671 |
P_SetMobjState(actor, actor->info->missilestate); |
| 5672 |
return; |
| 5673 |
} |
| 5674 |
|
| 5675 |
// chase towards target |
| 5676 |
if (!P_Move(actor, false)) |
| 5677 |
{ |
| 5678 |
P_NewChaseDir(actor); |
| 5679 |
} |
| 5680 |
|
| 5681 |
// Active sound |
| 5682 |
if (actor->info->activesound && P_Random(pr_hexen) < 6) |
| 5683 |
{ |
| 5684 |
S_StartMobjSound(actor, actor->info->activesound); |
| 5685 |
} |
| 5686 |
} |
| 5687 |
|
| 5688 |
void Hexen_A_Scream(mobj_t * actor) |
| 5689 |
{ |
| 5690 |
int sound; |
| 5691 |
|
| 5692 |
S_StopSound(actor); |
| 5693 |
if (actor->player) |
| 5694 |
{ |
| 5695 |
if (actor->player->morphTics) |
| 5696 |
{ |
| 5697 |
S_StartMobjSound(actor, actor->info->deathsound); |
| 5698 |
} |
| 5699 |
else |
| 5700 |
{ |
| 5701 |
// Handle the different player death screams |
| 5702 |
if (actor->momz <= -39 * FRACUNIT) |
| 5703 |
{ // Falling splat |
| 5704 |
sound = hexen_sfx_player_falling_splat; |
| 5705 |
} |
| 5706 |
else if (actor->health > -50) |
| 5707 |
{ // Normal death sound |
| 5708 |
switch (actor->player->pclass) |
| 5709 |
{ |
| 5710 |
case PCLASS_FIGHTER: |
| 5711 |
sound = hexen_sfx_player_fighter_normal_death; |
| 5712 |
break; |
| 5713 |
case PCLASS_CLERIC: |
| 5714 |
sound = hexen_sfx_player_cleric_normal_death; |
| 5715 |
break; |
| 5716 |
case PCLASS_MAGE: |
| 5717 |
sound = hexen_sfx_player_mage_normal_death; |
| 5718 |
break; |
| 5719 |
default: |
| 5720 |
sound = hexen_sfx_None; |
| 5721 |
break; |
| 5722 |
} |
| 5723 |
} |
| 5724 |
else if (actor->health > -100) |
| 5725 |
{ // Crazy death sound |
| 5726 |
switch (actor->player->pclass) |
| 5727 |
{ |
| 5728 |
case PCLASS_FIGHTER: |
| 5729 |
sound = hexen_sfx_player_fighter_crazy_death; |
| 5730 |
break; |
| 5731 |
case PCLASS_CLERIC: |
| 5732 |
sound = hexen_sfx_player_cleric_crazy_death; |
| 5733 |
break; |
| 5734 |
case PCLASS_MAGE: |
| 5735 |
sound = hexen_sfx_player_mage_crazy_death; |
| 5736 |
break; |
| 5737 |
default: |
| 5738 |
sound = hexen_sfx_None; |
| 5739 |
break; |
| 5740 |
} |
| 5741 |
} |
| 5742 |
else |
| 5743 |
{ // Extreme death sound |
| 5744 |
switch (actor->player->pclass) |
| 5745 |
{ |
| 5746 |
case PCLASS_FIGHTER: |
| 5747 |
sound = hexen_sfx_player_fighter_extreme1_death; |
| 5748 |
break; |
| 5749 |
case PCLASS_CLERIC: |
| 5750 |
sound = hexen_sfx_player_cleric_extreme1_death; |
| 5751 |
break; |
| 5752 |
case PCLASS_MAGE: |
| 5753 |
sound = hexen_sfx_player_mage_extreme1_death; |
| 5754 |
break; |
| 5755 |
default: |
| 5756 |
sound = hexen_sfx_None; |
| 5757 |
break; |
| 5758 |
} |
| 5759 |
sound += P_Random(pr_hexen) % 3; // Three different extreme deaths |
| 5760 |
} |
| 5761 |
S_StartMobjSound(actor, sound); |
| 5762 |
} |
| 5763 |
} |
| 5764 |
else |
| 5765 |
{ |
| 5766 |
S_StartMobjSound(actor, actor->info->deathsound); |
| 5767 |
} |
| 5768 |
} |
| 5769 |
|
| 5770 |
void A_SerpentUnHide(mobj_t * actor) |
| 5771 |
{ |
| 5772 |
actor->flags2 &= ~MF2_DONTDRAW; |
| 5773 |
actor->floorclip = 24 * FRACUNIT; |
| 5774 |
} |
| 5775 |
|
| 5776 |
void A_SerpentHide(mobj_t * actor) |
| 5777 |
{ |
| 5778 |
actor->flags2 |= MF2_DONTDRAW; |
| 5779 |
actor->floorclip = 0; |
| 5780 |
} |
| 5781 |
|
| 5782 |
void A_SerpentChase(mobj_t * actor) |
| 5783 |
{ |
| 5784 |
int delta; |
| 5785 |
int oldX, oldY, oldFloor; |
| 5786 |
|
| 5787 |
if (actor->reactiontime) |
| 5788 |
{ |
| 5789 |
actor->reactiontime--; |
| 5790 |
} |
| 5791 |
|
| 5792 |
// Modify target threshold |
| 5793 |
if (actor->threshold) |
| 5794 |
{ |
| 5795 |
actor->threshold--; |
| 5796 |
} |
| 5797 |
|
| 5798 |
if (skill_info.flags & SI_FAST_MONSTERS) |
| 5799 |
{ // Monsters move faster in nightmare mode |
| 5800 |
actor->tics -= actor->tics / 2; |
| 5801 |
if (actor->tics < 3) |
| 5802 |
{ |
| 5803 |
actor->tics = 3; |
| 5804 |
} |
| 5805 |
} |
| 5806 |
|
| 5807 |
// |
| 5808 |
// turn towards movement direction if not there yet |
| 5809 |
// |
| 5810 |
if (actor->movedir < 8) |
| 5811 |
{ |
| 5812 |
actor->angle &= (7 << 29); |
| 5813 |
delta = actor->angle - (actor->movedir << 29); |
| 5814 |
if (delta > 0) |
| 5815 |
{ |
| 5816 |
actor->angle -= ANG90 / 2; |
| 5817 |
} |
| 5818 |
else if (delta < 0) |
| 5819 |
{ |
| 5820 |
actor->angle += ANG90 / 2; |
| 5821 |
} |
| 5822 |
} |
| 5823 |
|
| 5824 |
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) |
| 5825 |
{ // look for a new target |
| 5826 |
if (P_LookForPlayers(actor, true)) |
| 5827 |
{ // got a new target |
| 5828 |
return; |
| 5829 |
} |
| 5830 |
P_SetMobjState(actor, actor->info->spawnstate); |
| 5831 |
return; |
| 5832 |
} |
| 5833 |
|
| 5834 |
// |
| 5835 |
// don't attack twice in a row |
| 5836 |
// |
| 5837 |
if (actor->flags & MF_JUSTATTACKED) |
| 5838 |
{ |
| 5839 |
actor->flags &= ~MF_JUSTATTACKED; |
| 5840 |
if (!(skill_info.flags & SI_FAST_MONSTERS)) |
| 5841 |
P_NewChaseDir(actor); |
| 5842 |
return; |
| 5843 |
} |
| 5844 |
|
| 5845 |
// |
| 5846 |
// check for melee attack |
| 5847 |
// |
| 5848 |
if (actor->info->meleestate && P_CheckMeleeRange(actor)) |
| 5849 |
{ |
| 5850 |
if (actor->info->attacksound) |
| 5851 |
{ |
| 5852 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 5853 |
} |
| 5854 |
P_SetMobjState(actor, actor->info->meleestate); |
| 5855 |
return; |
| 5856 |
} |
| 5857 |
|
| 5858 |
// |
| 5859 |
// possibly choose another target |
| 5860 |
// |
| 5861 |
if (netgame && !actor->threshold && !P_CheckSight(actor, actor->target)) |
| 5862 |
{ |
| 5863 |
if (P_LookForPlayers(actor, true)) |
| 5864 |
return; // got a new target |
| 5865 |
} |
| 5866 |
|
| 5867 |
// |
| 5868 |
// chase towards player |
| 5869 |
// |
| 5870 |
oldX = actor->x; |
| 5871 |
oldY = actor->y; |
| 5872 |
oldFloor = actor->subsector->sector->floorpic; |
| 5873 |
if (--actor->movecount < 0 || !P_Move(actor, false)) |
| 5874 |
{ |
| 5875 |
P_NewChaseDir(actor); |
| 5876 |
} |
| 5877 |
if (actor->subsector->sector->floorpic != oldFloor) |
| 5878 |
{ |
| 5879 |
P_TryMove(actor, oldX, oldY, 0); |
| 5880 |
P_NewChaseDir(actor); |
| 5881 |
} |
| 5882 |
|
| 5883 |
// |
| 5884 |
// make active sound |
| 5885 |
// |
| 5886 |
if (actor->info->activesound && P_Random(pr_hexen) < 3) |
| 5887 |
{ |
| 5888 |
S_StartMobjSound(actor, actor->info->activesound); |
| 5889 |
} |
| 5890 |
} |
| 5891 |
|
| 5892 |
void A_SerpentRaiseHump(mobj_t * actor) |
| 5893 |
{ |
| 5894 |
actor->floorclip -= 4 * FRACUNIT; |
| 5895 |
} |
| 5896 |
|
| 5897 |
void A_SerpentLowerHump(mobj_t * actor) |
| 5898 |
{ |
| 5899 |
actor->floorclip += 4 * FRACUNIT; |
| 5900 |
} |
| 5901 |
|
| 5902 |
void A_SerpentHumpDecide(mobj_t * actor) |
| 5903 |
{ |
| 5904 |
if (actor->type == HEXEN_MT_SERPENTLEADER) |
| 5905 |
{ |
| 5906 |
if (P_Random(pr_hexen) > 30) |
| 5907 |
{ |
| 5908 |
return; |
| 5909 |
} |
| 5910 |
else if (P_Random(pr_hexen) < 40) |
| 5911 |
{ // Missile attack |
| 5912 |
P_SetMobjState(actor, HEXEN_S_SERPENT_SURFACE1); |
| 5913 |
return; |
| 5914 |
} |
| 5915 |
} |
| 5916 |
else if (P_Random(pr_hexen) > 3) |
| 5917 |
{ |
| 5918 |
return; |
| 5919 |
} |
| 5920 |
if (!P_CheckMeleeRange(actor)) |
| 5921 |
{ // The hump shouldn't occur when within melee range |
| 5922 |
if (actor->type == HEXEN_MT_SERPENTLEADER && P_Random(pr_hexen) < 128) |
| 5923 |
{ |
| 5924 |
P_SetMobjState(actor, HEXEN_S_SERPENT_SURFACE1); |
| 5925 |
} |
| 5926 |
else |
| 5927 |
{ |
| 5928 |
P_SetMobjState(actor, HEXEN_S_SERPENT_HUMP1); |
| 5929 |
S_StartMobjSound(actor, hexen_sfx_serpent_active); |
| 5930 |
} |
| 5931 |
} |
| 5932 |
} |
| 5933 |
|
| 5934 |
void A_SerpentBirthScream(mobj_t * actor) |
| 5935 |
{ |
| 5936 |
S_StartMobjSound(actor, hexen_sfx_serpent_birth); |
| 5937 |
} |
| 5938 |
|
| 5939 |
void A_SerpentDiveSound(mobj_t * actor) |
| 5940 |
{ |
| 5941 |
S_StartMobjSound(actor, hexen_sfx_serpent_active); |
| 5942 |
} |
| 5943 |
|
| 5944 |
void A_SerpentWalk(mobj_t * actor) |
| 5945 |
{ |
| 5946 |
int delta; |
| 5947 |
|
| 5948 |
if (actor->reactiontime) |
| 5949 |
{ |
| 5950 |
actor->reactiontime--; |
| 5951 |
} |
| 5952 |
|
| 5953 |
// Modify target threshold |
| 5954 |
if (actor->threshold) |
| 5955 |
{ |
| 5956 |
actor->threshold--; |
| 5957 |
} |
| 5958 |
|
| 5959 |
if (skill_info.flags & SI_FAST_MONSTERS) |
| 5960 |
{ // Monsters move faster in nightmare mode |
| 5961 |
actor->tics -= actor->tics / 2; |
| 5962 |
if (actor->tics < 3) |
| 5963 |
{ |
| 5964 |
actor->tics = 3; |
| 5965 |
} |
| 5966 |
} |
| 5967 |
|
| 5968 |
// |
| 5969 |
// turn towards movement direction if not there yet |
| 5970 |
// |
| 5971 |
if (actor->movedir < 8) |
| 5972 |
{ |
| 5973 |
actor->angle &= (7 << 29); |
| 5974 |
delta = actor->angle - (actor->movedir << 29); |
| 5975 |
if (delta > 0) |
| 5976 |
{ |
| 5977 |
actor->angle -= ANG90 / 2; |
| 5978 |
} |
| 5979 |
else if (delta < 0) |
| 5980 |
{ |
| 5981 |
actor->angle += ANG90 / 2; |
| 5982 |
} |
| 5983 |
} |
| 5984 |
|
| 5985 |
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) |
| 5986 |
{ // look for a new target |
| 5987 |
if (P_LookForPlayers(actor, true)) |
| 5988 |
{ // got a new target |
| 5989 |
return; |
| 5990 |
} |
| 5991 |
P_SetMobjState(actor, actor->info->spawnstate); |
| 5992 |
return; |
| 5993 |
} |
| 5994 |
|
| 5995 |
// |
| 5996 |
// don't attack twice in a row |
| 5997 |
// |
| 5998 |
if (actor->flags & MF_JUSTATTACKED) |
| 5999 |
{ |
| 6000 |
actor->flags &= ~MF_JUSTATTACKED; |
| 6001 |
if (!(skill_info.flags & SI_FAST_MONSTERS)) |
| 6002 |
P_NewChaseDir(actor); |
| 6003 |
return; |
| 6004 |
} |
| 6005 |
|
| 6006 |
// |
| 6007 |
// check for melee attack |
| 6008 |
// |
| 6009 |
if (actor->info->meleestate && P_CheckMeleeRange(actor)) |
| 6010 |
{ |
| 6011 |
if (actor->info->attacksound) |
| 6012 |
{ |
| 6013 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 6014 |
} |
| 6015 |
P_SetMobjState(actor, HEXEN_S_SERPENT_ATK1); |
| 6016 |
return; |
| 6017 |
} |
| 6018 |
// |
| 6019 |
// possibly choose another target |
| 6020 |
// |
| 6021 |
if (netgame && !actor->threshold && !P_CheckSight(actor, actor->target)) |
| 6022 |
{ |
| 6023 |
if (P_LookForPlayers(actor, true)) |
| 6024 |
return; // got a new target |
| 6025 |
} |
| 6026 |
|
| 6027 |
// |
| 6028 |
// chase towards player |
| 6029 |
// |
| 6030 |
if (--actor->movecount < 0 || !P_Move(actor, false)) |
| 6031 |
{ |
| 6032 |
P_NewChaseDir(actor); |
| 6033 |
} |
| 6034 |
} |
| 6035 |
|
| 6036 |
void A_SerpentCheckForAttack(mobj_t * actor) |
| 6037 |
{ |
| 6038 |
if (!actor->target) |
| 6039 |
{ |
| 6040 |
return; |
| 6041 |
} |
| 6042 |
if (actor->type == HEXEN_MT_SERPENTLEADER) |
| 6043 |
{ |
| 6044 |
if (!P_CheckMeleeRange(actor)) |
| 6045 |
{ |
| 6046 |
P_SetMobjState(actor, HEXEN_S_SERPENT_ATK1); |
| 6047 |
return; |
| 6048 |
} |
| 6049 |
} |
| 6050 |
if (P_CheckMeleeRange2(actor)) |
| 6051 |
{ |
| 6052 |
P_SetMobjState(actor, HEXEN_S_SERPENT_WALK1); |
| 6053 |
} |
| 6054 |
else if (P_CheckMeleeRange(actor)) |
| 6055 |
{ |
| 6056 |
if (P_Random(pr_hexen) < 32) |
| 6057 |
{ |
| 6058 |
P_SetMobjState(actor, HEXEN_S_SERPENT_WALK1); |
| 6059 |
} |
| 6060 |
else |
| 6061 |
{ |
| 6062 |
P_SetMobjState(actor, HEXEN_S_SERPENT_ATK1); |
| 6063 |
} |
| 6064 |
} |
| 6065 |
} |
| 6066 |
|
| 6067 |
void A_SerpentChooseAttack(mobj_t * actor) |
| 6068 |
{ |
| 6069 |
if (!actor->target || P_CheckMeleeRange(actor)) |
| 6070 |
{ |
| 6071 |
return; |
| 6072 |
} |
| 6073 |
if (actor->type == HEXEN_MT_SERPENTLEADER) |
| 6074 |
{ |
| 6075 |
P_SetMobjState(actor, HEXEN_S_SERPENT_MISSILE1); |
| 6076 |
} |
| 6077 |
} |
| 6078 |
|
| 6079 |
void A_SerpentMeleeAttack(mobj_t * actor) |
| 6080 |
{ |
| 6081 |
if (!actor->target) |
| 6082 |
{ |
| 6083 |
return; |
| 6084 |
} |
| 6085 |
if (P_CheckMeleeRange(actor)) |
| 6086 |
{ |
| 6087 |
P_DamageMobj(actor->target, actor, actor, HITDICE(5)); |
| 6088 |
S_StartMobjSound(actor, hexen_sfx_serpent_meleehit); |
| 6089 |
} |
| 6090 |
if (P_Random(pr_hexen) < 96) |
| 6091 |
{ |
| 6092 |
A_SerpentCheckForAttack(actor); |
| 6093 |
} |
| 6094 |
} |
| 6095 |
|
| 6096 |
void A_SerpentMissileAttack(mobj_t * actor) |
| 6097 |
{ |
| 6098 |
if (!actor->target) |
| 6099 |
{ |
| 6100 |
return; |
| 6101 |
} |
| 6102 |
|
| 6103 |
P_SpawnMissile(actor, actor->target, HEXEN_MT_SERPENTFX); |
| 6104 |
} |
| 6105 |
|
| 6106 |
void A_SerpentHeadPop(mobj_t * actor) |
| 6107 |
{ |
| 6108 |
P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6109 |
HEXEN_MT_SERPENT_HEAD); |
| 6110 |
} |
| 6111 |
|
| 6112 |
void A_SerpentSpawnGibs(mobj_t * actor) |
| 6113 |
{ |
| 6114 |
mobj_t *mo; |
| 6115 |
int r1, r2; |
| 6116 |
|
| 6117 |
r1 = P_Random(pr_hexen); |
| 6118 |
r2 = P_Random(pr_hexen); |
| 6119 |
mo = P_SpawnMobj(actor->x + ((r2 - 128) << 12), |
| 6120 |
actor->y + ((r1 - 128) << 12), |
| 6121 |
actor->floorz + FRACUNIT, HEXEN_MT_SERPENT_GIB1); |
| 6122 |
if (mo) |
| 6123 |
{ |
| 6124 |
mo->momx = (P_Random(pr_hexen) - 128) << 6; |
| 6125 |
mo->momy = (P_Random(pr_hexen) - 128) << 6; |
| 6126 |
mo->floorclip = 6 * FRACUNIT; |
| 6127 |
} |
| 6128 |
r1 = P_Random(pr_hexen); |
| 6129 |
r2 = P_Random(pr_hexen); |
| 6130 |
mo = P_SpawnMobj(actor->x + ((r2 - 128) << 12), |
| 6131 |
actor->y + ((r1 - 128) << 12), |
| 6132 |
actor->floorz + FRACUNIT, HEXEN_MT_SERPENT_GIB2); |
| 6133 |
if (mo) |
| 6134 |
{ |
| 6135 |
mo->momx = (P_Random(pr_hexen) - 128) << 6; |
| 6136 |
mo->momy = (P_Random(pr_hexen) - 128) << 6; |
| 6137 |
mo->floorclip = 6 * FRACUNIT; |
| 6138 |
} |
| 6139 |
r1 = P_Random(pr_hexen); |
| 6140 |
r2 = P_Random(pr_hexen); |
| 6141 |
mo = P_SpawnMobj(actor->x + ((r2 - 128) << 12), |
| 6142 |
actor->y + ((r1 - 128) << 12), |
| 6143 |
actor->floorz + FRACUNIT, HEXEN_MT_SERPENT_GIB3); |
| 6144 |
if (mo) |
| 6145 |
{ |
| 6146 |
mo->momx = (P_Random(pr_hexen) - 128) << 6; |
| 6147 |
mo->momy = (P_Random(pr_hexen) - 128) << 6; |
| 6148 |
mo->floorclip = 6 * FRACUNIT; |
| 6149 |
} |
| 6150 |
} |
| 6151 |
|
| 6152 |
void A_FloatGib(mobj_t * actor) |
| 6153 |
{ |
| 6154 |
actor->floorclip -= FRACUNIT; |
| 6155 |
} |
| 6156 |
|
| 6157 |
void A_SinkGib(mobj_t * actor) |
| 6158 |
{ |
| 6159 |
actor->floorclip += FRACUNIT; |
| 6160 |
} |
| 6161 |
|
| 6162 |
void A_DelayGib(mobj_t * actor) |
| 6163 |
{ |
| 6164 |
actor->tics -= P_Random(pr_hexen) >> 2; |
| 6165 |
} |
| 6166 |
|
| 6167 |
void A_SerpentHeadCheck(mobj_t * actor) |
| 6168 |
{ |
| 6169 |
if (actor->z <= actor->floorz) |
| 6170 |
{ |
| 6171 |
if (P_GetThingFloorType(actor) >= FLOOR_LIQUID) |
| 6172 |
{ |
| 6173 |
P_HitFloor(actor); |
| 6174 |
P_SetMobjState(actor, HEXEN_S_NULL); |
| 6175 |
} |
| 6176 |
else |
| 6177 |
{ |
| 6178 |
P_SetMobjState(actor, HEXEN_S_SERPENT_HEAD_X1); |
| 6179 |
} |
| 6180 |
} |
| 6181 |
} |
| 6182 |
|
| 6183 |
void A_CentaurAttack(mobj_t * actor) |
| 6184 |
{ |
| 6185 |
if (!actor->target) |
| 6186 |
{ |
| 6187 |
return; |
| 6188 |
} |
| 6189 |
if (P_CheckMeleeRange(actor)) |
| 6190 |
{ |
| 6191 |
P_DamageMobj(actor->target, actor, actor, P_Random(pr_hexen) % 7 + 3); |
| 6192 |
} |
| 6193 |
} |
| 6194 |
|
| 6195 |
void A_CentaurAttack2(mobj_t * actor) |
| 6196 |
{ |
| 6197 |
if (!actor->target) |
| 6198 |
{ |
| 6199 |
return; |
| 6200 |
} |
| 6201 |
P_SpawnMissile(actor, actor->target, HEXEN_MT_CENTAUR_FX); |
| 6202 |
S_StartMobjSound(actor, hexen_sfx_centaurleader_attack); |
| 6203 |
} |
| 6204 |
|
| 6205 |
void A_CentaurDropStuff(mobj_t * actor) |
| 6206 |
{ |
| 6207 |
mobj_t *mo; |
| 6208 |
angle_t angle; |
| 6209 |
|
| 6210 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6211 |
HEXEN_MT_CENTAUR_SHIELD); |
| 6212 |
if (mo) |
| 6213 |
{ |
| 6214 |
angle = actor->angle + ANG90; |
| 6215 |
mo->momz = FRACUNIT * 8 + (P_Random(pr_hexen) << 10); |
| 6216 |
mo->momx = FixedMul(((P_Random(pr_hexen) - 128) << 11) + FRACUNIT, |
| 6217 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6218 |
mo->momy = FixedMul(((P_Random(pr_hexen) - 128) << 11) + FRACUNIT, |
| 6219 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6220 |
P_SetTarget(&mo->target, actor); |
| 6221 |
} |
| 6222 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6223 |
HEXEN_MT_CENTAUR_SWORD); |
| 6224 |
if (mo) |
| 6225 |
{ |
| 6226 |
angle = actor->angle - ANG90; |
| 6227 |
mo->momz = FRACUNIT * 8 + (P_Random(pr_hexen) << 10); |
| 6228 |
mo->momx = FixedMul(((P_Random(pr_hexen) - 128) << 11) + FRACUNIT, |
| 6229 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6230 |
mo->momy = FixedMul(((P_Random(pr_hexen) - 128) << 11) + FRACUNIT, |
| 6231 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6232 |
P_SetTarget(&mo->target, actor); |
| 6233 |
} |
| 6234 |
} |
| 6235 |
|
| 6236 |
void A_CentaurDefend(mobj_t * actor) |
| 6237 |
{ |
| 6238 |
A_FaceTarget(actor); |
| 6239 |
if (P_CheckMeleeRange(actor) && P_Random(pr_hexen) < 32) |
| 6240 |
{ |
| 6241 |
A_UnSetInvulnerable(actor); |
| 6242 |
P_SetMobjState(actor, actor->info->meleestate); |
| 6243 |
} |
| 6244 |
} |
| 6245 |
|
| 6246 |
void A_BishopAttack(mobj_t * actor) |
| 6247 |
{ |
| 6248 |
if (!actor->target) |
| 6249 |
{ |
| 6250 |
return; |
| 6251 |
} |
| 6252 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 6253 |
if (P_CheckMeleeRange(actor)) |
| 6254 |
{ |
| 6255 |
P_DamageMobj(actor->target, actor, actor, HITDICE(4)); |
| 6256 |
return; |
| 6257 |
} |
| 6258 |
actor->special1.i = (P_Random(pr_hexen) & 3) + 5; |
| 6259 |
} |
| 6260 |
|
| 6261 |
void A_BishopAttack2(mobj_t * actor) |
| 6262 |
{ |
| 6263 |
mobj_t *mo; |
| 6264 |
|
| 6265 |
if (!actor->target || !actor->special1.i) |
| 6266 |
{ |
| 6267 |
actor->special1.i = 0; |
| 6268 |
P_SetMobjState(actor, HEXEN_S_BISHOP_WALK1); |
| 6269 |
return; |
| 6270 |
} |
| 6271 |
mo = P_SpawnMissile(actor, actor->target, HEXEN_MT_BISH_FX); |
| 6272 |
if (mo) |
| 6273 |
{ |
| 6274 |
P_SetTarget(&mo->special1.m, actor->target); |
| 6275 |
mo->special2.i = 16; // High word == x/y, Low word == z |
| 6276 |
} |
| 6277 |
actor->special1.i--; |
| 6278 |
} |
| 6279 |
|
| 6280 |
void A_BishopMissileWeave(mobj_t * actor) |
| 6281 |
{ |
| 6282 |
fixed_t newX, newY; |
| 6283 |
int weaveXY, weaveZ; |
| 6284 |
int angle; |
| 6285 |
|
| 6286 |
weaveXY = actor->special2.i >> 16; |
| 6287 |
weaveZ = actor->special2.i & 0xFFFF; |
| 6288 |
angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 6289 |
newX = actor->x - FixedMul(finecosine[angle], |
| 6290 |
FloatBobOffsets[weaveXY] << 1); |
| 6291 |
newY = actor->y - FixedMul(finesine[angle], |
| 6292 |
FloatBobOffsets[weaveXY] << 1); |
| 6293 |
weaveXY = (weaveXY + 2) & 63; |
| 6294 |
newX += FixedMul(finecosine[angle], FloatBobOffsets[weaveXY] << 1); |
| 6295 |
newY += FixedMul(finesine[angle], FloatBobOffsets[weaveXY] << 1); |
| 6296 |
P_TryMove(actor, newX, newY, false); |
| 6297 |
actor->z -= FloatBobOffsets[weaveZ]; |
| 6298 |
weaveZ = (weaveZ + 2) & 63; |
| 6299 |
actor->z += FloatBobOffsets[weaveZ]; |
| 6300 |
actor->special2.i = weaveZ + (weaveXY << 16); |
| 6301 |
} |
| 6302 |
|
| 6303 |
void A_BishopMissileSeek(mobj_t * actor) |
| 6304 |
{ |
| 6305 |
P_SeekerMissile(actor, &actor->special1.m, ANG1 * 2, ANG1 * 3, false); |
| 6306 |
} |
| 6307 |
|
| 6308 |
void A_BishopDecide(mobj_t * actor) |
| 6309 |
{ |
| 6310 |
if (P_Random(pr_hexen) < 220) |
| 6311 |
{ |
| 6312 |
return; |
| 6313 |
} |
| 6314 |
else |
| 6315 |
{ |
| 6316 |
P_SetMobjState(actor, HEXEN_S_BISHOP_BLUR1); |
| 6317 |
} |
| 6318 |
} |
| 6319 |
|
| 6320 |
void A_BishopDoBlur(mobj_t * actor) |
| 6321 |
{ |
| 6322 |
actor->special1.i = (P_Random(pr_hexen) & 3) + 3; // Random number of blurs |
| 6323 |
if (P_Random(pr_hexen) < 120) |
| 6324 |
{ |
| 6325 |
P_ThrustMobj(actor, actor->angle + ANG90, 11 * FRACUNIT); |
| 6326 |
} |
| 6327 |
else if (P_Random(pr_hexen) > 125) |
| 6328 |
{ |
| 6329 |
P_ThrustMobj(actor, actor->angle - ANG90, 11 * FRACUNIT); |
| 6330 |
} |
| 6331 |
else |
| 6332 |
{ // Thrust forward |
| 6333 |
P_ThrustMobj(actor, actor->angle, 11 * FRACUNIT); |
| 6334 |
} |
| 6335 |
S_StartMobjSound(actor, hexen_sfx_bishop_blur); |
| 6336 |
} |
| 6337 |
|
| 6338 |
void A_BishopSpawnBlur(mobj_t * actor) |
| 6339 |
{ |
| 6340 |
mobj_t *mo; |
| 6341 |
|
| 6342 |
if (!--actor->special1.i) |
| 6343 |
{ |
| 6344 |
actor->momx = 0; |
| 6345 |
actor->momy = 0; |
| 6346 |
if (P_Random(pr_hexen) > 96) |
| 6347 |
{ |
| 6348 |
P_SetMobjState(actor, HEXEN_S_BISHOP_WALK1); |
| 6349 |
} |
| 6350 |
else |
| 6351 |
{ |
| 6352 |
P_SetMobjState(actor, HEXEN_S_BISHOP_ATK1); |
| 6353 |
} |
| 6354 |
} |
| 6355 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_BISHOPBLUR); |
| 6356 |
if (mo) |
| 6357 |
{ |
| 6358 |
mo->angle = actor->angle; |
| 6359 |
} |
| 6360 |
} |
| 6361 |
|
| 6362 |
void A_BishopChase(mobj_t * actor) |
| 6363 |
{ |
| 6364 |
actor->z -= FloatBobOffsets[actor->special2.i] >> 1; |
| 6365 |
actor->special2.i = (actor->special2.i + 4) & 63; |
| 6366 |
actor->z += FloatBobOffsets[actor->special2.i] >> 1; |
| 6367 |
} |
| 6368 |
|
| 6369 |
void A_BishopPuff(mobj_t * actor) |
| 6370 |
{ |
| 6371 |
mobj_t *mo; |
| 6372 |
|
| 6373 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 40 * FRACUNIT, |
| 6374 |
HEXEN_MT_BISHOP_PUFF); |
| 6375 |
if (mo) |
| 6376 |
{ |
| 6377 |
mo->momz = FRACUNIT / 2; |
| 6378 |
} |
| 6379 |
} |
| 6380 |
|
| 6381 |
void A_BishopPainBlur(mobj_t * actor) |
| 6382 |
{ |
| 6383 |
mobj_t *mo; |
| 6384 |
int r1,r2,r3; |
| 6385 |
|
| 6386 |
if (P_Random(pr_hexen) < 64) |
| 6387 |
{ |
| 6388 |
P_SetMobjState(actor, HEXEN_S_BISHOP_BLUR1); |
| 6389 |
return; |
| 6390 |
} |
| 6391 |
|
| 6392 |
r1 = P_SubRandom(); |
| 6393 |
r2 = P_SubRandom(); |
| 6394 |
r3 = P_SubRandom(); |
| 6395 |
|
| 6396 |
mo = P_SpawnMobj(actor->x + (r3 << 12), actor->y |
| 6397 |
+ (r2 << 12), |
| 6398 |
actor->z + (r1 << 11), |
| 6399 |
HEXEN_MT_BISHOPPAINBLUR); |
| 6400 |
if (mo) |
| 6401 |
{ |
| 6402 |
mo->angle = actor->angle; |
| 6403 |
} |
| 6404 |
} |
| 6405 |
|
| 6406 |
static void DragonSeek(mobj_t * actor, angle_t thresh, angle_t turnMax) |
| 6407 |
{ |
| 6408 |
int dir; |
| 6409 |
int dist; |
| 6410 |
angle_t delta; |
| 6411 |
angle_t angle; |
| 6412 |
mobj_t *target; |
| 6413 |
int search; |
| 6414 |
int i; |
| 6415 |
int bestArg; |
| 6416 |
angle_t bestAngle; |
| 6417 |
angle_t angleToSpot, angleToTarget; |
| 6418 |
mobj_t *mo; |
| 6419 |
|
| 6420 |
target = actor->special1.m; |
| 6421 |
if (target == NULL) |
| 6422 |
{ |
| 6423 |
return; |
| 6424 |
} |
| 6425 |
dir = P_FaceMobj(actor, target, &delta); |
| 6426 |
if (delta > thresh) |
| 6427 |
{ |
| 6428 |
delta >>= 1; |
| 6429 |
if (delta > turnMax) |
| 6430 |
{ |
| 6431 |
delta = turnMax; |
| 6432 |
} |
| 6433 |
} |
| 6434 |
if (dir) |
| 6435 |
{ // Turn clockwise |
| 6436 |
actor->angle += delta; |
| 6437 |
} |
| 6438 |
else |
| 6439 |
{ // Turn counter clockwise |
| 6440 |
actor->angle -= delta; |
| 6441 |
} |
| 6442 |
angle = actor->angle >> ANGLETOFINESHIFT; |
| 6443 |
actor->momx = FixedMul(actor->info->speed, finecosine[angle]); |
| 6444 |
actor->momy = FixedMul(actor->info->speed, finesine[angle]); |
| 6445 |
if (actor->z + actor->height < target->z |
| 6446 |
|| target->z + target->height < actor->z) |
| 6447 |
{ |
| 6448 |
dist = P_AproxDistance(target->x - actor->x, target->y - actor->y); |
| 6449 |
dist = dist / actor->info->speed; |
| 6450 |
if (dist < 1) |
| 6451 |
{ |
| 6452 |
dist = 1; |
| 6453 |
} |
| 6454 |
actor->momz = (target->z - actor->z) / dist; |
| 6455 |
} |
| 6456 |
else |
| 6457 |
{ |
| 6458 |
dist = P_AproxDistance(target->x - actor->x, target->y - actor->y); |
| 6459 |
dist = dist / actor->info->speed; |
| 6460 |
} |
| 6461 |
if (target->flags & MF_SHOOTABLE && P_Random(pr_hexen) < 64) |
| 6462 |
{ // attack the destination mobj if it's attackable |
| 6463 |
mobj_t *oldTarget; |
| 6464 |
|
| 6465 |
if (abs((int) actor->angle - (int) R_PointToAngle2(actor->x, actor->y, |
| 6466 |
target->x, |
| 6467 |
target->y)) < ANG45 / 2) |
| 6468 |
{ |
| 6469 |
oldTarget = actor->target; |
| 6470 |
actor->target = target; |
| 6471 |
if (P_CheckMeleeRange(actor)) |
| 6472 |
{ |
| 6473 |
P_DamageMobj(actor->target, actor, actor, HITDICE(10)); |
| 6474 |
S_StartMobjSound(actor, hexen_sfx_dragon_attack); |
| 6475 |
} |
| 6476 |
else if (P_Random(pr_hexen) < 128 && P_CheckMissileRange(actor)) |
| 6477 |
{ |
| 6478 |
P_SpawnMissile(actor, target, HEXEN_MT_DRAGON_FX); |
| 6479 |
S_StartMobjSound(actor, hexen_sfx_dragon_attack); |
| 6480 |
} |
| 6481 |
actor->target = oldTarget; |
| 6482 |
} |
| 6483 |
} |
| 6484 |
if (dist < 4) |
| 6485 |
{ // Hit the target thing |
| 6486 |
if (actor->target && P_Random(pr_hexen) < 200) |
| 6487 |
{ |
| 6488 |
bestArg = -1; |
| 6489 |
bestAngle = ANGLE_MAX; |
| 6490 |
angleToTarget = R_PointToAngle2(actor->x, actor->y, |
| 6491 |
actor->target->x, |
| 6492 |
actor->target->y); |
| 6493 |
for (i = 0; i < 5; i++) |
| 6494 |
{ |
| 6495 |
int mo_x, mo_y; |
| 6496 |
if (!target->special_args[i]) |
| 6497 |
{ |
| 6498 |
continue; |
| 6499 |
} |
| 6500 |
search = -1; |
| 6501 |
mo = P_FindMobjFromTID(target->special_args[i], &search); |
| 6502 |
// [crispy] fix wyvern + porkalator bug |
| 6503 |
if (mo == NULL) |
| 6504 |
{ |
| 6505 |
lprintf(LO_WARN, "DragonSeek: P_FindMobjFromTID() returned NULL mobj!\n"); |
| 6506 |
mo_x = 0; |
| 6507 |
mo_y = 0; |
| 6508 |
} |
| 6509 |
else |
| 6510 |
{ |
| 6511 |
mo_x = mo->x; |
| 6512 |
mo_y = mo->y; |
| 6513 |
} |
| 6514 |
angleToSpot = R_PointToAngle2(actor->x, actor->y, |
| 6515 |
mo_x, mo_y); |
| 6516 |
if (abs((int) angleToSpot - (int) angleToTarget) < bestAngle) |
| 6517 |
{ |
| 6518 |
bestAngle = abs((int) angleToSpot - (int) angleToTarget); |
| 6519 |
bestArg = i; |
| 6520 |
} |
| 6521 |
} |
| 6522 |
if (bestArg != -1) |
| 6523 |
{ |
| 6524 |
search = -1; |
| 6525 |
P_SetTarget( |
| 6526 |
&actor->special1.m, |
| 6527 |
P_FindMobjFromTID(target->special_args[bestArg], &search) |
| 6528 |
); |
| 6529 |
} |
| 6530 |
} |
| 6531 |
else |
| 6532 |
{ |
| 6533 |
do |
| 6534 |
{ |
| 6535 |
i = (P_Random(pr_hexen) >> 2) % 5; |
| 6536 |
} |
| 6537 |
while (!target->special_args[i]); |
| 6538 |
search = -1; |
| 6539 |
P_SetTarget( |
| 6540 |
&actor->special1.m, |
| 6541 |
P_FindMobjFromTID(target->special_args[i], &search) |
| 6542 |
); |
| 6543 |
} |
| 6544 |
} |
| 6545 |
} |
| 6546 |
|
| 6547 |
void A_DragonInitFlight(mobj_t * actor) |
| 6548 |
{ |
| 6549 |
int search; |
| 6550 |
|
| 6551 |
search = -1; |
| 6552 |
do |
| 6553 |
{ // find the first tid identical to the dragon's tid |
| 6554 |
P_SetTarget( |
| 6555 |
&actor->special1.m, |
| 6556 |
P_FindMobjFromTID(actor->tid, &search) |
| 6557 |
); |
| 6558 |
if (search == -1) |
| 6559 |
{ |
| 6560 |
P_SetMobjState(actor, actor->info->spawnstate); |
| 6561 |
return; |
| 6562 |
} |
| 6563 |
} |
| 6564 |
while (actor->special1.m == actor); |
| 6565 |
map_format.remove_mobj_thing_id(actor); |
| 6566 |
} |
| 6567 |
|
| 6568 |
void A_DragonFlight(mobj_t * actor) |
| 6569 |
{ |
| 6570 |
angle_t angle; |
| 6571 |
|
| 6572 |
DragonSeek(actor, 4 * ANG1, 8 * ANG1); |
| 6573 |
if (actor->target) |
| 6574 |
{ |
| 6575 |
if (!(actor->target->flags & MF_SHOOTABLE)) |
| 6576 |
{ // target died |
| 6577 |
P_SetTarget(&actor->target, NULL); |
| 6578 |
return; |
| 6579 |
} |
| 6580 |
angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, |
| 6581 |
actor->target->y); |
| 6582 |
if (abs((int) actor->angle - (int) angle) < ANG45 / 2 |
| 6583 |
&& P_CheckMeleeRange(actor)) |
| 6584 |
{ |
| 6585 |
P_DamageMobj(actor->target, actor, actor, HITDICE(8)); |
| 6586 |
S_StartMobjSound(actor, hexen_sfx_dragon_attack); |
| 6587 |
} |
| 6588 |
else if (abs((int) actor->angle - (int) angle) <= ANG1 * 20) |
| 6589 |
{ |
| 6590 |
P_SetMobjState(actor, actor->info->missilestate); |
| 6591 |
S_StartMobjSound(actor, hexen_sfx_dragon_attack); |
| 6592 |
} |
| 6593 |
} |
| 6594 |
else |
| 6595 |
{ |
| 6596 |
P_LookForPlayers(actor, true); |
| 6597 |
} |
| 6598 |
} |
| 6599 |
|
| 6600 |
void A_DragonFlap(mobj_t * actor) |
| 6601 |
{ |
| 6602 |
A_DragonFlight(actor); |
| 6603 |
if (P_Random(pr_hexen) < 240) |
| 6604 |
{ |
| 6605 |
S_StartMobjSound(actor, hexen_sfx_dragon_wingflap); |
| 6606 |
} |
| 6607 |
else |
| 6608 |
{ |
| 6609 |
S_StartMobjSound(actor, actor->info->activesound); |
| 6610 |
} |
| 6611 |
} |
| 6612 |
|
| 6613 |
void A_DragonAttack(mobj_t * actor) |
| 6614 |
{ |
| 6615 |
P_SpawnMissile(actor, actor->target, HEXEN_MT_DRAGON_FX); |
| 6616 |
} |
| 6617 |
|
| 6618 |
void A_DragonFX2(mobj_t * actor) |
| 6619 |
{ |
| 6620 |
mobj_t *mo; |
| 6621 |
int i; |
| 6622 |
int r1,r2,r3; |
| 6623 |
int delay; |
| 6624 |
|
| 6625 |
delay = 16 + (P_Random(pr_hexen) >> 3); |
| 6626 |
for (i = 1 + (P_Random(pr_hexen) & 3); i; i--) |
| 6627 |
{ |
| 6628 |
r1 = P_Random(pr_hexen); |
| 6629 |
r2 = P_Random(pr_hexen); |
| 6630 |
r3 = P_Random(pr_hexen); |
| 6631 |
mo = P_SpawnMobj(actor->x + ((r3 - 128) << 14), |
| 6632 |
actor->y + ((r2 - 128) << 14), |
| 6633 |
actor->z + ((r1 - 128) << 12), |
| 6634 |
HEXEN_MT_DRAGON_FX2); |
| 6635 |
if (mo) |
| 6636 |
{ |
| 6637 |
mo->tics = delay + (P_Random(pr_hexen) & 3) * i * 2; |
| 6638 |
P_SetTarget(&mo->target, actor->target); |
| 6639 |
} |
| 6640 |
} |
| 6641 |
} |
| 6642 |
|
| 6643 |
void A_DragonPain(mobj_t * actor) |
| 6644 |
{ |
| 6645 |
A_Pain(actor); |
| 6646 |
if (!actor->special1.m) |
| 6647 |
{ // no destination spot yet |
| 6648 |
P_SetMobjState(actor, HEXEN_S_DRAGON_INIT); |
| 6649 |
} |
| 6650 |
} |
| 6651 |
|
| 6652 |
void A_DragonCheckCrash(mobj_t * actor) |
| 6653 |
{ |
| 6654 |
if (actor->z <= actor->floorz) |
| 6655 |
{ |
| 6656 |
P_SetMobjState(actor, HEXEN_S_DRAGON_CRASH1); |
| 6657 |
} |
| 6658 |
} |
| 6659 |
|
| 6660 |
void A_DemonAttack1(mobj_t * actor) |
| 6661 |
{ |
| 6662 |
if (P_CheckMeleeRange(actor)) |
| 6663 |
{ |
| 6664 |
P_DamageMobj(actor->target, actor, actor, HITDICE(2)); |
| 6665 |
} |
| 6666 |
} |
| 6667 |
|
| 6668 |
void A_DemonAttack2(mobj_t * actor) |
| 6669 |
{ |
| 6670 |
mobj_t *mo; |
| 6671 |
int fireBall; |
| 6672 |
|
| 6673 |
if (actor->type == HEXEN_MT_DEMON) |
| 6674 |
{ |
| 6675 |
fireBall = HEXEN_MT_DEMONFX1; |
| 6676 |
} |
| 6677 |
else |
| 6678 |
{ |
| 6679 |
fireBall = HEXEN_MT_DEMON2FX1; |
| 6680 |
} |
| 6681 |
mo = P_SpawnMissile(actor, actor->target, fireBall); |
| 6682 |
if (mo) |
| 6683 |
{ |
| 6684 |
mo->z += 30 * FRACUNIT; |
| 6685 |
S_StartMobjSound(actor, hexen_sfx_demon_missile_fire); |
| 6686 |
} |
| 6687 |
} |
| 6688 |
|
| 6689 |
void A_DemonDeath(mobj_t * actor) |
| 6690 |
{ |
| 6691 |
mobj_t *mo; |
| 6692 |
angle_t angle; |
| 6693 |
|
| 6694 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6695 |
HEXEN_MT_DEMONCHUNK1); |
| 6696 |
if (mo) |
| 6697 |
{ |
| 6698 |
angle = actor->angle + ANG90; |
| 6699 |
mo->momz = 8 * FRACUNIT; |
| 6700 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6701 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6702 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6703 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6704 |
P_SetTarget(&mo->target, actor); |
| 6705 |
} |
| 6706 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6707 |
HEXEN_MT_DEMONCHUNK2); |
| 6708 |
if (mo) |
| 6709 |
{ |
| 6710 |
angle = actor->angle - ANG90; |
| 6711 |
mo->momz = 8 * FRACUNIT; |
| 6712 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6713 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6714 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6715 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6716 |
P_SetTarget(&mo->target, actor); |
| 6717 |
} |
| 6718 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6719 |
HEXEN_MT_DEMONCHUNK3); |
| 6720 |
if (mo) |
| 6721 |
{ |
| 6722 |
angle = actor->angle - ANG90; |
| 6723 |
mo->momz = 8 * FRACUNIT; |
| 6724 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6725 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6726 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6727 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6728 |
P_SetTarget(&mo->target, actor); |
| 6729 |
} |
| 6730 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6731 |
HEXEN_MT_DEMONCHUNK4); |
| 6732 |
if (mo) |
| 6733 |
{ |
| 6734 |
angle = actor->angle - ANG90; |
| 6735 |
mo->momz = 8 * FRACUNIT; |
| 6736 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6737 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6738 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6739 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6740 |
P_SetTarget(&mo->target, actor); |
| 6741 |
} |
| 6742 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6743 |
HEXEN_MT_DEMONCHUNK5); |
| 6744 |
if (mo) |
| 6745 |
{ |
| 6746 |
angle = actor->angle - ANG90; |
| 6747 |
mo->momz = 8 * FRACUNIT; |
| 6748 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6749 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6750 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6751 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6752 |
P_SetTarget(&mo->target, actor); |
| 6753 |
} |
| 6754 |
} |
| 6755 |
|
| 6756 |
void A_Demon2Death(mobj_t * actor) |
| 6757 |
{ |
| 6758 |
mobj_t *mo; |
| 6759 |
angle_t angle; |
| 6760 |
|
| 6761 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6762 |
HEXEN_MT_DEMON2CHUNK1); |
| 6763 |
if (mo) |
| 6764 |
{ |
| 6765 |
angle = actor->angle + ANG90; |
| 6766 |
mo->momz = 8 * FRACUNIT; |
| 6767 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6768 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6769 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6770 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6771 |
P_SetTarget(&mo->target, actor); |
| 6772 |
} |
| 6773 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6774 |
HEXEN_MT_DEMON2CHUNK2); |
| 6775 |
if (mo) |
| 6776 |
{ |
| 6777 |
angle = actor->angle - ANG90; |
| 6778 |
mo->momz = 8 * FRACUNIT; |
| 6779 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6780 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6781 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6782 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6783 |
P_SetTarget(&mo->target, actor); |
| 6784 |
} |
| 6785 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6786 |
HEXEN_MT_DEMON2CHUNK3); |
| 6787 |
if (mo) |
| 6788 |
{ |
| 6789 |
angle = actor->angle - ANG90; |
| 6790 |
mo->momz = 8 * FRACUNIT; |
| 6791 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6792 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6793 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6794 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6795 |
P_SetTarget(&mo->target, actor); |
| 6796 |
} |
| 6797 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6798 |
HEXEN_MT_DEMON2CHUNK4); |
| 6799 |
if (mo) |
| 6800 |
{ |
| 6801 |
angle = actor->angle - ANG90; |
| 6802 |
mo->momz = 8 * FRACUNIT; |
| 6803 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6804 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6805 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6806 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6807 |
P_SetTarget(&mo->target, actor); |
| 6808 |
} |
| 6809 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + 45 * FRACUNIT, |
| 6810 |
HEXEN_MT_DEMON2CHUNK5); |
| 6811 |
if (mo) |
| 6812 |
{ |
| 6813 |
angle = actor->angle - ANG90; |
| 6814 |
mo->momz = 8 * FRACUNIT; |
| 6815 |
mo->momx = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6816 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6817 |
mo->momy = FixedMul((P_Random(pr_hexen) << 10) + FRACUNIT, |
| 6818 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6819 |
P_SetTarget(&mo->target, actor); |
| 6820 |
} |
| 6821 |
} |
| 6822 |
|
| 6823 |
dboolean A_SinkMobj(mobj_t * actor) |
| 6824 |
{ |
| 6825 |
if (actor->floorclip < actor->info->height) |
| 6826 |
{ |
| 6827 |
switch (actor->type) |
| 6828 |
{ |
| 6829 |
case HEXEN_MT_THRUSTFLOOR_DOWN: |
| 6830 |
case HEXEN_MT_THRUSTFLOOR_UP: |
| 6831 |
actor->floorclip += 6 * FRACUNIT; |
| 6832 |
break; |
| 6833 |
default: |
| 6834 |
actor->floorclip += FRACUNIT; |
| 6835 |
break; |
| 6836 |
} |
| 6837 |
return false; |
| 6838 |
} |
| 6839 |
return true; |
| 6840 |
} |
| 6841 |
|
| 6842 |
dboolean A_RaiseMobj(mobj_t * actor) |
| 6843 |
{ |
| 6844 |
int done = true; |
| 6845 |
|
| 6846 |
// Raise a mobj from the ground |
| 6847 |
if (actor->floorclip > 0) |
| 6848 |
{ |
| 6849 |
switch (actor->type) |
| 6850 |
{ |
| 6851 |
case HEXEN_MT_WRAITHB: |
| 6852 |
actor->floorclip -= 2 * FRACUNIT; |
| 6853 |
break; |
| 6854 |
case HEXEN_MT_THRUSTFLOOR_DOWN: |
| 6855 |
case HEXEN_MT_THRUSTFLOOR_UP: |
| 6856 |
actor->floorclip -= actor->special2.i * FRACUNIT; |
| 6857 |
break; |
| 6858 |
default: |
| 6859 |
actor->floorclip -= 2 * FRACUNIT; |
| 6860 |
break; |
| 6861 |
} |
| 6862 |
if (actor->floorclip <= 0) |
| 6863 |
{ |
| 6864 |
actor->floorclip = 0; |
| 6865 |
done = true; |
| 6866 |
} |
| 6867 |
else |
| 6868 |
{ |
| 6869 |
done = false; |
| 6870 |
} |
| 6871 |
} |
| 6872 |
return done; // Reached target height |
| 6873 |
} |
| 6874 |
|
| 6875 |
void A_WraithInit(mobj_t * actor) |
| 6876 |
{ |
| 6877 |
actor->z += 48 << FRACBITS; |
| 6878 |
actor->special1.i = 0; // index into floatbob |
| 6879 |
} |
| 6880 |
|
| 6881 |
void A_WraithRaiseInit(mobj_t * actor) |
| 6882 |
{ |
| 6883 |
actor->flags2 &= ~MF2_DONTDRAW; |
| 6884 |
actor->flags2 &= ~MF2_NONSHOOTABLE; |
| 6885 |
actor->flags |= MF_SHOOTABLE | MF_SOLID; |
| 6886 |
actor->floorclip = actor->info->height; |
| 6887 |
} |
| 6888 |
|
| 6889 |
void A_WraithRaise(mobj_t * actor) |
| 6890 |
{ |
| 6891 |
if (A_RaiseMobj(actor)) |
| 6892 |
{ |
| 6893 |
// Reached it's target height |
| 6894 |
P_SetMobjState(actor, HEXEN_S_WRAITH_CHASE1); |
| 6895 |
} |
| 6896 |
|
| 6897 |
P_SpawnDirt(actor, actor->radius); |
| 6898 |
} |
| 6899 |
|
| 6900 |
void A_WraithMelee(mobj_t * actor) |
| 6901 |
{ |
| 6902 |
int amount; |
| 6903 |
|
| 6904 |
// Steal health from target and give to player |
| 6905 |
if (P_CheckMeleeRange(actor) && (P_Random(pr_hexen) < 220)) |
| 6906 |
{ |
| 6907 |
amount = HITDICE(2); |
| 6908 |
P_DamageMobj(actor->target, actor, actor, amount); |
| 6909 |
actor->health += amount; |
| 6910 |
} |
| 6911 |
} |
| 6912 |
|
| 6913 |
void A_WraithMissile(mobj_t * actor) |
| 6914 |
{ |
| 6915 |
mobj_t *mo; |
| 6916 |
|
| 6917 |
mo = P_SpawnMissile(actor, actor->target, HEXEN_MT_WRAITHFX1); |
| 6918 |
if (mo) |
| 6919 |
{ |
| 6920 |
S_StartMobjSound(actor, hexen_sfx_wraith_missile_fire); |
| 6921 |
} |
| 6922 |
} |
| 6923 |
|
| 6924 |
void A_WraithFX2(mobj_t * actor) |
| 6925 |
{ |
| 6926 |
mobj_t *mo; |
| 6927 |
angle_t angle; |
| 6928 |
int i; |
| 6929 |
|
| 6930 |
for (i = 0; i < 2; i++) |
| 6931 |
{ |
| 6932 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_WRAITHFX2); |
| 6933 |
if (mo) |
| 6934 |
{ |
| 6935 |
if (P_Random(pr_hexen) < 128) |
| 6936 |
{ |
| 6937 |
angle = actor->angle + (P_Random(pr_hexen) << 22); |
| 6938 |
} |
| 6939 |
else |
| 6940 |
{ |
| 6941 |
angle = actor->angle - (P_Random(pr_hexen) << 22); |
| 6942 |
} |
| 6943 |
mo->momz = 0; |
| 6944 |
mo->momx = FixedMul((P_Random(pr_hexen) << 7) + FRACUNIT, |
| 6945 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 6946 |
mo->momy = FixedMul((P_Random(pr_hexen) << 7) + FRACUNIT, |
| 6947 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 6948 |
P_SetTarget(&mo->target, actor); |
| 6949 |
mo->floorclip = 10 * FRACUNIT; |
| 6950 |
} |
| 6951 |
} |
| 6952 |
} |
| 6953 |
|
| 6954 |
void A_WraithFX3(mobj_t * actor) |
| 6955 |
{ |
| 6956 |
mobj_t *mo; |
| 6957 |
int numdropped = P_Random(pr_hexen) % 15; |
| 6958 |
int i; |
| 6959 |
|
| 6960 |
for (i = 0; i < numdropped; i++) |
| 6961 |
{ |
| 6962 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_WRAITHFX3); |
| 6963 |
if (mo) |
| 6964 |
{ |
| 6965 |
mo->x += (P_Random(pr_hexen) - 128) << 11; |
| 6966 |
mo->y += (P_Random(pr_hexen) - 128) << 11; |
| 6967 |
mo->z += (P_Random(pr_hexen) << 10); |
| 6968 |
P_SetTarget(&mo->target, actor); |
| 6969 |
} |
| 6970 |
} |
| 6971 |
} |
| 6972 |
|
| 6973 |
void A_WraithFX4(mobj_t * actor) |
| 6974 |
{ |
| 6975 |
mobj_t *mo; |
| 6976 |
int chance = P_Random(pr_hexen); |
| 6977 |
int spawn4, spawn5; |
| 6978 |
|
| 6979 |
if (chance < 10) |
| 6980 |
{ |
| 6981 |
spawn4 = true; |
| 6982 |
spawn5 = false; |
| 6983 |
} |
| 6984 |
else if (chance < 20) |
| 6985 |
{ |
| 6986 |
spawn4 = false; |
| 6987 |
spawn5 = true; |
| 6988 |
} |
| 6989 |
else if (chance < 25) |
| 6990 |
{ |
| 6991 |
spawn4 = true; |
| 6992 |
spawn5 = true; |
| 6993 |
} |
| 6994 |
else |
| 6995 |
{ |
| 6996 |
spawn4 = false; |
| 6997 |
spawn5 = false; |
| 6998 |
} |
| 6999 |
|
| 7000 |
if (spawn4) |
| 7001 |
{ |
| 7002 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_WRAITHFX4); |
| 7003 |
if (mo) |
| 7004 |
{ |
| 7005 |
mo->x += (P_Random(pr_hexen) - 128) << 12; |
| 7006 |
mo->y += (P_Random(pr_hexen) - 128) << 12; |
| 7007 |
mo->z += (P_Random(pr_hexen) << 10); |
| 7008 |
P_SetTarget(&mo->target, actor); |
| 7009 |
} |
| 7010 |
} |
| 7011 |
if (spawn5) |
| 7012 |
{ |
| 7013 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_WRAITHFX5); |
| 7014 |
if (mo) |
| 7015 |
{ |
| 7016 |
mo->x += (P_Random(pr_hexen) - 128) << 11; |
| 7017 |
mo->y += (P_Random(pr_hexen) - 128) << 11; |
| 7018 |
mo->z += (P_Random(pr_hexen) << 10); |
| 7019 |
P_SetTarget(&mo->target, actor); |
| 7020 |
} |
| 7021 |
} |
| 7022 |
} |
| 7023 |
|
| 7024 |
void A_WraithLook(mobj_t * actor) |
| 7025 |
{ |
| 7026 |
// A_WraithFX4(actor); // too expensive |
| 7027 |
A_Look(actor); |
| 7028 |
} |
| 7029 |
|
| 7030 |
void A_WraithChase(mobj_t * actor) |
| 7031 |
{ |
| 7032 |
int weaveindex = actor->special1.i; |
| 7033 |
actor->z += FloatBobOffsets[weaveindex]; |
| 7034 |
actor->special1.i = (weaveindex + 2) & 63; |
| 7035 |
A_Chase(actor); |
| 7036 |
A_WraithFX4(actor); |
| 7037 |
} |
| 7038 |
|
| 7039 |
void A_EttinAttack(mobj_t * actor) |
| 7040 |
{ |
| 7041 |
if (P_CheckMeleeRange(actor)) |
| 7042 |
{ |
| 7043 |
P_DamageMobj(actor->target, actor, actor, HITDICE(2)); |
| 7044 |
} |
| 7045 |
} |
| 7046 |
|
| 7047 |
void A_DropMace(mobj_t * actor) |
| 7048 |
{ |
| 7049 |
mobj_t *mo; |
| 7050 |
|
| 7051 |
mo = P_SpawnMobj(actor->x, actor->y, |
| 7052 |
actor->z + (actor->height >> 1), HEXEN_MT_ETTIN_MACE); |
| 7053 |
if (mo) |
| 7054 |
{ |
| 7055 |
mo->momx = (P_Random(pr_hexen) - 128) << 11; |
| 7056 |
mo->momy = (P_Random(pr_hexen) - 128) << 11; |
| 7057 |
mo->momz = FRACUNIT * 10 + (P_Random(pr_hexen) << 10); |
| 7058 |
P_SetTarget(&mo->target, actor); |
| 7059 |
} |
| 7060 |
} |
| 7061 |
|
| 7062 |
void A_FiredSpawnRock(mobj_t * actor) |
| 7063 |
{ |
| 7064 |
mobj_t *mo; |
| 7065 |
int x, y, z; |
| 7066 |
int rtype = 0; |
| 7067 |
|
| 7068 |
switch (P_Random(pr_hexen) % 5) |
| 7069 |
{ |
| 7070 |
case 0: |
| 7071 |
rtype = HEXEN_MT_FIREDEMON_FX1; |
| 7072 |
break; |
| 7073 |
case 1: |
| 7074 |
rtype = HEXEN_MT_FIREDEMON_FX2; |
| 7075 |
break; |
| 7076 |
case 2: |
| 7077 |
rtype = HEXEN_MT_FIREDEMON_FX3; |
| 7078 |
break; |
| 7079 |
case 3: |
| 7080 |
rtype = HEXEN_MT_FIREDEMON_FX4; |
| 7081 |
break; |
| 7082 |
case 4: |
| 7083 |
rtype = HEXEN_MT_FIREDEMON_FX5; |
| 7084 |
break; |
| 7085 |
} |
| 7086 |
|
| 7087 |
x = actor->x + ((P_Random(pr_hexen) - 128) << 12); |
| 7088 |
y = actor->y + ((P_Random(pr_hexen) - 128) << 12); |
| 7089 |
z = actor->z + ((P_Random(pr_hexen)) << 11); |
| 7090 |
mo = P_SpawnMobj(x, y, z, rtype); |
| 7091 |
if (mo) |
| 7092 |
{ |
| 7093 |
P_SetTarget(&mo->target, actor); |
| 7094 |
mo->momx = (P_Random(pr_hexen) - 128) << 10; |
| 7095 |
mo->momy = (P_Random(pr_hexen) - 128) << 10; |
| 7096 |
mo->momz = (P_Random(pr_hexen) << 10); |
| 7097 |
mo->special1.i = 2; // Number bounces |
| 7098 |
} |
| 7099 |
|
| 7100 |
// Initialize fire demon |
| 7101 |
actor->special2.i = 0; |
| 7102 |
actor->flags &= ~MF_JUSTATTACKED; |
| 7103 |
} |
| 7104 |
|
| 7105 |
void A_FiredRocks(mobj_t * actor) |
| 7106 |
{ |
| 7107 |
A_FiredSpawnRock(actor); |
| 7108 |
A_FiredSpawnRock(actor); |
| 7109 |
A_FiredSpawnRock(actor); |
| 7110 |
A_FiredSpawnRock(actor); |
| 7111 |
A_FiredSpawnRock(actor); |
| 7112 |
} |
| 7113 |
|
| 7114 |
void A_FiredAttack(mobj_t * actor) |
| 7115 |
{ |
| 7116 |
mobj_t *mo; |
| 7117 |
mo = P_SpawnMissile(actor, actor->target, HEXEN_MT_FIREDEMON_FX6); |
| 7118 |
if (mo) |
| 7119 |
S_StartMobjSound(actor, hexen_sfx_fired_attack); |
| 7120 |
} |
| 7121 |
|
| 7122 |
void A_SmBounce(mobj_t * actor) |
| 7123 |
{ |
| 7124 |
// give some more momentum (x,y,&z) |
| 7125 |
actor->z = actor->floorz + FRACUNIT; |
| 7126 |
actor->momz = (2 * FRACUNIT) + (P_Random(pr_hexen) << 10); |
| 7127 |
actor->momx = P_Random(pr_hexen) % 3 << FRACBITS; |
| 7128 |
actor->momy = P_Random(pr_hexen) % 3 << FRACBITS; |
| 7129 |
} |
| 7130 |
|
| 7131 |
#define FIREDEMON_ATTACK_RANGE 64*8*FRACUNIT |
| 7132 |
|
| 7133 |
void A_FiredChase(mobj_t * actor) |
| 7134 |
{ |
| 7135 |
int weaveindex = actor->special1.i; |
| 7136 |
mobj_t *target = actor->target; |
| 7137 |
angle_t ang; |
| 7138 |
fixed_t dist; |
| 7139 |
|
| 7140 |
if (actor->reactiontime) |
| 7141 |
actor->reactiontime--; |
| 7142 |
if (actor->threshold) |
| 7143 |
actor->threshold--; |
| 7144 |
|
| 7145 |
// Float up and down |
| 7146 |
actor->z += FloatBobOffsets[weaveindex]; |
| 7147 |
actor->special1.i = (weaveindex + 2) & 63; |
| 7148 |
|
| 7149 |
// Insure it stays above certain height |
| 7150 |
if (actor->z < actor->floorz + (64 * FRACUNIT)) |
| 7151 |
{ |
| 7152 |
actor->z += 2 * FRACUNIT; |
| 7153 |
} |
| 7154 |
|
| 7155 |
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) |
| 7156 |
{ // Invalid target |
| 7157 |
P_LookForPlayers(actor, true); |
| 7158 |
return; |
| 7159 |
} |
| 7160 |
|
| 7161 |
// Strafe |
| 7162 |
if (actor->special2.i > 0) |
| 7163 |
{ |
| 7164 |
actor->special2.i--; |
| 7165 |
} |
| 7166 |
else |
| 7167 |
{ |
| 7168 |
actor->special2.i = 0; |
| 7169 |
actor->momx = actor->momy = 0; |
| 7170 |
dist = P_AproxDistance(actor->x - target->x, actor->y - target->y); |
| 7171 |
if (dist < FIREDEMON_ATTACK_RANGE) |
| 7172 |
{ |
| 7173 |
if (P_Random(pr_hexen) < 30) |
| 7174 |
{ |
| 7175 |
ang = |
| 7176 |
R_PointToAngle2(actor->x, actor->y, target->x, target->y); |
| 7177 |
if (P_Random(pr_hexen) < 128) |
| 7178 |
ang += ANG90; |
| 7179 |
else |
| 7180 |
ang -= ANG90; |
| 7181 |
ang >>= ANGLETOFINESHIFT; |
| 7182 |
actor->momx = FixedMul(8 * FRACUNIT, finecosine[ang]); |
| 7183 |
actor->momy = FixedMul(8 * FRACUNIT, finesine[ang]); |
| 7184 |
actor->special2.i = 3; // strafe time |
| 7185 |
} |
| 7186 |
} |
| 7187 |
} |
| 7188 |
|
| 7189 |
FaceMovementDirection(actor); |
| 7190 |
|
| 7191 |
// Normal movement |
| 7192 |
if (!actor->special2.i) |
| 7193 |
{ |
| 7194 |
if (--actor->movecount < 0 || !P_Move(actor, false)) |
| 7195 |
{ |
| 7196 |
P_NewChaseDir(actor); |
| 7197 |
} |
| 7198 |
} |
| 7199 |
|
| 7200 |
// Do missile attack |
| 7201 |
if (!(actor->flags & MF_JUSTATTACKED)) |
| 7202 |
{ |
| 7203 |
if (P_CheckMissileRange(actor) && (P_Random(pr_hexen) < 20)) |
| 7204 |
{ |
| 7205 |
P_SetMobjState(actor, actor->info->missilestate); |
| 7206 |
actor->flags |= MF_JUSTATTACKED; |
| 7207 |
return; |
| 7208 |
} |
| 7209 |
} |
| 7210 |
else |
| 7211 |
{ |
| 7212 |
actor->flags &= ~MF_JUSTATTACKED; |
| 7213 |
} |
| 7214 |
|
| 7215 |
// make active sound |
| 7216 |
if (actor->info->activesound && P_Random(pr_hexen) < 3) |
| 7217 |
{ |
| 7218 |
S_StartMobjSound(actor, actor->info->activesound); |
| 7219 |
} |
| 7220 |
} |
| 7221 |
|
| 7222 |
void A_FiredSplotch(mobj_t * actor) |
| 7223 |
{ |
| 7224 |
mobj_t *mo; |
| 7225 |
|
| 7226 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_FIREDEMON_SPLOTCH1); |
| 7227 |
if (mo) |
| 7228 |
{ |
| 7229 |
mo->momx = (P_Random(pr_hexen) - 128) << 11; |
| 7230 |
mo->momy = (P_Random(pr_hexen) - 128) << 11; |
| 7231 |
mo->momz = FRACUNIT * 3 + (P_Random(pr_hexen) << 10); |
| 7232 |
} |
| 7233 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_FIREDEMON_SPLOTCH2); |
| 7234 |
if (mo) |
| 7235 |
{ |
| 7236 |
mo->momx = (P_Random(pr_hexen) - 128) << 11; |
| 7237 |
mo->momy = (P_Random(pr_hexen) - 128) << 11; |
| 7238 |
mo->momz = FRACUNIT * 3 + (P_Random(pr_hexen) << 10); |
| 7239 |
} |
| 7240 |
} |
| 7241 |
|
| 7242 |
#include "heretic/sb_bar.h" |
| 7243 |
|
| 7244 |
void A_FreezeDeath(mobj_t * actor) |
| 7245 |
{ |
| 7246 |
int r = P_Random(pr_hexen); |
| 7247 |
actor->tics = 75 + r + P_Random(pr_hexen); |
| 7248 |
actor->flags |= MF_SOLID | MF_SHOOTABLE | MF_NOBLOOD; |
| 7249 |
actor->flags2 |= MF2_PUSHABLE | MF2_TELESTOMP | MF2_PASSMOBJ | MF2_SLIDE; |
| 7250 |
actor->height <<= 2; |
| 7251 |
S_StartMobjSound(actor, hexen_sfx_freeze_death); |
| 7252 |
|
| 7253 |
if (actor->player) |
| 7254 |
{ |
| 7255 |
actor->player->damagecount = 0; |
| 7256 |
actor->player->poisoncount = 0; |
| 7257 |
actor->player->bonuscount = 0; |
| 7258 |
if (actor->player == &players[consoleplayer]) |
| 7259 |
{ |
| 7260 |
SB_PaletteFlash(false); |
| 7261 |
} |
| 7262 |
} |
| 7263 |
else if (actor->flags & MF_COUNTKILL && actor->special) |
| 7264 |
{ |
| 7265 |
// Initiate monster death actions. |
| 7266 |
map_format.execute_line_special(actor->special, actor->special_args, NULL, 0, actor); |
| 7267 |
} |
| 7268 |
} |
| 7269 |
|
| 7270 |
void A_IceSetTics(mobj_t * actor) |
| 7271 |
{ |
| 7272 |
int floor; |
| 7273 |
|
| 7274 |
actor->tics = 70 + (P_Random(pr_hexen) & 63); |
| 7275 |
floor = P_GetThingFloorType(actor); |
| 7276 |
if (floor == FLOOR_LAVA) |
| 7277 |
{ |
| 7278 |
actor->tics >>= 2; |
| 7279 |
} |
| 7280 |
else if (floor == FLOOR_ICE) |
| 7281 |
{ |
| 7282 |
actor->tics <<= 1; |
| 7283 |
} |
| 7284 |
} |
| 7285 |
|
| 7286 |
void A_IceCheckHeadDone(mobj_t * actor) |
| 7287 |
{ |
| 7288 |
if (actor->special2.i == 666) |
| 7289 |
{ |
| 7290 |
P_SetMobjState(actor, HEXEN_S_ICECHUNK_HEAD2); |
| 7291 |
} |
| 7292 |
} |
| 7293 |
|
| 7294 |
void A_FreezeDeathChunks(mobj_t * actor) |
| 7295 |
{ |
| 7296 |
int i; |
| 7297 |
int r1,r2,r3; |
| 7298 |
mobj_t *mo; |
| 7299 |
|
| 7300 |
if (actor->momx || actor->momy || actor->momz) |
| 7301 |
{ |
| 7302 |
actor->tics = 105; |
| 7303 |
return; |
| 7304 |
} |
| 7305 |
S_StartMobjSound(actor, hexen_sfx_freeze_shatter); |
| 7306 |
|
| 7307 |
for (i = 12 + (P_Random(pr_hexen) & 15); i >= 0; i--) |
| 7308 |
{ |
| 7309 |
r1 = P_Random(pr_hexen); |
| 7310 |
r2 = P_Random(pr_hexen); |
| 7311 |
r3 = P_Random(pr_hexen); |
| 7312 |
mo = P_SpawnMobj(actor->x + |
| 7313 |
(((r3 - 128) * actor->radius) >> 7), |
| 7314 |
actor->y + |
| 7315 |
(((r2 - 128) * actor->radius) >> 7), |
| 7316 |
actor->z + (r1 * actor->height / 255), |
| 7317 |
HEXEN_MT_ICECHUNK); |
| 7318 |
P_SetMobjState(mo, mo->info->spawnstate + (P_Random(pr_hexen) % 3)); |
| 7319 |
mo->momz = FixedDiv(mo->z - actor->z, actor->height) << 2; |
| 7320 |
mo->momx = P_SubRandom() << (FRACBITS - 7); |
| 7321 |
mo->momy = P_SubRandom() << (FRACBITS - 7); |
| 7322 |
A_IceSetTics(mo); // set a random tic wait |
| 7323 |
} |
| 7324 |
for (i = 12 + (P_Random(pr_hexen) & 15); i >= 0; i--) |
| 7325 |
{ |
| 7326 |
r1 = P_Random(pr_hexen); |
| 7327 |
r2 = P_Random(pr_hexen); |
| 7328 |
r3 = P_Random(pr_hexen); |
| 7329 |
mo = P_SpawnMobj(actor->x + |
| 7330 |
(((r3 - 128) * actor->radius) >> 7), |
| 7331 |
actor->y + |
| 7332 |
(((r2 - 128) * actor->radius) >> 7), |
| 7333 |
actor->z + (r1 * actor->height / 255), |
| 7334 |
HEXEN_MT_ICECHUNK); |
| 7335 |
P_SetMobjState(mo, mo->info->spawnstate + (P_Random(pr_hexen) % 3)); |
| 7336 |
mo->momz = FixedDiv(mo->z - actor->z, actor->height) << 2; |
| 7337 |
mo->momx = P_SubRandom() << (FRACBITS - 7); |
| 7338 |
mo->momy = P_SubRandom() << (FRACBITS - 7); |
| 7339 |
A_IceSetTics(mo); // set a random tic wait |
| 7340 |
} |
| 7341 |
if (actor->player) |
| 7342 |
{ // attach the player's view to a chunk of ice |
| 7343 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z + g_viewheight, |
| 7344 |
HEXEN_MT_ICECHUNK); |
| 7345 |
P_SetMobjState(mo, HEXEN_S_ICECHUNK_HEAD); |
| 7346 |
mo->momz = FixedDiv(mo->z - actor->z, actor->height) << 2; |
| 7347 |
mo->momx = P_SubRandom() << (FRACBITS - 7); |
| 7348 |
mo->momy = P_SubRandom() << (FRACBITS - 7); |
| 7349 |
mo->flags2 |= MF2_ICEDAMAGE; // used to force blue palette |
| 7350 |
mo->flags2 &= ~MF2_FOOTCLIP; |
| 7351 |
mo->player = actor->player; |
| 7352 |
actor->player = NULL; |
| 7353 |
mo->health = actor->health; |
| 7354 |
mo->angle = actor->angle; |
| 7355 |
mo->player->mo = mo; |
| 7356 |
mo->player->lookdir = 0; |
| 7357 |
} |
| 7358 |
map_format.remove_mobj_thing_id(actor); |
| 7359 |
P_SetMobjState(actor, HEXEN_S_FREETARGMOBJ); |
| 7360 |
actor->flags2 |= MF2_DONTDRAW; |
| 7361 |
} |
| 7362 |
|
| 7363 |
void A_IceGuyLook(mobj_t * actor) |
| 7364 |
{ |
| 7365 |
fixed_t dist; |
| 7366 |
fixed_t an; |
| 7367 |
|
| 7368 |
A_Look(actor); |
| 7369 |
if (P_Random(pr_hexen) < 64) |
| 7370 |
{ |
| 7371 |
dist = ((P_Random(pr_hexen) - 128) * actor->radius) >> 7; |
| 7372 |
an = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 7373 |
|
| 7374 |
P_SpawnMobj(actor->x + FixedMul(dist, finecosine[an]), |
| 7375 |
actor->y + FixedMul(dist, finesine[an]), |
| 7376 |
actor->z + 60 * FRACUNIT, |
| 7377 |
HEXEN_MT_ICEGUY_WISP1 + (P_Random(pr_hexen) & 1)); |
| 7378 |
} |
| 7379 |
} |
| 7380 |
|
| 7381 |
void A_IceGuyChase(mobj_t * actor) |
| 7382 |
{ |
| 7383 |
fixed_t dist; |
| 7384 |
fixed_t an; |
| 7385 |
mobj_t *mo; |
| 7386 |
|
| 7387 |
A_Chase(actor); |
| 7388 |
if (P_Random(pr_hexen) < 128) |
| 7389 |
{ |
| 7390 |
dist = ((P_Random(pr_hexen) - 128) * actor->radius) >> 7; |
| 7391 |
an = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 7392 |
|
| 7393 |
mo = P_SpawnMobj(actor->x + FixedMul(dist, finecosine[an]), |
| 7394 |
actor->y + FixedMul(dist, finesine[an]), |
| 7395 |
actor->z + 60 * FRACUNIT, |
| 7396 |
HEXEN_MT_ICEGUY_WISP1 + (P_Random(pr_hexen) & 1)); |
| 7397 |
if (mo) |
| 7398 |
{ |
| 7399 |
mo->momx = actor->momx; |
| 7400 |
mo->momy = actor->momy; |
| 7401 |
mo->momz = actor->momz; |
| 7402 |
P_SetTarget(&mo->target, actor); |
| 7403 |
} |
| 7404 |
} |
| 7405 |
} |
| 7406 |
|
| 7407 |
void A_IceGuyAttack(mobj_t * actor) |
| 7408 |
{ |
| 7409 |
fixed_t an; |
| 7410 |
|
| 7411 |
if (!actor->target) |
| 7412 |
{ |
| 7413 |
return; |
| 7414 |
} |
| 7415 |
an = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 7416 |
P_SpawnMissileXYZ(actor->x + FixedMul(actor->radius >> 1, |
| 7417 |
finecosine[an]), |
| 7418 |
actor->y + FixedMul(actor->radius >> 1, finesine[an]), |
| 7419 |
actor->z + 40 * FRACUNIT, actor, actor->target, |
| 7420 |
HEXEN_MT_ICEGUY_FX); |
| 7421 |
an = (actor->angle - ANG90) >> ANGLETOFINESHIFT; |
| 7422 |
P_SpawnMissileXYZ(actor->x + FixedMul(actor->radius >> 1, |
| 7423 |
finecosine[an]), |
| 7424 |
actor->y + FixedMul(actor->radius >> 1, finesine[an]), |
| 7425 |
actor->z + 40 * FRACUNIT, actor, actor->target, |
| 7426 |
HEXEN_MT_ICEGUY_FX); |
| 7427 |
S_StartMobjSound(actor, actor->info->attacksound); |
| 7428 |
} |
| 7429 |
|
| 7430 |
void A_IceGuyMissilePuff(mobj_t * actor) |
| 7431 |
{ |
| 7432 |
P_SpawnMobj(actor->x, actor->y, actor->z + 2 * FRACUNIT, HEXEN_MT_ICEFX_PUFF); |
| 7433 |
} |
| 7434 |
|
| 7435 |
void A_IceGuyDie(mobj_t * actor) |
| 7436 |
{ |
| 7437 |
actor->momx = 0; |
| 7438 |
actor->momy = 0; |
| 7439 |
actor->momz = 0; |
| 7440 |
actor->height <<= 2; |
| 7441 |
A_FreezeDeathChunks(actor); |
| 7442 |
} |
| 7443 |
|
| 7444 |
void A_IceGuyMissileExplode(mobj_t * actor) |
| 7445 |
{ |
| 7446 |
mobj_t *mo; |
| 7447 |
unsigned int i; |
| 7448 |
|
| 7449 |
for (i = 0; i < 8; i++) |
| 7450 |
{ |
| 7451 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_ICEGUY_FX2, i * ANG45, |
| 7452 |
-0.3 * FRACUNIT); |
| 7453 |
if (mo) |
| 7454 |
{ |
| 7455 |
P_SetTarget(&mo->target, actor->target); |
| 7456 |
} |
| 7457 |
} |
| 7458 |
} |
| 7459 |
|
| 7460 |
//============================================================================ |
| 7461 |
// |
| 7462 |
// Sorcerer stuff |
| 7463 |
// |
| 7464 |
// Sorcerer Variables |
| 7465 |
// special1 Angle of ball 1 (all others relative to that) |
| 7466 |
// special2 which ball to stop at in stop mode (HEXEN_MT_???) |
| 7467 |
// args[0] Denfense time |
| 7468 |
// args[1] Number of full rotations since stopping mode |
| 7469 |
// args[2] Target orbit speed for acceleration/deceleration |
| 7470 |
// args[3] Movement mode (see SORC_ macros) |
| 7471 |
// args[4] Current ball orbit speed |
| 7472 |
// Sorcerer Ball Variables |
| 7473 |
// special1 Previous angle of ball (for woosh) |
| 7474 |
// special2 Countdown of rapid fire (FX4) |
| 7475 |
// args[0] If set, don't play the bounce sound when bouncing |
| 7476 |
//============================================================================ |
| 7477 |
|
| 7478 |
#define SORCBALL_INITIAL_SPEED 7 |
| 7479 |
#define SORCBALL_TERMINAL_SPEED 25 |
| 7480 |
#define SORCBALL_SPEED_ROTATIONS 5 |
| 7481 |
#define SORC_DEFENSE_TIME 255 |
| 7482 |
#define SORC_DEFENSE_HEIGHT 45 |
| 7483 |
#define BOUNCE_TIME_UNIT (35/2) |
| 7484 |
#define SORCFX4_RAPIDFIRE_TIME (6*3) // 3 seconds |
| 7485 |
#define SORCFX4_SPREAD_ANGLE 20 |
| 7486 |
|
| 7487 |
#define SORC_DECELERATE 0 |
| 7488 |
#define SORC_ACCELERATE 1 |
| 7489 |
#define SORC_STOPPING 2 |
| 7490 |
#define SORC_FIRESPELL 3 |
| 7491 |
#define SORC_STOPPED 4 |
| 7492 |
#define SORC_NORMAL 5 |
| 7493 |
#define SORC_FIRING_SPELL 6 |
| 7494 |
|
| 7495 |
#define BALL1_ANGLEOFFSET 0 |
| 7496 |
#define BALL2_ANGLEOFFSET (ANGLE_MAX/3) |
| 7497 |
#define BALL3_ANGLEOFFSET ((ANGLE_MAX/3)*2) |
| 7498 |
|
| 7499 |
void A_SorcBallOrbit(mobj_t * actor); |
| 7500 |
void A_SorcSpinBalls(mobj_t * actor); |
| 7501 |
void A_SpeedBalls(mobj_t * actor); |
| 7502 |
void A_SlowBalls(mobj_t * actor); |
| 7503 |
void A_StopBalls(mobj_t * actor); |
| 7504 |
void A_AccelBalls(mobj_t * actor); |
| 7505 |
void A_DecelBalls(mobj_t * actor); |
| 7506 |
void A_SorcBossAttack(mobj_t * actor); |
| 7507 |
void A_SpawnFizzle(mobj_t * actor); |
| 7508 |
void A_CastSorcererSpell(mobj_t * actor); |
| 7509 |
void A_SorcUpdateBallAngle(mobj_t * actor); |
| 7510 |
void A_BounceCheck(mobj_t * actor); |
| 7511 |
void A_SorcFX1Seek(mobj_t * actor); |
| 7512 |
void A_SorcOffense1(mobj_t * actor); |
| 7513 |
void A_SorcOffense2(mobj_t * actor); |
| 7514 |
|
| 7515 |
void A_SorcSpinBalls(mobj_t * actor) |
| 7516 |
{ |
| 7517 |
mobj_t *mo; |
| 7518 |
fixed_t z; |
| 7519 |
|
| 7520 |
A_SlowBalls(actor); |
| 7521 |
actor->special_args[0] = 0; // Currently no defense |
| 7522 |
actor->special_args[3] = SORC_NORMAL; |
| 7523 |
actor->special_args[4] = SORCBALL_INITIAL_SPEED; // Initial orbit speed |
| 7524 |
actor->special1.i = ANG1; |
| 7525 |
z = actor->z - actor->floorclip + actor->info->height; |
| 7526 |
|
| 7527 |
mo = P_SpawnMobj(actor->x, actor->y, z, HEXEN_MT_SORCBALL1); |
| 7528 |
if (mo) |
| 7529 |
{ |
| 7530 |
P_SetTarget(&mo->target, actor); |
| 7531 |
mo->special2.i = SORCFX4_RAPIDFIRE_TIME; |
| 7532 |
} |
| 7533 |
mo = P_SpawnMobj(actor->x, actor->y, z, HEXEN_MT_SORCBALL2); |
| 7534 |
if (mo) |
| 7535 |
P_SetTarget(&mo->target, actor); |
| 7536 |
mo = P_SpawnMobj(actor->x, actor->y, z, HEXEN_MT_SORCBALL3); |
| 7537 |
if (mo) |
| 7538 |
P_SetTarget(&mo->target, actor); |
| 7539 |
} |
| 7540 |
|
| 7541 |
void A_SorcBallOrbit(mobj_t * actor) |
| 7542 |
{ |
| 7543 |
int x, y; |
| 7544 |
angle_t angle, baseangle; |
| 7545 |
int mode = actor->target->special_args[3]; |
| 7546 |
mobj_t *parent = (mobj_t *) actor->target; |
| 7547 |
int dist = parent->radius - (actor->radius << 1); |
| 7548 |
angle_t prevangle = actor->special1.i; |
| 7549 |
|
| 7550 |
if (actor->target->health <= 0) |
| 7551 |
P_SetMobjState(actor, actor->info->painstate); |
| 7552 |
|
| 7553 |
baseangle = (angle_t) parent->special1.i; |
| 7554 |
switch (actor->type) |
| 7555 |
{ |
| 7556 |
case HEXEN_MT_SORCBALL1: |
| 7557 |
angle = baseangle + BALL1_ANGLEOFFSET; |
| 7558 |
break; |
| 7559 |
case HEXEN_MT_SORCBALL2: |
| 7560 |
angle = baseangle + BALL2_ANGLEOFFSET; |
| 7561 |
break; |
| 7562 |
case HEXEN_MT_SORCBALL3: |
| 7563 |
angle = baseangle + BALL3_ANGLEOFFSET; |
| 7564 |
break; |
| 7565 |
default: |
| 7566 |
I_Error("corrupted sorcerer"); |
| 7567 |
return; |
| 7568 |
} |
| 7569 |
actor->angle = angle; |
| 7570 |
angle >>= ANGLETOFINESHIFT; |
| 7571 |
|
| 7572 |
switch (mode) |
| 7573 |
{ |
| 7574 |
case SORC_NORMAL: // Balls rotating normally |
| 7575 |
A_SorcUpdateBallAngle(actor); |
| 7576 |
break; |
| 7577 |
case SORC_DECELERATE: // Balls decelerating |
| 7578 |
A_DecelBalls(actor); |
| 7579 |
A_SorcUpdateBallAngle(actor); |
| 7580 |
break; |
| 7581 |
case SORC_ACCELERATE: // Balls accelerating |
| 7582 |
A_AccelBalls(actor); |
| 7583 |
A_SorcUpdateBallAngle(actor); |
| 7584 |
break; |
| 7585 |
case SORC_STOPPING: // Balls stopping |
| 7586 |
if ((parent->special2.i == actor->type) && |
| 7587 |
(parent->special_args[1] > SORCBALL_SPEED_ROTATIONS) && |
| 7588 |
(abs((int) angle - (int) (parent->angle >> ANGLETOFINESHIFT)) < |
| 7589 |
(30 << 5))) |
| 7590 |
{ |
| 7591 |
// Can stop now |
| 7592 |
actor->target->special_args[3] = SORC_FIRESPELL; |
| 7593 |
actor->target->special_args[4] = 0; |
| 7594 |
// Set angle so ball angle == sorcerer angle |
| 7595 |
switch (actor->type) |
| 7596 |
{ |
| 7597 |
case HEXEN_MT_SORCBALL1: |
| 7598 |
parent->special1.i = (int) (parent->angle - |
| 7599 |
BALL1_ANGLEOFFSET); |
| 7600 |
break; |
| 7601 |
case HEXEN_MT_SORCBALL2: |
| 7602 |
parent->special1.i = (int) (parent->angle - |
| 7603 |
BALL2_ANGLEOFFSET); |
| 7604 |
break; |
| 7605 |
case HEXEN_MT_SORCBALL3: |
| 7606 |
parent->special1.i = (int) (parent->angle - |
| 7607 |
BALL3_ANGLEOFFSET); |
| 7608 |
break; |
| 7609 |
default: |
| 7610 |
break; |
| 7611 |
} |
| 7612 |
} |
| 7613 |
else |
| 7614 |
{ |
| 7615 |
A_SorcUpdateBallAngle(actor); |
| 7616 |
} |
| 7617 |
break; |
| 7618 |
case SORC_FIRESPELL: // Casting spell |
| 7619 |
if (parent->special2.i == actor->type) |
| 7620 |
{ |
| 7621 |
// Put sorcerer into special throw spell anim |
| 7622 |
if (parent->health > 0) |
| 7623 |
P_SetMobjStateNF(parent, HEXEN_S_SORC_ATTACK1); |
| 7624 |
|
| 7625 |
if (actor->type == HEXEN_MT_SORCBALL1 && P_Random(pr_hexen) < 200) |
| 7626 |
{ |
| 7627 |
S_StartVoidSound(hexen_sfx_sorcerer_spellcast); |
| 7628 |
actor->special2.i = SORCFX4_RAPIDFIRE_TIME; |
| 7629 |
actor->special_args[4] = 128; |
| 7630 |
parent->special_args[3] = SORC_FIRING_SPELL; |
| 7631 |
} |
| 7632 |
else |
| 7633 |
{ |
| 7634 |
A_CastSorcererSpell(actor); |
| 7635 |
parent->special_args[3] = SORC_STOPPED; |
| 7636 |
} |
| 7637 |
} |
| 7638 |
break; |
| 7639 |
case SORC_FIRING_SPELL: |
| 7640 |
if (parent->special2.i == actor->type) |
| 7641 |
{ |
| 7642 |
if (actor->special2.i-- <= 0) |
| 7643 |
{ |
| 7644 |
// Done rapid firing |
| 7645 |
parent->special_args[3] = SORC_STOPPED; |
| 7646 |
// Back to orbit balls |
| 7647 |
if (parent->health > 0) |
| 7648 |
P_SetMobjStateNF(parent, HEXEN_S_SORC_ATTACK4); |
| 7649 |
} |
| 7650 |
else |
| 7651 |
{ |
| 7652 |
// Do rapid fire spell |
| 7653 |
A_SorcOffense2(actor); |
| 7654 |
} |
| 7655 |
} |
| 7656 |
break; |
| 7657 |
case SORC_STOPPED: // Balls stopped |
| 7658 |
default: |
| 7659 |
break; |
| 7660 |
} |
| 7661 |
|
| 7662 |
if ((angle < prevangle) && (parent->special_args[4] == SORCBALL_TERMINAL_SPEED)) |
| 7663 |
{ |
| 7664 |
parent->special_args[1]++; // Bump rotation counter |
| 7665 |
// Completed full rotation - make woosh sound |
| 7666 |
S_StartMobjSound(actor, hexen_sfx_sorcerer_ballwoosh); |
| 7667 |
} |
| 7668 |
actor->special1.i = angle; // Set previous angle |
| 7669 |
x = parent->x + FixedMul(dist, finecosine[angle]); |
| 7670 |
y = parent->y + FixedMul(dist, finesine[angle]); |
| 7671 |
actor->x = x; |
| 7672 |
actor->y = y; |
| 7673 |
actor->z = parent->z - parent->floorclip + parent->info->height; |
| 7674 |
} |
| 7675 |
|
| 7676 |
void A_SpeedBalls(mobj_t * actor) |
| 7677 |
{ |
| 7678 |
actor->special_args[3] = SORC_ACCELERATE; // speed mode |
| 7679 |
actor->special_args[2] = SORCBALL_TERMINAL_SPEED; // target speed |
| 7680 |
} |
| 7681 |
|
| 7682 |
void A_SlowBalls(mobj_t * actor) |
| 7683 |
{ |
| 7684 |
actor->special_args[3] = SORC_DECELERATE; // slow mode |
| 7685 |
actor->special_args[2] = SORCBALL_INITIAL_SPEED; // target speed |
| 7686 |
} |
| 7687 |
|
| 7688 |
void A_StopBalls(mobj_t * actor) |
| 7689 |
{ |
| 7690 |
int chance = P_Random(pr_hexen); |
| 7691 |
actor->special_args[3] = SORC_STOPPING; // stopping mode |
| 7692 |
actor->special_args[1] = 0; // Reset rotation counter |
| 7693 |
|
| 7694 |
if ((actor->special_args[0] <= 0) && (chance < 200)) |
| 7695 |
{ |
| 7696 |
actor->special2.i = HEXEN_MT_SORCBALL2; // Blue |
| 7697 |
} |
| 7698 |
else if ((actor->health < (P_MobjSpawnHealth(actor) >> 1)) && |
| 7699 |
(chance < 200)) |
| 7700 |
{ |
| 7701 |
actor->special2.i = HEXEN_MT_SORCBALL3; // Green |
| 7702 |
} |
| 7703 |
else |
| 7704 |
{ |
| 7705 |
actor->special2.i = HEXEN_MT_SORCBALL1; // Yellow |
| 7706 |
} |
| 7707 |
} |
| 7708 |
|
| 7709 |
void A_AccelBalls(mobj_t * actor) |
| 7710 |
{ |
| 7711 |
mobj_t *sorc = actor->target; |
| 7712 |
|
| 7713 |
if (sorc->special_args[4] < sorc->special_args[2]) |
| 7714 |
{ |
| 7715 |
sorc->special_args[4]++; |
| 7716 |
} |
| 7717 |
else |
| 7718 |
{ |
| 7719 |
sorc->special_args[3] = SORC_NORMAL; |
| 7720 |
if (sorc->special_args[4] >= SORCBALL_TERMINAL_SPEED) |
| 7721 |
{ |
| 7722 |
// Reached terminal velocity - stop balls |
| 7723 |
A_StopBalls(sorc); |
| 7724 |
} |
| 7725 |
} |
| 7726 |
} |
| 7727 |
|
| 7728 |
void A_DecelBalls(mobj_t * actor) |
| 7729 |
{ |
| 7730 |
mobj_t *sorc = actor->target; |
| 7731 |
|
| 7732 |
if (sorc->special_args[4] > sorc->special_args[2]) |
| 7733 |
{ |
| 7734 |
sorc->special_args[4]--; |
| 7735 |
} |
| 7736 |
else |
| 7737 |
{ |
| 7738 |
sorc->special_args[3] = SORC_NORMAL; |
| 7739 |
} |
| 7740 |
} |
| 7741 |
|
| 7742 |
void A_SorcUpdateBallAngle(mobj_t * actor) |
| 7743 |
{ |
| 7744 |
if (actor->type == HEXEN_MT_SORCBALL1) |
| 7745 |
{ |
| 7746 |
actor->target->special1.i += ANG1 * actor->target->special_args[4]; |
| 7747 |
} |
| 7748 |
} |
| 7749 |
|
| 7750 |
void A_CastSorcererSpell(mobj_t * actor) |
| 7751 |
{ |
| 7752 |
mobj_t *mo; |
| 7753 |
int spell = actor->type; |
| 7754 |
angle_t ang1, ang2; |
| 7755 |
fixed_t z; |
| 7756 |
mobj_t *parent = actor->target; |
| 7757 |
|
| 7758 |
S_StartVoidSound(hexen_sfx_sorcerer_spellcast); |
| 7759 |
|
| 7760 |
// Put sorcerer into throw spell animation |
| 7761 |
if (parent->health > 0) |
| 7762 |
P_SetMobjStateNF(parent, HEXEN_S_SORC_ATTACK4); |
| 7763 |
|
| 7764 |
switch (spell) |
| 7765 |
{ |
| 7766 |
case HEXEN_MT_SORCBALL1: // Offensive |
| 7767 |
A_SorcOffense1(actor); |
| 7768 |
break; |
| 7769 |
case HEXEN_MT_SORCBALL2: // Defensive |
| 7770 |
z = parent->z - parent->floorclip + |
| 7771 |
SORC_DEFENSE_HEIGHT * FRACUNIT; |
| 7772 |
mo = P_SpawnMobj(actor->x, actor->y, z, HEXEN_MT_SORCFX2); |
| 7773 |
parent->flags2 |= MF2_REFLECTIVE | MF2_INVULNERABLE; |
| 7774 |
parent->special_args[0] = SORC_DEFENSE_TIME; |
| 7775 |
if (mo) |
| 7776 |
P_SetTarget(&mo->target, parent); |
| 7777 |
break; |
| 7778 |
case HEXEN_MT_SORCBALL3: // Reinforcements |
| 7779 |
ang1 = actor->angle - ANG45; |
| 7780 |
ang2 = actor->angle + ANG45; |
| 7781 |
if (actor->health < (P_MobjSpawnHealth(actor) / 3)) |
| 7782 |
{ // Spawn 2 at a time |
| 7783 |
mo = P_SpawnMissileAngle(parent, HEXEN_MT_SORCFX3, ang1, |
| 7784 |
4 * FRACUNIT); |
| 7785 |
if (mo) |
| 7786 |
P_SetTarget(&mo->target, parent); |
| 7787 |
mo = P_SpawnMissileAngle(parent, HEXEN_MT_SORCFX3, ang2, |
| 7788 |
4 * FRACUNIT); |
| 7789 |
if (mo) |
| 7790 |
P_SetTarget(&mo->target, parent); |
| 7791 |
} |
| 7792 |
else |
| 7793 |
{ |
| 7794 |
if (P_Random(pr_hexen) < 128) |
| 7795 |
ang1 = ang2; |
| 7796 |
mo = P_SpawnMissileAngle(parent, HEXEN_MT_SORCFX3, ang1, |
| 7797 |
4 * FRACUNIT); |
| 7798 |
if (mo) |
| 7799 |
P_SetTarget(&mo->target, parent); |
| 7800 |
} |
| 7801 |
break; |
| 7802 |
default: |
| 7803 |
break; |
| 7804 |
} |
| 7805 |
} |
| 7806 |
|
| 7807 |
void A_SorcOffense1(mobj_t * actor) |
| 7808 |
{ |
| 7809 |
mobj_t *mo; |
| 7810 |
angle_t ang1, ang2; |
| 7811 |
mobj_t *parent = (mobj_t *) actor->target; |
| 7812 |
|
| 7813 |
ang1 = actor->angle + ANG1 * 70; |
| 7814 |
ang2 = actor->angle - ANG1 * 70; |
| 7815 |
mo = P_SpawnMissileAngle(parent, HEXEN_MT_SORCFX1, ang1, 0); |
| 7816 |
if (mo) |
| 7817 |
{ |
| 7818 |
P_SetTarget(&mo->target, parent); |
| 7819 |
P_SetTarget(&mo->special1.m, parent->target); |
| 7820 |
mo->special_args[4] = BOUNCE_TIME_UNIT; |
| 7821 |
mo->special_args[3] = 15; // Bounce time in seconds |
| 7822 |
} |
| 7823 |
mo = P_SpawnMissileAngle(parent, HEXEN_MT_SORCFX1, ang2, 0); |
| 7824 |
if (mo) |
| 7825 |
{ |
| 7826 |
P_SetTarget(&mo->target, parent); |
| 7827 |
P_SetTarget(&mo->special1.m, parent->target); |
| 7828 |
mo->special_args[4] = BOUNCE_TIME_UNIT; |
| 7829 |
mo->special_args[3] = 15; // Bounce time in seconds |
| 7830 |
} |
| 7831 |
} |
| 7832 |
|
| 7833 |
void A_SorcOffense2(mobj_t * actor) |
| 7834 |
{ |
| 7835 |
angle_t ang1; |
| 7836 |
mobj_t *mo; |
| 7837 |
int delta, index; |
| 7838 |
mobj_t *parent = actor->target; |
| 7839 |
mobj_t *dest = parent->target; |
| 7840 |
int dist; |
| 7841 |
|
| 7842 |
index = actor->special_args[4] << 5; |
| 7843 |
actor->special_args[4] += 15; |
| 7844 |
actor->special_args[4] &= 0xff; |
| 7845 |
delta = (finesine[index]) * SORCFX4_SPREAD_ANGLE; |
| 7846 |
delta = (delta >> FRACBITS) * ANG1; |
| 7847 |
ang1 = actor->angle + delta; |
| 7848 |
mo = P_SpawnMissileAngle(parent, HEXEN_MT_SORCFX4, ang1, 0); |
| 7849 |
if (mo) |
| 7850 |
{ |
| 7851 |
mo->special2.i = 35 * 5 / 2; // 5 seconds |
| 7852 |
dist = P_AproxDistance(dest->x - mo->x, dest->y - mo->y); |
| 7853 |
dist = dist / mo->info->speed; |
| 7854 |
if (dist < 1) |
| 7855 |
dist = 1; |
| 7856 |
mo->momz = (dest->z - mo->z) / dist; |
| 7857 |
} |
| 7858 |
} |
| 7859 |
|
| 7860 |
void A_SorcBossAttack(mobj_t * actor) |
| 7861 |
{ |
| 7862 |
actor->special_args[3] = SORC_ACCELERATE; |
| 7863 |
actor->special_args[2] = SORCBALL_INITIAL_SPEED; |
| 7864 |
} |
| 7865 |
|
| 7866 |
void A_SpawnFizzle(mobj_t * actor) |
| 7867 |
{ |
| 7868 |
fixed_t x, y, z; |
| 7869 |
fixed_t dist = 5 * FRACUNIT; |
| 7870 |
angle_t angle = actor->angle >> ANGLETOFINESHIFT; |
| 7871 |
fixed_t speed = actor->info->speed; |
| 7872 |
angle_t rangle; |
| 7873 |
mobj_t *mo; |
| 7874 |
int ix; |
| 7875 |
|
| 7876 |
x = actor->x + FixedMul(dist, finecosine[angle]); |
| 7877 |
y = actor->y + FixedMul(dist, finesine[angle]); |
| 7878 |
z = actor->z - actor->floorclip + (actor->height >> 1); |
| 7879 |
for (ix = 0; ix < 5; ix++) |
| 7880 |
{ |
| 7881 |
mo = P_SpawnMobj(x, y, z, HEXEN_MT_SORCSPARK1); |
| 7882 |
if (mo) |
| 7883 |
{ |
| 7884 |
rangle = angle + ((P_Random(pr_hexen) % 5) << 1); |
| 7885 |
mo->momx = FixedMul(P_Random(pr_hexen) % speed, finecosine[rangle]); |
| 7886 |
mo->momy = FixedMul(P_Random(pr_hexen) % speed, finesine[rangle]); |
| 7887 |
mo->momz = FRACUNIT * 2; |
| 7888 |
} |
| 7889 |
} |
| 7890 |
} |
| 7891 |
|
| 7892 |
//============================================================================ |
| 7893 |
// Yellow spell - offense |
| 7894 |
//============================================================================ |
| 7895 |
|
| 7896 |
void A_SorcFX1Seek(mobj_t * actor) |
| 7897 |
{ |
| 7898 |
A_BounceCheck(actor); |
| 7899 |
P_SeekerMissile(actor, &actor->special1.m, ANG1 * 2, ANG1 * 6, false); |
| 7900 |
} |
| 7901 |
|
| 7902 |
//============================================================================ |
| 7903 |
// Blue spell - defense |
| 7904 |
//============================================================================ |
| 7905 |
// |
| 7906 |
// FX2 Variables |
| 7907 |
// special1 current angle |
| 7908 |
// special2 |
| 7909 |
// args[0] 0 = CW, 1 = CCW |
| 7910 |
// args[1] |
| 7911 |
//============================================================================ |
| 7912 |
|
| 7913 |
void A_SorcFX2Split(mobj_t * actor) |
| 7914 |
{ |
| 7915 |
mobj_t *mo; |
| 7916 |
|
| 7917 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_SORCFX2); |
| 7918 |
if (mo) |
| 7919 |
{ |
| 7920 |
P_SetTarget(&mo->target, actor->target); |
| 7921 |
mo->special_args[0] = 0; // CW |
| 7922 |
mo->special1.i = actor->angle; // Set angle |
| 7923 |
P_SetMobjStateNF(mo, HEXEN_S_SORCFX2_ORBIT1); |
| 7924 |
} |
| 7925 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_SORCFX2); |
| 7926 |
if (mo) |
| 7927 |
{ |
| 7928 |
P_SetTarget(&mo->target, actor->target); |
| 7929 |
mo->special_args[0] = 1; // CCW |
| 7930 |
mo->special1.i = actor->angle; // Set angle |
| 7931 |
P_SetMobjStateNF(mo, HEXEN_S_SORCFX2_ORBIT1); |
| 7932 |
} |
| 7933 |
P_SetMobjStateNF(actor, HEXEN_S_NULL); |
| 7934 |
} |
| 7935 |
|
| 7936 |
void A_SorcFX2Orbit(mobj_t * actor) |
| 7937 |
{ |
| 7938 |
angle_t angle; |
| 7939 |
fixed_t x, y, z; |
| 7940 |
mobj_t *parent = actor->target; |
| 7941 |
fixed_t dist = parent->info->radius; |
| 7942 |
|
| 7943 |
if ((parent->health <= 0) || // Sorcerer is dead |
| 7944 |
(!parent->special_args[0])) // Time expired |
| 7945 |
{ |
| 7946 |
P_SetMobjStateNF(actor, actor->info->deathstate); |
| 7947 |
parent->special_args[0] = 0; |
| 7948 |
parent->flags2 &= ~MF2_REFLECTIVE; |
| 7949 |
parent->flags2 &= ~MF2_INVULNERABLE; |
| 7950 |
} |
| 7951 |
|
| 7952 |
if (actor->special_args[0] && (parent->special_args[0]-- <= 0)) // Time expired |
| 7953 |
{ |
| 7954 |
P_SetMobjStateNF(actor, actor->info->deathstate); |
| 7955 |
parent->special_args[0] = 0; |
| 7956 |
parent->flags2 &= ~MF2_REFLECTIVE; |
| 7957 |
} |
| 7958 |
|
| 7959 |
// Move to new position based on angle |
| 7960 |
if (actor->special_args[0]) // Counter clock-wise |
| 7961 |
{ |
| 7962 |
actor->special1.i += ANG1 * 10; |
| 7963 |
angle = ((angle_t) actor->special1.i) >> ANGLETOFINESHIFT; |
| 7964 |
x = parent->x + FixedMul(dist, finecosine[angle]); |
| 7965 |
y = parent->y + FixedMul(dist, finesine[angle]); |
| 7966 |
z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT * FRACUNIT; |
| 7967 |
z += FixedMul(15 * FRACUNIT, finecosine[angle]); |
| 7968 |
// Spawn trailer |
| 7969 |
P_SpawnMobj(x, y, z, HEXEN_MT_SORCFX2_T1); |
| 7970 |
} |
| 7971 |
else // Clock wise |
| 7972 |
{ |
| 7973 |
actor->special1.i -= ANG1 * 10; |
| 7974 |
angle = ((angle_t) actor->special1.i) >> ANGLETOFINESHIFT; |
| 7975 |
x = parent->x + FixedMul(dist, finecosine[angle]); |
| 7976 |
y = parent->y + FixedMul(dist, finesine[angle]); |
| 7977 |
z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT * FRACUNIT; |
| 7978 |
z += FixedMul(20 * FRACUNIT, finesine[angle]); |
| 7979 |
// Spawn trailer |
| 7980 |
P_SpawnMobj(x, y, z, HEXEN_MT_SORCFX2_T1); |
| 7981 |
} |
| 7982 |
|
| 7983 |
actor->x = x; |
| 7984 |
actor->y = y; |
| 7985 |
actor->z = z; |
| 7986 |
} |
| 7987 |
|
| 7988 |
//============================================================================ |
| 7989 |
// Green spell - spawn bishops |
| 7990 |
//============================================================================ |
| 7991 |
|
| 7992 |
void A_SpawnBishop(mobj_t * actor) |
| 7993 |
{ |
| 7994 |
mobj_t *mo; |
| 7995 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_BISHOP); |
| 7996 |
if (mo) |
| 7997 |
{ |
| 7998 |
if (!P_TestMobjLocation(mo)) |
| 7999 |
{ |
| 8000 |
P_SetMobjState(mo, HEXEN_S_NULL); |
| 8001 |
} |
| 8002 |
} |
| 8003 |
P_SetMobjState(actor, HEXEN_S_NULL); |
| 8004 |
} |
| 8005 |
|
| 8006 |
void A_SmokePuffExit(mobj_t * actor) |
| 8007 |
{ |
| 8008 |
P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_MNTRSMOKEEXIT); |
| 8009 |
} |
| 8010 |
|
| 8011 |
void A_SorcererBishopEntry(mobj_t * actor) |
| 8012 |
{ |
| 8013 |
P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_SORCFX3_EXPLOSION); |
| 8014 |
S_StartMobjSound(actor, actor->info->seesound); |
| 8015 |
} |
| 8016 |
|
| 8017 |
void A_SorcFX4Check(mobj_t * actor) |
| 8018 |
{ |
| 8019 |
if (actor->special2.i-- <= 0) |
| 8020 |
{ |
| 8021 |
P_SetMobjStateNF(actor, actor->info->deathstate); |
| 8022 |
} |
| 8023 |
} |
| 8024 |
|
| 8025 |
void A_SorcBallPop(mobj_t * actor) |
| 8026 |
{ |
| 8027 |
S_StartVoidSound(hexen_sfx_sorcerer_ballpop); |
| 8028 |
actor->flags &= ~MF_NOGRAVITY; |
| 8029 |
actor->flags2 |= MF2_LOGRAV; |
| 8030 |
actor->momx = ((P_Random(pr_hexen) % 10) - 5) << FRACBITS; |
| 8031 |
actor->momy = ((P_Random(pr_hexen) % 10) - 5) << FRACBITS; |
| 8032 |
actor->momz = (2 + (P_Random(pr_hexen) % 3)) << FRACBITS; |
| 8033 |
actor->special2.i = 4 * FRACUNIT; // Initial bounce factor |
| 8034 |
actor->special_args[4] = BOUNCE_TIME_UNIT; // Bounce time unit |
| 8035 |
actor->special_args[3] = 5; // Bounce time in seconds |
| 8036 |
} |
| 8037 |
|
| 8038 |
void A_BounceCheck(mobj_t * actor) |
| 8039 |
{ |
| 8040 |
if (actor->special_args[4]-- <= 0) |
| 8041 |
{ |
| 8042 |
if (actor->special_args[3]-- <= 0) |
| 8043 |
{ |
| 8044 |
P_SetMobjState(actor, actor->info->deathstate); |
| 8045 |
switch (actor->type) |
| 8046 |
{ |
| 8047 |
case HEXEN_MT_SORCBALL1: |
| 8048 |
case HEXEN_MT_SORCBALL2: |
| 8049 |
case HEXEN_MT_SORCBALL3: |
| 8050 |
S_StartVoidSound(hexen_sfx_sorcerer_bigballexplode); |
| 8051 |
break; |
| 8052 |
case HEXEN_MT_SORCFX1: |
| 8053 |
S_StartVoidSound(hexen_sfx_sorcerer_headscream); |
| 8054 |
break; |
| 8055 |
default: |
| 8056 |
break; |
| 8057 |
} |
| 8058 |
} |
| 8059 |
else |
| 8060 |
{ |
| 8061 |
actor->special_args[4] = BOUNCE_TIME_UNIT; |
| 8062 |
} |
| 8063 |
} |
| 8064 |
} |
| 8065 |
|
| 8066 |
#define CLASS_BOSS_STRAFE_RANGE 64*10*FRACUNIT |
| 8067 |
|
| 8068 |
void A_FastChase(mobj_t * actor) |
| 8069 |
{ |
| 8070 |
int delta; |
| 8071 |
fixed_t dist; |
| 8072 |
angle_t ang; |
| 8073 |
mobj_t *target; |
| 8074 |
|
| 8075 |
if (actor->reactiontime) |
| 8076 |
{ |
| 8077 |
actor->reactiontime--; |
| 8078 |
} |
| 8079 |
|
| 8080 |
// Modify target threshold |
| 8081 |
if (actor->threshold) |
| 8082 |
{ |
| 8083 |
actor->threshold--; |
| 8084 |
} |
| 8085 |
|
| 8086 |
if (skill_info.flags & SI_FAST_MONSTERS) |
| 8087 |
{ // Monsters move faster in nightmare mode |
| 8088 |
actor->tics -= actor->tics / 2; |
| 8089 |
if (actor->tics < 3) |
| 8090 |
{ |
| 8091 |
actor->tics = 3; |
| 8092 |
} |
| 8093 |
} |
| 8094 |
|
| 8095 |
// |
| 8096 |
// turn towards movement direction if not there yet |
| 8097 |
// |
| 8098 |
if (actor->movedir < 8) |
| 8099 |
{ |
| 8100 |
actor->angle &= (7 << 29); |
| 8101 |
delta = actor->angle - (actor->movedir << 29); |
| 8102 |
if (delta > 0) |
| 8103 |
{ |
| 8104 |
actor->angle -= ANG90 / 2; |
| 8105 |
} |
| 8106 |
else if (delta < 0) |
| 8107 |
{ |
| 8108 |
actor->angle += ANG90 / 2; |
| 8109 |
} |
| 8110 |
} |
| 8111 |
|
| 8112 |
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) |
| 8113 |
{ // look for a new target |
| 8114 |
if (P_LookForPlayers(actor, true)) |
| 8115 |
{ // got a new target |
| 8116 |
return; |
| 8117 |
} |
| 8118 |
P_SetMobjState(actor, actor->info->spawnstate); |
| 8119 |
return; |
| 8120 |
} |
| 8121 |
|
| 8122 |
// |
| 8123 |
// don't attack twice in a row |
| 8124 |
// |
| 8125 |
if (actor->flags & MF_JUSTATTACKED) |
| 8126 |
{ |
| 8127 |
actor->flags &= ~MF_JUSTATTACKED; |
| 8128 |
if (!(skill_info.flags & SI_FAST_MONSTERS)) |
| 8129 |
P_NewChaseDir(actor); |
| 8130 |
return; |
| 8131 |
} |
| 8132 |
|
| 8133 |
// Strafe |
| 8134 |
if (actor->special2.i > 0) |
| 8135 |
{ |
| 8136 |
actor->special2.i--; |
| 8137 |
} |
| 8138 |
else |
| 8139 |
{ |
| 8140 |
target = actor->target; |
| 8141 |
actor->special2.i = 0; |
| 8142 |
actor->momx = actor->momy = 0; |
| 8143 |
dist = P_AproxDistance(actor->x - target->x, actor->y - target->y); |
| 8144 |
if (dist < CLASS_BOSS_STRAFE_RANGE) |
| 8145 |
{ |
| 8146 |
if (P_Random(pr_hexen) < 100) |
| 8147 |
{ |
| 8148 |
ang = R_PointToAngle2(actor->x, actor->y, |
| 8149 |
target->x, target->y); |
| 8150 |
if (P_Random(pr_hexen) < 128) |
| 8151 |
ang += ANG90; |
| 8152 |
else |
| 8153 |
ang -= ANG90; |
| 8154 |
ang >>= ANGLETOFINESHIFT; |
| 8155 |
actor->momx = FixedMul(13 * FRACUNIT, finecosine[ang]); |
| 8156 |
actor->momy = FixedMul(13 * FRACUNIT, finesine[ang]); |
| 8157 |
actor->special2.i = 3; // strafe time |
| 8158 |
} |
| 8159 |
} |
| 8160 |
} |
| 8161 |
|
| 8162 |
// |
| 8163 |
// check for missile attack |
| 8164 |
// |
| 8165 |
if (actor->info->missilestate) |
| 8166 |
{ |
| 8167 |
if (!(skill_info.flags & SI_FAST_MONSTERS) && actor->movecount) |
| 8168 |
goto nomissile; |
| 8169 |
if (!P_CheckMissileRange(actor)) |
| 8170 |
goto nomissile; |
| 8171 |
P_SetMobjState(actor, actor->info->missilestate); |
| 8172 |
actor->flags |= MF_JUSTATTACKED; |
| 8173 |
return; |
| 8174 |
} |
| 8175 |
nomissile: |
| 8176 |
|
| 8177 |
// |
| 8178 |
// possibly choose another target |
| 8179 |
// |
| 8180 |
if (netgame && !actor->threshold && !P_CheckSight(actor, actor->target)) |
| 8181 |
{ |
| 8182 |
if (P_LookForPlayers(actor, true)) |
| 8183 |
return; // got a new target |
| 8184 |
} |
| 8185 |
|
| 8186 |
// |
| 8187 |
// chase towards player |
| 8188 |
// |
| 8189 |
if (!actor->special2.i) |
| 8190 |
{ |
| 8191 |
if (--actor->movecount < 0 || !P_Move(actor, false)) |
| 8192 |
{ |
| 8193 |
P_NewChaseDir(actor); |
| 8194 |
} |
| 8195 |
} |
| 8196 |
} |
| 8197 |
|
| 8198 |
void A_FighterAttack(mobj_t * actor) |
| 8199 |
{ |
| 8200 |
extern void A_FSwordAttack2(mobj_t * actor); |
| 8201 |
|
| 8202 |
if (!actor->target) |
| 8203 |
return; |
| 8204 |
A_FSwordAttack2(actor); |
| 8205 |
} |
| 8206 |
|
| 8207 |
void A_ClericAttack(mobj_t * actor) |
| 8208 |
{ |
| 8209 |
extern void A_CHolyAttack3(mobj_t * actor); |
| 8210 |
|
| 8211 |
if (!actor->target) |
| 8212 |
return; |
| 8213 |
A_CHolyAttack3(actor); |
| 8214 |
} |
| 8215 |
|
| 8216 |
void A_MageAttack(mobj_t * actor) |
| 8217 |
{ |
| 8218 |
extern void A_MStaffAttack2(mobj_t * actor); |
| 8219 |
|
| 8220 |
if (!actor->target) |
| 8221 |
return; |
| 8222 |
A_MStaffAttack2(actor); |
| 8223 |
} |
| 8224 |
|
| 8225 |
void A_ClassBossHealth(mobj_t * actor) |
| 8226 |
{ |
| 8227 |
if (netgame && !deathmatch) // co-op only |
| 8228 |
{ |
| 8229 |
if (!actor->special1.i) |
| 8230 |
{ |
| 8231 |
actor->health *= 5; |
| 8232 |
actor->special1.i = true; // has been initialized |
| 8233 |
} |
| 8234 |
} |
| 8235 |
} |
| 8236 |
|
| 8237 |
void A_CheckFloor(mobj_t * actor) |
| 8238 |
{ |
| 8239 |
if (actor->z <= actor->floorz) |
| 8240 |
{ |
| 8241 |
actor->z = actor->floorz; |
| 8242 |
actor->flags2 &= ~MF2_LOGRAV; |
| 8243 |
P_SetMobjState(actor, actor->info->deathstate); |
| 8244 |
} |
| 8245 |
} |
| 8246 |
|
| 8247 |
//=========================================================================== |
| 8248 |
// Korax Variables |
| 8249 |
// special1 last teleport destination |
| 8250 |
// special2 set if "below half" script not yet run |
| 8251 |
// |
| 8252 |
// Korax Scripts (reserved) |
| 8253 |
// 249 Tell scripts that we are below half health |
| 8254 |
// 250-254 Control scripts |
| 8255 |
// 255 Death script |
| 8256 |
// |
| 8257 |
// Korax TIDs (reserved) |
| 8258 |
// 245 Reserved for Korax himself |
| 8259 |
// 248 Initial teleport destination |
| 8260 |
// 249 Teleport destination |
| 8261 |
// 250-254 For use in respective control scripts |
| 8262 |
// 255 For use in death script (spawn spots) |
| 8263 |
//=========================================================================== |
| 8264 |
#define KORAX_SPIRIT_LIFETIME (5*(35/5)) // 5 seconds |
| 8265 |
#define KORAX_COMMAND_HEIGHT (120*FRACUNIT) |
| 8266 |
#define KORAX_COMMAND_OFFSET (27*FRACUNIT) |
| 8267 |
|
| 8268 |
void KoraxFire1(mobj_t * actor, int type); |
| 8269 |
void KoraxFire2(mobj_t * actor, int type); |
| 8270 |
void KoraxFire3(mobj_t * actor, int type); |
| 8271 |
void KoraxFire4(mobj_t * actor, int type); |
| 8272 |
void KoraxFire5(mobj_t * actor, int type); |
| 8273 |
void KoraxFire6(mobj_t * actor, int type); |
| 8274 |
void KSpiritInit(mobj_t * spirit, mobj_t * korax); |
| 8275 |
|
| 8276 |
#define KORAX_TID (245) |
| 8277 |
#define KORAX_FIRST_TELEPORT_TID (248) |
| 8278 |
#define KORAX_TELEPORT_TID (249) |
| 8279 |
|
| 8280 |
void A_KoraxChase(mobj_t * actor) |
| 8281 |
{ |
| 8282 |
mobj_t *spot; |
| 8283 |
int lastfound; |
| 8284 |
byte args[3] = {0, 0, 0}; |
| 8285 |
|
| 8286 |
if ((!actor->special2.i) && |
| 8287 |
(actor->health <= (P_MobjSpawnHealth(actor) / 2))) |
| 8288 |
{ |
| 8289 |
lastfound = 0; |
| 8290 |
spot = P_FindMobjFromTID(KORAX_FIRST_TELEPORT_TID, &lastfound); |
| 8291 |
if (spot) |
| 8292 |
{ |
| 8293 |
P_Teleport(actor, spot->x, spot->y, spot->angle, true); |
| 8294 |
} |
| 8295 |
|
| 8296 |
CheckACSPresent(249); |
| 8297 |
P_StartACS(249, 0, args, actor, NULL, 0); |
| 8298 |
actor->special2.i = 1; // Don't run again |
| 8299 |
|
| 8300 |
return; |
| 8301 |
} |
| 8302 |
|
| 8303 |
if (!actor->target) |
| 8304 |
return; |
| 8305 |
if (P_Random(pr_hexen) < 30) |
| 8306 |
{ |
| 8307 |
P_SetMobjState(actor, actor->info->missilestate); |
| 8308 |
} |
| 8309 |
else if (P_Random(pr_hexen) < 30) |
| 8310 |
{ |
| 8311 |
S_StartVoidSound(hexen_sfx_korax_active); |
| 8312 |
} |
| 8313 |
|
| 8314 |
// Teleport away |
| 8315 |
if (actor->health < (P_MobjSpawnHealth(actor) >> 1)) |
| 8316 |
{ |
| 8317 |
if (P_Random(pr_hexen) < 10) |
| 8318 |
{ |
| 8319 |
lastfound = actor->special1.i; |
| 8320 |
spot = P_FindMobjFromTID(KORAX_TELEPORT_TID, &lastfound); |
| 8321 |
actor->special1.i = lastfound; |
| 8322 |
if (spot) |
| 8323 |
{ |
| 8324 |
P_Teleport(actor, spot->x, spot->y, spot->angle, true); |
| 8325 |
} |
| 8326 |
} |
| 8327 |
} |
| 8328 |
} |
| 8329 |
|
| 8330 |
void A_KoraxStep(mobj_t * actor) |
| 8331 |
{ |
| 8332 |
A_Chase(actor); |
| 8333 |
} |
| 8334 |
|
| 8335 |
void A_KoraxStep2(mobj_t * actor) |
| 8336 |
{ |
| 8337 |
S_StartVoidSound(hexen_sfx_korax_step); |
| 8338 |
A_Chase(actor); |
| 8339 |
} |
| 8340 |
|
| 8341 |
void A_KoraxBonePop(mobj_t * actor) |
| 8342 |
{ |
| 8343 |
mobj_t *mo; |
| 8344 |
byte args[5]; |
| 8345 |
|
| 8346 |
args[0] = args[1] = args[2] = args[3] = args[4] = 0; |
| 8347 |
|
| 8348 |
// Spawn 6 spirits equalangularly |
| 8349 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_KORAX_SPIRIT1, ANG60 * 0, |
| 8350 |
5 * FRACUNIT); |
| 8351 |
if (mo) |
| 8352 |
KSpiritInit(mo, actor); |
| 8353 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_KORAX_SPIRIT2, ANG60 * 1, |
| 8354 |
5 * FRACUNIT); |
| 8355 |
if (mo) |
| 8356 |
KSpiritInit(mo, actor); |
| 8357 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_KORAX_SPIRIT3, ANG60 * 2, |
| 8358 |
5 * FRACUNIT); |
| 8359 |
if (mo) |
| 8360 |
KSpiritInit(mo, actor); |
| 8361 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_KORAX_SPIRIT4, ANG60 * 3, |
| 8362 |
5 * FRACUNIT); |
| 8363 |
if (mo) |
| 8364 |
KSpiritInit(mo, actor); |
| 8365 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_KORAX_SPIRIT5, ANG60 * 4, |
| 8366 |
5 * FRACUNIT); |
| 8367 |
if (mo) |
| 8368 |
KSpiritInit(mo, actor); |
| 8369 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_KORAX_SPIRIT6, ANG60 * 5, |
| 8370 |
5 * FRACUNIT); |
| 8371 |
if (mo) |
| 8372 |
KSpiritInit(mo, actor); |
| 8373 |
|
| 8374 |
CheckACSPresent(255); |
| 8375 |
P_StartACS(255, 0, args, actor, NULL, 0); // Death script |
| 8376 |
} |
| 8377 |
|
| 8378 |
void KSpiritInit(mobj_t * spirit, mobj_t * korax) |
| 8379 |
{ |
| 8380 |
int i; |
| 8381 |
mobj_t *tail, *next; |
| 8382 |
|
| 8383 |
spirit->health = KORAX_SPIRIT_LIFETIME; |
| 8384 |
|
| 8385 |
P_SetTarget(&spirit->special1.m, korax); // Swarm around korax |
| 8386 |
spirit->special2.i = 32 + (P_Random(pr_hexen) & 7); // Float bob index |
| 8387 |
spirit->special_args[0] = 10; // initial turn value |
| 8388 |
spirit->special_args[1] = 0; // initial look angle |
| 8389 |
|
| 8390 |
// Spawn a tail for spirit |
| 8391 |
tail = P_SpawnMobj(spirit->x, spirit->y, spirit->z, HEXEN_MT_HOLY_TAIL); |
| 8392 |
P_SetTarget(&tail->special2.m, spirit); // parent |
| 8393 |
for (i = 1; i < 3; i++) |
| 8394 |
{ |
| 8395 |
next = P_SpawnMobj(spirit->x, spirit->y, spirit->z, HEXEN_MT_HOLY_TAIL); |
| 8396 |
P_SetMobjState(next, next->info->spawnstate + 1); |
| 8397 |
P_SetTarget(&tail->special1.m, next); |
| 8398 |
tail = next; |
| 8399 |
} |
| 8400 |
P_SetTarget(&tail->special1.m, NULL); // last tail bit |
| 8401 |
} |
| 8402 |
|
| 8403 |
void A_KoraxDecide(mobj_t * actor) |
| 8404 |
{ |
| 8405 |
if (P_Random(pr_hexen) < 220) |
| 8406 |
{ |
| 8407 |
P_SetMobjState(actor, HEXEN_S_KORAX_MISSILE1); |
| 8408 |
} |
| 8409 |
else |
| 8410 |
{ |
| 8411 |
P_SetMobjState(actor, HEXEN_S_KORAX_COMMAND1); |
| 8412 |
} |
| 8413 |
} |
| 8414 |
|
| 8415 |
void A_KoraxMissile(mobj_t * actor) |
| 8416 |
{ |
| 8417 |
int type = P_Random(pr_hexen) % 6; |
| 8418 |
int sound = 0; |
| 8419 |
|
| 8420 |
S_StartMobjSound(actor, hexen_sfx_korax_attack); |
| 8421 |
|
| 8422 |
switch (type) |
| 8423 |
{ |
| 8424 |
case 0: |
| 8425 |
type = HEXEN_MT_WRAITHFX1; |
| 8426 |
sound = hexen_sfx_wraith_missile_fire; |
| 8427 |
break; |
| 8428 |
case 1: |
| 8429 |
type = HEXEN_MT_DEMONFX1; |
| 8430 |
sound = hexen_sfx_demon_missile_fire; |
| 8431 |
break; |
| 8432 |
case 2: |
| 8433 |
type = HEXEN_MT_DEMON2FX1; |
| 8434 |
sound = hexen_sfx_demon_missile_fire; |
| 8435 |
break; |
| 8436 |
case 3: |
| 8437 |
type = HEXEN_MT_FIREDEMON_FX6; |
| 8438 |
sound = hexen_sfx_fired_attack; |
| 8439 |
break; |
| 8440 |
case 4: |
| 8441 |
type = HEXEN_MT_CENTAUR_FX; |
| 8442 |
sound = hexen_sfx_centaurleader_attack; |
| 8443 |
break; |
| 8444 |
case 5: |
| 8445 |
type = HEXEN_MT_SERPENTFX; |
| 8446 |
sound = hexen_sfx_centaurleader_attack; |
| 8447 |
break; |
| 8448 |
} |
| 8449 |
|
| 8450 |
// Fire all 6 missiles at once |
| 8451 |
S_StartVoidSound(sound); |
| 8452 |
KoraxFire1(actor, type); |
| 8453 |
KoraxFire2(actor, type); |
| 8454 |
KoraxFire3(actor, type); |
| 8455 |
KoraxFire4(actor, type); |
| 8456 |
KoraxFire5(actor, type); |
| 8457 |
KoraxFire6(actor, type); |
| 8458 |
} |
| 8459 |
|
| 8460 |
void A_KoraxCommand(mobj_t * actor) |
| 8461 |
{ |
| 8462 |
byte args[5]; |
| 8463 |
fixed_t x, y, z; |
| 8464 |
angle_t ang; |
| 8465 |
int numcommands; |
| 8466 |
|
| 8467 |
S_StartMobjSound(actor, hexen_sfx_korax_command); |
| 8468 |
|
| 8469 |
// Shoot stream of lightning to ceiling |
| 8470 |
ang = (actor->angle - ANG90) >> ANGLETOFINESHIFT; |
| 8471 |
x = actor->x + FixedMul(KORAX_COMMAND_OFFSET, finecosine[ang]); |
| 8472 |
y = actor->y + FixedMul(KORAX_COMMAND_OFFSET, finesine[ang]); |
| 8473 |
z = actor->z + KORAX_COMMAND_HEIGHT; |
| 8474 |
P_SpawnMobj(x, y, z, HEXEN_MT_KORAX_BOLT); |
| 8475 |
|
| 8476 |
args[0] = args[1] = args[2] = args[3] = args[4] = 0; |
| 8477 |
|
| 8478 |
if (actor->health <= (P_MobjSpawnHealth(actor) >> 1)) |
| 8479 |
{ |
| 8480 |
numcommands = 5; |
| 8481 |
} |
| 8482 |
else |
| 8483 |
{ |
| 8484 |
numcommands = 4; |
| 8485 |
} |
| 8486 |
|
| 8487 |
switch (P_Random(pr_hexen) % numcommands) |
| 8488 |
{ |
| 8489 |
case 0: |
| 8490 |
CheckACSPresent(250); |
| 8491 |
P_StartACS(250, 0, args, actor, NULL, 0); |
| 8492 |
break; |
| 8493 |
case 1: |
| 8494 |
CheckACSPresent(251); |
| 8495 |
P_StartACS(251, 0, args, actor, NULL, 0); |
| 8496 |
break; |
| 8497 |
case 2: |
| 8498 |
CheckACSPresent(252); |
| 8499 |
P_StartACS(252, 0, args, actor, NULL, 0); |
| 8500 |
break; |
| 8501 |
case 3: |
| 8502 |
CheckACSPresent(253); |
| 8503 |
P_StartACS(253, 0, args, actor, NULL, 0); |
| 8504 |
break; |
| 8505 |
case 4: |
| 8506 |
CheckACSPresent(254); |
| 8507 |
P_StartACS(254, 0, args, actor, NULL, 0); |
| 8508 |
break; |
| 8509 |
} |
| 8510 |
} |
| 8511 |
|
| 8512 |
#define KORAX_DELTAANGLE (85*ANG1) |
| 8513 |
#define KORAX_ARM_EXTENSION_SHORT (40*FRACUNIT) |
| 8514 |
#define KORAX_ARM_EXTENSION_LONG (55*FRACUNIT) |
| 8515 |
|
| 8516 |
#define KORAX_ARM1_HEIGHT (108*FRACUNIT) |
| 8517 |
#define KORAX_ARM2_HEIGHT (82*FRACUNIT) |
| 8518 |
#define KORAX_ARM3_HEIGHT (54*FRACUNIT) |
| 8519 |
#define KORAX_ARM4_HEIGHT (104*FRACUNIT) |
| 8520 |
#define KORAX_ARM5_HEIGHT (86*FRACUNIT) |
| 8521 |
#define KORAX_ARM6_HEIGHT (53*FRACUNIT) |
| 8522 |
|
| 8523 |
// Arm projectiles |
| 8524 |
// arm positions numbered: |
| 8525 |
// 1 top left |
| 8526 |
// 2 middle left |
| 8527 |
// 3 lower left |
| 8528 |
// 4 top right |
| 8529 |
// 5 middle right |
| 8530 |
// 6 lower right |
| 8531 |
|
| 8532 |
void KoraxFire1(mobj_t * actor, int type) |
| 8533 |
{ |
| 8534 |
angle_t ang; |
| 8535 |
fixed_t x, y, z; |
| 8536 |
|
| 8537 |
ang = (actor->angle - KORAX_DELTAANGLE) >> ANGLETOFINESHIFT; |
| 8538 |
x = actor->x + FixedMul(KORAX_ARM_EXTENSION_SHORT, finecosine[ang]); |
| 8539 |
y = actor->y + FixedMul(KORAX_ARM_EXTENSION_SHORT, finesine[ang]); |
| 8540 |
z = actor->z - actor->floorclip + KORAX_ARM1_HEIGHT; |
| 8541 |
P_SpawnKoraxMissile(x, y, z, actor, actor->target, type); |
| 8542 |
} |
| 8543 |
|
| 8544 |
void KoraxFire2(mobj_t * actor, int type) |
| 8545 |
{ |
| 8546 |
angle_t ang; |
| 8547 |
fixed_t x, y, z; |
| 8548 |
|
| 8549 |
ang = (actor->angle - KORAX_DELTAANGLE) >> ANGLETOFINESHIFT; |
| 8550 |
x = actor->x + FixedMul(KORAX_ARM_EXTENSION_LONG, finecosine[ang]); |
| 8551 |
y = actor->y + FixedMul(KORAX_ARM_EXTENSION_LONG, finesine[ang]); |
| 8552 |
z = actor->z - actor->floorclip + KORAX_ARM2_HEIGHT; |
| 8553 |
P_SpawnKoraxMissile(x, y, z, actor, actor->target, type); |
| 8554 |
} |
| 8555 |
|
| 8556 |
void KoraxFire3(mobj_t * actor, int type) |
| 8557 |
{ |
| 8558 |
angle_t ang; |
| 8559 |
fixed_t x, y, z; |
| 8560 |
|
| 8561 |
ang = (actor->angle - KORAX_DELTAANGLE) >> ANGLETOFINESHIFT; |
| 8562 |
x = actor->x + FixedMul(KORAX_ARM_EXTENSION_LONG, finecosine[ang]); |
| 8563 |
y = actor->y + FixedMul(KORAX_ARM_EXTENSION_LONG, finesine[ang]); |
| 8564 |
z = actor->z - actor->floorclip + KORAX_ARM3_HEIGHT; |
| 8565 |
P_SpawnKoraxMissile(x, y, z, actor, actor->target, type); |
| 8566 |
} |
| 8567 |
|
| 8568 |
void KoraxFire4(mobj_t * actor, int type) |
| 8569 |
{ |
| 8570 |
angle_t ang; |
| 8571 |
fixed_t x, y, z; |
| 8572 |
|
| 8573 |
ang = (actor->angle + KORAX_DELTAANGLE) >> ANGLETOFINESHIFT; |
| 8574 |
x = actor->x + FixedMul(KORAX_ARM_EXTENSION_SHORT, finecosine[ang]); |
| 8575 |
y = actor->y + FixedMul(KORAX_ARM_EXTENSION_SHORT, finesine[ang]); |
| 8576 |
z = actor->z - actor->floorclip + KORAX_ARM4_HEIGHT; |
| 8577 |
P_SpawnKoraxMissile(x, y, z, actor, actor->target, type); |
| 8578 |
} |
| 8579 |
|
| 8580 |
void KoraxFire5(mobj_t * actor, int type) |
| 8581 |
{ |
| 8582 |
angle_t ang; |
| 8583 |
fixed_t x, y, z; |
| 8584 |
|
| 8585 |
ang = (actor->angle + KORAX_DELTAANGLE) >> ANGLETOFINESHIFT; |
| 8586 |
x = actor->x + FixedMul(KORAX_ARM_EXTENSION_LONG, finecosine[ang]); |
| 8587 |
y = actor->y + FixedMul(KORAX_ARM_EXTENSION_LONG, finesine[ang]); |
| 8588 |
z = actor->z - actor->floorclip + KORAX_ARM5_HEIGHT; |
| 8589 |
P_SpawnKoraxMissile(x, y, z, actor, actor->target, type); |
| 8590 |
} |
| 8591 |
|
| 8592 |
void KoraxFire6(mobj_t * actor, int type) |
| 8593 |
{ |
| 8594 |
angle_t ang; |
| 8595 |
fixed_t x, y, z; |
| 8596 |
|
| 8597 |
ang = (actor->angle + KORAX_DELTAANGLE) >> ANGLETOFINESHIFT; |
| 8598 |
x = actor->x + FixedMul(KORAX_ARM_EXTENSION_LONG, finecosine[ang]); |
| 8599 |
y = actor->y + FixedMul(KORAX_ARM_EXTENSION_LONG, finesine[ang]); |
| 8600 |
z = actor->z - actor->floorclip + KORAX_ARM6_HEIGHT; |
| 8601 |
P_SpawnKoraxMissile(x, y, z, actor, actor->target, type); |
| 8602 |
} |
| 8603 |
|
| 8604 |
void A_KSpiritWeave(mobj_t * actor) |
| 8605 |
{ |
| 8606 |
fixed_t newX, newY; |
| 8607 |
int weaveXY, weaveZ; |
| 8608 |
int angle; |
| 8609 |
|
| 8610 |
weaveXY = actor->special2.i >> 16; |
| 8611 |
weaveZ = actor->special2.i & 0xFFFF; |
| 8612 |
angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 8613 |
newX = actor->x - FixedMul(finecosine[angle], |
| 8614 |
FloatBobOffsets[weaveXY] << 2); |
| 8615 |
newY = actor->y - FixedMul(finesine[angle], |
| 8616 |
FloatBobOffsets[weaveXY] << 2); |
| 8617 |
weaveXY = (weaveXY + (P_Random(pr_hexen) % 5)) & 63; |
| 8618 |
newX += FixedMul(finecosine[angle], FloatBobOffsets[weaveXY] << 2); |
| 8619 |
newY += FixedMul(finesine[angle], FloatBobOffsets[weaveXY] << 2); |
| 8620 |
P_TryMove(actor, newX, newY, false); |
| 8621 |
actor->z -= FloatBobOffsets[weaveZ] << 1; |
| 8622 |
weaveZ = (weaveZ + (P_Random(pr_hexen) % 5)) & 63; |
| 8623 |
actor->z += FloatBobOffsets[weaveZ] << 1; |
| 8624 |
actor->special2.i = weaveZ + (weaveXY << 16); |
| 8625 |
} |
| 8626 |
|
| 8627 |
void A_KSpiritSeeker(mobj_t * actor, angle_t thresh, angle_t turnMax) |
| 8628 |
{ |
| 8629 |
int dir; |
| 8630 |
int dist; |
| 8631 |
angle_t delta; |
| 8632 |
angle_t angle; |
| 8633 |
mobj_t *target; |
| 8634 |
fixed_t newZ; |
| 8635 |
fixed_t deltaZ; |
| 8636 |
|
| 8637 |
target = actor->special1.m; |
| 8638 |
if (target == NULL) |
| 8639 |
{ |
| 8640 |
return; |
| 8641 |
} |
| 8642 |
dir = P_FaceMobj(actor, target, &delta); |
| 8643 |
if (delta > thresh) |
| 8644 |
{ |
| 8645 |
delta >>= 1; |
| 8646 |
if (delta > turnMax) |
| 8647 |
{ |
| 8648 |
delta = turnMax; |
| 8649 |
} |
| 8650 |
} |
| 8651 |
if (dir) |
| 8652 |
{ // Turn clockwise |
| 8653 |
actor->angle += delta; |
| 8654 |
} |
| 8655 |
else |
| 8656 |
{ // Turn counter clockwise |
| 8657 |
actor->angle -= delta; |
| 8658 |
} |
| 8659 |
angle = actor->angle >> ANGLETOFINESHIFT; |
| 8660 |
actor->momx = FixedMul(actor->info->speed, finecosine[angle]); |
| 8661 |
actor->momy = FixedMul(actor->info->speed, finesine[angle]); |
| 8662 |
|
| 8663 |
if (!(leveltime & 15) |
| 8664 |
|| actor->z > target->z + (target->info->height) |
| 8665 |
|| actor->z + actor->height < target->z) |
| 8666 |
{ |
| 8667 |
newZ = target->z + ((P_Random(pr_hexen) * target->info->height) >> 8); |
| 8668 |
deltaZ = newZ - actor->z; |
| 8669 |
if (abs(deltaZ) > 15 * FRACUNIT) |
| 8670 |
{ |
| 8671 |
if (deltaZ > 0) |
| 8672 |
{ |
| 8673 |
deltaZ = 15 * FRACUNIT; |
| 8674 |
} |
| 8675 |
else |
| 8676 |
{ |
| 8677 |
deltaZ = -15 * FRACUNIT; |
| 8678 |
} |
| 8679 |
} |
| 8680 |
dist = P_AproxDistance(target->x - actor->x, target->y - actor->y); |
| 8681 |
dist = dist / actor->info->speed; |
| 8682 |
if (dist < 1) |
| 8683 |
{ |
| 8684 |
dist = 1; |
| 8685 |
} |
| 8686 |
actor->momz = deltaZ / dist; |
| 8687 |
} |
| 8688 |
return; |
| 8689 |
} |
| 8690 |
|
| 8691 |
void A_KSpiritRoam(mobj_t * actor) |
| 8692 |
{ |
| 8693 |
if (actor->health-- <= 0) |
| 8694 |
{ |
| 8695 |
S_StartMobjSound(actor, hexen_sfx_spirit_die); |
| 8696 |
P_SetMobjState(actor, HEXEN_S_KSPIRIT_DEATH1); |
| 8697 |
} |
| 8698 |
else |
| 8699 |
{ |
| 8700 |
if (actor->special1.m) |
| 8701 |
{ |
| 8702 |
A_KSpiritSeeker(actor, actor->special_args[0] * ANG1, |
| 8703 |
actor->special_args[0] * ANG1 * 2); |
| 8704 |
} |
| 8705 |
A_KSpiritWeave(actor); |
| 8706 |
if (P_Random(pr_hexen) < 50) |
| 8707 |
{ |
| 8708 |
S_StartVoidSound(hexen_sfx_spirit_active); |
| 8709 |
} |
| 8710 |
} |
| 8711 |
} |
| 8712 |
|
| 8713 |
void A_KBolt(mobj_t * actor) |
| 8714 |
{ |
| 8715 |
// Countdown lifetime |
| 8716 |
if (actor->special1.i-- <= 0) |
| 8717 |
{ |
| 8718 |
P_SetMobjState(actor, HEXEN_S_NULL); |
| 8719 |
} |
| 8720 |
} |
| 8721 |
|
| 8722 |
#define KORAX_BOLT_HEIGHT 48*FRACUNIT |
| 8723 |
#define KORAX_BOLT_LIFETIME 3 |
| 8724 |
|
| 8725 |
void A_KBoltRaise(mobj_t * actor) |
| 8726 |
{ |
| 8727 |
mobj_t *mo; |
| 8728 |
fixed_t z; |
| 8729 |
|
| 8730 |
// Spawn a child upward |
| 8731 |
z = actor->z + KORAX_BOLT_HEIGHT; |
| 8732 |
|
| 8733 |
if ((z + KORAX_BOLT_HEIGHT) < actor->ceilingz) |
| 8734 |
{ |
| 8735 |
mo = P_SpawnMobj(actor->x, actor->y, z, HEXEN_MT_KORAX_BOLT); |
| 8736 |
if (mo) |
| 8737 |
{ |
| 8738 |
mo->special1.i = KORAX_BOLT_LIFETIME; |
| 8739 |
} |
| 8740 |
} |
| 8741 |
else |
| 8742 |
{ |
| 8743 |
// Maybe cap it off here |
| 8744 |
} |
| 8745 |
} |