1. signed int __cdecl Script_UnitPosition(int a1)
  2. {
  3. int kw; // [email protected]
  4. int v3; // [email protected]
  5. CGUnit_C *pObiect; // [email protected]
  6. C3Vector *v5; // [email protected]
  7. signed int mapId; // [email protected]
  8. int v7; // [email protected]
  9. float v8; // [email protected]
  10. signed int v9; // [email protected]
  11. int v10; // [email protected]
  12. int v11; // [email protected]
  13. float y; // [email protected]
  14. int _z; // [email protected]
  15. WoWGUID guid; // [sp+10h] [bp-2Ch]@3
  16. int v15; // [sp+20h] [bp-1Ch]@3
  17. C3Vector pos; // [sp+24h] [bp-18h]@7
  18. C3Vector pos2; // [sp+30h] [bp-Ch]@7
  19. if ( !lua_isstring(a1, 1) )
  20. {
  21. lua_error(a1, "Usage: UnitPosition(\"unit\")");
  22. return 0;
  23. }
  24. kw = lua_tostring(a1, 1, 0);
  25. GetGUIDByKeyWord(&guid, kw);
  26. v3 = GetParty();
  27. sub_6A3025(&v15);
  28. if ( sub_4264C9((int)&guid, (int)&v15) && (!v3 || !Party::HasMember(v3, (int)&guid, 0)) )
  29. return 0;
  30. pObiect = (CGUnit_C *)GetObjectPtrByGUID((int)&guid, 8, (unsigned int)"ScriptEvents.cpp");
  31. if ( !pObiect )
  32. {
  33. v7 = sub_93AC7F(&guid);
  34. if ( v7 )
  35. {
  36. v8 = (float)*(_WORD *)(v7 + 32);
  37. v9 = *(_WORD *)(v7 + 34);
  38. v10 = *(_WORD *)(v7 + 24);
  39. pos2.X = v8;
  40. pos2.Y = (float)v9;
  41. v11 = GetMapIDByAreaID((int)&dword_115EAC4, v10);
  42. if ( v11 )
  43. mapId = *(_DWORD *)(v11 + 4);
  44. else
  45. mapId = -1;
  46. goto LABEL_13;
  47. }
  48. return 0;
  49. }
  50. v5 = (C3Vector *)pObiect->vtable->GetPosition(pObiect, &pos);
  51. pos2.X = v5->X;
  52. pos2.Y = v5->Y;
  53. pos2.Z = v5->Z;
  54. mapId = dword_1263C14;
  55. LABEL_13:
  56. pos2.X = (float)(signed int)sub_48AA75(pos2.X * 10.0) * 0.1;
  57. y = (float)(signed int)sub_48AA75(pos2.Y * 10.0) * 0.1;
  58. _z = 7 * ((signed int)ffloor(pos2.X) ^ ((signed int)ffloor(y) + 3));
  59. pos2.Y = y;
  60. pos2.Z = (float)(_z & 0xFFFFF);
  61. lua_pushnumber(a1, *(_OWORD *)&_mm_cvtps_pd((__m128)(unsigned int)pos2.X));
  62. lua_pushnumber(a1, *(_OWORD *)&_mm_cvtps_pd((__m128)LODWORD(pos2.Y)));
  63. lua_pushnumber(a1, *(_OWORD *)&_mm_cvtps_pd((__m128)LODWORD(pos2.Z)));
  64. lua_pushinteger(a1, mapId);
  65. return 4;
  66. }
Comments powered by Disqus