Skip to content

0x16 — battle_acquisition_setup

Battle/acquisition setup command. It initializes a global command buffer, writes battle-result/drop fields, and calls CBtlAcquisition::AddDroppedItem.

proven— handler traced, and exercised by at least one shipped script.

At a glance

Opcode0x16 (22)
HandlerCRadiScript::Command_16
SignatureCRadiScript::Command_16(int,SCR_DATA*,unsigned int,unsigned int)
Translation unitr_script_run0.cpp
Address— debug build; click for all 3
Handler size0x348 (840 bytes)
Engine namebattle_acquisition_setup
FamilyScript control, flags and values
Command size4 + extra_words * 4 bytes

Handler behaviour

Battle/acquisition setup command. It initializes a global command buffer, writes battle-result/drop fields, and calls CBtlAcquisition::AddDroppedItem.

Encoding

The command header is one 32-bit word, as described in §3 Instruction encoding:

 31            24 23            16 15             8 7              0
+----------------+----------------+----------------+----------------+
|  flags         |  argument byte |  extra words   |  0x16          |
+----------------+----------------+----------------+----------------+

Bits 8–15 give the number of 32-bit operand words that follow. Bits 16–23 are handed to the handler as a bitfield; on character commands bit 0 normally says whether a character selector word is present. Bit 31 is the keep-going bit.

Operand fields

15 documented fields. input fields are read from the command's operand words; derived fields are computed from other fields rather than stored separately.

FieldRoleMeaning
battle_bgminputMusic the battle plays.
battle_event_fileinputEvent file the battle loads. Command_16 writes it to app+0x84C, where CGame's battle path passes it to CRadiScript::LoadScriptFile; a non-zero value also makes CBackGround::SettingMap skip the map's own init script.
battle_event_scriptinputScript number inside battle_event_file to run. Written to app+0x84E and passed to CRadiScript::SetScriptNumber as the script selector, which stashes it in the new slot while the file is still loading. Together the two name one script the way the files do: file 500 script 3 is 500_03.
battle_mapinputMap the battle loads.
battle_scriptinputEvent script the battle runs, loaded as id | 0x8000.
finish_check1inputBattle-end condition preset checked by CBtlFinishCheck.
finish_check2inputSecond battle-end condition preset.
finish_check3inputThird battle-end condition preset.
finish_param1inputOperand for finish_check1; its meaning depends on the preset.
finish_param2inputOperand for finish_check2.
finish_param3inputOperand for finish_check3.
option_bit0inputSingle bit of option.
option_bit1inputSingle bit of option.
unused_2824inputWritten to the global at 0x3B2824 and never read: a scan of every module finds exactly one access to that address, this handler's store. Preserved verbatim.
unused_2826inputWritten to the global at 0x3B2826 and never read: a scan of every module finds exactly one access to that address, this handler's store. Preserved verbatim.

Engine calls

Engine functions this handler was observed calling:

  • CBtlAcquisition::AddDroppedItem(unsigned short,int,unsigned short)
  • CCharaPutManager::GetLifeFlag
  • CCharacterManager::GetCharacterSubManager(int)
  • memset

Bit masks

Masks the handler applies to its argument byte or operand words:

0x00FF 0x0001 0x0002 0x7FFF 0x8000