Get event's map x/y position with a script command?

Penumbra

A Floof
Member
Joined
Dec 20, 2013
Messages
12
Reaction score
16
First Language
English
Primarily Uses
RMMV
I'm writing a hunting scene where the player shoots projectiles on the map to strike monsters, and I need a way to check a monster's x/y without using two variable slots for each monster (I can do that if I have to, but it would be harder to keep track of). Is there a way to use a script command in the corresponding spot of an if-statement to check the map x or y value of the event that calls it?

Grazie!
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
319
Reaction score
130
First Language
English
Primarily Uses
RMMV
I think something like this should work?

JavaScript:
(who => who.x == 4 && who.y == 5)(this.character(0))
Explanation, if you're interested:
  • The expression (who => ...) declares a function taking parameter who.
  • We then immediately call the function, assigning this.character(0) (which returns the current event) to the variable who.
  • The && means "and", so you're checking both coordinates. If you only need to check either x or y but not both, you can omit it.
  • If you need to check a range, you can use <= or >= instead of ==
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,375
Reaction score
623
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi there!
To check an event position on the map, without variables, you can use the script call:
$gameMap.event(Id).x
or
$gameMap.event(Id).y
(I don't remember if it is 'event' or 'events', not in my pc right now)
So, in the script call of the if statement you can use
$gameMap.event(id).x === 10 && $gameMap.event(id).y === 12
This will check if both conditions are true.
If you want one or another, you can replace && for ||
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
1,869
Reaction score
1,219
First Language
English
Primarily Uses
RMMV
Hi there!
To check an event position on the map, without variables, you can use the script call:
$gameMap.event(Id).x
or
$gameMap.event(Id).y
(I don't remember if it is 'event' or 'events', not in my pc right now)
So, in the script call of the if statement you can use
$gameMap.event(id).x === 10 && $gameMap.event(id).y === 12
This will check if both conditions are true.
If you want one or another, you can replace && for ||
You're correct, the function is event.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Automatic level scaling without an option to turn it off can be a very bad choice for a game. The worst I've ever seen was in Nightmare of Druaga, where if a power outage made your system turn off, the game detects it as an attempted cheat and overwrites your save while taking away your best gear, leaving you unable to progress at the late stages of the game, and unable to recover.
Problem with sequels: Heroes getting rid of all their items and forgets all of their skills within the span of a year without explanation. :kaomad3:
I can see the end of my prologue. Perfect time to decide to pull everything over into MZ, right? Right?!
Excited to be nearing the end of setting up my own custom Point-And-Click system template! Just need to iron out some kinks, get an input text system going, add animations to buttons, and then finalize my button-mashing event system and it'll be complete >:3c
AlcTheHero wrote on Mystic_Enigma's profile.
hi.

Forum statistics

Threads
99,643
Messages
967,616
Members
131,312
Latest member
jacob_rev
Top