Trying to rebuild 1.3 fake console assets
Moderator: Moderators
- AnthonyBF2
- Sith
- Posts: 1255
- Joined: Wed Aug 21, 2013 3:55 pm
- Projects :: PS2+PSP Overhaul
Trying to rebuild 1.3 fake console assets
After noticing something, I had a new idea; the ability to add fake console assets as part of new mods, without actually having the original assets (as they have been lost) or using the compiled .lvl files included from the official patch release.
First I was messing around with the .lvl file extractor, I don't remember who made this tool because I downloaded it a very long time ago and I always throw away readme files.
I ran the .lvl extractor on the 3 files replaced by the 1.3 patch; ingame.lvl, shell.lvl and common.lvl
So now I have a .lub file that's the name of each script file from the 1.3 files, example; fakeconsole_functions.lub, utility_functions2.lub, etc.
Note: Will be ignoring texture files in this post as scripts is the important part of making fake console what it is.
Then I noticed:
The extracted .lub files are the exact same as the premunged files that get created after a first time munge, located in:
C:\BF2_ModTools\data_MOD\_BUILD\Common\MUNGED\PC
Example; ifs_fakeconsole.lub(an extracted file) is the same as ifs_fakeconsole.script located in the premunged folder after a first time munge.
The only difference being the file extension name.
So then I took all of the .lub extraction files, and renamed them in the .script extension, then copy/pasted and replaced them over the matching files in C:\BF2_ModTools\data_MOD\_BUILD\Common\MUNGED\PC
At this point I'm thinking that I am going to fool the munger into thinking the extractions from the official patch files are the premunge files that it made from first time munge. The next thought is that the second time munge will add the 1.3 patch items along with the standard Battlefront 2 assets as it makes new .lvl files - therefor giving us 1.3 fake console patch additions. My personal goal with this is to get Fake Console menu on the PS2 version of swbf2.
Anyway, when I do the second munge, I get some weird error about fakeconsole_functions.script located in
C:\BF2_ModTools\data_MOD\_BUILD\Common\MUNGED\PC is not a valid UCF Binary file
And it's not just this file.
If I remove that one specific file, it presents the same error on other files. It only presents the error on files that were replaced by 1.3 patch extractions.
I'll see if I can fix this and post more progress but any help/thoughts would be super great!
Edit: Yes, I added the 1.3 patch-specific items to the .req files for shell, common and ingame so I know they're getting called in.
First I was messing around with the .lvl file extractor, I don't remember who made this tool because I downloaded it a very long time ago and I always throw away readme files.
I ran the .lvl extractor on the 3 files replaced by the 1.3 patch; ingame.lvl, shell.lvl and common.lvl
So now I have a .lub file that's the name of each script file from the 1.3 files, example; fakeconsole_functions.lub, utility_functions2.lub, etc.
Note: Will be ignoring texture files in this post as scripts is the important part of making fake console what it is.
Then I noticed:
The extracted .lub files are the exact same as the premunged files that get created after a first time munge, located in:
C:\BF2_ModTools\data_MOD\_BUILD\Common\MUNGED\PC
Example; ifs_fakeconsole.lub(an extracted file) is the same as ifs_fakeconsole.script located in the premunged folder after a first time munge.
The only difference being the file extension name.
So then I took all of the .lub extraction files, and renamed them in the .script extension, then copy/pasted and replaced them over the matching files in C:\BF2_ModTools\data_MOD\_BUILD\Common\MUNGED\PC
At this point I'm thinking that I am going to fool the munger into thinking the extractions from the official patch files are the premunge files that it made from first time munge. The next thought is that the second time munge will add the 1.3 patch items along with the standard Battlefront 2 assets as it makes new .lvl files - therefor giving us 1.3 fake console patch additions. My personal goal with this is to get Fake Console menu on the PS2 version of swbf2.
Anyway, when I do the second munge, I get some weird error about fakeconsole_functions.script located in
C:\BF2_ModTools\data_MOD\_BUILD\Common\MUNGED\PC is not a valid UCF Binary file
And it's not just this file.
If I remove that one specific file, it presents the same error on other files. It only presents the error on files that were replaced by 1.3 patch extractions.
I'll see if I can fix this and post more progress but any help/thoughts would be super great!
Edit: Yes, I added the 1.3 patch-specific items to the .req files for shell, common and ingame so I know they're getting called in.
- [RDH]Zerted
- Gametoast Staff
- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Trying to rebuild 1.3 fake console assets
There should only be minor changes to ifs_fakeconsole.lua to get the v1.3 Fake Console working.
1) You need to prevent the 'console' button from being hidden in ifs_pausemenu.lua.
2) Call ff_rebuildFakeConsoleList() in ifs_fakeconsole.Enter() instead of ScriptCB_GetConsoleCmds(). I think there were other changes to Enter() but the single function replacement is basically it.
3) Load utility_functions2.lua from game_interface.lua so the FC commands can get access to a bunch of helper functions they use and track which units are loaded on the map (so their class properties can change).
4) Find the .lub that contains the Popup_Prompt and get that included (loaded from game_interface.lua?). This is probably the second hardest step and is required if you want to use any of the FC commands that ask the user for a value.
5) Mess around with ifs_fakeconsole's layout to get it working well enough on all screen resolutions (maybe not an issue on the PS2). This was one of the most annoying tasks of making v1.3.
I do have the source code to these file:
fakeconsole_functions.lua
utility_functions2.lua
ifs_era_handler.lua
I've seen UCF errors before but it's been years... Compare that .script file with other partially munged .script files.
1) You need to prevent the 'console' button from being hidden in ifs_pausemenu.lua.
2) Call ff_rebuildFakeConsoleList() in ifs_fakeconsole.Enter() instead of ScriptCB_GetConsoleCmds(). I think there were other changes to Enter() but the single function replacement is basically it.
3) Load utility_functions2.lua from game_interface.lua so the FC commands can get access to a bunch of helper functions they use and track which units are loaded on the map (so their class properties can change).
4) Find the .lub that contains the Popup_Prompt and get that included (loaded from game_interface.lua?). This is probably the second hardest step and is required if you want to use any of the FC commands that ask the user for a value.
5) Mess around with ifs_fakeconsole's layout to get it working well enough on all screen resolutions (maybe not an issue on the PS2). This was one of the most annoying tasks of making v1.3.
I do have the source code to these file:
fakeconsole_functions.lua
utility_functions2.lua
ifs_era_handler.lua
I've seen UCF errors before but it's been years... Compare that .script file with other partially munged .script files.
- AnthonyBF2
- Sith
- Posts: 1255
- Joined: Wed Aug 21, 2013 3:55 pm
- Projects :: PS2+PSP Overhaul
Re: Trying to rebuild 1.3 fake console assets
Thanks for the reply, I do have those source files as well.
No, I am not deeply concerned about popup_prompt.
Apart from PS2 game I would like to get those bits implemented for misc. mods for the PC version.
And last thanks for the better instructions, I've still been trying to fool visualmunge into munging .lvl extractions.
EDIT
Ok I've gotten fake console to be unhidden in ifs_pausemenu but I'm stuck at what to do in ifs_fakeconsole.
I really don't understand coding, and I can't make sense of what I am supposed to with ff_rebuildFakeConsoleList().
Here is default ifs_fakeconsole script, with colored part what I have been messing with, anything I do just blanks out fake console list(normally one thing for qos) and makes going back fail, having to alt-f4 out of the game.
No, I am not deeply concerned about popup_prompt.
Apart from PS2 game I would like to get those bits implemented for misc. mods for the PC version.
And last thanks for the better instructions, I've still been trying to fool visualmunge into munging .lvl extractions.
EDIT
Ok I've gotten fake console to be unhidden in ifs_pausemenu but I'm stuck at what to do in ifs_fakeconsole.
I really don't understand coding, and I can't make sense of what I am supposed to with ff_rebuildFakeConsoleList().
Here is default ifs_fakeconsole script, with colored part what I have been messing with, anything I do just blanks out fake console list(normally one thing for qos) and makes going back fail, having to alt-f4 out of the game.
Hidden/Spoiler:
Last edited by AnthonyBF2 on Thu Oct 22, 2015 10:54 pm, edited 1 time in total.
- [RDH]Zerted
- Gametoast Staff
- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Trying to rebuild 1.3 fake console assets
I was saying change:
ScriptCB_GetConsoleCmds() -- puts contents in gConsoleCmdList
to:
ff_rebuildFakeConsoleList()
You need to make sure fakeconsole_functions.lua and utility_functions2.lua have been loaded before you try to use them, so before ifs_fakeconsole.lua (loading them in game_interface.lua is a good place). I should have mentioned that. Adding script files to a .req isn't good enough. You still need a function call somewhere that loads those scripts. See all the ScriptCB_DoFile()s in game_interface.lua as an example.
Can you get the debug output from the PS2 version? It might be hard to get everything working without it.
ScriptCB_GetConsoleCmds() -- puts contents in gConsoleCmdList
to:
ff_rebuildFakeConsoleList()
You need to make sure fakeconsole_functions.lua and utility_functions2.lua have been loaded before you try to use them, so before ifs_fakeconsole.lua (loading them in game_interface.lua is a good place). I should have mentioned that. Adding script files to a .req isn't good enough. You still need a function call somewhere that loads those scripts. See all the ScriptCB_DoFile()s in game_interface.lua as an example.
Can you get the debug output from the PS2 version? It might be hard to get everything working without it.
- AnthonyBF2
- Sith
- Posts: 1255
- Joined: Wed Aug 21, 2013 3:55 pm
- Projects :: PS2+PSP Overhaul
Re: Trying to rebuild 1.3 fake console assets
I'm not modding the PS2 version at all for now, I am testing all of this on file replacements for the PC version. When I have the ability to load fake console into the default assets(meaning everything is done)all I have to do is a munge for PS2 type to get PS2 files, much easier and quicker.
I'll report back after I've tried the last bit you've instructed.
EDIT
I finally [RC Cola] got it!
Wow that was a goal I've been trying to do for some time. Thanks for all the help over the months!
I'll edit this post later to explain everything I've done for future reference to help others.
For other people; if you want to add 1.3 fake console items to your own mods, your process to do is;
EDIT2
I got a little carried away and forgot to mention that as of now everything is built and fake console now shows my custom and the old 1.3 commands but they can't be ran yet. Selecting a command just returns to main pause menu.
I'll report back after I've tried the last bit you've instructed.
EDIT
I finally [RC Cola] got it!
Wow that was a goal I've been trying to do for some time. Thanks for all the help over the months!
I'll edit this post later to explain everything I've done for future reference to help others.
For other people; if you want to add 1.3 fake console items to your own mods, your process to do is;
Hidden/Spoiler:
EDIT2
I got a little carried away and forgot to mention that as of now everything is built and fake console now shows my custom and the old 1.3 commands but they can't be ran yet. Selecting a command just returns to main pause menu.
- [RDH]Zerted
- Gametoast Staff
- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Trying to rebuild 1.3 fake console assets
FYI: If you're only making PC mods, then you should only be using custom user scripts to add custom commands to all maps or just call the proper function from within your mission script for new commands specific to that map. The v1.3 docs include info on how to add custom FC commands properly. Munging a new Fake Consoles can lead to fragmentation and incompatible mods. The whole point of v1.3 was to reduce fragmentation by combining the shell, common, and FC mods. The 'proper' way is injecting changes from your scripts into v1.3 by wrapping function calls instead of rewriting v1.3 scripts.anthonybf2 wrote:Now you may add fake console items + your own custom scripts/commands to your own mods using a custom fake console. You can add them inside of fakeconsole_functions.lua and they will be there ingame.
What commands and what's the debug output?
Also, there's no need to double post. Edit your posts instead. Use code and hide tags too.
- AnthonyBF2
- Sith
- Posts: 1255
- Joined: Wed Aug 21, 2013 3:55 pm
- Projects :: PS2+PSP Overhaul
Re: Trying to rebuild 1.3 fake console assets
My reason for doing this is to have the fake console abilities without having to use the 1.3 patch. Some users like to have their own copies of ingame.lvl, common.lvl and shell.lvl which are replaced by 1.3.
EDIT
Can I bump this?
It has been good progress to finally integrate fake console assets into the default game files/assets but one problem persists;
The fake console menu buttons are not actually clickable. I guess there needs to be more work done in ifs_fakeconsole.lua
What happens is that when I click a fake console command, any of them (even the blank lines) the game just returns to the main pause menu.
Even if I click outside of the fake console border (on empty screen space) it still returns back to main pause menu.
This happens in PC, PS2 and even in the PSP version of the game. Zerted, can we go over this when you see this again? Thanks.
EDIT
Can I bump this?
It has been good progress to finally integrate fake console assets into the default game files/assets but one problem persists;
The fake console menu buttons are not actually clickable. I guess there needs to be more work done in ifs_fakeconsole.lua
What happens is that when I click a fake console command, any of them (even the blank lines) the game just returns to the main pause menu.
Even if I click outside of the fake console border (on empty screen space) it still returns back to main pause menu.
This happens in PC, PS2 and even in the PSP version of the game. Zerted, can we go over this when you see this again? Thanks.
Hidden/Spoiler:
- [RDH]Zerted
- Gametoast Staff
- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Trying to rebuild 1.3 fake console assets
I knew there was something I was forgetting... I probably changed fake console's CreateItem and PopulateItem to hold a reference to their data's run function then called that function (using pcall to detect and control errors) when that item was clicked. That's the efficient way of doing it.
Or you can search through all the entries in gConsoleCmdList looking for the entry with a ShowStr that matches Selection.ShowStr. This is slower but you won't have to understand as much about how SWBF2 listBoxes work. You'd put this code in the InputAccept function right before ScriptCB_DoConsoleCmd. To get things to change pink or blue, check the result of the pcall and use IFObj_fnSetColor() on Selection (maybe?) similar to how the color is changed in PopulateItem.
ScriptCB_PopScreen() is what closes the screen, so remove that from InputAccept if you want to be able to select multiple commands and/or see the entry change colors (pink/blue). I forget if screens automatically close if you press Esc or if you have to add the code to do that.
Or you can search through all the entries in gConsoleCmdList looking for the entry with a ShowStr that matches Selection.ShowStr. This is slower but you won't have to understand as much about how SWBF2 listBoxes work. You'd put this code in the InputAccept function right before ScriptCB_DoConsoleCmd. To get things to change pink or blue, check the result of the pcall and use IFObj_fnSetColor() on Selection (maybe?) similar to how the color is changed in PopulateItem.
ScriptCB_PopScreen() is what closes the screen, so remove that from InputAccept if you want to be able to select multiple commands and/or see the entry change colors (pink/blue). I forget if screens automatically close if you press Esc or if you have to add the code to do that.
- AnthonyBF2
- Sith
- Posts: 1255
- Joined: Wed Aug 21, 2013 3:55 pm
- Projects :: PS2+PSP Overhaul
Re: Trying to rebuild 1.3 fake console assets
I don't understand that but that may not matter since I got the old extracted scripts to insert into newly munged files(use your ifs_fakeconsole script already built), but that does lead me to another question:
Where, if any, and how many locations calls popup_prompt? Or does it just need to exist in the output .lvl file?
Where, if any, and how many locations calls popup_prompt? Or does it just need to exist in the output .lvl file?
- [RDH]Zerted
- Gametoast Staff
- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Trying to rebuild 1.3 fake console assets
That's something we could use a tutorial for. Basically InputAccept handles when the user clicks something in a list. That needed to be modified to run the custom function of the command being clicked on. Without that change, the game just tries to process the entry as a debug exe FC command. pcall is a Lua function that lets you run another function. If that function causes a crash, pcall 'catches' it and lets you handle the error instead of crashing the game.anthonybf2 wrote:I don't understand that but that may not matter since I got the old extracted scripts to insert into newly munged files
popup_prompt is called by every FC command that asks the user for a value. I don't think it's used anywhere else. It was a completely new prompt so none of the official code uses it.
- AnthonyBF2
- Sith
- Posts: 1255
- Joined: Wed Aug 21, 2013 3:55 pm
- Projects :: PS2+PSP Overhaul
Re: Trying to rebuild 1.3 fake console assets
Well a tutorial for that inserting old file into new file isn't ready yet, It's partly guessing the right header to add in hex editor. I've done this to some psp missions and got them to work with a new file to prevent losing them with a new file.
I also tried this method with your ifs_fakeconsole script but then the entire fake console button inside of pause menu becomes unusable.
I don't know if this a bad edit on inserting the file or a function from the fake console/pause menu script.
I still need to take the time to insert popup_promp and maybe some other scripts into new files, again it relies on guessing the right header on hex editor. It usually looks something like this:
http://prntscr.com/9685sf
Certain bytes change in the header of just about every game script, so far I've just been randomly using headers from different scripts. I don't have a way of knowing what they really mean or what they do.
I also tried this method with your ifs_fakeconsole script but then the entire fake console button inside of pause menu becomes unusable.
I don't know if this a bad edit on inserting the file or a function from the fake console/pause menu script.
I still need to take the time to insert popup_promp and maybe some other scripts into new files, again it relies on guessing the right header on hex editor. It usually looks something like this:
http://prntscr.com/9685sf
Certain bytes change in the header of just about every game script, so far I've just been randomly using headers from different scripts. I don't have a way of knowing what they really mean or what they do.