A downloadable RPG Maker MV Plugin

Download NowName your own price

Find the event(s) nearest the player (or any other object)

Script calls:

  $gameMap.nearestEvent()

  $gameMap.nearestEventId()

  $gameMap.eventsByDistance()

  $gameMap.eventIdsByDistance()

  $gameMap.hasNearEvent()

  $gameMap.eventsByName('name')

  $gameMap.eventByName('name')

  $gameMap.eventIdByName('name')

  *character*.getDistanceFrom(*character*)

  *character*.getXyDistanceFrom(*character*)

To use a notetag filter:

Place a notetag like <target> into an event's note field

To use a comment as a notetag use a comment like the following examples:

 <target: true/>

 <target: $gameVariables.value(30) > 5/>

then use any of the the following script calls:

  $gameMap.nearestEvent('target')

  $gameMap.nearestEventId('target')

  $gameMap.eventsByDistance('target')

  $gameMap.eventIdsByDistance('target')

  $gameMap.hasNearEvent('target')

this can also be used to check against other events like this:

  $gameMap.nearestEventId('target', $gameMap.event(1))

Example of how to set a self-switch using this:

  $gameSelfSwitches.setValue([$gameMap._mapId, $gameMap.nearestEventId('target'), 'A'], true);

Other Examples

  $gamePlayer.getDistanceFrom($gameMap.event(this._eventId))

The above returns a value of how far away the player is from the current event

this uses simple distance formula to return the single value

  $gamePlayer.getXyDistanceFrom($gameMap.event(1))

The above returns an object containing an x an y value {x: X Value, y: Y Value}

of how far away the player is from the event #1

& sets the object a into an array variable of both $gamePlayer and event #1

Example, after calling the above function then you can use

  $gamePlayer._xYdistanceFrom[1].x

  $gamePlayer._xYdistanceFrom[1].y

That would then return the X & Y distance from event 1

Alternatively you could also do like this:

  $gamePlayer.getXyDistanceFrom($gameMap.event(1)).x

  $gamePlayer.getXyDistanceFrom($gameMap.event(1)).y

That does the same thing.

Download

Download NowName your own price

Click download now to get access to the following files:

CTB_NearestEventMV.js 6.9 kB

Comments

Log in with itch.io to leave a comment.

You have no idea how much I love you right now. This is extremely helpful and blows my current distance checking by miles!

Aww shucks lol yay!

Happy to be of assistance.
Let me know if you need/want me to add anything extra & surely I will add other features if needed/wanted :)