Modding Kamidori
Kamidori-specific facts for the generic guides. The identity block (game id, engine ABI, modules, tables, patch points) is generated in README.md.
Install and options
Section titled “Install and options”The expected install is games/kamidori/ beside the repository: the game with its official updates applied. The English
fan translation is a separate install, games/kamidori-translated/, with its overlay in patch/. Every Ome.Cli
command needs the game options:
| Install | Options |
|---|---|
| untranslated | --game kamidori --game-root ../games/kamidori |
| translated | --game kamidori --game-root ../games/kamidori-translated --overlay-root patch |
-
Port:
.\run-godot.cmd -Kamidori, or.\run-godot.cmd -Kamidori -TranslationPatchfor the translated install. Add-Mod PATHfor a mod. -
Driver, translated:
py -3.11 -X utf8 tools/drive.py --game kamidori --game-root ../games/kamidori-translated port start --mod PATH --port-arg=--overlay-root --port-arg=<absolute path to games\kamidori-translated\patch> --port-arg=--allow-bmp-as-agfThe game’s points include
title.start(Game Start on the title screen) andnewgame.begin(Begin Game on the next screen); define others withpoint NAME X Y. -
Native AGE on the untranslated install shows Japanese dialogs, so
dialogsandansweruse Japanese labels: the close dialog is 終了, withプログラムを終了する(&E),タイトルに戻る(&T),OKandキャンセル. -
The menu bar, the fullscreen strip and the 終了 dialog are the port’s own, so both installs have them. The driver reads and answers 終了 by its Japanese texts on the port, whatever language it shows. On native AGE, the translated install’s
agerc.dllshows 終了 in English: Quit, withExit(&E),'Return to title(&T)',OKandCancel. -
設定, バージョン情報 and 動作環境 are the port’s own options panel, so both installs have them, although the untranslated install’s
AGERC.DLLis packed. While CONFIG runs (op0x142’s gate is 0) its メッセージ, サウンド and その他 sections are read-only, as native’s 設定 cannot open then. The port’s shell is Japanese unlessOME.INI’sui:Languageor--language enpicks English; native AGE on the translated install shows itsagerc.dll’s English. The driver’soptionandoptionssteps set and list them on both targets without labels, andtools/drive/scenarios/kamidori-shell.stepschecks 終了 and three options on the clean install. -
Registries for fragments:
py -3.11 -X utf8 tools/globals_build.py --game kamidori --build.
The translation is a different base
Section titled “The translation is a different base”The translation replaces scripts such as SC0000.bin with translated ones, which have different bytes and
offsets. A fragment matches one of them only. Print fingerprints and decompile with the same options you play
with, and ship two fragments if the mod should work on both.
SC0000.BIN |
Fingerprint |
|---|---|
| translated | sha256:54d6bc4d8cf85e32903808979d16ff851f10e62f06dcb8ab87bc8076a31c1e30 |
| untranslated | sha256:e8db06e1287c557533e93380084358dbc28beb684b3344f3890852514ad97f58 |
Both installs hold loose $n$*.BIN append records in their root. AGE loads a root-loose $n$ file in place of
the append catalog’s record of that name, and so does the port, with or without --overlay-root patch. The
untranslated install has 17 of them, its official data updates (ITINIT, SKINIT, SCJUMP and others); fingerprint and
decompile those records from the root file. The translated install replaces 11 of the 17 and adds 75 more, so
append content shows in English there with or without the overlay (../../asset-resolution-re.md). The translated
records’ strings are partly damaged, so do not copy code from them.
The translation as a language package
Section titled “The translation as a language package”One command turns the translated install into a package that shows the untranslated install in English in the port (languages.md, “From a translation made in place”):
Ome.Cli omp text import-scripts --game kamidori --game-root ../games/kamidori --from ../games/kamidori-translated --overlay-root patch --allow-bmp-as-agf --output build/games/kamidori/import-en --package --verify- The package holds 48,586 entries in 217 catalog files and 232 images: 207 from
patch/, and the 25$n$append images from the translated root. All of them are BMPs under AGF names, written as PNG. - The manifest’s
glyph_delay_scalecomes out at 0.48. - Play it with
.\run-godot.cmd -Kamidori -Mod build\games\kamidori\import-en, and choose English in the options panel’s OME section (or pass--language ento the port). - Keep it under
build/. It is the translators’ work, for playing on your own machine only. - Kamidori’s text font is the player’s choice in its config screen (
CONFIG2: メイリオ, MS ゴシック or MS 明朝), kept inSAVE.DAT. The clean install starts with メイリオ, a proportional face (MS 明朝 where it is missing). The translated install’sINITCONFIGandCHECKCONFIGsettle on MS ゴシック instead. Those are face names, not text, so the importer reports them and carries none: to play in the translated install’s face, choose MS ゴシック in the config screen. SYSTEM4selects aspect mode at boot, so the port lays English out on the cells native AGE gives the same characters (languages.md, “Fonts”). On the pages localization gate 12 compares, every name plate and every run of text starts within a pixel of native AGE on the translated install (../../localization-import-test.md). Stat boxes and item tables are not compared yet (../../backlog.md).
First mod values
Section titled “First mod values”The values for first-mod.md, on the translated opening scene:
| Step | Value |
|---|---|
| Page | The prologue’s first page. |
| Site | 0xd0a |
| Fingerprint | the translated one above |
oms 1patch "SC0000.BIN" fingerprint "sha256:54d6bc4d8cf85e32903808979d16ff851f10e62f06dcb8ab87bc8076a31c1e30"use kamidori.globalsuse kamidori.adv
before site 0xd0a { "[MOD] Hello from my first mod."}The finished mod is oms/examples/mods/example.kamidori-prologue-line.
Dialogue lines
Section titled “Dialogue lines”The prelude’s template is line(text, speaker = none, voice = none, form = form_name):
"[MOD] A narration line."水那 "「…………」" (voice: 0x1be, form: form_descriptor)form picks what the nameplate shows:
form_name, the default (leave it out);form_alternate;form_descriptor, a description shown before the character is introduced;form_unknown,????.
Speakers come from unit_speaker_names (enum speaker in oms/kamidori/adv.oms).
Data edits
Section titled “Data edits”A data file (../data-files.md) changes the unit, item and skill tables, the quests, recipes,
conditions, stage list, dig tables, character profiles, objectives and glossary, and each floor’s enemies, with no
Lua and no script. kamidori-base accepts the kind kamidori.tables. It applies each file’s boot
tables at kamidori.data.layered, after every layer has written them and before INIT2’s own work reads them, and a
stage’s part each time the floor’s loaders have run: at kamidori.stage.loaded for the floor being played, and at
kamidori.stage.previewed for the stage list’s preview. This one changes the enemy unit 761
(緑プテテット), which appears in the first stage; the comments give the game’s own values:
# data/slimes.toml; the manifest names it with [[data]] kind = "kamidori.tables", file = "slimes.toml"[unit.761]stats.max_hp = 150 # 12experience_reward = 999 # 10drop_chance.drop_1 = 100 # 30-
Tables and fields are those of
../../global-reference-kamidori.md, “Tables”, by the names in itsfieldcolumn. Each table has room for the records below, by id, and the game writes some of them:Table What it holds Records The game writes unitunits: characters and enemies 0 to 999 445 itemitems 0 to 1999 1,318 skillskills 0 to 999 452 questthe quest board (QUINIT) 0 to 1999 187, 20 of them 仮placeholdersrecipealchemy recipes (ALINIT) 0 to 1999 492 conditionconditions such as poison, five levels each (ILINIT) 0 to 29 28 stage_catalogthe stage list: names, gates, rewards (STINIT2) 0 to 999 209 dig_tablewhat a dig point yields (DIINIT) 0 to 199 93 world_areathe world map’s areas: labyrinths, towns and facilities (AMINIT2) 0 to 99 33 character_profilethe character profiles (CIINIT) 0 to 199 43 objectivethe chapter objectives (FAINIT) 0 to 1999 126 glossary_entrythe glossary (VIINIT) 0 to 999 163 elementthe elements’ names (INIT2) 0 to 7 8 terrainthe ground of a floor’s tiles (LAINIT) 0 to 39 31 object_typethe map objects a floor places (OBINIT) 0 to 99 50 cardthe cards a floor’s card points deal (CDINIT2) 0 to 99 85 The stage list’s table is
stage_catalog, sincestagenames a floor’s enemies and objective texts (below). A field with a row takes its columns by the names the reference gives (stats.max_hp,level_names.level_1), and by number only where a column has no name. The reference’sclass_changetable, the block the title-change rules fill, is not one a file writes:kamidori.tablesdoes not edit it, and the shape refuses it. -
The field’s tables are not saved.
element,terrain,object_typeandcardlie past the saved prefix, and no script copies their values into a save: an edit holds while the mod is on and is gone when it is removed. One field decides what a save keeps: a map object type whosestate_modeis 1 has FIELD seed the savedstage_object_persistent_stateof each such object from itsprimary_paramon the floor’s first visit (below). A map object’sbattle_stat_deltashas the columns of a skill’scombat_stat_deltasup toagility; a card’svisual_asset_idis a movie, the animation FIELD plays when the card is dealt. -
Saved fields are refused:
item.inventory_count,item.growth_exp,item.growth_level,item.costume_enhancement_gridanditem.costume_gem_sockets. They lie below the saved prefix, so a load would bring the saved value back over the edit. -
The shape.
kamidori-baseships the kind’s shape,shapes/tables.schema.json, generated from the same record map as the tables above (../data-files.md, “Shapes”). So the link,omp checkandomp buildrefuse a table, field or column the reference does not name, a saved field, an id or a column out of range and a value of the wrong kind, with the file’s line, before the game starts.omp lua-stubs --game kamidoriwrites a copy,kamidori.tables.schema.json, and prints the#:schemaline that points an editor at it. Text that code page 932 cannot encode passes the shape;kamidori-baserefuses it at the file’s first delivery. -
A floor’s enemies are the
stage_enemytable, which a file names through the stage:stage.51.enemy.3is stage 51’s enemy slot 3 (stage ids 1 to 999, of which STINIT writes 1 to 968 and the appends up to 977; slots 0 to 29, of which FIELD reads 1 to 29). Its fields are the reference’s:unit_id(0 for an empty slot),min_level,max_level,auto_level_scale_divisor, the spawn (spawn_tile_xandspawn_tile_y, orspawn_object_slot),faction_id,difficulty_mask,first_visit_only,random_selection_weight, and four rows whose columns have no names and are given by number:movement_routine_set_idsandbattle_routine_set_ids(columns 0 to 2),required_story_flags(0 to 6) andforbidden_story_flags(0 to 4). None of them is saved. -
Which slots the floor places. At a floor’s start FIELD goes through slots 1 to 29 (
FIELD@0xaa5) and skips a slot whose gates fail: an emptyunit_id, adifficulty_maskwithout the current difficulty,first_visit_only2 on a cleared floor, a required story flag not set or a forbidden one set (FIELD@0x49a6). A slot whoserandom_selection_weightis 0 is placed there and then. One whose weight is not 0 joins the pool of the spawner itsspawn_object_slotnames; spawners place from their pools at the floor’s start (FIELD@0xc8a) and send reinforcements from them later (FIELD@0xa040). So an edit shows at the start only on a slot placed then: at ◆開けた涼風西湖畔◆ (stage 51), when シセティカ湖 has just opened (before the first visit to 蒼月の南湖畔), only slot 1, ハルピュア, whose spawner places it. This file puts 緑プテテット there:data/stages.toml [stage.51.enemy.1]unit_id = 761 # 331, ハルピュア; 761 is 緑プテテット -
The stage part holds through the floor. FIELD runs the floor’s loaders at its start, before it places the units, and again each time it is entered again during the floor; INFO’s third tab, アイテム情報, runs them again too when its 獲得地点 view is opened on the floor (below, “FIELD runs the layers more than once a floor”). The part is applied after each run, so the edit changes what the floor places, and the reinforcements a spawner sends later follow it. A save made on the floor keeps the units placed (
battle_unit_unit_ids): loaded without the mod, the table is the floor’s own again, and a unit the edit placed is still on the field. -
The stage list’s preview shows the edit. The stage list (SELSTAGE) runs the loaders of the stage under its cursor for its preview, which lists the enemies whose gates pass, and
stage.previewedis raised after them, so the preview shows a file’s edit. That stage is not being played: nothing is placed, and the list runs them again each time the cursor moves onto another stage. On an install whose SELSTAGE the point does not name,stage.previewedis not raised: the report says so in a note, the part is still applied where the floor is played, and the preview lists the floor’s own enemies. -
INFO’s 獲得地点 view reads no enemy. To find the floors whose dig points yield an item, it runs every stage’s loaders and reads the stages’ objects; it raises no event for those stages, so it reads each floor’s own objects, not a file’s edit of them. Off a floor (INFO opened from the town or the workshop) it raises no event at all and leaves
current_stage_idat 1000. -
A floor’s map objects are the
stage_objecttable, named through the stage as its enemies are:stage.51.object.4is stage 51’s object slot 4 (slots 0 to 49, of which SETOBJ and SELSTAGE read 1 to 49). Its fields are the reference’s:type_id(an OBINIT object type, 0 for an empty slot),tile_xandtile_y,primary_param,secondary_param,base_value,reinforcement_interval_turns,reinforcement_spawn_limit,difficulty_mask, and three rows given by number:required_story_flags(columns 0 to 6),forbidden_story_flags(0 to 4) anduse_story_flags_by_faction(0 to 4). A 採取 point (type 32) or 発掘 point (type 33) gathers from dig table (type - 32) × 100 +primary_param, rollingsecondary_parammaterials a use (FIELD@0x897e,0x899f). The part is applied with the stage’s enemies, each time its loaders run, and none of the table is saved; what a save keeps of an object is apart from it, its uses (stage_object_use_counts) and its state (stage_object_persistent_state, which FIELD@0x83eseeds fromprimary_paramon a floor’s first visit). -
A stage’s objective texts are the
stage_rewardtable, named through the stage as its enemies are:stage.51.reward.2.condition_textnames the condition of stage 51’s objective reward 2, in the order ofstage_catalog’sobjective_money_rewardsand the other reward rows (records 0 to 3). STINIT writes records 1 to 3 for each stage and leaves record 0 empty: AIM@0x5b4and STAGECLEAR@0x8bedraw a fixed 占有率100% in its place, so a text for record 0 shows nowhere. The part is applied with the stage’s enemies, each time its loaders run, and none of it is saved. -
A character keeps a copy of its definition. When a unit joins, UNITECH copies part of its definition into the character’s saved state (
../../kamidori-data-tables.md, “Runtime character state”), which the game uses from then on. An edit to these fields reaches a character who joins after it, not one who has joined, and what was copied while the mod was on stays in the save when the mod is removed. UNITECH takes the character throughunit.canonical_character_id, refuses one of 100 or more (UNITECH@0x6d), and makes the first join’s copies when the character’scharacter_levelsis 0 (UNITECH@0x13a).example.kamidori-unit-statsraises ウィル’s maximum HP:tools/drive/scenarios/port/kamidori-unit-stats.stepsloads a save made after he joined with it (below, “Examples”), where his definition holds the edit and his saved stats the save’s own.Field Saved value When unit.default_costume_item_idcharacter_costume_item_id, and the costume itselfeach join of a character with no costume yet or at level 0 ( UNITECH@0xf7); the costume, through ADDITEM, when the inventory has none (UNITECH@0x129)unit.initial_party_capacityparty_cost_capacitycharacter 1’s first join ( UNITECH@0x156)unit.party_costcharacter_party_costthe first join ( UNITECH@0x169)unit.initial_affinity_tenthscharacter_affinity, times 10the first join ( UNITECH@0x17c)unit.starting_levelcharacter_levelsthe first join ( UNITECH@0x191)unit.initial_weapon_levelcharacter_weapon_levelthe first join ( UNITECH@0x1b0)unit.statscharacter_stats, all 14 columnsthe first join ( UNITECH@0x1e1)unit.initial_stat_capscharacter_stat_capsthe first join ( UNITECH@0x208)unit.element_resistancecharacter_resistancesthe first join ( UNITECH@0x22f)unit.skillcharacter_skill_list, withcharacter_learned_skill_flagsset for each, and the first four in the roster slot’sroster_equipped_skill_idsthe first join ( UNITECH@0x256,0x2a7); the roster’s copy at the character’s first place in the roster (UNITECH@0x4fe)unit.initial_class_titlecharacter_class_titlesthe first join ( UNITECH@0x3ac)unit.initial_equipmentthe roster slot’s roster_equipment_item_idsthe character’s first place in the roster ( character_join_flagsbit 0 clear,UNITECH@0x417; the copy at0x4ac), and a new game’s first party (GAMESTART@0xb0d)unit.stat_growthcharacter_statsandcharacter_stat_growth_fractionsthe first join, for each level it adds past the starting level ( UNITECH@0x325), and each level up (ADDEXP@0x2a5). The rate is read each time, so an edit changes later levels’ growth, and the growth already added stays -
The battle units are copies too. When FIELD places a unit, SETEN (an enemy) or SETCH (a character) writes its battle slot (the
battle_unit_*arrays) from the tables: an enemy’s level from its slot’smin_level,max_levelandauto_level_scale_divisorand the unit’sstarting_level,level_capandauto_level_scale_divisor, and itsstats,element_resistance,skill,initial_equipment,party_cost,graphicandinitial_class_title, with the slot’smovement_routine_set_idsandbattle_routine_set_ids; a character’s from its saved state above, withunit.graphicand its costume’sitem.costume_graphic_asset_ids. CALCREVISE works out the effective values from the equipment and skills (item.stat_modifiers,min_range,max_range,critical_rate_bonus,affinity_level_deltas,costume_battle_variantandgranted_skill_id, the skills’ ranges,unit.cutin_element), and EQUIP the condition floors (item.equipped_condition_levels, intounit_condition_baseline_levels). The battle units are saved, so a save made on a floor keeps them as they were placed and worked out, with the mod or without it. -
Play keeps its results, as it does without a mod: while the mod is on, an edit changes what an action gives or costs, and the result is saved.
item.priceis paid fromplayer_moneywhen an item is bought (SHOP), and itssellcolumn is added to it when one is sold (SALE,CHANGEARM@0x103,USEITEM@0x20d) and for the part of a stock past 999 when an item is added (ADDITEM@0x8d);unit.bestiary_knowledge_gainis added tobestiary_knowledge_percentfor each unit beaten (COMMITBTL@0x50e);item.rankis added to a saved tally in the shop’s settlement (G[0x63c89], unnamed,CALCSETTLE@0x4ac), and the settlement’s sales, which CALCSETTLE works out from each item sold’sprice.retail_base(CALCSETTLE@0x4de), to a saved cell (G[0x3698], unnamed,SHOWSETTLE@0x2b);unit.experience_rewardsets the experience a battle awards (COMMITBTL@0x3f9, which ADDEXP adds throughshared_scratch_value), and the levels and stats that follow are saved; anditem.growth_mastery_reward_itemsnames the item added to the inventory when an item’s growth is mastered (CHECKIMPROVE@0x139, through ADDITEM). -
The quest, recipe, condition, stage list, world area and dig tables are read where the game uses them, with these copies into saved state:
condition.duration_turnsgives a condition’s turns when it is applied (unit_condition_remaining_turns,ADDILLSUB@0x193and0x1b1), so a save made on a floor keeps the turns it gave.condition.stat_deltasandcritical_rate_deltaare worked into the battle units’ stats too, but CALCREVISE rebuilds those from scratch each time, so an edit holds from the next recompute.stage_catalog.labyrinth_idandfloor_numberbecomecurrent_labyrinth_idandcurrent_floor_nowhen a floor is entered (FIELD@0x7,ORGANIZE@0xa2e), and the labyrinth becomescurrent_world_area_idwhen an expedition starts (FIELD@0x265).stage_catalog.namebecomes the location title (GS[0x278],FIELD@0x52e), which a save copies into its slot’s label (SAVE@0xd53): the save list shows the name the stage had when the save was made.world_area.namebecomes the location title too, when a town is entered (TOWN@0xc).world_area.travel_daysis added toexpedition_elapsed_dayson entering an area (SELSTAGE@0xc00,TOWN@0x7b, andFIELD@0x271on a fresh labyrinth entry), which a save keeps and the settlement consumes.
Play keeps its results here as well:
- A quest’s appear, clear and failure flags, prerequisite and deadline set its state bits (CHECKCONTRACT), and its
failure_result_flaga story flag. Its rewards are paid once, when it is settled (RECEIPT): reputation intoplayer_evaluation_points,reward_moneyintoplayer_money, and its items into the inventory. - A recipe’s unlock fields decide when it is learned (
CHECKRECIPE@0x1da). The learned flags are never cleared, andalchemy_recipe_ever_learned_flagsis written to the shared profile too, which outlives every save, so a recipe an edit made learnable stays learned without the mod. Crafting takes the ingredients and their quantities and adds the output and mutation items (ALCHEMY@0xaad), with synthesis experience and theevaluation_reward(ALCHEMY@0xba6). - A condition’s susceptibility group, immunity skill and
can_affect_bossesdecide whether it takes hold, and itsresource_deltaschange HP, SP and FS each turn (FIELD@0x9775). - A stage’s flags, prerequisite and labyrinth decide when it is open (
stage_availability_flags,CHECKSTAGE@0x1d, whose bit 0, once set, is never cleared), and its objective rewards are paid at the clear (STAGECLEAR@0xcf9). - A dig table decides what a dig point yields, added to the inventory after the floor (
REWARD@0x944).
The character profiles, objectives and glossary are only shown: nothing of them is copied.
-
Every other field is read where the game uses it, so an edit reaches a save made before it. These lists come from a scan of the installed scripts that follows each field’s value through a script’s locals and block copies into a cell the save keeps, and into a global it leaves for a script it calls or takes back from one, and from reading each cell it found. The scan does not follow a value left in a global for a script that runs later without being called there (another screen), so a copy made that way can be missing.
-
Old names. No table or field has been renamed yet. When one is, the old name keeps working until
kamidori-base’s next major version, anddiagnostics/lua.lognames each old name a file uses.
A boot script does the same with OMS (oms/examples/kamidori-gate6/OMSAUTO.oms), and writes the same three cells:
with unit[761] { .stats.max_hp = 150 .experience_reward = 999 .drop_chance.drop_1 = 100}The unit tables sit above the saved range, so boot rebuilds them with the edit on every start, and the edit holds
after loading a save. Saves made before the edit pick it up too. ../../kamidori-data-tables.md explains how the
init scripts fill each table.
Patch points
Section titled “Patch points”kamidori.experience.after_calculation (ADDEXP.BIN) is reached once per experience award, after the costume
bonus. L[0x1] holds the amount the character receives: the amount the caller passes, times 100 plus 25 for each
experience gem (0x118) in the character’s costume sockets, over 100. The point lists both installs’ ADDEXP, which
differ only in two strings:
ADDEXP.BIN |
Fingerprint |
|---|---|
| untranslated | sha256:606b83e952a3ce45ee406a2383710734f1ea707288f5751b5614be50e3edd7b6 |
| translated | sha256:23bb6ac1e1aa83ef248bbacba4cadd71801fa07188aed3938c4768034f52b40b |
oms 1patch "ADDEXP.BIN" fingerprint "sha256:606b83e952a3ce45ee406a2383710734f1ea707288f5751b5614be50e3edd7b6"use kamidori.globals
local int exp @ 0x1
before site kamidori.experience.after_calculation { exp = exp * 2}A fragment names one fingerprint, so this one patches the untranslated install; put the translated fingerprint in a second fragment for the other. A Lua hook or event subscriber names no fingerprint and links on both.
In Lua (../lua.md, “Game names”), kamidori-base gives the game’s tables by name.
require("kamidori-base").table("unit_condition_levels")[unit].charm reads a battle unit’s charm level. The table
has 50 rows, which end where unit_condition_remaining_turns starts. The names are those of
../../global-reference-kamidori.md. Levels and experience belong to the character, not the unit:
character_levels and character_experience are indexed by current_character_id, the unit’s canonical
character.
kamidori-base declares seven game events (../lua.md, “Game events”). The experience award is raised at
the experience point:
| Event | Field | Type | Access | Cell |
|---|---|---|---|---|
kamidori.experience.award |
amount |
int | rw | L[0x1], the experience the character receives |
unit |
int | r | current_unit_id |
|
character |
int | r | current_character_id |
|
level |
int | r | character_levels[current_character_id] |
A subscriber needs no vm. oms/examples/mods/example.kamidori-double-exp-event doubles every award with
event.amount = event.amount * 2, and leaves the same state as the patch above. An amount of 0 or less, or a
character at the level cap, gains no experience. Weapon experience is awarded after the point and does not read the
amount.
The other seven follow the boot, each floor and the stage list. Each is raised where INIT2, FIELD, INFO3 or SELSTAGE
has walked the chains the appends register their handlers in (../../kamidori-data-tables.md, “Hook chains”), so a
handler runs after the base game’s and every append’s. Each point lists both installs’ scripts, which put it at the
same site. Their fields are read-only:
| Event | Raised | Fields |
|---|---|---|
kamidori.data.layered |
kamidori.boot.data_layered (INIT2, after op 0x143): every layer has written its tables, the appends’ included, and the boot has not used them yet |
none |
kamidori.data.ready |
kamidori.boot.data_ready (INIT2’s exit): every data table is built, and INIT2’s own work on them is done |
none |
kamidori.stage.loaded |
kamidori.stage.after_loader (FIELD): every layer’s MPINIT and STINIT have run; kamidori.stage.after_info_reload (INFO3): INFO’s third tab, アイテム情報, has run them again for its 獲得地点 view on the floor. A data file’s stage part is applied there |
stage (current_stage_id) |
kamidori.stage.previewed |
kamidori.stage.after_list_preview (SELSTAGE): the stage list has run every layer’s MPINIT and STINIT for its preview of the stage under its cursor, which is not being played. A data file’s stage part is applied there too |
stage |
kamidori.stage.ready |
kamidori.stage.after_ready_handlers: once per floor, at its start, with the units placed |
stage |
kamidori.stage.round |
kamidori.stage.after_round_handlers: each player turn after the first |
stage, turn (current_stage_turn) |
kamidori.stage.close |
kamidori.stage.after_close_handlers: the floor ends |
stage, result (stage_result: 1 won, 2 lost), turn |
- Edit the boot’s tables at
data.layered. An edit there lands where an append’s edit lands. INIT2’s own work after it writes no record table and reads the edited fields: at the load of a save made on a floor it rebuilds the field, and SETMAPTEX and READICON readunit_canonical_character_id,unit_graphic_asset_idsanditem_costume_graphic_asset_ids. An edit atdata.readycomes after that rebuild. - Data files are applied at
data.layered, among its handlers in load order. A handler atdata.readyruns after every data file, whatever the load order; one that should take its place among them by load order subscribes todata.layered. - A load builds the data tables again and raises
data.layeredanddata.readyagain while it restores (maid.session.restoringis true), so a handler that edits them makes its edit again. - FIELD runs the layers more than once a floor. At a floor’s start (
field_map_continue_mode0) it runs them, places the units and walks the ready chain. When FIELD is entered again during the floor (at the load of a save made on it, for one) it runs them again and raisesstage.loadedagain, but places nothing and raises nostage.ready. INFO’s third tab, アイテム情報 (FIELD’s menu, then INFO), runs every stage’s loaders when its 獲得地点 view is opened for an item, to find the floors whose dig points yield it, then the floor’s again, andstage.loadedis raised after that second run (kamidori.stage.after_info_reload,INFO3@0xd20). A handler that rewrites the layers’ tables makes the same change each time. - The stage list raises
stage.previewed, notstage.loaded. For its preview it runs the loaders of the stage under its cursor (SELSTAGE@0x13d0to0x1405), when it opens, each time the pointer moves onto another stage’s panel or a key moves the cursor, and when the party screen comes back to it without setting out;stage.previewedis raised after each run (kamidori.stage.after_list_preview,SELSTAGE@0x1408), andstageis the stage under the cursor. That stage is not being played, so a handler onstage.loadeddoes not run there. A handler that rewrites the stage’s enemy slots and should change the preview too subscribes to both events, askamidori-basedoes for data files. Work that belongs once to a played floor goes tostage.ready. result. Withdrawing from a free floor (撤退, 探索を終了しますか?) closes it with 1, as winning does, and the floor’s clear screen follows; forfeiting an arena match (試合を放棄しますか?) closes it with 2.
kamidori-base’s helpers (../lua.md, “Game names”):
| Helper | Calls | What it does |
|---|---|---|
give_item(item, count) |
ADDITEM.BIN |
adds count (-999 to 999, 1 when nil) of item item (1 to 1999) as the game does: the count stays at 0 or more, a count past 999 is paid out as money at the item’s price, the item is marked obtained, the skills it grants are learned, and a key item (item_category 1 or 2) sets its story flag. It puts back current_item_id, current_item_count_change, and the shared_loop_index and shared_scratch_value ADDITEM uses, and returns item_inventory_counts[item]. |
Catalogs, scenes and saves
Section titled “Catalogs, scenes and saves”- Selectors. The install ships three append catalogs (
APPEND01–03), so a first mod’s catalog normally gets selector 4. - Scene registry. SCJUMP decision 0 already maps to SC0000. Writing a mod scene into
scjump_scene_script_resource_ids[0x0]replaces the opening instead of preceding it. Pick the decision your scene belongs to. - Untested. No Kamidori save-capable scene mod has been tested yet (
../../backlog.md). Copy the skeleton from one of Kamidori’s own append scenes, and test saving on native AGE as well as in the port. - Free cells. The examples use the string cells
GS[0x9000]andGS[0x9001](oms/examples/kamidori-gate6/).
Examples
Section titled “Examples”| Path | What it shows |
|---|---|
oms/examples/mods/example.kamidori-prologue-line |
a patch against the translated opening |
oms/examples/kamidori-gate6/ |
a boot-time data edit and a script called by packed id |
oms/examples/mods/example.kamidori-double-exp-event |
a Lua subscriber of kamidori.experience.award, without vm |
oms/examples/mods/example.kamidori-stage-enemies |
a data file that edits two floors’ enemy slots, applied at kamidori.stage.loaded and kamidori.stage.previewed; example.kamidori-stage-enemies-mistake is its twin with a mistake no shape can say (a unit name code page 932 cannot encode), which the link takes and the boot reports; tools/drive/scenarios/port/kamidori-stage-enemies*.steps drive both through the stage list’s preview, INFO’s 獲得地点 view, a floor save and its load with the mod and without |
oms/examples/mods/example.kamidori-unit-stats |
a data file that raises ウィル’s maximum HP, which reaches only a character who joins after it; tools/drive/scenarios/port/kamidori-unit-stats.steps loads a save with it |
The Kamidori scenarios start from saves in the clean install’s story: one in ウィルの工房 (the workshop) when シセティカ湖 has just opened, before the first visit to 蒼月の南湖畔, and two on 蒼月の南湖畔 (turns 1 and 5). Each scenario’s header names the save slots it loads. The repository does not ship them: make saves at those places, or change the slots in the scenario.