2008-11-15 09:57:18 +00:00
|
|
|
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "p_local.h"
|
2009-05-11 22:16:41 +00:00
|
|
|
#include "g_level.h"
|
2009-12-31 09:02:38 +00:00
|
|
|
#include "r_sky.h"
|
|
|
|
#include "p_lnspec.h"
|
2008-11-15 09:57:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS(AFastProjectile)
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// AFastProjectile :: Tick
|
|
|
|
//
|
|
|
|
// Thinker for the ultra-fast projectiles used by Heretic and Hexen
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void AFastProjectile::Tick ()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
fixed_t xfrac;
|
|
|
|
fixed_t yfrac;
|
|
|
|
fixed_t zfrac;
|
|
|
|
int changexy;
|
|
|
|
|
|
|
|
PrevX = x;
|
|
|
|
PrevY = y;
|
|
|
|
PrevZ = z;
|
2009-12-30 12:20:47 +00:00
|
|
|
PrevAngle = angle;
|
2008-11-15 09:57:18 +00:00
|
|
|
|
2009-05-11 22:16:41 +00:00
|
|
|
if (!(flags5 & MF5_NOTIMEFREEZE))
|
|
|
|
{
|
|
|
|
//Added by MC: Freeze mode.
|
|
|
|
if (bglobal.freeze || level.flags2 & LEVEL2_FROZEN)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-15 09:57:18 +00:00
|
|
|
// [RH] Ripping is a little different than it was in Hexen
|
|
|
|
FCheckPosition tm(!!(flags2 & MF2_RIP));
|
|
|
|
|
2009-01-01 15:09:49 +00:00
|
|
|
int shift = 3;
|
|
|
|
int count = 8;
|
|
|
|
if (radius > 0)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
while ( ((abs(velx) >> shift) > radius) || ((abs(vely) >> shift) > radius))
|
2009-01-01 15:09:49 +00:00
|
|
|
{
|
|
|
|
// we need to take smaller steps.
|
|
|
|
shift++;
|
|
|
|
count<<=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-15 09:57:18 +00:00
|
|
|
// Handle movement
|
2009-06-30 20:57:51 +00:00
|
|
|
if (velx || vely || (z != floorz) || velz)
|
2008-11-15 09:57:18 +00:00
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
xfrac = velx >> shift;
|
|
|
|
yfrac = vely >> shift;
|
|
|
|
zfrac = velz >> shift;
|
2008-11-15 09:57:18 +00:00
|
|
|
changexy = xfrac || yfrac;
|
2009-01-01 15:09:49 +00:00
|
|
|
int ripcount = count >> 3;
|
|
|
|
for (i = 0; i < count; i++)
|
2008-11-15 09:57:18 +00:00
|
|
|
{
|
|
|
|
if (changexy)
|
|
|
|
{
|
2009-01-01 15:09:49 +00:00
|
|
|
if (--ripcount <= 0)
|
|
|
|
{
|
|
|
|
tm.LastRipped = NULL; // [RH] Do rip damage each step, like Hexen
|
|
|
|
}
|
2009-01-25 21:59:38 +00:00
|
|
|
|
2008-11-15 09:57:18 +00:00
|
|
|
if (!P_TryMove (this, x + xfrac,y + yfrac, true, false, tm))
|
|
|
|
{ // Blocked move
|
2009-12-31 09:02:38 +00:00
|
|
|
if (!(flags3 & MF3_SKYEXPLODE))
|
|
|
|
{
|
|
|
|
if (tm.ceilingline &&
|
|
|
|
tm.ceilingline->backsector &&
|
|
|
|
tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
|
|
|
z >= tm.ceilingline->backsector->ceilingplane.ZatPoint (x, y))
|
|
|
|
{
|
|
|
|
// Hack to prevent missiles exploding against the sky.
|
|
|
|
// Does not handle sky floors.
|
|
|
|
Destroy ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// [RH] Don't explode on horizon lines.
|
|
|
|
if (BlockingLine != NULL && BlockingLine->special == Line_Horizon)
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-15 09:57:18 +00:00
|
|
|
P_ExplodeMissile (this, BlockingLine, BlockingMobj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z += zfrac;
|
|
|
|
if (z <= floorz)
|
|
|
|
{ // Hit the floor
|
2009-12-31 09:02:38 +00:00
|
|
|
|
|
|
|
if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE))
|
|
|
|
{
|
|
|
|
// [RH] Just remove the missile without exploding it
|
|
|
|
// if this is a sky floor.
|
|
|
|
Destroy ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-15 09:57:18 +00:00
|
|
|
z = floorz;
|
|
|
|
P_HitFloor (this);
|
|
|
|
P_ExplodeMissile (this, NULL, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (z + height > ceilingz)
|
|
|
|
{ // Hit the ceiling
|
2009-12-31 09:02:38 +00:00
|
|
|
|
|
|
|
if (ceilingpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE))
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-15 09:57:18 +00:00
|
|
|
z = ceilingz - height;
|
|
|
|
P_ExplodeMissile (this, NULL, NULL);
|
|
|
|
return;
|
|
|
|
}
|
2009-01-25 21:59:38 +00:00
|
|
|
if (changexy && ripcount <= 0)
|
|
|
|
{
|
|
|
|
ripcount = count >> 3;
|
|
|
|
Effect();
|
|
|
|
}
|
2008-11-15 09:57:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Advance the state
|
|
|
|
if (tics != -1)
|
|
|
|
{
|
2009-10-19 17:17:06 +00:00
|
|
|
if (tics > 0) tics--;
|
2008-11-15 09:57:18 +00:00
|
|
|
while (!tics)
|
|
|
|
{
|
|
|
|
if (!SetState (state->GetNextState ()))
|
|
|
|
{ // mobj was removed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AFastProjectile::Effect()
|
|
|
|
{
|
2009-10-03 17:07:11 +00:00
|
|
|
//if (pr_smoke() < 128) // [RH] I think it looks better if it's consistent
|
|
|
|
{
|
2010-03-25 20:38:00 +00:00
|
|
|
FName name = GetClass()->MissileName;
|
2009-10-03 17:07:11 +00:00
|
|
|
if (name != NAME_None)
|
|
|
|
{
|
|
|
|
fixed_t hitz = z-8*FRACUNIT;
|
|
|
|
if (hitz < floorz)
|
|
|
|
{
|
|
|
|
hitz = floorz;
|
|
|
|
}
|
|
|
|
|
|
|
|
const PClass *trail = PClass::FindClass(name);
|
2009-12-25 00:24:54 +00:00
|
|
|
if (trail != NULL)
|
|
|
|
{
|
|
|
|
AActor *act = Spawn (trail, x, y, hitz, ALLOW_REPLACE);
|
|
|
|
if (act != NULL)
|
|
|
|
{
|
|
|
|
act->angle = this->angle;
|
|
|
|
}
|
|
|
|
}
|
2009-10-03 17:07:11 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-15 09:57:18 +00:00
|
|
|
}
|
|
|
|
|