Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
Sign in to follow this  
some0ne

Fighting algorithm

Recommended Posts

Hi, im new to the fighting algorithm here, but how this fighting algorithm should be done? 

- Problem: The bot doesnt recognize that the player is fighting and attacks next target straight away
Source code:

	public void execute() {		//TODO camera rotation		RSNPC[] npc = NPCs.sortByDistance(this.getMyPosition(), this.getFreeNPCS());		if(!Player.getRSPlayer().isInCombat() && !npc[0].isInCombat()) {			if(npc.length > 0) {				RSNPC target = npc[0];				target.setClickHeight(target.getHeight());				target.click("Attack");				General.sleep(900, 1300);			}		} else {			General.sleep(50,100);		}	}

Share this post


Link to post
Share on other sites

Set a time tracker if you successfully attack, check the time since last attack (safe is like 2-3 seconds, since you'll probably be in combat by then). You can also update that timer when you have the attack animation if you like.

 

/e note just a solution, there are many ways to accomplish what you are asking.

Edited by FALSkills

Share this post


Link to post
Share on other sites

- You are accessing npc[0] before checking the length of the array.

- isInCombat only returns true if you have a health bar above your head.

Some suggestions,

- get your player's interacting character and wait for it to be in combat

- use conditional sleeps rather than static sleeps

- NPCs.findNearest automatically sorts by distance from your player

- Check out the Clicking class and take note that the clicking methods return a boolean value

  • Like 1

Share this post


Link to post
Share on other sites

Set a time tracker if you successfully attack, check the time since last attack (safe is like 2-3 seconds, since you'll probably be in combat by then). You can also update that timer when you have the attack animation if you like.

 

/e note just a solution, there are many ways to accomplish what you are asking.

 

This. You may also want to wait until we have stopped moving if distance is greater than, say, 3 tiles.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By Mals
      Hi,
      I created my first Script which attacks the dummies in Varrock east. I decided to make this script because I needed it myself, and couldn't find it in the repository.
      It will walk to the dummies and start punching one until Attack reaches level 8.
      Repo link: https://tribot.org/repository/script/id/2430
      If you have any feedback or problems, please let me know!
      «MALS»
    • By picocode
      for fight cave and jad
    • By Soxs
      Quick-links: Repository URL.
       
      I've been out of the scripting scene for a very long time, I thought I'd ease back in by releasing some community scripts. I made this script because I didn't want to pay/didn't like what was readily available which did the same task.
       
      This script features:
        Clean, well-written code.   Anti-ban features that extend past of which the tribot client offers.   100% uses names, instead of ID's which makes it far less likely to break in the foreseeing future.   Eats any food.   Can use both north and south locations for training.  
       
      Upcoming:
        World-hopping   Potions   Special attacks   Bone burying  
       
      Screenshot:

    • By Bradsta
      Like this script?  Like this post!

       

      Version: v1.005

      Last Updated: April 4th, 2014

























       



      Intelligent combat algorithm



       

      Detecting closest target & target changes



       

      (-) Interactive UI & pop-out loot table

      (-) Pure friendly, and excellent training for low & even higher level accounts

      (-) Returns to fighting area if teleported by random & user has ring of dueling equipped.

      (-) Strength, Super strength, and Ranging potion support

      (-) Makes use of all 4 possible areas for warriors so player should never be wasting time waiting for respawns.  Will use left room, right room, centre lobby, and the throne room.

      (-) Excellent door handling, and target location system.  Will ensure player is in same area as the target before attempting

      to attack using a custom method to handle doors that may be in the way.

      (-) Fast response time between targets, re-attacking after eating

      (-) Randomized optional eating patterns.  Choose your base eating HP, then choose your +- offset

      that is changed each time a piece of food is eaten.

      (-) Optional looting for all  unidsabove a given price with zybez grabbing current prices to track your profit!


      All unids >= price you choose


       
      Access by clicking treasure chest on paint

       


      v1.005 - 04/04/2014 (-) Loot table has been changed slightly. I've added in % tracking for overall loots. I'd be real interested for you guys to loot all herbs over 10-12 hour period and post your loot table results. It will breakdown how much of a % each specific herb yielded over your total overall loot.
      v1.004 - 02/08/2014 (-) New UI, more options. (-) Option to loot bones added (-) Option to bury bones added [Must be looting bones also] Will bury if >= 5 bones in inventory. (-) Option to loot ammo added [Make SURE you have your equipment tab opened before setting up this otherwise name will return null](-) Multiple potion support added.  Regular attack & Super attack potions added to possible potions list. (-) You are now alloed 3 accounts per auth! Enjoy!
      v1.003 - 01/18/2014 (-) If you get teleported by a random, and end up to far away from the fighting spot, and have a ring of dueling equipped. It will teleport with the ring to duel arena, and walk back to the spot. v1.002 - 12/30/2013 (-) Edited how looting is handled should operate more smoothly now. (-) Changed walking for banking was having issues during the path to the bank causing it to run back to warrior area.
      v1.001 - 12/30/2013 (-) Fixed defence experience tracking. Spelling error on my part. (-) Looting has been modified to loot any unid above the given price in the GUI. Leave 0 to loot all.
      v1.000 - 12/29/2013 (-) Initial release

      FAQ

       

      Q: How many accounts is my auth code good for?

      A: Three RS accounts per purchase & 1 TRiBot at a time.

       

      Q: What if I'm getting the error maximum instances met?

      A: When occuring try waiting 5 minutes for the sessions to expire.  There could also be an issue with the

      repository which is out of my control, or your connection dropped.  This would be apparent for all script users though so you will know if this happens.

  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
      • 31 replies
    • Come give us feedback on the next version of TRiBot!
      • 74 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...