/* 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" #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 "tp" 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; /*** 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