Way of retrieving a unique event ID?

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!
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.
I suppose the more useful question would be "Why do you need this?"
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.
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.
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.")
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.
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
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.
Spoiler
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.
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.
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!
Check out Yanfly's Self Variables plugin
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.

Original thread: https://forums.rpgmakerweb.com/threads/way-of-retrieving-a-unique-event-id.124090/