Results 1 to 9 of 9

Thread: Distance to The Middle Tile?

  1. #1
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default Distance to The Middle Tile?

    K this may be my last question before my script is finished..

    Attachment 11396

    In the picture attached above, I want to find the distance from two or more objects.. Inorder to Find which Door I need to Open.. See object finding finds more than one door that is 6 tiles away from the K-portal..

    So the script can't find which door to open and does nothing..

    I want to Find the Tile that the green object is on.. Using the purple ones.. Like Distance from All three purple portals to the middle.. or from the purple portals to the door so that I find the door tile and I know which door to open.. Basically find which door is blocking me from reaching the portal? How do I go about doing that?

    Same problem for the altar.. I want to Find which door if any, is blocking me from reaching the altar..
    I am Ggzz..
    Hackintosher

  2. #2
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Find the teleport focus's tile. Sort the door object tiles by the distance from the teleport focus. The first door in the sorted array is the door your after (Doors[0]).

  3. #3
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    Find the teleport focus's tile. Sort the door object tiles by the distance from the teleport focus. The first door in the sorted array is the door your after (Doors[0]).
    Thanks I got it:

    Simba Code:
    //Sorts Objects By Distance From Another..
    //Objects = Multiple Objects To Sort.
    //SingleObject = Object To Sort From.
    //SingleObjectType = Type Of Object To Sort From.
    //Distance = Distance from you to the SingleObject Object to Search.

    function R_SortObjects(Objects: TRSOBJECTARRAY; SingleObject, SingleObjectType, Distance: Integer): TRSOBJECTARRAY;
    var
      i,i2, L: integer;
      tpa: TPointArray;
      Obj, AltarDoor: TRSOBJECT;
    begin

      Obj:= R_GetObject(SingleObject, SingleObjectType, Distance);
      if(R_FindObject(SingleObject, SingleObjectType, Distance, Obj)) then
      Repeat
        wait(RandomRange(500, 1000));
      Until(R_FindObject(SingleObject, SingleObjectType, Distance, Obj));

      L := GetArrayLength(Objects);
      if L < 1 then Exit;
      SetArrayLength(TPA, L);
      SetArrayLength(Result, L);
      for i := 0 to L-1 do
        TPA[i] := Objects[i].Tile;
      SortTPAFrom(TPA, Obj.Tile);
      for i := 0 to L-1 do
        for i2 := 0 to L-1 do
          if (TPA[i].x=Objects[i2].Tile.x) and (TPA[i].y=Objects[i2].Tile.y) then
            Result[i] := Objects[i2];
    end;
    Last edited by Brandon; 07-11-2011 at 10:12 PM.
    I am Ggzz..
    Hackintosher

  4. #4
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    I advise against using SetArrayLength over SetLength.

  5. #5
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Me to, I think setarraylength acts strange sometimes, not sure what causes it I will try to find some posts, setlength is the correct way to do it



  6. #6
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Also, Length() over GetArrayLength()

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Hmmm Thats odd because I Learned how to Do the Sorting from the: SortNPCs function..

    And it used SetArrayLength and GetArrayLength so thats how I always used it :S So does that mean the SortNPCs is bad? Actually What is bad about it? Im just curious. I'll change it but I really wanna know now.
    I am Ggzz..
    Hackintosher

  8. #8
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I'm pretty sure wizzup? And zytex both posted in a thread about this, but I can't remember correctly i am going to have a guess and say it might be the same reason you shouldn't really use byte, they just behave odd every now and then



  9. #9
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Umm I didn't wanna make a new thread because I have three on the first page already -_____-
    My script is finished and compiled well before I added the code below..
    I get Exception in Script: Access violation. And it doesn't highlight what is causing it..

    can you guys tell me why I get access violation doing this:

    Simba Code:
    const
          Logs1 = false; //Walk To the First log (No Ghasts attack here, Only one log per bloom = One Mushroom per bloom)
          Logs2 = true;  //Walk To the Second Log (Ghasts Can Attack here, Two logs Per bloom = Two mushrooms per bloom)
          FoodToEat = 385;  //385 = shark..
          HPToEatAt = 500;  //Eats when HP Gets Below this Number..
          DisableSwampWarning = true; //Disables the Warning About the swamp being dangerous..  

    Procedure EnterSwamp;
    var
    MyPos: TTile;
    begin
    MyPos:= R_GetMyPos;
      If(R_ValidInterface(SwampWarningInterface)) then
      begin
        if(DisableSwampWarning = true) then
        begin
          Repeat
            debug('Disabling Swamp Warning');
            R_ClickInterface(R_GetInterfaceChild(SwampWarningInterface, SwampWarningCheckBox), 1);
            wait(500 + Random(500));
          Until(R_GetInterfaceChild(SwampWarningInterface, SwampWarningCheckBox).TextureID = CheckBoxCheckedTexture);
        end else
        begin
            debug('Entering The Swamp.. SwampWarningDisable = false.');
            Repeat
              R_ClickInterface(R_GetInterfaceChild(SwampWarningInterface, SwampWarningText, 1));
              wait(500 + Random(500));
            Until((MyPos = Point(3444, 3457)) or (MyPos = Point(3443, 3457)) or (R_ValidInterface(SwampWarningInterface) = false));
        end;
      end;
    end;
    I am Ggzz..
    Hackintosher

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •