qzdoom-gpl/src/g_strife/a_spectral.cpp

160 lines
3.5 KiB
C++
Raw Normal View History

/*
#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"
#include "thingdef/thingdef.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);
}
DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail)
{
PARAM_ACTION_PROLOGUE;
AActor *foo = Spawn("SpectralLightningHTail", self->x - self->velx, self->y - self->vely, self->z, ALLOW_REPLACE);
foo->angle = self->angle;
foo->health = self->health;
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_SpectralBigBallLightning)
{
PARAM_ACTION_PROLOGUE;
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);
}
return 0;
}
static FRandom pr_zap5 ("Zap5");
DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning)
{
PARAM_ACTION_PROLOGUE;
AActor *flash;
fixed_t x, y;
if (self->threshold != 0)
--self->threshold;
self->velx += pr_zap5.Random2(3) << FRACBITS;
self->vely += 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(NAME_SpectralLightningV2) :
PClass::FindClass(NAME_SpectralLightningV1), x, y, ONCEILINGZ, ALLOW_REPLACE);
flash->target = self->target;
flash->velz = -18*FRACUNIT;
flash->health = self->health;
flash = Spawn(NAME_SpectralLightningV2, self->x, self->y, ONCEILINGZ, ALLOW_REPLACE);
flash->target = self->target;
flash->velz = -18*FRACUNIT;
flash->health = self->health;
return 0;
}
// In Strife, this number is stored in the data segment, but it doesn't seem to be
// altered anywhere.
#define TRACEANGLE (0xe000000)
DEFINE_ACTION_FUNCTION(AActor, A_Tracer2)
{
PARAM_ACTION_PROLOGUE;
AActor *dest;
angle_t exact;
fixed_t dist;
fixed_t slope;
dest = self->tracer;
if (!dest || dest->health <= 0 || self->Speed == 0 || !self->CanSeek(dest))
return 0;
// 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->velx = FixedMul (self->Speed, finecosine[exact]);
self->vely = FixedMul (self->Speed, finesine[exact]);
- fixed: WIF_STAFF2_KICKBACK did not work anymore because it depended on conditions that were changed some time ago. - fixed: The damage inflictor for a rail attack was the shooter, not the puff. - Fixed: Floor and ceiling huggers may not change their z-velocity when seeking. - Fixed: UDMF set the secret sector flag before parsing the sector's properties, resulting in it always being false. - Renamed sector's oldspecial variable to secretsector to better reflect its only use. - Fixed: A_BrainSpit stored as the SpawnShot's target the intended BossTarget, not itself contrarily to other projectile spawning functions. A_SpawnFly then used the target for CopyFriendliness, thinking it'll be the BossEye when in fact it wasn't. - Added Gez's submission for a DEHACKED hack introduced by Boom. (using code pointers of the form 'Pointer 0 (x statenumber)'. - fixed: Attaching 3DMidtex lines by sector tag did not work because lines were marked by index in the sector's line list but needed to be marked by line index in the global array. - fixed: On Linux ZDoom was creating a directory called "~.zdoom" for save files because of a missing slash. - fixed: UDMF was unable to read floating point values in exponential format because the C Mode scanner was missing a definition for them. - fixed: The recent changes for removing pointer aliasing got the end sequence info from an incorrect variable. To make this more robust the sequence index is now stored as a hexadecimal string to avoid storing binary data in a string. Also moved end sequence lookup from f_finale.cpp to the calling code so that the proper end sequences can be retrieved for secret exits, too. SVN r1777 (trunk)
2009-08-30 10:43:51 +00:00
if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
{
- fixed: WIF_STAFF2_KICKBACK did not work anymore because it depended on conditions that were changed some time ago. - fixed: The damage inflictor for a rail attack was the shooter, not the puff. - Fixed: Floor and ceiling huggers may not change their z-velocity when seeking. - Fixed: UDMF set the secret sector flag before parsing the sector's properties, resulting in it always being false. - Renamed sector's oldspecial variable to secretsector to better reflect its only use. - Fixed: A_BrainSpit stored as the SpawnShot's target the intended BossTarget, not itself contrarily to other projectile spawning functions. A_SpawnFly then used the target for CopyFriendliness, thinking it'll be the BossEye when in fact it wasn't. - Added Gez's submission for a DEHACKED hack introduced by Boom. (using code pointers of the form 'Pointer 0 (x statenumber)'. - fixed: Attaching 3DMidtex lines by sector tag did not work because lines were marked by index in the sector's line list but needed to be marked by line index in the global array. - fixed: On Linux ZDoom was creating a directory called "~.zdoom" for save files because of a missing slash. - fixed: UDMF was unable to read floating point values in exponential format because the C Mode scanner was missing a definition for them. - fixed: The recent changes for removing pointer aliasing got the end sequence info from an incorrect variable. To make this more robust the sequence index is now stored as a hexadecimal string to avoid storing binary data in a string. Also moved end sequence lookup from f_finale.cpp to the calling code so that the proper end sequences can be retrieved for secret exits, too. SVN r1777 (trunk)
2009-08-30 10:43:51 +00:00
// 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->velz)
{
self->velz -= FRACUNIT/8;
}
else
{
self->velz += FRACUNIT/8;
}
}
return 0;
}