You are here

Lets kick off modding! :D

Pages

Trent's picture
I was in the War!
Community VIPKickstarter BackerCompetition Winner
Posts: 2989
Submitted: Wed, 02/04/2014 - 11:19

copmac wrote:
Trent If I look at the source code the local variable decoding happens in the guess.c file.

Perhaps it is best to run the project in debug mode and step over the sequence to see how it is done.

I don't have the LOL file at my disposition otherwise i would do it . (I'm at work) :-(

Yup way ahead of you there, I've looked through the function and tried to wrap my head around it yesterday. The code just isn't very descriptive and I need to figure out how the code in the guessing function relates to the ported Unluac code, though I think I have an idea for it relates.

What I'll probably try to do is write some much smaller test LUA scripts which only have the bits I know are broken and run them through in debug so I can more clearly see what's going on in both decompilers with and without the debug information stripped from the script. It may take some time to unravel but I'm sure I'll get there eventually, I'm feeling more confident than I was yesterday :)

copmac's picture
Cunning Stunt Licker
PayPal Backer
Posts: 135
Submitted: Wed, 02/04/2014 - 12:31

Hi Trent perhaps this will help:

http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lpack

the original Lua Pack and unpack binary files.

Trent's picture
I was in the War!
Community VIPKickstarter BackerCompetition Winner
Posts: 2989
Submitted: Wed, 02/04/2014 - 13:12

copmac wrote:
Hi Trent perhaps this will help:

http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lpack

the original Lua Pack and unpack binary files.

Thanks for the suggestion. I've just taken a look at it but unfortunately it seems that's not actually related to LUA bytecode, rather it's an extension library for LUA for packing and unpacking binary data from inside a LUA script. For instance if you wanted to write a LUA script to handle saving and loading savegames you would run the gamestate variables through the library's pack function to convert it to a binary string ready for saving to a file, then when you load the file you would run the file's contents through unpack to retrieve the gamestate variables. It doesn't actually handle converting LUA code to and from bytecode, only binary serialization of data.

copmac's picture
Cunning Stunt Licker
PayPal Backer
Posts: 135
Submitted: Wed, 02/04/2014 - 13:34

:( damn it. I'll keep looking perhaps I can find something that actually can help you.

anyway this is the original webiste containing all kind of lua extensions.

https://code.google.com/p/luaforwindows/

this is a nice one:

http://lua-users.org/wiki/LuaTools

especially this one looks interesting:

http://chunkspy.luaforge.net

Edited by: copmac on Wed, 02/04/2014 - 13:44
Trent's picture
I was in the War!
Community VIPKickstarter BackerCompetition Winner
Posts: 2989
Submitted: Wed, 02/04/2014 - 14:43

I've tried chunkspy before and the 5.1 version simply wouldn't work plus on the website it says "If you want to disassemble to source code, try LuaDec by Hisham Muhammad." so I doubt it's suitable for our needs

LUA For Windows is just a handy package containing LUA and various libraries for it, pretty much to just simplify using LUA on windows. It doesn't seem to contain any actual decompiling bytecode.

LuaAssemblyTools linked to from that LuaTools page looks like it may be useful, but it does say that the decompiler in it is incomplete so it may end up being a dead end.

I've come across that LuaTools page before, it's the tools in the "Assembler / Disassembler / Bytecodes" section which are interesting to us, but only the ones which support 5.1 are compatible with C:R's LOL scripts. LBCJ is just a bytecode inspector, not a decompiler. LuaAssemblyTools and ChunkSpy don't seem suitable as I've mentioned above. That leaves LuaDec51 and Unluac, which are the two I've been using. The tools for older versions may have some info which could be useful, but unfortunately they're no longer available or don't have the source code.

Thanks for the help but I do think the best bet is to figure out what LuaDec51's guess function is doing and porting that to Unluac. I honestly don't think there's going to be another tool which is more complete than either of then. However if you find some actual discussion between coders about how the bytecode is structured, how it works and all that jazz then that certainly would be handy.

Purple44's picture
Cunning Stunt Licker
Kickstarter Backer
Posts: 208
Submitted: Wed, 02/04/2014 - 15:23

Gorth_le_Barbare wrote:
Purple44, the list under "unlocked" is not related to the difficulty, it is just the list of available car in the car selection menu.
I believe the lists under "easy", "medium", etc, are available opponents for each difficulty level. Could be fun to add police cars to these lists to see what happen.

For your problem, you don't need to unpack/repack the .zad. Just open the "scripts.zad" with 7zip, go to the folder where stands the original "VehicleGroups.LOL" in the 7zip file manager, then simply drag and drop the "VehicleGroups.LOL" you downloaded earlier in this folder.

Good to know I don't have to repack scripts.zad file, I can leave it unpack. Ok, I tried renaming scripts.zad to scriptsmod.zad and double check Scripts.ZAD/Data_Core/Content/Scripts folder that it did have modded VehicleGroups.LOL file. I use notepad to make sure the APC and SQUAD_CAR are listed under unlock.

I start C:R and click "change car" and scroll through the cars and only see the stock 6 cars I have been seeing before. So I ask again, what am I doing wrong?

Gorth_le_Barbare did you run Trent's APC mod successfully? I see in post #130 you used the change name of one of the stock cars to APC trick.

Gorth_le_Barbare wrote:
2 easy modifications :
Remember to backup your files first.

Drive the APC :
Open veh_base.zad with something like 7zip. Go to the \Data_Core\Content\Vehicles\ directory.
Rename the "APC" folder to a selectable vehicle, let's say the "Eagle_R". Rename "Eagle_R" folder to "APC". Of course you will need to temporary rename one of the folder to not have 2 folders with the same name.

Trent's picture
I was in the War!
Community VIPKickstarter BackerCompetition Winner
Posts: 2989
Submitted: Wed, 02/04/2014 - 16:04

Purple44 wrote:
Good to know I don't have to repack scripts.zad file, I can leave it unpack. Ok, I tried renaming scripts.zad to scriptsmod.zad and double check Scripts.ZAD/Data_Core/Content/Scripts folder that it did have modded VehicleGroups.LOL file. I use notepad to make sure the APC and SQUAD_CAR are listed under unlock.

I start C:R and click "change car" and scroll through the cars and only see the stock 6 cars I have been seeing before. So I ask again, what am I doing wrong?

Gorth_le_Barbare did you run Trent's APC mod successfully? I see in post #130 you used the change name of one of the stock cars to APC trick.

You have to put the LOL file back in the ZAD file, it won't load if it's not in the ZAD file. Just open up the scripts.zad file in WinRAR, WinZIP, 7Zip or whatever, navigate to the folder in the ZAD file and drag the modified VehicleGroups.lol file back into it.

suicidal_banana's picture
Cunning Stunt Licker
Kickstarter Backer
Posts: 262
Submitted: Wed, 02/04/2014 - 18:06

Did anybody ever find out if the carmodgeddon option enables loading files outside of the zad?
(like, im guessing theres a way to structure the directory tree so that it will actually load the files as if its loading .zad files, but all my tries have come up bust)

And that's some fancy progress on the tools Trent and Errol!! nicely done!

Ooooh, hard nipples. Noooo.... :( *limp nipples* Hmmm, vanilla nipples!

Purple44's picture
Cunning Stunt Licker
Kickstarter Backer
Posts: 208
Submitted: Wed, 02/04/2014 - 18:12

Trent wrote:
Purple44 wrote:
Good to know I don't have to repack scripts.zad file, I can leave it unpack. Ok, I tried renaming scripts.zad to scriptsmod.zad and double check Scripts.ZAD/Data_Core/Content/Scripts folder that it did have modded VehicleGroups.LOL file. I use notepad to make sure the APC and SQUAD_CAR are listed under unlock.

I start C:R and click "change car" and scroll through the cars and only see the stock 6 cars I have been seeing before. So I ask again, what am I doing wrong?

Gorth_le_Barbare did you run Trent's APC mod successfully? I see in post #130 you used the change name of one of the stock cars to APC trick.

You have to put the LOL file back in the ZAD file, it won't load if it's not in the ZAD file. Just open up the scripts.zad file in WinRAR, WinZIP, 7Zip or whatever, navigate to the folder in the ZAD file and drag the modified VehicleGroups.lol file back into it.

Here a pic of the unpack scripts folder. I'm pretty sure I got the modded VehicleGroups.LOL file in the right folder since I see the stock VehicleGroups.LOL file.

I have tried running modded VehicleGroups.LOL file from the unpack \scripts folder and I have tried running modded VehicleGroups.LOL file from a packed back up scripts.zad file and all I see is the 6 stock cars when I go to change car menu.

I also tried this for a test, I rename scripts.zad file and the \scripts folder so game could not load these files and C:R loaded without error and I race the AI on Country track no problem.

Trent are you disagreeing with Gorth_le_Barbare that VehicleGroups.LOL can not be loaded from an unpack folder? That scripts.zad files need to be repack into new scripts.zad file for VehicleGroups.LOL file to work?

Also there nothing I need to do to unlock the APC and SQUAD_CAR in game?

And here my first post if you miss it:

Purple44 wrote:
Deamon wrote:
Purple44 wrote:
Trent wrote:
Going back to getting the APC drivable: If you decode and open Scripts.ZAD/Data_Core/Content/Scripts/VehicleGroups.LOL you can add the APC to the unlocked array like so:
unlocked = {
  "EAGLE_R",
  "CLEAVER",
  "TWISTER",
  "TOWMEISTER",
  "COUNTSLASH",
  "CADDY_FAT_CAT",
  "APC"
}

That makes the APC playable without having to replace an existing car. I discovered this while looking for how to change the amount of cars in a race earlier.

Trent, would it be possible to release this as a tweaked ( ready to go file ) a player could put into his C:R game folder?

I know I'm not Trent, but here you go:

VehicleGroups.lol (right click, save link/target as)

CU:NT is in there as well, just replace the one in scripts.ZAD with this.

Thanks Deamon for the file, thanks Trent for the tweak. I tried to to run the mod, but was unsuccessful. I will post what I did and maybe you can tell me where I went wrong.

Had to do a little thread research to find out how to unpack the Scripts.ZAD file. Need 7zip, WinRAR don't work. So after getting 7zip installed, I unpacked Scripts.ZAD to a folder and swap out VehicleGroups.LOL file for modded version.

To pack the files back up, had to save file as scripts.zip and then rename file to scripts.zad. Game start up fine and I go to change car and scroll through the different cars and do not see cop car ( APC ).

Looking at VehicleGroups.LOL in notepad:

module((...), vehicle_groups_definition)
easy = {
"EAGLE_R",
"CLEAVER",
"TWISTER",
"TOWMEISTER",
"COUNTSLASH",
"CADDY_FAT_CAT"
}
medium = {
"EAGLE_R",
"CLEAVER",
"TWISTER",
"TOWMEISTER",
"COUNTSLASH",
"CADDY_FAT_CAT"
}
hard = {
"EAGLE_R",
"CLEAVER",
"TWISTER",
"TOWMEISTER",
"COUNTSLASH",
"CADDY_FAT_CAT"
}
insane = {
"EAGLE_R",
"CLEAVER",
"TWISTER",
"TOWMEISTER",
"COUNTSLASH",
"CADDY_FAT_CAT"
}
default = {"EAGLE_R"}
unlocked = {
"EAGLE_R",
"CLEAVER",
"TWISTER",
"TOWMEISTER",
"COUNTSLASH",
"CADDY_FAT_CAT",
"APC",
"SQUAD_CAR"
}
all = {
"APC",
"EAGLE_R",
"CLEAVER",
"TWISTER",
"TOWMEISTER",
"COUNTSLASH",
"CADDY_FAT_CAT"
}
dev = {
"EAGLE_R",
"CLEAVER",
"TWISTER",
"TOWMEISTER",
"COUNTSLASH",
"CADDY_FAT_CAT",
"PLOW"
}

I've been using the medium difficulty settings and APC not listed in medium settings there in VehicleGroups.LOL file. So how do I run C:R in unlock mode? I thing this where my problem is.

suicidal_banana's picture
Cunning Stunt Licker
Kickstarter Backer
Posts: 262
Submitted: Wed, 02/04/2014 - 18:25

0. If you didnt yet; backup scripts.zad (copy, paste, rename to mention 'backup' and not be a .zad file)

  1. If you don't have it already, install WinRAR (get it here)
  2. Double click any of the .zad files, Windows will ask you what program it should open .zad files with, select WinRAR (or browse and go to winrar dir and click winrar.exe)
  3. Now WinRAR should open, and you should see some folders, inside WinRAR (aka inside the scripts.zad) browse to this path: scripts.zad\Data_Core\Content\Scripts
  4. Drag-Drop your replacement VehicleGroups.lol file on WinRAR
  5. Profit!

Bonus advice;
It could be that WinRAR is beeing anal and sees VehicleGroups.lol and VehicleGroups.LOL as seperate files, make sure your replacement VehicleGroups file has a .lol extension, lowercase, not capitals.

Bonus advice #2;
If you forget, or are to lazy too make a backup of scripts.zad, and you break stuff, no worries, heres how you fix; delete scripts.zad, then in your steam library rightclick C:R and go properties -> local files -> verify integrity of game cache, then steam will check all game files and download any that are missing (like the broken script.zad you removed)

Edited by: suicidal_banana on Wed, 02/04/2014 - 21:56

Ooooh, hard nipples. Noooo.... :( *limp nipples* Hmmm, vanilla nipples!

Pages

randomness