dokato Posted June 25, 2015 Share Posted June 25, 2015 (edited) Ok, so I've tried out 100000 things to make my fighting scripts as good as possible but it still keeps dissapointing me. Currently I'm using this one, its an example that should kill chickens at the new chicken area in lumbridge: http://pastebin.com/xGX3bTfD And PLEASE, for those who have little to none expierence with fighting scripts, dont post obvious stuff like do this..., or you should better do that..., cuz the chance is big I've alrdy tried it lol. Or just dont post at all in that case. Just a call out for help to those who have expierence with this kind of stuff. Edited June 25, 2015 by dokato Quote Link to comment Share on other sites More sharing options...
Extreme Scripts Posted June 25, 2015 Share Posted June 25, 2015 Well firstly, you don't need to iterate the npc's in the region to get the best one you can just use filters for that and return the npc best suited based on the conditions you provide. 1) Get the instance of the NPC 2) Check if your player is interacting with it 3) If not attack if yes, sleep I would give you the code for it but then I don't think you would learn from it unless you familiarize yourself with the api by digging through it. Quote Link to comment Share on other sites More sharing options...
Botre Posted June 25, 2015 Share Posted June 25, 2015 It keeps disappointing you how exactly ? Quote Link to comment Share on other sites More sharing options...
dokato Posted June 25, 2015 Author Share Posted June 25, 2015 (edited) @Botre it will sometimes click on another chicken while he's alrdy in combat with a chicken, and sometimes while he's fighting a chicken, it will reclick on the chicken, while it is alrdy fighting it. And after it has killed the chicken, it will keep clicking on it till it completely dissapears (the animation of one dying and dissapearing). Well firstly, you don't need to iterate the npc's in the region to get the best one you can just use filters for that and return the npc best suited based on the conditions you provide. 1) Get the instance of the NPC 2) Check if your player is interacting with it 3) If not attack if yes, sleep I would give you the code for it but then I don't think you would learn from it unless you familiarize yourself with the api by digging through it. "1) Get the instance of the NPC" if i do that, and the chicken is alrdy under attack by someone else, it will do nothing and wait till it's dead, while it should be looking for another one to kill, that can be located a bit further than the one in the instance. So basically it is wasting time while he could be attacking another one. Or do you mean something else, or did i misunderstand u? Edited June 25, 2015 by dokato Quote Link to comment Share on other sites More sharing options...
Extreme Scripts Posted June 25, 2015 Share Posted June 25, 2015 (edited) @Botre it will sometimes click on another chicken while he's alrdy in combat with a chicken, and sometimes while he's fighting a chicken, it will reclick on the chicken, while it is alrdy fighting it. And after it has killed the chicken, it will keep clicking on it till it completely dissapears (the animation of one dying and dissapearing). "1) Get the instance of the NPC" if i do that, and the chicken is alrdy under attack by someone else, it will do nothing and wait till it's dead, while it should be looking for another one to kill, that can be located a bit further than the one in the instance. So basically it is wasting time while he could be attacking another one. Or do you mean something else, or did i misunderstand u? i meant use filters; NPC chicken = getNpcs().closest(new Filter<NPC>({ @Override public boolean match(NPC npc){ return npc.getName().equalsIgnoreCase("chicken") && !npc.isUnderAttack() && getMap().canReach(npc) && npc.getHealth() > 0; } }); Don't copy and paste cos I wrote that with no code assist so the filter could be wrong. This in essence will return the closest chicken that you can attack, is reachable, has health > 0, not currently being attacked. Of course you can tweak the boolean as you wish but that's all you need really. Much more efficient/cleaner/easy to read & understand Edited June 25, 2015 by Divinity 2 Quote Link to comment Share on other sites More sharing options...
Botre Posted June 25, 2015 Share Posted June 25, 2015 i meant use filters; NPC chicken = getNpcs().closest(new Filter<NPC>({ @Override public boolean match(NPC npc){ return npc.getName().equalsIgnoreCase("chicken") && !npc.isUnderAttack() && getMap().canReach(npc) && npc.getHealth() > 0; } }); Don't copy and paste cos I wrote that with no code assist so the filter could be wrong. This in essence will return the closest chicken that you can attack, is reachable, has health > 0, not currently being attacked. Of course you can tweak the boolean as you wish but that's all you need really. Much more efficient/cleaner/easy to read & understand Alek is going to kill you for not using a stream + lambda :x 2 Quote Link to comment Share on other sites More sharing options...
dokato Posted June 25, 2015 Author Share Posted June 25, 2015 i meant use filters; NPC chicken = getNpcs().closest(new Filter<NPC>({ @Override public boolean match(NPC npc){ return npc.getName().equalsIgnoreCase("chicken") && !npc.isUnderAttack() && getMap().canReach(npc) && npc.getHealth() > 0; } }); Don't copy and paste cos I wrote that with no code assist so the filter could be wrong. This in essence will return the closest chicken that you can attack, is reachable, has health > 0, not currently being attacked. Of course you can tweak the boolean as you wish but that's all you need really. Much more efficient/cleaner/easy to read & understand Wauw , didnt know that, thank you man!!! Quote Link to comment Share on other sites More sharing options...
Extreme Scripts Posted June 25, 2015 Share Posted June 25, 2015 Alek is going to kill you for not using a stream + lambda :x He's begginner, can't make him eat big macs when he's only ready for cheese burgers 2 Quote Link to comment Share on other sites More sharing options...