Saturday, February 3, 2018

modding - Fix broken Portal 2 Chapter Handling in my Mod


I am running again into issues where my mod and the Portal 2 base game do not like each other!


In order to provide the proper menu background images and the music for each of the 5 (internal - internal means here the division in 5 acts while having about 12 chapters ingame so the player can choose rather a chapter than a act to start with) chapters of my mod I have included the following to override the base game:




  • /media/menu_act(01 | ... | 05).bik: The background video/image which is displayed in the main menu.

  • pak01_dir.vpk/materials/vgui/backgrounds: Images of the main menu background which are displayed before the bik video files are loaded and played. Usually the first frame of the video.

  • pak01_dir.vpk/sound/music/mainmenu/portal2_background(01 | ... | 05).wav: Main menu background music overide with my content rather than the original.


However I have and issue and one question concerning this one:




  1. Assume I play the first level of my mod, this is obviously Act 1 and Chapter 1. Now i close my mod and start playing Portal 2 - let's say we start with a new Game in Chapter 7 which is Act 3 internally. When I now change back to my mod it thinks it is already in Act 3 and therefore displays the wrong menu background and could spoiler the player etc. therefore the chapter handling of the base game influences my mod and I do not want to everybody something like "don't play Portal 2 unless you play through my mod.".





  2. Is there any way to fix this issue? I already tried to mess around with the sv_unlockedchapters variable but it looks like this not affect Portal 2.




A workaround would be to use only one background and the same music for all chapters but it would very neat if the menu is contextual based on the progress in the mod!




My experiments so far


I have started again my mod and it shows Chapter 3 (changed the BGs to be able to distinguish and debug which chapter is selected), after running my very first map once, which is for the sake of simplicity called sp_a1_intro1 and returning to the menu the chapter was set (and saved!) to be 1. Experimenting a bit revealed, that naming the map sp_a4_intro1 does not change the chapter to 4. Even including map sp_a4_intro1 in the chapter4.cfg did not help.


I figured out that it seems that the relation map <-> chapter is hardcoded into the game. Naming my map the as one of the original ones here or putting them in a separate folder and using symlinks with "original" allowed me to change the current chapter... (I don't know where this information is stored! I NEED to know it!) however that way I am restricted to either the original names AND the maximum amount of maps available. I need to find out, how to change this behaviour, otherwise I probably have to stick to having only one menu setting...




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...