Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Need help on basic combat script


    AsBakedAsCake

    Recommended Posts

    I finally got some spare time again and decided I would try to make another tiny script, anyways..

     

    I have two problems with this: https://pastebin.com/nN7XZ70z

     

    #1: It still tries to attack seagulls that are already in combat. (I tried checking for the health bar but maybe I did this incorrectly?)

     

    #2: Every time it levels up and the seagull moves away, it stops attacking.

     

    I followed Rickk's tutorial to make the script, I'm almost certain I followed it 100%.

     

    Can someone point out what I need to add/did wrong here?

     

    Thanks

     

     

     

     

    Link to comment
    Share on other sites

    You may want to add a check on the NPC's combat status in the filter. Or to be even more stringent, you may add something along the lines of the npc not being interacted with by any other players to your filter instead.

     

    I believe that the isInCombat method returns true only if both Characters are interacting with eachother.

     

    As for the level up issue, why not check for dialogue and either continue it or attack the seagull again if dialogue is present.

     

    Mind you, the framework and general structure of your script isn't particularly favored, but those should fix up your issues without you having to change things around too much. I would recommend you look at either implementing states and a switch statement that allows you to easily read what you're doing if you want to keep it in the same AbstractScript framework, or investigate the TaskScript framework, which should make everything much nicer overall. @iamreyne had a great example of a taskscript framework on one of his local scripts if I remember correctly.

    Link to comment
    Share on other sites

     

     

    #1: It still tries to attack seagulls that are already in combat. (I tried checking for the health bar but maybe I did this incorrectly?)

     

    #2: Every time it levels up and the seagull moves away, it stops attacking.

     

    1) Try checking for npc.getInteractingCharacter = null instead of checking for health bar, that may possibly fix that issue. I'm unaware of how IsInCombat returns if you check for that.

     

    2) This is something that just happens with level up message. You're referring to the seagull retreating once it gets low hp yes? Unless seagull is attacking you, the level up message will always interrupt combat.

    Could have it check for if it canContinue, then clickContinue and re-attack the seagull. Unless clicking continue resumes combat, you'd have to check that  :(

    Link to comment
    Share on other sites

    You may want to add a check on the NPC's combat status in the filter. Or to be even more stringent, you may add something along the lines of the npc not being interacted with by any other players to your filter instead.

     

    I believe that the isInCombat method returns true only if both Characters are interacting with eachother.

     

    As for the level up issue, why not check for dialogue and either continue it or attack the seagull again if dialogue is present.

     

    Mind you, the framework and general structure of your script isn't particularly favored, but those should fix up your issues without you having to change things around too much. I would recommend you look at either implementing states and a switch statement that allows you to easily read what you're doing if you want to keep it in the same AbstractScript framework, or investigate the TaskScript framework, which should make everything much nicer overall. @iamreyne had a great example of a taskscript framework on one of his local scripts if I remember correctly.

     

    1) Try checking for npc.getInteractingCharacter = null instead of checking for health bar, that may possibly fix that issue. I'm unaware of how IsInCombat returns if you check for that.

     

    2) This is something that just happens with level up message. You're referring to the seagull retreating once it gets low hp yes? Unless seagull is attacking you, the level up message will always interrupt combat.

    Could have it check for if it canContinue, then clickContinue and re-attack the seagull. Unless clicking continue resumes combat, you'd have to check that  :(

    Thanks for the replies boys, I'll get back on it tomorrow. Clicking to continue does resume combat. (My main problem was that if it this happened it will just afk until that seagull is dead or it logs out.) Yes I was referring to the seagull retreating when its about to die :P I'll try some of the suggestions above either tn or tomorrow when I feel like frustrating myself a little more :D

     

    I'll be damned if I cant complete a simple script.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.