Mokrocaan Posted September 15, 2020 Share Posted September 15, 2020 I have read alot of other scripts and examples of how to loot before attacking again. I cannot understand this concept, could somebody explain me how to do this inside of my own code. This is my code for now: =============================================================================================== NPC npc = getNpcs().closest(o -> o.getName().equals("Cow") && o.getInteracting() == null && !o.isUnderAttack()); if (npc != null && npc.getName().equals("Cow") && npc.getHealthPercent() > 0 && npc.isAttackable() && npc.hasAction("Attack") && map.canReach(npc) && !npc.isUnderAttack()) { if (npc.equals(myPlayer().getInteracting())) { } else { npc.interact("Attack"); if (npc.interact("Attack")) { sleep(random(3500,5000)); } } } else { camera.toEntity(npc); npc = npcs.closest("Cow"); } ================================================================================================== Quote Link to comment Share on other sites More sharing options...
Nbacon Posted September 15, 2020 Share Posted September 15, 2020 (edited) if( Im not in combat ){ if(is there loot on the ground? ){ pick up the loot... }else{ atttack some npc... } } Edited September 15, 2020 by Nbacon 1 Quote Link to comment Share on other sites More sharing options...
Gunman Posted September 15, 2020 Share Posted September 15, 2020 @Mokrocaan You can do what Nbacon did if you don't care about picking up other peoples loot they left. But if you want to only pick up your loot, then store the tile the npc health percent == 0 is and then check that tile is != null and if it contains items you want to loot, loot. Else make the tile == null so it can attack another monster. Can look something like this. Also if you haven't look into conditional sleeps. if (lootTile != null) { if (items I want exist at tile) { loot the tile } else { lootTile == null; } } else { find and attack the next monster } 1 1 Quote Link to comment Share on other sites More sharing options...
Mokrocaan Posted September 15, 2020 Author Share Posted September 15, 2020 (edited) @Gunman I am going to try this out. Do you mean that I have to store the position of the NPC when he is at 0 healthPercent? Like this: If ( monster.healthPercent() == 0 ) { Position lootTile = monster.getPosition(); } Edited September 15, 2020 by Mokrocaan Quote Link to comment Share on other sites More sharing options...
Mokrocaan Posted September 15, 2020 Author Share Posted September 15, 2020 @Nbacon Thankyou so much. The only problem im facing right now is that he doesnt loot the NPC I directly killed. It loots other peoples stuff or it loots my previous kill. Quote Link to comment Share on other sites More sharing options...
Gunman Posted September 15, 2020 Share Posted September 15, 2020 (edited) 36 minutes ago, Mokrocaan said: @Gunman I am going to try this out. Do you mean that I have to store the position of the NPC when he is at 0 healthPercent? Like this: If ( monster.healthPercent() == 0 ) { Position lootTile = monster.getPosition(); } Yes right before he disappears, then you will probably have to wait about 3 seconds for the loot to spawn before checking the tile. EDIT: You may find something useful in this video; It has no looting but it involves combat and may be useful to you. Edited September 15, 2020 by Gunman 1 Quote Link to comment Share on other sites More sharing options...
Nbacon Posted September 15, 2020 Share Posted September 15, 2020 This is my supppppppppppppppppppper generic combat code I made almost a full slayer bot out it and it suports Ironman looting. Its writen in kotlin... but it still compiles and runs. http://www.mediafire.com/file/6drc4vhydvbpyhv/methods.zip/file Hope you can find some usefull in it. 1 Quote Link to comment Share on other sites More sharing options...
Mokrocaan Posted September 15, 2020 Author Share Posted September 15, 2020 Thankyou brother! Every bit of information helps Quote Link to comment Share on other sites More sharing options...