// problems: giving reclaim order on moving target causes commander // to walk (messing up subsequent dgun order if target still moving) // and does not take commander torso rotation time into account // void DGunController::trackAttackTarget(unsigned int currentFrame) { if (commanderWD && currentFrame - state.targetSelectionFrame == 5) { // five sim-frames have passed since selecting target, attack float3 newTargetPos = CALLOUT->GetUnitPos(state.targetID); // current target position float3 commanderPos = CALLOUT->GetUnitPos(commanderID); // current commander position float targetDist = (commanderPos - newTargetPos).Length(); // distance to target float3 targetDir = (newTargetPos - state.oldTargetPos).Normalize(); // target direction of movement float targetSpeed = (newTargetPos - state.oldTargetPos).Length() / 5; // target speed per sim-frame during tracking interval float dgunDelay = targetDist / commanderWD->projectilespeed; // sim-frames needed for dgun to reach target position float3 attackPos = newTargetPos + targetDir * (targetSpeed * dgunDelay); // position where target will be in <dgunDelay> frames float maxRange = CALLOUT->GetUnitMaxRange(commanderID); // CALLOUT->CreateLineFigure(commanderPos, attackPos, 48, 1, 3600, 0); if ((commanderPos - attackPos).Length() < maxRange * 0.9f) { // multiply by 0.9 to ensure commander does not have to walk if ((CALLOUT->GetEnergy()) >= DGUN_MIN_ENERGY_LEVEL) { state.dgunOrderFrame = currentFrame; issueOrder(attackPos, CMD_DGUN, 0); } else { state.reclaimOrderFrame = currentFrame; issueOrder(state.targetID, CMD_RECLAIM, 0); } } else { state.reset(currentFrame, true); } } state.reset(currentFrame, false); }
bool RtBroker::unblockingIssueOrder(BrkLib::BrokerSession &session, BrkLib::Order const& order) { if (session.isConnected()) { RtSession& rtSession = (RtSession&)session; issueOrder( session, order ); return true; } // failure return false; }