Page 1 of 1

Script Decompiling

Posted: Sat Apr 11, 2009 5:33 am
by mtxboxfreak
I've been working on decompiling the single player scripts for a few days now. Turns out Halo 1 scripts are pretty similar to Halo 2 scripts, so I was able to use most of the Halo 2 script docs.

I thought I'd share what I've got so far in case anyone else is interested. It's quite fascinating reading through them... or at least I think so.

I've been able to extract every script I've found so far, the only thing lacking in the output is proper display of all the different variable types. Halo has around 50 different types, so far I've only coded in support for the basic few (boolean, short, long, real, etc), the rest are shown as hexvalue:type, e.g. ffff0051:vehicle. The hexvalue is either a tag id, or, as in this example, an index to one of the various reflexives in the scenario. Therefore ffff0051:vehicle means the vehicle referenced in the 0x51st chunk of the vehicles reflexive.

I might get around to supporting most of the types if there is enough interest.

Here is a sample from b40 (AotCR):

Code: Select all

(global boolean global_dialog_on false)
(global boolean global_music_on false)
(global long global_delay_music (* 30:real 300:real))
(global long global_delay_music_alt (* 30:real 300:real))
(global boolean debug true)
(global long default_turret_delay (* 30:real 10:real))
(global long control_turret_delay (* 30:real 10:real))
(global short exterior_player_location 0:short)
(global boolean mission_start false)
(global boolean a1_spawn true)
(global short a1_spawn_counter 0:short)
(global short a1_squad_index 1:short)

// returns unit
(script static player0 
    (begin 
        (unit (list_get (players) 0:short))
    )
)

// returns short
(script static player_count 
    (begin 
        (list_count (players))
    )
)

// returns boolean
(script static cinematic_skip_start 
    (begin 
        (cinematic_skip_start_internal) 
        (game_save_totally_unsafe) 
        (sleep_until (not (game_saving)) 1:short) 
        (not (game_reverted))
    )
)

// returns void
(script static player_effect_vibration 
    (begin 
        (player_effect_set_max_translation 0.0075:real 0.0075:real 0.0125:real) 
        (player_effect_set_max_rotation 0.01:real 0.01:real 0.05:real) 
        (player_effect_set_max_rumble 0.2:real 0.5:real) 
        (player_effect_start (real_random_range 0.7:real 0.9:real) 1:real)
    )
)

// returns void
(script static cutscene_insertion_a 
    (begin 
        (sound_looping_start e55b03e7:looping_sound ffffffff:object 1:real) 
        (sound_class_set_gain 10365114:string 0.3:real 0:short) 
        (objects_predict ffff01b9:object_list) 
        (objects_predict ffff01b6:object_list) 
        (object_beautify ffff01b6:object true) 
        (fade_out 0:real 0:real 0:real 0:short) 
        (switch_bsp 3:short) 
        (object_teleport (player0) 43:cutscene_flag) 
        (object_teleport (player1) 42:cutscene_flag) 
        (cinematic_start) 
        (show_hud false) 
        (camera_control true) 
        (camera_set 7:cutscene_camera_point 0:short) 
        (fade_in 0:real 0:real 0:real 60:short) 
        (object_destroy ffff01b6:object) 
        (object_destroy ffff01b7:object) 
        (object_destroy ffff01b7:object) 
        (object_create ffff01b6:object_name) 
        (object_create ffff01b7:object_name) 
        (object_create ffff01b8:object_name) 
        (object_teleport ffff01b6:object 3d:cutscene_flag) 
        (object_pvs_activate ffff01b6:object) 
        (camera_set 8:cutscene_camera_point 300:short) 
        (unit_set_seat ffff01b6:unit 1036526b:string) 
        (recording_play ffff01b6:unit 17:cutscene_recording) 
        (sleep 300:short) 
        (cinematic_set_near_clip_distance 0.01:real) 
        (camera_set f:cutscene_camera_point 0:short) 
        (camera_set e:cutscene_camera_point 120:short) 
        (wake pelican_up:script) 
        (recording_kill ffff01b6:unit) 
        (object_teleport ffff01b6:object 45:cutscene_flag) 
        (custom_animation ffff01b6:unit e55d03e9:animation_graph 10365324:string false) 
        (sleep 150:short) 
        (camera_set c:cutscene_camera_point 0:short) 
        (camera_set d:cutscene_camera_point 120:short) 
        (sleep 60:short) 
        (camera_set 29:cutscene_camera_point 60:short) 
        (sleep (camera_time)) 
        (recording_kill ffff01b6:unit) 
        (object_destroy ffff01b6:object) 
        (object_destroy ffff01b7:object) 
        (object_destroy ffff01b8:object)
    )
)
I've attached the complete output to this post.

The functions you see such as sleep, or switch_bsp are defined in the xbe, rather than the map. I've attached a list of these along with descriptions of what they do.

As for compiling (recompiling), I don't think it's going to happen any time soon. Arsenic is supposed to have a script compiler in the works and I'm far too lazy to waste time on duplicating the enormous amount of work it'll take to get compiling to work.

I'm open to requests for features, maps to decompile, or whatever. I don't feel like releasing the program or code at the moment though.

Thanks to:
Soldier of Light & the other members of Brok3n Halo who worked on the original Halo 2 scripting tutorial.
Mike (aka xbox7887) for the xbe script list.

Note: The xbe scripts and their descriptions were lifted straight out of the xbe, all the colourful language belongs to Bungie. :P

Re: Script Decompiling

Posted: Sat Apr 11, 2009 8:09 am
by nintendo9713
Good research. Interesting stuff. Glad to see 7 years down the line so much research is being done.

Re: Script Decompiling

Posted: Sat Apr 11, 2009 7:47 pm
by kibito87
mt, I think this is the stuff that Luis was looking for to integrate into arsenic. Maybe you should post a thread with this information in the Test Team section so he can read it.

Re: Script Decompiling

Posted: Sun Apr 12, 2009 6:29 am
by Choking Victim
kibito87 wrote:mt, I think this is the stuff that Luis was looking for to integrate into arsenic. Maybe you should post a thread with this information in the Test Team section so he can read it.
Zteam already gave him hep with that. ShadowSpartan gave him our source code for script extraction awhile back.

Re: Script Decompiling

Posted: Sun Apr 12, 2009 8:20 am
by mtxboxfreak
Choking Victim wrote:Zteam already gave him hep with that. ShadowSpartan gave him our source code for script extraction awhile back.
Oh nice, is that stuff public?

Re: Script Decompiling

Posted: Sun Apr 12, 2009 9:52 am
by Choking Victim
mtxboxfreak wrote:
Choking Victim wrote:Zteam already gave him hep with that. ShadowSpartan gave him our source code for script extraction awhile back.
Oh nice, is that stuff public?
We open sourced bungies extracted campaign scripts awhile back, but that's the only thing public at the moment.

http://www.modacity.net/forums/showthread.php?t=7657

Be advised that those were extracted using a 2 year old build of our script extractor, all spacing issues have been sorted out long ago. Despite the spacing issues, they still compile perfectly fine (using Halo Custom Edition's HEK).

Re: Script Decompiling

Posted: Sun Apr 12, 2009 11:04 am
by mtxboxfreak
Ah, I see, thanks for the link.

As you haven't released any code/docs I shall carry on with my app. :)

Re: Script Decompiling

Posted: Sun Apr 12, 2009 1:01 pm
by Choking Victim
mtxboxfreak wrote:Ah, I see, thanks for the link.

As you haven't released any code/docs I shall carry on with my app. :)
Heh, sounds good to me. Good luck and nice work so far. :wink: