Skip to content

0x15 — script_defaults

Sets script defaults. It calls SetDefaultCharacter, optionally sourcing the character id through GetEventValueForScript, and can call SetDefaultObjectName.

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

At a glance

Opcode0x15 (21)
HandlerCRadiScript::Command_15
SignatureCRadiScript::Command_15(int,SCR_DATA*,unsigned int,unsigned int)
Translation unitr_script_run0.cpp
Address— debug build; click for all 3
Handler size0xB8 (184 bytes)
Engine namescript_defaults
FamilyScript control, flags and values
Command size4 + extra_words * 4 bytes

Handler behaviour

Sets script defaults. It calls SetDefaultCharacter, optionally sourcing the character id through GetEventValueForScript, and can call SetDefaultObjectName.

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   |  0x15          |
+----------------+----------------+----------------+----------------+

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

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

FieldRoleMeaning
characterinputThe packed 32-bit character selector word. Its low half is the character id and byte 2 is a secondary class/variant input; see character_number and character_variant.
character_variantinputByte 2 of the character selector: a secondary character/class input passed alongside the id.
default_charderivedArgument-byte bit 0: whether a character selector word follows, which then becomes this script's default character. It is a gate, not a character id — default_char=1 means "a character is given below", not character 1.
default_objectderivedArgument-byte bit 1: whether a default object name follows, setting the name later commands act on when they are not given one.
event_charderivedArgument-byte bit 7: read the default character from an event value instead of taking it literally. It changes what the following word means, which is why the line then prints event_value= rather than character=.
event_valueinputScript event-value id that the condition or command reads.
yieldderivedPause the script here for one game frame; the next command runs on the following update. Lines without it keep running immediately.

Engine calls

Engine functions this handler was observed calling:

  • CRadiScript::GetEventValueForScript(int,const SCR_DATA*)
  • CRadiScript::SetDefaultCharacter(unsigned int,unsigned int,unsigned int)
  • CRadiScript::SetDefaultObjectName(int,const char*)

Bit masks

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

0x0001 0x0080 0xFFFF 0x00FF 0x0002