// Function: A_JetbThink
//
// Description: Thinker for Jetty-Syn bombers
//
// var1 = unused
// var2 = unused
//
void A_JetbThink(mobj_t *actor)
{
sector_t *nextsector;
fixed_t thefloor;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_JetbThink", actor))
return;
#endif
if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz
&& actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale))
thefloor = actor->watertop;
else
thefloor = actor->floorz;
if (actor->target)
{
A_JetChase(actor);
// check for melee attack
if (actor->info->raisestate
&& (actor->z > (actor->floorz + FixedMul((32<<FRACBITS), actor->scale)))
&& P_JetbCheckMeleeRange(actor) && !actor->reactiontime
&& (actor->target->z >= actor->floorz))
{
mobj_t *bomb;
if (actor->info->attacksound)
S_StartAttackSound(actor, actor->info->attacksound);
// use raisestate instead of MT_MINE
bomb = P_SpawnMobj(actor->x, actor->y, actor->z - FixedMul((32<<FRACBITS), actor->scale), (mobjtype_t)actor->info->raisestate);
P_SetTarget(&bomb->target, actor);
bomb->destscale = actor->scale;
P_SetScale(bomb, actor->scale);
actor->reactiontime = TICRATE; // one second
S_StartSound(actor, actor->info->attacksound);
}
}
else if (((actor->z - FixedMul((32<<FRACBITS), actor->scale)) < thefloor) && !((thefloor + FixedMul((32<<FRACBITS), actor->scale) + actor->height) > actor->ceilingz))
actor->z = thefloor+FixedMul((32<<FRACBITS), actor->scale);
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE))
{
// look for a new target
if (P_LookForPlayers(actor, true, false, 0))
return; // got a new target
P_SetMobjState(actor, actor->info->spawnstate);
return;
}
nextsector = R_PointInSubsector(actor->x + actor->momx, actor->y + actor->momy)->sector;
// Move downwards or upwards to go through a passageway.
if (nextsector->ceilingheight < actor->z + actor->height)
actor->momz -= FixedMul(5*FRACUNIT, actor->scale);
else if (nextsector->floorheight > actor->z)
actor->momz += FixedMul(5*FRACUNIT, actor->scale);
}