Paradoxum 0 Share Posted September 9, 2018 Hi, I've been working on a sort of semi-automatic script that assists a human player doing basic mundane tasks, and am trying to find a way to get a reference to a player (or entity) that exists under the mouses current position. Can anyone think of an efficient way to accomplish this? Currently I'm simply following the player, then getting the interacting character using this: final Character interactingWith = main.getLocalPlayer().getInteractingCharacter(); if (interactingWith != null) main.hsLookup(interactingWith.getName()); This is however, getting very troublesome having to constantly follow players when I want to get a reference to them. Is there any way to get a list of player's/characters under the mouses hovered position? EDIT: Nvm, just found my answer in the API ! getMouse().getEntitiesOnCursor() is exactly what i needed. Thanks Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted September 9, 2018 You can load and store every local player, then probably determine the player(s) at the mouse location by determining the tile/position at which the mouse is existent and comparing this to the location of the players. Link to comment Share on other sites More sharing options...
Paradoxum 0 Author Share Posted September 9, 2018 Just now, Pseudo said: You can load and store every local player, then probably determine the player(s) at the mouse location by determining the tile/position at which the mouse is existent and comparing this to the location of the players. Yeeaaahh... I was thinking of this... I was just hoping there would be a way without searching through every single player, as in the area I'm in this would mean hundreds. Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted September 9, 2018 39 minutes ago, Paradoxum said: Yeeaaahh... I was thinking of this... I was just hoping there would be a way without searching through every single player, as in the area I'm in this would mean hundreds. Well you could filter the search down to a smaller radius, so you'd only then iterate over the players in say, a 10 tile radius from our local player. Link to comment Share on other sites More sharing options...
ArmyofDragons 28 Share Posted September 9, 2018 Get the Polygon/Bounding Box of the Player and check if the mouse is inside it. Link to comment Share on other sites More sharing options...
RoboMan 1 Share Posted September 11, 2018 I'm glad you've found the answer. I've recently been thinking about how to randomize various aspects of scripts, and needed something like this. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.