2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "a_strifeglobal.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "doomstat.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_shootgun ("ShootGun");
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_ShootGun
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ShootGun)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
int pitch;
|
|
|
|
|
|
|
|
if (self->target == NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
S_Sound (self, CHAN_WEAPON, "monsters/rifle", 1, ATTN_NORM);
|
|
|
|
A_FaceTarget (self);
|
|
|
|
pitch = P_AimLineAttack (self, self->angle, MISSILERANGE);
|
|
|
|
P_LineAttack (self, self->angle + (pr_shootgun.Random2() << 19),
|
|
|
|
MISSILERANGE, pitch,
|
2012-06-17 03:18:26 +00:00
|
|
|
3*(pr_shootgun() % 5 + 1), NAME_Hitscan, NAME_StrifePuff);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Teleporter Beacon --------------------------------------------------------
|
|
|
|
|
|
|
|
class ATeleporterBeacon : public AInventory
|
|
|
|
{
|
2008-08-05 17:58:38 +00:00
|
|
|
DECLARE_CLASS (ATeleporterBeacon, AInventory)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
bool Use (bool pickup);
|
|
|
|
};
|
|
|
|
|
2008-08-05 17:58:38 +00:00
|
|
|
IMPLEMENT_CLASS (ATeleporterBeacon)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
bool ATeleporterBeacon::Use (bool pickup)
|
|
|
|
{
|
|
|
|
AInventory *drop;
|
|
|
|
|
|
|
|
// Increase the amount by one so that when DropInventory decrements it,
|
|
|
|
// the actor will have the same number of beacons that he started with.
|
|
|
|
// When we return to UseInventory, it will take care of decrementing
|
|
|
|
// Amount again and disposing of this item if there are no more.
|
|
|
|
Amount++;
|
|
|
|
drop = Owner->DropInventory (this);
|
|
|
|
if (drop == NULL)
|
|
|
|
{
|
|
|
|
Amount--;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-01 02:19:46 +00:00
|
|
|
drop->SetState(drop->FindState(NAME_Drop));
|
2006-02-24 04:48:15 +00:00
|
|
|
drop->target = Owner;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Beacon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
AActor *owner = self->target;
|
2008-08-05 17:58:38 +00:00
|
|
|
AActor *rebel;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle_t an;
|
|
|
|
|
2016-01-19 10:50:07 +00:00
|
|
|
rebel = Spawn("Rebel1", self->X(), self->Y(), self->floorz, ALLOW_REPLACE);
|
|
|
|
if (!P_TryMove (rebel, rebel->X(), rebel->Y(), true))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
rebel->Destroy ();
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
// Once the rebels start teleporting in, you can't pick up the beacon anymore.
|
|
|
|
self->flags &= ~MF_SPECIAL;
|
|
|
|
static_cast<AInventory *>(self)->DropTime = 0;
|
|
|
|
// Set up the new rebel.
|
2015-10-14 12:36:30 +00:00
|
|
|
rebel->threshold = rebel->DefThreshold;
|
2006-02-24 04:48:15 +00:00
|
|
|
rebel->target = NULL;
|
|
|
|
rebel->flags4 |= MF4_INCOMBAT;
|
|
|
|
rebel->LastHeard = owner; // Make sure the rebels look for targets
|
|
|
|
if (deathmatch)
|
|
|
|
{
|
|
|
|
rebel->health *= 2;
|
|
|
|
}
|
|
|
|
if (owner != NULL)
|
|
|
|
{
|
2010-01-08 02:17:49 +00:00
|
|
|
// Rebels are the same color as their owner (but only in multiplayer)
|
2010-01-08 02:15:42 +00:00
|
|
|
if (multiplayer)
|
|
|
|
{
|
|
|
|
rebel->Translation = owner->Translation;
|
|
|
|
}
|
2012-06-09 04:15:56 +00:00
|
|
|
rebel->SetFriendPlayer(owner->player);
|
2006-02-24 04:48:15 +00:00
|
|
|
// Set the rebel's target to whatever last hurt the player, so long as it's not
|
|
|
|
// one of the player's other rebels.
|
2006-07-03 09:07:56 +00:00
|
|
|
if (owner->target != NULL && !rebel->IsFriend (owner->target))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
rebel->target = owner->target;
|
|
|
|
}
|
|
|
|
}
|
2006-07-03 09:07:56 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
rebel->SetState (rebel->SeeState);
|
|
|
|
rebel->angle = self->angle;
|
|
|
|
an = self->angle >> ANGLETOFINESHIFT;
|
2016-01-19 10:50:07 +00:00
|
|
|
Spawn<ATeleportFog> (rebel->Vec3Offset(20*finecosine[an], 20*finesine[an], TELEFOGHEIGHT), ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (--self->health < 0)
|
|
|
|
{
|
2009-03-01 02:19:46 +00:00
|
|
|
self->SetState(self->FindState(NAME_Death));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|