2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "a_action.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_posattack ("PosAttack");
|
|
|
|
static FRandom pr_sposattack ("SPosAttack");
|
|
|
|
static FRandom pr_cposattack ("CPosAttack");
|
|
|
|
static FRandom pr_cposrefire ("CPosRefire");
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_PosAttack
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_PosAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int angle;
|
|
|
|
int damage;
|
|
|
|
int slope;
|
|
|
|
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
angle = self->angle;
|
|
|
|
slope = P_AimLineAttack (self, angle, MISSILERANGE);
|
|
|
|
|
|
|
|
S_Sound (self, CHAN_WEAPON, "grunt/attack", 1, ATTN_NORM);
|
|
|
|
angle += pr_posattack.Random2() << 20;
|
|
|
|
damage = ((pr_posattack()%5)+1)*3;
|
2012-06-17 03:18:26 +00:00
|
|
|
P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void A_SPosAttack2 (AActor *self)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int bangle;
|
|
|
|
int slope;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
bangle = self->angle;
|
|
|
|
slope = P_AimLineAttack (self, bangle, MISSILERANGE);
|
|
|
|
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
int angle = bangle + (pr_sposattack.Random2() << 20);
|
|
|
|
int damage = ((pr_sposattack()%5)+1)*3;
|
2012-06-17 03:18:26 +00:00
|
|
|
P_LineAttack(self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SPosAttackUseAtkSound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
A_SPosAttack2 (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This version of the function, which uses a hard-coded sound, is
|
|
|
|
// meant for Dehacked only.
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SPosAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
S_Sound (self, CHAN_WEAPON, "shotguy/attack", 1, ATTN_NORM);
|
|
|
|
A_SPosAttack2 (self);
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CPosAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int angle;
|
|
|
|
int bangle;
|
|
|
|
int damage;
|
|
|
|
int slope;
|
|
|
|
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// [RH] Andy Baker's stealth monsters
|
|
|
|
if (self->flags & MF_STEALTH)
|
|
|
|
{
|
|
|
|
self->visdir = 1;
|
|
|
|
}
|
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
A_FaceTarget (self);
|
|
|
|
bangle = self->angle;
|
|
|
|
slope = P_AimLineAttack (self, bangle, MISSILERANGE);
|
|
|
|
|
|
|
|
angle = bangle + (pr_cposattack.Random2() << 20);
|
|
|
|
damage = ((pr_cposattack()%5)+1)*3;
|
2012-06-17 03:18:26 +00:00
|
|
|
P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CPosRefire)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// keep firing unless target got out of sight
|
|
|
|
A_FaceTarget (self);
|
|
|
|
|
|
|
|
if (pr_cposrefire() < 40)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!self->target
|
|
|
|
|| P_HitFriend (self)
|
|
|
|
|| self->target->health <= 0
|
2010-04-03 07:10:52 +00:00
|
|
|
|| !P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
self->SetState (self->SeeState);
|
|
|
|
}
|
|
|
|
}
|