Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Player Health Listener

Featured Replies

Synopsis: I want to cut willows at Draynor, but that damn wizard keeps kicking my ass. 

How would I write a listener that keeps track of health and the minute the wizard starts attacking me, I can tell my player to move to a safespot.

 

EDIT: I just got an idea. Would it be wise to put it at the top of the states so it's the first thing that gets checked?

i.e.

 

public states getStates() {

if my player is being harassed by the dark mage { return run }

if blah blah blah { return chop }

if blah blue { return bank }

Edited by Noidlox

14 minutes ago, Noidlox said:

Synopsis: I want to cut willows at Draynor, but that damn wizard keeps kicking my ass. 

How would I write a listener that keeps track of health and the minute the wizard starts attacking me, I can tell my player to move to a safespot.

You could create a concurrent thread to track this kind of thing, but since your onLoop should be continuously looping anyway, and you don't need such a big degree of accuracy (oh, and it can be easy to implement new threads incorrectly), why not just put the check in your onLoop (or create a new state if you're using some kind of structure):

if (getSkills().getDynamic(Skill.HITPOINTS) < getSkills().getStatic(Skill.HITPOINTS)) {
  //We've lost some health - run!
}

You could use what Apaec wrote or you could even check if your player is in combat or under attack.

if (myPlayer().isUnderAttack() || getCombat().isFighting()) {
	//We are in combat, run
}

 

34 minutes ago, Apaec said:

You could create a concurrent thread to track this kind of thing, but since your onLoop should be continuously looping anyway, and you don't need such a big degree of accuracy (oh, and it can be easy to implement new threads incorrectly), why not just put the check in your onLoop (or create a new state if you're using some kind of structure):


if (getSkills().getDynamic(Skill.HITPOINTS) < getSkills().getStatic(Skill.HITPOINTS)) {
  //We've lost some health - run!
}

I totally forgot about the on-loop part lol. Thanks for that!

[I wish I could like your comment, but I've reached my threshold]

25 minutes ago, d0zza said:

You could use what Apaec wrote or you could even check if your player is in combat or under attack.


if (myPlayer().isUnderAttack() || getCombat().isFighting()) {
	//We are in combat, run
}

 

Gonna use isUnderAttack instead of HitVarVisible from now on. Ty for this!

[I wish I could like your comment, but I've reached my threshold]

Edited by Noidlox

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.