Decompiling Challenge Scripts

Keshire

New member
Joined
May 24, 2007
Messages
28
Progressing nicely. ;)

http://allboards.lionhead.com/showpost.php?p=2766286&postcount=6
 
Hey guys, I'm the partner Kesh was referring to.  I've been able to make quite a bit of progress on the disassembly side of the chl format.  However, right now I'm seeing a few instructions in LH's chl files that I cannot reproduce with the script commands I have tried.  So I have a favor to ask of you guys: I want scripts! The more the merrier.  This will also help in the future when we have to figure out all the hundreds (and, unfortunately, probably thousands) of game engine calls.

If you're working on a killer mod and are afraid of people to stealing your scripts don't worry.  I guaranty you I will not use the scripts for any purpose other than reverse engineering CHL files.

Feel free to PM me with anything you think might help.
 
If you're just loking for the raw scripts there's plenty in our Script library

For scripts and .chl files to match. A lot of the player made maps do have the scripts included. On the view file page, here's a link the readme and all the files included are usually listed.

http://www.bwfiles.com/files/index.php?action=category&id=72
 
Yep, those worked well.  Found a good 5-6 insructions from them.  Unfortunately, I'm still missing about 3 that are in LH chl's and I've yet to find a way to reproduce.  Also I could not manage to get KalevFPS, Llama, and Invincible Man scripts to compile.  They actually crashed the compiler, no error message, just went straight to windows error report.
 
The compiler doesn't like quotes.  When using it, we had to copy I think it was the bw2text.bin or the bw2text.lhts file from the text folder into the compiler folder. There will be an Windows error, but the compiler will complete compiling the scripts properly.
 
I just got done documenting all the 3.1.N Commands in Assembly. :|

file:///C:/Program%20Files/Lionhead%20Studios/Black%20%26%20White%202/Tools/Script%20Language%20Documentation/Statements.htm#3.1
 
If anyone is interested in looking at assembly, here's some reference:
http://wiki.planetblackandwhite.gamespy.com/PBnWModdingWIKI/index.php/Scripting:CHL:Instructions .

I don't guaranty the quality on that since I hate writing big docs and I'm really tired.

Edit: Heh, just noticed that that doc is 2x the length of the disassembler itself... at least in lines.
 
For anyone following along. Here are the Statement commands broken down into assembly.

These are the commands I couldn't get to compile, if anyone wants to help me out it'd be appreciated. Faster this gets done the faster we can get a decompiler out. :)

Code:
//needs to be state driven// enable anim events on NewObject //3.2.1
------------------------------------------------------------------------------------------------
//needs to be state driven// set NewObject anim event probability //3.2.2
------------------------------------------------------------------------------------------------
//Won't compile// enable VAR visible //3.3.1
------------------------------------------------------------------------------------------------
//Won't compile// disable player town migration //3.4.6
------------------------------------------------------------------------------------------------
//Won't compile// set physics from hand with strength position radius 10 //3.9.1
------------------------------------------------------------------------------------------------
//disable gate can open for platoons
------------------------------------------------------------------------------------------------
//set player 0 objective TRIBUTE_OBJECTIVE_COLLECT_WOOD with amount 5000 text "BW2T_SCRIPT_01FINAL_OBJECTIVE_ELOI_10" amount 5000 description "BW2T_SCRIPT_01FINAL_OBJECTIVE_ELOI_10" parent TRIBUTE_OBJECTIVE_COLLECT_FOOD icon TRIBUTE_OBJECTIVE_ICON_OBJECTIVE_L1_FOLLOWCREATURE class TRIBUTE_OBJECTIVE_CLASS_SKILL start value 200 reward 250 force open dont show player
------------------------------------------------------------------------------------------------
//set player 0 objective TRIBUTE_OBJECTIVE_COLLECT_WOOD icon TRIBUTE_OBJECTIVE_ICON_OBJECTIVE_L3_WOODSTORAGEPIT
------------------------------------------------------------------------------------------------
//add performance stat called "STRING"
------------------------------------------------------------------------------------------------
//set interaction SCRIPT_INTERACTION_LEVEL_1
------------------------------------------------------------------------------------------------
//Speed statement only valid in game speed blocks// set game speed to 0.5
------------------------------------------------------------------------------------------------
//Camera statement only valid in cinema blocks// enable leash draw
------------------------------------------------------------------------------------------------
//Camera statement only valid in cinema blocks// enable highlight draw
------------------------------------------------------------------------------------------------
//Camera statement only valid in cinema blocks// enable spell icon draw
------------------------------------------------------------------------------------------------
//String not in database// set hand icon text "BW2T_SCRIPT_01FINAL_OBJECTIVE_ELOI_50"
------------------------------------------------------------------------------------------------
//trigger floaty number FLOATY_SKULL at POS importance 2 icon VAR value 17
------------------------------------------------------------------------------------------------
//set VAR desire CREATURE_DESIRE_HUNGER 0
------------------------------------------------------------------------------------------------
//set creature DEVELOPMENT_PHASE_PUNISHMENT development
------------------------------------------------------------------------------------------------
//enable VAR object auto scale
------------------------------------------------------------------------------------------------
//set VAR all desire TRUE
------------------------------------------------------------------------------------------------
//teach VAR MAGICAL MAGIC_TYPE_VECTOR_FLAME SCRIPT_TRUE percentage 50
------------------------------------------------------------------------------------------------
//teach VAR all
------------------------------------------------------------------------------------------------
//teach VAR all excluding CREATURE_ACTION_LEARNING_TYPE_MAGIC
------------------------------------------------------------------------------------------------
//set VAR name HELP_TEXT_CREATURE_NAME_01
------------------------------------------------------------------------------------------------
//disable VAR Navigation
------------------------------------------------------------------------------------------------
//request creature VAR play individual anim "MyAnim"
------------------------------------------------------------------------------------------------
//request creature VAR action CREATURE_ACTION ObjectToActOn ObjectToUse
------------------------------------------------------------------------------------------------
//set creature object happiness to maximum
------------------------------------------------------------------------------------------------
//set creature object script thought text "BW2T_SCRIPT_LAND15_CREATUREDREAMS_TOOLTIP_IAMONION"
------------------------------------------------------------------------------------------------
//disable tooltips on creature VAR
------------------------------------------------------------------------------------------------
//play anim ANM_CRY on VAR loop 5
------------------------------------------------------------------------------------------------
//remove VAR to platoon VAR attack list
------------------------------------------------------------------------------------------------
//set platoon VAR formation to 4 wide by 3 deep
------------------------------------------------------------------------------------------------
//set platoon stat PLATOON_STAT_MOVE_TO_ATTACK_DIST of VAR to 1.0
------------------------------------------------------------------------------------------------
//add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_THING using {POS} next in platoon VAR action queue
------------------------------------------------------------------------------------------------
//set town VAR siege weapon type SIEGE_BALANCE_TYPE_CATAPULT to 2
------------------------------------------------------------------------------------------------
//add action SIEGEWEAPON_AGENDA_ACTION_ATTACK_THING using {POS} next in platoon siege weapon VAR action queue
------------------------------------------------------------------------------------------------
//enable platoon VAR response to VAR attack
------------------------------------------------------------------------------------------------
//enable platoon VAR response to local platoon attack
------------------------------------------------------------------------------------------------
//town VAR capture all enemy towns
------------------------------------------------------------------------------------------------
//attach reaction VAR REACTION_FLEE_FROM_OBJECT	
------------------------------------------------------------------------------------------------
//detach REACTION_FLEE_FROM_OBJECT reaction VAR
------------------------------------------------------------------------------------------------
//stop all scripts "Dummy"
------------------------------------------------------------------------------------------------													//stop script files "DummyScript.txt"	
------------------------------------------------------------------------------------------------
//run map script line "CREATE_MOBILE_STATIC("2030,2354.30", 25, 10.324, 0.232123, 0.566464, 0,0006, 1,198000)"
------------------------------------------------------------------------------------------------													//wait until VAR clicked																										------------------------------------------------------------------------------------------------
//attach atmos "SpookySounds" to camera volume 1
------------------------------------------------------------------------------------------------
//destroy mixer 1 with fadetime 3
------------------------------------------------------------------------------------------------
//say random sound from group "HELP_TEXT_LOST" at {POS} with volume 0.8	
------------------------------------------------------------------------------------------------
//set precipitaion at {POS} radius 10 disable rainfall enable snowfall disable overcast
------------------------------------------------------------------------------------------------
//set lightning strike at {POS} from VAR
------------------------------------------------------------------------------------------------
//set sandstorm VAR {POS} moving to {POS} strength 0.8 radius 20.8
------------------------------------------------------------------------------------------------
 
Some of what's in the documentation is incorrect due to typos, omissions and such.

//set VAR desire CREATURE_DESIRE_HUNGER 0
//set creature object happiness to maximum
//teach VAR all
//set creature DEVELOPMENT_PHASE_PUNISHMENT development

That's creature stuff, some of which can be found in this script.

http://www.bwfiles.com/scripts/index.php?action=file&id=27

The rest of I'm not familiar with, but I could take a look into some of them tomorrow.


 
Kays said:
Some of what's in the documentation is incorrect due to typos, omissions and such.

Ya...

I'll be rewriting some of that.
There's also the option of changing the scripting syntax with a new compiler if there's enough interest.
 
Keshire said:
There's also the option of changing the scripting syntax with a new compiler if there's enough interest.

To clarify this we'd probably have to make a new compiler in order to use some of the unlisted optional parameters. And we've found quite  a few.
 
You mean like a compliler which works properly. That would be sweet. :)

I'm absolutly amased at what you have been able to do so far and appreciate the effort.
 
I got a few of them to compile. Haven't looked at the platoon ones yet. Which ones still need to be done?


//set physics from hand with strength position radius 10
set physics from hand with strength {34,65,95} radius 10


//disable gate can open for platoons
disable gate GateHouse can open for platoons


//Camera statement only valid in cinema blocks// enable leash draw
------------------------------------------------------------------------------------------------
//Camera statement only valid in cinema blocks// enable highlight draw
------------------------------------------------------------------------------------------------
//Camera statement only valid in cinema blocks// enable spell icon draw
'

Do compile in a cinima block

begin cinema
enable leash draw
enable highlight draw
enable spell icon draw
end cinema



 
Thank you kindly, and still have these to go:

Code:
//clear VARIABLE hit VARIABLE //3.1.45
//disable anim events on NewObject //3.2.1 //needs to be state driven
//set NewObject anim event probability //3.2.2 //needs to be state driven
//disable VARIABLE visible //3.3.1 //Spits out a wants T_DISABLE or T_ENABLE error. :|
//disable player town migration //3.4.6
//add performance stat called "STRING" //3.13.24
//set interaction SCRIPT_INTERACTION_LEVEL_1 //3.13.31
//set game speed to NUMBER //3.13.32 //Wants a game speed block, tried both "game speed" and "speed"
//trigger floaty number FLOATY_SKULL at POSITION importance NUMBER icon VARIABLE value NUMBER //3.16.22
//remove VARIABLE to platoon VARIABLE attack list //3.18.2 //near token "to": parse error, expecting `T_FROM' or `T_HIT' or `T_PILGRIMAGE'
//set platoon VARIABLE formation to NUMBER wide by NUMBER deep //3.18.25
//set platoon stat ENUMERATION of VARIABLE to NUMBER //3.18.26
//add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_THING using {POSITION} next in platoon VARIABLE action queue //3.18.33
//add action SIEGEWEAPON_AGENDA_ACTION_ATTACK_THING using {POSITION} next in platoon siege weapon VARIABLE action queue //3.18.45
//disable platoon VARIABLE response to VARIABLE attack //3.18.49
//disable platoon VARIABLE response to local platoon attack //3.18.50
//town VARIABLE capture all enemy towns //3.18.54
//attach reaction VARIABLE REACTION_FLEE_FROM_OBJECT //3.23.1
//detach REACTION_FLEE_FROM_OBJECT reaction VARIABLE //3.23.3
//stop all scripts "Dummy" //3.24.4
//stop script files "DummyScript.txt" //3.24.5
//run map script line "CREATE_MOBILE_STATIC("2030,2354.30", 25, 10.324, 0.232123, 0.566464, 0,0006, 1,198000)" //3.24.8
//attach atmos "SpookySounds" to camera volume NUMBER //3.26.12
//destroy mixer NUMBER with fadetime NUMBER //3.26.20
//say random sound from group "HELP_TEXT_LOST" at {POSITION} with volume NUMBER //3.26.28
//set precipitaion at {POSITION} radius NUMBER disable rainfall disable snowfall disable overcast //3.27.1
//set lightning strike at {POSITION} from VARIABLE //3.27.7
//set sandstorm VARIABLE {POSITION} moving to {POSITION} strength NUMBER radius NUMBER //3.27.9
 
I've had no luck on these so far.

//disable player town migration //3.4.6
-> Tried a variety of combinations for player and town

//set interaction SCRIPT_INTERACTION_LEVEL_1 //3.13.31
->  "SCRIPT_INTERACTION_LEVEL_1" appears to be a contant that's not defined

//disable tooltips on creature VAR
-> "tooltips" needs to be declared. I think this is one of the items which doesn't work with this compiler.

//clear VARIABLE hit VARIABLE //3.1.45
-> getting a parser error on the second variable. "expecting 'T_OBJECT'or 'T_LAND'. Creating an object for the second varible doesn't work

//trigger floaty number FLOATY_SKULL at POSITION importance NUMBER icon VARIABLE value NUMBER //3.16.22
-> The icon variable needs to be declared



Successes :)

//attach atmos "SpookySounds" to camera volume NUMBER //3.26.12
attach atmos "SpookySounds" to camera with volume 1
-> added "with"

//say random sound from group "HELP_TEXT_LOST" at {POSITION} with volume NUMBER
play random sound from group "HELP_TEXT_LOST" at {POSITION} with volume NUMBER
-> change say to play

//set precipitaion at {POSITION} radius NUMBER disable rainfall disable snowfall disable overcast //3.27.1
set precipitation at {126,100,258} radius 10 disable rainfall enable snowfall disable overcast
->  precipitation  mis-spelt

//attach reaction VARIABLE REACTION_FLEE_FROM_OBJECT //3.23.1
//detach REACTION_FLEE_FROM_OBJECT reaction VARIABLE //3.23.3
attach reaction wCreature REACTION_FLEE_FROM_OBJECT
detach reaction wCreature
-> These do compile with a creature variable.

//set game speed to NUMBER //3.13.32 //Wants a game speed block, tried both "game speed" and "speed"
  -> It does compile in a cinema block. Strange. ???


 
//disable player town migration //3.4.6 //Only accepts enable//
//disable tooltips on creature VAR //tooltips should be tooltip, and is used twice in the API docs
//clear VARIABLE hit VARIABLE //3.1.45 only uses object and land. Not a variable

Fixed those. Still have these left and We'll be done with the Script statements. Then I can move onto camera, dialogue, and conditions.
Code:
 set NewObject anim event probability //3.2.2 //doesn't like anim
//disable VARIABLE visible //3.3.1
//add performance stat called "STRING" //3.13.24
//enable VARIABLE reaction //3.17.12
//remove VARIABLE to platoon VARIABLE attack list //3.18.2
//set platoon VARIABLE formation to NUMBER wide by NUMBER deep //3.18.25
//set platoon stat ENUMERATION of VARIABLE to NUMBER //3.18.26
//disable platoon VARIABLE response to VARIABLE attack //3.18.49
//disable platoon VARIABLE response to local platoon attack //3.18.50
//town VARIABLE capture all enemy towns //3.18.54
//stop all scripts "Dummy" //3.24.4
//stop script files "DummyScript.txt" //3.24.5
//run map script line "CREATE_MOBILE_STATIC("2030,2354.30", 25, 10.324, 0.232123, 0.566464, 0,0006, 1,198000)" //3.24.8
//destroy mixer NUMBER with fadetime NUMBER //3.26.20
//set lightning strike at {POSITION} from VARIABLE //3.27.7
//set sandstorm VARIABLE {POSITION} moving to {POSITION} strength NUMBER radius NUMBER //3.27.9
 
//run map script line "CREATE_MOBILE_STATIC("2030,2354.30", 25, 10.324, 0.232123, 0.566464, 0,0006, 1,198000)" //3.24.8
run map script line "CREATE_MOBILE_STATIC(\"2030,2354.30\", 25, 10.324, 0.232123, 0.566464, 0,0006, 1,198000)"
-> Compiles if the double quotes in the middle are escaped. Haven't checked in game to see if it works.

//remove VARIABLE to platoon VARIABLE attack list //3.18.2
remove VARIABLE from platoon VARIABLE attack list
-> Change the "to" to "from"

//disable platoon VARIABLE response to local platoon attack //3.18.50
disable platoon VARIABLE respond to local platoon attack
-> Changed "response" to "respond" suspect the same for 3.18.49 but  can't get it to compile.

//disable platoon VARIABLE response to VARIABLE attack //3.18.49
enable platoon VARIABLE respond to town VARIABLE attack
-> Added "town"

//town VARIABLE capture all enemy towns //3.18.54
set town VARIABLE capture all enemy towns

//destroy mixer NUMBER with fadetime NUMBER //3.26.20
destroy mixer VARIABLE with fadetime NUMBER
 
Only got a few left.

Code:
//set VARIABLE anim event probability //3.2.2
//disable VARIABLE visible //3.3.1
//trigger floaty number ENUMERATION at VARIABLE importance 2 icon ENUMERATION value 17 //3.16.22 //Thought I had this one. :|
//set platoon VARIABLE formation to NUMBER wide by NUMBER deep //3.18.25 //Spits out an expecting T_WITH error??
//set platoon stat ENUMERATION of VARIABLE to NUMBER //3.18.26
//set lightning strike at {POSITION} from VARIABLE //3.27.7
//set sandstorm VARIABLE {POSITION} moving to {POSITION} strength NUMBER radius NUMBER //3.27.9

For refernce I've been using.
Code:
define NUMBER = 1234
global VARIABLE
global POSITION //VARIABLE or COORDINATE {X, Y, Z}

And added an enum file with my custom ENUMERATION set to 4321. :)
 
Here's two more but the rest are eluding me.

//set sandstorm VARIABLE {POSITION} moving to {POSITION} strength NUMBER radius NUMBER //3.27.9
set sandstorm VARIABLE position {POSITION} moving to {POSITION} strength NUMBER radius NUMBER

//set lightning strike at {POSITION} from VARIABLE //3.27.7
set lightning strike at {POSITION} from VARIABLE scale NUMBER



//disable VARIABLE visible //3.3.1
Getting an expecting T_ENABLE or T_DISABLE error

//set platoon VARIABLE formation to NUMBER wide by NUMBER deep //3.18.25 //Spits out an expecting T_WITH error??
Same here and I can't find where to place "with"

 
Code:
//set VARIABLE anim event probability//3.2.2
//disable VARIABLE visible //3.3.1
//set platoon VARIABLE formation to NUMBER wide by NUMBER deep //3.18.25
//set platoon stat ENUMERATION of VARIABLE to NUMBER //3.18.26

This is all that's left then. That should be good enough. If the decompiler gets hung up we can probably deduce if these were the commands.

Now to work on the other blocks. :)
 
Back
Top