-
Detect Worn Items of Other Players
@Fruity This helps me out so much!!! Thank you
-
Detect Worn Items of Other Players
Hello. I'm trying to write a fully functional cwars script, and have it actually defend the flag and run after players. I need it to read all the equipped items of nearby players into a list and iterate through until it finds the one holding the flag, it then needs to grab what gear they are wearing to attack using the combat triangle. I'm not quite sure how to read the gear of other players, because it's different than reading your own gear. I spent a lot of time reading the API, but can't find any way of possibly doing this. I was wondering if this is something that can be done with OSbots API and if anyone has any examples/hints of how to do this. What I'm trying to do is something like this, however this code is invalid and halts execution of the client.. for(final Player player : getPlayers().getAll()) { if(player.getMethods().getEquipment().getItemInSlot(EquipmentSlot.WEAPON.slot).getName().contains("flag")) { //interact and attack player } }
-
getHealthPercent()
Got everything working, not sure what the problem with the method to get percent hitpoints, but found that using the depricated methods works for my case. Are the depricated methods considered unsafe for bot detection or just aren't really used anymore? Nevertheless, the code I used is as follows.. while(!(starting_area.contains(myPlayer()))) { walkToStart(); if(gui.getFood() != null) inventory.getItem(new String(gui.getFood())).interact("Eat"); } private void walkToStart() throws InterruptedException { WebWalkEvent to_start = new WebWalkEvent(starting_area); to_start.setBreakCondition(new Condition() { @Override public boolean evaluate() { return (getHealthPercentB() <= 0.60); } }); getWalking().execute(to_start); }
-
getHealthPercent()
You're right. My fix helped fix the issue of when I was idle, my script would tell me that I was 100% hp, when I was not.
-
getHealthPercent()
Seems that I've found a current fix using deprecated methods, thanks for your help private double getHealthPercentB() { return (double)myPlayer().getCurrentHealth() / (double)myPlayer().getMaximumHealth(); } while(myPlayer().isMoving()) { if(getHealthPercentB() <= 0.6) { if(gui.getFood() != null) inventory.getItem(new String(gui.getFood())).interact("Eat"); } sleep(random(100, 200)); }
-
getHealthPercent()
I can try that, but I'm not sure why it would work if it does. log(myPlayer().getHealthPercent()) gives me an output of 100, so we would be sending into the if statement (false && true && true)
-
Kawaii_s changed their profile photo
-
getHealthPercent()
Hello, during deathwalking I am trying to enable eating in my script, the code is as follows... while(myPlayer().isMoving()) { if(myPlayer().getHealthPercent() < 60) { if(getFood() != null) inventory.getItem(new String(getFood())).interact("Eat"); } sleep(random(100, 200)); } This seems like it should work, but the problem is that it is never eating. I tried some basic debugging of the script and decided to log the output from the getHealthPercent function and it is always returning 100. When my hitpoints are 8/38 it says that my health percent is 100 and therefore does not eat.