Jump to content

Search the Community

Showing results for tags 'eating'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • TRiBot
    • News and Announcements
    • Old School Scripts
    • RS3 Scripts
    • Help and Guidance
    • Development
    • Bugs and Errors
    • Tutorials
    • TRiBot Script Repository
    • Purchase VIP
  • Scripters' Forums
    • Scripter Application
  • RuneScape®
    • General
    • Guides/Tutorials
    • Achievements
  • General
    • General
    • Questions
    • Discussions & Debates
    • Introductions
    • Suggestions
  • The Black Market
    • Disputes
    • Repository Credits
    • Gold Exchange
    • Item Exchange
    • Membership Sales
    • Services
  • Programming
    • Java
    • C/C++
    • Microsoft .NET
    • Web Development
    • General Programming
    • Game Development
  • Off Topic
    • Games
    • Graphics
    • Music and Television
    • Random
    • Computer Hardware
  • Body Building
    • Supplements
    • Exercises
    • Nutrition
    • Motivation
    • Losing Fat
    • Progress Pictures and Measurements

Found 2 results

  1. Open Guide: Combat Helper

    Notes: This is not exactly a guide as much as it is me sharing my experience and findings with various aspects of scripting for combat-related tasks. The format in which this guide is presented resembles that of a guide, and is why I have decided to share this under the Scripting Tutorials section. I intend for this to be useful to beginners who wish to quickly grasp the concept sand fundamentals of writing scripts which rely on combat-based functions and methods. Also, this was meant to be an open guide, in that all members feel free to add to it any information, corrections, or suggestions. Let us begin. Combat Helper - RS07 1. COMPOSITION My first attempt at a script that included combat was awful, to say the least. 5 months ago, January 2015, I wrote my first combat script while learning to program in Java (with 4 years prior C/C++ knowledge). The first thing I learned from my experience was to invest time into figuring out what you intend for your script to accomplish, and planning out important steps or "components" of the overall routine. Consider what you will need and what you wish to include in your script before beginning. Essentially, this should be the case for almost any script, not just combat. What will your program do? What will you need to make it do what you wish? How should it perform overall? Answering these questions ahead of time will save a lot confusion later and allow for some form of organization to be followed. Additionally, be considerate of the user even if that user is yourself. It is worthwhile to make scripts that are very presentable, have friendly-simple interfacing, have good modifiability and robustness. What might a combat script include? It may of course may entirely BLAH: 1. Banking 2. Looting 3. Attacking 4. Healing For simplicity and starting out, only what is necessary should be included. For example, a power-leveling bot would not need to incorporate a routine for looting. Though, it may be given the option to do so through design. Also, consider a bot which kills chickens for feathers. In this instance, it would be unnecessary to include a healing routine. A simple yet effective implementation for these components that works well for me is: private boolean stopScript;public void run() { // Run function of main program loop while(!stopScript) { // Boolean conditional for script bank(); // Check for banking. If so, perform it and travel. combat(); // Get in game NPC and pursue it. Heal if needed. loot(); // Pick items off the ground. }}public void combat() { // Combat function - integrates both attacking and healing /* attack and heal */} 1.1 Banking Banking is perhaps the simplest of the above fundamental combat script components. In many of my script applications, I have gotten away will writing a single function to perform the banking routine necessary for my task. private final RSTile myBank = new RSTile(1000, 1000, 0);private final RSTile mySpot = new RSTile(2000, 2000, 0);public void bank() { if(Inventory.isFull()) { // Is inventory full? banking = true; // If so, enable banking status (thread-safe) WebWalking.walkTo(myBank); // and run/walk to myBank. if(Banking.openBank()) { // Check if the bank account is open. Banking.depositAll(); // If so, deposit all inventory items sleep(400,800); // and perform short delay. WebWalking.walkTo(mySpot); // Walk back to desired location, my spot, banking = false; // and disable banking status. (thread-safe) } }}Other programs may not be as simple, requiring additional features and capabilities. Such features include dynamic clicking, sleeping, or waiting using time-based conditionals. /* This conditional statement dynamically waits for the bank screen to appear. */if(Timing.waitCondition(new Condition() { // If the wait condition returns true @Override // Allow process Override for conditional public boolean active() { // Condition function General.sleep(100); // Sleep every 0.1 seconds return Banking.isBankScreenOpen(); // Check: Is bank screen open? } }, 1000)) { // If Condition function returns true before time-out /* Perform banking actions here */}Most importantly from banking I have learned that it is extremely important to test the method for getting to the bank. Nothing is worse then having a bot that knows how to bank, but cannot properly get to the bank or travel back from the bank. The banking actions, if written and tested, should be rather straight forward and cooperative. 1.2 Looting In my experience, I have found it very useful to allow looting to be optional. This is done by simply designing a boolean control or state via enum property to govern the capability, and then implementing it as some form of user control. In this case, the shell design for the loot() function may look somewhat like: private boolean looting;public void loot() { if(looting) { /* Perform loot operations here */ }}In my opinion, looting is a bit more tricky then your typical banking routine. The difficulty in this is knowing when an enemy has been killed, and then waiting for the items to appear on the ground after completing their unique death animation. One simple way to do this is to manually determine the time it takes for the items to drop once detecting the NPC target's health to be zero. A routine for this might look like: private final int[] lootItems = { 100, 200, 300 }; // Array of item IDsprivate RSNPC monster; // Target monsterprivate boolean fighting; // Boolean combat conditionalprivate boolean looting; // Boolean loot conditionalpublic void loot() { if(looting) { if(monster != null) { // Check if NPC target is null. if(monster.getHealth() == 0) { // Is NPC target dead? sleep(3500); // Sleep for death animation. pickUp(lootItems); // Loot only items from loot array. monster = null; // Reset NPC target to no target. fighting = false; // Reset combat conditional to "out-of-combat" } } }}With this sleep function approach, the player is forced to wait out the death animation and allow the loot to appear. However, the pickUp() method is what's responsible for performing the actual looting action. An approach that has worked for me was: boolean pickUp(int[] ids) { if(ids != null) { // Check if loot ID array is null RSGroundItem item = findClosestItem(ids); // Get closest item if(item != null) { // If the item exist if(item.isOnScreen()) { // If the item is on the screen final int currentInventory = Inventory.getCount(ids); // Get number of inventory items for(int i = 0; i < 20; ++i) { Clicking.click("Take " + item.getDefinition().getName(), item); sleep(200,500); if(Inventory.getCount(ids) > currentInventory) // If item was picked up break; } return Inventory.getCount(ids) > currentInventory; // Return pick up status } else { WebWalking.walkTo(item.getPosition()); // If not on screen, walk to item pickUp(ids); // Recursive call: pick up item } } } return false;}RSGroundItem findClosestItem(int[] ids) { RSGroundItem[] items = GroundItems.find(ids); // Get items on ground int distance = 99999; // Initialize large distance RSGroundItem closest = null; // Initialize closest item DPathNavigator dNav = new DPathNavigator(); // Path object for(RSGroundItem iter : items) { int i; if(iter != null && (i = dNav.findPath(iter).length) < distance) { distance = i; // New closest distance closest = iter; // New closest item } } return closest;}Keep in mind that it is important for the primary combat sequence loop to be fast enough to detect when the health of the target reaches zero. There is of course only a limited amount of time for when the target's health will be equal to zero before it disappears. Other methods for looting may be as simple as clicking the item once it appears, and utilizing a boolean condition to flag if the item has or has not been successfully looted. A cowhide farming bot, for example, could make use of such a simple method because it is expected that a cowhide drops from each cow upon death. What you should employ depends on your script's needs and performance expectations. 1.3 Attacking The attacking routine has been the most challenging to pursue. I have learned that it requires more testing then any of the components, and deserves extremely careful design in order to be successful. There are several instances to consider when attacking a target. They include, multi-combat, retaliation, target switching, target validation. There will always be instances in which multi-combat may be present, retaliation is needed if being attacked, switching to another target if the target NPC is lost or stolen, and validating if a target is available for attack. But first, we will look at the basics for finding a potential target. A procedure that works well for me includes, finding a target in the area, getting the closest target, and then clicking on that target: private RSNPC monster;public void attack() { RSNPC npcs[] = NPCs.findNearest("Chicken"); // Get array of nearest NPCs if(npcs.length > 0) { // Did we get any NPCs nearby? target = npcs[0]; // The 0th NPC is the closest if(monster != null) { // Null check the RSNPC object // Click the target DynamicClicking.clickRSTile(monster.getAnimablePosition(), "Attack "+monster.getName()); } }}Though the process is simple, there are immediately problems with this short snippet of code. Firstly, how do we know if nearest target is even on the screen to be clicked? Also, we do not know if the target is valid for combat. Is it already being attacked or busy with some sort of other action? Lastly, how is it known if the user has finally started attacking the target and can top clicking it? A revised and more promising routine might be: private RSNPC monster;public void attack() { if(!fighting) { // Boolean condition for combat RSNPC npcs[] = NPCs.findNearest("Chicken"); // Get array of nearest NPCs if(npcs.length > 0) { // Did we get any NPCs nearby? for(RSNPC npc : npcs) { // Iterate through all NPCs // Check if NPC is available if(!npc.isInCombat() && !npc.isInteractingWithMe() && npc.isValid())) { monster = npc; // Set target } } if(monster != null) { // Null check the RSNPC object if(!monster.isOnScreen()) { // Is monster on screen? int rand = 1 + General.random(1, 99); // Get a random number between 1-100 if(rand > 50) { Camera.turnToTile(monster.getPosition()); // Turn to the target's tile } else { WebWalking.walkTo(monster.getAnimablePosition()); // Walk to the target's tile } } for(int i = 0; i < 20; ++i) { // Attempt a max of 20 clicks // If target and player in combat if(npc.isInCombat() || Combat.isUnderAttack() || (Combat.getAttackingEntities.length > 0)) { break; } // Click the target DynamicClicking.clickRSTile(monster.getAnimablePosition(),"Attack "+monster.getName()); sleep(200,500); // Short delay } // Player is engaged in combat if(Combat.isUnderAttack() || (Combat.getAttackingEntities.length > 0)) { fighting = true; // Toggle fighting, stop searching for a target } } } }}Though this snippet may not work for certain instance of combat, it is useful to show what kind of necessary checks and procedures should be considered when trying to attack a target. In my applications, this snippet of code has been enough for me to accomplish what I need. Additional code that is necessary to include are checks for in-combat instances. What if the user is being attacked but not attacking or if the NPC is somehow lost or stolen? Here is one way I have addressed this problem: private RSNPC monster;private boolean fighting;public void inFight() { // Can be included in attack() if(fighting) { // Boolean condition for combat RSPlayer player = Player.getRSPlayer(); // Get user object info if(player != null) { // Null check RSPlayer object RSCharacter target = player.getInteractingCharacter(); // Get the user's actual target if(target == null) { // If actual target is null monster = getInterractingNPC(); // Set target to attacking NPC if(monster != null) { // If an attacking target exists monster.click(); // Click the new attacking target sleep(250, 400); // Short delay } else { // If no attacking target present fighting = false; // There is no fight, toggle off } } } }}A few necessary states and conditions that I would like to share regarding combat are below. I found that much of the methods in the API did not accomplish what was expected. These methods I have defined offer a little bit more of a literal meaning to their actions. /* Check if the player is in combat */boolean playerInCombat() { return Combat.getAttackingEntities().length > 0;}/* Check if the player is attacking a target */boolean playerIsAttacking() { return Combat.isUnderAttack();}/* Check if the target is attacking the user */boolean targetIsAttackingMe(RSNPC target) { return target.isInCombat() && target.isInteractingWithMe();}​/* Check if the target is in combat, but not attacking the user */boolean targetNotAttackingMe(RSNPC target) { return target.isInCombat() && !target.isInteractingWithMe();}​/* Check if the target engaged with the user but not attacking (stuck behind something or walking toward user) */boolean targetEngagedWithMe(RSNPC target) { return !target.isInCombat() && target.isInteractingWithMe();}​/* Check if the target is not in combat and not interacting with user (free to engage) */boolean targetIsNotEngaged(RSNPC target) { return !target.isInCombat() && !target.isInteractingWithMe();}​/* Check if the user is in combat and not attacking a target */boolean playerInCombatAndNotAttacking() { return Combat.getAttackingEntities().length > 0 && !Combat.isUnderAttack();}​/* Check if the user is attacking a target and not being attacked */boolean playerAttackingAndNotAttacked() { return Combat.getAttackingEntities().length < 1 && Combat.isUnderAttack();}​/* Check if the target has died */boolean targetIsDead(RSNPC target) { return target.getHealth() == 0;} 1.4 Healing Healing is an integral part of many combat scripts. Essentially, healing in/out of combat requires a few steps: checking for food in the inventory (and bank), eating below a certain health level or percentage, executing the click-to-eat process. Most times, healing methods will need to be implemented in with the attacking methods of a combat script. In this case it is necessary to combine methods or designate an individual thread for healing. In implementation, I prefer to check if the health value is below a certain point before checking for available food in the user's inventory. The user is to flee combat in the case that there is no food and the health falls below the observed percentage. In all other cases, the user may continue to fight. Another important consideration is with banking and food supplies. I've found it best to end the script when the user runs out of the selected food supply. If both the bank and inventory has no supply of the desired food, then log out and kill the program. A simple example of a healing method would be: private final int[] foodToEat = { 100, 200, 300 }; // Food array for eatingprivate final int timeToEat = 1900; // Rounded-up time to eatprivate final int minHealth = 10; // Eat at or below this healthpublic void heal() { // While current HP <= minHealth and food exists while((Combat.getHP() < (minHealth+1)) && foodExists()) eat(); // Eat food}public boolean eat() { RSItem[] food = Inventory.find(foodToEat); // Get food in inventory final int currHP = Combat.getHP(); // Get current HP level if(food.length > 0) { // Check if food was found if(food[0] != null) { // Check if first food is null if(Clicking.click("Eat", food[0])) { // Click to eat food return Timing.waitCondition(new Condition() { // Conditional for eating action @Override public boolean active() { // True when finished eating return Combat.getHP() > currHP; // Return health change status } }, timeToEat); // If Condition function returns true before time-out } } } return false; // Didn't complete eating sequence}public boolean foodExists() { return Inventory.find(foodToEat).length > 0; // Return inventory food quantity}Such a method might be included using a thread or be directly implemented into the combat method. Either method works well unless the thread actions are unsafe (via design) or the time to loop through the entire combat sequence is too long and slow (again, via design). For example, the direct combat implementation from section 1.3 would look like: private RSNPC monster;private boolean fighting;public void inFight() { // Can be included in attack() if(fighting) { // Boolean condition for combat heal(); /* Implement heal() here */ RSPlayer player = Player.getRSPlayer(); // Get user object info if(player != null) { // Null check RSPlayer object RSCharacter target = player.getInteractingCharacter(); // Get the user's actual target if(target == null) { // If actual target is null monster = getInterractingNPC(); // Set target to attacking NPC if(monster != null) { // If an attacking target exists monster.click(); // Click the new attacking target sleep(250, 400); // Short delay } else { // If no attacking target present fighting = false; // There is no fight, toggle off } } } }}This implementation would make the overall design flow as: private boolean stopScript;public void run() { // Run function of main program loop while(!stopScript) { // Boolean conditional for script bank(); combat(); loot(); }}public void combat() { attack(); inFight();}Another task-based design could be to implement each of the discussed four components directly in order. Fighting cows, goblins, men/women, and rats may allow for such implementation as they may rarely require healing. private boolean stopScript;public void run() { // Run function of main program loop while(!stopScript) { // Boolean conditional for script bank(); attack(); // Incorporates our inFight() method loot(); heal(); }} Closing Remarks: These are methods which I have experience, learned, and followed myself. I do not take credit for creating or inventing all of the content presented in this forum thread. It is intended to represent my experience and learned lessons, and for me to share the collection of knowledge I have gained in regards to combat-based scripts and tasks. Feel free to append to this information or offer additional insightful information for our reading audience. Thank you.
  2. Repository link JJ's Fighter Pro is an AIO Fighter script: it can kill any monster that you want. You can also make a list of items to loot and select the food you want to eat. You can drink potions if needed, pick up and alch certain items, use special attacks, prioritize looting, etc. This is all configurable through the GUI. You can save your settings for future usage. Anti Ban Compliance implementation ABCL 10 has been implemented. Screenshots Statistics JJ's Fighter needs an internet connection to send script statistics to my server. The data is anonymous and you can check what it sends in bot debug. Example chart from 15/10/2013 Features Melee, range, mage support Eating Looting Banking Bones to peaches XP checking Fast monster switching Dynamic mainloop Setting loading/saving Changelog
×