QVector ComputeJumpPointArrival( QVector pos, std::string origin, std::string destination ) { QVector finish = SystemLocation( destination ); QVector start = SystemLocation( origin ); QVector dir = finish-start; if ( dir.MagnitudeSquared() ) { dir.Normalize(); dir = -dir; pos = -pos; pos.Normalize(); if ( pos.MagnitudeSquared() ) pos.Normalize(); return (dir*.5+pos*.125)*howFarToJump(); } return QVector( 0, 0, 0 ); }
static void FaceTarget (Unit * un) { Unit * targ = un->Target(); if (targ) { QVector dir (targ->Position()-un->Position()); dir.Normalize(); Vector p,q,r; un->GetOrientation(p,q,r); QVector qq(q.Cast()); qq = qq+QVector (.001,.001,.001); un->SetOrientation (qq,dir); } }