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
|
/* SPDX-License-Identifier: MIT */
/*
* konrmdata.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 KONRMDATA_H
#define KONRMDATA_H
#include "konbattle.h"
#include "konparty.h"
#ifdef __cplusplus
extern "C" {
#endif
/*** definition ***/
/* what mzdata writes for the database of an RPG Maker MV or MZ game: enemies and troops here, the states, skills and items
as the tables konbattle.h already has. all of it is indexed by the id the game gives, entry 0 is empty and so is an id that
is not there. the structs are only ever read. a troop's battle events are scripts, the page n of troop t is the label
"t<t>p<n>" in the konscript the converter wrote, counting from 1 */
#define KON_RM_ELEMENTS 16
typedef struct kon_rmEnemyAction {
int skillId;
int conditionType; /* 0 always, 1 turn, 2 hp, 3 mp, 4 state, 5 party level, 6 switch */
int param1, param2; /* turn: a and b, hp and mp: from and to in percent, the others the number to look at */
int rating;
} kon_rmEnemyAction_t;
typedef struct kon_rmDrop {
int kind; /* 1 item, 2 weapon, 3 armor */
int dataId;
int denominator; /* one chance in so many */
} kon_rmDrop_t;
typedef struct kon_rmEnemy {
const char *name;
const char *battlerName; /* the picture, in img/enemies or img/sv_enemies */
int battlerHue;
int params[KON_PARAMS]; /* max hp, max mp, atk, def, mat, mdf, agi, luk */
int exp, gold;
int hit, eva, cri, cev, mev, mrf; /* percents */
int pdr, mdr; /* damage taken from physical and magical hits, percent */
int hrg, mrg, trg;
int elementRate[KON_RM_ELEMENTS]; /* percent, 0 and the ones past the end of the table are no element */
const kon_rmEnemyAction_t *actions;
int actionCount;
const kon_rmDrop_t *drops;
int dropCount;
} kon_rmEnemy_t;
typedef struct kon_rmTroopMember {
int enemyId, x, y, hidden;
} kon_rmTroopMember_t;
/* when a battle event page runs. each condition counts only when its valid flag is 1 */
typedef struct kon_rmTroopPage {
int turnValid, turnA, turnB, turnEnding;
int enemyValid, enemyIndex, enemyHp;
int actorValid, actorId, actorHp;
int switchValid, switchId;
int span; /* 0 once in the battle, 1 once a turn, 2 all the time */
} kon_rmTroopPage_t;
typedef struct kon_rmTroop {
const char *name;
const kon_rmTroopMember_t *members;
int memberCount;
const kon_rmTroopPage_t *pages;
int pageCount;
} kon_rmTroop_t;
/*** actors ***/
/* who the game starts with, by the actor's id. the party module keeps the people that change, this is how they begin: the pictures
they are drawn with, their class, level and what they wear (weapon and armor ids by slot, 0 for nothing) */
typedef struct kon_rmActor {
const char *name, *nickname;
const char *characterName, *faceName, *battlerName;
int characterIndex, faceIndex;
int classId, initialLevel, maxLevel;
int equips[KON_EQUIP_SLOTS];
} kon_rmActor_t;
/* makes actor number index of the party from a table entry, wearing what it starts with. the weapons and armor come into the bag
and are put on, so the bag ends up as it was. weaponBase and armorBase are what the converter wrote (name_WEAPON_BASE and
name_ARMOR_BASE). returns 0 when the class is not in the database */
int kon_rmActorStart(kon_party_t *party, int index, const kon_rmActor_t *actor, int weaponBase, int armorBase);
/*** enemies ***/
/* the battler of an enemy, at full hp and mp. the name is the enemy's */
void kon_rmEnemyBattler(const kon_rmEnemy_t *enemy, kon_battler_t *out);
/* what the game knows about the enemy and the fight, for the actions that have conditions. any of the callbacks can be NULL, which
reads as no, and a skill that is not usable is not picked */
typedef struct kon_rmAi {
int turn;
const kon_battler_t *self;
int partyLevel;
int (*switchOn)(int id, void *user);
int (*usable)(int skillId, void *user);
void *user;
} kon_rmAi_t;
/* the skill the enemy does, picked the way RPG Maker does: of the usable actions whose condition is true, the ones within 2 of
the best rating are drawn by how much they are above that. returns 0 for none. seed is the state of a random generator, any
number but 0 */
int kon_rmEnemyAction(const kon_rmEnemy_t *enemy, const kon_rmAi_t *ai, uint32_t *seed);
/*** troops ***/
/* is the page's condition true. turnEnd is 1 at the end of a turn. enemyHp and actorHp are the percent of hp the enemy and the actor the condition names have, or -1 when
they are not in the fight. turn counts from 1 and a page with a span is the game's to keep track of */
int kon_rmTroopPageReady(const kon_rmTroopPage_t *page, int turn, int turnEnd, int enemyHp, int actorHp, int switchOn);
#ifdef __cplusplus
}
#endif
#endif
|