# Thread: Pyramid Esp [ Delphi]

1. ## Pyramid Esp [ Delphi]

Pyramid Esp [ Delphi]

type
tpixel=record
x,y,z:integer;
end;

tmatrix=array[1..4,1..4]of single;
tvector=array[1..4] of single;

function vector********(V:tvector;Y:tmatrix):tVector;
var
s:single;
i,j:integer;
a:tvector;
begin
for i:=1 to 4 do begin
s:=0;
for j:=1 to 4 do s:=s+V[j]*Y[j,i];
a[i]:=s;
end;
vector********:=a;
end;

function matrix********(X:tmatrix;Y:tmatrix):Tmatrix;
var
i,j,k:integer;
S:single;
begin
for i:=1 to 4 do
for j:=1 to 4 do begin
s:=0;
for k:=1 to 4 do s:=s+X[i,k]*Y[k,j];
matrix********[i,j]:=s;
end;
end;

function getrotatematrix(axis:byte;alpha:single):tmatrix;
var
i,j:integer;
a:tmatrix;
begin
for i:=1 to 4 do
for j:=1 to 4 do
if i=j then a[i,j]:=1
else a[i,j]:=0;

case axis of
1:begin
a[2,2]:=cos(alpha);
a[2,3]:=-sin(alpha);
a[3,2]:=sin(alpha);
a[3,3]:=cos(alpha);
end;
2:begin
a[1,1]:=cos(alpha);
a[3,1]:=-sin(alpha);
a[1,3]:=sin(alpha);
a[3,3]:=cos(alpha);
end;
3:begin
a[1,1]:=cos(alpha);
a[1,2]:=-sin(alpha);
a[2,1]:=sin(alpha);
a[2,2]:=cos(alpha);
end;
end;
getrotatematrix:=a;
end;

function proection(x1,y1,z1,x2,y2,z2,alpha,beta,gama,fov:si ngle;xres,yres:integer):tpixel;// this is my function proection 3d to 2d , inside it you can use 'worldtoscreen'
var
x,y,z:single;
mat,rot,rot1,rot2,rot3,trans:tmatrix;
v1,v2:tvector;
i,j:integer;
begin
alpha:=alpha*(pi/180);
beta:=beta*(pi/180);
gama:=gama*(pi/180);
v1[1]:=x2;
v1[2]:=y2;
v1[3]:=z2;
v1[4]:=1;
trans:=gettransmatrix(-x1,-y1,-z1);
rot1:=getrotatematrix(3,alpha);
rot2:=getrotatematrix(2,beta);
rot3:=getrotatematrix(1,gama);
mat:=matrix********(trans,rot1);
mat:=matrix********(mat,rot2);
mat:=matrix********(mat,rot3);
v2:=vector********(v1,mat);
x:=(xres/2)-((v2[2])*(xres/2)/fov)/(v2[1]);
y:=(yres/2)-((v2[3])*(yres/(yres/(xres/2)))/fov)/(v2[1]);
proection.x:=round(x);
proection.y:=round(y);
end;

function distance1(x1,y1,x2,y2:single):single;//distance 2d
begin
distance1:=sqrt(sqr(x1-x2)+sqr(y1-y2));
end;

function distance2(x1,y1,z1,x2,y2,z2:single):single;//distance 3d
begin
distance2:=sqrt(sqr(x1-x2)+sqr(y1-y2)+sqr(z1-z2));
end;

//my functions for calculation of angles between 2 objects (can use for aimbot)
function xangle(x1,y1,x2,y2,myangle:single):single;
var
dl,dl2,teta:single;
begin
dl:=distance1(x1,y1,x2,y2);
if dl=0 then dl:=1;
dl2:=abs(x2-x1);
teta:=((180/pi)*arccos(dl2/dl));
if x2<x1 then teta:=180-teta;
if y2<y1 then teta:=teta*-1 ;
teta:=teta-myangle;
if teta>180 then teta:=(360-teta)*(-1);
if teta<-180 then teta:=(360+teta);
xangle:=teta;

end;

function yangle(x1,y1,z1,x2,y2,z2,myangle:single):single;
var
dl,dl2,teta:single;
begin
dl:=distance2(x1,y1,z1,x2,y2,z2);
if dl=0 then dl:=1;
dl2:=abs(z2-z1);
teta:=((180/pi)*arcsin(dl2/dl));
if z2<z1 then teta:=teta*-1 ;
teta:=myangle+teta;
if teta>180 then teta:=(360-teta)*(-1);
if teta<-180 then teta:=(360+teta);
yangle:=teta;
end;

function check_triangle(w1,w2,w3,w4,w5:tpixel):boolean;
begin
check_triangle:=true;
if (w1.x<0)or(w2.x<0)or(w3.x<0)or(w4.x<0)or(w5.x<0)or
(w1.y<0)or(w2.y<0)or(w3.y<0)or(w4.y<0)or(w5.y<0)th en
check_triangle:=false;
end;

PROCEDURE draw_triangle(x1,y1,x2,y2,x3,y3:integer;w,r,g,b:by te);
var linecord: array[0..5] of Td3dxvector2;
begin
linecord[0].x:=x1;
linecord[0].y:=y1;
linecord[1].x:=x2;
linecord[1].y:=y2;
linecord[2]:=linecord[1];
linecord[3].x:=x3;
linecord[3].y:=y3;
linecord[4]:=linecord[3];
linecord[5].x:=x1;
linecord[5].y:=y1;
if line<>nil then begin
line.SetWidth(w);
line.Draw(@Linecord,6,D3DCOLOR_XRGB(r,g,b));
end;
end;

var linecord: array[0..7] of Td3dxvector2;
begin
linecord[0].x:=x1;
linecord[0].y:=y1;
linecord[1].x:=x2;
linecord[1].y:=y2;
linecord[2]:=linecord[1];
linecord[3].x:=x3;
linecord[3].y:=y3;
linecord[4]:=linecord[3];
linecord[5].x:=x4;
linecord[5].y:=y4;
linecord[6]:=linecord[5];
linecord[7]:=linecord[0];
if line<>nil then begin
line.SetWidth(w);
line.Draw(@Linecord,8,D3DCOLOR_XRGB(r,g,b));
end;
end;

procedure draw_pyramid(w1,w2,w3,w4,w5:tpixel;w,r,g,b:byte);
begin
if check_triangle(w1,w2,w3,w4,w5)=false then exit;
draw_poligon(w1.x,w1.y,w2.x,w2.y,w3.x,w3.y,w4.x,w4 .y,w,r,g,b);

draw_triangle(w1.x,w1.y,w2.x,w2.y,w5.x,w5.y,w,r,g, b);
draw_triangle(w3.x,w3.y,w4.x,w4.y,w5.x,w5.y,w,r,g, b);

end;

//in endscene:
var
x,y,z,alpha,beta,gama:^single;//my coordinates
x2,y2,z2,alpha2,beta2:^single//player coordinates
alive,a:^byte;
i:integer;
w1,w2,w3,w4,w0:tpixel;
dx1,dx2,dx3,dx4,dy1,dy2,dy3,dy4:single;
mat:tmatrix;
vec1,vec2:tvector;

begin
x:=ptr(\$797618);
y:=ptr(\$797618+4);
z:=ptr(\$797618+8);
beta:=ptr(\$0072AF38);
alpha:=ptr(\$0072AF38+4);
gama:=ptr(\$0072AF38+8);
view:=ptr(\$00797610);

for i:=1 to 64 do begin

alpha:=xangle(x^,y^,x2^,y2^,alpha^);
beta:=yangle(x^,y^,z^,x2^,y2^,z2^,beta^);
if (dword(a^)<>0)and(abs(alpha)<=80)and(abs(beta)<=80 )and
(distance2(x^,y^,z^,x2^,y2^,z2^)>=100)and(alive^=1 ) then begin
//pyramid esp
mat:=getrotatematrix(3,-alpha2^*3.14/180);//get matrix of rotation

w0:=proection(x^,y^,z^,x2^,y2^,z2^+80,alpha^,beta^ ,gama^,view^,wnd_clientrect.Right,wnd_clientrect.B ottom);//coordinate of pyramid top

//w1,w2,w3,w4 - coordinates of pyramid basis with rotations
vec1[1]:=25;vec1[2]:=25;
vec2:=vector********(vec1,mat);
dx1:=vec2[1]+x2^;dy1:=vec2[2]+y2^;
w1:=proection(x^,y^,z^,dx1,dy1,z2^,alpha^,beta^,ga ma^,view^,wnd_clientrect.Right,wnd_clientrect.Bott om);

vec1[1]:=-25;vec1[2]:=25;
vec2:=vector********(vec1,mat);
dx2:=vec2[1]+x2^;dy2:=vec2[2]+y2^;
w2:=proection(x^,y^,z^,dx2,dy2,z2^,alpha^,beta^,ga ma^,view^,wnd_clientrect.Right,wnd_clientrect.Bott om);

vec1[1]:=-25;vec1[2]:=-25;
vec2:=vector********(vec1,mat);
dx3:=vec2[1]+x2^;dy3:=vec2[2]+y2^;
w3:=proection(x^,y^,z^,dx3,dy3,z2^,alpha^,beta^,ga ma^,view^,wnd_clientrect.Right,wnd_clientrect.Bott om);

vec1[1]:=25;vec1[2]:=-25;
vec2:=vector********(vec1,mat);
dx4:=vec2[1]+x2^;dy4:=vec2[2]+y2^;
w4:=proection(x^,y^,z^,dx4,dy4,z2^,alpha^,beta^,ga ma^,view^,wnd_clientrect.Right,wnd_clientrect.Bott om);

draw_pyramid(w1,w2,w3,w4,w0,2,255,255,0);
end;
end;
end;

2. @yoda23456

have a look at your code stuff, some of its been blocked by the forum, like all the ones with ******* are probably words lol.

3. Ohh... I diden't see that... Well how could i fix it lol

4. Originally Posted by yoda23456
Ohh... I diden't see that... Well how could i fix it lol
go and edit it, where ever you see the fuckups, just post them OUTSIDE the quote, and do something like this m.e.d.i.a.f.i.r.e < like that or if you dont you get this > *********

5. Originally Posted by Alex

go and edit it, where ever you see the fuckups, just post them OUTSIDE the quote, and do something like this m.e.d.i.a.f.i.r.e < like that or if you dont you get this > *********
Oke im juust going 2 play a bit cod4 first :3