Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • AIO Fighter [Open Source] [Community Driven] [Documented]


    wesrsmith

    Recommended Posts

    I was checking out your code and I saw that you needed food ids, I had all the fish ids laying around so here they are :) 

    private static Integer[] LIST_OF_FOOD = {315, 319, 325, 329, 333, 337, 339, 347, 351, 355, 361, 365, 373, 379, 385, 391, 397, 3144, 7946, 11936, 13441};

    It's from Shrimp to Anglerfish.

    Link to comment
    Share on other sites

    59 minutes ago, Milasoft said:

    I was checking out your code and I saw that you needed food ids, I had all the fish ids laying around so here they are :) 

    
    private static Integer[] LIST_OF_FOOD = {315, 319, 325, 329, 333, 337, 339, 347, 351, 355, 361, 365, 373, 379, 385, 391, 397, 3144, 7946, 11936, 13441};

    It's from Shrimp to Anglerfish.

    I really appreciate that :) Ill add it soon!

    Link to comment
    Share on other sites

    • 2 weeks later...

    I want to do two things quickly

    1. Check if item is a food or other consumable
      - achieved by membership in the hash map
    2. Find out how much it heals
      - achieved by reading value stored in hashmap

    This allows me to do both in roughly the same place. I could also change the hash map to store some more information about the food like name, Total Health Restored, Next Eat Heal (for things like cakes, pizzas, pies)

    Link to comment
    Share on other sites

    Had trouble with git - didn't want to make a new account. I'll work on polishing up my utility library and getting it up on github so you can use it.

    PM me your discord name if you want updates/to talk off the forums.

    Link to comment
    Share on other sites

    I think 2 int arrays or 2D arrays is technically faster. If i recall correctly Hashmaps use arrays under the hood anyways so you can get rid of performance overhead by correctly using indexed int arrays instead. But its likely not a noticeable difference anyways. In any sense it is a great utility that would be greatly useful in the script. Ill pm you my discord soon.

    Link to comment
    Share on other sites

    On 7/25/2018 at 2:52 PM, FissionChips said:

    I want to do two things quickly

    1. Check if item is a food or other consumable
      - achieved by membership in the hash map
    2. Find out how much it heals
      - achieved by reading value stored in hashmap

    This allows me to do both in roughly the same place. I could also change the hash map to store some more information about the food like name, Total Health Restored, Next Eat Heal (for things like cakes, pizzas, pies)

    Why not use an Enum?

    Link to comment
    Share on other sites

    package io.articron.cronabyss.fw.consume;
    
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.skills.Skill;
    import org.dreambot.api.methods.skills.Skills;
    
    import java.util.Arrays;
    import java.util.Optional;
    
    public enum Edible {
    
        SHRIMP(3.0, 315),
        COOKED_CHICKEN(3.0, 2140),
        SARDINE(3.0, 325),
        COOKED_MEAT(3.0, 2142),
        BREAD(5.0, 2309),
        HERRING(5.0, 347),
        MACKEREL(6.0, 355),
        TROUT(7.0, 333),
        COD(7.0, 339),
        PIKE(8.0, 351),
        ROAST_BEAST_MEAT(8.0, 9988),
        PINEAPPLE_PUNCH(9.0, 2048),
        SALMON(9.0, 329),
        TUNA(10.0, 361),
        JUG_OF_WINE(11.0, 1993),
        RAINBOW_FISH(11.0, 10136),
        STEW(11.0, 2003),
        CAKE(4.0, 1891),
        MEAT_PIE(6.0, 2327),
        LOBSTER(12.0, 379),
        BASS(13.0, 365),
        PLAIN_PIZZA(7.0, 2289),
        SWORDFISH(14.0, 373),
        POTATO_WITH_BUTTER(14.0, 6703),
        CHOCOLATE_CAKE(5.0, 1897),
        TANGLED_TOADS_LEGS(15.0, 2187),
        POTATO_WITH_CHEESE(16.0, 6705),
        MEAT_PIZZA(8.0, 2293),
        MONKFISH(16.0, 7946),
        ANCHOVY_PIZZA(9.0, 2297),
        COOKED_KARAMBWAN(18.0, 3144),
        CURRY(19.0, 2011),
        UGTHANKI_KEBAB(19.0, 1885),
        MUSHROOM_POTATO(20.0, 7058),
        SHARK(20.0, 385),
        SEA_TURTLE(21.0, 397),
        PINEAPPLE_PIZZA(11.0, 2301),
        MANTA_RAY(22.0, 391),
        TUNA_POTATO(22.0, 7060),
        DARK_CRAB(22.0, 11936),
        ANGLERFISH(22.0, 13441);
    
        private double heal;
        private int id;
    
        Edible(double heal, int id) {
            this.heal = heal;
            this.id = id;
        }
    
        public double getHeal() {
            return heal;
        }
    
        public int getId() {
            return id;
        }
    
        public static int required(Edible edible, Skills skills) {
            return (int) Math.ceil((skills.getRealLevel(Skill.HITPOINTS) - skills.getBoostedLevels(Skill.HITPOINTS)) / edible.getHeal());
        }
    
        public static Optional<Edible> find(int id) {
            return Arrays.stream(Edible.values()).filter(edible -> edible.getId() == id).findAny();
        }
    
        public static boolean hasEdible(Inventory inventory) {
            for (Edible edible : Edible.values()) {
                if (inventory.contains(edible.toString())) {
                    return true;
                }
            }
            return false;
        }
    
        public static Edible getFood(Inventory inventory) {
            for (Edible edible : Edible.values()) {
                if (inventory.contains(edible.toString())) {
                    return edible;
                }
            }
            return null;
        }
    
        @Override
            public String toString() {
                char[] name = this.name().toCharArray();
                for (int i = 2; i < name.length + 1; i++) {
                    int position = i - 1;
                    char previous = name[position - 1];
                    if (previous != 95) {
                        name[position] = Character.toLowerCase(name[position]);
                    } else {
                        name[position - 1] = (char) 32;
                    }
                }
                return new String(name);
        }
    }

    Maybe this is handy for you. An enum with all foods :)

    Link to comment
    Share on other sites

    Thanks Arti! Good thing I didnt put much time into food cuz yall got it taken care of! Ill implement this into the script this weekend.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.