May 28, 20178 yr 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 May 28, 20178 yr by Noidlox
May 28, 20178 yr 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! }
May 28, 20178 yr 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 }
May 28, 20178 yr 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 May 28, 20178 yr by Noidlox
Create an account or sign in to comment