//Emulates missile travel. Returns distance travelled. fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) { AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8*FRACUNIT), NO_REPLACE); th->target = source; // where it came from float speed = (float)th->Speed; TVector3<double> velocity = source->Vec3To(dest); velocity.MakeUnit(); th->velx = FLOAT2FIXED(velocity[0] * speed); th->vely = FLOAT2FIXED(velocity[1] * speed); th->velz = FLOAT2FIXED(velocity[2] * speed); fixed_t dist = 0; while (dist < SAFE_SELF_MISDIST) { dist += th->Speed; th->Move(th->velx, th->vely, th->velz); if (!CleanAhead (th, th->X(), th->Y(), cmd)) break; } th->Destroy (); return dist; }
bool FCajunMaster::Move (AActor *actor, ticcmd_t *cmd) { fixed_t tryx, tryy; bool try_ok; int good; if (actor->movedir == DI_NODIR) return false; if ((unsigned)actor->movedir >= 8) I_Error ("Weird bot movedir!"); tryx = actor->x + 8*xspeed[actor->movedir]; tryy = actor->y + 8*yspeed[actor->movedir]; try_ok = CleanAhead (actor, tryx, tryy, cmd); if (!try_ok) //Anything blocking that could be opened etc.. { if (!spechit.Size ()) return false; actor->movedir = DI_NODIR; good = 0; line_t *ld; while (spechit.Pop (ld)) { bool tryit = true; if (ld->special == Door_LockedRaise && !P_CheckKeys (actor, ld->args[3], false)) tryit = false; else if (ld->special == Generic_Door && !P_CheckKeys (actor, ld->args[4], false)) tryit = false; if (tryit && (P_TestActivateLine (ld, actor, 0, SPAC_Use) || P_TestActivateLine (ld, actor, 0, SPAC_Push))) { good |= ld == actor->BlockingLine ? 1 : 2; } } if (good && ((pr_botopendoor() >= 203) ^ (good & 1))) { cmd->ucmd.buttons |= BT_USE; cmd->ucmd.forwardmove = FORWARDRUN; return true; } else return false; } else //Move forward. cmd->ucmd.forwardmove = FORWARDRUN; return true; }