Jump to content

Recommended Posts

Posted (edited)

I have a script to change from one chamber to another, but when I have party members they get stuck in the walls, so I added a delay to the movement, but the delay is too long and I want to wait only till they are in a certain range. So how would that be?

function   distanceBetween (x1, y1, z1, x2, y2, z2: int64): extended;
begin
	 Result := sqrt(((x2 - x1)*(x2 - x1)) + ((y2 - y1)*(y2 - y1)) + ((z2 - z1)*(z2 - z1)));
end;

procedure  MoveAndWait (x, y, z: integer);
for  Party.User.Chars(i)  do
var
  x1, y1, z1: integer;
  x2, y2, z2: integer;
begin
  Engine.MoveTo (x, y, z);
  for  i := 0  to  Party.User.Chars.Count-1  do
  begin
    x1 := User.X;  y1 := User.Y;  z1 := User.Z;
    x2 := Party.User.Chars.Items(i).X;
    y2 := Party.User.Chars.Items(i).Y;
    z2 := Party.User.Chars.Items(i).Z;

    if  (distanceBetween (x1, y1, z1, x2, y2, z2) < 1000)  then
    begin
      while  not (distanceBetween (x1, y1, z1, x2, y2, z2) < 110)  then
      begin
        x2 := Party.User.Chars.Items(i).X;
        y2 := Party.User.Chars.Items(i).Y;
        z2 := Party.User.Chars.Items(i).Z;
        Delay (1111);
      end;
    end;
  end;
end;

What do you think about this code?

Edited by darknesscrysis
Posted

This works nice:

procedure  MoveAndWait (x, y, z: integer);
var
  i: integer;
  x1, y1, z1: integer;
  x2, y2, z2: integer;
begin
  Engine.MoveTo (x, y, z);
  for  i := 0  to  Party.Chars.Count-1  do
  begin
    x1 := User.X;  y1 := User.Y;  z1 := User.Z;
    x2 := Party.Chars.Items(i).X;
    y2 := Party.Chars.Items(i).Y;
    z2 := Party.Chars.Items(i).Z;

    if  (distanceBetween (x1, y1, z1, x2, y2, z2) < 1000)  then
    begin
      while  not (distanceBetween (x1, y1, z1, x2, y2, z2) < 100)  do
      begin
        x2 := Party.Chars.Items(i).X;
        y2 := Party.Chars.Items(i).Y;
        z2 := Party.Chars.Items(i).Z;
        Delay (500);
      end;
    end;
  end;
end;

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock