Jump to content

LifezHatred

Members
  • Posts

    423
  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by LifezHatred

  1. no feedback =[ tip on antileech (it is in the update method and has to do with creating an object if it doesn't exists)
  2. Made this a while ago and thought some people could make use of it What it does? Stores Data of Entities that are in combat or are initiating combat Uses this data to determine what to attack without any mistakes (Doesn't target any npcs already being attacked, or switches to a new target if another player reaches a npc before you. Also it targets npcs that target/attack you) Thought that this was a little bit more trustworthy than what the API provides and has many uses you can build into it (such as detecting players attacking you and other stuff) Also as fucked up as it sounds i plan to make a pking bot out of this system (Would rework some of the stuff in it) But anyways i am aware the code could be cleaned up a little bit but too lazy to go through it 3 classes, (or 2 classes and modify your main class) Main - (note have your loop set to 300 (runescape sends data to client every 600 ms, so having it at 300 ensures that no data is missed) package source; import org.osbot.script.Script; import org.osbot.script.ScriptManifest; @ScriptManifest(author = "Zach (LifezHatred)", info = "Combat info", name = "Combat", version = 1.0) public class Main extends Script { public Combat combat = new Combat(this); public int onLoop() { if(runCombatListener()) { combat.update(); } return 300; } public boolean runCombatListener() { return true; } } Combat Class (Factory) package source; import java.util.ArrayList; import java.util.List; import org.osbot.script.rs2.model.Character; import org.osbot.script.rs2.model.Entity; import org.osbot.script.rs2.model.NPC; import org.osbot.script.rs2.model.Player; public class Combat { public Main main; public List<CombatEntity> combatEntities; public Combat(Main main) { this.main = main; combatEntities = new ArrayList<CombatEntity>(); } public void update() { //Clean Up for(CombatEntity combat : combatEntities) { if(combat == null) { combatEntities.remove(combat); continue; } if(!combat.getEntity().exists()) { if(combat.hasAttacked) { CombatEntity cleanup = combat.getAttacking(); cleanup.attacker = null; if(cleanup.attacking == combat) { cleanup.setAttacking(null); cleanup.setHasAttacked(false); } } } } //add new entities for(NPC npc : main.client.getLocalNPCs()) { if(npc == null) { continue; } Entity facing = npc.getFacing(); if(facing != null) { if(!exists(npc)) { combatEntities.add(new CombatEntity(npc,facing)); } } else { if(exists(npc)) { CombatEntity remove = getCombatEntity(npc); combatEntities.remove(remove); } } } for(Player player : main.client.getLocalPlayers()) { if(player == null) { continue; } Entity facing = player.getFacing(); if(facing != null) { if(!exists(player)) { combatEntities.add(new CombatEntity(player,facing)); } } else { if(exists(player)) { CombatEntity remove = getCombatEntity(player); combatEntities.remove(remove); } } } //Updates state of the entities for(CombatEntity combat : combatEntities) { if(combat == null) { combatEntities.remove(combat); continue; } Entity facing = ((Character<?>) combat.getEntity()).getFacing(); if(combat.getFacing() != facing) { //switched to new target if(combat.getHasAttacked()) { CombatEntity entity = combat.getAttacking(); combat.setHasAttacked(false);//if switched to new target we do not know if he has fully attacked yet combat.setFacing(facing); entity.setAttacker(null); } } if(((Character<?>) combat.getEntity()).getAnimation() != -1) { //made a combat animation (if non combat animation has happened you would no longer be facing a target and wouldn't reach this point) combat.setHasAttacked(true); CombatEntity attacking = getCombatEntity(combat.getFacing()); attacking.setAttacker(combat); combat.setAttacking(attacking); } } } public boolean attack(int targetId) throws InterruptedException { Entity target = getClosestTarget(targetId); if(target == null) { return false; } target.interact("Attack"); return true; } public boolean attackRandomWithinDistance(int distance, int targetId) throws InterruptedException { Entity target = getRandomTarget(distance, targetId); if(target == null) { return false; } target.interact("Attack"); return true; } public boolean canAttack() { CombatEntity myPlayer = getCombatEntity(main.client.getMyPlayer()); if(myPlayer.isAttacking()) { return false; } if(myPlayer.getFacing() != null) { CombatEntity facing = getCombatEntity(myPlayer.getFacing()); if(facing.getAttacker() != myPlayer) { return true; } return false; } return true; } public Entity getRandomTarget(int targetId, int distance) { //will still return if being attacked by an aggressive npc CombatEntity myPlayer = getCombatEntity(main.client.getMyPlayer()); for(CombatEntity combat : combatEntities) { if(combat == null) { combatEntities.remove(combat); continue; } if(combat.getFacing() == main.client.getMyPlayer()) { if(combat.beingAttacked() && combat.getAttacker() != myPlayer) { continue; } return combat.getEntity(); //If being targetted by a npc in an aggressive area, checks if this npc is being attacked by another player } } List<NPC> attackables = new ArrayList<NPC>(); for(NPC npc : main.client.getLocalNPCs()) { if(npc == null) { continue; } if(npc.getId() != targetId) { continue; } if(exists(npc)) { CombatEntity combatEntity = getCombatEntity(npc); if(combatEntity.beingAttacked()) { continue; } } int distanceBetween = main.client.getMyPlayer().getPosition().distance(npc.getPosition()); if(distanceBetween < distance) { //checks if this entity is closer or not, if so sets it to the currently known closest npc attackables.add(npc); } } if(attackables.size() == 0) { return null; } NPC toReturn = attackables.get((int) (Math.random() * (attackables.size()-1))); return toReturn; } public Entity getClosestTarget(int targetId) { CombatEntity myPlayer = getCombatEntity(main.client.getMyPlayer()); for(CombatEntity combat : combatEntities) { if(combat == null) { combatEntities.remove(combat); continue; } if(combat.getFacing() == main.client.getMyPlayer()) { if(combat.beingAttacked() && combat.getAttacker() != myPlayer) { continue; } return combat.getEntity(); //If being targetted by a npc in an aggressive area, checks if this npc is being attacked by another player } } NPC closestAttackable = null; int distance = 20; //Max distance it'll attack (change if you want O.o) for(NPC npc : main.client.getLocalNPCs()) { if(npc == null) { continue; } if(npc.getId() != targetId) { continue; } if(exists(npc)) { CombatEntity combatEntity = getCombatEntity(npc); if(combatEntity.beingAttacked()) { continue; } } int distanceBetween = main.client.getMyPlayer().getPosition().distance(npc.getPosition()); if(distanceBetween < distance) { //checks if this entity is closer or not, if so sets it to the currently known closest npc closestAttackable = npc; distance = distanceBetween; } } return closestAttackable; //if returns null there is no npcs to attack O.o } public boolean exists(Entity entity) { for(CombatEntity check : combatEntities) { if(check == null) { combatEntities.remove(check); continue; } if(check.isEntity(entity)) { return true; } } return false; } public CombatEntity getCombatEntity(Entity entity) { for(CombatEntity check : combatEntities) { if(check == null) { combatEntities.remove(check); continue; } if(check.isEntity(entity)) { return check; } } return null; } } 3rd class CombatEntity (Object) package source; import org.osbot.script.rs2.model.Entity; public class CombatEntity { public Entity entity; public Entity facing; public boolean hasAttacked; public CombatEntity attacker = null; public CombatEntity attacking = null; public CombatEntity(Entity entity, Entity facing) { this.entity = entity; this.facing = facing; } public boolean isEntity(Entity entity) { if(this.entity == entity) { return true; } return false; } public boolean getHasAttacked() { return hasAttacked; } public void setHasAttacked(boolean bool) { hasAttacked = bool; } public Entity getEntity() { return entity; } public Entity getFacing() { return facing; } public void setFacing(Entity facing) { this.facing = facing; } public CombatEntity getAttacking() { return attacking; } public void setAttacking(CombatEntity entity) { attacking = entity; } public CombatEntity getAttacker() { return attacker; } public void setAttacker(CombatEntity attacker) { this.attacker = attacker; } public boolean beingAttacked() { if(attacker != null) { return true; } return false; } public boolean isAttacking() { if(attacking != null) { return true; } return false; } } To use this simply have this set to true when your bot is going to be entering combat public boolean runCombatListener() { if((methods to set true)) { return true; } return false; } And then for attacking, whatever system your using to perform actions use this to check if your character can attack canAttack() and if it can attack use these methods to attack an npc //note will always attack an npc attacking you even if its not the type of npc you declare in the npc id attackRandomWithinDistance(int distance, int targetId) or attack(int targetId) Good luck and have fun with making combat scripts with this code =D (note might remove for a little bit depending on some things) Also there is a small anti-leech (null pointer in there) simple fix
  3. Have GUI Finished thanks to Qbots XDruids should be finished by tomorrow and hopefully up in the sdn as soon as possible
  4. Updated the druid bot video, shows progress so far, how long it took to get one inventory full I got pathing about half way done so i did not include that in the video (I'm aware of 1 rare bug that surfaced during this vid)
  5. Yeah i'm aware, can you please stop posting on my threads? No. I have human rights. Doesn't mean you can do what you want, you still have to abide by the rules set by this website. (not implying that your necessarily breaking any)
  6. Yeah i'm aware, can you please stop posting on my threads?
  7. Progress on my druid bot (started about 2 hours ago haha) Fastest possible combat, attacks druids that attack you or the nearest druid that can be attacked Unique Pick up system, pick up herbs in a mass amount to speed up the amount of herbs you can get per hour Eating, Eats when your health falls below a certain percentage (randomly around that percentage) To-Do Paint Starting GUI Path from bank to Druids, supporting tele tabs or not Not bad for two hours in imo
  8. Wait let me smoke a blunt and come back in 20 minutes with an opinion...
  9. WHAT!!!!!!!!!!!!!!!!!!!!! HOW PLEASE TELL ME HOW mentally you duck... I wish those "Tuff" weed smokers gl with their focus in 20 years. idk i haven't noticed anything negative in 10 years of smoking it, but hey thats me not you
  10. Alright i'd thought i'll update this thread, haven't been able to start the project yet due to some irl things coming across, but anyways i'll let you know our current projects First 2 scripts planned to be released: -XRockCrab, Will support banking, fast and efficient rock crab killing, and some unique features -XDruids, Will Kill chaos druids and bank herbs, with a table to select which items to be picked up, will detect players attacking you and a very efficient attack/loot system Plan to release these in a week of them starting Still looking for someone who is experience in GUI design
  11. There is no possible way you can make a bot Wrong. Do you know how hard it is to make a bot? The coding required to make OSBot is insane. If he has no prior knowledge of coding, it will take him years to make a bot. this is not true i didnt know almost anything about scripting just 2 weeks ago and now im getitng ready to release my third script id say if your otivated go for it and if you need any help add me Script != Bot That's what I am saying :facepalm: he implies that he wants to make a script in his post who reads the posts? title says it all idk you've got me there
  12. There is no possible way you can make a bot Wrong. Do you know how hard it is to make a bot? The coding required to make OSBot is insane. If he has no prior knowledge of coding, it will take him years to make a bot. this is not true i didnt know almost anything about scripting just 2 weeks ago and now im getitng ready to release my third script id say if your otivated go for it and if you need any help add me Script != Bot That's what I am saying :facepalm: he implies that he wants to make a script in his post
  13. Why? Your code is 74 lines long (2.34 KB) -- most of which is redundant. Mine is 11 (522 bytes) and it draws pretty much the same conclusion (without walking handler). I'm not going to tell you how to program, but at least have consideration for possible improvements. because idc bout all that stuff? don't post on my thread anymore if all ur going to do is complain about what i do
  14. Ehh i guess, but i'd rather keep mine the way it is
  15. Simplified public void sleepCondition(boolean condition, int sleepTime) { while(condition) { sleep(sleepTime); } } Tho still wondering why you would need this
  16. A new class isn't needed... very inefficient and doesn't follow oop as for the doesnt follow loop part, it is only called from within the loop, so yeah it does follow the loop. Dumbass oop stands for Object-orientated programming, why don't you learn it? might aswell continue it here
  17. Np man, its less detectable because it uses a different path to that location every time (in my yew cutter i released it never runs the same path)
  18. ...Removing factual criticism. Sad. I'll post it again in short-form: If you've read the source for CowHideKiller or XYewCutter, you will know that those bolded keywords aren't reflected in either of his scripts. Dude don't post here... not going to say this again. Honestly neither of those scripts are a result of the project or are what that statement is directed towards.
  19. whateve free yew cutter if anyone wants it http://pastebin.com/Jp3xQgw4 cuts yews at catherby
  20. ight i'll add that to the list snape grass from that island?
  21. Lol dude i could have my account boosted to gold/plat for that price secondly it takes like a week to get an account to lvl 30
  22. XWoodCutter is moving along smoothly, Currently done Banks logs, moves to and from locations, detects randoms such as ents, axe head and nests current code length - 320 lines estimated final code length - 350-375 suppoorts catherby yews, cammy yews, cammy maples, draynor yews, draynor willows, and varrock yews working on adding more places, need a gui designer to help complete script
×
×
  • Create New...