2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "a_action.h"
|
2008-04-06 17:33:43 +00:00
|
|
|
#include "templates.h"
|
|
|
|
#include "m_bbox.h"
|
2007-05-28 14:46:49 +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
|
|
|
|
2008-08-10 22:48:37 +00:00
|
|
|
DECLARE_ACTION(A_SkullAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
static const PClass *GetSpawnType(DECLARE_PARAMINFO)
|
2007-12-06 08:55:17 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_CLASS(spawntype, 0);
|
|
|
|
|
2007-12-06 08:55:17 +00:00
|
|
|
if (spawntype == NULL) spawntype = PClass::FindClass("LostSoul");
|
|
|
|
return spawntype;
|
|
|
|
}
|
|
|
|
|
2008-04-06 17:33:43 +00:00
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
#define SKULLSPEED (20*FRACUNIT)
|
|
|
|
void A_SkullAttack(AActor *self, fixed_t speed);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// A_PainShootSkull
|
|
|
|
// Spawn a lost soul and launch it at the target
|
|
|
|
//
|
2007-12-06 08:55:17 +00:00
|
|
|
void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t x, y, z;
|
|
|
|
|
|
|
|
AActor *other;
|
|
|
|
angle_t an;
|
|
|
|
int prestep;
|
|
|
|
|
2008-03-14 09:27:02 +00:00
|
|
|
if (spawntype == NULL) return;
|
2006-10-31 14:53:21 +00:00
|
|
|
if (self->DamageType==NAME_Massacre) return;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] check to make sure it's not too close to the ceiling
|
|
|
|
if (self->z + self->height + 8*FRACUNIT > self->ceilingz)
|
|
|
|
{
|
|
|
|
if (self->flags & MF_FLOAT)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velz -= 2*FRACUNIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
self->flags |= MF_INFLOAT;
|
|
|
|
self->flags4 |= MF4_VFRICTION;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] make this optional
|
2006-06-03 12:30:11 +00:00
|
|
|
if (i_compatflags & COMPATF_LIMITPAIN)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// count total number of skulls currently on the level
|
2008-11-29 16:37:54 +00:00
|
|
|
// if there are already 21 skulls on the level, don't spit another one
|
|
|
|
int count = 21;
|
2006-02-24 04:48:15 +00:00
|
|
|
FThinkerIterator iterator (spawntype);
|
|
|
|
DThinker *othink;
|
|
|
|
|
|
|
|
while ( (othink = iterator.Next ()) )
|
|
|
|
{
|
|
|
|
if (--count == 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// okay, there's room for another one
|
|
|
|
an = angle >> ANGLETOFINESHIFT;
|
|
|
|
|
|
|
|
prestep = 4*FRACUNIT +
|
|
|
|
3*(self->radius + GetDefaultByType(spawntype)->radius)/2;
|
|
|
|
|
|
|
|
x = self->x + FixedMul (prestep, finecosine[an]);
|
|
|
|
y = self->y + FixedMul (prestep, finesine[an]);
|
|
|
|
z = self->z + 8*FRACUNIT;
|
|
|
|
|
|
|
|
// Check whether the Lost Soul is being fired through a 1-sided // phares
|
|
|
|
// wall or an impassible line, or a "monsters can't cross" line.// |
|
|
|
|
// If it is, then we don't allow the spawn. // V
|
|
|
|
|
2008-04-06 17:33:43 +00:00
|
|
|
FBoundingBox box(MIN(self->x, x), MIN(self->y, y), MAX(self->x, x), MAX(self->y, y));
|
|
|
|
FBlockLinesIterator it(box);
|
|
|
|
line_t *ld;
|
|
|
|
|
|
|
|
while ((ld = it.Next()))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-04-06 17:33:43 +00:00
|
|
|
if (!(ld->flags & ML_TWOSIDED) ||
|
|
|
|
(ld->flags & (ML_BLOCKING|ML_BLOCKMONSTERS|ML_BLOCKEVERYTHING)))
|
|
|
|
{
|
|
|
|
if (!(box.Left() > ld->bbox[BOXRIGHT] ||
|
|
|
|
box.Right() < ld->bbox[BOXLEFT] ||
|
|
|
|
box.Top() < ld->bbox[BOXBOTTOM] ||
|
|
|
|
box.Bottom() > ld->bbox[BOXTOP]))
|
|
|
|
{
|
|
|
|
if (P_PointOnLineSide(self->x,self->y,ld) != P_PointOnLineSide(x,y,ld))
|
|
|
|
return; // line blocks trajectory // ^
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-07-16 09:10:45 +00:00
|
|
|
other = Spawn (spawntype, x, y, z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Check to see if the new Lost Soul's z value is above the
|
|
|
|
// ceiling of its new sector, or below the floor. If so, kill it.
|
|
|
|
|
|
|
|
if ((other->z >
|
|
|
|
(other->Sector->ceilingplane.ZatPoint (other->x, other->y) - other->height)) ||
|
|
|
|
(other->z < other->Sector->floorplane.ZatPoint (other->x, other->y)))
|
|
|
|
{
|
|
|
|
// kill it immediately
|
2009-08-07 03:57:03 +00:00
|
|
|
P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None);// ^
|
2006-02-24 04:48:15 +00:00
|
|
|
return; // |
|
|
|
|
} // phares
|
|
|
|
|
|
|
|
// Check for movements.
|
|
|
|
|
|
|
|
if (!P_CheckPosition (other, other->x, other->y))
|
|
|
|
{
|
|
|
|
// kill it immediately
|
2009-08-07 03:57:03 +00:00
|
|
|
P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Lost souls hate the same things as their pain elementals
|
|
|
|
other->CopyFriendliness (self, true);
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
A_SkullAttack(other, SKULLSPEED);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// A_PainAttack
|
|
|
|
// Spawn a lost soul and launch it at the target
|
|
|
|
//
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PainAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
const PClass *spawntype = GetSpawnType(PUSH_PARAMINFO);
|
2006-02-24 04:48:15 +00:00
|
|
|
A_FaceTarget (self);
|
2007-12-06 08:55:17 +00:00
|
|
|
A_PainShootSkull (self, self->angle, spawntype);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DualPainAttack)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
const PClass *spawntype = GetSpawnType(PUSH_PARAMINFO);
|
2006-04-11 08:36:23 +00:00
|
|
|
A_FaceTarget (self);
|
2007-12-06 08:55:17 +00:00
|
|
|
A_PainShootSkull (self, self->angle + ANG45, spawntype);
|
|
|
|
A_PainShootSkull (self, self->angle - ANG45, spawntype);
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PainDie)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-05-03 14:54:48 +00:00
|
|
|
if (self->target != NULL && self->IsFriend (self->target))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // And I thought you were my friend!
|
|
|
|
self->flags &= ~MF_FRIENDLY;
|
|
|
|
}
|
2008-08-12 14:30:07 +00:00
|
|
|
const PClass *spawntype = GetSpawnType(PUSH_PARAMINFO);
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_NoBlocking, self);
|
2007-12-06 08:55:17 +00:00
|
|
|
A_PainShootSkull (self, self->angle + ANG90, spawntype);
|
|
|
|
A_PainShootSkull (self, self->angle + ANG180, spawntype);
|
|
|
|
A_PainShootSkull (self, self->angle + ANG270, spawntype);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|