MV Yanfly's Proximity Activation - Need help with 'Nearest' target

Hello, I have a sequence in my project where the player can activate a 'shoot' button to 'attack' something at a distance. The player will automatically target the Event within Activation Range, as I don't plan on having the player use their mouse for aiming. The issue I'm running into, however, is that there are multiple events with overlapping Activation Ranges.

I was wondering what the best way would be to implement a "Nearest Target" priority (Clockwise for targets the exact same distance from the player) with Yanfly's Proximity Activation plugin.

As things currently operate, when I'm within range of the two overlapping Events and I press the 'shoot' button, I attack both Events at the same time. My goal is to only attack one at a time.


Additional information: I am also using Galv's Map Projectiles for the visual effects of shooting. It seems Galv's Map Projectiles targets only a single Event even though I'm actually attacking both two Events within range at the same time. Ideally, I want to be able to sync up what Galv's Map Projectiles is targeting with Yanfly's Proximity Activation.

(The left gun on the Mech is invisible because I was in the middle of changing the sprite. The player's gun only shoots at the right turret, but I'm actually hitting both the right and left turret at the same time.)
DynamicBossCombatTest06.gif


I'm relatively Mid when it comes to working on plugins. I know just enough to know I'm messing something up, but not enough to know how to resolve every single mistake. I can learn, and Javascript is my main programming language that I'm familiar with. This is also my first Thread that I'm posting on this forum. I hope I'm making it in the correct location. I just realized I should've placed this in Plugin Support, not Request. I have no idea how to change it over.
Hmmm, if you're using Galv's projectiles, can't you use that to activate self-switch when projectiles hit target and run the effect parallel and turn self-switch off at the end of page? Use the shoot at target variant. I think you can get one event target id for it with something like this (not sure if this is clockwise though + you need to give values to stuff in the projectile script, other than tid):

const shootDistance = 5;

const targets = $gameMap.events().filter(event =>
$gameMap.distance(
$gamePlayer.x, $gamePlayer.y,
$gameMap.event(event.eventId()).x, $gameMap.event(event.eventId()).y
) <= shootDistance;
)

if (targets.length) {
const tid = targets[0].eventId()
Galv.PROJ.atTarget(sid,tid,s,d,'img',anim,'action',[r],[t],z,pid,size);
}
Thank you for the reply.

I was having another issue with Galv's Projectiles, actually. It seems that using the Projectiles to activate a Common Event, Audio Effects function properly, but the Common Event activated by Projectiles will seemingly completely ignore Switch and Variable Activation/Alterations.

Example: Projectile activates Common Event 40 on hit. Common Event 40 has a "Metal Plate" shot sound effect, as well as a Switch Activation to open a door, and a Variable Activation to tell you how much "Damage" the Plate Received (Random between 100 and 500). Only the Audio Activates while the Switch remains Off, and the Variable remains at 0.


I'll try your suggestion, but it seems this issue with the Projectiles might be creating more problems later down the pipeline.


Edit: I've tried ignoring Common Event activations altogether and tried activating a switch directly (ie; instead of using 'c(40)' in the script, I used 'S(197: on)', without the space), but even that failed to activate the switch. Not entirely sure what's going on here.

Edit 2: Actually, I messed up. I forgot that I included the "Metal Plate" shot sound effect to the animation that plays in the projectile script. So it actually seems like the 'Action' part of the script doesn't seem to be functional at all. (I do have <projEffect> comment on the event, as well)
Don't know about that, but did you try to make the projectile activate a self-switch? Then the event runs the code parallel on the page with that self-switch condition and then flips the self-switch off at the end.

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-proximity-activation-need-help-with-nearest-target.179642/