case MT_ROBRA:
case MT_BLUEROBRA:
if (mobj->health)
{
boolean blue = (mobj->type == MT_BLUEROBRA);
if (blue)
{
if (mobj->spawnpoint)
mobj->extravalue2 = mobj->spawnpoint->angle;
else
mobj->extravalue2 = 128;
}
else
{
if (!mobj->extravalue2)
mobj->extravalue2 = P_RandomRange(64, 192);
}
if (mobj->reactiontime)
mobj->reactiontime--;
else
{
if (!mobj->extravalue1)
{
mobj_t *head = P_SpawnMobj(mobj->x, mobj->y, mobj->z, (blue ? MT_BLUEROBRA_HEAD : MT_ROBRA_HEAD));
P_SetTarget(&mobj->tracer, head);
mobj->destscale = mapobjectscale;
P_SetTarget(&mobj->tracer->target, mobj->target);
P_SetTarget(&mobj->tracer->tracer, mobj);
mobj->tracer->extravalue2 = mobj->extravalue2;
if (!blue)
mobj->tracer->angle = mobj->angle;
mobj->extravalue1 = 1;
}
}
if ((mobj->extravalue1) && !(mobj->tracer && !P_MobjWasRemoved(mobj->tracer)))
{
mobj->reactiontime = 20*mobj->info->reactiontime;
P_SetTarget(&mobj->target, NULL);
mobj->extravalue1 = 0;
}
if ((mobj->tracer && !P_MobjWasRemoved(mobj->tracer)) && !(leveltime % 10))
{
mobj_t *dust = P_SpawnMobj(mobj->x + (P_RandomRange(-4, 4)<<FRACBITS),
mobj->y + (P_RandomRange(-4, 4)<<FRACBITS),
mobj->z + (P_RandomRange(0, 2)<<FRACBITS), MT_BBZDUST);
P_SetScale(dust, mobj->scale/2);
P_InstaThrust(dust, FixedAngle(P_RandomRange(0,359)<<FRACBITS), abs(mobj->tracer->momz)/2);
if (abs(mobj->tracer->momz) >= 2<<FRACBITS)
S_StartSound(mobj, sfx_s3k7e);
}
}
break;
case MT_ROBRA_HEAD:
case MT_BLUEROBRA_HEAD:
if (mobj->health)
{
boolean blue = (mobj->type == MT_BLUEROBRA_HEAD);
UINT8 locnumsegs = abs(mobj->z - mobj->floorz) / (32 * mobj->scale);
UINT8 i;
mobj_t *cur = mobj->hnext, *prev = mobj;
if (blue)
mobj->angle = (angle_t)mobj->extravalue1;
mobj->extravalue1 += (FixedAngle(2*mobj->momz) * (blue ? -1 : 1));
for (i = 0; i < locnumsegs*2; i++) // *2 to check for any extra segs still present
{
fixed_t segz = mobj->z - ((i+1) * (32 * mobj->scale));
if (cur && !P_MobjWasRemoved(cur))
{
if (i >= locnumsegs) // Remove extras
{
mobj_t *next = cur->hnext;
P_RemoveMobj(cur);
cur = next;
continue;
}
else // Move into place
P_TeleportMove(cur, mobj->x, mobj->y, segz);
}
else
{
if (i >= locnumsegs) // We're done with this list
continue; //break;
else // Need another here!
cur = P_SpawnMobj(mobj->x, mobj->y, segz, (blue ? MT_BLUEROBRA_JOINT : MT_ROBRA_JOINT));
}
P_SetTarget(&cur->target, mobj);
P_SetScale(cur, (7*mobj->scale)/8);
cur->angle = mobj->extravalue1;
mobj->extravalue1 += (FixedAngle(2*mobj->momz) * (blue ? -1 : 1));
P_SetTarget(&prev->hnext, cur);
P_SetTarget(&cur->hprev, prev);
prev = cur;
cur = cur->hnext;
}
{
//fixed_t ceilingheight = mobj->ceilingz - (72<<FRACBITS);
fixed_t floorheight = mobj->floorz + (72<<FRACBITS);
fixed_t maxheight = mobj->floorz + (mobj->extravalue2<<FRACBITS);
fixed_t targetheight = maxheight;
if (mobj->z < targetheight)
{
mobj->momz += mobj->info->speed;
if ((mobj->z < floorheight) && (mobj->momz < 0))
mobj->momz /= 2;
}
else
{
mobj->momz -= mobj->info->speed;
if ((mobj->z > (targetheight + (64<<FRACBITS))) && (mobj->momz > 0))
mobj->momz /= 2;
}
}
}
break;
case MT_ROBRA_JOINT:
case MT_BLUEROBRA_JOINT:
if (!mobj->target || P_MobjWasRemoved(mobj->target))
{
P_RemoveMobj(mobj);
return;
}
break;