//Check use of vamps// bool useVmap = false; bool swapZone = true; if( MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(cx, cy, cz, false) < MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(cx, cy, cz, true) ) useVmap = true; const float obj_size = unitTarget->GetObjectSize(); const float _dx = (obj_size + 0.5f) * cos(angle); const float _dy = (obj_size + 0.5f) * sin(angle); dx = cx; dy = cy; //Going foward 0.5f until max distance for(float i=0.5f; i<dis; i+=0.5f) { dx += _dx; dy += _dy; Trinity::NormalizeMapCoord(dx); Trinity::NormalizeMapCoord(dy); //unitTarget->GetNearPoint2D(dx,dy,i,angle); dz = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(dx, dy, cz, useVmap); //Prevent climbing and go around object maybe 2.0f is to small? use 3.0f? if( (dz-cz) < 2.0f && (dz-cz) > -2.0f && (unitTarget->IsWithinLOS(dx, dy, dz))) { //No climb, the z differenze between this and prev step is ok. Store this destination for future use or check. cx = dx; cy = dy; cz = dz; } else { //Something wrong with los or z differenze... maybe we are going from outer world inside a building or viceversa if(swapZone) { //so... change use of vamp and go back 1 step backward and recheck again. swapZone = false; useVmap = !useVmap; i-=0.5f; dx -= _dx; dy -= _dy; Trinity::NormalizeMapCoord(dx); Trinity::NormalizeMapCoord(dy); }