filestealer Posted August 14, 2013 Posted August 14, 2013 (edited) Anyone have a snippet to find an Ent (random wcing tree that damages your axe) and avoid it? I tried many different ideas of how to make this work, they never seemed to be successful. Any suggestions? EDIT: DUE TO A LAG, THIS WAS POSTED 3 TIMES. I APOLOGIZE. Edited August 14, 2013 by filestealer
Illumi Posted August 14, 2013 Posted August 14, 2013 (edited) if (!myPlayer().isAnimating() || (myPlayer().getFacing() != null && !myPlayer().isUnderAttack())) { } Just place your woodcutting method inside there. Edited August 14, 2013 by Illumi
Diclonius Posted August 14, 2013 Posted August 14, 2013 What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } 1
filestealer Posted August 14, 2013 Author Posted August 14, 2013 What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } Thanks
Illumi Posted August 14, 2013 Posted August 14, 2013 What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } The name does not change.
filestealer Posted August 14, 2013 Author Posted August 14, 2013 What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } Actually this did not work due to the fact that the name of the ent is the same as the tree.
filestealer Posted August 14, 2013 Author Posted August 14, 2013 if (!myPlayer().isAnimating() || (myPlayer().getFacing() != null && !myPlayer().isUnderAttack())) { } Just place your woodcutting method inside there. How would this fix the problem? The ent doesnt put you in combat. It just breaks your axe if you continue to try and chop it, and this does not identify if you are facing the ent or not.
Diclonius Posted August 14, 2013 Posted August 14, 2013 What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } Actually this did not work due to the fact that the name of the ent is the same as the tree. Okay well the ent is an NPC not an RSObject right? (yellow text instead of blue) so try: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Tree") && myPlayer().getFacing() instanceof NPC) ) { //chop a new tree } }
filestealer Posted August 14, 2013 Author Posted August 14, 2013 (edited) What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } Actually this did not work due to the fact that the name of the ent is the same as the tree. Okay well the ent is an NPC not an RSObject right? (yellow text instead of blue) so try: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Tree") && myPlayer().getFacing() instanceof NPC) ) { //chop a new tree } } The text becomes yellow whenever the tree becomes an ent using this code, i got an 2 errors NPC cannot be resolved to a type Incompatible conditional operand types Character<capture#3-of ?> Edited August 14, 2013 by filestealer
Diclonius Posted August 14, 2013 Posted August 14, 2013 What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } Actually this did not work due to the fact that the name of the ent is the same as the tree. Okay well the ent is an NPC not an RSObject right? (yellow text instead of blue) so try: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Tree") && myPlayer().getFacing() instanceof NPC) ) { //chop a new tree } } The text becomes yellow whenever the tree becomes an ent Then it is an NPC and the code I posted should work.
filestealer Posted August 14, 2013 Author Posted August 14, 2013 (edited) What is the name of the ent, is it "Ent"? Just do something like this: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Ent") { //chop a new tree } } Actually this did not work due to the fact that the name of the ent is the same as the tree. Okay well the ent is an NPC not an RSObject right? (yellow text instead of blue) so try: if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Tree") && myPlayer().getFacing() instanceof NPC) ) { //chop a new tree } } The text becomes yellow whenever the tree becomes an ent Then it is an NPC and the code I posted should work. using this code, i got an 2 errors NPC cannot be resolved to a type Incompatible conditional operand types Character<capture#3-of ?> I appreciate any help, I have been coding java for just over a year now, im just unfamiliar with osbot methods. I have coded about 12 basic scripts over the course of about 2 weeks of learning how to code on osbot. So any methods you can teach me to help figure this out would be very much appreciated. Edited August 14, 2013 by filestealer
Diclonius Posted August 14, 2013 Posted August 14, 2013 (edited) I did a bit of testing and it looks like the noun colour is the colour of the text and "<col=ffff00>" is the yellow colour and so we can use this to see if it is an NPC. if(myPlayer().getFacing() != null) { if(myPlayer().getFacing().getName().equals("Tree") && myPlayer().getFacing().nounColour().equals("<col=ffff00>")) { //chop a new tree } } Edited August 14, 2013 by Diclonius 2
filestealer Posted August 14, 2013 Author Posted August 14, 2013 Thank you so much for your help, I will monitor it and see how it works in the situation. I appreciate all your help.