How to check location of an event.

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
I'm trying to put in a conditional branch that checks to see if an event has made it to a specific x,y coordinate, and when it does, I'd like to end the event. My other choice is to have it end when it hits a certain event. Both options I don't have answers too, any help would be greatly appreciated.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,569
Reaction score
915
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi!
Put each one of the X and Y coordinates of the event in a variable.
When the variables reach the values specific x,y coordinate that you want, you do your thing.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
953
Reaction score
514
First Language
Javascript
Primarily Uses
RMMZ
Hi!
Put each one of the X and Y coordinates of the event in a variable.
When the variables reach the values specific x,y coordinate that you want, you do your thing.
Well yep that's certainly a way... however that's gonna be quite a bit of extra steps to achieve the desired result though...

I'm trying to put in a conditional branch that checks to see if an event has made it to a specific x,y coordinate
upload_2019-11-19_0-59-52.png
Code:
$gameMap.event(1).x === 5 && $gameMap.event(1).y === 6
Use this script to check if Event 1 is at coordinates (5, 6) on the map.
and when it does, I'd like to end the event.
"End" the event...
...hmm what you want to do is turn on a self switch for the event?
Code:
$gameSelfSwitches.setValue([$gameMap._mapId, 1, 'A'], true);
This turns on self switch "A" for event 1 on the current map.
or if you want to "erase" the event...
Code:
$gameMap.eraseEvent(1);
My other choice is to have it end when it hits a certain event.
Code:
$gameMap.event(1).x === $gameMap.event(2).x && $gameMap.event(1).y === $gameMap.event(2).y
Use this script to check if Event 1 is at the same location as Event 2

I also have created an Event touch Event plugin a back in 2016 (recently updated for compatibility) if it would help you...
https://forums.rpgmakerweb.com/index.php?threads/events-touching-trigger-v1-0.57814/

Let me know how it goes for ya. :)
Happy Game Making!
 
Last edited:

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Well yep that's certainly a way... however that's gonna be quite a bit of extra steps to achieve the desired result though...


Code:
$gameMap.event(1).x === 5 && $gameMap.event(1).y === 6
Use this script to check if Event 1 is at coordinates (5, 6) on the map.

"End" the event...
...hmm what you want to do is turn on a self switch for the event?
Code:
$gameSelfSwitches.setValue([$gameMap._mapId, 1, 'A'], true);
This turns on self switch "A" for event 1 on the current map.
or if you want to "erase" the event...
Code:
$gameMap.eraseEvent(1);

Code:
$gameMap.event(1).x === $gameMap.event(2).x && $gameMap.event(1).y === $gameMap.event(2).y
Use this script to check if Event 1 is at the same location as Event 2

I also have created an Event touch Event plugin a back in 2016 (recently updated for compatibility) if it would help you...
https://forums.rpgmakerweb.com/index.php?threads/events-touching-trigger-v1-0.57814/

Let me know how it goes for ya. :)
Happy Game Making!
These are certainly what I'm looking for, I'd like to use any of them, but I think I know my issue, however don't have an answer to it yet. As you can see by my picture, the event is set to "Event Touch" so when the "rock" hits the player, it destroys and does damage. However, because it's set to event touch, it seems it may not run unless it's touching the Player event. I can't put it to a global switch, because this event spawns constantly from a location, so they would all be ran from the same switch, and shutting that switch off would destroy all the other rocks being spawned. However, I feel like that Event Touch should affect it, as it still runs my other "If" statement. Hopefully you can see the error of my ways, cause I certainly cannot lol.

Well yep that's certainly a way... however that's gonna be quite a bit of extra steps to achieve the desired result though...


Code:
$gameMap.event(1).x === 5 && $gameMap.event(1).y === 6
Use this script to check if Event 1 is at coordinates (5, 6) on the map.

"End" the event...
...hmm what you want to do is turn on a self switch for the event?
Code:
$gameSelfSwitches.setValue([$gameMap._mapId, 1, 'A'], true);
This turns on self switch "A" for event 1 on the current map.
or if you want to "erase" the event...
Code:
$gameMap.eraseEvent(1);

Code:
$gameMap.event(1).x === $gameMap.event(2).x && $gameMap.event(1).y === $gameMap.event(2).y
Use this script to check if Event 1 is at the same location as Event 2

I also have created an Event touch Event plugin a back in 2016 (recently updated for compatibility) if it would help you...
https://forums.rpgmakerweb.com/index.php?threads/events-touching-trigger-v1-0.57814/

Let me know how it goes for ya. :)
Happy Game Making!
I guess a better question would be this: Is there a way, instead of saying "$gameMap.eraseEvent(1);" to say "gameMap.erasEvent(self);" the self part is just an example, but it would pertain to the event that it's running from. Because I imagine if multiple events continue to spawn, they will each be considered a new event number. What do you think? Thanks alot.
 
Last edited by a moderator:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
953
Reaction score
514
First Language
Javascript
Primarily Uses
RMMZ
I guess a better question would be this: Is there a way, instead of saying "$gameMap.eraseEvent(1);" to say "gameMap.eraseEvent(self);" the self part is just an example, but it would pertain to the event that it's running from. Because I imagine if multiple events continue to spawn, they will each be considered a new event number. What do you think? Thanks alot.
If I understand correct the conditional branch is running in the event you want to erase?
If so the following I believe would work...
Code:
$gameMap.eraseEvent(this._eventId);
Haven't tested it yet myself though.
Please let me know if that works for ya. :)
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Hi!
Put each one of the X and Y coordinates of the event in a variable.
When the variables reach the values specific x,y coordinate that you want, you do your thing.
Are you able to elaborate a bit on this, as far as the process goes? I sort of get where you're going, but not experienced enough to do the logic. Thanks

If I understand correct the conditional branch is running in the event you want to erase?
If so the following I believe would work...
Code:
$gameMap.eraseEvent(this._eventId);
Haven't tested it yet myself though.
Please let me know if that works for ya. :)
Well, that code might help me in a way, but what I need to say is, instead of finding the asking if "event(5)" has hit those coordinates, I need to say
If I understand correct the conditional branch is running in the event you want to erase?
If so the following I believe would work...
Code:
$gameMap.eraseEvent(this._eventId);
Haven't tested it yet myself though.
Please let me know if that works for ya. :)
Are you able to elaborate a bit on this, as far as the process goes? I sort of get where you're going, but not experienced enough to do the logic. Thanks
So, I uploaded a picture, should this not do the trick? Or am I putting in something redundant? Thanks for your time
 

Attachments

Last edited by a moderator:

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,475
Reaction score
5,310
First Language
english
Primarily Uses
RMMZ

@PKirkby , please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.


I've merged them for you this time, but in the future please just edit your post if you have something else to add.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
[dpost]@PKirkby [/dpost]
I've merged them for you this time, but in the future please just edit your post if you have something else to add.
Sorry, I didn't even realize I had it double posted, thanks.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,569
Reaction score
915
First Language
Portuguese - Br
Primarily Uses
RMMV
Are you able to elaborate a bit on this, as far as the process goes? I sort of get where you're going, but not experienced enough to do the logic. Thanks
@PKirkby
Yes, I can.
There are a lot of ways doing that, including the script call.
But since you ask that question, and don't know how to achieve that, I first recommend you to do this with the event command tabs, so you can know a little more about the engine :)

So, going in that way, you ask:
I'm trying to put in a conditional branch that checks to see if an event has made it to a specific x,y coordinate, and when it does, I'd like to end the event. My other choice is to have it end when it hits a certain event. Both options I don't have answers too, any help would be greatly appreciated.
Just to explain the screenshot that I gave to you before:
Go to control variables > Choose a variable to store the position X of the event > In OPERAND, choose Game Data > Click in the tab Character and choose the event you want to check > in the right side, choose Map X.

Repeat the same process to store the event position Y.

So now, you can use the conditional branch to check the variables that you used(Which would be the positions X and Y of the event) with the coordinates that you want.
Alternatively, you can set the variables to store the position of "this event", in case you want to put this check in the event itself.
With that, you can check the coordinates of the event.

However, with script calls, there is a way to do that, that I think it's best to event everything:

You can put that in a parallel event.
var rock = [put here all the event id numbers that you want to check]
if($gameMap.event(eventId).pos(X, Y)) { // replace the X and Y for the coordinates you want to check.
If an event is in that specified position, it will be erased.

OBS: you can put a wait command after the script call to avoid lag. I think if you put 3-5 frames it would be nice.

I hope it helps!
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
@PKirkby
Yes, I can.
There are a lot of ways doing that, including the script call.
But since you ask that question, and don't know how to achieve that, I first recommend you to do this with the event command tabs, so you can know a little more about the engine :)

So, going in that way, you ask:


Just to explain the screenshot that I gave to you before:
Go to control variables > Choose a variable to store the position X of the event > In OPERAND, choose Game Data > Click in the tab Character and choose the event you want to check > in the right side, choose Map X.

Repeat the same process to store the event position Y.

So now, you can use the conditional branch to check the variables that you used(Which would be the positions X and Y of the event) with the coordinates that you want.
Alternatively, you can set the variables to store the position of "this event", in case you want to put this check in the event itself.
With that, you can check the coordinates of the event.

However, with script calls, there is a way to do that, that I think it's best to event everything:

You can put that in a parallel event.
var rock = [put here all the event id numbers that you want to check]
if($gameMap.event(eventId).pos(X, Y)) { // replace the X and Y for the coordinates you want to check.
If an event is in that specified position, it will be erased.

OBS: you can put a wait command after the script call to avoid lag. I think if you put 3-5 frames it would be nice.

I hope it helps!
Ok, I guess I had it working before, however it's in an event that is set to trigger when it comes in contact with the Player, so it won't run the conditional branch unless it's set to a parallel process. Do you know of a way to have the event run code if it collides with the player, and seperate code if it hits the MAPID? Thanks again for your help
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,569
Reaction score
915
First Language
Portuguese - Br
Primarily Uses
RMMV
Ok, I guess I had it working before, however it's in an event that is set to trigger when it comes in contact with the Player, so it won't run the conditional branch unless it's set to a parallel process. Do you know of a way to have the event run code if it collides with the player, and seperate code if it hits the MAPID? Thanks again for your help
Don't know if I understand you anymore.
But you can make the check coordinates in a parallel event and the other things inside the event(rock).
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Don't know if I understand you anymore.
But you can make the check coordinates in a parallel event and the other things inside the event(rock).
Yeah, I'm going to fool around with putting it in another event. The only problem is that I can't name an event in particular, because I have them spawning constantly, and I can only assume that everytime a new one spawns, it has a new event ID.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,569
Reaction score
915
First Language
Portuguese - Br
Primarily Uses
RMMV
@PKirkby How it is spawning? Do you are using any plugin for that?
Because I can think that might be a way to add to the method that I show to you, a kind of filter.
So it will filter only the events Id with has a specific notetag or name.
Sure it is a way, but I don't know for sure how to do.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
@PKirkby How it is spawning? Do you are using any plugin for that?
Because I can think that might be a way to add to the method that I show to you, a kind of filter.
So it will filter only the events Id with has a specific notetag or name.
Sure it is a way, but I don't know for sure how to do.
I'm using GALVS event spawner, there's probably so many solutions and ways around it, I just can't seem to think of one on my own.
 

ImaginaryVillain

Resident of Silent Hill... Apparently
Veteran
Joined
Jun 22, 2019
Messages
722
Reaction score
3,775
First Language
Absurdism
Primarily Uses
RMMV
When you spawn in an event, have it's first page be a parallel one that sets a variable to this._eventId, then have it move to another page with whatever code the event normally does. Personally I like doing that with Yanfly's Self Variables, but you don't actually need that. Whatever the case you will then have an easy reference to what the event's ID is.

Optionally you can use https://github.com/Aesica/RMMV Aesica Core to reference all events with a specific note tag.

Also since you're using Galv's Event Spawner don't use the regular erase command (I advise against using it at all in general), instead use Galv.SPAWN.unspawn(this); in a script command. This will actually erase an event spawned by Galv's Event Spawner.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
When you spawn in an event, have it's first page be a parallel one that sets a variable to this._eventId, then have it move to another page with whatever code the event normally does. Personally I like doing that with Yanfly's Self Variables, but you don't actually need that. Whatever the case you will then have an easy reference to what the event's ID is.

Optionally you can use https://github.com/Aesica/RMMV Aesica Core to reference all events with a specific note tag.

Also since you're using Galv's Event Spawner don't use the regular erase command (I advise against using it at all in general), instead use Galv.SPAWN.unspawn(this); in a script command. This will actually erase an event spawned by Galv's Event Spawner.
Hey thanks, I've decided to try just using the same handful of events, and moving their location back and forth, it has the same effect basically, and might end up working out the same. That way I can set one event to move event when it hits a certain coordinate, and then within itself i can do the "on event touch" code. I will look into your way too if it doesnt pan out, thanks again
 

ImaginaryVillain

Resident of Silent Hill... Apparently
Veteran
Joined
Jun 22, 2019
Messages
722
Reaction score
3,775
First Language
Absurdism
Primarily Uses
RMMV
Reasonable enough, also worth noting if you just want to throw a rock at the player and have it do something, https://galvs-scripts.com/2016/09/13/mv-map-projectiles/ and you just replace the projectile graphic with a rock. Though a lot of these are pretty extreme unless you're going to be basing your entire game on it.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
18
First Language
english
Primarily Uses
RMMV
Reasonable enough, also worth noting if you just want to throw a rock at the player and have it do something, https://galvs-scripts.com/2016/09/13/mv-map-projectiles/ and you just replace the projectile graphic with a rock. Though a lot of these are pretty extreme unless you're going to be basing your entire game on it.
I'm all over the map, Im starting to think that spawning the events is the better way to go now. It will just take alot of planning to make sure certain events are moved at the right times. I'm going to start fooling around again. I created a projectile for my player to fire, but the issue is that i have to specify every "enemy" that it's going to come in contact. I'm going to check out that plugin, thanks again!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

There once was a man whose name was my own
Who tried to make games for console and phone
But after ten years
Some blood sweat and tears
Weird status updates were all that he'd shown.....
I go out once every two weeks. My bf works full-time. Why is it only ever me getting sick? T_T
I've been debating on this as the title screen for a while now...
Ami
--- Dialog Filter ---

Gunner: Yo! my ****** friend?
Hero: Uhh,what happen with your mouth?
Gunner: Huh? what ****** happen with my mouth? i just speech as usual.
Hero: But,your mouth are like the garbage!
Gunner: Hey,what the **** are you say? you want the piece of **** with my ****** Gun!
(Meanwhile,The Dialog Filter In The Option Is Off)
Demo for Maze of the Lost MZ released. I would appreciate any and all feedback and constructive criticism. If you like Dungeon Crawlers and JRPG's with a hint of Metroidvania and Shadowgate/Uninvited you might like it. https://forums.rpgmakerweb.com/index.php?threads/maze-of-the-lost-mz-demo-port-from-mv.127971/

Forum statistics

Threads
103,393
Messages
998,996
Members
134,913
Latest member
Tenerezu
Top