Results 1 to 7 of 7

Thread: Help with my combat script

  1. #1
    Join Date
    Jan 2016
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default Help with my combat script

    Code:
    program BrainyChickenFighter;
    
    {$DEFINE SMART}
    {$i AeroLib/AeroLib.Simba}
    {$i reflection/Reflection.Simba}
    
    var
      MyPlayer: TReflectLocalPlayer;
    
    
    procedure FightChicken;
    var
      Point: TPoint;
      Chicken: TReflectNpc;
    begin
      while MyPlayer.GetInteractingIndex < 0 do
      begin
        if Chicken.Find('Chicken') then
        begin
          Point := Reflect.Tiles.TileToMS(Chicken.GetTile);
          HumanMMouse(Point, 2, 2);
          FastClick(MOUSE_LEFT);
          Wait(1500 + Random(100));
          while MyPlayer.IsMoving do
            Wait(50 + Random(100));
        end;
      end;
    end;
    
    begin
      InitAL;
      reflect.Setup;
      LoginPlayer(False);
      MyPlayer.Create;
      repeat
      begin
        FightChicken;
      end;
      until(false);
    end.
    Above is my very simple chicken fighter, ripped straight from one of the tutorials and updated to fit the latest API. Here are my questions:

    1. Are there working SRL docs? When I try to visit the page, it times out.
    2. How do I check that my character is in combat? Is there some code using animations? I can't access the documentation so I can't even help myself.
    3. How do I handle the annoying Level Up dialog?
    4. If the npc is moving, then my clicking will obviously not be able to keep up with the NPC's movement. Is there a better way to handle mouse movement and clicking?
    5. How do I handle accidental misclicks?
    6. With my current method, once my current chicken reaches 0 health, but has not disappeared off the screen yet, the script will select this already dead chicken as its new target and continue to spam click it until it disappears. Then it will choose an actually alive chicken. How do I fix this problem?

    My goal here before I start adding bone burial and antiban is for the script to be able to smoothly click once to attack a chicken, do nothing while in combat, then once the chicken reaches 0 health, immediately smoothly target and click to attack the next chicken without having to wait for the dead chicken to do its death animation.

  2. #2
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default HI

    1 - You are using the AeroLib and Reflection include - The reflection tutorials - https://villavu.com/forum/showthread.php?t=111665

    2 -

    Code:
    while reflectplayer.IsAnimating or reflectPlayer.IsMoving or  reflectplayer.IsUnderAttack do
    wait(100);
    end;
    This will return true and wait(100) if the player is moving,in-fight or animating

    3 - This code should click through the level up screen. There are other ways.

    Code:
     Reflect.Chat.NpcChooseOption('continue')
    4 -

    FFlag(0); is another command which will wait wait until the flag on the minimap is no longer present.

    5-

    You want to make missclicks? missmouse; (thought i am not even sure if this is needed? as reflection will miss; due the milliseconds delays between grabbing tiles and moving the mouse there; those dam chickens move around in between

    6 -

    If you you make a suitable wait timer with number (2) you should find 6 will be resolved.



    Let me know how you go.

    <------------------>



  3. #3
    Join Date
    Jan 2016
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by AFools View Post
    1 - You are using the AeroLib and Reflection include

    2 -

    Code:
    while reflectplayer.IsAnimating or reflectPlayer.IsMoving or  reflectplayer.IsUnderAttack do
    wait(100);
    end;
    This will return true and wait(100) if the player is moving,in-fight or animating

    3 - This code should click through the level up screen. There are other ways.

    Code:
     Reflect.Chat.NpcChooseOption('continue')
    4 -

    FFlag(0); is another command which will wait wait until the flag on the minimap is no longer present.

    5-

    You want to make missclicks? missmouse; (thought i am not even sure if this is needed? as reflection will miss; due the milliseconds delays between grabbing tiles and moving the mouse there; those dam chickens move around in between

    6 -

    If you you make a suitable wait timer with number (2) you should find 6 will be resolved.



    Let me know how you go.
    How do you click on a moving npc?

  4. #4
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    Quote Originally Posted by brainblips View Post
    How do you click on a moving npc?
    Does you attack function work correctly? If so it will work out which tile the npc is on an attack it; but if the npc moves in those split seconds.. then it will be slightly off. its not a problem.. more of an anti ban..

    <------------------>



  5. #5
    Join Date
    Jan 2016
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by AFools View Post
    Does you attack function work correctly? If so it will work out which tile the npc is on an attack it; but if the npc moves in those split seconds.. then it will be slightly off. its not a problem.. more of an anti ban..
    Code:
    program BrainyChickenFighter;
    
    {$DEFINE SMART}
    {$i AeroLib/AeroLib.Simba}
    {$i reflection/Reflection.Simba}
    
    var
      MyPlayer: TReflectLocalPlayer;
    
    
    procedure FightChicken;
    var
      Point: TPoint;
      Chicken: TReflectNpc;
    begin
      while MyPlayer.GetInteractingIndex < 0 do
      begin
        if Chicken.Find('Chicken') then
        begin
          Point := Reflect.Tiles.TileToMS(Chicken.GetTile);
          HumanMMouse(Point, 2, 2);
          FastClick(MOUSE_LEFT);
          Wait(1500 + Random(100));
          while MyPlayer.IsMoving or MyPlayer.IsAnimating or MyPlayer.IsUnderAttack do
            Wait(1500 + Random(100));
        end;
      end;
    end;
    
    begin
      InitAL;
      reflect.Setup;
      LoginPlayer(False);
      MyPlayer.Create;
      Writeln('script starting...');
      repeat
      begin
        if LevelUp() then
          Reflect.Chat.NpcChooseOption('continue');
        FightChicken;
      end;
      until(false);
    end.
    Any ideas why this script isn't doing anything now? I've used print statements to confirm that the script is reaching the inner loop in FightChicken, but for some reason the mouse isn't moving.

  6. #6
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    Quote Originally Posted by brainblips View Post
    ..........
    Flick me a PM; as i keep loosing the thread. I am just finishing off one of my projects and i then i can test yours.


    ********* Edit i suspect there may be an error in the last hooks update. As i cannot find any objects and most of my scripts are broken atm. Just wait patiently and everything should get fixed =D

    <------------------>



  7. #7
    Join Date
    Jan 2016
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by AFools View Post
    Flick me a PM; as i keep loosing the thread. I am just finishing off one of my projects and i then i can test yours.


    ********* Edit i suspect there may be an error in the last hooks update. As i cannot find any objects and most of my scripts are broken atm. Just wait patiently and everything should get fixed =D
    pm me when you think the hooks are fixed, and we'll talk more in private

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
  •