- signed int __cdecl Script_UnitPosition(int a1)
- {
- int kw; // eax@3
- int v3; // esi@3
- CGUnit_C *pObiect; // eax@6
- C3Vector *v5; // eax@7
- signed int mapId; // esi@7
- int v7; // eax@8
- float v8; // xmm0_4@10
- signed int v9; // ecx@10
- int v10; // eax@10
- int v11; // eax@10
- float y; // xmm0_4@13
- int _z; // eax@13
- WoWGUID guid; // [sp+10h] [bp-2Ch]@3
- int v15; // [sp+20h] [bp-1Ch]@3
- C3Vector pos; // [sp+24h] [bp-18h]@7
- C3Vector pos2; // [sp+30h] [bp-Ch]@7
- if ( !lua_isstring(a1, 1) )
- {
- lua_error(a1, "Usage: UnitPosition(\"unit\")");
- return 0;
- }
- kw = lua_tostring(a1, 1, 0);
- GetGUIDByKeyWord(&guid, kw);
- v3 = GetParty();
- sub_6A3025(&v15);
- if ( sub_4264C9((int)&guid, (int)&v15) && (!v3 || !Party::HasMember(v3, (int)&guid, 0)) )
- return 0;
- pObiect = (CGUnit_C *)GetObjectPtrByGUID((int)&guid, 8, (unsigned int)"ScriptEvents.cpp");
- if ( !pObiect )
- {
- v7 = sub_93AC7F(&guid);
- if ( v7 )
- {
- v8 = (float)*(_WORD *)(v7 + 32);
- v9 = *(_WORD *)(v7 + 34);
- v10 = *(_WORD *)(v7 + 24);
- pos2.X = v8;
- pos2.Y = (float)v9;
- v11 = GetMapIDByAreaID((int)&dword_115EAC4, v10);
- if ( v11 )
- mapId = *(_DWORD *)(v11 + 4);
- else
- mapId = -1;
- goto LABEL_13;
- }
- return 0;
- }
- v5 = (C3Vector *)pObiect->vtable->GetPosition(pObiect, &pos);
- pos2.X = v5->X;
- pos2.Y = v5->Y;
- pos2.Z = v5->Z;
- mapId = dword_1263C14;
- LABEL_13:
- pos2.X = (float)(signed int)sub_48AA75(pos2.X * 10.0) * 0.1;
- y = (float)(signed int)sub_48AA75(pos2.Y * 10.0) * 0.1;
- _z = 7 * ((signed int)ffloor(pos2.X) ^ ((signed int)ffloor(y) + 3));
- pos2.Y = y;
- pos2.Z = (float)(_z & 0xFFFFF);
- lua_pushnumber(a1, *(_OWORD *)&_mm_cvtps_pd((__m128)(unsigned int)pos2.X));
- lua_pushnumber(a1, *(_OWORD *)&_mm_cvtps_pd((__m128)LODWORD(pos2.Y)));
- lua_pushnumber(a1, *(_OWORD *)&_mm_cvtps_pd((__m128)LODWORD(pos2.Z)));
- lua_pushinteger(a1, mapId);
- return 4;
- }