• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

wtg 7 file format

Status
Not open for further replies.
Level 26
Joined
Aug 18, 2009
Messages
4,097
I am trying to parse the gui trigger file format of TFT (version 7) and have not fully succeeded.

According to http://www.wc3c.net/tools/specs/index.html

it's as following:

Code:
[COLOR="Wheat"]char[4]: file ID (WTG!)
int: wtg file format version = 7
int: number "a" of triggers categories
"a" times a category definition structure*
int: number "b" ???
int: number "c" of variables
"c" times a variable definition structure**
int: number "d" of triggers
"d" times a trigger definition structure***[/COLOR]

[COLOR="Teal"][B][U]*Category Definition Structure:[/U][/B]
int: category index
String: category name
int: Category type: 0=normal, 1=comment[/COLOR]

[COLOR="DarkOrchid"][B][U]**Variable Definition Structure:[/U][/B]
String: variable name
String: variable type
int: number "e" ???
int: array status: 0=not an array, 1=array
int: array size
int: initialisation status: 0=not initialized, 1=initialized
String: initial value (string)[/COLOR]

[COLOR="YellowGreen"][B][U]***Triggers Definiton Structure:[/U][/B]
String: trigger name
String: trigger description
int: trigger type: 0=normal, 1=comment
int: enable state: 0=disabled, 1=enabled
int: custom text trigger state: 0=not a custom text trigger, 1=custom text trigger (use data in the WCT)
int: initial state: 0=initially on, 1=not initially on
int: run on map initialization: 0=no, 1=yes
int: index of the category the trigger belongs to
int: number "i" of event-condition-action (ECA) function
"i" times an ECA function definition structure*(4) (if it's a custom text trigger it should be 0 so we don't have this section)[/COLOR]

[COLOR="Magenta"][B][U]*(4)ECA function definition structure[/U][/B]
int: function type: 0=event, 1=condition, 2=action
String: function name
int: enable state: 0=function disabled, 1=function enabled
"x" times a parameter structure*(5). x depends of the function and is hardcoded.
int: ???
int: number "i" of event-condition-action (ECA) function
"i" times an ECA function definition structure*(4)(if this trigger doesn't have multiple actions it should be set to 0 so we don't have this section)[/COLOR]

[COLOR="DarkOrange"][B][U]*(5)Parameters Structure:[/U][/B]
int: type which can be 0=preset, 1=variable, 2=function, 3=string
String: parameter value
int: begin function (if it is function it should be set to 1 otherwise to 0)
���� if begin function is set to 1:
���� int: type: 3
���� String: the same as parameter value
���� int: begin function: 1
���� "x" times a parameters structure*(5). x depends on the function and is hardcoded.
int: end function (always set to 0)[/COLOR]

As you may see, ECA (event/condition/action) structures may be nested. This is the case with loops or other blocks. However, my issue is that the int: ??? seems to be missing or displaced sometimes.

The definition stated here, which is of version 4, says:

Code:
[COLOR="Magenta"]int: Function type: 0 = Event, 1 = Condition, 2 = Action
String: Function name
int: Enable state: 0 = Function disabled, 1 = Function enabled
"x"times a Parameter Structure. "x"depends of the function and is stored in UI\TriggerData.txt*

int: Number "i" of ECA Function Definition Structures
If this function has no parent or if it is the last of a function structure and all it's parents it's the last) read the following:

    If the number "i" of ECA Function Definition Structures is not
    0 then read the following:

        int: 2 (???) 

"i" times an ECA Function Definition Structure (If this trigger doesn't have multiple actions it should be set to 0 so we don't have this section)[/COLOR]

So there, the/an unknown int would be after the amount of ECAs and exists only under special conditions* (that I cannot confirm either).

*(has no parent ECA OR it's the last defined child of the whole hierarchy except its own children) AND has at least 1 child itself

The example code I am currently looking at:

  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Do nothing
translates to this byte code (I omitted header, variables and the previous part of the trigger since those values are all okay and only the ECAs follow):

Code:
02 00 00 00 46 6F 72 4C 6F 6F 70 41 4D 75 6C 74
69 70 6C 65 00 01 00 00 00 03 00 00 00 31 00 00
00 00 00 00 00 00 00 03 00 00 00 31 30 00 00 00
00 00 00 00 00 00 01 00 00 00 02 00 00 00 00 00
00 00 44 6F 4E 6F 74 68 69 6E 67 00 01 00 00 00
00 00 00 00

Code:
02 00 00 00 -> type = action
46 6F 72 4C 6F 6F 70 41 4D 75 6C 74 69 70 6C 65 00 -> funcName = ForLoopAMultiple
01 00 00 00 -> enabled = true

ForLoopAMultiple's 2 params:

param1:
03 00 00 00 -> type = string
31 00 -> value = 1
00 00 00 00 -> begin function = no
00 00 00 00 -> end token

param2:
03 00 00 00 -> type = string
31 30 00 -> value = 10
00 00 00 00 -> begin function = no
00 00 00 00 -> end token

->return to ForLoopAMultiple-ECA

01 00 00 00 -> amount of children = 1

child:
02 00 00 00 -> type = action

[COLOR="Red"]00 00 00 00 -> what is this?[/COLOR]

44 6F 4E 6F 74 68 69 6E 67 00 -> funcName = DoNothing
01 00 00 00 -> enabled = true
00 00 00 00 -> amount of children = 0

There should not be a number between type and funcName of an ECA. Of course I am assuming that 02 00 00 00 is the type here because otherwise it could be only the ??? int and the 00 00 00 00 would represent the DoNothing-ECA as an event, which is tosh.
 
Level 5
Joined
May 6, 2013
Messages
125
Wondered me indeed, so i disassembled the world editor to look where the number comes from. What i found out:
- The Assemblercode clearly shows some features and when they were added (eg, enabling/disabling triggers came with version 3). This one was introduced in version 6.
- This number is Part of what you call "child" functions. In fact, it recursively calls the function that prints a "ECA function definition structure". The Value is printed directly before the recursive ECA call; therefor, it is always there if your function is part of a "multiple actions" block (which would explain why it came with version 6, as only tft came with multiple actions GUI functions), or "child function" how you called it
- Much like the amount of parameters, which is hardcoded at FunctionStruct+0x128, this number comes from FunctionStruct+0x154, so it as well is a hardcoded value it seems
- The FunctionStructs are dynamically created when you alter things in the GUI, therefor, this number is not (only) depended of the kind of action
- By testing some funtions, i found out that it is:
--> 0 for pick-every-unit, and i guess for that matter, every function that is translated into calling a different function
--> 1 for "THEN-Actions"
--> 2 for "ELSE-Actions"

thats all i found out. hope it helps.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The exceptions for boolexpr/boolcall/eventcall/code parameters described in http://www.wc3c.net/zoxc/mapformat/wtg_w3x.htm are true, as well as the variable array indexing, which was left out in the other source. But I want to note that there is an additional int endToken in the beginFunction block in the parameter structure. Also the special ECAs, since they are within parameters, of course they do not possess a branch/there is no need to state it.
 
Status
Not open for further replies.
Top