Way of retrieving a unique event ID?

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
39
Reaction score
18
First Language
Swedish
Primarily Uses
RMMV
I think this.eventId() returns a number which can refer to different events on different maps. Are there event IDs somewhere that uniquely identify events across all maps in the game? I guess map ID + event ID constitutes a unique event ID, but are there any standard methods or tricks for working with such a construct?

Thanks!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,960
Reaction score
13,590
First Language
English
Primarily Uses
RMMV
Events only exist when a map is loaded into memory, and only one map can be loaded at a time, under normal circumstances.

If you want to refer to a specific event on a specific map, without getting it confused with an event on a different map with the same id, then you have to combine map id and event id.

Self switches, for example, exist in a single array in Game_System. It is a list of all self switches (there are 4) for every event, for every map. It uses [mapId, eventId, selfSwitchId] as the key.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,603
Reaction score
1,941
First Language
English
Primarily Uses
RMMV
I suppose the more useful question would be "Why do you need this?"
 

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
39
Reaction score
18
First Language
Swedish
Primarily Uses
RMMV
If you want to refer to a specific event on a specific map, without getting it confused with an event on a different map with the same id, then you have to combine map id and event id.
Ok, thanks! I'm vaguely thinking of adding new state information to events, I think preferably in my own namespace. Say for example that turning some event into an NPC by way of a note tag associates a bunch of new persistent properties and methods to that event. I guess it would be best to model that on how switches are handled then, and use map ID + event ID as the key.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,603
Reaction score
1,941
First Language
English
Primarily Uses
RMMV
Alternatively, you could create a new class called Game_NPC or something and then overwrite the event creation code to create one of those instead of Game_Event if the notetag is present.
 

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
39
Reaction score
18
First Language
Swedish
Primarily Uses
RMMV
Alternatively, you could create a new class called Game_NPC or something and then overwrite the event creation code to create one of those instead of Game_Event if the notetag is present.
Right, that sounds like the way to do it, from one point of view. I'm handicapped by having a brain tuned to relational databases and functions, not object oriented code. Still, I'm wondering if it's not a good idea if, as far as RMMV knows, these are just regular events that don't misbehave in any way. That is, I would manipulate them using the standard RMMV methods, but based on states and methods kept elsewhere. (This is what I meant by "vaguely thinking.")
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,603
Reaction score
1,941
First Language
English
Primarily Uses
RMMV
Right, that sounds like the way to do it, from one point of view. I'm handicapped by having a brain tuned to relational databases and functions, not object oriented code. Still, I'm wondering if it's not a good idea if, as far as RMMV knows, these are just regular events that don't misbehave in any way. That is, I would manipulate them using the standard RMMV methods, but based on states and methods kept elsewhere. (This is what I meant by "vaguely thinking.")
You could get around that by having Game_NPC inherit from Game_Event (which will cause the engine to treat it like a regular event in every way that matters) but then add your properties/methods to that class. That would actually accomplish your goal better than tacking properties onto a Game_Event only if it has the notetag.
 

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
39
Reaction score
18
First Language
Swedish
Primarily Uses
RMMV
You could get around that by having Game_NPC inherit from Game_Event (which will cause the engine to treat it like a regular event in every way that matters) but then add your properties/methods to that class. That would actually accomplish your goal better than tacking properties onto a Game_Event only if it has the notetag.
Yeah, that sounds like the way to go, having NPCs be a type of event, and the game engine doesn't need to know that it's a special type. I just need to learn how to do this. :^D
 

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
460
Reaction score
1,437
First Language
Indonesia
Primarily Uses
RMMV
this if it's called inside an event will be referred to Game_Event, which is the current event.
this._eventId is referring to the ID of that current event.

To refer any event on the currently loaded map, it's $gameMap.event(ID)

If you're trying to refer a specific event in a specific map, it's something along $datamap... not sure... I don't quite remember as well. Maybe $datamap[map_id].events[event_id].

There's the same question with the same purpose asked in discord. IDK if it could help. But he planned to store the data and parameter inside the game variable which I think is more direct and flexible.
1594805761536.png
1594805854284.png
1594805898237.png

One thing I don't understand is, why are you trying to bind your event? If you specify a unique event by his map and event ID, then it will be bound forever to that specific map and event ID. You will lose flexibility in this aspect.

Here's the problem: What if you are trying to make that "Old Man A" from map X appear in map Y while carrying his unique parameter? You no longer can. They are bound to their location forever.

Just create a new accessible data and have your event access it anytime, anywhere.
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,603
Reaction score
1,941
First Language
English
Primarily Uses
RMMV
Yeah, that sounds like the way to go, having NPCs be a type of event, and the game engine doesn't need to know that it's a special type. I just need to learn how to do this. :^D
If you look at rpg_objects.js, Game_Event is actually a child class of Game_Character. If you look at how Game_Character and Game_CharacterBase are coded, it should give you a fair idea of how to incorporate a new subclass for NPCs specifically.

Kuro, what you're suggesting won't work. $dataMap only contains the data for the currently-loaded map, and $dataMapInfos, although it has an element for every map in the game, only holds information about the map itself and has no concept of the events on it.
 
Last edited:

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
39
Reaction score
18
First Language
Swedish
Primarily Uses
RMMV
If you look at rpg_objects.js, Game_Event is actually a child class of Game_Character. If you look at how Game_Character and Game_CharacterBase are coded, it should give you a fair idea of how to incorporate a new subclass for NPCs specifically.
Cool, thanks!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,960
Reaction score
13,590
First Language
English
Primarily Uses
RMMV
Check out Yanfly's Self Variables plugin
 

Kronicide

Veteran
Veteran
Joined
Jul 7, 2020
Messages
39
Reaction score
18
First Language
Swedish
Primarily Uses
RMMV
If you're trying to refer a specific event in a specific map, it's something along $datamap... not sure... I don't quite remember as well. Maybe $datamap[map_id].events[event_id].

There's the same question with the same purpose asked in discord.
Thanks, that's useful!

One thing I don't understand is, why are you trying to bind your event? If you specify a unique event by his map and event ID, then it will be bound forever to that specific map and event ID. You will lose flexibility in this aspect.

Here's the problem: What if you are trying to make that "Old Man A" from map X appear in map Y while carrying his unique parameter? You no longer can. They are bound to their location forever.
That's a good point, and my original idea was actually to not bind the NPC data permanently to an event, but to create a new NPC object that is associated with an event (by a unique identifier), as one of its properties. That was more due to my relational-databases way of thinking than because of this issue, though.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Just for the lols I have taken the Szondi test. That test looked like a load of bull. But for whatever reason it was incredibly accurate.
How can a society function with an entire media establishment that is complicit in publishing partisan slander and easily disprovable lies right alongside each other with no accountability whatsoever? After I live through it, maybe I'll make a game based on it. The level of dishonesty at this point just astounds me though.
If you download a resource, be it art or plugin, please thank the creator for their time. We are all guilty sometimes of just grabbing something without commenting. Now is the time to go through your credit list and visit the threads/site where you got the resource from and leave a heartfelt thank you!
October is officially here. I'm hoping to get a call from Spirit Halloween soon. It didn't happen today, but I've got to keep my head high.
So, what is this "Inktober" everyone's speaking about? Because apparently, I have no idea what happens on this site...

Forum statistics

Threads
103,493
Messages
999,759
Members
135,041
Latest member
SebasMonsalve
Top