| 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 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 |
* Weapon sprite animation, weapon objects. |
| 31 |
* Action functions for weapons. |
| 32 |
* |
| 33 |
*-----------------------------------------------------------------------------*/ |
| 34 |
|
| 35 |
#include "doomstat.h" |
| 36 |
#include "r_main.h" |
| 37 |
#include "p_map.h" |
| 38 |
#include "p_inter.h" |
| 39 |
#include "p_pspr.h" |
| 40 |
#include "p_user.h" |
| 41 |
#include "p_enemy.h" |
| 42 |
#include "p_tick.h" |
| 43 |
#include "m_random.h" |
| 44 |
#include "s_sound.h" |
| 45 |
#include "sounds.h" |
| 46 |
#include "d_event.h" |
| 47 |
#include "smooth.h" |
| 48 |
#include "g_game.h" |
| 49 |
#include "lprintf.h" |
| 50 |
#include "e6y.h"//e6y |
| 51 |
|
| 52 |
#include "dsda.h" |
| 53 |
#include "dsda/aim.h" |
| 54 |
#include "dsda/excmd.h" |
| 55 |
|
| 56 |
#define LOWERSPEED (FRACUNIT*6) |
| 57 |
#define RAISESPEED (FRACUNIT*6) |
| 58 |
#define WEAPONBOTTOM (FRACUNIT*128) |
| 59 |
#define WEAPONTOP (FRACUNIT*32) |
| 60 |
|
| 61 |
#define BFGCELLS bfgcells /* Ty 03/09/98 externalized in p_inter.c */ |
| 62 |
|
| 63 |
// Checking correctness of input parameters for weapon codepointers |
| 64 |
// for avoiding crashes when they are used with player/monster states. |
| 65 |
#ifdef PRBOOM_DEBUG |
| 66 |
#define CHECK_WEAPON_CODEPOINTER(codepointer, player)\ |
| 67 |
if (!player->mo->player) {\ |
| 68 |
I_Error("%s: Weapon codepointers cannot be used with player/monster states (incorrect DEH).", codepointer);\ |
| 69 |
return;\ |
| 70 |
} |
| 71 |
#else |
| 72 |
#define CHECK_WEAPON_CODEPOINTER(codepointer, player) |
| 73 |
#endif |
| 74 |
|
| 75 |
extern void P_ForwardThrust(player_t *, angle_t, fixed_t); |
| 76 |
extern void P_Thrust(player_t *, angle_t, fixed_t); |
| 77 |
|
| 78 |
// The following array holds the recoil values // phares |
| 79 |
|
| 80 |
static const int recoil_values[] = { // phares |
| 81 |
10, // wp_fist |
| 82 |
10, // wp_pistol |
| 83 |
30, // wp_shotgun |
| 84 |
10, // wp_chaingun |
| 85 |
100,// wp_missile |
| 86 |
20, // wp_plasma |
| 87 |
100,// wp_bfg |
| 88 |
0, // wp_chainsaw |
| 89 |
80 // wp_supershotgun |
| 90 |
}; |
| 91 |
|
| 92 |
// |
| 93 |
// P_SetPsprite |
| 94 |
// |
| 95 |
|
| 96 |
void P_SetPsprite(player_t *player, int position, statenum_t stnum) |
| 97 |
{ |
| 98 |
P_SetPspritePtr(player, &player->psprites[position], stnum); |
| 99 |
} |
| 100 |
|
| 101 |
// |
| 102 |
// P_SetPspritePtr |
| 103 |
// |
| 104 |
|
| 105 |
void P_SetPspritePtr(player_t *player, pspdef_t *psp, statenum_t stnum) |
| 106 |
{ |
| 107 |
do |
| 108 |
{ |
| 109 |
state_t *state; |
| 110 |
|
| 111 |
if (!stnum) |
| 112 |
{ |
| 113 |
// object removed itself |
| 114 |
psp->state = NULL; |
| 115 |
break; |
| 116 |
} |
| 117 |
|
| 118 |
state = &states[stnum]; |
| 119 |
psp->state = state; |
| 120 |
psp->tics = state->tics; // could be 0 |
| 121 |
|
| 122 |
if (hexen) |
| 123 |
{ |
| 124 |
if (state->misc1) |
| 125 |
{ // Set coordinates. |
| 126 |
psp->sx = state->misc1 << FRACBITS; |
| 127 |
} |
| 128 |
if (state->misc2) |
| 129 |
{ |
| 130 |
psp->sy = state->misc2 << FRACBITS; |
| 131 |
} |
| 132 |
} |
| 133 |
else if (state->misc1) |
| 134 |
{ |
| 135 |
// coordinate set |
| 136 |
psp->sx = state->misc1 << FRACBITS; |
| 137 |
psp->sy = state->misc2 << FRACBITS; |
| 138 |
} |
| 139 |
|
| 140 |
// Call action routine. |
| 141 |
// Modified handling. |
| 142 |
if (state->action) |
| 143 |
{ |
| 144 |
state->action(player, psp); |
| 145 |
if (!psp->state) |
| 146 |
break; |
| 147 |
} |
| 148 |
stnum = psp->state->nextstate; |
| 149 |
} |
| 150 |
while (!psp->tics); // an initial state of 0 could cycle through |
| 151 |
} |
| 152 |
|
| 153 |
// |
| 154 |
// P_BringUpWeapon |
| 155 |
// Starts bringing the pending weapon up |
| 156 |
// from the bottom of the screen. |
| 157 |
// Uses player |
| 158 |
// |
| 159 |
|
| 160 |
static void P_BringUpWeapon(player_t *player) |
| 161 |
{ |
| 162 |
statenum_t newstate; |
| 163 |
|
| 164 |
if (player->pendingweapon == wp_nochange) |
| 165 |
player->pendingweapon = player->readyweapon; |
| 166 |
|
| 167 |
if (player->pendingweapon == g_wp_chainsaw) |
| 168 |
S_StartMobjSound(player->mo, g_sfx_sawup); |
| 169 |
|
| 170 |
if (player->pendingweapon >= NUMWEAPONS) |
| 171 |
lprintf(LO_WARN, "P_BringUpWeapon: weaponinfo overrun has occurred.\n"); |
| 172 |
|
| 173 |
if (player->pclass) |
| 174 |
{ |
| 175 |
if (player->pclass == PCLASS_FIGHTER && player->pendingweapon == wp_second |
| 176 |
&& player->ammo[MANA_1]) |
| 177 |
{ |
| 178 |
newstate = HEXEN_S_FAXEUP_G; |
| 179 |
} |
| 180 |
else |
| 181 |
{ |
| 182 |
newstate = hexen_weaponinfo[player->pendingweapon][player->pclass].upstate; |
| 183 |
} |
| 184 |
} |
| 185 |
else if (player->powers[pw_weaponlevel2]) |
| 186 |
{ |
| 187 |
newstate = wpnlev2info[player->pendingweapon].upstate; |
| 188 |
} |
| 189 |
else |
| 190 |
{ |
| 191 |
newstate = weaponinfo[player->pendingweapon].upstate; |
| 192 |
} |
| 193 |
|
| 194 |
player->pendingweapon = wp_nochange; |
| 195 |
// killough 12/98: prevent pistol from starting visibly at bottom of screen: |
| 196 |
player->psprites[ps_weapon].sy = |
| 197 |
mbf_features ? WEAPONBOTTOM + FRACUNIT * 2 : WEAPONBOTTOM; |
| 198 |
|
| 199 |
P_SetPsprite(player, ps_weapon, newstate); |
| 200 |
} |
| 201 |
|
| 202 |
// The first set is where the weapon preferences from // killough, |
| 203 |
// default.cfg are stored. These values represent the keys used // phares |
| 204 |
// in DOOM2 to bring up the weapon, i.e. 6 = plasma gun. These // | |
| 205 |
// are NOT the wp_* constants. // V |
| 206 |
|
| 207 |
int weapon_preferences[2][NUMWEAPONS+1] = { |
| 208 |
{6, 9, 4, 3, 2, 8, 5, 7, 1, 0}, // !compatibility preferences |
| 209 |
{6, 9, 4, 3, 2, 8, 5, 7, 1, 0}, // compatibility preferences |
| 210 |
}; |
| 211 |
|
| 212 |
// [XA] fixed version of P_SwitchWeapon that correctly |
| 213 |
// takes each weapon's ammotype and ammopershot into account, |
| 214 |
// instead of blindly assuming both. |
| 215 |
|
| 216 |
static int P_SwitchWeaponMBF21(player_t *player) |
| 217 |
{ |
| 218 |
int *prefer; |
| 219 |
int currentweapon, newweapon; |
| 220 |
int i; |
| 221 |
weapontype_t checkweapon; |
| 222 |
ammotype_t ammotype; |
| 223 |
|
| 224 |
prefer = weapon_preferences[0]; |
| 225 |
currentweapon = player->readyweapon; |
| 226 |
newweapon = currentweapon; |
| 227 |
i = NUMWEAPONS + 1; |
| 228 |
|
| 229 |
do |
| 230 |
{ |
| 231 |
checkweapon = wp_nochange; |
| 232 |
switch (*prefer++) |
| 233 |
{ |
| 234 |
case 1: |
| 235 |
if (!player->powers[pw_strength]) // allow chainsaw override |
| 236 |
break; |
| 237 |
// fallthrough |
| 238 |
case 0: |
| 239 |
checkweapon = wp_fist; |
| 240 |
break; |
| 241 |
case 2: |
| 242 |
checkweapon = wp_pistol; |
| 243 |
break; |
| 244 |
case 3: |
| 245 |
checkweapon = wp_shotgun; |
| 246 |
break; |
| 247 |
case 4: |
| 248 |
checkweapon = wp_chaingun; |
| 249 |
break; |
| 250 |
case 5: |
| 251 |
checkweapon = wp_missile; |
| 252 |
break; |
| 253 |
case 6: |
| 254 |
if (gamemode != shareware) |
| 255 |
checkweapon = wp_plasma; |
| 256 |
break; |
| 257 |
case 7: |
| 258 |
if (gamemode != shareware) |
| 259 |
checkweapon = wp_bfg; |
| 260 |
break; |
| 261 |
case 8: |
| 262 |
checkweapon = wp_chainsaw; |
| 263 |
break; |
| 264 |
case 9: |
| 265 |
if (gamemode == commercial) |
| 266 |
checkweapon = wp_supershotgun; |
| 267 |
break; |
| 268 |
} |
| 269 |
|
| 270 |
if (checkweapon != wp_nochange && player->weaponowned[checkweapon]) |
| 271 |
{ |
| 272 |
ammotype = weaponinfo[checkweapon].ammo; |
| 273 |
if (ammotype == am_noammo || |
| 274 |
player->ammo[ammotype] >= weaponinfo[checkweapon].ammopershot) |
| 275 |
newweapon = checkweapon; |
| 276 |
} |
| 277 |
} |
| 278 |
while (newweapon == currentweapon && --i); |
| 279 |
return newweapon; |
| 280 |
} |
| 281 |
|
| 282 |
// P_SwitchWeapon checks current ammo levels and gives you the |
| 283 |
// most preferred weapon with ammo. It will not pick the currently |
| 284 |
// raised weapon. When called from P_CheckAmmo this won't matter, |
| 285 |
// because the raised weapon has no ammo anyway. When called from |
| 286 |
// G_BuildTiccmd you want to toggle to a different weapon regardless. |
| 287 |
|
| 288 |
int P_SwitchWeapon(player_t *player) |
| 289 |
{ |
| 290 |
int *prefer; |
| 291 |
int currentweapon, newweapon; |
| 292 |
int i; |
| 293 |
|
| 294 |
// [XA] use fixed behavior for mbf21. no need |
| 295 |
// for a discrete compat option for this, as |
| 296 |
// it doesn't impact demo playback (weapon |
| 297 |
// switches are saved in the demo itself) |
| 298 |
if (mbf21) |
| 299 |
return P_SwitchWeaponMBF21(player); |
| 300 |
|
| 301 |
prefer = weapon_preferences[demo_compatibility != 0]; // killough 3/22/98 |
| 302 |
currentweapon = player->readyweapon; |
| 303 |
newweapon = currentweapon; |
| 304 |
i = NUMWEAPONS + 1; // killough 5/2/98 |
| 305 |
|
| 306 |
// Fix weapon switch logic in vanilla (example: chainsaw with ammo) |
| 307 |
if (demo_compatibility) |
| 308 |
currentweapon = newweapon = wp_nochange; |
| 309 |
|
| 310 |
// killough 2/8/98: follow preferences and fix BFG/SSG bugs |
| 311 |
|
| 312 |
do |
| 313 |
switch (*prefer++) |
| 314 |
{ |
| 315 |
case 1: |
| 316 |
if (!player->powers[pw_strength]) // allow chainsaw override |
| 317 |
break; |
| 318 |
// fallthrough |
| 319 |
case 0: |
| 320 |
newweapon = wp_fist; |
| 321 |
break; |
| 322 |
case 2: |
| 323 |
if (player->ammo[am_clip]) |
| 324 |
newweapon = wp_pistol; |
| 325 |
break; |
| 326 |
case 3: |
| 327 |
if (player->weaponowned[wp_shotgun] && player->ammo[am_shell]) |
| 328 |
newweapon = wp_shotgun; |
| 329 |
break; |
| 330 |
case 4: |
| 331 |
if (player->weaponowned[wp_chaingun] && player->ammo[am_clip]) |
| 332 |
newweapon = wp_chaingun; |
| 333 |
break; |
| 334 |
case 5: |
| 335 |
if (player->weaponowned[wp_missile] && player->ammo[am_misl]) |
| 336 |
newweapon = wp_missile; |
| 337 |
break; |
| 338 |
case 6: |
| 339 |
if (player->weaponowned[wp_plasma] && player->ammo[am_cell] && |
| 340 |
gamemode != shareware) |
| 341 |
newweapon = wp_plasma; |
| 342 |
break; |
| 343 |
case 7: |
| 344 |
if (player->weaponowned[wp_bfg] && gamemode != shareware && |
| 345 |
player->ammo[am_cell] >= (demo_compatibility ? 41 : 40)) |
| 346 |
newweapon = wp_bfg; |
| 347 |
break; |
| 348 |
case 8: |
| 349 |
if (player->weaponowned[wp_chainsaw]) |
| 350 |
newweapon = wp_chainsaw; |
| 351 |
break; |
| 352 |
case 9: |
| 353 |
if (player->weaponowned[wp_supershotgun] && gamemode == commercial && |
| 354 |
player->ammo[am_shell] >= (demo_compatibility ? 3 : 2)) |
| 355 |
newweapon = wp_supershotgun; |
| 356 |
break; |
| 357 |
} |
| 358 |
while (newweapon == currentweapon && --i); // killough 5/2/98 |
| 359 |
return newweapon; |
| 360 |
} |
| 361 |
|
| 362 |
// killough 5/2/98: whether consoleplayer prefers weapon w1 over weapon w2. |
| 363 |
int P_WeaponPreferred(int w1, int w2) |
| 364 |
{ |
| 365 |
return |
| 366 |
(weapon_preferences[0][0] != ++w2 && (weapon_preferences[0][0] == ++w1 || |
| 367 |
(weapon_preferences[0][1] != w2 && (weapon_preferences[0][1] == w1 || |
| 368 |
(weapon_preferences[0][2] != w2 && (weapon_preferences[0][2] == w1 || |
| 369 |
(weapon_preferences[0][3] != w2 && (weapon_preferences[0][3] == w1 || |
| 370 |
(weapon_preferences[0][4] != w2 && (weapon_preferences[0][4] == w1 || |
| 371 |
(weapon_preferences[0][5] != w2 && (weapon_preferences[0][5] == w1 || |
| 372 |
(weapon_preferences[0][6] != w2 && (weapon_preferences[0][6] == w1 || |
| 373 |
(weapon_preferences[0][7] != w2 && (weapon_preferences[0][7] == w1 |
| 374 |
)))))))))))))))); |
| 375 |
} |
| 376 |
|
| 377 |
int P_AmmoPercent(player_t *player, int weapon) |
| 378 |
{ |
| 379 |
int ammo_i = weaponinfo[weapon].ammo; |
| 380 |
|
| 381 |
if (!player->maxammo[ammo_i]) |
| 382 |
return 0; |
| 383 |
|
| 384 |
return player->ammo[ammo_i] * 100 / player->maxammo[ammo_i]; |
| 385 |
} |
| 386 |
|
| 387 |
// |
| 388 |
// P_CheckAmmo |
| 389 |
// Returns true if there is enough ammo to shoot. |
| 390 |
// If not, selects the next weapon to use. |
| 391 |
// (only in demo_compatibility mode -- killough 3/22/98) |
| 392 |
// |
| 393 |
|
| 394 |
static dboolean Heretic_P_CheckAmmo(struct player_s * player); |
| 395 |
static dboolean P_CheckMana(player_t * player); |
| 396 |
|
| 397 |
dboolean P_CheckAmmo(player_t *player) |
| 398 |
{ |
| 399 |
ammotype_t ammo; |
| 400 |
int count; // Regular |
| 401 |
|
| 402 |
if (heretic) return Heretic_P_CheckAmmo(player); |
| 403 |
if (hexen) return P_CheckMana(player); |
| 404 |
|
| 405 |
ammo = weaponinfo[player->readyweapon].ammo; |
| 406 |
if (mbf21) |
| 407 |
count = weaponinfo[player->readyweapon].ammopershot; |
| 408 |
else |
| 409 |
if (player->readyweapon == wp_bfg) // Minimal amount for one shot varies. |
| 410 |
count = BFGCELLS; |
| 411 |
else |
| 412 |
if (player->readyweapon == wp_supershotgun) // Double barrel. |
| 413 |
count = 2; |
| 414 |
else |
| 415 |
count = 1; |
| 416 |
|
| 417 |
// Some do not need ammunition anyway. |
| 418 |
// Return if current ammunition sufficient. |
| 419 |
|
| 420 |
if (player->cheats & CF_INFINITE_AMMO || ammo == am_noammo || player->ammo[ammo] >= count) |
| 421 |
return true; |
| 422 |
|
| 423 |
// Out of ammo, pick a weapon to change to. |
| 424 |
// |
| 425 |
// killough 3/22/98: for old demos we do the switch here and now; |
| 426 |
// for Boom games we cannot do this, and have different player |
| 427 |
// preferences across demos or networks, so we have to use the |
| 428 |
// G_BuildTiccmd() interface instead of making the switch here. |
| 429 |
|
| 430 |
if (demo_compatibility) |
| 431 |
{ |
| 432 |
player->pendingweapon = P_SwitchWeapon(player); // phares |
| 433 |
// Now set appropriate weapon overlay. |
| 434 |
P_SetPsprite(player,ps_weapon,weaponinfo[player->readyweapon].downstate); |
| 435 |
} |
| 436 |
|
| 437 |
return false; |
| 438 |
} |
| 439 |
|
| 440 |
// |
| 441 |
// P_SubtractAmmo |
| 442 |
// Subtracts ammo, w/compat handling. In mbf21, use |
| 443 |
// readyweapon's "ammopershot" field if it's explicitly |
| 444 |
// defined in dehacked; otherwise use the amount specified |
| 445 |
// by the codepointer instead (Doom behavior) |
| 446 |
// |
| 447 |
// [XA] NOTE: this function is for handling Doom's native |
| 448 |
// attack pointers; of note, the new A_ConsumeAmmo mbf21 |
| 449 |
// codepointer does NOT call this function, since it doesn't |
| 450 |
// have to worry about any compatibility shenanigans. |
| 451 |
// |
| 452 |
|
| 453 |
void P_SubtractAmmo(struct player_s *player, int vanilla_amount) |
| 454 |
{ |
| 455 |
int amount; |
| 456 |
ammotype_t ammotype = weaponinfo[player->readyweapon].ammo; |
| 457 |
|
| 458 |
if (player->cheats & CF_INFINITE_AMMO || (mbf21 && ammotype == am_noammo)) |
| 459 |
return; // [XA] hmm... I guess vanilla/boom will go out of bounds then? |
| 460 |
|
| 461 |
if (mbf21 && (weaponinfo[player->readyweapon].intflags & WIF_ENABLEAPS)) |
| 462 |
amount = weaponinfo[player->readyweapon].ammopershot; |
| 463 |
else |
| 464 |
amount = vanilla_amount; |
| 465 |
|
| 466 |
player->ammo[ammotype] -= amount; |
| 467 |
|
| 468 |
if (mbf21 && player->ammo[ammotype] < 0) |
| 469 |
player->ammo[ammotype] = 0; |
| 470 |
} |
| 471 |
|
| 472 |
// |
| 473 |
// P_FireWeapon. |
| 474 |
// |
| 475 |
|
| 476 |
static void P_FireWeapon(player_t *player) |
| 477 |
{ |
| 478 |
statenum_t newstate; |
| 479 |
|
| 480 |
if (!P_CheckAmmo(player)) |
| 481 |
return; |
| 482 |
|
| 483 |
dsda_WatchWeaponFire(player->readyweapon); |
| 484 |
|
| 485 |
P_SetMobjState(player->mo, pclass[player->pclass].fire_weapon_state); |
| 486 |
|
| 487 |
if (heretic) |
| 488 |
{ |
| 489 |
weaponinfo_t *wpinfo; |
| 490 |
|
| 491 |
wpinfo = player->powers[pw_weaponlevel2] ? &wpnlev2info[0] |
| 492 |
: &weaponinfo[0]; |
| 493 |
newstate = player->refire ? wpinfo[player->readyweapon].holdatkstate |
| 494 |
: wpinfo[player->readyweapon].atkstate; |
| 495 |
} |
| 496 |
else if (hexen) |
| 497 |
{ |
| 498 |
if (player->pclass == PCLASS_FIGHTER && player->readyweapon == wp_second |
| 499 |
&& player->ammo[MANA_1] > 0) |
| 500 |
{ // Glowing axe |
| 501 |
newstate = HEXEN_S_FAXEATK_G1; |
| 502 |
} |
| 503 |
else |
| 504 |
{ |
| 505 |
newstate = player->refire ? |
| 506 |
hexen_weaponinfo[player->readyweapon][player->pclass].holdatkstate |
| 507 |
: hexen_weaponinfo[player->readyweapon][player->pclass].atkstate; |
| 508 |
} |
| 509 |
} |
| 510 |
else |
| 511 |
{ |
| 512 |
newstate = weaponinfo[player->readyweapon].atkstate; |
| 513 |
} |
| 514 |
|
| 515 |
P_SetPsprite(player, ps_weapon, newstate); |
| 516 |
if (hexen || !(weaponinfo[player->readyweapon].flags & WPF_SILENT)) |
| 517 |
P_NoiseAlert(player->mo, player->mo); |
| 518 |
|
| 519 |
// heretic_note: does the order matter? can we move it up? |
| 520 |
if (heretic) |
| 521 |
{ |
| 522 |
if (player->readyweapon == wp_gauntlets && !player->refire) |
| 523 |
{ // Play the sound for the initial gauntlet attack |
| 524 |
S_StartMobjSound(player->mo, heretic_sfx_gntuse); |
| 525 |
} |
| 526 |
} |
| 527 |
} |
| 528 |
|
| 529 |
// |
| 530 |
// P_DropWeapon |
| 531 |
// Player died, so put the weapon away. |
| 532 |
// |
| 533 |
|
| 534 |
void P_DropWeapon(player_t *player) |
| 535 |
{ |
| 536 |
statenum_t newstate; |
| 537 |
if (player->powers[pw_weaponlevel2]) |
| 538 |
{ |
| 539 |
newstate = wpnlev2info[player->readyweapon].downstate; |
| 540 |
} |
| 541 |
else if (player->pclass) |
| 542 |
{ |
| 543 |
newstate = hexen_weaponinfo[player->readyweapon][player->pclass].downstate; |
| 544 |
} |
| 545 |
else |
| 546 |
{ |
| 547 |
newstate = weaponinfo[player->readyweapon].downstate; |
| 548 |
} |
| 549 |
P_SetPsprite(player, ps_weapon, newstate); |
| 550 |
} |
| 551 |
|
| 552 |
// |
| 553 |
// A_WeaponReady |
| 554 |
// The player can fire the weapon |
| 555 |
// or change to another weapon at this time. |
| 556 |
// Follows after getting weapon up, |
| 557 |
// or after previous attack/fire sequence. |
| 558 |
// |
| 559 |
|
| 560 |
void A_WeaponReady(player_t *player, pspdef_t *psp) |
| 561 |
{ |
| 562 |
CHECK_WEAPON_CODEPOINTER("A_WeaponReady", player); |
| 563 |
|
| 564 |
if (player->chickenTics) |
| 565 |
{ // Change to the chicken beak |
| 566 |
P_ActivateBeak(player); |
| 567 |
return; |
| 568 |
} |
| 569 |
|
| 570 |
// get out of attack state |
| 571 |
if (player->mo->state >= &states[pclass[player->pclass].attack_state] |
| 572 |
&& player->mo->state <= &states[pclass[player->pclass].attack_end_state]) |
| 573 |
P_SetMobjState(player->mo, pclass[player->pclass].normal_state); |
| 574 |
|
| 575 |
if (heretic) |
| 576 |
{ |
| 577 |
if (player->readyweapon == wp_staff |
| 578 |
&& psp->state == &states[HERETIC_S_STAFFREADY2_1] |
| 579 |
&& P_Random(pr_heretic) < 128) |
| 580 |
{ |
| 581 |
S_StartMobjSound(player->mo, heretic_sfx_stfcrk); |
| 582 |
} |
| 583 |
} |
| 584 |
else if (hexen) |
| 585 |
{ |
| 586 |
// hexen does nothing here |
| 587 |
} |
| 588 |
else |
| 589 |
if (player->readyweapon == wp_chainsaw && psp->state == &states[S_SAW]) |
| 590 |
S_StartMobjSound(player->mo, sfx_sawidl); |
| 591 |
|
| 592 |
// check for change |
| 593 |
// if player is dead, put the weapon away |
| 594 |
|
| 595 |
if (player->pendingweapon != wp_nochange || !player->health) |
| 596 |
{ |
| 597 |
// change weapon (pending weapon should already be validated) |
| 598 |
statenum_t newstate; |
| 599 |
if (player->powers[pw_weaponlevel2]) |
| 600 |
newstate = wpnlev2info[player->readyweapon].downstate; |
| 601 |
else if (player->pclass) |
| 602 |
newstate = hexen_weaponinfo[player->readyweapon][player->pclass].downstate; |
| 603 |
else |
| 604 |
newstate = weaponinfo[player->readyweapon].downstate; |
| 605 |
P_SetPsprite(player, ps_weapon, newstate); |
| 606 |
return; |
| 607 |
} |
| 608 |
|
| 609 |
// check for fire |
| 610 |
// the missile launcher and bfg do not auto fire |
| 611 |
|
| 612 |
if (player->cmd.buttons & BT_ATTACK) |
| 613 |
{ |
| 614 |
if ( |
| 615 |
hexen || // hexen_note: why is this different? |
| 616 |
!player->attackdown || |
| 617 |
!(weaponinfo[player->readyweapon].flags & WPF_NOAUTOFIRE) |
| 618 |
) |
| 619 |
{ |
| 620 |
player->attackdown = true; |
| 621 |
P_FireWeapon(player); |
| 622 |
return; |
| 623 |
} |
| 624 |
} |
| 625 |
else |
| 626 |
player->attackdown = false; |
| 627 |
|
| 628 |
// bob the weapon based on movement speed |
| 629 |
if (!player->morphTics) |
| 630 |
{ |
| 631 |
int angle = (128 * leveltime) & FINEMASK; |
| 632 |
psp->sx = FRACUNIT + FixedMul(player->bob, finecosine[angle]); |
| 633 |
angle &= FINEANGLES / 2 - 1; |
| 634 |
psp->sy = WEAPONTOP + FixedMul(player->bob, finesine[angle]); |
| 635 |
} |
| 636 |
} |
| 637 |
|
| 638 |
// |
| 639 |
// A_ReFire |
| 640 |
// The player can re-fire the weapon |
| 641 |
// without lowering it entirely. |
| 642 |
// |
| 643 |
|
| 644 |
void A_ReFire(player_t *player, pspdef_t *psp) |
| 645 |
{ |
| 646 |
CHECK_WEAPON_CODEPOINTER("A_ReFire", player); |
| 647 |
|
| 648 |
// check for fire |
| 649 |
// (if a weaponchange is pending, let it go through instead) |
| 650 |
|
| 651 |
if ( (player->cmd.buttons & BT_ATTACK) |
| 652 |
&& player->pendingweapon == wp_nochange && player->health) |
| 653 |
{ |
| 654 |
player->refire++; |
| 655 |
P_FireWeapon(player); |
| 656 |
} |
| 657 |
else |
| 658 |
{ |
| 659 |
player->refire = 0; |
| 660 |
P_CheckAmmo(player); |
| 661 |
} |
| 662 |
} |
| 663 |
|
| 664 |
dboolean boom_weapon_state_injection; |
| 665 |
|
| 666 |
void A_CheckReload(player_t *player, pspdef_t *psp) |
| 667 |
{ |
| 668 |
CHECK_WEAPON_CODEPOINTER("A_CheckReload", player); |
| 669 |
|
| 670 |
if (!P_CheckAmmo(player) && compatibility_level >= prboom_4_compatibility) { |
| 671 |
/* cph 2002/08/08 - In old Doom, P_CheckAmmo would start the weapon lowering |
| 672 |
* immediately. This was lost in Boom when the weapon switching logic was |
| 673 |
* rewritten. But we must tell Doom that we don't need to complete the |
| 674 |
* reload frames for the weapon here. G_BuildTiccmd will set ->pendingweapon |
| 675 |
* for us later on. */ |
| 676 |
boom_weapon_state_injection = true; |
| 677 |
P_SetPsprite(player,ps_weapon,weaponinfo[player->readyweapon].downstate); |
| 678 |
} |
| 679 |
} |
| 680 |
|
| 681 |
// |
| 682 |
// A_Lower |
| 683 |
// Lowers current weapon, |
| 684 |
// and changes weapon at bottom. |
| 685 |
// |
| 686 |
|
| 687 |
void A_Lower(player_t *player, pspdef_t *psp) |
| 688 |
{ |
| 689 |
CHECK_WEAPON_CODEPOINTER("A_Lower", player); |
| 690 |
|
| 691 |
if (player->chickenTics || player->morphTics) |
| 692 |
{ |
| 693 |
psp->sy = WEAPONBOTTOM; |
| 694 |
} |
| 695 |
else |
| 696 |
{ |
| 697 |
psp->sy += LOWERSPEED; |
| 698 |
} |
| 699 |
|
| 700 |
// Is already down. |
| 701 |
if (psp->sy < WEAPONBOTTOM) |
| 702 |
return; |
| 703 |
|
| 704 |
// Player is dead. |
| 705 |
if (player->playerstate == PST_DEAD) |
| 706 |
{ |
| 707 |
psp->sy = WEAPONBOTTOM; |
| 708 |
return; // don't bring weapon back up |
| 709 |
} |
| 710 |
|
| 711 |
// The old weapon has been lowered off the screen, |
| 712 |
// so change the weapon and start raising it |
| 713 |
|
| 714 |
if (!player->health) |
| 715 |
{ // Player is dead, so keep the weapon off screen. |
| 716 |
P_SetPsprite(player, ps_weapon, g_s_null); |
| 717 |
return; |
| 718 |
} |
| 719 |
|
| 720 |
if (player->pendingweapon < NUMWEAPONS || !mbf21) |
| 721 |
{ |
| 722 |
player->readyweapon = player->pendingweapon; |
| 723 |
} |
| 724 |
|
| 725 |
P_BringUpWeapon(player); |
| 726 |
} |
| 727 |
|
| 728 |
// |
| 729 |
// A_Raise |
| 730 |
// |
| 731 |
|
| 732 |
void A_Raise(player_t *player, pspdef_t *psp) |
| 733 |
{ |
| 734 |
statenum_t newstate; |
| 735 |
|
| 736 |
CHECK_WEAPON_CODEPOINTER("A_Raise", player); |
| 737 |
|
| 738 |
psp->sy -= RAISESPEED; |
| 739 |
|
| 740 |
if (psp->sy > WEAPONTOP) |
| 741 |
return; |
| 742 |
|
| 743 |
psp->sy = WEAPONTOP; |
| 744 |
|
| 745 |
// The weapon has been raised all the way, |
| 746 |
// so change to the ready state. |
| 747 |
|
| 748 |
if (player->powers[pw_weaponlevel2]) |
| 749 |
newstate = wpnlev2info[player->readyweapon].readystate; |
| 750 |
else if (player->pclass) |
| 751 |
{ |
| 752 |
if (player->pclass == PCLASS_FIGHTER && player->readyweapon == wp_second |
| 753 |
&& player->ammo[MANA_1]) |
| 754 |
{ |
| 755 |
newstate = HEXEN_S_FAXEREADY_G; |
| 756 |
} |
| 757 |
else |
| 758 |
{ |
| 759 |
newstate = hexen_weaponinfo[player->readyweapon][player->pclass].readystate; |
| 760 |
} |
| 761 |
} |
| 762 |
else |
| 763 |
newstate = weaponinfo[player->readyweapon].readystate; |
| 764 |
|
| 765 |
P_SetPsprite(player, ps_weapon, newstate); |
| 766 |
} |
| 767 |
|
| 768 |
|
| 769 |
// Weapons now recoil, amount depending on the weapon. // phares |
| 770 |
// // | |
| 771 |
// The P_SetPsprite call in each of the weapon firing routines // V |
| 772 |
// was moved here so the recoil could be synched with the |
| 773 |
// muzzle flash, rather than the pressing of the trigger. |
| 774 |
// The BFG delay caused this to be necessary. |
| 775 |
|
| 776 |
static void A_FireSomething(player_t* player,int adder) |
| 777 |
{ |
| 778 |
P_SetPsprite(player, ps_flash, |
| 779 |
weaponinfo[player->readyweapon].flashstate+adder); |
| 780 |
|
| 781 |
// killough 3/27/98: prevent recoil in no-clipping mode |
| 782 |
if (!(player->mo->flags & MF_NOCLIP)) |
| 783 |
if (!compatibility && weapon_recoil) // phares |
| 784 |
P_ForwardThrust(player, ANG180 + player->mo->angle, |
| 785 |
2048 * recoil_values[player->readyweapon]); |
| 786 |
} |
| 787 |
|
| 788 |
// |
| 789 |
// A_GunFlash |
| 790 |
// |
| 791 |
|
| 792 |
void A_GunFlash(player_t *player, pspdef_t *psp) |
| 793 |
{ |
| 794 |
CHECK_WEAPON_CODEPOINTER("A_GunFlash", player); |
| 795 |
|
| 796 |
P_SetMobjState(player->mo, S_PLAY_ATK2); |
| 797 |
|
| 798 |
A_FireSomething(player,0); // phares |
| 799 |
} |
| 800 |
|
| 801 |
// |
| 802 |
// WEAPON ATTACKS |
| 803 |
// |
| 804 |
|
| 805 |
// |
| 806 |
// A_Punch |
| 807 |
// |
| 808 |
|
| 809 |
void A_Punch(player_t *player, pspdef_t *psp) |
| 810 |
{ |
| 811 |
angle_t angle; |
| 812 |
int t, slope, damage, range; |
| 813 |
|
| 814 |
CHECK_WEAPON_CODEPOINTER("A_Punch", player); |
| 815 |
|
| 816 |
damage = (P_Random(pr_punch)%10+1)<<1; |
| 817 |
|
| 818 |
if (player->powers[pw_strength]) |
| 819 |
damage *= 10; |
| 820 |
|
| 821 |
angle = player->mo->angle; |
| 822 |
|
| 823 |
// killough 5/5/98: remove dependence on order of evaluation: |
| 824 |
t = P_Random(pr_punchangle); |
| 825 |
angle += (t - P_Random(pr_punchangle))<<18; |
| 826 |
|
| 827 |
range = (mbf21 ? player->mo->info->meleerange : MELEERANGE); |
| 828 |
|
| 829 |
/* killough 8/2/98: make autoaiming prefer enemies */ |
| 830 |
if (!mbf_features || |
| 831 |
(slope = P_AimLineAttack(player->mo, angle, range, MF_FRIEND), |
| 832 |
!linetarget)) |
| 833 |
slope = P_AimLineAttack(player->mo, angle, range, 0); |
| 834 |
|
| 835 |
P_LineAttack(player->mo, angle, range, slope, damage); |
| 836 |
|
| 837 |
if (!linetarget) |
| 838 |
return; |
| 839 |
|
| 840 |
S_StartMobjSound(player->mo, sfx_punch); |
| 841 |
|
| 842 |
// turn to face target |
| 843 |
|
| 844 |
player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, |
| 845 |
linetarget->x, linetarget->y); |
| 846 |
R_SmoothPlaying_Reset(player); // e6y |
| 847 |
} |
| 848 |
|
| 849 |
// |
| 850 |
// A_Saw |
| 851 |
// |
| 852 |
|
| 853 |
void A_Saw(player_t *player, pspdef_t *psp) |
| 854 |
{ |
| 855 |
int slope, damage, range; |
| 856 |
angle_t angle; |
| 857 |
int t; |
| 858 |
|
| 859 |
CHECK_WEAPON_CODEPOINTER("A_Saw", player); |
| 860 |
|
| 861 |
damage = 2*(P_Random(pr_saw)%10+1); |
| 862 |
angle = player->mo->angle; |
| 863 |
// killough 5/5/98: remove dependence on order of evaluation: |
| 864 |
t = P_Random(pr_saw); |
| 865 |
angle += (t - P_Random(pr_saw))<<18; |
| 866 |
|
| 867 |
// Use meleerange + 1 so that the puff doesn't skip the flash |
| 868 |
range = (mbf21 ? player->mo->info->meleerange : MELEERANGE) + 1; |
| 869 |
|
| 870 |
/* killough 8/2/98: make autoaiming prefer enemies */ |
| 871 |
if (!mbf_features || |
| 872 |
(slope = P_AimLineAttack(player->mo, angle, range, MF_FRIEND), |
| 873 |
!linetarget)) |
| 874 |
slope = P_AimLineAttack(player->mo, angle, range, 0); |
| 875 |
|
| 876 |
P_LineAttack(player->mo, angle, range, slope, damage); |
| 877 |
|
| 878 |
if (!linetarget) |
| 879 |
{ |
| 880 |
S_StartMobjSound(player->mo, sfx_sawful); |
| 881 |
return; |
| 882 |
} |
| 883 |
|
| 884 |
S_StartMobjSound(player->mo, sfx_sawhit); |
| 885 |
|
| 886 |
// turn to face target |
| 887 |
angle = R_PointToAngle2(player->mo->x, player->mo->y, |
| 888 |
linetarget->x, linetarget->y); |
| 889 |
|
| 890 |
if (angle - player->mo->angle > ANG180) { |
| 891 |
if (angle - player->mo->angle < -ANG90/20) |
| 892 |
player->mo->angle = angle + ANG90/21; |
| 893 |
else |
| 894 |
player->mo->angle -= ANG90/20; |
| 895 |
} else { |
| 896 |
if (angle - player->mo->angle > ANG90/20) |
| 897 |
player->mo->angle = angle - ANG90/21; |
| 898 |
else |
| 899 |
player->mo->angle += ANG90/20; |
| 900 |
} |
| 901 |
|
| 902 |
player->mo->flags |= MF_JUSTATTACKED; |
| 903 |
R_SmoothPlaying_Reset(player); // e6y |
| 904 |
} |
| 905 |
|
| 906 |
// |
| 907 |
// A_FireMissile |
| 908 |
// |
| 909 |
|
| 910 |
void A_FireMissile(player_t *player, pspdef_t *psp) |
| 911 |
{ |
| 912 |
CHECK_WEAPON_CODEPOINTER("A_FireMissile", player); |
| 913 |
|
| 914 |
P_SubtractAmmo(player, 1); |
| 915 |
P_SpawnPlayerMissile(player->mo, MT_ROCKET); |
| 916 |
} |
| 917 |
|
| 918 |
// |
| 919 |
// A_FireBFG |
| 920 |
// |
| 921 |
|
| 922 |
void A_FireBFG(player_t *player, pspdef_t *psp) |
| 923 |
{ |
| 924 |
CHECK_WEAPON_CODEPOINTER("A_FireBFG", player); |
| 925 |
|
| 926 |
P_SubtractAmmo(player, BFGCELLS); |
| 927 |
P_SpawnPlayerMissile(player->mo, MT_BFG); |
| 928 |
} |
| 929 |
|
| 930 |
// |
| 931 |
// A_FireOldBFG |
| 932 |
// |
| 933 |
// This function emulates Doom's Pre-Beta BFG |
| 934 |
// By Lee Killough 6/6/98, 7/11/98, 7/19/98, 8/20/98 |
| 935 |
// |
| 936 |
// This code may not be used in other mods without appropriate credit given. |
| 937 |
// Code leeches will be telefragged. |
| 938 |
|
| 939 |
int autoaim = 0; // killough 7/19/98: autoaiming was not in original beta |
| 940 |
void A_FireOldBFG(player_t *player, pspdef_t *psp) |
| 941 |
{ |
| 942 |
int type = MT_PLASMA1; |
| 943 |
|
| 944 |
if (compatibility_level < mbf_compatibility) |
| 945 |
return; |
| 946 |
|
| 947 |
CHECK_WEAPON_CODEPOINTER("A_FireOldBFG", player); |
| 948 |
|
| 949 |
if (weapon_recoil && !(player->mo->flags & MF_NOCLIP)) |
| 950 |
P_ForwardThrust(player, ANG180 + player->mo->angle, |
| 951 |
512 * recoil_values[wp_plasma]); |
| 952 |
|
| 953 |
P_SubtractAmmo(player, 1); |
| 954 |
|
| 955 |
player->extralight = 2; |
| 956 |
|
| 957 |
do |
| 958 |
{ |
| 959 |
mobj_t *th, *mo = player->mo; |
| 960 |
angle_t an = mo->angle; |
| 961 |
angle_t an1 = ((P_Random(pr_bfg)&127) - 64) * (ANG90/768) + an; |
| 962 |
angle_t an2 = ((P_Random(pr_bfg)&127) - 64) * (ANG90/640) + ANG90; |
| 963 |
extern int autoaim; |
| 964 |
|
| 965 |
if (autoaim/* || !beta_emulation*/) |
| 966 |
{ |
| 967 |
// killough 8/2/98: make autoaiming prefer enemies |
| 968 |
uint64_t mask = mbf_features ? MF_FRIEND : 0; |
| 969 |
fixed_t slope; |
| 970 |
do |
| 971 |
{ |
| 972 |
slope = P_AimLineAttack(mo, an, 16*64*FRACUNIT, mask); |
| 973 |
if (!linetarget) |
| 974 |
slope = P_AimLineAttack(mo, an += 1<<26, 16*64*FRACUNIT, mask); |
| 975 |
if (!linetarget) |
| 976 |
slope = P_AimLineAttack(mo, an -= 2<<26, 16*64*FRACUNIT, mask); |
| 977 |
if (!linetarget) |
| 978 |
slope = 0, an = mo->angle; |
| 979 |
} |
| 980 |
while (mask && (mask=0, !linetarget)); // killough 8/2/98 |
| 981 |
an1 += an - mo->angle; |
| 982 |
an2 += tantoangle[slope >> DBITS]; |
| 983 |
} |
| 984 |
|
| 985 |
th = P_SpawnMobj(mo->x, mo->y, mo->z + 62*FRACUNIT - player->psprites[ps_weapon].sy, type); |
| 986 |
P_SetTarget(&th->target, mo); |
| 987 |
th->angle = an1; |
| 988 |
th->momx = finecosine[an1>>ANGLETOFINESHIFT] * 25; |
| 989 |
th->momy = finesine[an1>>ANGLETOFINESHIFT] * 25; |
| 990 |
th->momz = finetangent[an2>>ANGLETOFINESHIFT] * 25; |
| 991 |
P_CheckMissileSpawn(th); |
| 992 |
} |
| 993 |
while ((type != MT_PLASMA2) && (type = MT_PLASMA2)); //killough: obfuscated! |
| 994 |
} |
| 995 |
|
| 996 |
// |
| 997 |
// A_FirePlasma |
| 998 |
// |
| 999 |
|
| 1000 |
void A_FirePlasma(player_t *player, pspdef_t *psp) |
| 1001 |
{ |
| 1002 |
CHECK_WEAPON_CODEPOINTER("A_FirePlasma", player); |
| 1003 |
|
| 1004 |
P_SubtractAmmo(player, 1); |
| 1005 |
|
| 1006 |
A_FireSomething(player,P_Random(pr_plasma)&1); // phares |
| 1007 |
P_SpawnPlayerMissile(player->mo, MT_PLASMA); |
| 1008 |
} |
| 1009 |
|
| 1010 |
// |
| 1011 |
// P_BulletSlope |
| 1012 |
// Sets a slope so a near miss is at aproximately |
| 1013 |
// the height of the intended target |
| 1014 |
// |
| 1015 |
|
| 1016 |
//e6y static |
| 1017 |
fixed_t bulletslope; |
| 1018 |
|
| 1019 |
static void P_BulletSlope(mobj_t *mo) |
| 1020 |
{ |
| 1021 |
aim_t aim; |
| 1022 |
|
| 1023 |
dsda_PlayerAimBad(mo, mo->angle, &aim, mbf_features ? MF_FRIEND : 0); |
| 1024 |
|
| 1025 |
bulletslope = aim.slope; |
| 1026 |
} |
| 1027 |
|
| 1028 |
// |
| 1029 |
// P_GunShot |
| 1030 |
// |
| 1031 |
|
| 1032 |
static void P_GunShot(mobj_t *mo, dboolean accurate) |
| 1033 |
{ |
| 1034 |
int damage = 5*(P_Random(pr_gunshot)%3+1); |
| 1035 |
angle_t angle = mo->angle; |
| 1036 |
|
| 1037 |
if (!accurate) |
| 1038 |
{ // killough 5/5/98: remove dependence on order of evaluation: |
| 1039 |
int t = P_Random(pr_misfire); |
| 1040 |
angle += (t - P_Random(pr_misfire))<<18; |
| 1041 |
} |
| 1042 |
|
| 1043 |
P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); |
| 1044 |
} |
| 1045 |
|
| 1046 |
// |
| 1047 |
// A_FirePistol |
| 1048 |
// |
| 1049 |
|
| 1050 |
void A_FirePistol(player_t *player, pspdef_t *psp) |
| 1051 |
{ |
| 1052 |
CHECK_WEAPON_CODEPOINTER("A_FirePistol", player); |
| 1053 |
|
| 1054 |
S_StartMobjSound(player->mo, sfx_pistol); |
| 1055 |
|
| 1056 |
P_SetMobjState(player->mo, S_PLAY_ATK2); |
| 1057 |
P_SubtractAmmo(player, 1); |
| 1058 |
|
| 1059 |
A_FireSomething(player,0); // phares |
| 1060 |
P_BulletSlope(player->mo); |
| 1061 |
P_GunShot(player->mo, !player->refire); |
| 1062 |
} |
| 1063 |
|
| 1064 |
// |
| 1065 |
// A_FireShotgun |
| 1066 |
// |
| 1067 |
|
| 1068 |
void A_FireShotgun(player_t *player, pspdef_t *psp) |
| 1069 |
{ |
| 1070 |
int i; |
| 1071 |
|
| 1072 |
CHECK_WEAPON_CODEPOINTER("A_FireShotgun", player); |
| 1073 |
|
| 1074 |
S_StartMobjSound(player->mo, sfx_shotgn); |
| 1075 |
P_SetMobjState(player->mo, S_PLAY_ATK2); |
| 1076 |
|
| 1077 |
P_SubtractAmmo(player, 1); |
| 1078 |
|
| 1079 |
A_FireSomething(player,0); // phares |
| 1080 |
|
| 1081 |
P_BulletSlope(player->mo); |
| 1082 |
|
| 1083 |
for (i=0; i<7; i++) |
| 1084 |
P_GunShot(player->mo, false); |
| 1085 |
} |
| 1086 |
|
| 1087 |
// |
| 1088 |
// A_FireShotgun2 |
| 1089 |
// |
| 1090 |
|
| 1091 |
void A_FireShotgun2(player_t *player, pspdef_t *psp) |
| 1092 |
{ |
| 1093 |
int i; |
| 1094 |
|
| 1095 |
CHECK_WEAPON_CODEPOINTER("A_FireShotgun2", player); |
| 1096 |
|
| 1097 |
S_StartMobjSound(player->mo, sfx_dshtgn); |
| 1098 |
P_SetMobjState(player->mo, S_PLAY_ATK2); |
| 1099 |
P_SubtractAmmo(player, 2); |
| 1100 |
|
| 1101 |
A_FireSomething(player,0); // phares |
| 1102 |
|
| 1103 |
P_BulletSlope(player->mo); |
| 1104 |
|
| 1105 |
for (i=0; i<20; i++) |
| 1106 |
{ |
| 1107 |
int damage = 5*(P_Random(pr_shotgun)%3+1); |
| 1108 |
angle_t angle = player->mo->angle; |
| 1109 |
// killough 5/5/98: remove dependence on order of evaluation: |
| 1110 |
int t = P_Random(pr_shotgun); |
| 1111 |
angle += (t - P_Random(pr_shotgun))<<19; |
| 1112 |
t = P_Random(pr_shotgun); |
| 1113 |
P_LineAttack(player->mo, angle, MISSILERANGE, bulletslope + |
| 1114 |
((t - P_Random(pr_shotgun))<<5), damage); |
| 1115 |
} |
| 1116 |
} |
| 1117 |
|
| 1118 |
// |
| 1119 |
// A_FireCGun |
| 1120 |
// |
| 1121 |
|
| 1122 |
void A_FireCGun(player_t *player, pspdef_t *psp) |
| 1123 |
{ |
| 1124 |
dboolean has_ammo; |
| 1125 |
|
| 1126 |
CHECK_WEAPON_CODEPOINTER("A_FireCGun", player); |
| 1127 |
|
| 1128 |
has_ammo = player->ammo[weaponinfo[player->readyweapon].ammo] || |
| 1129 |
player->cheats & CF_INFINITE_AMMO; |
| 1130 |
|
| 1131 |
if (has_ammo || comp[comp_sound]) |
| 1132 |
S_StartMobjSound(player->mo, sfx_pistol); |
| 1133 |
|
| 1134 |
if (!has_ammo) |
| 1135 |
return; |
| 1136 |
|
| 1137 |
P_SetMobjState(player->mo, S_PLAY_ATK2); |
| 1138 |
P_SubtractAmmo(player, 1); |
| 1139 |
|
| 1140 |
A_FireSomething(player,psp->state - &states[S_CHAIN1]); // phares |
| 1141 |
|
| 1142 |
P_BulletSlope(player->mo); |
| 1143 |
|
| 1144 |
P_GunShot(player->mo, !player->refire); |
| 1145 |
} |
| 1146 |
|
| 1147 |
void A_Light0(player_t *player, pspdef_t *psp) |
| 1148 |
{ |
| 1149 |
CHECK_WEAPON_CODEPOINTER("A_Light0", player); |
| 1150 |
|
| 1151 |
player->extralight = 0; |
| 1152 |
} |
| 1153 |
|
| 1154 |
void A_Light1 (player_t *player, pspdef_t *psp) |
| 1155 |
{ |
| 1156 |
CHECK_WEAPON_CODEPOINTER("A_Light1", player); |
| 1157 |
|
| 1158 |
player->extralight = 1; |
| 1159 |
} |
| 1160 |
|
| 1161 |
void A_Light2 (player_t *player, pspdef_t *psp) |
| 1162 |
{ |
| 1163 |
CHECK_WEAPON_CODEPOINTER("A_Light2", player); |
| 1164 |
|
| 1165 |
player->extralight = 2; |
| 1166 |
} |
| 1167 |
|
| 1168 |
// |
| 1169 |
// A_BFGSpray |
| 1170 |
// Spawn a BFG explosion on every monster in view |
| 1171 |
// |
| 1172 |
|
| 1173 |
void A_BFGSpray(mobj_t *mo) |
| 1174 |
{ |
| 1175 |
int i; |
| 1176 |
|
| 1177 |
for (i=0 ; i<40 ; i++) // offset angles from its attack angle |
| 1178 |
{ |
| 1179 |
int j, damage; |
| 1180 |
angle_t an = mo->angle - ANG90/2 + ANG90/40*i; |
| 1181 |
|
| 1182 |
// mo->target is the originator (player) of the missile |
| 1183 |
|
| 1184 |
// killough 8/2/98: make autoaiming prefer enemies |
| 1185 |
if (!mbf_features || |
| 1186 |
(P_AimLineAttack(mo->target, an, 16*64*FRACUNIT, MF_FRIEND), |
| 1187 |
!linetarget)) |
| 1188 |
P_AimLineAttack(mo->target, an, 16*64*FRACUNIT, 0); |
| 1189 |
|
| 1190 |
if (!linetarget) |
| 1191 |
continue; |
| 1192 |
|
| 1193 |
P_SpawnMobj(linetarget->x, linetarget->y, |
| 1194 |
linetarget->z + (linetarget->height>>2), MT_EXTRABFG); |
| 1195 |
|
| 1196 |
for (damage=j=0; j<15; j++) |
| 1197 |
damage += (P_Random(pr_bfg)&7) + 1; |
| 1198 |
|
| 1199 |
P_DamageMobj(linetarget, mo->target, mo->target, damage); |
| 1200 |
} |
| 1201 |
} |
| 1202 |
|
| 1203 |
// |
| 1204 |
// A_BFGsound |
| 1205 |
// |
| 1206 |
|
| 1207 |
void A_BFGsound(player_t *player, pspdef_t *psp) |
| 1208 |
{ |
| 1209 |
CHECK_WEAPON_CODEPOINTER("A_BFGsound", player); |
| 1210 |
|
| 1211 |
S_StartMobjSound(player->mo, sfx_bfg); |
| 1212 |
} |
| 1213 |
|
| 1214 |
// |
| 1215 |
// [XA] New mbf21 codepointers |
| 1216 |
// |
| 1217 |
|
| 1218 |
// |
| 1219 |
// A_WeaponProjectile |
| 1220 |
// A parameterized player weapon projectile attack. Does not consume ammo. |
| 1221 |
// args[0]: Type of actor to spawn |
| 1222 |
// args[1]: Angle (degrees, in fixed point), relative to calling player's angle |
| 1223 |
// args[2]: Pitch (degrees, in fixed point), relative to calling player's pitch; approximated |
| 1224 |
// args[3]: X/Y spawn offset, relative to calling player's angle |
| 1225 |
// args[4]: Z spawn offset, relative to player's default projectile fire height |
| 1226 |
// |
| 1227 |
void A_WeaponProjectile(player_t *player, pspdef_t *psp) |
| 1228 |
{ |
| 1229 |
int type, angle, pitch, spawnofs_xy, spawnofs_z; |
| 1230 |
mobj_t *mo; |
| 1231 |
int an; |
| 1232 |
|
| 1233 |
CHECK_WEAPON_CODEPOINTER("A_WeaponProjectile", player); |
| 1234 |
|
| 1235 |
if (!mbf21 || !psp->state || !psp->state->args[0]) |
| 1236 |
return; |
| 1237 |
|
| 1238 |
type = psp->state->args[0] - 1; |
| 1239 |
angle = psp->state->args[1]; |
| 1240 |
pitch = psp->state->args[2]; |
| 1241 |
spawnofs_xy = psp->state->args[3]; |
| 1242 |
spawnofs_z = psp->state->args[4]; |
| 1243 |
|
| 1244 |
mo = P_SpawnPlayerMissile(player->mo, type); |
| 1245 |
if (!mo) |
| 1246 |
return; |
| 1247 |
|
| 1248 |
// adjust angle |
| 1249 |
mo->angle += (unsigned int)(((int64_t)angle << 16) / 360); |
| 1250 |
an = mo->angle >> ANGLETOFINESHIFT; |
| 1251 |
mo->momx = FixedMul(mo->info->speed, finecosine[an]); |
| 1252 |
mo->momy = FixedMul(mo->info->speed, finesine[an]); |
| 1253 |
|
| 1254 |
// adjust pitch (approximated, using Doom's ye olde |
| 1255 |
// finetangent table; same method as autoaim) |
| 1256 |
mo->momz += FixedMul(mo->info->speed, DegToSlope(pitch)); |
| 1257 |
|
| 1258 |
// adjust position |
| 1259 |
an = (player->mo->angle - ANG90) >> ANGLETOFINESHIFT; |
| 1260 |
mo->x += FixedMul(spawnofs_xy, finecosine[an]); |
| 1261 |
mo->y += FixedMul(spawnofs_xy, finesine[an]); |
| 1262 |
mo->z += spawnofs_z; |
| 1263 |
|
| 1264 |
// set tracer to the player's autoaim target, |
| 1265 |
// so player seeker missiles prioritizing the |
| 1266 |
// baddie the player is actually aiming at. ;) |
| 1267 |
P_SetTarget(&mo->tracer, linetarget); |
| 1268 |
} |
| 1269 |
|
| 1270 |
// |
| 1271 |
// A_WeaponBulletAttack |
| 1272 |
// A parameterized player weapon bullet attack. Does not consume ammo. |
| 1273 |
// args[0]: Horizontal spread (degrees, in fixed point) |
| 1274 |
// args[1]: Vertical spread (degrees, in fixed point) |
| 1275 |
// args[2]: Number of bullets to fire; if not set, defaults to 1 |
| 1276 |
// args[3]: Base damage of attack (e.g. for 5d3, customize the 5); if not set, defaults to 5 |
| 1277 |
// args[4]: Attack damage modulus (e.g. for 5d3, customize the 3); if not set, defaults to 3 |
| 1278 |
// |
| 1279 |
void A_WeaponBulletAttack(player_t *player, pspdef_t *psp) |
| 1280 |
{ |
| 1281 |
int hspread, vspread, numbullets, damagebase, damagemod; |
| 1282 |
int i, damage, angle, slope; |
| 1283 |
|
| 1284 |
CHECK_WEAPON_CODEPOINTER("A_WeaponBulletAttack", player); |
| 1285 |
|
| 1286 |
if (!mbf21 || !psp->state) |
| 1287 |
return; |
| 1288 |
|
| 1289 |
hspread = psp->state->args[0]; |
| 1290 |
vspread = psp->state->args[1]; |
| 1291 |
numbullets = psp->state->args[2]; |
| 1292 |
damagebase = psp->state->args[3]; |
| 1293 |
damagemod = psp->state->args[4]; |
| 1294 |
|
| 1295 |
P_BulletSlope(player->mo); |
| 1296 |
|
| 1297 |
for (i = 0; i < numbullets; i++) |
| 1298 |
{ |
| 1299 |
damage = (P_Random(pr_mbf21) % damagemod + 1) * damagebase; |
| 1300 |
angle = (int)player->mo->angle + P_RandomHitscanAngle(pr_mbf21, hspread); |
| 1301 |
slope = bulletslope + P_RandomHitscanSlope(pr_mbf21, vspread); |
| 1302 |
|
| 1303 |
P_LineAttack(player->mo, angle, MISSILERANGE, slope, damage); |
| 1304 |
} |
| 1305 |
} |
| 1306 |
|
| 1307 |
// |
| 1308 |
// A_WeaponMeleeAttack |
| 1309 |
// A parameterized player weapon melee attack. |
| 1310 |
// args[0]: Base damage of attack (e.g. for 2d10, customize the 2); if not set, defaults to 2 |
| 1311 |
// args[1]: Attack damage modulus (e.g. for 2d10, customize the 10); if not set, defaults to 10 |
| 1312 |
// args[2]: Berserk damage multiplier (fixed point); if not set, defaults to 1.0 (no change). |
| 1313 |
// args[3]: Sound to play if attack hits |
| 1314 |
// args[4]: Range (fixed point); if not set, defaults to player mobj's melee range |
| 1315 |
// |
| 1316 |
void A_WeaponMeleeAttack(player_t *player, pspdef_t *psp) |
| 1317 |
{ |
| 1318 |
int damagebase, damagemod, zerkfactor, hitsound, range; |
| 1319 |
angle_t angle; |
| 1320 |
int t, slope, damage; |
| 1321 |
|
| 1322 |
CHECK_WEAPON_CODEPOINTER("A_WeaponMeleeAttack", player); |
| 1323 |
|
| 1324 |
if (!mbf21 || !psp->state) |
| 1325 |
return; |
| 1326 |
|
| 1327 |
damagebase = psp->state->args[0]; |
| 1328 |
damagemod = psp->state->args[1]; |
| 1329 |
zerkfactor = psp->state->args[2]; |
| 1330 |
hitsound = psp->state->args[3]; |
| 1331 |
range = psp->state->args[4]; |
| 1332 |
|
| 1333 |
if (range == 0) |
| 1334 |
range = player->mo->info->meleerange; |
| 1335 |
|
| 1336 |
damage = (P_Random(pr_mbf21) % damagemod + 1) * damagebase; |
| 1337 |
if (player->powers[pw_strength]) |
| 1338 |
damage = (damage * zerkfactor) >> FRACBITS; |
| 1339 |
|
| 1340 |
// slight randomization; weird vanillaism here. :P |
| 1341 |
angle = player->mo->angle; |
| 1342 |
|
| 1343 |
t = P_Random(pr_mbf21); |
| 1344 |
angle += (t - P_Random(pr_mbf21))<<18; |
| 1345 |
|
| 1346 |
// make autoaim prefer enemies |
| 1347 |
slope = P_AimLineAttack(player->mo, angle, range, MF_FRIEND); |
| 1348 |
if (!linetarget) |
| 1349 |
slope = P_AimLineAttack(player->mo, angle, range, 0); |
| 1350 |
|
| 1351 |
// attack, dammit! |
| 1352 |
P_LineAttack(player->mo, angle, range, slope, damage); |
| 1353 |
|
| 1354 |
// missed? ah, welp. |
| 1355 |
if (!linetarget) |
| 1356 |
return; |
| 1357 |
|
| 1358 |
// un-missed! |
| 1359 |
S_StartMobjSound(player->mo, hitsound); |
| 1360 |
|
| 1361 |
// turn to face target |
| 1362 |
player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, linetarget->x, linetarget->y); |
| 1363 |
R_SmoothPlaying_Reset(player); |
| 1364 |
} |
| 1365 |
|
| 1366 |
// |
| 1367 |
// A_WeaponSound |
| 1368 |
// Plays a sound. Usable from weapons, unlike A_PlaySound |
| 1369 |
// args[0]: ID of sound to play |
| 1370 |
// args[1]: If 1, play sound at full volume (may be useful in DM?) |
| 1371 |
// |
| 1372 |
void A_WeaponSound(player_t *player, pspdef_t *psp) |
| 1373 |
{ |
| 1374 |
CHECK_WEAPON_CODEPOINTER("A_WeaponSound", player); |
| 1375 |
|
| 1376 |
if (!mbf21 || !psp->state) |
| 1377 |
return; |
| 1378 |
|
| 1379 |
S_StartMobjSound(psp->state->args[1] ? NULL : player->mo, psp->state->args[0]); |
| 1380 |
} |
| 1381 |
|
| 1382 |
// |
| 1383 |
// A_WeaponAlert |
| 1384 |
// Alerts monsters to the player's presence. Handy when combined with WPF_SILENT. |
| 1385 |
// |
| 1386 |
void A_WeaponAlert(player_t *player, pspdef_t *psp) |
| 1387 |
{ |
| 1388 |
CHECK_WEAPON_CODEPOINTER("A_WeaponAlert", player); |
| 1389 |
|
| 1390 |
if (!mbf21) |
| 1391 |
return; |
| 1392 |
|
| 1393 |
P_NoiseAlert(player->mo, player->mo); |
| 1394 |
} |
| 1395 |
|
| 1396 |
// |
| 1397 |
// A_WeaponJump |
| 1398 |
// Jumps to the specified state, with variable random chance. |
| 1399 |
// Basically the same as A_RandomJump, but for weapons. |
| 1400 |
// args[0]: State number |
| 1401 |
// args[1]: Chance, out of 255, to make the jump |
| 1402 |
// |
| 1403 |
void A_WeaponJump(player_t *player, pspdef_t *psp) |
| 1404 |
{ |
| 1405 |
CHECK_WEAPON_CODEPOINTER("A_WeaponJump", player); |
| 1406 |
|
| 1407 |
if (!mbf21 || !psp->state) |
| 1408 |
return; |
| 1409 |
|
| 1410 |
if (P_Random(pr_mbf21) < psp->state->args[1]) |
| 1411 |
P_SetPspritePtr(player, psp, psp->state->args[0]); |
| 1412 |
} |
| 1413 |
|
| 1414 |
// |
| 1415 |
// A_ConsumeAmmo |
| 1416 |
// Subtracts ammo from the player's "inventory". 'Nuff said. |
| 1417 |
// args[0]: Amount of ammo to consume. If zero, use the weapon's ammo-per-shot amount. |
| 1418 |
// |
| 1419 |
void A_ConsumeAmmo(player_t *player, pspdef_t *psp) |
| 1420 |
{ |
| 1421 |
int amount; |
| 1422 |
ammotype_t type; |
| 1423 |
|
| 1424 |
CHECK_WEAPON_CODEPOINTER("A_ConsumeAmmo", player); |
| 1425 |
|
| 1426 |
if (!mbf21) |
| 1427 |
return; |
| 1428 |
|
| 1429 |
// don't do dumb things, kids |
| 1430 |
type = weaponinfo[player->readyweapon].ammo; |
| 1431 |
if (player->cheats & CF_INFINITE_AMMO || !psp->state || type == am_noammo) |
| 1432 |
return; |
| 1433 |
|
| 1434 |
// use the weapon's ammo-per-shot amount if zero. |
| 1435 |
// to subtract zero ammo, don't call this function. ;) |
| 1436 |
if (psp->state->args[0] != 0) |
| 1437 |
amount = psp->state->args[0]; |
| 1438 |
else |
| 1439 |
amount = weaponinfo[player->readyweapon].ammopershot; |
| 1440 |
|
| 1441 |
// subtract ammo, but don't let it get below zero |
| 1442 |
if (player->ammo[type] >= amount) |
| 1443 |
player->ammo[type] -= amount; |
| 1444 |
else |
| 1445 |
player->ammo[type] = 0; |
| 1446 |
} |
| 1447 |
|
| 1448 |
// |
| 1449 |
// A_CheckAmmo |
| 1450 |
// Jumps to a state if the player's ammo is lower than the specified amount. |
| 1451 |
// args[0]: State to jump to |
| 1452 |
// args[1]: Minimum required ammo to NOT jump. If zero, use the weapon's ammo-per-shot amount. |
| 1453 |
// |
| 1454 |
void A_CheckAmmo(player_t *player, pspdef_t *psp) |
| 1455 |
{ |
| 1456 |
int amount; |
| 1457 |
ammotype_t type; |
| 1458 |
|
| 1459 |
CHECK_WEAPON_CODEPOINTER("A_CheckAmmo", player); |
| 1460 |
|
| 1461 |
if (!mbf21) |
| 1462 |
return; |
| 1463 |
|
| 1464 |
type = weaponinfo[player->readyweapon].ammo; |
| 1465 |
if (!psp->state || type == am_noammo) |
| 1466 |
return; |
| 1467 |
|
| 1468 |
if (psp->state->args[1] != 0) |
| 1469 |
amount = psp->state->args[1]; |
| 1470 |
else |
| 1471 |
amount = weaponinfo[player->readyweapon].ammopershot; |
| 1472 |
|
| 1473 |
if (player->ammo[type] < amount) |
| 1474 |
P_SetPspritePtr(player, psp, psp->state->args[0]); |
| 1475 |
} |
| 1476 |
|
| 1477 |
// |
| 1478 |
// A_RefireTo |
| 1479 |
// Jumps to a state if the player is holding down the fire button |
| 1480 |
// args[0]: State to jump to |
| 1481 |
// args[1]: If nonzero, skip the ammo check |
| 1482 |
// |
| 1483 |
void A_RefireTo(player_t *player, pspdef_t *psp) |
| 1484 |
{ |
| 1485 |
CHECK_WEAPON_CODEPOINTER("A_RefireTo", player); |
| 1486 |
|
| 1487 |
if (!mbf21 || !psp->state) |
| 1488 |
return; |
| 1489 |
|
| 1490 |
if ((psp->state->args[1] || P_CheckAmmo(player)) |
| 1491 |
&& (player->cmd.buttons & BT_ATTACK) |
| 1492 |
&& (player->pendingweapon == wp_nochange && player->health)) |
| 1493 |
P_SetPspritePtr(player, psp, psp->state->args[0]); |
| 1494 |
} |
| 1495 |
|
| 1496 |
// |
| 1497 |
// A_GunFlashTo |
| 1498 |
// Sets the weapon flash layer to the specified state. |
| 1499 |
// args[0]: State number |
| 1500 |
// args[1]: If nonzero, don't change the player actor state |
| 1501 |
// |
| 1502 |
void A_GunFlashTo(player_t *player, pspdef_t *psp) |
| 1503 |
{ |
| 1504 |
CHECK_WEAPON_CODEPOINTER("A_GunFlashTo", player); |
| 1505 |
|
| 1506 |
if (!mbf21 || !psp->state) |
| 1507 |
return; |
| 1508 |
|
| 1509 |
if(!psp->state->args[1]) |
| 1510 |
P_SetMobjState(player->mo, S_PLAY_ATK2); |
| 1511 |
|
| 1512 |
P_SetPsprite(player, ps_flash, psp->state->args[0]); |
| 1513 |
} |
| 1514 |
|
| 1515 |
// |
| 1516 |
// P_SetupPsprites |
| 1517 |
// Called at start of level for each player. |
| 1518 |
// |
| 1519 |
|
| 1520 |
void P_SetupPsprites(player_t *player) |
| 1521 |
{ |
| 1522 |
int i; |
| 1523 |
|
| 1524 |
// remove all psprites |
| 1525 |
for (i=0; i<NUMPSPRITES; i++) |
| 1526 |
player->psprites[i].state = NULL; |
| 1527 |
|
| 1528 |
// spawn the gun |
| 1529 |
player->pendingweapon = player->readyweapon; |
| 1530 |
P_BringUpWeapon(player); |
| 1531 |
} |
| 1532 |
|
| 1533 |
// |
| 1534 |
// P_MovePsprites |
| 1535 |
// Called every tic by player thinking routine. |
| 1536 |
// |
| 1537 |
|
| 1538 |
void P_MovePsprites(player_t *player) |
| 1539 |
{ |
| 1540 |
pspdef_t *psp = player->psprites; |
| 1541 |
int i; |
| 1542 |
|
| 1543 |
// a null state means not active |
| 1544 |
// drop tic count and possibly change state |
| 1545 |
// a -1 tic count never changes |
| 1546 |
|
| 1547 |
for (i=0; i<NUMPSPRITES; i++, psp++) |
| 1548 |
if (psp->state && psp->tics != -1 && !--psp->tics) |
| 1549 |
P_SetPsprite(player, i, psp->state->nextstate); |
| 1550 |
|
| 1551 |
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; |
| 1552 |
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; |
| 1553 |
} |
| 1554 |
|
| 1555 |
// heretic |
| 1556 |
|
| 1557 |
#include "heretic/def.h" |
| 1558 |
#include "p_user.h" |
| 1559 |
#include "p_maputl.h" |
| 1560 |
|
| 1561 |
#define MAGIC_JUNK 1234 |
| 1562 |
#define FLAME_THROWER_TICS 10*35 |
| 1563 |
|
| 1564 |
#define MAX_MACE_SPOTS 8 |
| 1565 |
|
| 1566 |
static int MaceSpotCount; |
| 1567 |
static struct |
| 1568 |
{ |
| 1569 |
fixed_t x; |
| 1570 |
fixed_t y; |
| 1571 |
} MaceSpots[MAX_MACE_SPOTS]; |
| 1572 |
|
| 1573 |
void A_BeakReady(player_t * player, pspdef_t * psp) |
| 1574 |
{ |
| 1575 |
if (player->cmd.buttons & BT_ATTACK) |
| 1576 |
{ // Chicken beak attack |
| 1577 |
player->attackdown = true; |
| 1578 |
P_SetMobjState(player->mo, HERETIC_S_CHICPLAY_ATK1); |
| 1579 |
if (player->powers[pw_weaponlevel2]) |
| 1580 |
{ |
| 1581 |
P_SetPsprite(player, ps_weapon, HERETIC_S_BEAKATK2_1); |
| 1582 |
} |
| 1583 |
else |
| 1584 |
{ |
| 1585 |
P_SetPsprite(player, ps_weapon, HERETIC_S_BEAKATK1_1); |
| 1586 |
} |
| 1587 |
P_NoiseAlert(player->mo, player->mo); |
| 1588 |
} |
| 1589 |
else |
| 1590 |
{ |
| 1591 |
if (player->mo->state == &states[HERETIC_S_CHICPLAY_ATK1]) |
| 1592 |
{ // Take out of attack state |
| 1593 |
P_SetMobjState(player->mo, HERETIC_S_CHICPLAY); |
| 1594 |
} |
| 1595 |
player->attackdown = false; |
| 1596 |
} |
| 1597 |
} |
| 1598 |
|
| 1599 |
void A_BeakRaise(player_t * player, pspdef_t * psp) |
| 1600 |
{ |
| 1601 |
psp->sy = WEAPONTOP; |
| 1602 |
P_SetPsprite(player, ps_weapon, |
| 1603 |
wpnlev1info[player->readyweapon].readystate); |
| 1604 |
} |
| 1605 |
|
| 1606 |
extern mobjtype_t PuffType; |
| 1607 |
|
| 1608 |
void A_BeakAttackPL1(player_t * player, pspdef_t * psp) |
| 1609 |
{ |
| 1610 |
angle_t angle; |
| 1611 |
int damage; |
| 1612 |
int slope; |
| 1613 |
|
| 1614 |
damage = 1 + (P_Random(pr_heretic) & 3); |
| 1615 |
angle = player->mo->angle; |
| 1616 |
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, 0); |
| 1617 |
PuffType = HERETIC_MT_BEAKPUFF; |
| 1618 |
P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); |
| 1619 |
if (linetarget) |
| 1620 |
{ |
| 1621 |
player->mo->angle = R_PointToAngle2(player->mo->x, |
| 1622 |
player->mo->y, linetarget->x, |
| 1623 |
linetarget->y); |
| 1624 |
} |
| 1625 |
S_StartMobjSound(player->mo, heretic_sfx_chicpk1 + (P_Random(pr_heretic) % 3)); |
| 1626 |
player->chickenPeck = 12; |
| 1627 |
psp->tics -= P_Random(pr_heretic) & 7; |
| 1628 |
} |
| 1629 |
|
| 1630 |
void A_BeakAttackPL2(player_t * player, pspdef_t * psp) |
| 1631 |
{ |
| 1632 |
angle_t angle; |
| 1633 |
int damage; |
| 1634 |
int slope; |
| 1635 |
|
| 1636 |
damage = HITDICE(4); |
| 1637 |
angle = player->mo->angle; |
| 1638 |
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, 0); |
| 1639 |
PuffType = HERETIC_MT_BEAKPUFF; |
| 1640 |
P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); |
| 1641 |
if (linetarget) |
| 1642 |
{ |
| 1643 |
player->mo->angle = R_PointToAngle2(player->mo->x, |
| 1644 |
player->mo->y, linetarget->x, |
| 1645 |
linetarget->y); |
| 1646 |
} |
| 1647 |
S_StartMobjSound(player->mo, heretic_sfx_chicpk1 + (P_Random(pr_heretic) % 3)); |
| 1648 |
player->chickenPeck = 12; |
| 1649 |
psp->tics -= P_Random(pr_heretic) & 3; |
| 1650 |
} |
| 1651 |
|
| 1652 |
void A_StaffAttackPL1(player_t * player, pspdef_t * psp) |
| 1653 |
{ |
| 1654 |
angle_t angle; |
| 1655 |
int damage; |
| 1656 |
int slope; |
| 1657 |
|
| 1658 |
damage = 5 + (P_Random(pr_heretic) & 15); |
| 1659 |
angle = player->mo->angle; |
| 1660 |
angle += P_SubRandom() << 18; |
| 1661 |
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, 0); |
| 1662 |
PuffType = HERETIC_MT_STAFFPUFF; |
| 1663 |
P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); |
| 1664 |
if (linetarget) |
| 1665 |
{ |
| 1666 |
//S_StartMobjSound(player->mo, sfx_stfhit); |
| 1667 |
// turn to face target |
| 1668 |
player->mo->angle = R_PointToAngle2(player->mo->x, |
| 1669 |
player->mo->y, linetarget->x, |
| 1670 |
linetarget->y); |
| 1671 |
R_SmoothPlaying_Reset(player); // e6y |
| 1672 |
} |
| 1673 |
} |
| 1674 |
|
| 1675 |
void A_StaffAttackPL2(player_t * player, pspdef_t * psp) |
| 1676 |
{ |
| 1677 |
angle_t angle; |
| 1678 |
int damage; |
| 1679 |
int slope; |
| 1680 |
|
| 1681 |
// P_inter.c:P_DamageMobj() handles target momentums |
| 1682 |
damage = 18 + (P_Random(pr_heretic) & 63); |
| 1683 |
angle = player->mo->angle; |
| 1684 |
angle += P_SubRandom() << 18; |
| 1685 |
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, 0); |
| 1686 |
PuffType = HERETIC_MT_STAFFPUFF2; |
| 1687 |
P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); |
| 1688 |
if (linetarget) |
| 1689 |
{ |
| 1690 |
//S_StartMobjSound(player->mo, sfx_stfpow); |
| 1691 |
// turn to face target |
| 1692 |
player->mo->angle = R_PointToAngle2(player->mo->x, |
| 1693 |
player->mo->y, linetarget->x, |
| 1694 |
linetarget->y); |
| 1695 |
R_SmoothPlaying_Reset(player); // e6y |
| 1696 |
} |
| 1697 |
} |
| 1698 |
|
| 1699 |
void A_FireBlasterPL1(player_t * player, pspdef_t * psp) |
| 1700 |
{ |
| 1701 |
mobj_t *mo; |
| 1702 |
angle_t angle; |
| 1703 |
int damage; |
| 1704 |
|
| 1705 |
mo = player->mo; |
| 1706 |
S_StartMobjSound(mo, heretic_sfx_gldhit); |
| 1707 |
player->ammo[am_blaster] -= USE_BLSR_AMMO_1; |
| 1708 |
P_BulletSlope(mo); |
| 1709 |
damage = HITDICE(4); |
| 1710 |
angle = mo->angle; |
| 1711 |
if (player->refire) |
| 1712 |
{ |
| 1713 |
angle += P_SubRandom() << 18; |
| 1714 |
} |
| 1715 |
PuffType = HERETIC_MT_BLASTERPUFF1; |
| 1716 |
P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); |
| 1717 |
S_StartMobjSound(player->mo, heretic_sfx_blssht); |
| 1718 |
} |
| 1719 |
|
| 1720 |
void A_FireBlasterPL2(player_t * player, pspdef_t * psp) |
| 1721 |
{ |
| 1722 |
mobj_t *mo; |
| 1723 |
|
| 1724 |
player->ammo[am_blaster] -= |
| 1725 |
deathmatch ? USE_BLSR_AMMO_1 : USE_BLSR_AMMO_2; |
| 1726 |
mo = P_SpawnPlayerMissile(player->mo, HERETIC_MT_BLASTERFX1); |
| 1727 |
if (mo) |
| 1728 |
{ |
| 1729 |
mo->thinker.function = P_BlasterMobjThinker; |
| 1730 |
} |
| 1731 |
S_StartMobjSound(player->mo, heretic_sfx_blssht); |
| 1732 |
} |
| 1733 |
|
| 1734 |
void A_FireGoldWandPL1(player_t * player, pspdef_t * psp) |
| 1735 |
{ |
| 1736 |
mobj_t *mo; |
| 1737 |
angle_t angle; |
| 1738 |
int damage; |
| 1739 |
|
| 1740 |
mo = player->mo; |
| 1741 |
player->ammo[am_goldwand] -= USE_GWND_AMMO_1; |
| 1742 |
P_BulletSlope(mo); |
| 1743 |
damage = 7 + (P_Random(pr_heretic) & 7); |
| 1744 |
angle = mo->angle; |
| 1745 |
if (player->refire) |
| 1746 |
{ |
| 1747 |
angle += P_SubRandom() << 18; |
| 1748 |
} |
| 1749 |
PuffType = HERETIC_MT_GOLDWANDPUFF1; |
| 1750 |
P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); |
| 1751 |
S_StartMobjSound(player->mo, heretic_sfx_gldhit); |
| 1752 |
} |
| 1753 |
|
| 1754 |
void A_FireGoldWandPL2(player_t * player, pspdef_t * psp) |
| 1755 |
{ |
| 1756 |
int i; |
| 1757 |
mobj_t *mo; |
| 1758 |
angle_t angle; |
| 1759 |
int damage; |
| 1760 |
fixed_t momz; |
| 1761 |
|
| 1762 |
mo = player->mo; |
| 1763 |
player->ammo[am_goldwand] -= |
| 1764 |
deathmatch ? USE_GWND_AMMO_1 : USE_GWND_AMMO_2; |
| 1765 |
PuffType = HERETIC_MT_GOLDWANDPUFF2; |
| 1766 |
P_BulletSlope(mo); |
| 1767 |
momz = FixedMul(mobjinfo[HERETIC_MT_GOLDWANDFX2].speed, bulletslope); |
| 1768 |
P_SpawnMissileAngle(mo, HERETIC_MT_GOLDWANDFX2, mo->angle - (ANG45 / 8), momz); |
| 1769 |
P_SpawnMissileAngle(mo, HERETIC_MT_GOLDWANDFX2, mo->angle + (ANG45 / 8), momz); |
| 1770 |
angle = mo->angle - (ANG45 / 8); |
| 1771 |
for (i = 0; i < 5; i++) |
| 1772 |
{ |
| 1773 |
damage = 1 + (P_Random(pr_heretic) & 7); |
| 1774 |
P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); |
| 1775 |
angle += ((ANG45 / 8) * 2) / 4; |
| 1776 |
} |
| 1777 |
S_StartMobjSound(player->mo, heretic_sfx_gldhit); |
| 1778 |
} |
| 1779 |
|
| 1780 |
void A_FireMacePL1B(player_t * player, pspdef_t * psp) |
| 1781 |
{ |
| 1782 |
mobj_t *pmo; |
| 1783 |
mobj_t *ball; |
| 1784 |
angle_t angle; |
| 1785 |
|
| 1786 |
if (player->ammo[am_mace] < USE_MACE_AMMO_1) |
| 1787 |
{ |
| 1788 |
return; |
| 1789 |
} |
| 1790 |
player->ammo[am_mace] -= USE_MACE_AMMO_1; |
| 1791 |
pmo = player->mo; |
| 1792 |
|
| 1793 |
// Vanilla bug here: |
| 1794 |
// Original code here looks like: |
| 1795 |
// (pmo->flags2 & MF2_FEETARECLIPPED != 0) |
| 1796 |
// C's operator precedence interprets this as: |
| 1797 |
// (pmo->flags2 & (MF2_FEETARECLIPPED != 0)) |
| 1798 |
// Which simplifies to: |
| 1799 |
// (pmo->flags2 & 1) |
| 1800 |
ball = P_SpawnMobj(pmo->x, pmo->y, pmo->z + 28 * FRACUNIT |
| 1801 |
- FOOTCLIPSIZE * (pmo->flags2 & 1), HERETIC_MT_MACEFX2); |
| 1802 |
|
| 1803 |
ball->momz = 2 * FRACUNIT + (dsda_PlayerLookDir(player) << (FRACBITS - 5)); |
| 1804 |
angle = pmo->angle; |
| 1805 |
P_SetTarget(&ball->target, pmo); |
| 1806 |
ball->angle = angle; |
| 1807 |
ball->z += dsda_PlayerLookDir(player) << (FRACBITS - 4); |
| 1808 |
angle >>= ANGLETOFINESHIFT; |
| 1809 |
ball->momx = (pmo->momx >> 1) |
| 1810 |
+ FixedMul(ball->info->speed, finecosine[angle]); |
| 1811 |
ball->momy = (pmo->momy >> 1) |
| 1812 |
+ FixedMul(ball->info->speed, finesine[angle]); |
| 1813 |
S_StartMobjSound(ball, heretic_sfx_lobsht); |
| 1814 |
P_CheckMissileSpawn(ball); |
| 1815 |
} |
| 1816 |
|
| 1817 |
void A_FireMacePL1(player_t * player, pspdef_t * psp) |
| 1818 |
{ |
| 1819 |
mobj_t *ball; |
| 1820 |
|
| 1821 |
if (P_Random(pr_heretic) < 28) |
| 1822 |
{ |
| 1823 |
A_FireMacePL1B(player, psp); |
| 1824 |
return; |
| 1825 |
} |
| 1826 |
if (player->ammo[am_mace] < USE_MACE_AMMO_1) |
| 1827 |
{ |
| 1828 |
return; |
| 1829 |
} |
| 1830 |
player->ammo[am_mace] -= USE_MACE_AMMO_1; |
| 1831 |
psp->sx = ((P_Random(pr_heretic) & 3) - 2) * FRACUNIT; |
| 1832 |
psp->sy = WEAPONTOP + (P_Random(pr_heretic) & 3) * FRACUNIT; |
| 1833 |
ball = P_SPMAngle(player->mo, HERETIC_MT_MACEFX1, player->mo->angle |
| 1834 |
+ (((P_Random(pr_heretic) & 7) - 4) << 24)); |
| 1835 |
if (ball) |
| 1836 |
{ |
| 1837 |
ball->special1.i = 16; // tics till dropoff |
| 1838 |
} |
| 1839 |
} |
| 1840 |
|
| 1841 |
void A_MacePL1Check(mobj_t * ball) |
| 1842 |
{ |
| 1843 |
angle_t angle; |
| 1844 |
|
| 1845 |
if (ball->special1.i == 0) |
| 1846 |
{ |
| 1847 |
return; |
| 1848 |
} |
| 1849 |
ball->special1.i -= 4; |
| 1850 |
if (ball->special1.i > 0) |
| 1851 |
{ |
| 1852 |
return; |
| 1853 |
} |
| 1854 |
ball->special1.i = 0; |
| 1855 |
ball->flags2 |= MF2_LOGRAV; |
| 1856 |
angle = ball->angle >> ANGLETOFINESHIFT; |
| 1857 |
ball->momx = FixedMul(7 * FRACUNIT, finecosine[angle]); |
| 1858 |
ball->momy = FixedMul(7 * FRACUNIT, finesine[angle]); |
| 1859 |
ball->momz -= ball->momz >> 1; |
| 1860 |
} |
| 1861 |
|
| 1862 |
void A_MaceBallImpact(mobj_t * ball) |
| 1863 |
{ |
| 1864 |
if ((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) |
| 1865 |
{ // Landed in some sort of liquid |
| 1866 |
P_RemoveMobj(ball); |
| 1867 |
return; |
| 1868 |
} |
| 1869 |
if ((ball->health != MAGIC_JUNK) && (ball->z <= ball->floorz) |
| 1870 |
&& ball->momz) |
| 1871 |
{ // Bounce |
| 1872 |
ball->health = MAGIC_JUNK; |
| 1873 |
ball->momz = (ball->momz * 192) >> 8; |
| 1874 |
ball->flags2 &= ~MF2_FLOORBOUNCE; |
| 1875 |
P_SetMobjState(ball, ball->info->spawnstate); |
| 1876 |
S_StartMobjSound(ball, heretic_sfx_bounce); |
| 1877 |
} |
| 1878 |
else |
| 1879 |
{ // Explode |
| 1880 |
ball->flags |= MF_NOGRAVITY; |
| 1881 |
ball->flags2 &= ~MF2_LOGRAV; |
| 1882 |
S_StartMobjSound(ball, heretic_sfx_lobhit); |
| 1883 |
} |
| 1884 |
} |
| 1885 |
|
| 1886 |
void A_MaceBallImpact2(mobj_t * ball) |
| 1887 |
{ |
| 1888 |
mobj_t *tiny; |
| 1889 |
angle_t angle; |
| 1890 |
|
| 1891 |
if ((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) |
| 1892 |
{ // Landed in some sort of liquid |
| 1893 |
P_RemoveMobj(ball); |
| 1894 |
return; |
| 1895 |
} |
| 1896 |
if ((ball->z != ball->floorz) || (ball->momz < 2 * FRACUNIT)) |
| 1897 |
{ // Explode |
| 1898 |
ball->momx = ball->momy = ball->momz = 0; |
| 1899 |
ball->flags |= MF_NOGRAVITY; |
| 1900 |
ball->flags2 &= ~(MF2_LOGRAV | MF2_FLOORBOUNCE); |
| 1901 |
} |
| 1902 |
else |
| 1903 |
{ // Bounce |
| 1904 |
ball->momz = (ball->momz * 192) >> 8; |
| 1905 |
P_SetMobjState(ball, ball->info->spawnstate); |
| 1906 |
|
| 1907 |
tiny = P_SpawnMobj(ball->x, ball->y, ball->z, HERETIC_MT_MACEFX3); |
| 1908 |
angle = ball->angle + ANG90; |
| 1909 |
P_SetTarget(&tiny->target, ball->target); |
| 1910 |
tiny->angle = angle; |
| 1911 |
angle >>= ANGLETOFINESHIFT; |
| 1912 |
tiny->momx = (ball->momx >> 1) + FixedMul(ball->momz - FRACUNIT, |
| 1913 |
finecosine[angle]); |
| 1914 |
tiny->momy = (ball->momy >> 1) + FixedMul(ball->momz - FRACUNIT, |
| 1915 |
finesine[angle]); |
| 1916 |
tiny->momz = ball->momz; |
| 1917 |
P_CheckMissileSpawn(tiny); |
| 1918 |
|
| 1919 |
tiny = P_SpawnMobj(ball->x, ball->y, ball->z, HERETIC_MT_MACEFX3); |
| 1920 |
angle = ball->angle - ANG90; |
| 1921 |
P_SetTarget(&tiny->target, ball->target); |
| 1922 |
tiny->angle = angle; |
| 1923 |
angle >>= ANGLETOFINESHIFT; |
| 1924 |
tiny->momx = (ball->momx >> 1) + FixedMul(ball->momz - FRACUNIT, |
| 1925 |
finecosine[angle]); |
| 1926 |
tiny->momy = (ball->momy >> 1) + FixedMul(ball->momz - FRACUNIT, |
| 1927 |
finesine[angle]); |
| 1928 |
tiny->momz = ball->momz; |
| 1929 |
P_CheckMissileSpawn(tiny); |
| 1930 |
} |
| 1931 |
} |
| 1932 |
|
| 1933 |
void A_FireMacePL2(player_t * player, pspdef_t * psp) |
| 1934 |
{ |
| 1935 |
mobj_t *mo; |
| 1936 |
|
| 1937 |
player->ammo[am_mace] -= deathmatch ? USE_MACE_AMMO_1 : USE_MACE_AMMO_2; |
| 1938 |
mo = P_SpawnPlayerMissile(player->mo, HERETIC_MT_MACEFX4); |
| 1939 |
if (mo) |
| 1940 |
{ |
| 1941 |
mo->momx += player->mo->momx; |
| 1942 |
mo->momy += player->mo->momy; |
| 1943 |
mo->momz = 2 * FRACUNIT + (dsda_PlayerLookDir(player) << (FRACBITS - 5)); |
| 1944 |
if (linetarget) |
| 1945 |
{ |
| 1946 |
P_SetTarget(&mo->special1.m, linetarget); |
| 1947 |
} |
| 1948 |
} |
| 1949 |
S_StartMobjSound(player->mo, heretic_sfx_lobsht); |
| 1950 |
} |
| 1951 |
|
| 1952 |
void A_DeathBallImpact(mobj_t * ball) |
| 1953 |
{ |
| 1954 |
int i; |
| 1955 |
mobj_t *target; |
| 1956 |
angle_t angle; |
| 1957 |
dboolean newAngle; |
| 1958 |
|
| 1959 |
if ((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) |
| 1960 |
{ // Landed in some sort of liquid |
| 1961 |
P_RemoveMobj(ball); |
| 1962 |
return; |
| 1963 |
} |
| 1964 |
if ((ball->z <= ball->floorz) && ball->momz) |
| 1965 |
{ // Bounce |
| 1966 |
newAngle = false; |
| 1967 |
target = (mobj_t *) ball->special1.m; |
| 1968 |
if (target) |
| 1969 |
{ |
| 1970 |
if (!(target->flags & MF_SHOOTABLE)) |
| 1971 |
{ // Target died |
| 1972 |
P_SetTarget(&ball->special1.m, NULL); |
| 1973 |
} |
| 1974 |
else |
| 1975 |
{ // Seek |
| 1976 |
angle = R_PointToAngle2(ball->x, ball->y, |
| 1977 |
target->x, target->y); |
| 1978 |
newAngle = true; |
| 1979 |
} |
| 1980 |
} |
| 1981 |
else |
| 1982 |
{ // Find new target |
| 1983 |
angle = 0; |
| 1984 |
for (i = 0; i < 16; i++) |
| 1985 |
{ |
| 1986 |
P_AimLineAttack(ball, angle, 10 * 64 * FRACUNIT, 0); |
| 1987 |
if (linetarget && ball->target != linetarget) |
| 1988 |
{ |
| 1989 |
P_SetTarget(&ball->special1.m, linetarget); |
| 1990 |
angle = R_PointToAngle2(ball->x, ball->y, |
| 1991 |
linetarget->x, linetarget->y); |
| 1992 |
newAngle = true; |
| 1993 |
break; |
| 1994 |
} |
| 1995 |
angle += ANG45 / 2; |
| 1996 |
} |
| 1997 |
} |
| 1998 |
if (newAngle) |
| 1999 |
{ |
| 2000 |
ball->angle = angle; |
| 2001 |
angle >>= ANGLETOFINESHIFT; |
| 2002 |
ball->momx = FixedMul(ball->info->speed, finecosine[angle]); |
| 2003 |
ball->momy = FixedMul(ball->info->speed, finesine[angle]); |
| 2004 |
} |
| 2005 |
P_SetMobjState(ball, ball->info->spawnstate); |
| 2006 |
S_StartMobjSound(ball, heretic_sfx_pstop); |
| 2007 |
} |
| 2008 |
else |
| 2009 |
{ // Explode |
| 2010 |
ball->flags |= MF_NOGRAVITY; |
| 2011 |
ball->flags2 &= ~MF2_LOGRAV; |
| 2012 |
S_StartMobjSound(ball, heretic_sfx_phohit); |
| 2013 |
} |
| 2014 |
} |
| 2015 |
|
| 2016 |
void A_SpawnRippers(mobj_t * actor) |
| 2017 |
{ |
| 2018 |
unsigned int i; |
| 2019 |
angle_t angle; |
| 2020 |
mobj_t *ripper; |
| 2021 |
|
| 2022 |
for (i = 0; i < 8; i++) |
| 2023 |
{ |
| 2024 |
ripper = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_RIPPER); |
| 2025 |
angle = i * ANG45; |
| 2026 |
P_SetTarget(&ripper->target, actor->target); |
| 2027 |
ripper->angle = angle; |
| 2028 |
angle >>= ANGLETOFINESHIFT; |
| 2029 |
ripper->momx = FixedMul(ripper->info->speed, finecosine[angle]); |
| 2030 |
ripper->momy = FixedMul(ripper->info->speed, finesine[angle]); |
| 2031 |
P_CheckMissileSpawn(ripper); |
| 2032 |
} |
| 2033 |
} |
| 2034 |
|
| 2035 |
void A_FireCrossbowPL1(player_t * player, pspdef_t * psp) |
| 2036 |
{ |
| 2037 |
mobj_t *pmo; |
| 2038 |
|
| 2039 |
pmo = player->mo; |
| 2040 |
player->ammo[am_crossbow] -= USE_CBOW_AMMO_1; |
| 2041 |
P_SpawnPlayerMissile(pmo, HERETIC_MT_CRBOWFX1); |
| 2042 |
P_SPMAngle(pmo, HERETIC_MT_CRBOWFX3, pmo->angle - (ANG45 / 10)); |
| 2043 |
P_SPMAngle(pmo, HERETIC_MT_CRBOWFX3, pmo->angle + (ANG45 / 10)); |
| 2044 |
} |
| 2045 |
|
| 2046 |
void A_FireCrossbowPL2(player_t * player, pspdef_t * psp) |
| 2047 |
{ |
| 2048 |
mobj_t *pmo; |
| 2049 |
|
| 2050 |
pmo = player->mo; |
| 2051 |
player->ammo[am_crossbow] -= |
| 2052 |
deathmatch ? USE_CBOW_AMMO_1 : USE_CBOW_AMMO_2; |
| 2053 |
P_SpawnPlayerMissile(pmo, HERETIC_MT_CRBOWFX2); |
| 2054 |
P_SPMAngle(pmo, HERETIC_MT_CRBOWFX2, pmo->angle - (ANG45 / 10)); |
| 2055 |
P_SPMAngle(pmo, HERETIC_MT_CRBOWFX2, pmo->angle + (ANG45 / 10)); |
| 2056 |
P_SPMAngle(pmo, HERETIC_MT_CRBOWFX3, pmo->angle - (ANG45 / 5)); |
| 2057 |
P_SPMAngle(pmo, HERETIC_MT_CRBOWFX3, pmo->angle + (ANG45 / 5)); |
| 2058 |
} |
| 2059 |
|
| 2060 |
void A_BoltSpark(mobj_t * bolt) |
| 2061 |
{ |
| 2062 |
mobj_t *spark; |
| 2063 |
|
| 2064 |
if (P_Random(pr_heretic) > 50) |
| 2065 |
{ |
| 2066 |
spark = P_SpawnMobj(bolt->x, bolt->y, bolt->z, HERETIC_MT_CRBOWFX4); |
| 2067 |
spark->x += P_SubRandom() << 10; |
| 2068 |
spark->y += P_SubRandom() << 10; |
| 2069 |
} |
| 2070 |
} |
| 2071 |
|
| 2072 |
void A_FireSkullRodPL1(player_t * player, pspdef_t * psp) |
| 2073 |
{ |
| 2074 |
mobj_t *mo; |
| 2075 |
|
| 2076 |
if (player->ammo[am_skullrod] < USE_SKRD_AMMO_1) |
| 2077 |
{ |
| 2078 |
return; |
| 2079 |
} |
| 2080 |
player->ammo[am_skullrod] -= USE_SKRD_AMMO_1; |
| 2081 |
mo = P_SpawnPlayerMissile(player->mo, HERETIC_MT_HORNRODFX1); |
| 2082 |
// Randomize the first frame |
| 2083 |
if (mo && P_Random(pr_heretic) > 128) |
| 2084 |
{ |
| 2085 |
P_SetMobjState(mo, HERETIC_S_HRODFX1_2); |
| 2086 |
} |
| 2087 |
} |
| 2088 |
|
| 2089 |
void A_FireSkullRodPL2(player_t * player, pspdef_t * psp) |
| 2090 |
{ |
| 2091 |
player->ammo[am_skullrod] -= |
| 2092 |
deathmatch ? USE_SKRD_AMMO_1 : USE_SKRD_AMMO_2; |
| 2093 |
P_SpawnPlayerMissile(player->mo, HERETIC_MT_HORNRODFX2); |
| 2094 |
// Use MissileMobj instead of the return value from |
| 2095 |
// P_SpawnPlayerMissile because we need to give info to the mobj |
| 2096 |
// even if it exploded immediately. |
| 2097 |
if (netgame) |
| 2098 |
{ // Multi-player game |
| 2099 |
MissileMobj->special2.i = P_GetPlayerNum(player); |
| 2100 |
} |
| 2101 |
else |
| 2102 |
{ // Always use red missiles in single player games |
| 2103 |
MissileMobj->special2.i = 2; |
| 2104 |
} |
| 2105 |
if (linetarget) |
| 2106 |
{ |
| 2107 |
P_SetTarget(&MissileMobj->special1.m, linetarget); |
| 2108 |
} |
| 2109 |
S_StartMobjSound(MissileMobj, heretic_sfx_hrnpow); |
| 2110 |
} |
| 2111 |
|
| 2112 |
void A_SkullRodPL2Seek(mobj_t * actor) |
| 2113 |
{ |
| 2114 |
P_SeekerMissile(actor, &actor->special1.m, ANG1_X * 10, ANG1_X * 30, false); |
| 2115 |
} |
| 2116 |
|
| 2117 |
void A_AddPlayerRain(mobj_t * actor) |
| 2118 |
{ |
| 2119 |
int playerNum; |
| 2120 |
player_t *player; |
| 2121 |
|
| 2122 |
playerNum = netgame ? actor->special2.i : 0; |
| 2123 |
if (!playeringame[playerNum]) |
| 2124 |
{ // Player left the game |
| 2125 |
return; |
| 2126 |
} |
| 2127 |
player = &players[playerNum]; |
| 2128 |
if (player->health <= 0) |
| 2129 |
{ // Player is dead |
| 2130 |
return; |
| 2131 |
} |
| 2132 |
if (player->rain1 && player->rain2) |
| 2133 |
{ // Terminate an active rain |
| 2134 |
if (player->rain1->health < player->rain2->health) |
| 2135 |
{ |
| 2136 |
if (player->rain1->health > 16) |
| 2137 |
{ |
| 2138 |
player->rain1->health = 16; |
| 2139 |
} |
| 2140 |
player->rain1 = NULL; |
| 2141 |
} |
| 2142 |
else |
| 2143 |
{ |
| 2144 |
if (player->rain2->health > 16) |
| 2145 |
{ |
| 2146 |
player->rain2->health = 16; |
| 2147 |
} |
| 2148 |
player->rain2 = NULL; |
| 2149 |
} |
| 2150 |
} |
| 2151 |
// Add rain mobj to list |
| 2152 |
if (player->rain1) |
| 2153 |
{ |
| 2154 |
player->rain2 = actor; |
| 2155 |
} |
| 2156 |
else |
| 2157 |
{ |
| 2158 |
player->rain1 = actor; |
| 2159 |
} |
| 2160 |
} |
| 2161 |
|
| 2162 |
void A_SkullRodStorm(mobj_t * actor) |
| 2163 |
{ |
| 2164 |
fixed_t x; |
| 2165 |
fixed_t y; |
| 2166 |
mobj_t *mo; |
| 2167 |
int playerNum; |
| 2168 |
player_t *player; |
| 2169 |
|
| 2170 |
if (actor->health-- == 0) |
| 2171 |
{ |
| 2172 |
P_SetMobjState(actor, g_s_null); |
| 2173 |
playerNum = netgame ? actor->special2.i : 0; |
| 2174 |
if (!playeringame[playerNum]) |
| 2175 |
{ // Player left the game |
| 2176 |
return; |
| 2177 |
} |
| 2178 |
player = &players[playerNum]; |
| 2179 |
if (player->health <= 0) |
| 2180 |
{ // Player is dead |
| 2181 |
return; |
| 2182 |
} |
| 2183 |
if (player->rain1 == actor) |
| 2184 |
{ |
| 2185 |
player->rain1 = NULL; |
| 2186 |
} |
| 2187 |
else if (player->rain2 == actor) |
| 2188 |
{ |
| 2189 |
player->rain2 = NULL; |
| 2190 |
} |
| 2191 |
return; |
| 2192 |
} |
| 2193 |
if (P_Random(pr_heretic) < 25) |
| 2194 |
{ // Fudge rain frequency |
| 2195 |
return; |
| 2196 |
} |
| 2197 |
x = actor->x + ((P_Random(pr_heretic) & 127) - 64) * FRACUNIT; |
| 2198 |
y = actor->y + ((P_Random(pr_heretic) & 127) - 64) * FRACUNIT; |
| 2199 |
mo = P_SpawnMobj(x, y, ONCEILINGZ, HERETIC_MT_RAINPLR1 + actor->special2.i); |
| 2200 |
P_SetTarget(&mo->target, actor->target); |
| 2201 |
mo->momx = 1; // Force collision detection |
| 2202 |
mo->momz = -mo->info->speed; |
| 2203 |
mo->special2.i = actor->special2.i; // Transfer player number |
| 2204 |
P_CheckMissileSpawn(mo); |
| 2205 |
if (!(actor->special1.i & 31)) |
| 2206 |
{ |
| 2207 |
S_StartMobjSound(actor, heretic_sfx_ramrain); |
| 2208 |
} |
| 2209 |
actor->special1.i++; |
| 2210 |
} |
| 2211 |
|
| 2212 |
void A_RainImpact(mobj_t * actor) |
| 2213 |
{ |
| 2214 |
if (actor->z > actor->floorz) |
| 2215 |
{ |
| 2216 |
P_SetMobjState(actor, HERETIC_S_RAINAIRXPLR1_1 + actor->special2.i); |
| 2217 |
} |
| 2218 |
else if (P_Random(pr_heretic) < 40) |
| 2219 |
{ |
| 2220 |
P_HitFloor(actor); |
| 2221 |
} |
| 2222 |
} |
| 2223 |
|
| 2224 |
void A_HideInCeiling(mobj_t * actor) |
| 2225 |
{ |
| 2226 |
actor->z = actor->ceilingz + 4 * FRACUNIT; |
| 2227 |
} |
| 2228 |
|
| 2229 |
void A_FirePhoenixPL1(player_t * player, pspdef_t * psp) |
| 2230 |
{ |
| 2231 |
angle_t angle; |
| 2232 |
|
| 2233 |
player->ammo[am_phoenixrod] -= USE_PHRD_AMMO_1; |
| 2234 |
P_SpawnPlayerMissile(player->mo, HERETIC_MT_PHOENIXFX1); |
| 2235 |
angle = player->mo->angle + ANG180; |
| 2236 |
angle >>= ANGLETOFINESHIFT; |
| 2237 |
player->mo->momx += FixedMul(4 * FRACUNIT, finecosine[angle]); |
| 2238 |
player->mo->momy += FixedMul(4 * FRACUNIT, finesine[angle]); |
| 2239 |
} |
| 2240 |
|
| 2241 |
void A_PhoenixPuff(mobj_t * actor) |
| 2242 |
{ |
| 2243 |
mobj_t *puff; |
| 2244 |
angle_t angle; |
| 2245 |
|
| 2246 |
P_SeekerMissile(actor, &actor->special1.m, ANG1_X * 5, ANG1_X * 10, false); |
| 2247 |
puff = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_PHOENIXPUFF); |
| 2248 |
angle = actor->angle + ANG90; |
| 2249 |
angle >>= ANGLETOFINESHIFT; |
| 2250 |
puff->momx = FixedMul((fixed_t)(FRACUNIT * 1.3), finecosine[angle]); |
| 2251 |
puff->momy = FixedMul((fixed_t)(FRACUNIT * 1.3), finesine[angle]); |
| 2252 |
puff->momz = 0; |
| 2253 |
puff = P_SpawnMobj(actor->x, actor->y, actor->z, HERETIC_MT_PHOENIXPUFF); |
| 2254 |
angle = actor->angle - ANG90; |
| 2255 |
angle >>= ANGLETOFINESHIFT; |
| 2256 |
puff->momx = FixedMul((fixed_t)(FRACUNIT * 1.3), finecosine[angle]); |
| 2257 |
puff->momy = FixedMul((fixed_t)(FRACUNIT * 1.3), finesine[angle]); |
| 2258 |
puff->momz = 0; |
| 2259 |
} |
| 2260 |
|
| 2261 |
// |
| 2262 |
// This function was present in the Heretic 1.0 executable for the |
| 2263 |
// removed "secondary phoenix flash" object (MT_PHOENIXFX_REMOVED). |
| 2264 |
// The purpose of this object is unknown, as is this function. |
| 2265 |
// |
| 2266 |
|
| 2267 |
void A_RemovedPhoenixFunc(mobj_t *actor) |
| 2268 |
{ |
| 2269 |
return; |
| 2270 |
} |
| 2271 |
|
| 2272 |
void A_InitPhoenixPL2(player_t * player, pspdef_t * psp) |
| 2273 |
{ |
| 2274 |
player->flamecount = FLAME_THROWER_TICS; |
| 2275 |
} |
| 2276 |
|
| 2277 |
void A_FirePhoenixPL2(player_t * player, pspdef_t * psp) |
| 2278 |
{ |
| 2279 |
mobj_t *mo; |
| 2280 |
mobj_t *pmo; |
| 2281 |
angle_t angle; |
| 2282 |
fixed_t x, y, z; |
| 2283 |
fixed_t slope; |
| 2284 |
|
| 2285 |
if (--player->flamecount == 0) |
| 2286 |
{ // Out of flame |
| 2287 |
P_SetPsprite(player, ps_weapon, HERETIC_S_PHOENIXATK2_4); |
| 2288 |
player->refire = 0; |
| 2289 |
return; |
| 2290 |
} |
| 2291 |
pmo = player->mo; |
| 2292 |
angle = pmo->angle; |
| 2293 |
x = pmo->x + (P_SubRandom() << 9); |
| 2294 |
y = pmo->y + (P_SubRandom() << 9); |
| 2295 |
z = pmo->z + 26 * FRACUNIT + dsda_PlayerSlope(player); |
| 2296 |
if (pmo->flags2 & MF2_FEETARECLIPPED) |
| 2297 |
{ |
| 2298 |
z -= FOOTCLIPSIZE; |
| 2299 |
} |
| 2300 |
slope = dsda_PlayerSlope(player) + (FRACUNIT / 10); |
| 2301 |
mo = P_SpawnMobj(x, y, z, HERETIC_MT_PHOENIXFX2); |
| 2302 |
P_SetTarget(&mo->target, pmo); |
| 2303 |
mo->angle = angle; |
| 2304 |
mo->momx = pmo->momx + FixedMul(mo->info->speed, |
| 2305 |
finecosine[angle >> ANGLETOFINESHIFT]); |
| 2306 |
mo->momy = pmo->momy + FixedMul(mo->info->speed, |
| 2307 |
finesine[angle >> ANGLETOFINESHIFT]); |
| 2308 |
mo->momz = FixedMul(mo->info->speed, slope); |
| 2309 |
if (!player->refire || !(leveltime % 38)) |
| 2310 |
{ |
| 2311 |
S_StartMobjSound(player->mo, heretic_sfx_phopow); |
| 2312 |
} |
| 2313 |
P_CheckMissileSpawn(mo); |
| 2314 |
} |
| 2315 |
|
| 2316 |
void A_ShutdownPhoenixPL2(player_t * player, pspdef_t * psp) |
| 2317 |
{ |
| 2318 |
player->ammo[am_phoenixrod] -= USE_PHRD_AMMO_2; |
| 2319 |
} |
| 2320 |
|
| 2321 |
void A_FlameEnd(mobj_t * actor) |
| 2322 |
{ |
| 2323 |
actor->momz += (fixed_t)(1.5 * FRACUNIT); |
| 2324 |
} |
| 2325 |
|
| 2326 |
void A_FloatPuff(mobj_t * puff) |
| 2327 |
{ |
| 2328 |
puff->momz += (fixed_t)(1.8 * FRACUNIT); |
| 2329 |
} |
| 2330 |
|
| 2331 |
void A_GauntletAttack(player_t * player, pspdef_t * psp) |
| 2332 |
{ |
| 2333 |
angle_t angle; |
| 2334 |
int damage; |
| 2335 |
int slope; |
| 2336 |
int randVal; |
| 2337 |
fixed_t dist; |
| 2338 |
|
| 2339 |
psp->sx = ((P_Random(pr_heretic) & 3) - 2) * FRACUNIT; |
| 2340 |
psp->sy = WEAPONTOP + (P_Random(pr_heretic) & 3) * FRACUNIT; |
| 2341 |
angle = player->mo->angle; |
| 2342 |
if (player->powers[pw_weaponlevel2]) |
| 2343 |
{ |
| 2344 |
damage = HITDICE(2); |
| 2345 |
dist = 4 * MELEERANGE; |
| 2346 |
angle += P_SubRandom() << 17; |
| 2347 |
PuffType = HERETIC_MT_GAUNTLETPUFF2; |
| 2348 |
} |
| 2349 |
else |
| 2350 |
{ |
| 2351 |
damage = HITDICE(2); |
| 2352 |
dist = MELEERANGE + 1; |
| 2353 |
angle += P_SubRandom() << 18; |
| 2354 |
PuffType = HERETIC_MT_GAUNTLETPUFF1; |
| 2355 |
} |
| 2356 |
slope = P_AimLineAttack(player->mo, angle, dist, 0); |
| 2357 |
P_LineAttack(player->mo, angle, dist, slope, damage); |
| 2358 |
if (!linetarget) |
| 2359 |
{ |
| 2360 |
if (P_Random(pr_heretic) > 64) |
| 2361 |
{ |
| 2362 |
player->extralight = !player->extralight; |
| 2363 |
} |
| 2364 |
S_StartMobjSound(player->mo, heretic_sfx_gntful); |
| 2365 |
return; |
| 2366 |
} |
| 2367 |
randVal = P_Random(pr_heretic); |
| 2368 |
if (randVal < 64) |
| 2369 |
{ |
| 2370 |
player->extralight = 0; |
| 2371 |
} |
| 2372 |
else if (randVal < 160) |
| 2373 |
{ |
| 2374 |
player->extralight = 1; |
| 2375 |
} |
| 2376 |
else |
| 2377 |
{ |
| 2378 |
player->extralight = 2; |
| 2379 |
} |
| 2380 |
if (player->powers[pw_weaponlevel2]) |
| 2381 |
{ |
| 2382 |
P_GiveBody(player, damage >> 1); |
| 2383 |
S_StartMobjSound(player->mo, heretic_sfx_gntpow); |
| 2384 |
} |
| 2385 |
else |
| 2386 |
{ |
| 2387 |
S_StartMobjSound(player->mo, heretic_sfx_gnthit); |
| 2388 |
} |
| 2389 |
// turn to face target |
| 2390 |
angle = R_PointToAngle2(player->mo->x, player->mo->y, |
| 2391 |
linetarget->x, linetarget->y); |
| 2392 |
if (angle - player->mo->angle > ANG180) |
| 2393 |
{ |
| 2394 |
if (angle - player->mo->angle < -ANG90 / 20) |
| 2395 |
player->mo->angle = angle + ANG90 / 21; |
| 2396 |
else |
| 2397 |
player->mo->angle -= ANG90 / 20; |
| 2398 |
} |
| 2399 |
else |
| 2400 |
{ |
| 2401 |
if (angle - player->mo->angle > ANG90 / 20) |
| 2402 |
player->mo->angle = angle - ANG90 / 21; |
| 2403 |
else |
| 2404 |
player->mo->angle += ANG90 / 20; |
| 2405 |
} |
| 2406 |
player->mo->flags |= MF_JUSTATTACKED; |
| 2407 |
R_SmoothPlaying_Reset(player); // e6y |
| 2408 |
} |
| 2409 |
|
| 2410 |
void P_RepositionMace(mobj_t * mo) |
| 2411 |
{ |
| 2412 |
int spot; |
| 2413 |
sector_t *sec; |
| 2414 |
|
| 2415 |
P_UnsetThingPosition(mo); |
| 2416 |
spot = P_Random(pr_heretic) % MaceSpotCount; |
| 2417 |
mo->x = MaceSpots[spot].x; |
| 2418 |
mo->y = MaceSpots[spot].y; |
| 2419 |
sec = R_PointInSector(mo->x, mo->y); |
| 2420 |
mo->z = mo->floorz = sec->floorheight; |
| 2421 |
mo->ceilingz = sec->ceilingheight; |
| 2422 |
P_SetThingPosition(mo); |
| 2423 |
} |
| 2424 |
|
| 2425 |
void P_ActivateBeak(player_t * player) |
| 2426 |
{ |
| 2427 |
player->pendingweapon = wp_nochange; |
| 2428 |
player->readyweapon = wp_beak; |
| 2429 |
player->psprites[ps_weapon].sy = WEAPONTOP; |
| 2430 |
P_SetPsprite(player, ps_weapon, HERETIC_S_BEAKREADY); |
| 2431 |
} |
| 2432 |
|
| 2433 |
void P_PostChickenWeapon(player_t * player, weapontype_t weapon) |
| 2434 |
{ |
| 2435 |
if (weapon == wp_beak) |
| 2436 |
{ // Should never happen |
| 2437 |
weapon = wp_staff; |
| 2438 |
} |
| 2439 |
player->pendingweapon = wp_nochange; |
| 2440 |
player->readyweapon = weapon; |
| 2441 |
player->psprites[ps_weapon].sy = WEAPONBOTTOM; |
| 2442 |
P_SetPsprite(player, ps_weapon, wpnlev1info[weapon].upstate); |
| 2443 |
} |
| 2444 |
|
| 2445 |
void P_UpdateBeak(player_t * player, pspdef_t * psp) |
| 2446 |
{ |
| 2447 |
psp->sy = WEAPONTOP + (player->chickenPeck << (FRACBITS - 1)); |
| 2448 |
} |
| 2449 |
|
| 2450 |
static dboolean Heretic_P_CheckAmmo(player_t * player) |
| 2451 |
{ |
| 2452 |
ammotype_t ammo; |
| 2453 |
weaponinfo_t *checkweaponinfo; |
| 2454 |
int count; |
| 2455 |
|
| 2456 |
ammo = wpnlev1info[player->readyweapon].ammo; |
| 2457 |
if (player->powers[pw_weaponlevel2] && !deathmatch) |
| 2458 |
{ |
| 2459 |
checkweaponinfo = wpnlev2info; |
| 2460 |
} |
| 2461 |
else |
| 2462 |
{ |
| 2463 |
checkweaponinfo = wpnlev1info; |
| 2464 |
} |
| 2465 |
count = checkweaponinfo[player->readyweapon].ammopershot; |
| 2466 |
if (ammo == am_noammo || player->ammo[ammo] >= count) |
| 2467 |
{ |
| 2468 |
return (true); |
| 2469 |
} |
| 2470 |
// out of ammo, pick a weapon to change to |
| 2471 |
do |
| 2472 |
{ |
| 2473 |
if (player->weaponowned[wp_skullrod] |
| 2474 |
&& player->ammo[am_skullrod] > checkweaponinfo[wp_skullrod].ammopershot) |
| 2475 |
{ |
| 2476 |
player->pendingweapon = wp_skullrod; |
| 2477 |
} |
| 2478 |
else if (player->weaponowned[wp_blaster] |
| 2479 |
&& player->ammo[am_blaster] > checkweaponinfo[wp_blaster].ammopershot) |
| 2480 |
{ |
| 2481 |
player->pendingweapon = wp_blaster; |
| 2482 |
} |
| 2483 |
else if (player->weaponowned[wp_crossbow] |
| 2484 |
&& player->ammo[am_crossbow] > checkweaponinfo[wp_crossbow].ammopershot) |
| 2485 |
{ |
| 2486 |
player->pendingweapon = wp_crossbow; |
| 2487 |
} |
| 2488 |
else if (player->weaponowned[wp_mace] |
| 2489 |
&& player->ammo[am_mace] > checkweaponinfo[wp_mace].ammopershot) |
| 2490 |
{ |
| 2491 |
player->pendingweapon = wp_mace; |
| 2492 |
} |
| 2493 |
else if (player->ammo[am_goldwand] > checkweaponinfo[wp_goldwand].ammopershot) |
| 2494 |
{ |
| 2495 |
player->pendingweapon = wp_goldwand; |
| 2496 |
} |
| 2497 |
else if (player->weaponowned[wp_gauntlets]) |
| 2498 |
{ |
| 2499 |
player->pendingweapon = wp_gauntlets; |
| 2500 |
} |
| 2501 |
else if (player->weaponowned[wp_phoenixrod] |
| 2502 |
&& player->ammo[am_phoenixrod] > checkweaponinfo[wp_phoenixrod].ammopershot) |
| 2503 |
{ |
| 2504 |
player->pendingweapon = wp_phoenixrod; |
| 2505 |
} |
| 2506 |
else |
| 2507 |
{ |
| 2508 |
player->pendingweapon = wp_staff; |
| 2509 |
} |
| 2510 |
} |
| 2511 |
while (player->pendingweapon == wp_nochange); |
| 2512 |
if (player->powers[pw_weaponlevel2]) |
| 2513 |
{ |
| 2514 |
P_SetPsprite(player, ps_weapon, |
| 2515 |
wpnlev2info[player->readyweapon].downstate); |
| 2516 |
} |
| 2517 |
else |
| 2518 |
{ |
| 2519 |
P_SetPsprite(player, ps_weapon, |
| 2520 |
wpnlev1info[player->readyweapon].downstate); |
| 2521 |
} |
| 2522 |
return (false); |
| 2523 |
} |
| 2524 |
|
| 2525 |
void P_OpenWeapons(void) |
| 2526 |
{ |
| 2527 |
MaceSpotCount = 0; |
| 2528 |
} |
| 2529 |
|
| 2530 |
void P_AddMaceSpot(const mapthing_t * mthing) |
| 2531 |
{ |
| 2532 |
if (MaceSpotCount == MAX_MACE_SPOTS) |
| 2533 |
{ |
| 2534 |
I_Error("Too many mace spots."); |
| 2535 |
} |
| 2536 |
MaceSpots[MaceSpotCount].x = mthing->x; |
| 2537 |
MaceSpots[MaceSpotCount].y = mthing->y; |
| 2538 |
MaceSpotCount++; |
| 2539 |
} |
| 2540 |
|
| 2541 |
void P_CloseWeapons(void) |
| 2542 |
{ |
| 2543 |
int spot; |
| 2544 |
|
| 2545 |
if (!MaceSpotCount) |
| 2546 |
{ // No maces placed |
| 2547 |
return; |
| 2548 |
} |
| 2549 |
if (!deathmatch && P_Random(pr_heretic) < 64) |
| 2550 |
{ // Sometimes doesn't show up if not in deathmatch |
| 2551 |
return; |
| 2552 |
} |
| 2553 |
spot = P_Random(pr_heretic) % MaceSpotCount; |
| 2554 |
P_SpawnMobj(MaceSpots[spot].x, MaceSpots[spot].y, ONFLOORZ, HERETIC_MT_WMACE); |
| 2555 |
} |
| 2556 |
|
| 2557 |
// hexen |
| 2558 |
|
| 2559 |
#include "heretic/sb_bar.h" |
| 2560 |
|
| 2561 |
extern fixed_t FloatBobOffsets[64]; |
| 2562 |
|
| 2563 |
static int WeaponManaUse[NUMCLASSES][HEXEN_NUMWEAPONS] = { |
| 2564 |
[PCLASS_FIGHTER] = {0, 2, 3, 14}, |
| 2565 |
{0, 1, 4, 18}, |
| 2566 |
{0, 3, 5, 15}, |
| 2567 |
{0, 0, 0, 0} |
| 2568 |
}; |
| 2569 |
|
| 2570 |
void P_SetPspriteNF(player_t * player, int position, statenum_t stnum) |
| 2571 |
{ |
| 2572 |
pspdef_t *psp; |
| 2573 |
state_t *state; |
| 2574 |
|
| 2575 |
psp = &player->psprites[position]; |
| 2576 |
do |
| 2577 |
{ |
| 2578 |
if (!stnum) |
| 2579 |
{ // Object removed itself. |
| 2580 |
psp->state = NULL; |
| 2581 |
break; |
| 2582 |
} |
| 2583 |
state = &states[stnum]; |
| 2584 |
psp->state = state; |
| 2585 |
psp->tics = state->tics; // could be 0 |
| 2586 |
if (state->misc1) |
| 2587 |
{ // Set coordinates. |
| 2588 |
psp->sx = state->misc1 << FRACBITS; |
| 2589 |
} |
| 2590 |
if (state->misc2) |
| 2591 |
{ |
| 2592 |
psp->sy = state->misc2 << FRACBITS; |
| 2593 |
} |
| 2594 |
stnum = psp->state->nextstate; |
| 2595 |
} |
| 2596 |
while (!psp->tics); // An initial state of 0 could cycle through. |
| 2597 |
} |
| 2598 |
|
| 2599 |
void P_ActivateMorphWeapon(player_t * player) |
| 2600 |
{ |
| 2601 |
player->pendingweapon = wp_nochange; |
| 2602 |
player->psprites[ps_weapon].sy = WEAPONTOP; |
| 2603 |
player->readyweapon = wp_first; // Snout is the first weapon |
| 2604 |
P_SetPsprite(player, ps_weapon, HEXEN_S_SNOUTREADY); |
| 2605 |
} |
| 2606 |
|
| 2607 |
void P_PostMorphWeapon(player_t * player, weapontype_t weapon) |
| 2608 |
{ |
| 2609 |
player->pendingweapon = wp_nochange; |
| 2610 |
player->readyweapon = weapon; |
| 2611 |
player->psprites[ps_weapon].sy = WEAPONBOTTOM; |
| 2612 |
P_SetPsprite(player, ps_weapon, |
| 2613 |
hexen_weaponinfo[weapon][player->pclass].upstate); |
| 2614 |
} |
| 2615 |
|
| 2616 |
static dboolean P_CheckMana(player_t * player) |
| 2617 |
{ |
| 2618 |
manatype_t mana; |
| 2619 |
int count; |
| 2620 |
|
| 2621 |
mana = hexen_weaponinfo[player->readyweapon][player->pclass].ammo; |
| 2622 |
count = WeaponManaUse[player->pclass][player->readyweapon]; |
| 2623 |
if (mana == MANA_BOTH) |
| 2624 |
{ |
| 2625 |
if (player->ammo[MANA_1] >= count && player->ammo[MANA_2] >= count) |
| 2626 |
{ |
| 2627 |
return true; |
| 2628 |
} |
| 2629 |
} |
| 2630 |
else if (mana == MANA_NONE || player->ammo[mana] >= count) |
| 2631 |
{ |
| 2632 |
return (true); |
| 2633 |
} |
| 2634 |
|
| 2635 |
// out of mana, pick a weapon to change to |
| 2636 |
if (player->weaponowned[wp_third] |
| 2637 |
&& player->ammo[MANA_2] >= WeaponManaUse[player->pclass][wp_third]) |
| 2638 |
{ |
| 2639 |
player->pendingweapon = wp_third; |
| 2640 |
} |
| 2641 |
else if (player->weaponowned[wp_second] |
| 2642 |
&& player->ammo[MANA_1] >= |
| 2643 |
WeaponManaUse[player->pclass][wp_second]) |
| 2644 |
{ |
| 2645 |
player->pendingweapon = wp_second; |
| 2646 |
} |
| 2647 |
else if (player->weaponowned[wp_fourth] |
| 2648 |
&& player->ammo[MANA_1] >= |
| 2649 |
WeaponManaUse[player->pclass][wp_fourth] |
| 2650 |
&& player->ammo[MANA_2] >= |
| 2651 |
WeaponManaUse[player->pclass][wp_fourth]) |
| 2652 |
{ |
| 2653 |
player->pendingweapon = wp_fourth; |
| 2654 |
} |
| 2655 |
else |
| 2656 |
{ |
| 2657 |
player->pendingweapon = wp_first; |
| 2658 |
} |
| 2659 |
|
| 2660 |
P_SetPsprite(player, ps_weapon, |
| 2661 |
hexen_weaponinfo[player->readyweapon][player->pclass].downstate); |
| 2662 |
return (false); |
| 2663 |
} |
| 2664 |
|
| 2665 |
#define MAX_ANGADJUST (5*ANG1) |
| 2666 |
|
| 2667 |
void AdjustPlayerAngle(mobj_t * pmo) |
| 2668 |
{ |
| 2669 |
angle_t angle; |
| 2670 |
int difference; |
| 2671 |
|
| 2672 |
angle = R_PointToAngle2(pmo->x, pmo->y, linetarget->x, linetarget->y); |
| 2673 |
difference = (int) angle - (int) pmo->angle; |
| 2674 |
if (abs(difference) > MAX_ANGADJUST) |
| 2675 |
{ |
| 2676 |
pmo->angle += difference > 0 ? MAX_ANGADJUST : -MAX_ANGADJUST; |
| 2677 |
} |
| 2678 |
else |
| 2679 |
{ |
| 2680 |
pmo->angle = angle; |
| 2681 |
} |
| 2682 |
R_SmoothPlaying_Reset(pmo->player); |
| 2683 |
} |
| 2684 |
|
| 2685 |
mobj_t *PuffSpawned; |
| 2686 |
|
| 2687 |
void A_SnoutAttack(player_t * player, pspdef_t * psp) |
| 2688 |
{ |
| 2689 |
angle_t angle; |
| 2690 |
int damage; |
| 2691 |
int slope; |
| 2692 |
|
| 2693 |
damage = 3 + (P_Random(pr_hexen) & 3); |
| 2694 |
angle = player->mo->angle; |
| 2695 |
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, 0); |
| 2696 |
PuffType = HEXEN_MT_SNOUTPUFF; |
| 2697 |
PuffSpawned = NULL; |
| 2698 |
P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); |
| 2699 |
S_StartMobjSound(player->mo, hexen_sfx_pig_active1 + (P_Random(pr_hexen) & 1)); |
| 2700 |
if (linetarget) |
| 2701 |
{ |
| 2702 |
AdjustPlayerAngle(player->mo); |
| 2703 |
if (PuffSpawned) |
| 2704 |
{ // Bit something |
| 2705 |
S_StartMobjSound(player->mo, hexen_sfx_pig_attack); |
| 2706 |
} |
| 2707 |
} |
| 2708 |
} |
| 2709 |
|
| 2710 |
#define HAMMER_RANGE (MELEERANGE+MELEERANGE/2) |
| 2711 |
|
| 2712 |
void A_FHammerAttack(player_t * player, pspdef_t * psp) |
| 2713 |
{ |
| 2714 |
angle_t angle; |
| 2715 |
mobj_t *pmo = player->mo; |
| 2716 |
int damage; |
| 2717 |
fixed_t power; |
| 2718 |
int slope; |
| 2719 |
int i; |
| 2720 |
|
| 2721 |
damage = 60 + (P_Random(pr_hexen) & 63); |
| 2722 |
power = 10 * FRACUNIT; |
| 2723 |
PuffType = HEXEN_MT_HAMMERPUFF; |
| 2724 |
for (i = 0; i < 16; i++) |
| 2725 |
{ |
| 2726 |
angle = pmo->angle + i * (ANG45 / 32); |
| 2727 |
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, 0); |
| 2728 |
if (linetarget) |
| 2729 |
{ |
| 2730 |
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage); |
| 2731 |
AdjustPlayerAngle(pmo); |
| 2732 |
if (linetarget->flags & MF_COUNTKILL || linetarget->player) |
| 2733 |
{ |
| 2734 |
P_ThrustMobj(linetarget, angle, power); |
| 2735 |
} |
| 2736 |
pmo->special1.i = false; // Don't throw a hammer |
| 2737 |
goto hammerdone; |
| 2738 |
} |
| 2739 |
angle = pmo->angle - i * (ANG45 / 32); |
| 2740 |
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, 0); |
| 2741 |
if (linetarget) |
| 2742 |
{ |
| 2743 |
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage); |
| 2744 |
AdjustPlayerAngle(pmo); |
| 2745 |
if (linetarget->flags & MF_COUNTKILL || linetarget->player) |
| 2746 |
{ |
| 2747 |
P_ThrustMobj(linetarget, angle, power); |
| 2748 |
} |
| 2749 |
pmo->special1.i = false; // Don't throw a hammer |
| 2750 |
goto hammerdone; |
| 2751 |
} |
| 2752 |
} |
| 2753 |
// didn't find any targets in meleerange, so set to throw out a hammer |
| 2754 |
PuffSpawned = NULL; |
| 2755 |
angle = pmo->angle; |
| 2756 |
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, 0); |
| 2757 |
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage); |
| 2758 |
if (PuffSpawned) |
| 2759 |
{ |
| 2760 |
pmo->special1.i = false; |
| 2761 |
} |
| 2762 |
else |
| 2763 |
{ |
| 2764 |
pmo->special1.i = true; |
| 2765 |
} |
| 2766 |
hammerdone: |
| 2767 |
if (player->ammo[MANA_2] < WeaponManaUse[player->pclass][player->readyweapon]) |
| 2768 |
{ // Don't spawn a hammer if the player doesn't have enough mana |
| 2769 |
pmo->special1.i = false; |
| 2770 |
} |
| 2771 |
return; |
| 2772 |
} |
| 2773 |
|
| 2774 |
void A_FHammerThrow(player_t * player, pspdef_t * psp) |
| 2775 |
{ |
| 2776 |
mobj_t *mo; |
| 2777 |
|
| 2778 |
if (!player->mo->special1.i) |
| 2779 |
{ |
| 2780 |
return; |
| 2781 |
} |
| 2782 |
player->ammo[MANA_2] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 2783 |
mo = P_SpawnPlayerMissile(player->mo, HEXEN_MT_HAMMER_MISSILE); |
| 2784 |
if (mo) |
| 2785 |
{ |
| 2786 |
mo->special1.i = 0; |
| 2787 |
} |
| 2788 |
} |
| 2789 |
|
| 2790 |
void A_FSwordAttack(player_t * player, pspdef_t * psp) |
| 2791 |
{ |
| 2792 |
mobj_t *pmo; |
| 2793 |
|
| 2794 |
player->ammo[MANA_1] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 2795 |
player->ammo[MANA_2] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 2796 |
pmo = player->mo; |
| 2797 |
P_SPMAngleXYZ(pmo, pmo->x, pmo->y, pmo->z - 10 * FRACUNIT, |
| 2798 |
HEXEN_MT_FSWORD_MISSILE, pmo->angle + ANG45 / 4); |
| 2799 |
P_SPMAngleXYZ(pmo, pmo->x, pmo->y, pmo->z - 5 * FRACUNIT, |
| 2800 |
HEXEN_MT_FSWORD_MISSILE, pmo->angle + ANG45 / 8); |
| 2801 |
P_SPMAngleXYZ(pmo, pmo->x, pmo->y, pmo->z, HEXEN_MT_FSWORD_MISSILE, pmo->angle); |
| 2802 |
P_SPMAngleXYZ(pmo, pmo->x, pmo->y, pmo->z + 5 * FRACUNIT, |
| 2803 |
HEXEN_MT_FSWORD_MISSILE, pmo->angle - ANG45 / 8); |
| 2804 |
P_SPMAngleXYZ(pmo, pmo->x, pmo->y, pmo->z + 10 * FRACUNIT, |
| 2805 |
HEXEN_MT_FSWORD_MISSILE, pmo->angle - ANG45 / 4); |
| 2806 |
S_StartMobjSound(pmo, hexen_sfx_fighter_sword_fire); |
| 2807 |
} |
| 2808 |
|
| 2809 |
void A_FSwordAttack2(mobj_t * actor) |
| 2810 |
{ |
| 2811 |
angle_t angle = actor->angle; |
| 2812 |
|
| 2813 |
P_SpawnMissileAngle(actor, HEXEN_MT_FSWORD_MISSILE, angle + ANG45 / 4, 0); |
| 2814 |
P_SpawnMissileAngle(actor, HEXEN_MT_FSWORD_MISSILE, angle + ANG45 / 8, 0); |
| 2815 |
P_SpawnMissileAngle(actor, HEXEN_MT_FSWORD_MISSILE, angle, 0); |
| 2816 |
P_SpawnMissileAngle(actor, HEXEN_MT_FSWORD_MISSILE, angle - ANG45 / 8, 0); |
| 2817 |
P_SpawnMissileAngle(actor, HEXEN_MT_FSWORD_MISSILE, angle - ANG45 / 4, 0); |
| 2818 |
S_StartMobjSound(actor, hexen_sfx_fighter_sword_fire); |
| 2819 |
} |
| 2820 |
|
| 2821 |
void A_FSwordFlames(mobj_t * actor) |
| 2822 |
{ |
| 2823 |
int i; |
| 2824 |
int r1,r2,r3; |
| 2825 |
|
| 2826 |
for (i = 1 + (P_Random(pr_hexen) & 3); i; i--) |
| 2827 |
{ |
| 2828 |
r1 = P_Random(pr_hexen); |
| 2829 |
r2 = P_Random(pr_hexen); |
| 2830 |
r3 = P_Random(pr_hexen); |
| 2831 |
P_SpawnMobj(actor->x + ((r3 - 128) << 12), actor->y |
| 2832 |
+ ((r2 - 128) << 12), |
| 2833 |
actor->z + ((r1 - 128) << 11), HEXEN_MT_FSWORD_FLAME); |
| 2834 |
} |
| 2835 |
} |
| 2836 |
|
| 2837 |
void A_MWandAttack(player_t * player, pspdef_t * psp) |
| 2838 |
{ |
| 2839 |
mobj_t *mo; |
| 2840 |
|
| 2841 |
mo = P_SpawnPlayerMissile(player->mo, HEXEN_MT_MWAND_MISSILE); |
| 2842 |
if (mo) |
| 2843 |
{ |
| 2844 |
mo->thinker.function = P_BlasterMobjThinker; |
| 2845 |
} |
| 2846 |
S_StartMobjSound(player->mo, hexen_sfx_mage_wand_fire); |
| 2847 |
} |
| 2848 |
|
| 2849 |
void A_LightningReady(player_t * player, pspdef_t * psp) |
| 2850 |
{ |
| 2851 |
A_WeaponReady(player, psp); |
| 2852 |
if (P_Random(pr_hexen) < 160) |
| 2853 |
{ |
| 2854 |
S_StartMobjSound(player->mo, hexen_sfx_mage_lightning_ready); |
| 2855 |
} |
| 2856 |
} |
| 2857 |
|
| 2858 |
#define ZAGSPEED FRACUNIT |
| 2859 |
|
| 2860 |
void A_LightningClip(mobj_t * actor) |
| 2861 |
{ |
| 2862 |
mobj_t *cMo; |
| 2863 |
mobj_t *target = NULL; |
| 2864 |
int zigZag; |
| 2865 |
|
| 2866 |
if (actor->type == HEXEN_MT_LIGHTNING_FLOOR) |
| 2867 |
{ |
| 2868 |
actor->z = actor->floorz; |
| 2869 |
target = actor->special2.m->special1.m; |
| 2870 |
} |
| 2871 |
else if (actor->type == HEXEN_MT_LIGHTNING_CEILING) |
| 2872 |
{ |
| 2873 |
actor->z = actor->ceilingz - actor->height; |
| 2874 |
target = actor->special1.m; |
| 2875 |
} |
| 2876 |
if (actor->type == HEXEN_MT_LIGHTNING_FLOOR) |
| 2877 |
{ // floor lightning zig-zags, and forces the ceiling lightning to mimic |
| 2878 |
cMo = actor->special2.m; |
| 2879 |
zigZag = P_Random(pr_hexen); |
| 2880 |
if ((zigZag > 128 && actor->special1.i < 2) || actor->special1.i < -2) |
| 2881 |
{ |
| 2882 |
P_ThrustMobj(actor, actor->angle + ANG90, ZAGSPEED); |
| 2883 |
if (cMo) |
| 2884 |
{ |
| 2885 |
P_ThrustMobj(cMo, actor->angle + ANG90, ZAGSPEED); |
| 2886 |
} |
| 2887 |
actor->special1.i++; |
| 2888 |
} |
| 2889 |
else |
| 2890 |
{ |
| 2891 |
P_ThrustMobj(actor, actor->angle - ANG90, ZAGSPEED); |
| 2892 |
if (cMo) |
| 2893 |
{ |
| 2894 |
P_ThrustMobj(cMo, cMo->angle - ANG90, ZAGSPEED); |
| 2895 |
} |
| 2896 |
actor->special1.i--; |
| 2897 |
} |
| 2898 |
} |
| 2899 |
if (target) |
| 2900 |
{ |
| 2901 |
if (target->health <= 0) |
| 2902 |
{ |
| 2903 |
P_ExplodeMissile(actor); |
| 2904 |
} |
| 2905 |
else |
| 2906 |
{ |
| 2907 |
actor->angle = R_PointToAngle2(actor->x, actor->y, target->x, |
| 2908 |
target->y); |
| 2909 |
actor->momx = 0; |
| 2910 |
actor->momy = 0; |
| 2911 |
P_ThrustMobj(actor, actor->angle, actor->info->speed >> 1); |
| 2912 |
} |
| 2913 |
} |
| 2914 |
} |
| 2915 |
|
| 2916 |
void A_LightningZap(mobj_t * actor) |
| 2917 |
{ |
| 2918 |
mobj_t *mo; |
| 2919 |
fixed_t deltaZ; |
| 2920 |
int r1,r2; |
| 2921 |
|
| 2922 |
A_LightningClip(actor); |
| 2923 |
|
| 2924 |
actor->health -= 8; |
| 2925 |
if (actor->health <= 0) |
| 2926 |
{ |
| 2927 |
P_SetMobjState(actor, actor->info->deathstate); |
| 2928 |
return; |
| 2929 |
} |
| 2930 |
if (actor->type == HEXEN_MT_LIGHTNING_FLOOR) |
| 2931 |
{ |
| 2932 |
deltaZ = 10 * FRACUNIT; |
| 2933 |
} |
| 2934 |
else |
| 2935 |
{ |
| 2936 |
deltaZ = -10 * FRACUNIT; |
| 2937 |
} |
| 2938 |
r1 = P_Random(pr_hexen); |
| 2939 |
r2 = P_Random(pr_hexen); |
| 2940 |
mo = P_SpawnMobj(actor->x + ((r2 - 128) * actor->radius / 256), |
| 2941 |
actor->y + ((r1 - 128) * actor->radius / 256), |
| 2942 |
actor->z + deltaZ, HEXEN_MT_LIGHTNING_ZAP); |
| 2943 |
if (mo) |
| 2944 |
{ |
| 2945 |
P_SetTarget(&mo->special2.m, actor); |
| 2946 |
mo->momx = actor->momx; |
| 2947 |
mo->momy = actor->momy; |
| 2948 |
P_SetTarget(&mo->target, actor->target); |
| 2949 |
if (actor->type == HEXEN_MT_LIGHTNING_FLOOR) |
| 2950 |
{ |
| 2951 |
mo->momz = 20 * FRACUNIT; |
| 2952 |
} |
| 2953 |
else |
| 2954 |
{ |
| 2955 |
mo->momz = -20 * FRACUNIT; |
| 2956 |
} |
| 2957 |
} |
| 2958 |
|
| 2959 |
if (actor->type == HEXEN_MT_LIGHTNING_FLOOR && P_Random(pr_hexen) < 160) |
| 2960 |
{ |
| 2961 |
S_StartMobjSound(actor, hexen_sfx_mage_lightning_continuous); |
| 2962 |
} |
| 2963 |
} |
| 2964 |
|
| 2965 |
void A_MLightningAttack2(mobj_t * actor) |
| 2966 |
{ |
| 2967 |
mobj_t *fmo, *cmo; |
| 2968 |
|
| 2969 |
fmo = P_SpawnPlayerMissile(actor, HEXEN_MT_LIGHTNING_FLOOR); |
| 2970 |
cmo = P_SpawnPlayerMissile(actor, HEXEN_MT_LIGHTNING_CEILING); |
| 2971 |
if (fmo) |
| 2972 |
{ |
| 2973 |
P_SetTarget(&fmo->special1.m, NULL); |
| 2974 |
P_SetTarget(&fmo->special2.m, cmo); |
| 2975 |
A_LightningZap(fmo); |
| 2976 |
} |
| 2977 |
if (cmo) |
| 2978 |
{ |
| 2979 |
P_SetTarget(&cmo->special1.m, NULL); // mobj that it will track |
| 2980 |
P_SetTarget(&cmo->special2.m, fmo); |
| 2981 |
A_LightningZap(cmo); |
| 2982 |
} |
| 2983 |
S_StartMobjSound(actor, hexen_sfx_mage_lightning_fire); |
| 2984 |
} |
| 2985 |
|
| 2986 |
void A_MLightningAttack(player_t * player, pspdef_t * psp) |
| 2987 |
{ |
| 2988 |
A_MLightningAttack2(player->mo); |
| 2989 |
player->ammo[MANA_2] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 2990 |
} |
| 2991 |
|
| 2992 |
void A_ZapMimic(mobj_t * actor) |
| 2993 |
{ |
| 2994 |
mobj_t *mo; |
| 2995 |
|
| 2996 |
mo = actor->special2.m; |
| 2997 |
if (mo) |
| 2998 |
{ |
| 2999 |
if (mo->state >= &states[mo->info->deathstate] |
| 3000 |
|| mo->state == &states[HEXEN_S_FREETARGMOBJ]) |
| 3001 |
{ |
| 3002 |
P_ExplodeMissile(actor); |
| 3003 |
} |
| 3004 |
else |
| 3005 |
{ |
| 3006 |
actor->momx = mo->momx; |
| 3007 |
actor->momy = mo->momy; |
| 3008 |
} |
| 3009 |
} |
| 3010 |
} |
| 3011 |
|
| 3012 |
void A_LastZap(mobj_t * actor) |
| 3013 |
{ |
| 3014 |
mobj_t *mo; |
| 3015 |
|
| 3016 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_LIGHTNING_ZAP); |
| 3017 |
if (mo) |
| 3018 |
{ |
| 3019 |
P_SetMobjState(mo, HEXEN_S_LIGHTNING_ZAP_X1); |
| 3020 |
mo->momz = 40 * FRACUNIT; |
| 3021 |
} |
| 3022 |
} |
| 3023 |
|
| 3024 |
void A_LightningRemove(mobj_t * actor) |
| 3025 |
{ |
| 3026 |
mobj_t *mo; |
| 3027 |
|
| 3028 |
mo = actor->special2.m; |
| 3029 |
if (mo) |
| 3030 |
{ |
| 3031 |
P_SetTarget(&mo->special2.m, NULL); |
| 3032 |
P_ExplodeMissile(mo); |
| 3033 |
} |
| 3034 |
} |
| 3035 |
|
| 3036 |
void MStaffSpawn(mobj_t * pmo, angle_t angle) |
| 3037 |
{ |
| 3038 |
mobj_t *mo; |
| 3039 |
|
| 3040 |
mo = P_SPMAngle(pmo, HEXEN_MT_MSTAFF_FX2, angle); |
| 3041 |
if (mo) |
| 3042 |
{ |
| 3043 |
P_SetTarget(&mo->target, pmo); |
| 3044 |
P_SetTarget(&mo->special1.m, P_RoughTargetSearch(mo, 0, 10)); |
| 3045 |
} |
| 3046 |
} |
| 3047 |
|
| 3048 |
void A_MStaffAttack(player_t * player, pspdef_t * psp) |
| 3049 |
{ |
| 3050 |
angle_t angle; |
| 3051 |
mobj_t *pmo; |
| 3052 |
|
| 3053 |
player->ammo[MANA_1] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 3054 |
player->ammo[MANA_2] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 3055 |
pmo = player->mo; |
| 3056 |
angle = pmo->angle; |
| 3057 |
|
| 3058 |
MStaffSpawn(pmo, angle); |
| 3059 |
MStaffSpawn(pmo, angle - ANG1 * 5); |
| 3060 |
MStaffSpawn(pmo, angle + ANG1 * 5); |
| 3061 |
S_StartMobjSound(player->mo, hexen_sfx_mage_staff_fire); |
| 3062 |
if (player == &players[consoleplayer]) |
| 3063 |
{ |
| 3064 |
player->damagecount = 0; |
| 3065 |
player->bonuscount = 0; |
| 3066 |
V_SetPalette(STARTSCOURGEPAL); |
| 3067 |
SB_Start(); |
| 3068 |
} |
| 3069 |
} |
| 3070 |
|
| 3071 |
void A_MStaffPalette(player_t * player, pspdef_t * psp) |
| 3072 |
{ |
| 3073 |
int pal; |
| 3074 |
|
| 3075 |
if (player == &players[consoleplayer]) |
| 3076 |
{ |
| 3077 |
pal = STARTSCOURGEPAL + psp->state - (&states[HEXEN_S_MSTAFFATK_2]); |
| 3078 |
if (pal == STARTSCOURGEPAL + 3) |
| 3079 |
{ // reset back to original playpal |
| 3080 |
pal = 0; |
| 3081 |
} |
| 3082 |
V_SetPalette(pal); |
| 3083 |
SB_Start(); |
| 3084 |
} |
| 3085 |
} |
| 3086 |
|
| 3087 |
void A_MStaffWeave(mobj_t * actor) |
| 3088 |
{ |
| 3089 |
fixed_t newX, newY; |
| 3090 |
int weaveXY, weaveZ; |
| 3091 |
int angle; |
| 3092 |
|
| 3093 |
weaveXY = actor->special2.i >> 16; |
| 3094 |
weaveZ = actor->special2.i & 0xFFFF; |
| 3095 |
angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 3096 |
newX = actor->x - FixedMul(finecosine[angle], |
| 3097 |
FloatBobOffsets[weaveXY] << 2); |
| 3098 |
newY = actor->y - FixedMul(finesine[angle], |
| 3099 |
FloatBobOffsets[weaveXY] << 2); |
| 3100 |
weaveXY = (weaveXY + 6) & 63; |
| 3101 |
newX += FixedMul(finecosine[angle], FloatBobOffsets[weaveXY] << 2); |
| 3102 |
newY += FixedMul(finesine[angle], FloatBobOffsets[weaveXY] << 2); |
| 3103 |
P_TryMove(actor, newX, newY, 0); |
| 3104 |
actor->z -= FloatBobOffsets[weaveZ] << 1; |
| 3105 |
weaveZ = (weaveZ + 3) & 63; |
| 3106 |
actor->z += FloatBobOffsets[weaveZ] << 1; |
| 3107 |
if (actor->z <= actor->floorz) |
| 3108 |
{ |
| 3109 |
actor->z = actor->floorz + FRACUNIT; |
| 3110 |
} |
| 3111 |
actor->special2.i = weaveZ + (weaveXY << 16); |
| 3112 |
} |
| 3113 |
|
| 3114 |
void A_MStaffTrack(mobj_t * actor) |
| 3115 |
{ |
| 3116 |
if ((actor->special1.m == NULL) && (P_Random(pr_hexen) < 50)) |
| 3117 |
{ |
| 3118 |
P_SetTarget(&actor->special1.m, P_RoughTargetSearch(actor, 0, 10)); |
| 3119 |
} |
| 3120 |
P_SeekerMissile(actor, &actor->special1.m, ANG1 * 2, ANG1 * 10, false); |
| 3121 |
} |
| 3122 |
|
| 3123 |
void MStaffSpawn2(mobj_t * actor, angle_t angle) |
| 3124 |
{ |
| 3125 |
mobj_t *mo; |
| 3126 |
|
| 3127 |
mo = P_SpawnMissileAngle(actor, HEXEN_MT_MSTAFF_FX2, angle, 0); |
| 3128 |
if (mo) |
| 3129 |
{ |
| 3130 |
P_SetTarget(&mo->target, actor); |
| 3131 |
P_SetTarget(&mo->special1.m, P_RoughTargetSearch(mo, 0, 10)); |
| 3132 |
} |
| 3133 |
} |
| 3134 |
|
| 3135 |
void A_MStaffAttack2(mobj_t * actor) |
| 3136 |
{ |
| 3137 |
angle_t angle; |
| 3138 |
angle = actor->angle; |
| 3139 |
MStaffSpawn2(actor, angle); |
| 3140 |
MStaffSpawn2(actor, angle - ANG1 * 5); |
| 3141 |
MStaffSpawn2(actor, angle + ANG1 * 5); |
| 3142 |
S_StartMobjSound(actor, hexen_sfx_mage_staff_fire); |
| 3143 |
} |
| 3144 |
|
| 3145 |
void A_FPunchAttack(player_t * player, pspdef_t * psp) |
| 3146 |
{ |
| 3147 |
angle_t angle; |
| 3148 |
int damage; |
| 3149 |
int slope; |
| 3150 |
mobj_t *pmo = player->mo; |
| 3151 |
fixed_t power; |
| 3152 |
int i; |
| 3153 |
|
| 3154 |
damage = 40 + (P_Random(pr_hexen) & 15); |
| 3155 |
power = 2 * FRACUNIT; |
| 3156 |
PuffType = HEXEN_MT_PUNCHPUFF; |
| 3157 |
for (i = 0; i < 16; i++) |
| 3158 |
{ |
| 3159 |
angle = pmo->angle + i * (ANG45 / 16); |
| 3160 |
slope = P_AimLineAttack(pmo, angle, 2 * MELEERANGE, 0); |
| 3161 |
if (linetarget) |
| 3162 |
{ |
| 3163 |
player->mo->special1.i++; |
| 3164 |
if (pmo->special1.i == 3) |
| 3165 |
{ |
| 3166 |
damage <<= 1; |
| 3167 |
power = 6 * FRACUNIT; |
| 3168 |
PuffType = HEXEN_MT_HAMMERPUFF; |
| 3169 |
} |
| 3170 |
P_LineAttack(pmo, angle, 2 * MELEERANGE, slope, damage); |
| 3171 |
if (linetarget->flags & MF_COUNTKILL || linetarget->player) |
| 3172 |
{ |
| 3173 |
P_ThrustMobj(linetarget, angle, power); |
| 3174 |
} |
| 3175 |
AdjustPlayerAngle(pmo); |
| 3176 |
goto punchdone; |
| 3177 |
} |
| 3178 |
angle = pmo->angle - i * (ANG45 / 16); |
| 3179 |
slope = P_AimLineAttack(pmo, angle, 2 * MELEERANGE, 0); |
| 3180 |
if (linetarget) |
| 3181 |
{ |
| 3182 |
pmo->special1.i++; |
| 3183 |
if (pmo->special1.i == 3) |
| 3184 |
{ |
| 3185 |
damage <<= 1; |
| 3186 |
power = 6 * FRACUNIT; |
| 3187 |
PuffType = HEXEN_MT_HAMMERPUFF; |
| 3188 |
} |
| 3189 |
P_LineAttack(pmo, angle, 2 * MELEERANGE, slope, damage); |
| 3190 |
if (linetarget->flags & MF_COUNTKILL || linetarget->player) |
| 3191 |
{ |
| 3192 |
P_ThrustMobj(linetarget, angle, power); |
| 3193 |
} |
| 3194 |
AdjustPlayerAngle(pmo); |
| 3195 |
goto punchdone; |
| 3196 |
} |
| 3197 |
} |
| 3198 |
// didn't find any creatures, so try to strike any walls |
| 3199 |
pmo->special1.i = 0; |
| 3200 |
|
| 3201 |
angle = pmo->angle; |
| 3202 |
slope = P_AimLineAttack(pmo, angle, MELEERANGE, 0); |
| 3203 |
P_LineAttack(pmo, angle, MELEERANGE, slope, damage); |
| 3204 |
|
| 3205 |
punchdone: |
| 3206 |
if (pmo->special1.i == 3) |
| 3207 |
{ |
| 3208 |
pmo->special1.i = 0; |
| 3209 |
P_SetPsprite(player, ps_weapon, HEXEN_S_PUNCHATK2_1); |
| 3210 |
S_StartMobjSound(pmo, hexen_sfx_fighter_grunt); |
| 3211 |
} |
| 3212 |
return; |
| 3213 |
} |
| 3214 |
|
| 3215 |
#define AXERANGE 2.25*MELEERANGE |
| 3216 |
|
| 3217 |
void A_FAxeAttack(player_t * player, pspdef_t * psp) |
| 3218 |
{ |
| 3219 |
angle_t angle; |
| 3220 |
mobj_t *pmo = player->mo; |
| 3221 |
fixed_t power; |
| 3222 |
int damage; |
| 3223 |
int slope; |
| 3224 |
int i; |
| 3225 |
int useMana; |
| 3226 |
int r; |
| 3227 |
|
| 3228 |
r = P_Random(pr_hexen); |
| 3229 |
damage = 40 + (r & 15) + (P_Random(pr_hexen) & 7); |
| 3230 |
power = 0; |
| 3231 |
if (player->ammo[MANA_1] > 0) |
| 3232 |
{ |
| 3233 |
damage <<= 1; |
| 3234 |
power = 6 * FRACUNIT; |
| 3235 |
PuffType = HEXEN_MT_AXEPUFF_GLOW; |
| 3236 |
useMana = 1; |
| 3237 |
} |
| 3238 |
else |
| 3239 |
{ |
| 3240 |
PuffType = HEXEN_MT_AXEPUFF; |
| 3241 |
useMana = 0; |
| 3242 |
} |
| 3243 |
for (i = 0; i < 16; i++) |
| 3244 |
{ |
| 3245 |
angle = pmo->angle + i * (ANG45 / 16); |
| 3246 |
slope = P_AimLineAttack(pmo, angle, AXERANGE, 0); |
| 3247 |
if (linetarget) |
| 3248 |
{ |
| 3249 |
P_LineAttack(pmo, angle, AXERANGE, slope, damage); |
| 3250 |
if (linetarget->flags & MF_COUNTKILL || linetarget->player) |
| 3251 |
{ |
| 3252 |
P_ThrustMobj(linetarget, angle, power); |
| 3253 |
} |
| 3254 |
AdjustPlayerAngle(pmo); |
| 3255 |
useMana++; |
| 3256 |
goto axedone; |
| 3257 |
} |
| 3258 |
angle = pmo->angle - i * (ANG45 / 16); |
| 3259 |
slope = P_AimLineAttack(pmo, angle, AXERANGE, 0); |
| 3260 |
if (linetarget) |
| 3261 |
{ |
| 3262 |
P_LineAttack(pmo, angle, AXERANGE, slope, damage); |
| 3263 |
if (linetarget->flags & MF_COUNTKILL) |
| 3264 |
{ |
| 3265 |
P_ThrustMobj(linetarget, angle, power); |
| 3266 |
} |
| 3267 |
AdjustPlayerAngle(pmo); |
| 3268 |
useMana++; |
| 3269 |
goto axedone; |
| 3270 |
} |
| 3271 |
} |
| 3272 |
// didn't find any creatures, so try to strike any walls |
| 3273 |
pmo->special1.i = 0; |
| 3274 |
|
| 3275 |
angle = pmo->angle; |
| 3276 |
slope = P_AimLineAttack(pmo, angle, MELEERANGE, 0); |
| 3277 |
P_LineAttack(pmo, angle, MELEERANGE, slope, damage); |
| 3278 |
|
| 3279 |
axedone: |
| 3280 |
if (useMana == 2) |
| 3281 |
{ |
| 3282 |
player->ammo[MANA_1] -= |
| 3283 |
WeaponManaUse[player->pclass][player->readyweapon]; |
| 3284 |
if (player->ammo[MANA_1] <= 0) |
| 3285 |
{ |
| 3286 |
P_SetPsprite(player, ps_weapon, HEXEN_S_FAXEATK_5); |
| 3287 |
} |
| 3288 |
} |
| 3289 |
return; |
| 3290 |
} |
| 3291 |
|
| 3292 |
void A_CMaceAttack(player_t * player, pspdef_t * psp) |
| 3293 |
{ |
| 3294 |
angle_t angle; |
| 3295 |
int damage; |
| 3296 |
int slope; |
| 3297 |
int i; |
| 3298 |
|
| 3299 |
damage = 25 + (P_Random(pr_hexen) & 15); |
| 3300 |
PuffType = HEXEN_MT_HAMMERPUFF; |
| 3301 |
for (i = 0; i < 16; i++) |
| 3302 |
{ |
| 3303 |
angle = player->mo->angle + i * (ANG45 / 16); |
| 3304 |
slope = P_AimLineAttack(player->mo, angle, 2 * MELEERANGE, 0); |
| 3305 |
if (linetarget) |
| 3306 |
{ |
| 3307 |
P_LineAttack(player->mo, angle, 2 * MELEERANGE, slope, damage); |
| 3308 |
AdjustPlayerAngle(player->mo); |
| 3309 |
|
| 3310 |
goto macedone; |
| 3311 |
} |
| 3312 |
angle = player->mo->angle - i * (ANG45 / 16); |
| 3313 |
slope = P_AimLineAttack(player->mo, angle, 2 * MELEERANGE, 0); |
| 3314 |
if (linetarget) |
| 3315 |
{ |
| 3316 |
P_LineAttack(player->mo, angle, 2 * MELEERANGE, slope, damage); |
| 3317 |
AdjustPlayerAngle(player->mo); |
| 3318 |
|
| 3319 |
goto macedone; |
| 3320 |
} |
| 3321 |
} |
| 3322 |
// didn't find any creatures, so try to strike any walls |
| 3323 |
player->mo->special1.i = 0; |
| 3324 |
|
| 3325 |
angle = player->mo->angle; |
| 3326 |
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, 0); |
| 3327 |
P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); |
| 3328 |
macedone: |
| 3329 |
return; |
| 3330 |
} |
| 3331 |
|
| 3332 |
void A_CStaffCheck(player_t * player, pspdef_t * psp) |
| 3333 |
{ |
| 3334 |
mobj_t *pmo; |
| 3335 |
int damage; |
| 3336 |
int newLife; |
| 3337 |
angle_t angle; |
| 3338 |
int slope; |
| 3339 |
int i; |
| 3340 |
|
| 3341 |
pmo = player->mo; |
| 3342 |
damage = 20 + (P_Random(pr_hexen) & 15); |
| 3343 |
PuffType = HEXEN_MT_CSTAFFPUFF; |
| 3344 |
for (i = 0; i < 3; i++) |
| 3345 |
{ |
| 3346 |
angle = pmo->angle + i * (ANG45 / 16); |
| 3347 |
slope = P_AimLineAttack(pmo, angle, 1.5 * MELEERANGE, 0); |
| 3348 |
if (linetarget) |
| 3349 |
{ |
| 3350 |
P_LineAttack(pmo, angle, 1.5 * MELEERANGE, slope, damage); |
| 3351 |
pmo->angle = R_PointToAngle2(pmo->x, pmo->y, |
| 3352 |
linetarget->x, linetarget->y); |
| 3353 |
if ((linetarget->player || linetarget->flags & MF_COUNTKILL) |
| 3354 |
&& (!(linetarget->flags2 & (MF2_DORMANT + MF2_INVULNERABLE)))) |
| 3355 |
{ |
| 3356 |
newLife = player->health + (damage >> 3); |
| 3357 |
newLife = newLife > 100 ? 100 : newLife; |
| 3358 |
pmo->health = player->health = newLife; |
| 3359 |
P_SetPsprite(player, ps_weapon, HEXEN_S_CSTAFFATK2_1); |
| 3360 |
} |
| 3361 |
player->ammo[MANA_1] -= |
| 3362 |
WeaponManaUse[player->pclass][player->readyweapon]; |
| 3363 |
break; |
| 3364 |
} |
| 3365 |
angle = pmo->angle - i * (ANG45 / 16); |
| 3366 |
slope = P_AimLineAttack(player->mo, angle, 1.5 * MELEERANGE, 0); |
| 3367 |
if (linetarget) |
| 3368 |
{ |
| 3369 |
P_LineAttack(pmo, angle, 1.5 * MELEERANGE, slope, damage); |
| 3370 |
pmo->angle = R_PointToAngle2(pmo->x, pmo->y, |
| 3371 |
linetarget->x, linetarget->y); |
| 3372 |
if (linetarget->player || linetarget->flags & MF_COUNTKILL) |
| 3373 |
{ |
| 3374 |
newLife = player->health + (damage >> 4); |
| 3375 |
newLife = newLife > 100 ? 100 : newLife; |
| 3376 |
pmo->health = player->health = newLife; |
| 3377 |
P_SetPsprite(player, ps_weapon, HEXEN_S_CSTAFFATK2_1); |
| 3378 |
} |
| 3379 |
player->ammo[MANA_1] -= |
| 3380 |
WeaponManaUse[player->pclass][player->readyweapon]; |
| 3381 |
break; |
| 3382 |
} |
| 3383 |
} |
| 3384 |
R_SmoothPlaying_Reset(player); // e6y |
| 3385 |
} |
| 3386 |
|
| 3387 |
void A_CStaffAttack(player_t * player, pspdef_t * psp) |
| 3388 |
{ |
| 3389 |
mobj_t *mo; |
| 3390 |
mobj_t *pmo; |
| 3391 |
|
| 3392 |
player->ammo[MANA_1] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 3393 |
pmo = player->mo; |
| 3394 |
mo = P_SPMAngle(pmo, HEXEN_MT_CSTAFF_MISSILE, pmo->angle - (ANG45 / 15)); |
| 3395 |
if (mo) |
| 3396 |
{ |
| 3397 |
mo->special2.i = 32; |
| 3398 |
} |
| 3399 |
mo = P_SPMAngle(pmo, HEXEN_MT_CSTAFF_MISSILE, pmo->angle + (ANG45 / 15)); |
| 3400 |
if (mo) |
| 3401 |
{ |
| 3402 |
mo->special2.i = 0; |
| 3403 |
} |
| 3404 |
S_StartMobjSound(player->mo, hexen_sfx_cleric_cstaff_fire); |
| 3405 |
} |
| 3406 |
|
| 3407 |
void A_CStaffMissileSlither(mobj_t * actor) |
| 3408 |
{ |
| 3409 |
fixed_t newX, newY; |
| 3410 |
int weaveXY; |
| 3411 |
int angle; |
| 3412 |
|
| 3413 |
weaveXY = actor->special2.i; |
| 3414 |
angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 3415 |
newX = actor->x - FixedMul(finecosine[angle], FloatBobOffsets[weaveXY]); |
| 3416 |
newY = actor->y - FixedMul(finesine[angle], FloatBobOffsets[weaveXY]); |
| 3417 |
weaveXY = (weaveXY + 3) & 63; |
| 3418 |
newX += FixedMul(finecosine[angle], FloatBobOffsets[weaveXY]); |
| 3419 |
newY += FixedMul(finesine[angle], FloatBobOffsets[weaveXY]); |
| 3420 |
P_TryMove(actor, newX, newY, 0); |
| 3421 |
actor->special2.i = weaveXY; |
| 3422 |
} |
| 3423 |
|
| 3424 |
void A_CStaffInitBlink(player_t * player, pspdef_t * psp) |
| 3425 |
{ |
| 3426 |
player->mo->special1.i = (P_Random(pr_hexen) >> 1) + 20; |
| 3427 |
} |
| 3428 |
|
| 3429 |
void A_CStaffCheckBlink(player_t * player, pspdef_t * psp) |
| 3430 |
{ |
| 3431 |
if (!--player->mo->special1.i) |
| 3432 |
{ |
| 3433 |
P_SetPsprite(player, ps_weapon, HEXEN_S_CSTAFFBLINK1); |
| 3434 |
player->mo->special1.i = (P_Random(pr_hexen) + 50) >> 2; |
| 3435 |
} |
| 3436 |
} |
| 3437 |
|
| 3438 |
#define FLAMESPEED (0.45*FRACUNIT) |
| 3439 |
#define CFLAMERANGE (12*64*FRACUNIT) |
| 3440 |
|
| 3441 |
void A_CFlameAttack(player_t * player, pspdef_t * psp) |
| 3442 |
{ |
| 3443 |
mobj_t *mo; |
| 3444 |
|
| 3445 |
mo = P_SpawnPlayerMissile(player->mo, HEXEN_MT_CFLAME_MISSILE); |
| 3446 |
if (mo) |
| 3447 |
{ |
| 3448 |
mo->thinker.function = P_BlasterMobjThinker; |
| 3449 |
mo->special1.i = 2; |
| 3450 |
} |
| 3451 |
|
| 3452 |
player->ammo[MANA_2] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 3453 |
S_StartMobjSound(player->mo, hexen_sfx_cleric_flame_fire); |
| 3454 |
} |
| 3455 |
|
| 3456 |
void A_CFlamePuff(mobj_t * actor) |
| 3457 |
{ |
| 3458 |
A_UnHideThing(actor); |
| 3459 |
actor->momx = 0; |
| 3460 |
actor->momy = 0; |
| 3461 |
actor->momz = 0; |
| 3462 |
S_StartMobjSound(actor, hexen_sfx_cleric_flame_explode); |
| 3463 |
} |
| 3464 |
|
| 3465 |
void A_CFlameMissile(mobj_t * actor) |
| 3466 |
{ |
| 3467 |
int i; |
| 3468 |
int an; |
| 3469 |
fixed_t dist; |
| 3470 |
mobj_t *mo; |
| 3471 |
|
| 3472 |
A_UnHideThing(actor); |
| 3473 |
S_StartMobjSound(actor, hexen_sfx_cleric_flame_explode); |
| 3474 |
if (BlockingMobj && BlockingMobj->flags & MF_SHOOTABLE) |
| 3475 |
{ // Hit something, so spawn the flame circle around the thing |
| 3476 |
dist = BlockingMobj->radius + 18 * FRACUNIT; |
| 3477 |
for (i = 0; i < 4; i++) |
| 3478 |
{ |
| 3479 |
an = (i * ANG45) >> ANGLETOFINESHIFT; |
| 3480 |
mo = P_SpawnMobj(BlockingMobj->x + FixedMul(dist, finecosine[an]), |
| 3481 |
BlockingMobj->y + FixedMul(dist, finesine[an]), |
| 3482 |
BlockingMobj->z + 5 * FRACUNIT, HEXEN_MT_CIRCLEFLAME); |
| 3483 |
if (mo) |
| 3484 |
{ |
| 3485 |
mo->angle = an << ANGLETOFINESHIFT; |
| 3486 |
P_SetTarget(&mo->target, actor->target); |
| 3487 |
mo->momx = mo->special1.i = |
| 3488 |
FixedMul(FLAMESPEED, finecosine[an]); |
| 3489 |
mo->momy = mo->special2.i = FixedMul(FLAMESPEED, finesine[an]); |
| 3490 |
mo->tics -= P_Random(pr_hexen) & 3; |
| 3491 |
} |
| 3492 |
mo = P_SpawnMobj(BlockingMobj->x - FixedMul(dist, finecosine[an]), |
| 3493 |
BlockingMobj->y - FixedMul(dist, finesine[an]), |
| 3494 |
BlockingMobj->z + 5 * FRACUNIT, HEXEN_MT_CIRCLEFLAME); |
| 3495 |
if (mo) |
| 3496 |
{ |
| 3497 |
mo->angle = ANG180 + (an << ANGLETOFINESHIFT); |
| 3498 |
P_SetTarget(&mo->target, actor->target); |
| 3499 |
mo->momx = mo->special1.i = FixedMul(-FLAMESPEED, |
| 3500 |
finecosine[an]); |
| 3501 |
mo->momy = mo->special2.i = FixedMul(-FLAMESPEED, finesine[an]); |
| 3502 |
mo->tics -= P_Random(pr_hexen) & 3; |
| 3503 |
} |
| 3504 |
} |
| 3505 |
P_SetMobjState(actor, HEXEN_S_FLAMEPUFF2_1); |
| 3506 |
} |
| 3507 |
} |
| 3508 |
|
| 3509 |
#define FLAMEROTSPEED 2*FRACUNIT |
| 3510 |
|
| 3511 |
void A_CFlameRotate(mobj_t * actor) |
| 3512 |
{ |
| 3513 |
int an; |
| 3514 |
|
| 3515 |
an = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 3516 |
actor->momx = actor->special1.i + FixedMul(FLAMEROTSPEED, finecosine[an]); |
| 3517 |
actor->momy = actor->special2.i + FixedMul(FLAMEROTSPEED, finesine[an]); |
| 3518 |
actor->angle += ANG90 / 15; |
| 3519 |
} |
| 3520 |
|
| 3521 |
void A_CHolyAttack3(mobj_t * actor) |
| 3522 |
{ |
| 3523 |
P_SpawnMissile(actor, actor->target, HEXEN_MT_HOLY_MISSILE); |
| 3524 |
S_StartMobjSound(actor, hexen_sfx_choly_fire); |
| 3525 |
} |
| 3526 |
|
| 3527 |
void A_CHolyAttack2(mobj_t * actor) |
| 3528 |
{ |
| 3529 |
int j; |
| 3530 |
int i; |
| 3531 |
int r; |
| 3532 |
mobj_t *mo; |
| 3533 |
mobj_t *tail, *next; |
| 3534 |
|
| 3535 |
for (j = 0; j < 4; j++) |
| 3536 |
{ |
| 3537 |
mo = P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_HOLY_FX); |
| 3538 |
if (!mo) |
| 3539 |
{ |
| 3540 |
continue; |
| 3541 |
} |
| 3542 |
switch (j) |
| 3543 |
{ // float bob index |
| 3544 |
case 0: |
| 3545 |
mo->special2.i = P_Random(pr_hexen) & 7; // upper-left |
| 3546 |
break; |
| 3547 |
case 1: |
| 3548 |
mo->special2.i = 32 + (P_Random(pr_hexen) & 7); // upper-right |
| 3549 |
break; |
| 3550 |
case 2: |
| 3551 |
mo->special2.i = (32 + (P_Random(pr_hexen) & 7)) << 16; // lower-left |
| 3552 |
break; |
| 3553 |
case 3: |
| 3554 |
r = P_Random(pr_hexen); |
| 3555 |
mo->special2.i = |
| 3556 |
((32 + (r & 7)) << 16) + 32 + (P_Random(pr_hexen) & 7); |
| 3557 |
break; |
| 3558 |
} |
| 3559 |
mo->z = actor->z; |
| 3560 |
mo->angle = actor->angle + (ANG45 + ANG45 / 2) - ANG45 * j; |
| 3561 |
P_ThrustMobj(mo, mo->angle, mo->info->speed); |
| 3562 |
P_SetTarget(&mo->target, actor->target); |
| 3563 |
mo->special_args[0] = 10; // initial turn value |
| 3564 |
mo->special_args[1] = 0; // initial look angle |
| 3565 |
if (deathmatch) |
| 3566 |
{ // Ghosts last slightly less longer in DeathMatch |
| 3567 |
mo->health = 85; |
| 3568 |
} |
| 3569 |
if (linetarget) |
| 3570 |
{ |
| 3571 |
P_SetTarget(&mo->special1.m, linetarget); |
| 3572 |
mo->flags |= MF_NOCLIP | MF_SKULLFLY; |
| 3573 |
mo->flags &= ~MF_MISSILE; |
| 3574 |
} |
| 3575 |
tail = P_SpawnMobj(mo->x, mo->y, mo->z, HEXEN_MT_HOLY_TAIL); |
| 3576 |
P_SetTarget(&tail->special2.m, mo); // parent |
| 3577 |
for (i = 1; i < 3; i++) |
| 3578 |
{ |
| 3579 |
next = P_SpawnMobj(mo->x, mo->y, mo->z, HEXEN_MT_HOLY_TAIL); |
| 3580 |
P_SetMobjState(next, next->info->spawnstate + 1); |
| 3581 |
P_SetTarget(&tail->special1.m, next); |
| 3582 |
tail = next; |
| 3583 |
} |
| 3584 |
P_SetTarget(&tail->special1.m, NULL); // last tail bit |
| 3585 |
} |
| 3586 |
} |
| 3587 |
|
| 3588 |
void A_CHolyAttack(player_t * player, pspdef_t * psp) |
| 3589 |
{ |
| 3590 |
player->ammo[MANA_1] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 3591 |
player->ammo[MANA_2] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 3592 |
P_SpawnPlayerMissile(player->mo, HEXEN_MT_HOLY_MISSILE); |
| 3593 |
if (player == &players[consoleplayer]) |
| 3594 |
{ |
| 3595 |
player->damagecount = 0; |
| 3596 |
player->bonuscount = 0; |
| 3597 |
V_SetPalette(STARTHOLYPAL); |
| 3598 |
SB_Start(); |
| 3599 |
} |
| 3600 |
S_StartMobjSound(player->mo, hexen_sfx_choly_fire); |
| 3601 |
} |
| 3602 |
|
| 3603 |
void A_CHolyPalette(player_t * player, pspdef_t * psp) |
| 3604 |
{ |
| 3605 |
int pal; |
| 3606 |
|
| 3607 |
if (player == &players[consoleplayer]) |
| 3608 |
{ |
| 3609 |
pal = STARTHOLYPAL + psp->state - (&states[HEXEN_S_CHOLYATK_6]); |
| 3610 |
if (pal == STARTHOLYPAL + 3) |
| 3611 |
{ // reset back to original playpal |
| 3612 |
pal = 0; |
| 3613 |
} |
| 3614 |
V_SetPalette(pal); |
| 3615 |
SB_Start(); |
| 3616 |
} |
| 3617 |
} |
| 3618 |
|
| 3619 |
static void CHolyFindTarget(mobj_t * actor) |
| 3620 |
{ |
| 3621 |
mobj_t *target; |
| 3622 |
|
| 3623 |
target = P_RoughTargetSearch(actor, 0, 6); |
| 3624 |
if (target != NULL) |
| 3625 |
{ |
| 3626 |
P_SetTarget(&actor->special1.m, target); |
| 3627 |
actor->flags |= MF_NOCLIP | MF_SKULLFLY; |
| 3628 |
actor->flags &= ~MF_MISSILE; |
| 3629 |
} |
| 3630 |
} |
| 3631 |
|
| 3632 |
static void CHolySeekerMissile(mobj_t * actor, angle_t thresh, |
| 3633 |
angle_t turnMax) |
| 3634 |
{ |
| 3635 |
int dir; |
| 3636 |
int dist; |
| 3637 |
angle_t delta; |
| 3638 |
angle_t angle; |
| 3639 |
mobj_t *target; |
| 3640 |
fixed_t newZ; |
| 3641 |
fixed_t deltaZ; |
| 3642 |
|
| 3643 |
target = actor->special1.m; |
| 3644 |
if (target == NULL) |
| 3645 |
{ |
| 3646 |
return; |
| 3647 |
} |
| 3648 |
if (!(target->flags & MF_SHOOTABLE) |
| 3649 |
|| (!(target->flags & MF_COUNTKILL) && !target->player)) |
| 3650 |
{ // Target died/target isn't a player or creature |
| 3651 |
P_SetTarget(&actor->special1.m, NULL); |
| 3652 |
actor->flags &= ~(MF_NOCLIP | MF_SKULLFLY); |
| 3653 |
actor->flags |= MF_MISSILE; |
| 3654 |
CHolyFindTarget(actor); |
| 3655 |
return; |
| 3656 |
} |
| 3657 |
dir = P_FaceMobj(actor, target, &delta); |
| 3658 |
if (delta > thresh) |
| 3659 |
{ |
| 3660 |
delta >>= 1; |
| 3661 |
if (delta > turnMax) |
| 3662 |
{ |
| 3663 |
delta = turnMax; |
| 3664 |
} |
| 3665 |
} |
| 3666 |
if (dir) |
| 3667 |
{ // Turn clockwise |
| 3668 |
actor->angle += delta; |
| 3669 |
} |
| 3670 |
else |
| 3671 |
{ // Turn counter clockwise |
| 3672 |
actor->angle -= delta; |
| 3673 |
} |
| 3674 |
angle = actor->angle >> ANGLETOFINESHIFT; |
| 3675 |
actor->momx = FixedMul(actor->info->speed, finecosine[angle]); |
| 3676 |
actor->momy = FixedMul(actor->info->speed, finesine[angle]); |
| 3677 |
if (!(leveltime & 15) |
| 3678 |
|| actor->z > target->z + (target->height) |
| 3679 |
|| actor->z + actor->height < target->z) |
| 3680 |
{ |
| 3681 |
newZ = target->z + ((P_Random(pr_hexen) * target->height) >> 8); |
| 3682 |
deltaZ = newZ - actor->z; |
| 3683 |
if (abs(deltaZ) > 15 * FRACUNIT) |
| 3684 |
{ |
| 3685 |
if (deltaZ > 0) |
| 3686 |
{ |
| 3687 |
deltaZ = 15 * FRACUNIT; |
| 3688 |
} |
| 3689 |
else |
| 3690 |
{ |
| 3691 |
deltaZ = -15 * FRACUNIT; |
| 3692 |
} |
| 3693 |
} |
| 3694 |
dist = P_AproxDistance(target->x - actor->x, target->y - actor->y); |
| 3695 |
dist = dist / actor->info->speed; |
| 3696 |
if (dist < 1) |
| 3697 |
{ |
| 3698 |
dist = 1; |
| 3699 |
} |
| 3700 |
actor->momz = deltaZ / dist; |
| 3701 |
} |
| 3702 |
return; |
| 3703 |
} |
| 3704 |
|
| 3705 |
static void CHolyWeave(mobj_t * actor) |
| 3706 |
{ |
| 3707 |
fixed_t newX, newY; |
| 3708 |
int weaveXY, weaveZ; |
| 3709 |
int angle; |
| 3710 |
|
| 3711 |
weaveXY = actor->special2.i >> 16; |
| 3712 |
weaveZ = actor->special2.i & 0xFFFF; |
| 3713 |
angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; |
| 3714 |
newX = actor->x - FixedMul(finecosine[angle], |
| 3715 |
FloatBobOffsets[weaveXY] << 2); |
| 3716 |
newY = actor->y - FixedMul(finesine[angle], |
| 3717 |
FloatBobOffsets[weaveXY] << 2); |
| 3718 |
weaveXY = (weaveXY + (P_Random(pr_hexen) % 5)) & 63; |
| 3719 |
newX += FixedMul(finecosine[angle], FloatBobOffsets[weaveXY] << 2); |
| 3720 |
newY += FixedMul(finesine[angle], FloatBobOffsets[weaveXY] << 2); |
| 3721 |
P_TryMove(actor, newX, newY, 0); |
| 3722 |
actor->z -= FloatBobOffsets[weaveZ] << 1; |
| 3723 |
weaveZ = (weaveZ + (P_Random(pr_hexen) % 5)) & 63; |
| 3724 |
actor->z += FloatBobOffsets[weaveZ] << 1; |
| 3725 |
actor->special2.i = weaveZ + (weaveXY << 16); |
| 3726 |
} |
| 3727 |
|
| 3728 |
void A_CHolySeek(mobj_t * actor) |
| 3729 |
{ |
| 3730 |
actor->health--; |
| 3731 |
if (actor->health <= 0) |
| 3732 |
{ |
| 3733 |
actor->momx >>= 2; |
| 3734 |
actor->momy >>= 2; |
| 3735 |
actor->momz = 0; |
| 3736 |
P_SetMobjState(actor, actor->info->deathstate); |
| 3737 |
actor->tics -= P_Random(pr_hexen) & 3; |
| 3738 |
return; |
| 3739 |
} |
| 3740 |
if (actor->special1.m) |
| 3741 |
{ |
| 3742 |
CHolySeekerMissile(actor, actor->special_args[0] * ANG1, |
| 3743 |
actor->special_args[0] * ANG1 * 2); |
| 3744 |
if (!((leveltime + 7) & 15)) |
| 3745 |
{ |
| 3746 |
actor->special_args[0] = 5 + (P_Random(pr_hexen) / 20); |
| 3747 |
} |
| 3748 |
} |
| 3749 |
CHolyWeave(actor); |
| 3750 |
} |
| 3751 |
|
| 3752 |
static void CHolyTailFollow(mobj_t * actor, fixed_t dist) |
| 3753 |
{ |
| 3754 |
mobj_t *child; |
| 3755 |
int an; |
| 3756 |
fixed_t oldDistance, newDistance; |
| 3757 |
|
| 3758 |
child = actor->special1.m; |
| 3759 |
if (child) |
| 3760 |
{ |
| 3761 |
an = R_PointToAngle2(actor->x, actor->y, child->x, |
| 3762 |
child->y) >> ANGLETOFINESHIFT; |
| 3763 |
oldDistance = |
| 3764 |
P_AproxDistance(child->x - actor->x, child->y - actor->y); |
| 3765 |
if ( |
| 3766 |
P_TryMove( |
| 3767 |
child, |
| 3768 |
actor->x + FixedMul(dist, finecosine[an]), |
| 3769 |
actor->y + FixedMul(dist, finesine[an]), |
| 3770 |
0 |
| 3771 |
) |
| 3772 |
) |
| 3773 |
{ |
| 3774 |
newDistance = P_AproxDistance(child->x - actor->x, |
| 3775 |
child->y - actor->y) - FRACUNIT; |
| 3776 |
if (oldDistance < FRACUNIT) |
| 3777 |
{ |
| 3778 |
if (child->z < actor->z) |
| 3779 |
{ |
| 3780 |
child->z = actor->z - dist; |
| 3781 |
} |
| 3782 |
else |
| 3783 |
{ |
| 3784 |
child->z = actor->z + dist; |
| 3785 |
} |
| 3786 |
} |
| 3787 |
else |
| 3788 |
{ |
| 3789 |
child->z = actor->z + FixedMul(FixedDiv(newDistance, |
| 3790 |
oldDistance), |
| 3791 |
child->z - actor->z); |
| 3792 |
} |
| 3793 |
} |
| 3794 |
CHolyTailFollow(child, dist - FRACUNIT); |
| 3795 |
} |
| 3796 |
} |
| 3797 |
|
| 3798 |
static void CHolyTailRemove(mobj_t * actor) |
| 3799 |
{ |
| 3800 |
mobj_t *child; |
| 3801 |
|
| 3802 |
child = actor->special1.m; |
| 3803 |
if (child) |
| 3804 |
{ |
| 3805 |
CHolyTailRemove(child); |
| 3806 |
} |
| 3807 |
P_RemoveMobj(actor); |
| 3808 |
} |
| 3809 |
|
| 3810 |
void A_CHolyTail(mobj_t * actor) |
| 3811 |
{ |
| 3812 |
mobj_t *parent; |
| 3813 |
|
| 3814 |
parent = actor->special2.m; |
| 3815 |
|
| 3816 |
if (parent) |
| 3817 |
{ |
| 3818 |
if (parent->state >= &states[parent->info->deathstate]) |
| 3819 |
{ // Ghost removed, so remove all tail parts |
| 3820 |
CHolyTailRemove(actor); |
| 3821 |
return; |
| 3822 |
} |
| 3823 |
else if ( |
| 3824 |
P_TryMove( |
| 3825 |
actor, |
| 3826 |
parent->x - FixedMul(14 * FRACUNIT, finecosine[parent->angle >> ANGLETOFINESHIFT]), |
| 3827 |
parent->y - FixedMul(14 * FRACUNIT, finesine[parent->angle >> ANGLETOFINESHIFT]), |
| 3828 |
0 |
| 3829 |
) |
| 3830 |
) |
| 3831 |
{ |
| 3832 |
actor->z = parent->z - 5 * FRACUNIT; |
| 3833 |
} |
| 3834 |
CHolyTailFollow(actor, 10 * FRACUNIT); |
| 3835 |
} |
| 3836 |
} |
| 3837 |
|
| 3838 |
void A_CHolyCheckScream(mobj_t * actor) |
| 3839 |
{ |
| 3840 |
A_CHolySeek(actor); |
| 3841 |
if (P_Random(pr_hexen) < 20) |
| 3842 |
{ |
| 3843 |
S_StartMobjSound(actor, hexen_sfx_spirit_active); |
| 3844 |
} |
| 3845 |
if (!actor->special1.m) |
| 3846 |
{ |
| 3847 |
CHolyFindTarget(actor); |
| 3848 |
} |
| 3849 |
} |
| 3850 |
|
| 3851 |
void A_CHolySpawnPuff(mobj_t * actor) |
| 3852 |
{ |
| 3853 |
P_SpawnMobj(actor->x, actor->y, actor->z, HEXEN_MT_HOLY_MISSILE_PUFF); |
| 3854 |
} |
| 3855 |
|
| 3856 |
#define SHARDSPAWN_LEFT 1 |
| 3857 |
#define SHARDSPAWN_RIGHT 2 |
| 3858 |
#define SHARDSPAWN_UP 4 |
| 3859 |
#define SHARDSPAWN_DOWN 8 |
| 3860 |
|
| 3861 |
void A_FireConePL1(player_t * player, pspdef_t * psp) |
| 3862 |
{ |
| 3863 |
angle_t angle; |
| 3864 |
int damage; |
| 3865 |
int i; |
| 3866 |
mobj_t *pmo, *mo; |
| 3867 |
int conedone = false; |
| 3868 |
|
| 3869 |
pmo = player->mo; |
| 3870 |
player->ammo[MANA_1] -= WeaponManaUse[player->pclass][player->readyweapon]; |
| 3871 |
S_StartMobjSound(pmo, hexen_sfx_mage_shards_fire); |
| 3872 |
|
| 3873 |
damage = 90 + (P_Random(pr_hexen) & 15); |
| 3874 |
for (i = 0; i < 16; i++) |
| 3875 |
{ |
| 3876 |
angle = pmo->angle + i * (ANG45 / 16); |
| 3877 |
P_AimLineAttack(pmo, angle, MELEERANGE, 0); |
| 3878 |
if (linetarget) |
| 3879 |
{ |
| 3880 |
pmo->flags2 |= MF2_ICEDAMAGE; |
| 3881 |
P_DamageMobj(linetarget, pmo, pmo, damage); |
| 3882 |
pmo->flags2 &= ~MF2_ICEDAMAGE; |
| 3883 |
conedone = true; |
| 3884 |
break; |
| 3885 |
} |
| 3886 |
} |
| 3887 |
|
| 3888 |
// didn't find any creatures, so fire projectiles |
| 3889 |
if (!conedone) |
| 3890 |
{ |
| 3891 |
mo = P_SpawnPlayerMissile(pmo, HEXEN_MT_SHARDFX1); |
| 3892 |
if (mo) |
| 3893 |
{ |
| 3894 |
mo->special1.i = SHARDSPAWN_LEFT | SHARDSPAWN_DOWN | SHARDSPAWN_UP |
| 3895 |
| SHARDSPAWN_RIGHT; |
| 3896 |
mo->special2.i = 3; // Set sperm count (levels of reproductivity) |
| 3897 |
P_SetTarget(&mo->target, pmo); |
| 3898 |
mo->special_args[0] = 3; // Mark Initial shard as super damage |
| 3899 |
} |
| 3900 |
} |
| 3901 |
} |
| 3902 |
|
| 3903 |
void A_ShedShard(mobj_t * actor) |
| 3904 |
{ |
| 3905 |
mobj_t *mo; |
| 3906 |
int spawndir = actor->special1.i; |
| 3907 |
int spermcount = actor->special2.i; |
| 3908 |
|
| 3909 |
if (spermcount <= 0) |
| 3910 |
return; // No sperm left |
| 3911 |
actor->special2.i = 0; |
| 3912 |
spermcount--; |
| 3913 |
|
| 3914 |
// every so many calls, spawn a new missile in it's set directions |
| 3915 |
if (spawndir & SHARDSPAWN_LEFT) |
| 3916 |
{ |
| 3917 |
mo = P_SpawnMissileAngleSpeed(actor, HEXEN_MT_SHARDFX1, |
| 3918 |
actor->angle + (ANG45 / 9), 0, |
| 3919 |
(20 + 2 * spermcount) << FRACBITS); |
| 3920 |
if (mo) |
| 3921 |
{ |
| 3922 |
mo->special1.i = SHARDSPAWN_LEFT; |
| 3923 |
mo->special2.i = spermcount; |
| 3924 |
mo->momz = actor->momz; |
| 3925 |
P_SetTarget(&mo->target, actor->target); |
| 3926 |
mo->special_args[0] = (spermcount == 3) ? 2 : 0; |
| 3927 |
} |
| 3928 |
} |
| 3929 |
if (spawndir & SHARDSPAWN_RIGHT) |
| 3930 |
{ |
| 3931 |
mo = P_SpawnMissileAngleSpeed(actor, HEXEN_MT_SHARDFX1, |
| 3932 |
actor->angle - (ANG45 / 9), 0, |
| 3933 |
(20 + 2 * spermcount) << FRACBITS); |
| 3934 |
if (mo) |
| 3935 |
{ |
| 3936 |
mo->special1.i = SHARDSPAWN_RIGHT; |
| 3937 |
mo->special2.i = spermcount; |
| 3938 |
mo->momz = actor->momz; |
| 3939 |
P_SetTarget(&mo->target, actor->target); |
| 3940 |
mo->special_args[0] = (spermcount == 3) ? 2 : 0; |
| 3941 |
} |
| 3942 |
} |
| 3943 |
if (spawndir & SHARDSPAWN_UP) |
| 3944 |
{ |
| 3945 |
mo = P_SpawnMissileAngleSpeed(actor, HEXEN_MT_SHARDFX1, actor->angle, |
| 3946 |
0, (15 + 2 * spermcount) << FRACBITS); |
| 3947 |
if (mo) |
| 3948 |
{ |
| 3949 |
mo->momz = actor->momz; |
| 3950 |
mo->z += 8 * FRACUNIT; |
| 3951 |
if (spermcount & 1) // Every other reproduction |
| 3952 |
mo->special1.i = |
| 3953 |
SHARDSPAWN_UP | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT; |
| 3954 |
else |
| 3955 |
mo->special1.i = SHARDSPAWN_UP; |
| 3956 |
mo->special2.i = spermcount; |
| 3957 |
P_SetTarget(&mo->target, actor->target); |
| 3958 |
mo->special_args[0] = (spermcount == 3) ? 2 : 0; |
| 3959 |
} |
| 3960 |
} |
| 3961 |
if (spawndir & SHARDSPAWN_DOWN) |
| 3962 |
{ |
| 3963 |
mo = P_SpawnMissileAngleSpeed(actor, HEXEN_MT_SHARDFX1, actor->angle, |
| 3964 |
0, (15 + 2 * spermcount) << FRACBITS); |
| 3965 |
if (mo) |
| 3966 |
{ |
| 3967 |
mo->momz = actor->momz; |
| 3968 |
mo->z -= 4 * FRACUNIT; |
| 3969 |
if (spermcount & 1) // Every other reproduction |
| 3970 |
mo->special1.i = |
| 3971 |
SHARDSPAWN_DOWN | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT; |
| 3972 |
else |
| 3973 |
mo->special1.i = SHARDSPAWN_DOWN; |
| 3974 |
mo->special2.i = spermcount; |
| 3975 |
P_SetTarget(&mo->target, actor->target); |
| 3976 |
mo->special_args[0] = (spermcount == 3) ? 2 : 0; |
| 3977 |
} |
| 3978 |
} |
| 3979 |
} |