Can eventA check if it occupies the same tile as any other event?

Martin

Veteran
Veteran
Joined
Apr 8, 2015
Messages
191
Reaction score
46
First Language
swe
Primarily Uses
RMMV
Using Orange Custom events, I copy eventA multiple times onto a region, acting as rocks.
What Im locking for is a
(parallel process)Conditional branch check for eventA to see if the tile its currently on, is in fact already occupied by something else.

If occupied.tile
delete.this
else
end

There might be other ways around this, but Im looking for a way to not get two rocks on same tile.
"rock eventA" runs a parallel process at start of map anyways so this is a good time to check if there is another rock or event on the same tile, for then to selfdestruct if there is.
 
Last edited:

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
168
First Language
English
Primarily Uses
RMMV
JavaScript:
$gameMap.distance($gameMap.event(event a id).x, $gameMap.event(event a id).y, $gameMap.event(event b id).x, $gameMap.event(event b id).y) === 0
Returns true if they're on the same tile!

JavaScript:
$gameMap.distance($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y, $gameMap.event(event b id).x, $gameMap.event(event b id).y) === 0
To compare with the event checking it.
 

Martin

Veteran
Veteran
Joined
Apr 8, 2015
Messages
191
Reaction score
46
First Language
swe
Primarily Uses
RMMV
Thank you very much @ozubon ! Will play with this right away!

Edit: Seems i may have forgotten to say that I wont know that ID to check with. In any case I need to check them all, or any at all.
Im copying event onto a "random generated map" so I need it to fit this kind of logic

If any other event is on this tile
delete.this
else
end
 
Last edited:

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
168
First Language
English
Primarily Uses
RMMV
Sorry that will of course not work if you're spawning in events you don't know the id of.
In that case use this. It's shorter code than the first one anyway:

JavaScript:
$gameMap.eventIdXy($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y) != 0
Returns true if the event that's checking is standing on an occupied tile.
 

Martin

Veteran
Veteran
Joined
Apr 8, 2015
Messages
191
Reaction score
46
First Language
swe
Primarily Uses
RMMV
Hmm interesting. that script actually deletes them all. I think it is because they are spawned from same object. I can delete via a variable ID then maybe
 
Last edited:

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
168
First Language
English
Primarily Uses
RMMV
My bad again, that only finds itself so it will run true everytime.

Try this, this should work lol:
JavaScript:
$gameMap.eventsXy($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y).length != 1
 

Martin

Veteran
Veteran
Joined
Apr 8, 2015
Messages
191
Reaction score
46
First Language
swe
Primarily Uses
RMMV
Thank you! This is just what I needed. :D
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
168
First Language
English
Primarily Uses
RMMV
Inga problem ;)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Dev stream today, come on by and ask questions about rpg maker!
Fun fact: If your story introduces a variety of different races, the "human race" will automatically become the most corrupt race in general.
Finally finished my late start entry for the jam. Now. I. Sleep.
Just made 3 easy, simple and small MZ plugins today(12 hours straight), and I never thought I could ever do this.
Now I feel myself being very productive, even though I know I'm just utterly flattering myself lol
Mind: "I have cool ideas! Let's make it real!

Body: "You wanna make sumthin? I'm in."

Eyes: "Go to sleep, go to sleep."

*Sleep*

Forum statistics

Threads
104,647
Messages
1,007,818
Members
136,133
Latest member
Cashews
Top