Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question How can i determine the type of equipment worn? (Melee, ranged, magic)

Joined
Aug 28, 2017
Messages
8
I'm trying to have my bot change it's gear based on whether it should be using magic, ranged, or melee combat style.
I can't find anywhere in Item, Items, or ItemDefinition classes where the TYPE of the equipment is stored.

Does anyone have any ideas on how to go about doing this?
 
Joined
Nov 18, 2013
Messages
126
If regarding RS3 you could check to see which of the abilities "Slice", "Wrack", or "Piercing Shot" are able to be activated. No clue on 07 though, sorry.

edit - Guess this could only check for weapons.. You could see if the equipment name contains common words for different styles.. "platebody" "chaps" "robe" ?
 
Joined
Aug 28, 2017
Messages
8
it's for RS3.

I considered doing a hard check of the name. as you said. Just wondered if there was a quicker way using API

I also considered just making big lists of all the melee/ranged/mage armor and dong a contains() on them.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
Item definitions have so called "attributes", which hold information about the special attack, damage, and also the attack style. It could be a bit tricky to figure out which exact attribute of an item informs you about the style, but it's there.
 
Joined
Aug 28, 2017
Messages
8
yeah i had dug into the attributes for items but they are all int values and i couldn't quite figure out how to decrypt what meant what :|
 
Client Developer
Joined
Oct 12, 2015
Messages
3,760
yeah i had dug into the attributes for items but they are all int values and i couldn't quite figure out how to decrypt what meant what :|

Each Attribute has a certain value associated with it, the easiest way to derive which each attribute maps to is to take a set of items where you can predict what attributes you think it will have even if you don't know the identifiers (like Slash +30, Range Defence +35) and look in the attributes for those expected values. Bit of work, but that's what you're going to have to do.

Just for reference, this is how the Rune API determines if you have an item which replaces a certain Rune type.

Code:
     private Predicate<SpriteItem> getSubstitutableEquipmentPredicate() {
        return Environment.isOSRS() || rs3AttributeId == -1 ? Items.getNamePredicate(staffPattern, TOME_OF_FIRE) : s -> {
            final ItemDefinition definition = s.getDefinition();
            final Attribute attribute;
            return definition != null && (attribute = definition.getAttribute(rs3AttributeId)) != null && attribute.getAsInteger() == 1;
        };
    }
 
Joined
Mar 26, 2014
Messages
33
I started mapping some of the parameter indices out ages ago and identified a fair few, I've just checked and a few seem to have broken but most are still accurate, specifically look at the equipment class ones for what you need

ItemParameter.java · GitHub
 
Top