DO/CTL

From Dark Omen Wiki

(Difference between revisions)
Jump to: navigation, search
(Beginning)
(Finish main article)
Line 28: Line 28:
     saveip  
     saveip  
     goto 7
     goto 7
 +
 +
A line always contains an opcode name (or #xy if the function is unknown) followed by an argument list. For a documentation of the known opcodes see the [[DO/CTL/OpCodes|opcodes subarticle]].
The script is connected via ARM and BTB file (Chunk <6000>):
The script is connected via ARM and BTB file (Chunk <6000>):
[[File:Armbtbctl.png‎]]
[[File:Armbtbctl.png‎]]
 +
 +
== Event handling ==
 +
 +
Every unit executes an event handler to allow communication between the regiments. It gets assigned with the command set_event_handler following the function. In the example above the handler would be function 15. All events are stored in a global message queue and have the following structure:
 +
 +
struct EventMessage {
 +
  DWORD targetId;
 +
  DWORD eventId;
 +
  DWORD arg1; // usually the source
 +
  DWORD arg2;
 +
  DWORD arg3;
 +
  DWORD arg4;
 +
  DWORD arg5;
 +
  DWORD indexLast; // -1 if the msg was handled
 +
}
 +
 +
Most functions set arg1 to the id of the sender. The id is an incrementing number starting with 0. At first the enemies get an id (in ARM-file order) followed by the allied units (only the ones available on the map). After the allied units the furniture (like destructable houses) follows. But the furniture does not execute a script function.
 +
 +
For a list of common events see the [[DO/CTL/Events|Event subarticle]].
 +
 +
== CTL Engine Control Flag ==
 +
 +
The status of the CTL-Engine can be altered by setting flags in the Control Flag. Currently only bit 2 is known. It is used by conditional functions to indicate "true".
 +
 +
== Unit Flags ==
 +
 +
The unit flags indicate the current status of the unit, like in combat or retreating. Most flags are still unknown. See the [[DO/CTL/Flags|Flags subarticle]] for a list.

Revision as of 10:55, 8 April 2012

Contents


CTL is the script executed on the battlefield. It's used to control the AI and it implements the logic of all units (also of allied ones). Use CTLdis to modify CTL files.

Structure

A CTL file consists of many functions. On startup every regiment executes one of these functions. Functions starting from 100 are common functions used in all CTL files. Allied units always execute .func 100.

Example of a script function:

.func 2
    init_unit 128
    clear_ctrl_flag 32768
    set_label 43970
    #3c 240, 0
    set_event_handler 15
    #3e 13, 31
    wait_for_deploy 
    saveip 
    goto 7

A line always contains an opcode name (or #xy if the function is unknown) followed by an argument list. For a documentation of the known opcodes see the opcodes subarticle.

The script is connected via ARM and BTB file (Chunk <6000>):

File:Armbtbctl.png‎

Event handling

Every unit executes an event handler to allow communication between the regiments. It gets assigned with the command set_event_handler following the function. In the example above the handler would be function 15. All events are stored in a global message queue and have the following structure:

struct EventMessage {
  DWORD targetId;
  DWORD eventId;
  DWORD arg1; // usually the source
  DWORD arg2;
  DWORD arg3;
  DWORD arg4;
  DWORD arg5;
  DWORD indexLast; // -1 if the msg was handled
}

Most functions set arg1 to the id of the sender. The id is an incrementing number starting with 0. At first the enemies get an id (in ARM-file order) followed by the allied units (only the ones available on the map). After the allied units the furniture (like destructable houses) follows. But the furniture does not execute a script function.

For a list of common events see the Event subarticle.

CTL Engine Control Flag

The status of the CTL-Engine can be altered by setting flags in the Control Flag. Currently only bit 2 is known. It is used by conditional functions to indicate "true".

Unit Flags

The unit flags indicate the current status of the unit, like in combat or retreating. Most flags are still unknown. See the Flags subarticle for a list.

Personal tools
communication