Results 1 to 19 of 19

Thread: advanced help

  1. #1
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default advanced help

    here is the code, if you can't figure it out when you hit run you wont be able to help me out anyway, for some reason the bitch doesnt wanna do what its told, it somehow successfully arrives at the wrong location so heres the code, if you need further explanation ill give it to ya

    SCAR Code:
    program New;

    function path1: TPointArray;
    begin
      SetLength(Result, 8);

      Result[0] := Point(0, 0);
      Result[1] := Point(0, 1);
      Result[2] := Point(0, 2);
      Result[3] := Point(0, 3);
      Result[4] := Point(0, 4);
      Result[5] := Point(0, 5);
      Result[6] := Point(0, 6);
      Result[7] := Point(0, 7);
    end;

    function path2: TPointArray;
    begin
      SetLength(Result, 8);

      Result[0] := Point(0, 0);
      Result[1] := Point(1, 1);
      Result[2] := Point(2, 2);
      Result[3] := Point(3, 3);
      Result[4] := Point(4, 4);
      Result[5] := Point(5, 5);
      Result[6] := Point(6, 6);
      Result[7] := Point(7, 7);
    end;

    function path3: TPointArray;
    begin
      SetLength(Result, 8);

      Result[0] := Point(0, 0);
      Result[1] := Point(1, 0);
      Result[2] := Point(2, 0);
      Result[3] := Point(3, 0);
      Result[4] := Point(4, 0);
      Result[5] := Point(5, 0);
      Result[6] := Point(6, 0);
      Result[7] := Point(7, 0);
    end;

    function path4: TPointArray;
    begin
      SetLength(Result, 8);

      Result[0] := Point(7, 0);
      Result[1] := Point(7, 1);
      Result[2] := Point(7, 2);
      Result[3] := Point(7, 3);
      Result[4] := Point(7, 4);
      Result[5] := Point(7, 5);
      Result[6] := Point(7, 6);
      Result[7] := Point(7, 7);
    end;

    function path5: TPointArray;
    begin
      SetLength(Result, 8);

      Result[0] := Point(0, 7);
      Result[1] := Point(1, 7);
      Result[2] := Point(2, 7);
      Result[3] := Point(3, 7);
      Result[4] := Point(4, 7);
      Result[5] := Point(5, 7);
      Result[6] := Point(6, 7);
      Result[7] := Point(7, 7);
    end;

    function IntinArr(int:integer; comp:array of integer):boolean;
    var i:integer;
    begin
         result := false;
         for i := 0 to High(comp) do
         begin
              if comp[i] = int then
              begin
                 result := true;
                 exit;
              end;
         end;
    end;

    type path = record
         node: TPointArray;
         avg, first,last: TPoint;
         index: integer;
         connection: array of integer;
    end;

    var paths:array of path;
        curindex: integer;
       
    function CalcAvginTPA(tpa:TPointArray):TPoint;
    var i:integer;
    begin
         for i := 0 to high(tpa) do
         begin
              result.x := result.x + tpa[i].x;
              result.y := result.y + tpa[i].y;
         end;
         result.x := Round(result.x / getarraylength(tpa));
         result.y := Round(result.y / getarraylength(tpa));
    end;
       
    function CreatePath(node:TPointArray):integer;
    begin
        SetArrayLength(paths, curindex+1);
        paths[curindex].node := node;
        paths[curindex].index := curindex;
        paths[curindex].avg := CalcAvginTPA(node);
        paths[curindex].first := node[0];
        paths[curindex].last := node[high(node)];
        result := curindex;
        curindex := curindex + 1;
    end;

    procedure LinkPath(i,y:integer);
    begin
         if IntinArr(i, paths[y].connection) = true then
         begin
            writeln('Following paths are already linked: ' + inttostr(i) + ':' + inttostr(y) + ' so fix your script because you''re losing efficiency!');
            exit;
         end;
         SetArrayLength(paths[i].connection, GetArrayLength(paths[i].connection)+1);
         SetArrayLength(paths[y].connection, GetArrayLength(paths[y].connection)+1);
         paths[i].connection[High(paths[i].connection)] := paths[y].index;
         paths[y].connection[High(paths[y].connection)] := paths[i].index;
    end;


    var charx,chary, destx, desty:integer;
        arrived: boolean;

    function TPt(x,y:integer):TPoint;
    begin
         result.x := x;
         result.y := y;
    end;

    function AngleBetweenPoints(y1,y2,x1,x2:integer):extended;
    begin
         result := Abs(Arctan2(y2-y1,x2-x1) * 180 / Pi);
    end;

    procedure MoveTo(p:TPoint);
    begin
         charx := p.x;
         chary := p.y;
         writeln('Moved to :' + inttostr(p.x) + ',' + inttostr(p.y));
    end;

    procedure Initialize();
    begin
         CreatePath(path1());
         CreatePath(path2());
         CreatePath(path3());
         CreatePath(path4());
         CreatePath(path5());
         LinkPath(0,1);
         LinkPath(0,2);
         LinkPath(1,2);
         LinkPath(1,3);
         LinkPath(1,4);
         LinkPath(3,4);
    end;

    procedure AutoMoveThroughTPA(start,inc:integer; node:TPointArray);
    var i:integer;
    begin
         i := start - inc;
         repeat
               i := i + inc;
               MoveTo(node[i]);
               if (node[i].x = destx) and (node[i].y = desty) then
               begin
                    arrived := true;
                    exit;
               end;
               wait(100);
         until (((i = 0) and (i <> start)) or ((i = high(node)) and (high(node) <> start)))
    end;

    function Pathable(path:integer):boolean;
    begin
         if Distance(charx, chary, paths[path].first.x, paths[path].first.y) < Distance(charx, chary, paths[path].last.x, paths[path].last.y)then
         begin
              result := ((charx = paths[path].first.x) and (chary = paths[path].first.y));
         end else
         begin
              result := ((charx = paths[path].last.x) and (chary = paths[path].last.y));
         end;
    end;

    procedure TakePath(path:integer);
    begin
         if Distance(charx, chary, paths[path].first.x, paths[path].first.y) < Distance(charx, chary, paths[path].last.x, paths[path].last.y) then
         begin
             AutoMoveThroughTPA(0, 1, paths[path].node)
         end else
         begin
             AutoMoveThroughTPA(high(paths[path].node), -1, paths[path].node)
         end;
    end;

    function DegreeDiff(A, B:extended):extended;
    begin
      result:= Abs(A-B);
      if result>180.0 then
        result:= 180.0-(result-180.0);
    end;

    function move(x,y:integer):boolean;
    var p, n, curpath, lastpath:integer;
        c, cd: extended;
        node: TPointArray;
    begin
         c := 360;
         arrived := false;
         destx := x;
         desty := y;
         // Get Closest path
         curpath := 0;
         node := paths[curpath].node;
         // Get Closest Point in TPA
         p := 3;
         // Finish first TPA
         cd := AngleBetweenPoints(chary, y, charx, x);
         if DegreeDiff(cd,AngleBetweenPoints(node[p+1].y, y,node[p+1].x,x)) < DegreeDiff(cd,AngleBetweenPoints(node[p-1].y, y,node[p-1].x,x)) then
         begin
             AutoMoveThroughTPA(p+1, 1, node);
         end else
         begin
             AutoMoveThroughTPA(p-1, -1, node);
         end;
         
         repeat
               cd := AngleBetweenPoints(chary, y, charx, x);
               for p := 0 to high(paths[curpath].connection) do
               begin
                    if (c > DegreeDiff(cd, AngleBetweenPoints(y, paths[paths[curpath].connection[p]].avg.y, x, paths[paths[curpath].connection[p]].avg.x))) {and (p <> lastpath) and (Pathable(p) = true)} then
                    begin
                       c := AngleBetweenPoints(y, paths[paths[curpath].connection[p]].avg.y, x, paths[paths[curpath].connection[p]].avg.x);
                       n := p;
                    end;
               c := 360;
               TakePath(n);
               lastpath := curpath;
               curpath := n;
               end;
         until (arrived = true)

    end;

    begin
         Initialize;
         MoveTo(TPt(0,3));
         Move(0,7);
    end.

  2. #2
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    well if you tell us what the problem is then we may be able to help without having to see if anything goes wrong

    ~shut
    That would help us out greatly. Just looking at your code you have a lot of needless begin..end nests. An if..then statement will do the first line of code below it without a begin..end nest, for example:

    SCAR Code:
    if blah then
    begin
      blah2
    end else
    begin
      blah3
    end;

    Can become:

    SCAR Code:
    if blah then
      blah2
    else
      blah3

    See what I mean?

    Also, if you want to save some lines, and have your code slightly more advanced, you can load your walk paths like this:

    SCAR Code:
    function Paths(i : Integer): TPointArray;
    begin
      case i of
        0: Result := [Point(0, 0), Point(0, 1), Point(0, 2), Point(0, 3), Point(0, 4)
                      Point(0, 5), Point(0, 6), Point(0, 7)];
        1: Result := [Point(0, 0), Point(1, 1), Point(2, 2), Point(3, 3), Point(4, 4)
                      Point(5, 5), Point(6, 6), Point(7, 7)];
        //The rest of the walk paths here...
    end;

    This way you save a lot of lines, and if you want to load the first path all you have to say is:

    SCAR Code:
    Paths(0);

    I know you didn't ask for any of that, but I thought I'd just help you out anyway. Expanding on your problem would help us out a lot.

    Cheers!
    Last edited by Coh3n; 08-09-2009 at 07:21 AM.

  4. #4
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    That would help us out greatly. Just looking at your code you have a lot of needless begin..end nests. An if..then statement will do the first line of code below it without a begin..end nest, for example:

    SCAR Code:
    if blah then
    begin
      blah2
    end else
    begin
      blah3
    end;

    Can become:

    SCAR Code:
    if blah then
      blah2
    else
      blah3

    See what I mean?

    Also, if you want to save some lines, and have your code slightly more advanced, you can load your walk paths like this:

    SCAR Code:
    function Paths(i : Integer): TPointArray;
    begin
      case i of
        0: Result := [Point(0, 0), Point(0, 1), Point(0, 2), Point(0, 3), Point(0, 4)
                      Point(0, 5), Point(0, 6), Point(0, 7)];
        1: Result := [Point(0, 0), Point(1, 1), Point(2, 2), Point(3, 3), Point(4, 4)
                      Point(5, 5), Point(6, 6), Point(7, 7)];
        //The rest of the walk paths here...
    end;

    This way you save a lot of lines, and if you want to load the first path all you have to say is:

    SCAR Code:
    Paths(0);

    I know you didn't ask for any of that, but I thought I'd just help you out anyway. Expanding on your problem would help us out a lot.

    Cheers!
    thanks for your useless post i won't consider any of it

    @shut if you ran the code and looked at the result and compared to what it was supposed to do which is quite obvious you'd instantly realize whats wrong unless you're an amateur coder in which case you won't be able to help anyways

  5. #5
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    thanks for your useless post i won't consider any of it

    @shut if you ran the code and looked at the result and compared to what it was supposed to do which is quite obvious you'd instantly realize whats wrong unless you're an amateur coder in which case you won't be able to help anyways
    i was going to post explaining how to fix it, but after reading that, i dont think i will, and delete my example for you.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  6. #6
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wtf, he was just trying to help you improve yourself, i would have helped, but your a sad messed up person.
    Just because you suck, and you know he's better than you, you have to be so rude?

    And shuttleu is much better than you .

    Edit: Sorry if i was rude, but you were rude to Coh3n, so it gives me the right to be rude to you. If you apologize i will apologize too.
    Last edited by Smarter Child; 08-09-2009 at 10:44 AM.

  7. #7
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Smarter Child View Post
    Wtf, he was just trying to help you improve yourself, i would have helped, but your a sad messed up person.
    Just because you suck, and you know he's better than you, you have to be so rude?

    And shuttleu i much better than you .
    that was a little rude too
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  8. #8
    Join Date
    Mar 2007
    Posts
    732
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    thanks for your useless post i won't consider any of it

    @shut if you ran the code and looked at the result and compared to what it was supposed to do which is quite obvious you'd instantly realize whats wrong unless you're an amateur coder in which case you won't be able to help anyways

    wow.. if i was a admin you would be banned right now. our comunity dosnt need imature children like yourself

    Edit: oops.. this is Lance, i didnt realize that i was logged into oo00o. hes my brother and im on his computer atm xP
    Last edited by Sean[714]; 08-09-2009 at 10:46 AM.
    Sean[714] @rscheata.net

  9. #9
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    thanks for your useless post i won't consider any of it
    Good luck gaining respect in this community with that attitude, I'll be sure not to help you out next time, I apologize.

    Quote Originally Posted by Awkwardsaw View Post
    that was a little rude too
    He was just making a point, considering what Feroc1ty said, I wouldn't consider that rude at all.
    Last edited by Coh3n; 08-09-2009 at 10:55 AM.

  10. #10
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    thanks for your useless post i won't consider any of it

    @shut if you ran the code and looked at the result and compared to what it was supposed to do which is quite obvious you'd instantly realize whats wrong unless you're an amateur coder in which case you won't be able to help anyways
    You insulted members... That were both really trying help...

    If you applied for members right now, I would vote no even if the script was 100% perfect.
    I do visit every 2-6 months

  11. #11
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by ZaSz View Post
    You insulted members... That were both really trying help...

    If you applied for members right now, I would vote no even if the script was 100% perfect.
    as if anyone cares what you have to say, you're a nobody.

    and akward, considering how bad you are, theres no way you knew the solution, so your post didnt make me feel bad in any way, just put a smirk on my face for your attempt at what you so call trolling

  12. #12
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    as if anyone cares what you have to say, you're a nobody.

    and akward, considering how bad you are, theres no way you knew the solution, so your post didnt make me feel bad in any way, just put a smirk on my face for your attempt at what you so call trolling
    Your asking for a ban. Disrespect to anyone on these forums are highly frowned upon, whether you think you're superior to them or not.

  13. #13
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Your asking for a ban. Disrespect to anyone on these forums are highly frowned upon, whether you think you're superior to them or not.
    think? I know.

  14. #14
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    think? I know.
    Okay.

  15. #15
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    think? I know.
    Then wtf is wrong with you.
    I do visit every 2-6 months

  16. #16
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    You, Feroc1ty, never seem to understand that flaming people who try to help you won't get you anywhere. Furthermore your arrogance is getting on my nerves...

  17. #17
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by ZephyrsFury View Post
    You, Feroc1ty, never seem to understand that flaming people who try to help you won't get you anywhere. Furthermore your arrogance is getting on my nerves...
    I suggest you ban him temporarily. If this doesn't stop him from being rude, make it permanent. Everybody complaining won't solve anything. He obviously doesn't care.

  18. #18
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by bullzeye95 View Post
    I suggest you ban him temporarily. If this doesn't stop him from being rude, make it permanent. Everybody complaining won't solve anything. He obviously doesn't care.
    And you care enough to post something offtopic?

    Every single post here is offtopic, not a single one points out the issue, or even attempts to solve the issue; a couple people somewhat tried to help but their attempts were utter failures that ended up discriminating my code when it's fine the way it is.

  19. #19
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    I guess since everyone here is too stupid and inferior to you there is no point in keeping this thread open.

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
  •