MV Galv Action Indicator omni-direction fix

So I'm trying to really wrap my mind around how to make Galv's Action Indicator script detect the player regardless of what direction they're facing. This is an issue I've seen multiple people face (because they want to put this plugin in their game) but nobody's gotten an answer yet, so I've been trying to break the ice.

JavaScript:
var x2 = $gameMap.roundXWithDirection($gamePlayer._x, $gamePlayer._direction);
    var y2 = $gameMap.roundYWithDirection($gamePlayer._y, $gamePlayer._direction);
    var x4 = $gameMap.roundXWithDirection($gamePlayer._x, $gamePlayer.reverseDir($gamePlayer.direction()));
    var y4 = $gameMap.roundYWithDirection($gamePlayer._y, $gamePlayer.reverseDir($gamePlayer.direction()));
    var action = null;
 
    // CHECK EVENT IN FRONT
    if (!action) {
        $gameMap.eventsXy(x2, y2).forEach(function(event) {
            if (event.isNormalPriority()) {
                action = Galv.AI.checkEventForIcon(event);
            };
        });
        $gameMap.eventsXy(x4, y4).forEach(function(event) {
            if (event.isNormalPriority()) {
                action = Galv.AI.checkEventForIcon(event);
            };
        });
    };

The closest I've gotten was this $gamePlayer.reverseDir code that makes it so the button pops up when the player is facing away from the event, but not to the left or right. I'd also like to extend the range of the detection to be 2 tiles instead of directly in front of the event.

(I'm also aware of Moghunter's Event Indicators, which for various reasons - primarily the fact it doesn't use icons - doesn't work for me.)
Where's the link, yo?! No link, no help! 😛

Go to line 161 and make a new line. Paste in:
Code:
    // Check all adjacent tiles
    if (!action)
    {
        x2 = $gamePlayer._x;
        y2 = $gamePlayer._y;
        $gameMap.eventsXy(x2 - 1, y2).forEach(function(event) 
        {
            if (event.isNormalPriority())
                action = Galv.AI.checkEventForIcon(event);
        });
        if (!action)
        {
            $gameMap.eventsXy(x2, y2 - 1).forEach(function(event) 
            {
                if (event.isNormalPriority())
                    action = Galv.AI.checkEventForIcon(event);
            });
        }
        if (!action)
        {
            $gameMap.eventsXy(x2 + 1, y2).forEach(function(event) 
            {
                if (event.isNormalPriority())
                    action = Galv.AI.checkEventForIcon(event);
            });
        }
        if (!action)
        {
            $gameMap.eventsXy(x2, y2 + 1).forEach(function(event) 
            {
                if (event.isNormalPriority())
                    action = Galv.AI.checkEventForIcon(event);
            });
        }
    }

Note that the plugin is still only designed to display one icon at a time - it's written on that fundamental concept. So if you want to walk onto a space and have all events on and around it light up, that would require a more in-depth rewriting of the plugin.
Where's the link, yo?! No link, no help! 😛

Oops!

(To be fair, it was 5 in the morning when I posted it. 😛)

Note that the plugin is still only designed to display one icon at a time - it's written on that fundamental concept. So if you want to walk onto a space and have all events on and around it light up, that would require a more in-depth rewriting of the plugin.

Ah. Oh well. Just gotta not stack interactables on opposing sides, I guess.

--

That said, the script you provided works! Now it shows if it's interactable from any angle. Thanks as always, Turan.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/galv-action-indicator-omni-direction-fix.171663/