Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: LORD KILLA on June 30, 2009, 02:25:51 pm
-
Hai all!
I'm currentyl working on my Zombie Remake 1.3b for my server, and i need a procedure that shoots from point A to point B, example: Shoot(GetPlayerStat(id, 'x'), GetPlayerStat(id, 'y'), GetPlayerStat(Player, 'x'), GetPlayerStat(Player, 'y')...);
not like Veloircity, anyway: Who will help will be added to my Credits list on my zombie server ^^
-
there you go (copied from MMod by Avarax)
function Aim(const X1,Y1,X2,Y2: single) : single;
begin
if (X2 - X1)<>0 then begin
if X1 > X2 then
result:= arctan((y2 - y1) / (x2 - x1)) + Pi
else
result:= arctan((y2 - y1) / (x2 - x1));
end
else begin
if Y2 > Y1 then result:= Pi/2 + Pi/4;
if Y2 < Y1 then result:= -Pi/2 + Pi/4;
end;
end;
procedure Shoot(const X1,Y1,X2,Y2,speed,power,decentralize,accuracy: single; const owner,style: byte);
var AccuracyMarginal: integer;
angle: single;
begin
If Accuracy < 100 then
AccuracyMarginal:=round((100 - Accuracy) / 100 * 3600)
else
AccuracyMarginal:=0;
angle:=Aim(X1,Y1,X2,Y2);
CreateBullet(X1+decentralize*cos(angle),Y1+decentralize*sin(angle),cos(angle + deg2rad(random(-AccuracyMarginal,AccuracyMarginal) / 10))*speed,sin(angle + deg2rad(random(-AccuracyMarginal,AccuracyMarginal) / 10))*speed,power,style,owner);
end;
-
Thanks, fast&easy like i like it ::)