Results 1 to 13 of 13

Thread: SetFightMode Variant

  1. #1
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default SetFightMode Variant

    Sets the fight mode using integers and strings:

    SCAR Code:
    function SetFightMode(oFightMode: Variant): Boolean;
    var
      i, x, y, r: Integer;
      b: TBox;
     
    begin
      if not(Loggedin)then Exit;
      GameTab(1);
      Wait(200 + Random(777));
      case VarType(oFightMode) of
        3: case oFightMode of
             1: b := IntToBox(575, 255, 630, 290);
             2: b := IntToBox(660, 255, 710, 290);
             3: b := IntToBox(575, 310, 630, 345);
             4: begin
                  r := 4;
                  b := IntToBox(660, 310, 710, 345);
                end;
           end;
        256: case Lowercase(oFightMode) of
               'attack': b := IntToBox(575, 255, 630, 290);
               'strength': b := IntToBox(660, 255, 710, 290);
               'defence': begin
                            b := IntToBox(660, 310, 710, 345);
                            r := 4;
                          end;
               'multi': b := IntToBox(575, 310, 630, 345);
             end;
      end;
      while (i < 4) and (not FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2)) do
      begin
        Mouse(RandomRange(b.x1, b.x2), RandomRange(b.y1, b.y2), 0, 0, True);
        Wait(200 + Random(300));
        Inc(i);
      end;
      Result := FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2);
      if (not Result) and (r = 4) then
        SetFightMode(3);
    end;

    Probably can be shortened.
    Last edited by Quickmarch; 05-31-2009 at 04:11 AM.
    lol

  2. #2
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    very cool i think it should have always been like this

  3. #3
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You do not need to check the vartype.

    Edit: Also, you should use MouseBox (edit: what you have does same thing as mousebox, didn't look at it to good just saw mouse )
    And
    SCAR Code:
    'attack': b := IntToBox(660, 255, 710, 290);
               'strength': b := IntToBox(660, 255, 710, 290);
    Typo? They are same.
    Last edited by Da 0wner; 05-27-2009 at 09:09 PM.

  4. #4
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    You do not need to check the vartype.

    Edit: Also, you should use MouseBox.
    And
    SCAR Code:
    'attack': b := IntToBox(660, 255, 710, 290);
               'strength': b := IntToBox(660, 255, 710, 290);
    Typo? They are same.
    0.o typo. Also, you do need to check the vartype, otherwise it will give runtime errors...

    EDIT: Fixed.
    Last edited by Quickmarch; 05-27-2009 at 08:42 PM.
    lol

  5. #5
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No it won't.
    SCAR Code:
    program New;
    var
      v : variant;
    begin
      v := 0;
      v := lowercase(v);
      case v of
        '0', 0 : Writeln('Zero.');
        '1', 1 : Writeln('One.');
      else
        Writeln('Wtf?');
      end;
    end.

  6. #6
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    No it won't.
    SCAR Code:
    program New;
    var
      v : variant;
    begin
      v := 0;
      v := lowercase(v);
      case v of
        '0', 0 : Writeln('Zero.');
        '1', 1 : Writeln('One.');
      else
        Writeln('Wtf?');
      end;
    end.
    This:

    SCAR Code:
    program New;
    var
      v : variant;
    begin
      v := 'attack';
      v := lowercase(v);
      case v of
        'attack', 0 : Writeln('Zero.');
        'strength', 1 : Writeln('One.');
      else
        Writeln('Wtf?');
      end;
    end.
    lol

  7. #7
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm, my bad, numbers as strings don't error, but when you have characters/letters it does. I will find a workaround.
    SCAR Code:
    program New;

    var
      v : variant;

    begin
    v := 'one';
      if VarType(v) = 3 then
        v := IntToStr(v);
      v := lowercase(v);
      case v of
        '0', 'zero' : Writeln('Zero.');
        '1', 'one' : Writeln('One.');
      else
        Writeln('Wtf?');
      end;
    end.

    aha.
    Last edited by Da 0wner; 05-27-2009 at 09:03 PM.

  8. #8
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    function SetFightMode(oFightMode: Variant): Boolean;
    var
      i, x, y, r: Integer;
      b: TBox;
      cmbBoxes: array of TBox;
      strs: array of array of String;
    begin
      if not(Loggedin)then Exit;
      GameTab(1);
      Wait(200 + Random(777));

      cmbBoxes := [IntToBox(575, 255, 630, 290), IntToBox(660, 255, 710, 290), IntToBox(575, 310, 630, 345), IntToBox(660, 310, 710, 345)];
      strs := [TStringArray('attack', 'att'), TStringArray('strength', 'str'), TStringArray('controlled', 'control', 'ctrl', 'multi'), TStringArray('defence', 'def', 'defense')];
      try oFightMode := LowerCase(oFightMode); except end;
      case VarType(oFightMode) of
        3: begin b := cmbBoxs[oFightMode - 1]; r := oFightMode; end;
        256: for x := 0 to 3 do
             begin
               i := High(strs[x]);
               for y := 0 to i do
                 if oFightMode = strs[x][y] then
                 begin
                   b := cmbBoxes[x];
                   r := x + 1;
                   Break;
                 end;
               if b.x1 <> 0 then Break;
             end;
      end;
      i := 0;
      while (i < 4) and (not FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2)) do
      begin
        Mouse(RandomRange(b.x1, b.x2), RandomRange(b.y1, b.y2), 0, 0, True);
        Wait(200 + Random(300));
        Inc(i);
      end;
      Result := FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2);
      if (not Result) and (r = 4) then
        SetFightMode(3);
    end;

    I THINK I shortened it.

    e: Nope, but I made it accept several more options.
    Last edited by Nava2; 05-27-2009 at 09:03 PM.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  9. #9
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    O_O Nava, they are the same length XD.

    And Quickmarch, check the post I edited it.

  10. #10
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    SCAR Code:
    function SetFightMode(oFightMode: Variant): Boolean;
    var
      i, x, y, r: Integer;
      b: TBox;
      cmbBoxes: array of TBox;
      strs: array of array of String;
    begin
      if not(Loggedin)then Exit;
      GameTab(1);
      Wait(200 + Random(777));

      cmbBoxes := [IntToBox(575, 255, 630, 290), IntToBox(660, 255, 710, 290), IntToBox(575, 310, 630, 345), IntToBox(660, 310, 710, 345)];
      strs := [TStringArray('attack', 'att'), TStringArray('strength', 'str'), TStringArray('controlled', 'control', 'ctrl', 'multi'), TStringArray('defence', 'def', 'defense')];
      try oFightMode := LowerCase(oFightMode); except end;
      case VarType(oFightMode) of
        3: begin b := cmbBoxs[oFightMode - 1]; r := oFightMode; end;
        256: for x := 0 to 3 do
             begin
               i := High(strs[x]);
               for y := 0 to i do
                 if oFightMode = strs[x][y] then
                 begin
                   b := cmbBoxes[x];
                   r := x + 1;
                   Break;
                 end;
               if b.x1 <> 0 then Break;
             end;
      end;
      i := 0;
      while (i < 4) and (not FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2)) do
      begin
        Mouse(RandomRange(b.x1, b.x2), RandomRange(b.y1, b.y2), 0, 0, True);
        Wait(200 + Random(300));
        Inc(i);
      end;
      Result := FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2);
      if (not Result) and (r = 4) then
        SetFightMode(3);
    end;

    I THINK I shortened it.

    e: Nope, but I made it accept several more options.
    Maybe make this bit:
    SCAR Code:
    if oFightMode = strs[x][y] then

    to:

    SCAR Code:
    if oFightMode = Lowercase(strs[x][y]) then
    lol

  11. #11
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Quickmarch View Post
    Maybe make this bit:
    SCAR Code:
    if oFightMode = strs[x][y] then

    to:

    SCAR Code:
    if oFightMode = Lowercase(strs[x][y]) then
    If you check the arrays, they are already lowercase
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  12. #12
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    If you check the arrays, they are already lowercase
    Oh yeah.

    Also Da 0wner, yours still won't work because it only takes strings.

    EDIT: nvm yours does work and it does take ints.
    Last edited by Quickmarch; 05-27-2009 at 09:16 PM.
    lol

  13. #13
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mine does work. Test it.
    SCAR Code:
    function SetFightModeEx(oFightMode: Variant): Boolean;
    var
      x, y, t : Integer;
      Boxes : TBoxArray;
    begin
      if not(Loggedin)then Exit;
      GameTab(1);
      Wait(200 + Random(777));
      if VarType(oFightMode) = 3 then
        oFightMode := IntToStr(oFightMode);
      Boxes := [IntToBox(575, 255, 630, 290), IntToBox(660, 255, 710, 290),
                IntToBox(575, 310, 630, 345), IntToBox(660, 310, 710, 345)];
      case oFightMode of
        '1', 'attack', 'att' : begin end;// so doesn't cause problem with the else
        '2', 'strength', 'str' : Boxes[0] := Boxes[1];
        '3', 'multi' : Boxes[0] := Boxes[2];
        '4', 'defence', 'defense', 'def' : Boxes[0] := Boxes[3];
      else
        begin
           SRL_Warn('SetFightModeEx', 'oFightMode not set correctly!', warn_AllVersions);
          exit;
        end;
      end;
      result := FindColorTolerance(x, y, 1777020, Boxes[0].x1, Boxes[0].y1, Boxes[0].x2, Boxes[0].y2, 2);
      if not result then
      begin
         MouseBox(Boxes[0].x1, Boxes[0].y1, Boxes[0].x2, Boxes[0].y2, 1);
        result := true;
      end;
    end;
    Mine is the shortest, and includes an SRL_Warn .
    Last edited by Da 0wner; 05-27-2009 at 09:45 PM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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