.mgx format

The mgx file consists of compressed header data and body data.

Data Type byte Description
bool 1 byte 0 or 1
BOOL 4 byte 0 or 1
char 1 byte  
short 2 byte  
int 4 byte  
float 4 byte  
double 8 byte  
String variable length(2 byte) + length byte
POINT 8 byte (int x, int y)
The hex data's byte order in mgx format is little endian.

mgx file

Data Type Name byte Description
Header header -  
  int header_len 4 Length of Header structure(header_len + next_pos + compressed_data)
int next_pos 4 Address of next Header structure. set to 0x00 if next header does not exist.
(This data does not exist in .mgl format)
char compressed_data[header_len - 8] var it contains player info, map setting, scenario data, and etc. need to uncompress. (zlib deflate function compress)
(compressed_data structure is the same as .gax file format)
Body body -  
  Operation operation[?] var Stream data. The data end is end of file.
  int type 4 Type of ope_data (1, 2 or 4)
union Ope_data ope_data var  

compressed_data

Data Type Name byte Description
char version[8] 4 "VER 9.4":AOC, "VER 9.3":AOK, "TRL 9.3":AOK Trial version
char unknown_const[4] 4 "F6 28 3C 41"
BOOL include_ai 4 0x00:No AI data is included, 0x01:AI data is included
AI_info ai_info[include_ai] var  
  String_table string_table - All AI's string resouces is in it.
  short unknown 2  
short num_string 2 number of strings
int unknown2 4  
Resource_string resource_string[num_string] var  
  int string_length 4  
char str[string_length] var  
char unknown3[6] 6 "78 00 64 00 08 00"
AI_data ai_data[8] - Compiled AI script data.
  int unknown 4  
int seq 4 Set to -1 if invalid AI data.
short max_rules 2 Max defrules. always 1000.
short num_rule 2 Number of defrules in AI script
int unknown2 4  
Rule rule[num_rule] var defrule data
  char unknown[12] 12  
char num_fact 1 number of fact
char num_fact_action 1 number of fact + action
short zero 2  
Data data[16] -  
  int type 4 01:action, 02:not/and/or, 03:condition
short id 2  
short unknown 2  
int param1 4  
int param2 4  
int param3 4  
int param4 4  
char unknown[104] 104  
Timers timers[8] - set value for each timer. not elapsed time. (for 8 player)
  int timer1 4  
int timer2 4  
int timer3 4  
int timer4 4  
int timer5 4  
int timer6 4  
int timer7 4  
int timer8 4  
int timer9 4  
int timer10 4  
int shared_goal[256] 1024  
int zero[1024] 4096  
int unknown 4  
int game_speed1 4 100:slow, 150:midium, 200:fast
int zero 4  
int game_speed2 4 100:slow, 150:midium, 200:fast
float unknown2 4  
int unknown3 4  
char unknown4[17] 17  
short rec_player_ref 2 player number of this record game's owner
char num_player 1 number of players + 1
int zero2 4  
char negative[12] 12  
char unknown5[14] 14  
int unknown6[8] 32  
int map_size_x 4  
int map_size_y 4  
int num_unknown_data 4  
Unknown_data unknown_data[num_unknown_data] var  
  char negative[255] 255  
int zero[255] 1020  
char zero2[map_size_x][map_size_y] var  
int num_float 4 usually 41
float unknown[num_float] var  
int unknown2 4  
char unknown7[2] 2  
Map map[map_size_x][map_size_y] var Map data
  char terrain_id 1  
char elevation 1  
char unknown8[120] 120  
int map_size_x2 4  
int map_size_y2 4  
int unknown9[map_size_x][map_size_y] var  
int zero3[2] 8  
char unknown_const2[7] 7 "98 9E 00 00 02 0B"
Player_info player_info[num_player] var index 0 is GAIA data
  char diplomacy_from[num_player] var index 0 is diplomacy from GAIA (0:ally or self, 3:enemy)
int diplomacy_to[9] 36 index 0 is diplomacy to GAIA
(0:GAIA, 1:self, 2:ally, 3:neutral, 4:enemy, -1:invalid player)
char zero[5] 5  
String player_name var player0's name is "GAIA".
char unknown1 1  
int num_header_data 4 198. number of civ_header float data
char unknown2 1  
Civ_header civ_header -  
  float food 4 food amount on hand
float wood 4 wood amount on hand
float stone 4 stone amount on hand
float gold 4 gold amoutn on hand
float headroom 4 (house capacity - population). negative value when Nomad map.
float data5 4  
float data6 4  
float data7 4  
float data8 4  
float data9 4  
float data10 4  
float population 4  
float data12_31[20] 80  
float max_pop 4 210 if Gothic and Impeiral age start.
float data33 4  
float data34 4  
float data35 4  
float farm_food_amount 4 depend on starting age and players civ.
float civilian_pop 4 villager, fish boat or etc.
float data38 4  
float data39 4  
float military_pop 4 military population
float data41_90[50] 200  
float food_bonus 4 civ bonus amount. For example, -200 if the player is Chinese Civ.
float wood_bonus 4 civ bonus amount. For example, 50 if the player is Persian Civ.
float stone_bonus 4 civ bonus amount.
float gold_bonus 4 civ bonus amount.
float data95_197[103] 412  
char unknown3 1 0x0b
float unknown4[2] 8  
char unknown5[9] 9  
char civilization 1  
char unknown9[3] 3  
char player_color 1 0x00:blue, 0x01:red, 0x02:green, etc.
char unknown10[4183] 4183  
float unknown11 4  
int num_research 4 always 460
short zero3 2  
Research_stat research_stat[num_research] var  
  short status 2  
char unknown[12] 12  
char long_unknown_data[?] ?  
int zero4 4  
int learn_len 4 set to 0 if learn_file is not used. Only used in scenario game?
char learn_file[learn_len] var For example, "learn\xxxxx.scxUsername.1"
char unknown12[?] ?  
char unknown13[80] 80  
int ai_filename_len 4  
char ai_filename[ai_filename_len] var "RandomGame" : standard AI,
"C:\Docume~1\user_name\Loacal~1\temp\temp_Airules1.tmp": AI in scenario
char unknown14[?] ?  
int num_object 4 always 866 (number of unit type)
int obj_exist_flg[num_object] var 0x00000000 or 0x00000001
char unknown15[2] 2  
master_object Master_Object[var] var all unit data without obj_exist_flg = 0 is included
  char object_type 1 10, 20, 30, 70 or 80
short unit_id 2  
short unknown_id[2] 4  
short unit_class 2  
char unknown2[6] 6  
union Object object var  
  Type10 type10 -  
  char unknown[24] 24  
Type30 type30 -  
  char unknown[32] 32  
Type60 type60 -  
  short HP 2  
float LOS 4  
char unknown 1  
float size_x 4  
float size_y 4  
char unknown2[7] 7  
float move_rate 4  
int unknown3 4  
float search_range 4  
float unknown4 4  
short unknown5 2  
char unknown6[10] 10  
float unknown7 4  
char unknown8[5] 5  
int neg 4  
float unknown8 4  
char unknown9[11] 11  
Type70 type70 -  
  short HP 2 hit point
float LOS 4 line of sight
float size_x 4  
float size_y 4  
short unknown3 2  
float unknown4 4  
float move_rate 4  
int unknown5 4  
float search_range 4  
float unknown6 4  
short unknown7 2  
Attack attack[attack_length] var  
Armour armour[armour_length] var  
float attack_range 4  
float unknown8 4  
short accuracy_pct 2 accuracy percent of range unit
short projectile 2 projectile object ID
short unknown9 2  
float unknown10 4  
int zero[2] 8  
short cost_01_type 2 0=food, 1=wood, 2=stone, 3=gold
short cost_01_amount 2  
short cost_01_used 2  
short cost_02_type 2 0=food, 1=wood, 2=stone, 3=gold
short cost_02_amount 2  
short cost_02_used 2  
short cost_03_type 2 0=food, 1=wood, 2=stone, 3=gold
short cost_03_amount 2  
short cost_03_used 2  
short training_time 2  
float unknown11 4  
char unknown12[3] 3  
Type80 type80 -  
  short HP 2  
float LOS 4  
int unknown[4] 16  
float move_rate 4  
int unknown2 4  
float search_range 4  
float unknown3 4  
short unknown4 2  
char unknown5[48] 48  
float unknown6 4  
char unknown7[5] 5  
int map_size_x 4  
int map_size_y 4  
char unknown16[6] 6  
char los[map_size_x][map_size_y] var line of sight area. set to 1 or more if the location is in sight.
int constant 4 usually 0x00000005
int unknown17 4  
int num_unknown 4  
int unknown18[8] 32  
Unknown_Data unknown_Data[num] var  
  int unknown1 4  
int unknown2 4  
short unknown19 2 usually 0x000B
int unknown20 4  
char unknown21[3] 3  
Exist_Object exist_object[?] -  
  char object_type 1 10, 20, 30, 70 or 80
char owner 1 player number
union Object_data object_data var depend on object_type
  Type10 type10 - Gaia object data? only exist if object_type=10
  short unit_id 2  
short unknown 2  
int negative 4  
float hitpoint 4  
int unknown3 4  
int unknown4 4  
char unknown5 1  
float pos_x 4 object location x
float pos_y 4 object location y
float unknown6 4  
short unknown7[4] 8  
short resource_type 2 0x02:stone, 0x03:gold
short amount 2 resouce amount
char unknown8[14] 14  
Type20 type20 - only exist if object_type=20
  short unit_id 2  
short unknown 2  
int negative 4  
float hitpoint 4  
int unknown2 4  
int unknown3 4  
char unknown4 1  
float pos_x 4  
float pos_y 4  
float unknown5 4  
char unknown6[67] 67  
Type70 type70 - Unit data. only exist if object_type=70
  short unit_id 2  
short unknown 2  
int negative 4  
float hitpoint 4  
int unknown2 4  
char unknown3 1  
float pos_x 4  
float pos_y 4  
float unknown5 4  
char unknown6[435 or 673] 435
or
673
673byte if this object is converted sheep
Type80 type80 - Building data. only exist if object_type=80
  short unit_id 2  
short unknown 2  
int negative 4  
float hitpoint 4  
int unknown2 4  
int unknown3 4  
char unknown4 1  
float pos_x 4  
float pos_y 4  
float unknown5 4  
char unknown6[547] 547  
char unknown22[4] 4 "00 00 00 0B"
int unknown23 4 usually 0x00000040
int unknown24 4 usually 0x00000080
char unknown25[?] ?  
Long_unknown long_unknown -  
  char unknown[?] ?  
Achievement achievement[num_player] -  
  char unknown1[13] 13  
int total_point 4  
char unknown2[26] 26  
int war_point 4  
char unknown3[34] 34  
float num_kill 4  
char unknown4[28] 28  
float num_killed 4  
char unknown5[28] 28  
float num_kill2 4  
char unknown7[60] 4  
float num_destroyed_bldg 4  
char unknown8[444] 444  
float total_food 4  
char unknown9[28] 28  
float total_wood 4  
char unknown10[28] 28  
float total_stone 4  
char unknown11[28] 28  
float total_gold 4  
char unknown12[444] 444  
float max_villager 4  
char unknown13[28] 28  
float max_villager2 4  
char unknown14[28] 28  
float relic_castle 4  
char unknown16[28] 28  
float relic_castle2 4  
char unknown17[28] 28  
float wonder 4  
float unknown18[28] 28  
float relic_gold 4  
char unknown19[124] 124  
float researched_tech 4  
char unknown20[28] 28  
float explored_percentage 4  
int neg 4  
Scenario_header scenario_header -  
  int next_unit_id 4 next unit ID
int constant 4  
char player_names[16][256] 4096 player_name in scenario
int string_id[16] 64 player_name string_id in language_x1.dll.
if this is not -1, this string is used instead of "player_names" above.
Player_data1 player_data1[16] - players data in scenario. default value is set if this rec is not scenario game.
  BOOL active 4 0x00:invalid player, 0x01:vaild player
BOOL human 4 human or computer(AI)
int civilization 4  
int constant 4 0x00000004
char unknown[5] 5  
float elapsed_time 4  
String orginial_filename var elapsed time from game start
Instruction instruction -  
  int instruct_string_id 4 instructions string_id in language_x1.dll.
int hints_string_id 4 hints string_id in language_x1.dll.
int victory_string_id 4 victory string_id in language_x1.dll.
int defeat_string_id 4 defeat string_id in language_x1.dll.
int history_string_id 4 history string_id in language_x1.dll.
int scouts_string_id 4 scouts string_id in language_x1.dll.
String instructions var 0 length string data if no instructions
String hints var 0 length string data if no hints
String victory var 0 length string data if no victory
String defeat var 0 length string data if no defeat
String history var 0 length string data if no history
String scouts var 0 length string data if no scouts
String pregame_cinem var pregame cinem file name. 0 length string data if no pregame cinem
String victory_cinem var victory cinem file name. 0 length string data if no victory cinem
String defeat_cinem var defeat cinem file name. 0 length string data if no defeat cinem
String background_image var file name of background image in pregame instructions
BOOL bitmap_included 4 0x00:no bitmap, 0x01:included bitmap
int bitmap_size_x 4  
int bitmap_size_y 4  
short whocares 2  
BITMAPINFOHEADER bmp_info[bitmap_included] 40 only exist if bitmap_included = 1
char bitmap[] var only exist if bitmap_included = 1
depend on bitmap size and BITMAPINFOHEADER data
int nulls[16] 64 0x00000000
Scenario_player scenario_player - player data in scenario. it contains 16 players info
  String ai_name[16] var standard computer AI name is "RandomGame".
AI_file ai_file[16] - AI data included in scenario file.
  int nulls[2] 4  
int file_len 4  
char file[file_len] var AI script text data
int separator 4 "9D FF FF FF"
Resource resource[16] -  
  int gold 4 gold amount at scenario game start
int wood 4 wood amount at scenario game start
int food 4 food amount at scenario game start
int stone 4 stone amount at scenario game start
int nulls[2] 8  
Victory victory - victory condition
  int separator 4 "9D FF FF FF"
BOOL conquest 4 condition for custom, (0x00:not conquest, 0x01:conquest)
int zero1 4  
int relics 4 condition for custom. number of relics
int zero2 4  
int explored 4 condition for custom. percentage of explored map
int zero3 4  
BOOL all 4 0x00:any, 0x01:all
int mode 4 0:normal, 1:conquest, 2:score, 3:time, 4:custom
int score 4  
int time 4  
Long_unknown2 long_unknown2 -  
  int unknown[256] 1024  
int nulls[2880] 11520  
Disables disables - it contains 16 players info
  int separator 4 "9D FF FF FF"
int nulls[16] 64  
int num_techs[16] 64 number of disable technologies for 16 players
int disabled_techs[16][30] 1920 disable technologies id for 16 players. Max disable technologies are 30.
int num_units[16] 64 number of disable units for 16 players
int disabled_units[16][30] 1920 disable units id for 16 players. Max disable units are 30.
int num_buildings[16] 64 number of disable buildings for 16 players
int disabled_bldgs[16][20] 1280 disable buildings id for 16 players. Max disable buildings are 20.
int nulls2[3] 12  
int starting_age[16] 64 starting age in scenario for 16 players. (-1:default, 0:dark age, 1:feudal age, 2:castle age, 3:imperial age, 4:post imperial age)
Game_setting game_setting -  
  int separator 4 "9D FF FF FF"
int negative[2] 8 -1
int map_id 4  
int difficulty 4 difficulty level (0:hardest, 1:hard, 2:moderate, 3:easy, 4:easiest)
int unknown 4  
Player_info player_info[9] - index 0 is GAIA player
  int player_data_index 4 player data index.
player data index become the same number if two players select same player number.
int human 4 0x00:invalid player, 0x02:human, 0x04:computer
int name_len 4  
char playername[name_len] var player name
int zero[9] 36  
int unknown2 4  
char long_unknown_data[?] ?  
float constant1 4 5500
double constant2 8 1.6 (hex "9A 99 99 99 99 99 F9 3F")
Trigger_info trigger_info - trigger data in scenario
  char zero 1  
int num_trigger 4 number of triggers. 0 is set if not scenario game.
Trigger trigger[num_trigger] var  
  BOOL enabled 4  
bool looping 1  
bool objective 1  
int desc_order 4  
int zeros 4  
int desc_len 4  
char description[desc_len] var  
int name_len 4  
char name[name_len] var  
int num_effect 4  
Effect effect[num_effect] var  
  int type 4 effect type
int check 4  
int ai_goal 4  
int amount 4  
int resource 4  
int diplomacy 4  
int num_selected_object 4  
int location_unit 4  
int unit_type 4  
int player_source 4  
int player_target 4  
int technology 4  
int text_id 4  
int unknown 4  
int disp_time 4  
int trig_index 4  
POINT location 8  
POINT area_ll 8  
POINT area_ur 8  
int unit_group 4  
int object_type 4  
int instruction_panel 4  
int text_len
4  
int text[text_len] var  
int sound_len 4  
int sound_file[sound_len] var  
int unit_ids[num_selected_object] var  
int effect_order[num_effect] var  
int num_condition 4  
Condition condition[num_condition] var  
  int type 4 condition type
int check 4  
int amount 4  
int resource 4  
int unit_object 4  
int unit_location 4  
int unit_type 4  
int player 4  
int technology 4  
int timer 4  
int unknown 4  
POINT area_ll 8  
POINT area_ur 8  
int unit_group 4  
int unknown2 4  
int ai_signal 4  
int condition_order[num_condition] var  
int list_order[num_trigger] var  
Other_data other_data -  
  char team[8] 8 (0x01:no team, 0x02:team1, 0x03:team2, 0x04:team3, 0x05:team4)
array index is player number.
char unknown[13] 13  
int pop_limit 4 population limit in game setting.
char game_type 1 0x00:Random map, 0x01:Regiced, 0x02:Death match, 0x03:Senario, 0x04:campaign, 0x05:King of the Hill, 0x06:Wonder race, 0x07:Defend Wonder, 0x08:Turbo Random map
char lock_diplomacy 1 0x01:cannot change diplomacy
int num_chat 4 number of pregame chat. Max num_chat is 50.
Chat_msg chat_msg[num_chat] var Pre-game chat messages
  int chat_len 4 !! 0 length chat exists.
char chat[chat_len] var format is "@#"+ player number + chat message.
!! chat string data is not always null termination.

ope_data

Sync sync - only exist if type=2.
  int time 4 elapse time from prev sync data(milli second).
this number get bigger if it is laggy
int unknown 4 0x00000000 or 0x00000003
int unknown2[7] 28 only exist if unknown = 0x00000000
flaot x 1 players view position x
float y 1 players view position y
int player_index 4  

Game_start game_start - only exist if type=4
  int command 4 0x000001F4
int unknown 4  
int unknown2 4  
int unknown3 4  
int unknown4 4  
int unknown5 4  

Chat chat - only exist if type=4
  int command 4 0xFFFFFFFF
int chat_len 4  
char chat[chat_len] var format is "@#"+ player number + chat message.

Command command - only exist if type=1
  int length 4  
Command_Data command_data[length] var  
char unknown1[4] 4  

Command_Data

Command_Data command_data -  
  char command_type 1 0x0B (resign)
char player_index 1 player_index can be the same as other player if two players select same player number (coop).
char player_number 1  
char zero 1  

Command_Data command_data -  
  int command_type 4 0x77(train unit)
int building_id 4 building's object ID
short unit_type_id 2 Type of unit to train.
short num_unit 2 number of unit to train. 5 is set when shift+click.

Updated 5/14/2006

*home