Krugiztar 0 Share Posted September 17, 2017 So I've been working on this combat script for a while, it works like charm and I decided to add a loot feature. The things is it keeps messing up alot. I tried making it attack then loot, but then it attacked and ran straight for a loot somewhere close. And i've tried a bunch of other things and this is what I want to do. Attack my NPC, WAIT until my npc is DEAD and then check for loot on those tiles that my enemy was standing at. Here are some things I have so far (I have some more but this will get you the gist of the script) NPC cows= getNpcs().closest("Cows"); Area fightingArea = new Area(cows.getTile()); if (cown.getInteractingCharacter() == null){ cown.interact("Attack"); sleepUntil(() -> getLocalPlayer().getInteractingCharacter() != null, 4253); } while (getLocalPlayer().getInteractingCharacter() != null){ sleepUntil(() -> cows.getInteractingCharacter() == null, 9000); } if (getLocalPlayer().getInteractingCharacter() != null){ if (fightingArea.contains(cowHides) || fightingArea.contains(bones) || fightingArea.contains(meat)) { cowHides.interact("Take"); sleepUntil(() -> getInventory().count("Cowhide") > InvCowHide, 5621); bones.interact("Take"); sleepUntil(() -> getInventory().count("Bones") > InvBones, 5621); beef.interact("Take"); sleepUntil(() -> getInventory().count("Raw beef") > invBeef, 5621); } } Do you guys see what the issue is? Never done a script like this before so thats why its confusing. Really appriciate all the help! Link to comment Share on other sites More sharing options...
Genius 49 Share Posted September 18, 2017 If you don't get any other help soon, PM me and I'd be happy to walk you through this. I spotted a couple issues with your code but I would write it much differently and don't want to blind side you with a wall of code Link to comment Share on other sites More sharing options...
332 1 Share Posted September 18, 2017 I'm learning too. But I think this is the reason your player runs away in combat. And the player should only loot when something is interacting with it. if (getLocalPlayer().getInteractingCharacter() != null){ if (fightingArea.contains(cowHides) || fightingArea.contains(bones) || fightingArea.contains(meat)) { cowHides.interact("Take"); sleepUntil(() -> getInventory().count("Cowhide") > InvCowHide, 5621); if (getLocalPlayer().getInteractingCharacter() != null) It will only loot if getLocalPlayer is interacting with something. If you made it if (getLocalPlayer().getInteractingCharacter() == null) I think it would work. Edited because I hit post too early. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.