- added DavidPH's A_Saw extension submission.

SVN r2453 (trunk)
This commit is contained in:
Christoph Oelckers 2010-07-24 06:21:53 +00:00
parent 58be666c9c
commit a6499a6efb
3 changed files with 64 additions and 20 deletions

View File

@ -100,52 +100,88 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
//
// A_Saw
//
enum SAW_Flags
{
SF_NORANDOM = 1,
SF_RANDOMLIGHTMISS = 2,
SF_RANDOMLIGHTHIT = 4,
SF_NOUSEAMMOMISS = 8,
SF_NOUSEAMMO = 16,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
{
angle_t angle;
angle_t angle;
angle_t slope;
player_t *player;
AActor *linetarget;
ACTION_PARAM_START(4);
ACTION_PARAM_START(9);
ACTION_PARAM_SOUND(fullsound, 0);
ACTION_PARAM_SOUND(hitsound, 1);
ACTION_PARAM_INT(damage, 2);
ACTION_PARAM_CLASS(pufftype, 3);
ACTION_PARAM_FIXED(Range, 4)
ACTION_PARAM_FIXED(LifeSteal, 5);
ACTION_PARAM_INT(Flags, 4);
ACTION_PARAM_FIXED(Range, 5);
ACTION_PARAM_ANGLE(Spread_XY, 6);
ACTION_PARAM_ANGLE(Spread_Z, 7);
ACTION_PARAM_FIXED(LifeSteal, 8);
if (NULL == (player = self->player))
{
return;
}
if (pufftype == NULL) pufftype = PClass::FindClass(NAME_BulletPuff);
if (damage == 0) damage = 2;
if (!(Flags & SF_NORANDOM))
damage *= (pr_saw()%10+1);
// use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states)
if (Range == 0) Range = MELEERANGE+1;
angle = self->angle + (pr_saw.Random2() * (Spread_XY / 255));
slope = P_AimLineAttack (self, angle, Range, &linetarget) + (pr_saw.Random2() * (Spread_Z / 255));
P_LineAttack (self, angle, Range,
slope, damage,
NAME_None, pufftype);
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if ((weapon != NULL) && !(Flags & SF_NOUSEAMMO) && !(!linetarget && (Flags & SF_NOUSEAMMOMISS)))
{
if (!weapon->DepleteAmmo (weapon->bAltFire))
return;
}
if (pufftype == NULL) pufftype = PClass::FindClass(NAME_BulletPuff);
if (damage == 0) damage = 2;
damage *= (pr_saw()%10+1);
angle = self->angle;
angle += pr_saw.Random2() << 18;
// use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states)
if (Range == 0) Range = MELEERANGE+1;
P_LineAttack (self, angle, Range,
P_AimLineAttack (self, angle, Range, &linetarget), damage,
NAME_None, pufftype);
if (!linetarget)
{
if ((Flags & SF_RANDOMLIGHTMISS) && (pr_saw() > 64))
{
player->extralight = !player->extralight;
}
S_Sound (self, CHAN_WEAPON, fullsound, 1, ATTN_NORM);
return;
}
if (Flags & SF_RANDOMLIGHTHIT)
{
int randVal = pr_saw();
if (randVal < 64)
{
player->extralight = 0;
}
else if (randVal < 160)
{
player->extralight = 1;
}
else
{
player->extralight = 2;
}
}
if (LifeSteal)
P_GiveBody (self, (damage * LifeSteal) >> FRACBITS);

View File

@ -1,4 +1,12 @@
// Flags for A_Saw
const int SF_NORANDOM = 1;
const int SF_RANDOMLIGHTMISS = 2;
const int SF_RANDOMLIGHTHIT = 4;
const int SF_RANDOMLIGHTBOTH = 6;
const int SF_NOUSEAMMOMISS = 8;
const int SF_NOUSEAMMO = 16;
// Flags for A_CustomMissile
const int CMF_AIMOFFSET = 1;
const int CMF_AIMDIRECTION = 2;

View File

@ -40,7 +40,7 @@ ACTOR Inventory native
action native A_ClearReFire();
action native A_CheckReload();
action native A_GunFlash(state flash = "");
action native A_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class<Actor> pufftype = "BulletPuff", float range = 0, float lifesteal = 0);
action native A_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class<Actor> pufftype = "BulletPuff", int flags = 0, float range = 0, float spread_xy = 2.8125, float spread_z = 0, float lifesteal = 0);
action native A_CheckForReload(int counter, state label, bool dontincrement = false);
action native A_ResetReloadCounter();
action native A_RestoreSpecialPosition();