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"
|
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-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
|
|
|
|
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)
|
|
|
|
{
|
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
|
|
|
|
{
|
|
|
|
FName name = (ENamedName) this->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None);
|
|
|
|
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
|
|
|
}
|
|
|
|
|