Talk:DO/CTL/OpCodes
From Dark Omen Wiki
Contents |
Raising and teleporting
Will be added later to the table:
#b5 0, nodeid, flags
True if one of the players regiments is in the circle defined by nodeid and the flags are NOT set (unit_flag1 is used). Typical value for flags is 8192. That is retreat (yellow arrow). If the unit is retreating the event is not triggered.
The use of the 0 is unknown. Only tested in B1_07 (Attack Helmgart). Every #b5 uses 0 and 8192 there...
Short way for:
test_unit_at_node nodeid iftrue test_unit_flags1 8192 iffalse do_something endif endif
#53 nodeid
(necromancer in helmgart has #54 nodeid, not tested if this is the same)
Teleports a regiment. This is used as a part of unit activation (=teleport on the map)
Attention: #53 must be followed by either #55 or #71 or the unit will glitch to the node!
#71 does a simple teleport and #55 does a zombie-raise-animation (only works for zombie sprite)
Basic Unit activation (Trading Post Goblins), not always used:
clear_unit_flag2 2048 ; Activates the Banner graphic (not needed but really useful ;)) #53 24 ; Teleport node (see above) #71 ; Normal Teleport #50 ; Unknown #3c 240, 0 ; Unknown wait_unit_flag1_clear 8
Typical way to block a regiment until the player reaches a special point:
set_r_i 6, 1 ; Set register 6 to 1 do set_wait_time 6 wait #b5 0, 15, 8192 ; Check if player hit node 15 iftrue set_r_i 6, 0 endif #d6 0 ; Unknown, but works with only #b5 of course too... iffalse set_r_i 6, 0 endif test_r_eq_i 6, 0 ; If one of the two above events happened the unit will be spawned whilenot clear_unit_flag2 2048 (rest see above)
The above code is often shared for lots of regiments to allow simultanious spawning of them (at different node id of course ;))
Hm stupid wiki converts # to a enumeration... (1., 2., 3.)
--Ghabry 02:02, 23 February 2010 (UTC)
CTL is a stack machine?
Checking the opcodes and reading the snippets, I get the feeling that CTL is a stack machine, that is, all operations are pushed and popped through the stack. Therefore, all operations push their result to the stack, and f.i. while and whilenot does not check the last operation, as said in the article, but rather the top item of the stack (which usually is the same thing as the last operation, though). I don't know, just thought I'd throw it here and see what you think. So the last code example would be interpreted like this:
do set_wait_time 6 wait #b5 0, 15, 8192 ; Check if player hit node 15, push result iftrue ; ?pop stack?, cmp value set_r_i 6, 0 endif #d6 0 ; ? cmp current value ? iffalse set_r_i 6, 0 endif test_r_eq_i 6, 0 ; Test reg6 against false (0) ; ? Does this push result or set current value ? whilenot ; if ??stack top or current value?? is false goto do
--Mikademus 11:06, 23 February 2010 (UTC)
- No, its not a stack machine. It's way more simple than that. Each unit has its own registers, and additionally, there is a set of global registers. Although, there doesn't seem to be any opcodes to mix the two. The conditions each check a set of flags Rob
Free OpCode Slots?
Are there any never used opcodes? (besides #37 (wait_unit_flag3_set))
I need at least two. It annoys me that unit_flag3 is read only (bad for testing). --Ghabry 19:25, 24 February 2010 (UTC)