2008-11-15 09:57:18 +00:00
|
|
|
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
// [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-01-25 21:59:38 +00:00
|
|
|
while ( ((abs(momx) >> shift) > radius) || ((abs(momy) >> 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
|
|
|
|
if (momx || momy || (z != floorz) || momz)
|
|
|
|
{
|
2009-01-01 15:09:49 +00:00
|
|
|
xfrac = momx>>shift;
|
|
|
|
yfrac = momy>>shift;
|
|
|
|
zfrac = momz>>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
|
|
|
|
P_ExplodeMissile (this, BlockingLine, BlockingMobj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z += zfrac;
|
|
|
|
if (z <= floorz)
|
|
|
|
{ // Hit the floor
|
|
|
|
z = floorz;
|
|
|
|
P_HitFloor (this);
|
|
|
|
P_ExplodeMissile (this, NULL, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (z + height > ceilingz)
|
|
|
|
{ // Hit the ceiling
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
tics--;
|
|
|
|
while (!tics)
|
|
|
|
{
|
|
|
|
if (!SetState (state->GetNextState ()))
|
|
|
|
{ // mobj was removed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AFastProjectile::Effect()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|