Advertisement
Rochet2

Get position relative to unit

Apr 24th, 2013
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. // left = 90 | right = -90
  2. {
  3.         Unit* unit;
  4.         float dist;
  5.         int deg;
  6.  
  7.         float o = unit->GetOrientation() + (deg*M_PI/180);
  8.         o = Position::NormalizeOrientation(o);
  9.         float x = unit->GetPositionX()+(dist*cosf(o));
  10.         float y = unit->GetPositionY()+(dist*sinf(o));
  11.         float z = unit->GetMap()->GetHeight(unit->GetPhaseMask(), x, y, MAX_HEIGHT);
  12.         if(z == INVALID_HEIGHT)
  13.             z = unit->GetPositionZ();
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement