ive made a lil code to Face (and turn camera) to the selected Target (GUID)
by doing Math
maybe some1 needs this. (i'm using it to autokill Tyrannus via port):
Code:
procedure FaceGUID(GUID:UInt64; CenterCam:Bool);
var
Mx, My, Tx, Ty, Distance1, Distance2, Rota: Extended;
C_Pointer, C_Offset: Integer;
begin
if (GUID <> 0) and (GUID <> MemRUInt64(PlayerGUID)) then begin
Mx := roundto(MemRFloat(MemRBase + PlayerX), -3);
My := roundto(MemRFloat(MemRBase + PlayerY), -3);
Tx := roundto(MemRFloat(GetObjectBaseByGuid(GUID) + UnitFieldsX),-3);
Ty := roundto(MemRFloat(GetObjectBaseByGuid(GUID) + UnitFieldsY),-3);
Distance1 := roundto(Sqrt(Sqr(Mx-Tx)+Sqr(My-Ty)), -3);
Distance2 := roundto(Sqrt(Sqr(My-Ty)), -3);
Rota := ArcSin(Distance2 / Distance1);
if (Mx < Tx) and (My > Ty) then
Rota := DegreeToRadian(360) - Rota
else
if (Mx > Tx) and (My > Ty) then
Rota := DegreeToRadian(180) + Rota
else
if (Mx > Tx) and (My < Ty) then Rota := DegreeToRadian(180) - Rota;
MemWFloat(MemRBase + PlayerR, Rota);
if CenterCam = true then
begin
C_Pointer := MemRInt(CameraPointer);
C_Offset := MemRInt(C_Pointer + CameraOffset);
MemWFloat(C_Offset + CameraRotaY, 0);
end;
end;
end;
MemWFloat = MemoryWrite a Float value (Extended or Single possible)
^^ u should know how to do that.
Rota <- your Rotation
Mx, ... <- your coords
Tx, ... <- targets coords
3.3.5 offsets are:
Code:
Base = $00CD87A8; BaseOffset1 = $34; BaseOffset2 = $24; ObjManagerBase = $00C79CE0; ObjManagerOffs = $2ED0; ObjManagerFirst = $AC; ObjManagerNext = $3C; PlayerX = $798; PlayerY = $79C; PlayerR = $7A8; UnitFieldsX = PlayerX; // $798 UnitFieldsY = PlayerY; // $79C CameraPointer = $00B7436C; CameraOffset = $7E20; CameraRotaY = $11C; LocalTargetGUID = $00BD07B0;
Code:
function MemRBase: Integer;
begin
result := MemRInt(MemRInt(MemRInt(Base) + BaseOffset1) + BaseOffset2);
end;
function GetFirstObject: Integer;
begin
result := MemRInt(MemRInt(MemRInt(ObjManagerBase) + ObjManagerOffs) + ObjManagerFirst);
end;
function GetObjectBaseByGuid(Guid:Uint64): integer;
var
TOBaseAddress: Integer;
TOGuid: UInt64;
begin
if GUID <> 0 then begin
result := 0;
TOBaseAddress := GetFirstObject;
while TOBaseAddress <> 0 do begin
TOGuid := MemRUInt64(TOBaseAddress + ObjGUIDOffset);
if TOGuid = Guid then begin
result := TOBaseAddress;
break;
end else
TOBaseAddress := MemRInt(TOBaseAddress + ObjManagerNext);
end;
//result := 0;
end else result := 0;
end;
greetz
piotr






