qzdoom-gpl/src/g_doom/a_revenant.cpp

153 lines
3.4 KiB
C++
Raw Normal View History

/*
#include "templates.h"
#include "actor.h"
#include "info.h"
#include "m_random.h"
#include "s_sound.h"
#include "p_local.h"
#include "p_enemy.h"
#include "gstrings.h"
#include "a_action.h"
#include "thingdef/thingdef.h"
#include "g_level.h"
*/
static FRandom pr_tracer ("Tracer");
static FRandom pr_skelfist ("SkelFist");
//
// A_SkelMissile
//
DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile)
{
AActor *missile;
if (!self->target)
return;
A_FaceTarget (self);
missile = P_SpawnMissileZ (self, self->z + 48*FRACUNIT,
self->target, PClass::FindClass("RevenantTracer"));
if (missile != NULL)
{
missile->x += missile->velx;
missile->y += missile->vely;
missile->tracer = self->target;
}
}
#define TRACEANGLE (0xc000000)
DEFINE_ACTION_FUNCTION(AActor, A_Tracer)
{
angle_t exact;
fixed_t dist;
fixed_t slope;
AActor *dest;
AActor *smoke;
// killough 1/18/98: this is why some missiles do not have smoke
// and some do. Also, internal demos start at random gametics, thus
// the bug in which revenants cause internal demos to go out of sync.
//
// killough 3/6/98: fix revenant internal demo bug by subtracting
// levelstarttic from gametic:
//
// [RH] level.time is always 0-based, so nothing special to do here.
if (level.time & 3)
return;
// spawn a puff of smoke behind the rocket
P_SpawnPuff (self, PClass::FindClass(NAME_BulletPuff), self->x, self->y, self->z, 0, 3);
smoke = Spawn ("RevenantTracerSmoke", self->x - self->velx,
self->y - self->vely, self->z, ALLOW_REPLACE);
smoke->velz = FRACUNIT;
smoke->tics -= pr_tracer()&3;
if (smoke->tics < 1)
smoke->tics = 1;
// adjust direction
dest = self->tracer;
if (!dest || dest->health <= 0 || self->Speed == 0 || !self->CanSeek(dest))
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->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 = dist / self->Speed;
if (dist < 1)
dist = 1;
- 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 (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;
}
}
DEFINE_ACTION_FUNCTION(AActor, A_SkelWhoosh)
{
if (!self->target)
return;
A_FaceTarget (self);
S_Sound (self, CHAN_WEAPON, "skeleton/swing", 1, ATTN_NORM);
}
DEFINE_ACTION_FUNCTION(AActor, A_SkelFist)
{
if (!self->target)
return;
A_FaceTarget (self);
if (self->CheckMeleeRange ())
{
int damage = ((pr_skelfist()%10)+1)*6;
S_Sound (self, CHAN_WEAPON, "skeleton/melee", 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self);
}
}