You are here

Lets kick off modding! :D

Pages

Trent's picture
I was in the War!
Community VIPKickstarter BackerCompetition Winner
Posts: 2997
Submitted: Tue, 01/04/2014 - 19:31

Heh thanks, I wish I shared your faith in me ;) trying to figure out how luadec guesses local variables and how to implement that into unluac will certainly take some doing given how little I actually understand lua bytecode and how the two decompilers work. While this version luadec does seem to handle local variables it completely fails to decompile the functions defined in the script at all.

As it stands LOLDecoder works fine for decompiling scripts which don't define any functions but just set variables and call existing functions. It also seems to work ok on scripts which define functions which don't use local variables, however there is no obvious way to tell whether that do or not so it's probably best to stay away from such scripts for the time being.

lemonrev's picture
Velociraptor Fister
Kickstarter Backer
Posts: 1628
Submitted: Tue, 01/04/2014 - 19:40

Sounds like if you had more help from that side of the tech then you could put something decent up or even come up with a solution, I think stainless worked with these files either knowing everything about these types of files or just creating there own little prog's the prog nobby gave you to play with, Although it helped can you deduce anything else from that ?..

Trent's picture
I was in the War!
Community VIPKickstarter BackerCompetition Winner
Posts: 2997
Submitted: Tue, 01/04/2014 - 21:49

lemonrev wrote:
Sounds like if you had more help from that side of the tech then you could put something decent up or even come up with a solution, I think stainless worked with these files either knowing everything about these types of files or just creating there own little prog's the prog nobby gave you to play with, Although it helped can you deduce anything else from that ?..

LOL files are compiled LUA scripts. LUA is an open source scripting language and is compiled with a tool provided with the scripting library. It's not something Stainless created, it's something they implemented in their engine. Coders at Stainless wrote LUA scripts and compiled them using a program called luac.exe. I doubt any of them have experience writing a decompiler as they have no need for one, they have the original versions of all the scripts. The file I got off Nobby was just an original version (e.g. before it was compiled) of a LOL script I knew was not decompiling properly so I could figure out what parts of it were not decompiling properly.

The main two LUA decompilers which are available are called LuaDec and UNLUAC. They are open source projects and, as far as I know, the most complete LUA decompilers which exist however neither are perfect. UNLUAC is the better of the two and handles most things correctly, however LuaDec handles on specific thing which UNLUAC does not and that thing is what's causing some decompiled scripts not to work in the game. Unfortuantely the two decompilers are written in different languages and seem to work in different ways so I need to figure out exactly how LuaDec does it and figure out what parts of Unluac I need to change for it to work. I could certainly do with help but I think the only people who could help are the people who wrote LuaDec and UNLUAC. I doubt they're available to help me though so hopefully I can get it sorted myself.

Eventually Stainless do plan on releasing the uncompiled LOL scripts for modders but they're not yet in a position to do that so what I'm doing is pretty much just trying to give people the opportunity to mess around with scripts and learn how they work now so when Stainless do release the original scripts publicly. What I've released so far works fine for learning about what the scripts do and how the game works, it also works fine for being able to edit some scripts when the just contain basic settings, it just doesn't work for editing scripts which contain actual gameplay logic as the code it produces is not quite correct.

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

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.

lemonrev's picture
Velociraptor Fister
Kickstarter Backer
Posts: 1628
Submitted: Wed, 02/04/2014 - 04:54

trent i dont know much about moddeing per say or anything even remotely close so im no good in this area but if you want help looking stuff up give me a yell ya ?..

Gorth_le_Barbare's picture
Fluffy Bunny
Kickstarter Backer
Posts: 15
Submitted: Wed, 02/04/2014 - 07:14

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.

Errol's picture
Piledriver
Community VIPKickstarter BackerModerator
Posts: 962
Submitted: Wed, 02/04/2014 - 07:57

Trent told me it wasn't the textures that were reversed but the entire mesh! A small fix later and...

Woo! I can now process to the final byte any MDL file with a single material. Mostly by skipping chunks but it's a start. And as long as "unknown A, B and C" are 0 I can successfully render the mesh with no holes too...

It's not all winning though. MDLs with multiple materials look like this...

And they have holes when "unknown A, B and C" aren't 0...

On the tool side I've added the ability to open pedestrian bodyform.cnt files and a few keyboard shortcuts. "." will cycle between poly, line and point mode and "," will toggle the visibility of multi-meshes.

:: You wanna build a snowman mod C:R? Get Flummery, the Carmageddon modders tool. ::
Making C:R mods happen since '14!

AlexTSK's picture
I was in the War!
Posts: 2765
Submitted: Wed, 02/04/2014 - 08:29

Hooray Errol, holding my fingers for an exporter of those MDL files :)

Edited by: Bloodstability on Wed, 02/04/2014 - 08:29
lemonrev's picture
Velociraptor Fister
Kickstarter Backer
Posts: 1628
Submitted: Wed, 02/04/2014 - 08:48

nice uncovery of the MDL files and nice mesh up's, if the unknowns are something that isnt just as simple as taking a guess, maybe in time you will find a equation to fill those gaps so even if its not perfect those holes in the mesh are at least filled.

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

Trent wrote:

LOL files are compiled LUA scripts. LUA is an open source scripting language and is compiled with a tool provided with the scripting library. It's not something Stainless created, it's something they implemented in their engine. Coders at Stainless wrote LUA scripts and compiled them using a program called luac.exe. I doubt any of them have experience writing a decompiler as they have no need for one, they have the original versions of all the scripts. The file I got off Nobby was just an original version (e.g. before it was compiled) ...

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) :-(

Pages

randomness