gzdoom-gles/src/g_doom/a_painelemental.cpp

174 lines
4.4 KiB
C++
Raw Normal View History

#include "actor.h"
#include "info.h"
#include "p_enemy.h"
#include "p_local.h"
#include "a_doomglobal.h"
#include "a_action.h"
#include "templates.h"
#include "m_bbox.h"
#include "thingdef/thingdef.h"
void A_PainAttack (AActor *);
void A_PainDie (AActor *);
void A_SkullAttack (AActor *self);
static const PClass *GetSpawnType()
{
const PClass *spawntype = NULL;
int index=CheckIndex(1, NULL);
if (index>=0)
{
spawntype = PClass::FindClass((ENamedName)StateParameters[index]);
}
if (spawntype == NULL) spawntype = PClass::FindClass("LostSoul");
return spawntype;
}
//
// A_PainShootSkull
// Spawn a lost soul and launch it at the target
//
void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype)
{
fixed_t x, y, z;
AActor *other;
angle_t an;
int prestep;
if (spawntype == NULL) return;
if (self->DamageType==NAME_Massacre) return;
// [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)
{
self->momz -= 2*FRACUNIT;
self->flags |= MF_INFLOAT;
self->flags4 |= MF4_VFRICTION;
}
return;
}
// [RH] make this optional
if (i_compatflags & COMPATF_LIMITPAIN)
{
// count total number of skulls currently on the level
// if there are already 20 skulls on the level, don't spit another one
int count = 20;
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
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()))
{
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-07-16 09:10:45 +00:00
other = Spawn (spawntype, x, y, z, ALLOW_REPLACE);
// 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
P_DamageMobj (other, self, self, 1000000, NAME_None); // ^
return; // |
} // phares
// Check for movements.
if (!P_CheckPosition (other, other->x, other->y))
{
// kill it immediately
P_DamageMobj (other, self, self, 1000000, NAME_None);
return;
}
// [RH] Lost souls hate the same things as their pain elementals
other->CopyFriendliness (self, true);
A_SkullAttack (other);
}
//
// A_PainAttack
// Spawn a lost soul and launch it at the target
//
void A_PainAttack (AActor *self)
{
if (!self->target)
return;
const PClass *spawntype = GetSpawnType();
A_FaceTarget (self);
A_PainShootSkull (self, self->angle, spawntype);
}
2006-04-11 08:36:23 +00:00
void A_DualPainAttack (AActor *self)
{
if (!self->target)
return;
const PClass *spawntype = GetSpawnType();
2006-04-11 08:36:23 +00:00
A_FaceTarget (self);
A_PainShootSkull (self, self->angle + ANG45, spawntype);
A_PainShootSkull (self, self->angle - ANG45, spawntype);
2006-04-11 08:36:23 +00:00
}
void A_PainDie (AActor *self)
{
May 3, 2006 (Changes by Graf Zahl) - Removed doom.x, heretic.x and strife.x from the SVN repository. These are generated files. - Fixed: A_PainDie has to check whether a valid target exists before calling IsFriend. - Fixed: FDecalLib::FindAnimator needs a signed counter to work properly. May 1, 2006 (Changes by Graf Zahl) - Added support for game specific pickup messages, if only to be able to define Raven's invulnerability item in DECORATE. - Removed A_TreeDeath because it is no longer used. - Fixed: When picking up a PowerupGiver for an active powerup the blend color and the duration were transferred to a temorary item and never took effect. They have to be trnasferred to the newly created powerup item before trying to give it to the player, not afterward. - Made the colormap of the InvulnerabilitySphere item specific. The base power class still needs to have its color adjusted per game though and since Raven's invulnerability item is used in both Hexen and Heretic it can't define its own colormap/blend. - Separated the invulnerability colormaps from the game being played and made them item specific. They can also be specified as regular blend colors in DECORATE now. - Converted a_hereticarmor.cpp and most of a_doomartifacts.cpp, a_hereticartifacts.cpp and a_heretickeys.cpp to DECORATE. - Changed the Soulsphere to be a real health item with the Dehacked modifications made in d_dehacked.cpp as for most other items which need to be adjusted. - Added IF_BIGPOWERUP flag to AInventory to expose the RESPAWN_SUPER dmflag to DECORATE. Also removed the now obsolete ShouldRespawn methods from AInvulnerabilitySphere and ABlurSphere. - Converted a_splashes.cpp to DECORATE. - Converted most of a_debris.cpp to DECORATE. SVN r73 (trunk)
2006-05-03 14:54:48 +00:00
if (self->target != NULL && self->IsFriend (self->target))
{ // And I thought you were my friend!
self->flags &= ~MF_FRIENDLY;
}
const PClass *spawntype = GetSpawnType();
A_NoBlocking (self);
A_PainShootSkull (self, self->angle + ANG90, spawntype);
A_PainShootSkull (self, self->angle + ANG180, spawntype);
A_PainShootSkull (self, self->angle + ANG270, spawntype);
}