Results 1 to 20 of 20

Thread: isAnimating not working ?

  1. #1
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default isAnimating not working ?

    Not sure if i'm doing something wrong, anyways, this is the code;
    Anyways the issue is that it'll keep clicking on the tree .. i have no ideas what to do or what i am doing wrong ..
    .. yeah .. i am new to Simba, started to attempt scripting like 2 days ago, any help is appreciated.



    Code:
    const
    CHOP_TREE = 0;
    
    procedure chopTree();
    var
      Tree: TReflectObject;
    begin
      while not myPlayer.IsAnimating do
        if Tree.Find(objGame, 'Tree', 16) then
      begin
      if Tree.IsOnMS then
      begin
      Reflect.Mouse.Move(Tree.GetMSPoint, 10, 10);
      if Reflect.Text.IsUpText('Chop down Tree') then
      Reflect.Mouse.Click(MOUSE_LEFT);
      end
      else
      begin
      rotateCameraToTile(Tree.GetTile);
      end;
      end;
    end;
    
    function GetState(): Integer;
    begin
      if ( Reflect.Inv.IsFull ) then
        // DO DROPPING HERE
      else if not myPlayer.IsAnimating then
        Exit(CHOP_TREE)
    end;
    
    procedure loopLogic();
    begin
      case (GetState()) of
        CHOP_TREE:
          chopTree();
      end;
    end; 
    
    begin
    repeat
    loopLogic();
    until (false)
    end.

  2. #2
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    My first question for you is, does this line

    if Tree.Find(objGame, 'Tree', 16) then


    click the tree?

  3. #3
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by rj View Post
    My first question for you is, does this line

    if Tree.Find(objGame, 'Tree', 16) then


    click the tree?
    if Tree.Find(objGame, 'Tree', 16) then
    begin
    if Tree.IsOnMS then
    begin
    Reflect.Mouse.Move(Tree.GetMSPoint, 10, 10);
    if Reflect.Text.IsUpText('Chop down Tree') then
    Reflect.Mouse.Click(MOUSE_LEFT);
    end
    else
    begin
    rotateCameraToTile(Tree.GetTile);
    end;
    end;
    This whole part does the clicking,
    and if Tree.Find(objGame, 'Tree', 16) then finds the tree.

  4. #4
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    This whole part does the clicking,
    and if Tree.Find(objGame, 'Tree', 16) then finds the tree.
    You should add a wait for it to start chopping

  5. #5
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by rj View Post
    You should add a wait for it to start chopping
    Care to write me an example and explain me why would i need to do it ?

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    Care to write me an example and explain me why would i need to do it ?

    Well when you click on the tree it's not like your character immediately starts animating does it? Well your script is programmed in a way to were it will click the tree and immediately wait for the player to animate. Of course it will click again.

    First I think choptree should be changed to a function called 'clickedTree'. It's confusing to add a check for the animation in the choptree procedure, it's out of place and confusing

    Simba Code:
    function clickedTree():boolean;
    var
      Tree: TReflectObject;
    begin
      if Tree.Find(objGame, 'Tree', 16) then
        if Tree.IsOnMS then
        begin
          Reflect.Mouse.Move(Tree.GetMSPoint, 10, 10);
          if Reflect.Text.IsUpText('Chop down Tree') then
          begin
            Reflect.Mouse.Click(MOUSE_LEFT);
            result := true; // since we clicked the tree the function returns true
          end;
        end else
          rotateCameraToTile(Tree.GetTile);
    end;

    What I did here was remove unnecessary begins/ends to make it easier to read. I also took out the animating check as that should be done elsewhere You don't need a begin/end block if you are only going to have '1 command' on the next line like right here:

    Simba Code:
    if Tree.Find(objGame, 'Tree', 16) then
        if Tree.IsOnMS then


    The place were you should do the animation check is in 'loopLogic'

    Simba Code:
    procedure loopLogic();
    begin
      case (GetState()) of
        CHOP_TREE:
          if foundTree() then
          begin
            wait(1500);
            if not myPlayer.IsAnimating then
            // code here whatever you want to do if the player isn't animating
          end;
      end;
    end;

    Now I don't know what you want to do with the loop logic I'll leave that up to you but the command for waiting is wait(timeinmilliseconds)

    There might even be a command for waiting for the player to animate you would have to ask @Kyle; I'm sure there is but I can't think of it off the top of me head

  7. #7
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by rj View Post
    Well when you click on the tree it's not like your character immediately starts animating does it? Well your script is programmed in a way to were it will click the tree and immediately wait for the player to animate. Of course it will click again.

    First I think choptree should be changed to a function called 'clickedTree'. It's confusing to add a check for the animation in the choptree procedure, it's out of place and confusing

    Simba Code:
    function clickedTree():boolean;
    var
      Tree: TReflectObject;
    begin
      if Tree.Find(objGame, 'Tree', 16) then
        if Tree.IsOnMS then
        begin
          Reflect.Mouse.Move(Tree.GetMSPoint, 10, 10);
          if Reflect.Text.IsUpText('Chop down Tree') then
          begin
            Reflect.Mouse.Click(MOUSE_LEFT);
            result := true; // since we clicked the tree the function returns true
          end;
        end else
          rotateCameraToTile(Tree.GetTile);
    end;

    What I did here was remove unnecessary begins/ends to make it easier to read. I also took out the animating check as that should be done elsewhere You don't need a begin/end block if you are only going to have '1 command' on the next line like right here:

    Simba Code:
    if Tree.Find(objGame, 'Tree', 16) then
        if Tree.IsOnMS then


    The place were you should do the animation check is in 'loopLogic'

    Simba Code:
    procedure loopLogic();
    begin
      case (GetState()) of
        CHOP_TREE:
          if foundTree() then
          begin
            wait(1500);
            if not myPlayer.IsAnimating then
            // code here whatever you want to do if the player isn't animating
          end;
      end;
    end;

    Now I don't know what you want to do with the loop logic I'll leave that up to you but the command for waiting is wait(timeinmilliseconds)

    There might even be a command for waiting for the player to animate you would have to ask @Kyle; I'm sure there is but I can't think of it off the top of me head
    Alright, thanks, makes alot sense now, also, i found this method;
    function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;
    Would this work as a conditional sleep ?

    EDIT:// I tried the logic but it still clicks on the tree even though player is animating .. is the logic wrong or isAnimating is not working ?
    Last edited by iJodix; 02-11-2016 at 07:26 PM.

  8. #8
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    Alright, thanks, makes alot sense now, also, i found this method;
    function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;
    Would this work as a conditional sleep ?
    Yes, I'm not sure if it will work with a type function like myPlayer.IsAnimating but I beleive there is something called waitTypeFunc

    Would be used like

    waitTypeFunc(@myPlayer.isAnimating, 50, 4000);

    This may be wrong, I haven't made a working script in a while so I'm not sure

  9. #9
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Still can't get it working, keeps clicking

  10. #10
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    Still can't get it working, keeps clicking
    Hmm try doing

    writeln(myPlayer.isAnimating()); while your player is animating and see if the animation function is working (maybe the hooks are outdated? I'm not sure but I don't want to blame it on this)

  11. #11
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by rj View Post
    Hmm try doing

    writeln(myPlayer.isAnimating()); while your player is animating and see if the animation function is working (maybe the hooks are outdated? I'm not sure but I don't want to blame it on this)
    did;
    Code:
    writeln(myPlayer.isAnimating());
    And it spams 'false' even though my player is animating, so i guess hooks are outdated ? if so, how do i report it to get it fixed ?

  12. #12
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    how do i report it to get it fixed ?


    You just did
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  13. #13
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    did;
    Code:
    writeln(myPlayer.isAnimating());
    And it spams 'false' even though my player is animating, so i guess hooks are outdated ? if so, how do i report it to get it fixed ?
    Hmm Maybe so I see Kyle is viewing this thread he may respond. Are you sure you have smart enabled when you check this?

    https://villavu.com/forum/forumdisplay.php?f=658

    All reflection hook announcements are there, they hooks may be outdated, not sure

  14. #14
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by rj View Post
    Hmm Maybe so I see Kyle is viewing this thread he may respond. Are you sure you have smart enabled when you check this?

    https://villavu.com/forum/forumdisplay.php?f=658

    All reflection hook announcements are there, they hooks may be outdated, not sure
    This is how my code looks; I am starting to think that i'm not activating smart here ?
    Code:
    begin
      initAL();
      Reflect.Setup;
      Me.Name := ''; //Username
      Me.Pass := '';  //Password
      Me.Pin := '';
      Me.Active := True;
      LoginPlayer(false);
      repeat
      begin
      if not myPlayer.IsLoggedIn then
          begin
          loginPlayer(False);
          myPlayer.Create;
        end;
          writeln(myPlayer.isAnimating());
      end;
      until (false);
    end.
    EDIT://
    Never mind, it took me a while to realize what you were asking, yes, i clicked on the tree myself then enabled Smart and it spammed false even though my player was animating
    Last edited by iJodix; 02-11-2016 at 09:17 PM.

  15. #15
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    This is how my code looks; I am starting to think that i'm not activating smart here ?
    Code:
    begin
      initAL();
      Reflect.Setup;
      Me.Name := ''; //Username
      Me.Pass := '';  //Password
      Me.Pin := '';
      Me.Active := True;
      LoginPlayer(false);
      repeat
      begin
      if not myPlayer.IsLoggedIn then
          begin
          loginPlayer(False);
          myPlayer.Create;
        end;
          writeln(myPlayer.isAnimating());
      end;
      until (false);
    end.
    EDIT://
    Never mind, it took me a while to realize what you were asking, yes, i clicked on the tree myself then enabled Smart and it spammed false even though my player was animating
    Is your zoom set to default? I haven't ran any scripts for about 10 hours - but I had no issues with it before then.

    Did you declare myPlayer as the TReflectPlayer (or whatever it is - this is just off the top of my head) as I don't see that in any of the other code.
    Last edited by Clutch; 02-11-2016 at 09:23 PM.

  16. #16
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    Is your zoom set to default? I haven't ran any scripts for about 10 hours - but I had no issues with it before then.
    Yup, zoom set to default.

    EDIT://
    I also tried;
    Code:
        if myPlayer.isMoving then
          writeln(myPlayer.isMoving());
    And it does return false even though i am moving while SMART is enabled
    Last edited by iJodix; 02-11-2016 at 09:31 PM.

  17. #17
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    Yup, zoom set to default.
    Well I'll be off work in about 3 and a half hours. I can help experiment with it then if you still don't have it figured out.

  18. #18
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    Well I'll be off work in about 3 and a half hours. I can help experiment with it then if you still don't have it figured out.
    Alright, much appericiated, please, if you have skype, pm me so i could add you!

  19. #19
    Join Date
    Nov 2014
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Got it working Thanks to Clutch, sorry if i mislead anyone.

  20. #20
    Join Date
    Jan 2014
    Posts
    51
    Mentioned
    5 Post(s)
    Quoted
    24 Post(s)

    Default

    Quote Originally Posted by iJodix View Post
    Got it working Thanks to Clutch, sorry if i mislead anyone.
    The IsAnimating general function normally doesn't work well for me well and neither does waitWhileAnimating. The Animating frame might only be at a certain point and if you miss it, your bot might think its not animating. I highly suggest using this method to check for animation.

    Simba Code:
    function IsDoingAction(): Boolean;
    var
      Timer: TReflectTimer;
      RandomTime: Integer;
    begin
      RandomTime := RandomRange(4800, 12000); // Change the interval to double how long one action takes (this was for looking a fish)
      Timer.Restart();
      while Timer.ElapsedTime() < RandomTime do
      begin
        if MyPlayer.IsAnimating() then
        begin
          Wait(100);
          Exit(True);
        end;
      end;
      Exit(False);
    end;

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
  •