1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/* SPDX-License-Identifier: MIT */
/*
* konrmmap.h
*
* Copyright (c) 2026 KonAki
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef KONRMMAP_H
#define KONRMMAP_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*** definition ***/
/* what mzmap writes for a map of an RPG Maker MV or MZ game: all of it const data, so it can sit in the program as it is.
the structs are only ever read. the event scripts are not in here, a page names the label of its script in the konscript
the converter wrote next to it ("m3e12p1" is map 3, event 12, page 1) */
#define KON_RM_LAYERS 6 /* four tile layers, then shadows, then regions */
typedef struct kon_rmPage {
/* conditions, each used only when its flag is 1 */
uint8_t hasSwitch1, hasSwitch2, hasVariable, hasSelfSwitch, hasItem, hasActor;
char selfSwitch; /* 'A' to 'D' */
int switch1, switch2, variable, variableValue, item, actor;
/* a character sheet, or a tile of the map's tileset when tileId is not 0 */
const char *characterName;
int characterIndex, direction, pattern, tileId;
uint8_t moveType; /* 0 fixed, 1 random, 2 approach, 3 custom */
uint8_t moveSpeed, moveFrequency;
uint8_t priority; /* 0 under the characters, 1 same as them, 2 over them */
uint8_t trigger; /* 0 action button, 1 player touch, 2 event touch, 3 autorun, 4 parallel */
uint8_t walkAnime, stepAnime, directionFix, through;
uint8_t routeRepeat, routeSkippable, routeWait;
const char *script;
/* the custom move route, a command and its numbers after each other: code, count, count numbers. a count of 0
for a command that had text, which is not kept. empty for none */
const int32_t *route;
int routeSize;
} kon_rmPage_t;
typedef struct kon_rmEvent {
int id;
const char *name;
int x, y;
const kon_rmPage_t *pages;
int pageCount;
} kon_rmEvent_t;
typedef struct kon_rmEncounter {
int troopId;
int weight;
const int *regions; /* where it can happen, none means everywhere */
int regionCount;
} kon_rmEncounter_t;
typedef struct kon_rmAudio {
const char *name; /* "" for none */
int volume, pitch, pan;
} kon_rmAudio_t;
typedef struct kon_rmMap {
int id;
int width, height;
int tilesetId;
const uint16_t *tiles; /* the layers one after the other, each width * height, row by row */
const char *displayName;
const char *note;
int scrollType; /* 0 none, 1 loops up and down, 2 loops left and right, 3 both */
int disableDashing;
int autoplayBgm, autoplayBgs;
kon_rmAudio_t bgm, bgs;
const char *parallaxName;
int parallaxLoopX, parallaxLoopY, parallaxSx, parallaxSy, parallaxShow;
int encounterStep;
const kon_rmEncounter_t *encounters;
int encounterCount;
const kon_rmEvent_t *events;
int eventCount;
} kon_rmMap_t;
typedef struct kon_rmTileset {
int id;
int mode; /* 0 for the world map, 1 for the others */
const char *names[9]; /* A1 to A5, then B to E, "" when there is none */
const uint16_t *flags;
int flagCount;
} kon_rmTileset_t;
typedef struct kon_rmSystem {
const char *title;
int startMapId, startX, startY;
const int *party;
int partyCount;
int switchCount, variableCount;
int optFollowers, optTransparent;
int windowTone[3];
} kon_rmSystem_t;
/*** pages ***/
/* what a page needs to know about the game to be switched on. any of them can be NULL, which reads as off, 0 and no */
typedef struct kon_rmState {
int (*switchOn)(int id, void *user);
int (*variable)(int id, void *user);
int (*selfSwitch)(int mapId, int eventId, char letter, void *user);
int (*hasItem)(int id, void *user);
int (*hasActor)(int id, void *user);
void *user;
} kon_rmState_t;
/* the page an event is showing, like RPG Maker picks it: the last one that has all its conditions, counted from the end.
returns -1 when none of them do, then the event is not on the map at all */
int kon_rmEventPage(const kon_rmEvent_t *event, int mapId, const kon_rmState_t *state);
/*** tiles ***/
/* layer is 0 to 5, the four tile layers, the shadows and the regions. 0 outside of the map or for a layer that is not there */
int kon_rmTile(const kon_rmMap_t *map, int layer, int x, int y);
#ifdef __cplusplus
}
#endif
#endif
|