gzdoom/src/g_strife/a_spectral.cpp

143 lines
3.2 KiB
C++
Raw Normal View History

#include "actor.h"
#include "m_random.h"
#include "a_action.h"
#include "p_local.h"
#include "p_enemy.h"
#include "s_sound.h"
#include "m_random.h"
#include "a_strifeglobal.h"
AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target);
class ASpectralMonster : public AActor
{
DECLARE_CLASS (ASpectralMonster, AActor)
public:
void Touch (AActor *toucher);
};
IMPLEMENT_CLASS (ASpectralMonster)
void ASpectralMonster::Touch (AActor *toucher)
{
P_DamageMobj (toucher, this, this, 5, NAME_Melee);
}
void A_SpectralLightningTail (AActor *self)
{
AActor *foo = Spawn("SpectralLightningHTail", self->x - self->momx, self->y - self->momy, self->z, ALLOW_REPLACE);
foo->angle = self->angle;
foo->health = self->health;
}
void A_SpectralBigBallLightning (AActor *self)
{
const PClass *cls = PClass::FindClass("SpectralLightningH3");
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);
}
}
static FRandom pr_zap5 ("Zap5");
void A_SpectralLightning (AActor *self)
{
AActor *flash;
fixed_t x, y;
if (self->threshold != 0)
--self->threshold;
self->momx += pr_zap5.Random2(3) << FRACBITS;
self->momy += pr_zap5.Random2(3) << FRACBITS;
x = self->x + pr_zap5.Random2(3) * FRACUNIT * 50;
y = self->y + pr_zap5.Random2(3) * FRACUNIT * 50;
flash = Spawn (self->threshold > 25 ? PClass::FindClass("SpectralLightningV2") :
PClass::FindClass("SpectralLightningV1"), x, y, ONCEILINGZ, ALLOW_REPLACE);
flash->target = self->target;
flash->momz = -18*FRACUNIT;
flash->health = self->health;
flash = Spawn("SpectralLightningV2", self->x, self->y, ONCEILINGZ, ALLOW_REPLACE);
flash->target = self->target;
flash->momz = -18*FRACUNIT;
flash->health = self->health;
}
// In Strife, this number is stored in the data segment, but it doesn't seem to be
// altered anywhere.
#define TRACEANGLE (0xe000000)
void A_Tracer2 (AActor *self)
{
AActor *dest;
angle_t exact;
fixed_t dist;
fixed_t slope;
dest = self->tracer;
- Converted the StrifePlayer to DECORATE. Even though it requires exporting 3 new code pointers without general use it was necessary to handle GiveDefaultInventory consistently for all players without the need to subclass this function. - Added a Player.RunHealth property to expose the StrifePlayer's behavior of not being able to run when its health is below 10. - Changed APlayerPawn::GiveDefaultInventory so that it always adds a HexenArmor and a BasicArmor item to the inventory. If these items are not the first ones added to the inventory anything else that might absorb damage is not guaranteed to work consistently because their function depends on the order in the inventory. - Changed handling of APowerup's DoEffect so that it is called from the owner's Tick function, not the item's. This is so that the order of execution is determined by the order in the inventory. When done in the item's Tick function order depends on the global thinker table which can cause problems with the order in which conflicting powerups apply their effect. Now it is guaranteed that the item that was added to the inventory first applies its effect last. - Fixed: Added checks for Speed==0 to A_Tracer and A_Tracer2 because this could cause a divide by zero. - Fixed: P_MoveThing must also set the moved actor's previous position to prevent interpolation of the move. - Fixed: APowerInvisibility and its subclasses need to constantly update the owner's translucency information in case of interference between different subclasses. Also changed Hexen's Cleric's invulnerability mode to disable the translucency effect if an invisibility powerup is active. SVN r448 (trunk)
2007-01-12 15:24:10 +00:00
if (dest == NULL || dest->health <= 0 || self->Speed == 0)
return;
// change angle
exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y);
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;
self->momx = FixedMul (self->Speed, finecosine[exact]);
self->momy = FixedMul (self->Speed, finesine[exact]);
// change slope
dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
dist /= self->Speed;
if (dist < 1)
{
dist = 1;
}
if (dest->height >= 56*FRACUNIT)
{
slope = (dest->z+40*FRACUNIT - self->z) / dist;
}
else
{
slope = (dest->z + self->height*2/3 - self->z) / dist;
}
if (slope < self->momz)
{
self->momz -= FRACUNIT/8;
}
else
{
self->momz += FRACUNIT/8;
}
}