2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_pickups.h"
|
|
|
|
#include "a_doomglobal.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "p_pspr.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "p_effect.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "templates.h"
|
2007-05-28 14:46:49 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_punch ("Punch");
|
|
|
|
static FRandom pr_saw ("Saw");
|
|
|
|
static FRandom pr_fireshotgun2 ("FireSG2");
|
|
|
|
static FRandom pr_fireplasma ("FirePlasma");
|
|
|
|
static FRandom pr_firerail ("FireRail");
|
|
|
|
static FRandom pr_bfgspray ("BFGSpray");
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_Punch
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Punch)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
angle_t angle;
|
|
|
|
int damage;
|
|
|
|
int pitch;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor *linetarget;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->player != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
damage = (pr_punch()%10+1)<<1;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->FindInventory<APowerStrength>())
|
2006-02-24 04:48:15 +00:00
|
|
|
damage *= 10;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
angle = self->angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
angle += pr_punch.Random2() << 18;
|
2008-08-10 20:48:55 +00:00
|
|
|
pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget);
|
|
|
|
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// turn to face target
|
|
|
|
if (linetarget)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
|
|
|
|
self->angle = R_PointToAngle2 (self->x,
|
|
|
|
self->y,
|
2006-02-24 04:48:15 +00:00
|
|
|
linetarget->x,
|
|
|
|
linetarget->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_FirePistol
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
bool accurate;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->player != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SetPsprite (self->player, ps_flash, weapon->FindState(NAME_Flash));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
self->player->mo->PlayAttacking2 ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
accurate = !self->player->refire;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
accurate = true;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_GunShot (self, accurate, PClass::FindClass(NAME_BulletPuff), P_BulletSlope (self));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_Saw
|
|
|
|
//
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
angle_t angle;
|
2006-08-10 15:28:12 +00:00
|
|
|
int damage=0;
|
2006-02-24 04:48:15 +00:00
|
|
|
player_t *player;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor *linetarget;
|
2006-08-10 15:28:12 +00:00
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
FSoundID fullsound;
|
|
|
|
FSoundID hitsound;
|
2006-08-10 15:28:12 +00:00
|
|
|
const PClass * pufftype = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
int index = CheckIndex (4);
|
2008-08-12 20:19:47 +00:00
|
|
|
if (index < 0) return;
|
|
|
|
|
|
|
|
fullsound = FSoundID(StateParameters[index]);
|
|
|
|
hitsound = FSoundID(StateParameters[index+1]);
|
|
|
|
damage = EvalExpressionI (StateParameters[index+2], self);
|
|
|
|
pufftype = PClass::FindClass ((ENamedName)StateParameters[index+3]);
|
2006-11-04 13:06:42 +00:00
|
|
|
if (pufftype == NULL) pufftype = PClass::FindClass(NAME_BulletPuff);
|
2006-08-10 15:28:12 +00:00
|
|
|
if (damage == 0) damage = 2;
|
|
|
|
|
|
|
|
damage *= (pr_saw()%10+1);
|
2008-08-10 20:48:55 +00:00
|
|
|
angle = self->angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle += pr_saw.Random2() << 18;
|
|
|
|
|
2006-08-10 15:28:12 +00:00
|
|
|
// use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states)
|
2008-08-10 20:48:55 +00:00
|
|
|
P_LineAttack (self, angle, MELEERANGE+1,
|
|
|
|
P_AimLineAttack (self, angle, MELEERANGE+1, &linetarget), damage,
|
2007-11-11 09:02:04 +00:00
|
|
|
GetDefaultByType(pufftype)->DamageType, pufftype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!linetarget)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, fullsound, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// turn to face target
|
2008-08-10 20:48:55 +00:00
|
|
|
angle = R_PointToAngle2 (self->x, self->y,
|
2006-02-24 04:48:15 +00:00
|
|
|
linetarget->x, linetarget->y);
|
2008-08-10 20:48:55 +00:00
|
|
|
if (angle - self->angle > ANG180)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (angle - self->angle < (angle_t)(-ANG90/20))
|
|
|
|
self->angle = angle + ANG90/21;
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2008-08-10 20:48:55 +00:00
|
|
|
self->angle -= ANG90/20;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (angle - self->angle > ANG90/20)
|
|
|
|
self->angle = angle - ANG90/21;
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2008-08-10 20:48:55 +00:00
|
|
|
self->angle += ANG90/20;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags |= MF_JUSTATTACKED;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_FireShotgun
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM);
|
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
2006-10-31 14:53:21 +00:00
|
|
|
P_SetPsprite (player, ps_flash, weapon->FindState(NAME_Flash));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
player->mo->PlayAttacking2 ();
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
angle_t pitch = P_BulletSlope (self);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (i=0 ; i<7 ; i++)
|
2008-08-10 20:48:55 +00:00
|
|
|
P_GunShot (self, false, PClass::FindClass(NAME_BulletPuff), pitch);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_FireShotgun2
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
angle_t angle;
|
|
|
|
int damage;
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
|
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
2006-10-31 14:53:21 +00:00
|
|
|
P_SetPsprite (player, ps_flash, weapon->FindState(NAME_Flash));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
player->mo->PlayAttacking2 ();
|
|
|
|
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
angle_t pitch = P_BulletSlope (self);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (i=0 ; i<20 ; i++)
|
|
|
|
{
|
|
|
|
damage = 5*(pr_fireshotgun2()%3+1);
|
2008-08-10 20:48:55 +00:00
|
|
|
angle = self->angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle += pr_fireshotgun2.Random2() << 19;
|
|
|
|
|
|
|
|
// Doom adjusts the bullet slope by shifting a random number [-255,255]
|
|
|
|
// left 5 places. At 2048 units away, this means the vertical position
|
|
|
|
// of the shot can deviate as much as 255 units from nominal. So using
|
|
|
|
// some simple trigonometry, that means the vertical angle of the shot
|
|
|
|
// can deviate by as many as ~7.097 degrees or ~84676099 BAMs.
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_LineAttack (self,
|
2006-02-24 04:48:15 +00:00
|
|
|
angle,
|
|
|
|
PLAYERMISSILERANGE,
|
2008-04-10 14:38:43 +00:00
|
|
|
pitch + (pr_fireshotgun2.Random2() * 332063), damage,
|
2006-11-04 13:06:42 +00:00
|
|
|
NAME_None, NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_OpenShotgun2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/sshoto", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_LoadShotgun2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/sshotl", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CloseShotgun2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/sshotc", 1, ATTN_NORM);
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_ReFire, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-28 09:06:32 +00:00
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Setting a random flash like some of Doom's weapons can easily crash when the
|
|
|
|
// definition is overridden incorrectly so let's check that the state actually exists.
|
|
|
|
// Be aware though that this will not catch all DEHACKED related problems. But it will
|
|
|
|
// find all DECORATE related ones.
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------------
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-04-28 09:06:32 +00:00
|
|
|
void P_SetSafeFlash(AWeapon * weapon, player_t * player, FState * flashstate, int index)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
|
2007-04-28 09:06:32 +00:00
|
|
|
const PClass * cls = weapon->GetClass();
|
|
|
|
while (cls != RUNTIME_CLASS(AWeapon))
|
|
|
|
{
|
|
|
|
FActorInfo * info = cls->ActorInfo;
|
|
|
|
if (flashstate >= info->OwnedStates && flashstate < info->OwnedStates + info->NumOwnedStates)
|
|
|
|
{
|
|
|
|
// The flash state belongs to this class.
|
|
|
|
// Now let's check if the actually wanted state does also
|
|
|
|
if (flashstate+index < info->OwnedStates + info->NumOwnedStates)
|
|
|
|
{
|
|
|
|
// we're ok so set the state
|
|
|
|
P_SetPsprite (player, ps_flash, flashstate + index);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// oh, no! The state is beyond the end of the state table so use the original flash state.
|
|
|
|
P_SetPsprite (player, ps_flash, flashstate);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// try again with parent class
|
|
|
|
cls = cls->ParentClass;
|
|
|
|
}
|
|
|
|
// if we get here the state doesn't seem to belong to any class in the inheritance chain
|
|
|
|
// This can happen with Dehacked if the flash states are remapped.
|
|
|
|
// The only way to check this would be to go through all Dehacked modifiable actors and
|
|
|
|
// find the correct one.
|
|
|
|
// For now let's assume that it will work.
|
|
|
|
P_SetPsprite (player, ps_flash, flashstate + index);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// A_FireCGun
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireCGun)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self == NULL || NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AWeapon *weapon = player->ReadyWeapon;
|
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
2006-10-31 14:53:21 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM);
|
2007-01-31 00:52:33 +00:00
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
FState *flash = weapon->FindState(NAME_Flash);
|
|
|
|
if (flash != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// [RH] Fix for Sparky's messed-up Dehacked patch! Blargh!
|
2006-10-31 14:53:21 +00:00
|
|
|
FState * atk = weapon->FindState(NAME_Fire);
|
|
|
|
|
2007-09-27 14:08:45 +00:00
|
|
|
int theflash = clamp (int(player->psprites[ps_weapon].state - atk), 0, 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 14:19:47 +00:00
|
|
|
if (flash[theflash].sprite != flash->sprite)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
theflash = 0;
|
|
|
|
}
|
|
|
|
|
2007-04-28 09:06:32 +00:00
|
|
|
P_SetSafeFlash (weapon, player, flash, theflash);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
player->mo->PlayAttacking2 ();
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_GunShot (self, !player->refire, PClass::FindClass(NAME_BulletPuff), P_BulletSlope (self));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_FireMissile
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnPlayerMissile (self, PClass::FindClass("Rocket"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_FirePlasma
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
2006-10-31 14:53:21 +00:00
|
|
|
|
|
|
|
FState *flash = weapon->FindState(NAME_Flash);
|
|
|
|
if (flash != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-04-28 09:06:32 +00:00
|
|
|
P_SetSafeFlash(weapon, player, flash, (pr_fireplasma()&1));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnPlayerMissile (self, PClass::FindClass("PlasmaBall"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// [RH] A_FireRailgun
|
|
|
|
//
|
2008-08-10 22:48:37 +00:00
|
|
|
static void FireRailgun(AActor *self, int RailOffset)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int damage;
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
2006-10-31 14:53:21 +00:00
|
|
|
|
|
|
|
FState *flash = weapon->FindState(NAME_Flash);
|
|
|
|
if (flash != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-04-28 09:06:32 +00:00
|
|
|
P_SetSafeFlash(weapon, player, flash, (pr_firerail()&1));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
damage = deathmatch ? 100 : 150;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_RailAttack (self, damage, RailOffset);
|
2008-08-10 22:48:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun)
|
|
|
|
{
|
|
|
|
FireRailgun(self, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
FireRailgun(self, 10);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
FireRailgun(self, -10);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_RailWait)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Okay, this was stupid. Just use a NULL function instead of this.
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_FireBFG
|
|
|
|
//
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FireBFG)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// [RH] bfg can be forced to not use freeaim
|
2008-08-10 20:48:55 +00:00
|
|
|
angle_t storedpitch = self->pitch;
|
2006-02-24 04:48:15 +00:00
|
|
|
int storedaimdist = player->userinfo.aimdist;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dmflags2 & DF2_NO_FREEAIMBFG)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->pitch = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
player->userinfo.aimdist = ANGLE_1*35;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnPlayerMissile (self, PClass::FindClass("BFGBall"));
|
|
|
|
self->pitch = storedpitch;
|
2006-02-24 04:48:15 +00:00
|
|
|
player->userinfo.aimdist = storedaimdist;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_BFGSpray
|
|
|
|
// Spawn a BFG explosion on every monster in view
|
|
|
|
//
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int damage;
|
|
|
|
angle_t an;
|
|
|
|
AActor *thingToHit;
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *spraytype = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
int numrays = 40;
|
2006-04-11 08:36:23 +00:00
|
|
|
int damagecnt = 15;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor *linetarget;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
int index = CheckIndex (3);
|
2008-08-12 20:19:47 +00:00
|
|
|
if (index < 0) return;
|
|
|
|
|
|
|
|
spraytype = PClass::FindClass ((ENamedName)StateParameters[index]);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (spraytype == NULL)
|
2007-04-28 09:06:32 +00:00
|
|
|
spraytype = PClass::FindClass("BFGExtra");
|
2008-08-12 20:19:47 +00:00
|
|
|
numrays = EvalExpressionI (StateParameters[index+1], self);
|
|
|
|
if (numrays <= 0)
|
|
|
|
numrays = 40;
|
|
|
|
damagecnt = EvalExpressionI (StateParameters[index+2], self);
|
|
|
|
if (damagecnt <= 0)
|
|
|
|
damagecnt = 15;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Don't crash if no target
|
2008-08-10 20:48:55 +00:00
|
|
|
if (!self->target)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// offset angles from its attack angle
|
|
|
|
for (i = 0; i < numrays; i++)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
an = self->angle - ANG90/2 + ANG90/numrays*i;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
// self->target is the originator (player) of the missile
|
|
|
|
P_AimLineAttack (self->target, an, 16*64*FRACUNIT, &linetarget, ANGLE_1*32);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!linetarget)
|
|
|
|
continue;
|
|
|
|
|
2008-07-05 10:17:10 +00:00
|
|
|
AActor *spray = Spawn (spraytype, linetarget->x, linetarget->y,
|
2006-07-16 09:10:45 +00:00
|
|
|
linetarget->z + (linetarget->height>>2), ALLOW_REPLACE);
|
2008-07-05 10:17:10 +00:00
|
|
|
|
|
|
|
if (spray && (spray->flags5 & MF5_PUFFGETSOWNER))
|
2008-08-10 20:48:55 +00:00
|
|
|
spray->target = self->target;
|
2008-07-05 10:17:10 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
damage = 0;
|
2006-04-11 08:36:23 +00:00
|
|
|
for (j = 0; j < damagecnt; ++j)
|
2006-02-24 04:48:15 +00:00
|
|
|
damage += (pr_bfgspray() & 7) + 1;
|
|
|
|
|
|
|
|
thingToHit = linetarget;
|
2008-08-10 20:48:55 +00:00
|
|
|
P_DamageMobj (thingToHit, self->target, self->target, damage, NAME_BFGSplash);
|
|
|
|
P_TraceBleed (damage, thingToHit, self->target);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_BFGsound
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BFGsound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "weapons/bfgf", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|