Darek93 0 Posted July 10, 2023 How should i approach this? do i really just have to get the attacking players equipment and then match the equipped weapon against list of known pvp weapons and handle prayers accordingly or is there another more robust method? somehow determining what type of weapon the attacker is wielding like range, mage, melee etc would be huge help
Diggington 20 Posted July 10, 2023 The first one. Get the list of the attacking player's equipment and use some kind of matrix or something to determine what style that weapon correlates with
Darek93 0 Author Posted July 11, 2023 39 minutes ago, Diggington said: The first one. Get the list of the attacking player's equipment and use some kind of matrix or something to determine what style that weapon correlates with ugh that is a lot of work and there will be a lot of edge cases due to it being pretty hard to predict every single item pkers would be wearing but i guess if that is the only way... maybe i can find some premade id lists somewhere if im lucky.
Darek93 0 Author Posted July 12, 2023 incase anyone else was looking for something like this i found this from some pvp plugins github page, seems to be pretty accurate from a quick glance, just missing some newer weapons like voidwaker etc. private static final String[] meleeWeaponNames = { "sword", "scimitar", "dagger", "spear", "mace", "axe", "whip", "tentacle", "-ket-", "-xil-", "warhammer", "halberd", "claws", "hasta", "scythe", "maul", "anchor", "sabre", "excalibur", "machete", "dragon hunter lance", "event rpg", "silverlight", "darklight", "arclight", "flail", "granite hammer", "rapier", "bulwark" }; private static final String[] rangedWeaponNames = { "bow", "blowpipe", "xil-ul", "knife", "dart", "thrownaxe", "chinchompa", "ballista" }; private static final String[] magicWeaponNames = { "staff", "trident", "wand" };
Zenz101 1 Posted July 23, 2023 What I would do is get the item IDs of each weapon style melee, ranged and magic and sort them into an array. Then use binarySearch to check if the opponents weapon slot equipment is included in one of the arrays. Next I would check the distance of the opponent from myself to determine if he is not staff bashing or casting a spell. Pour this into a separate thread which calls every 600ms (1 tick) and change a variable concurrently using AtomicReference in the main thread for thread safety to grab whichever attack style the opponent is using. You would only do this for the character interacting with yourself through Players.getLocal().getCharacterInteractingWithMe()
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now