Hex editing mission.lvl [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
somen00b
Private Recruit
Posts: 16
Joined: Wed Dec 08, 2010 7:12 pm
Projects :: No Mod project currently.
Games I'm Playing :: SWBFII

Hex editing mission.lvl [Solved]

Post by somen00b »

So I want to edit some scripts such as setup teams and ambush in the mission.lvl, I have the conversion pack so I'd rather not munge my own mission.lvl from scratch as it will be incompatable. I'm going to try to compare the lvl from my project with the shipped one to correctly insert the code, but even if I can insert the now code correctly, I still need to know how to recompute the headers that dictate file size info. I recall a turtorial on this type of editing touting adding flyers to yavin 4 somewhere...

Any help is appreciated.
Last edited by somen00b on Wed Jun 15, 2011 10:03 pm, edited 1 time in total.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Hex editing mission.lvl help

Post by [RDH]Zerted »

I can't help you with the hex editing, but you can use a v1.3 custom user script to override those scripts with your own versions. That might be easier.
User avatar
Dakota
Field Commander
Field Commander
Posts: 991
Joined: Mon Dec 06, 2010 8:21 pm
Projects :: making random weapon assets
Games I'm Playing :: SWBF2 and more
xbox live or psn: PS3 beats xbox
Location: at a computer desk floating around in space

Re: Hex editing mission.lvl help

Post by Dakota »

not to hijack a topic, but i got a question that i have been trying to get answered for almost half a year. also this could help the original poster if he didn't know how either.

How do you use/make a custom user script? Also how would i set it up to also work on multiplayer? (i got a dedicated with cps that need locking)
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Hex editing mission.lvl help

Post by Fiodis »

From the v1.3 documentation, which you should always consult first:
Hidden/Spoiler:
Overview
* The UnOfficial v1.3 patch r102+ supports up to 11 custom user scripts. User scripts are loaded and processed at the start of game_interface.lua. This allows the scripts to control or adjust almost everything that happens ingame. For instance, you can create a script that does a few FakeConsole commands at the start of any map or a script that changes the server name to reflect the amount of people on the server.
* The UnOfficial v1.3 patch r129+ supports an unlimited number of custom user scripts. These scripts must start at number 11 and increment that number one at a time. If there is a break in the numbering, such as: user_script_12, user_script_13, user_script_15, and user_script_16, then when the game sees script 14 missing, it will stop checking for other scripts. Thus user_script_15 and user_script_16 won't be loaded.

Requirements
* SWBF2 mod tools
* v1.3 patch r141+ installed
* Basic understanding of Lua
* Basic understanding of how the game works

How To Do It:
1) First, you will need to read and understand the 'Munge A Custom LVL File.txt' document
2) Next, you need to pick a user script slot. The open slots start at 11 and must go up one at a time. Check your "GameData\data\_LVL_PC folder" and see which 'user_script_##.lvl' files you have. If the script name in the req file doesn't match the lvl file name, the script won't work.
x) If you are using a v1.3 patch below version r141, then only slots 0-10 are available.
X) This guide will use slot eleven: "11". If you plan to distribute your scripts to others, it is best to include the source code. This will allow each person to adjust the code for the amount of user scripts that person already has.
3) Configure your map to munge the custom lvl: "user_script_11.lvl" (see the custom lvl doc for help)
4) user_script_11.lvl must, at the very least, contain the lua script: "user_script_11". When your custom lvl is processed by the game, it will load only this script. You can always include more scripts or resources in the lvl if you need them, but the expected script (user_script_11) must load them (use ScriptCB_DoFile() or ReadDataFile()).
5) After you munge your user_script_11.lvl, copy it to the folder: "GameData\Data\_LVL_PC"
6) Thats it! Run your game and check its debug output. You should see it saying it found and loaded your script each time you load a map/level.

More Info
* For an example user script that runs a few FakeConsole commands when you play a single-player map (easy to remove the SP part), see "user_script_example.zip" in the "code eamples" folder of the v1.3 patch.
* You can use these scripts to better configure a dedicated server or enforce rules, such as 'no vehicles' by using the FakeConsole command 'Lock Vehicles' or a snipers only rule by listening in on AddUnitClass() and canceling any non-sniper units from being added to the team!
Is that what you were looking for?
User avatar
Dakota
Field Commander
Field Commander
Posts: 991
Joined: Mon Dec 06, 2010 8:21 pm
Projects :: making random weapon assets
Games I'm Playing :: SWBF2 and more
xbox live or psn: PS3 beats xbox
Location: at a computer desk floating around in space

Re: Hex editing mission.lvl help

Post by Dakota »

Fiodis wrote:From the v1.3 documentation, which you should always consult first:
Hidden/Spoiler:
Overview
* The UnOfficial v1.3 patch r102+ supports up to 11 custom user scripts. User scripts are loaded and processed at the start of game_interface.lua. This allows the scripts to control or adjust almost everything that happens ingame. For instance, you can create a script that does a few FakeConsole commands at the start of any map or a script that changes the server name to reflect the amount of people on the server.
* The UnOfficial v1.3 patch r129+ supports an unlimited number of custom user scripts. These scripts must start at number 11 and increment that number one at a time. If there is a break in the numbering, such as: user_script_12, user_script_13, user_script_15, and user_script_16, then when the game sees script 14 missing, it will stop checking for other scripts. Thus user_script_15 and user_script_16 won't be loaded.

Requirements
* SWBF2 mod tools
* v1.3 patch r141+ installed
* Basic understanding of Lua
* Basic understanding of how the game works

How To Do It:
1) First, you will need to read and understand the 'Munge A Custom LVL File.txt' document
2) Next, you need to pick a user script slot. The open slots start at 11 and must go up one at a time. Check your "GameData\data\_LVL_PC folder" and see which 'user_script_##.lvl' files you have. If the script name in the req file doesn't match the lvl file name, the script won't work.
x) If you are using a v1.3 patch below version r141, then only slots 0-10 are available.
X) This guide will use slot eleven: "11". If you plan to distribute your scripts to others, it is best to include the source code. This will allow each person to adjust the code for the amount of user scripts that person already has.
3) Configure your map to munge the custom lvl: "user_script_11.lvl" (see the custom lvl doc for help)
4) user_script_11.lvl must, at the very least, contain the lua script: "user_script_11". When your custom lvl is processed by the game, it will load only this script. You can always include more scripts or resources in the lvl if you need them, but the expected script (user_script_11) must load them (use ScriptCB_DoFile() or ReadDataFile()).
5) After you munge your user_script_11.lvl, copy it to the folder: "GameData\Data\_LVL_PC"
6) Thats it! Run your game and check its debug output. You should see it saying it found and loaded your script each time you load a map/level.

More Info
* For an example user script that runs a few FakeConsole commands when you play a single-player map (easy to remove the SP part), see "user_script_example.zip" in the "code eamples" folder of the v1.3 patch.
* You can use these scripts to better configure a dedicated server or enforce rules, such as 'no vehicles' by using the FakeConsole command 'Lock Vehicles' or a snipers only rule by listening in on AddUnitClass() and canceling any non-sniper units from being added to the team!
Is that what you were looking for?
i had read that but it didn't say how to get it to work online, only that it is easy to set for online...
somen00b
Private Recruit
Posts: 16
Joined: Wed Dec 08, 2010 7:12 pm
Projects :: No Mod project currently.
Games I'm Playing :: SWBFII

Re: Hex editing mission.lvl help

Post by somen00b »

Just what I needed, thankyou!

Just one question, where do I download the guide that you pasted from? Is it a game patch or something?
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Hex editing mission.lvl help

Post by Fiodis »

C:\Program Files (x86)\LucasArts\Star Wars Battlefront II\GameData\v1.3patch\docs\howtos. Some installations of the v1.3 patch don't have these docs. I'm not sure why.

And glad to help. :)
Post Reply