Jump to content

Wait For Party Members When Moving


Recommended Posts

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
Link to comment
Share on other sites

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;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...