The relationship between the map_object struct and object_event's should be further defined.
object_event's are loaded into the map_object struct by means of CopyMapObjectEvents. There is a clear and corresponding relationship between these two. The only items in the map_object struct that isn't copied from the Map's object_event's is MAPOBJECT_OBJECT_STRUCT_ID which is initially set to -1 until the object appears on screen (_in which case it is then loaded with the index of the corresponding object_struct_), and the two extra bytes at the end of the struct represented by the rb_skip 2.
EDIT: To re-iterate the importance of this, you can't reorder/add/remove items from the object_event macro without also modifying the map_object struct.
The relationship between the
map_object
struct andobject_event
's should be further defined.object_event
's are loaded into themap_object
struct by means ofCopyMapObjectEvents
. There is a clear and corresponding relationship between these two. The only items in themap_object
struct that isn't copied from the Map'sobject_event
's isMAPOBJECT_OBJECT_STRUCT_ID
which is initially set to-1
until the object appears on screen (_in which case it is then loaded with the index of the correspondingobject_struct
_), and the two extra bytes at the end of the struct represented by therb_skip 2
.https://github.com/pret/pokecrystal/blob/c01409be5a9930d6f0687ce53c1c898e1855c884/constants/map_object_constants.asm#L99-L118
https://github.com/pret/pokecrystal/blob/c01409be5a9930d6f0687ce53c1c898e1855c884/macros/scripts/maps.asm#L105-L132
https://github.com/pret/pokecrystal/blob/c01409be5a9930d6f0687ce53c1c898e1855c884/home/map.asm#L610-L634
https://github.com/pret/pokecrystal/blob/41d5ea0482f4ef577df600d2d8b5cad70f74a396/constants/script_constants.asm#L115
Recommendation:
OBJECT_EVENT_SIZE
should be defined by themap_object
struct. Example:EDIT: To re-iterate the importance of this, you can't reorder/add/remove items from the
object_event
macro without also modifying themap_object
struct.