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 "s_sound.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_strifeglobal.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
|
|
|
|
2008-08-05 22:51:51 +00:00
|
|
|
class ASpectralMonster : public AActor
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-05 22:51:51 +00:00
|
|
|
DECLARE_CLASS (ASpectralMonster, AActor)
|
|
|
|
public:
|
|
|
|
void Touch (AActor *toucher);
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-08-05 22:51:51 +00:00
|
|
|
IMPLEMENT_CLASS (ASpectralMonster)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-05 22:51:51 +00:00
|
|
|
void ASpectralMonster::Touch (AActor *toucher)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-05 22:51:51 +00:00
|
|
|
P_DamageMobj (toucher, this, this, 5, NAME_Melee);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2016-01-19 10:50:07 +00:00
|
|
|
AActor *foo = Spawn("SpectralLightningHTail", self->Vec3Offset(-self->velx, -self->vely, 0), ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
foo->angle = self->angle;
|
2012-05-13 11:17:27 +00:00
|
|
|
foo->FriendPlayer = self->FriendPlayer;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SpectralBigBallLightning)
|
2008-07-12 10:59:36 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2010-04-03 04:07:17 +00:00
|
|
|
PClassActor *cls = PClass::FindActor("SpectralLightningH3");
|
2008-08-05 22:51:51 +00:00
|
|
|
if (cls)
|
|
|
|
{
|
|
|
|
self->angle += ANGLE_90;
|
|
|
|
P_SpawnSubMissile (self, cls, self->target);
|
|
|
|
self->angle += ANGLE_180;
|
|
|
|
P_SpawnSubMissile (self, cls, self->target);
|
|
|
|
self->angle += ANGLE_90;
|
|
|
|
P_SpawnSubMissile (self, cls, self->target);
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-07-12 10:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
static FRandom pr_zap5 ("Zap5");
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning)
|
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 *flash;
|
|
|
|
|
|
|
|
if (self->threshold != 0)
|
|
|
|
--self->threshold;
|
|
|
|
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velx += pr_zap5.Random2(3) << FRACBITS;
|
|
|
|
self->vely += pr_zap5.Random2(3) << FRACBITS;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2016-01-19 10:50:07 +00:00
|
|
|
fixedvec2 pos = self->Vec2Offset(
|
|
|
|
pr_zap5.Random2(3) * FRACUNIT * 50,
|
|
|
|
pr_zap5.Random2(3) * FRACUNIT * 50);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-04-03 04:07:17 +00:00
|
|
|
flash = Spawn (self->threshold > 25 ? PClass::FindActor(NAME_SpectralLightningV2) :
|
2016-01-19 12:43:11 +00:00
|
|
|
PClass::FindActor(NAME_SpectralLightningV1), pos.x, pos.y, ONCEILINGZ, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
flash->target = self->target;
|
2009-06-30 20:57:51 +00:00
|
|
|
flash->velz = -18*FRACUNIT;
|
2012-05-13 11:17:27 +00:00
|
|
|
flash->FriendPlayer = self->FriendPlayer;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2016-01-19 10:50:07 +00:00
|
|
|
flash = Spawn(NAME_SpectralLightningV2, self->X(), self->Y(), ONCEILINGZ, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
flash->target = self->target;
|
2009-06-30 20:57:51 +00:00
|
|
|
flash->velz = -18*FRACUNIT;
|
2012-05-13 11:17:27 +00:00
|
|
|
flash->FriendPlayer = self->FriendPlayer;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-12-06 10:38:47 +00:00
|
|
|
|
|
|
|
// In Strife, this number is stored in the data segment, but it doesn't seem to be
|
|
|
|
// altered anywhere.
|
|
|
|
#define TRACEANGLE (0xe000000)
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Tracer2)
|
2006-12-06 10:38:47 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-12-06 10:38:47 +00:00
|
|
|
AActor *dest;
|
|
|
|
angle_t exact;
|
|
|
|
fixed_t dist;
|
|
|
|
fixed_t slope;
|
|
|
|
|
|
|
|
dest = self->tracer;
|
|
|
|
|
2009-05-30 08:56:40 +00:00
|
|
|
if (!dest || dest->health <= 0 || self->Speed == 0 || !self->CanSeek(dest))
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-12-06 10:38:47 +00:00
|
|
|
|
|
|
|
// change angle
|
2016-01-15 14:36:21 +00:00
|
|
|
exact = self->AngleTo(dest);
|
2006-12-06 10:38:47 +00:00
|
|
|
|
|
|
|
if (exact != self->angle)
|
|
|
|
{
|
|
|
|
if (exact - self->angle > 0x80000000)
|
|
|
|
{
|
|
|
|
self->angle -= TRACEANGLE;
|
|
|
|
if (exact - self->angle < 0x80000000)
|
|
|
|
self->angle = exact;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->angle += TRACEANGLE;
|
|
|
|
if (exact - self->angle > 0x80000000)
|
|
|
|
self->angle = exact;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exact = self->angle >> ANGLETOFINESHIFT;
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velx = FixedMul (self->Speed, finecosine[exact]);
|
|
|
|
self->vely = FixedMul (self->Speed, finesine[exact]);
|
2006-12-06 10:38:47 +00:00
|
|
|
|
2009-08-30 10:43:51 +00:00
|
|
|
if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
|
2007-10-19 08:49:02 +00:00
|
|
|
{
|
2009-08-30 10:43:51 +00:00
|
|
|
// change slope
|
2016-01-15 14:36:21 +00:00
|
|
|
dist = self->AproxDistance (dest) / self->Speed;
|
2009-08-30 10:43:51 +00:00
|
|
|
|
|
|
|
if (dist < 1)
|
|
|
|
{
|
|
|
|
dist = 1;
|
|
|
|
}
|
|
|
|
if (dest->height >= 56*FRACUNIT)
|
|
|
|
{
|
2016-01-19 10:50:07 +00:00
|
|
|
slope = (dest->Z()+40*FRACUNIT - self->Z()) / dist;
|
2009-08-30 10:43:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-19 10:50:07 +00:00
|
|
|
slope = (dest->Z() + self->height*2/3 - self->Z()) / dist;
|
2009-08-30 10:43:51 +00:00
|
|
|
}
|
|
|
|
if (slope < self->velz)
|
|
|
|
{
|
|
|
|
self->velz -= FRACUNIT/8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->velz += FRACUNIT/8;
|
|
|
|
}
|
2006-12-06 10:38:47 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-12-06 10:38:47 +00:00
|
|
|
}
|