Jump to content

Trying adding new campaign to BGEE


Recommended Posts

Well, hello all!

First a big thanks to @K4thos for providing insightful suggestions to my problem, and suggested I discussed it on a public topic since the interest of many people. So here is the gist:

I'm trying to add a new campaign to BGEE. If this doesn't work out I'll try the alternative route proposed in a previous topic here

 

 

The solution proposed is taking up the slot attributed to SoD, so here is the coding I tried to used, which seems to install, but provokes an issue. Be mindful that I am no programmer and still learning how, so if you see my errors, please point it out. 

----------------------------------------------------------------------------------------------------------------------------------------------

// This section is needed to be added to Campaign.2da. Basically you can replace the worldmap if you need to, as I did since my campaign is set in Planescape. 

APPEND ~CAMPAIGN.2DA~ ~            WORLDSCRIPT            DESCRIPTION ICON       INTERDIA   LOADHINT   MASTAREA   MUSIC      NAME       NPCLEVEL   TBPPARTY   PDIALOG    SAVE_DIR   STARTARE   STRTGOLD   STARTPOS   STWEAPON   25STWEAP   XPCAP      XPLIST     WORLDMAP   WORLDSCRIPT MAP_DROPSHADOW MAP_FONTCOLOR      KEEP_POWERS   INTRO_MOVIE    IMPORT     INTERACT        YEARS      REPUTATION        CLASTEXT   RACETEXT 
                                    PP          BDBALDUR    104978         1         BDBANTER     *          SODMAREA     74      44685        NPCLVLDS   *          BDDIALOG      sodsave    SODSTRTA   STRTGOLD   sodstpos     SODWEAP    BDSTWEAP    161000     *          SIGILMAP       BDBALDUR          1          0xFFFFFFFF             1        SODCIN01       PARTY       SODINTER         SODYEARS    SODREPUTATI         SODCLTXT    SODRACE~

// K4thos provided this patch to do REPLACE_TEXTUALLY action used in EET.

COPY_EXISTING ~UI.MENU~ ~override~
    DEFINE_PATCH_FUNCTION 
    REPLACE_MULTILINE
    INT_VAR
        num = "-1"     //amount of times the pattern should be replaced with string (-1 by default which is at least 1 but without max limit)
        strict = 0     //set to 1 to enable strict checking (auto escapes $^.*+?[]\ special characters)
        verbose = 1    //set to 0 to skip printing patching message
        warn = 1       //set to 0 to skip printing warning message if the function can't do what you ask it to do
        only_count = 0 //set to to 1 to skip pattern replacing and just return num_matches (COUNT_REGEXP_INSTANCES alternative)
    STR_VAR
        pattern = ""   //pattern that you want to replace
        string = ""    //string that the pattern will be replaced with
    RET
        num_matches    //amount of times the pattern has been found
    BEGIN
    TEXT_SPRINT percent ~%~ // Below is the line of code in UI.Menu that starts the SoD campaign
    INNER_PATCH_SAVE textToReplace ~function onCampaignButton(buttonNum)
        local campaign = startEngine:GetCampaign()
        local clickedCampaign = startButtons[campaign][buttonNum]
        if(clickedCampaign == const.START_CAMPAIGN_SOD) then
            startEngine:OnCampaignButtonClick('SOD',true)
        elseif(clickedCampaign == const.START_CAMPAIGN_BP) then
            startEngine:OnTBPButtonClick(true)
        elseif(clickedCampaign == const.START_CAMPAIGN_BG) then
            startEngine:OnSoAButtonClick(true)
        end
    end~ BEGIN
            SET num_matches = num_matches + 1 // Replacing the code by starting the new campaign instead of Sod. Mine for example is PP for Project Planescape.
            INNER_PATCH_SAVE string ~function onCampaignButton(buttonNum)
        if buttonNum == 3 then
            startEngine:OnCampaignButtonClick('START_CAMPAIGN_PP',true)
        else
            local campaign = startEngine:GetCampaign()
            local clickedCampaign = startButtons[campaign][buttonNum]
            if(clickedCampaign == const.START_CAMPAIGN_SOD) then
                startEngine:OnCampaignButtonClick('SOD',true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BP) then
                startEngine:OnTBPButtonClick(true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BG) then
                startEngine:OnSoAButtonClick(true)
            end
        end
    end~ BEGIN
        PATCH_IF strict = 1 BEGIN
            REPLACE_TEXTUALLY ~\\~ ~\\\\~
            REPLACE_TEXTUALLY ~\[~ ~\[~
            REPLACE_TEXTUALLY ~\]~ ~\]~
            REPLACE_EVALUATE ~\([\$\^\.\*\+\?]\)~ BEGIN END ~\%MATCH1%~
        END
        REPLACE_TEXTUALLY ~[%WNL%%LNL%%MNL%%TAB% ]+~ ~[%WNL%%LNL%%MNL%%TAB% ]+~
    END
    SET num_matches = 0
    PATCH_IF only_count = 0 BEGIN
        REPLACE_EVALUATE CASE_INSENSITIVE ~function onCampaignButton(buttonNum)
        local campaign = startEngine:GetCampaign()
        local clickedCampaign = startButtons[campaign][buttonNum]
        if(clickedCampaign == const.START_CAMPAIGN_SOD) then
            startEngine:OnCampaignButtonClick('SOD',true)
        elseif(clickedCampaign == const.START_CAMPAIGN_BP) then
            startEngine:OnTBPButtonClick(true)
        elseif(clickedCampaign == const.START_CAMPAIGN_BG) then
            startEngine:OnSoAButtonClick(true)
        end
    end~ BEGIN
            SET num_matches = num_matches + 1
            INNER_PATCH_SAVE string ~function onCampaignButton(buttonNum)
        if buttonNum == 3 then
            startEngine:OnCampaignButtonClick('START_CAMPAIGN_PP',true)
        else
            local campaign = startEngine:GetCampaign()
            local clickedCampaign = startButtons[campaign][buttonNum]
            if(clickedCampaign == const.START_CAMPAIGN_SOD) then
                startEngine:OnCampaignButtonClick('SOD',true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BP) then
                startEngine:OnTBPButtonClick(true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BG) then
                startEngine:OnSoAButtonClick(true)
            end
        end
    end~ BEGIN
                REPLACE_TEXTUALLY ~%percent%MATCH\([0-9]+\)%percent%~ ~%MATCH\1%~
            END
        END ~function onCampaignButton(buttonNum)
        if buttonNum == 3 then
            startEngine:OnCampaignButtonClick('START_CAMPAIGN_PP',true)
        else
            local campaign = startEngine:GetCampaign()
            local clickedCampaign = startButtons[campaign][buttonNum]
            if(clickedCampaign == const.START_CAMPAIGN_SOD) then
                startEngine:OnCampaignButtonClick('SOD',true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BP) then
                startEngine:OnTBPButtonClick(true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BG) then
                startEngine:OnSoAButtonClick(true)
            end
        end
    end~
        SET warned = 0
        PATCH_IF num_matches != num BEGIN
            PATCH_IF num_matches = 0 BEGIN
                PATCH_IF warn = 1 BEGIN
                    PATCH_WARN ~WARNING %SOURCE_FILESPEC% - pattern not found:%LNL%%pattern%~
                END
                SET warned = 1
            END ELSE PATCH_IF num >= 0 AND (num_matches > num OR num_matches < num) BEGIN
                PATCH_IF warn = 1 BEGIN
                    PATCH_WARN ~WARNING %SOURCE_FILESPEC% - pattern replaced %num_matches% time(s) instead of %num%:%LNL%%pattern%~
                END
                SET warned = 1
            END
        END
        PATCH_IF verbose = 1 AND warned = 0 BEGIN
            PATCH_PRINT ~Patching %SOURCE_FILESPEC% - pattern replaced %num_matches% time(s):%LNL%%pattern% => function onCampaignButton(buttonNum)
        if buttonNum == 3 then
            startEngine:OnCampaignButtonClick('START_CAMPAIGN_PP',true)
        else
            local campaign = startEngine:GetCampaign()
            local clickedCampaign = startButtons[campaign][buttonNum]
            if(clickedCampaign == const.START_CAMPAIGN_SOD) then
                startEngine:OnCampaignButtonClick('SOD',true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BP) then
                startEngine:OnTBPButtonClick(true)
            elseif(clickedCampaign == const.START_CAMPAIGN_BG) then
                startEngine:OnSoAButtonClick(true)
            end
        end
    end~
        END
    END ELSE BEGIN
        COUNT_REGEXP_INSTANCES ~function onCampaignButton(buttonNum)
        local campaign = startEngine:GetCampaign()
        local clickedCampaign = startButtons[campaign][buttonNum]
        if(clickedCampaign == const.START_CAMPAIGN_SOD) then
            startEngine:OnCampaignButtonClick('SOD',true)
        elseif(clickedCampaign == const.START_CAMPAIGN_BP) then
            startEngine:OnTBPButtonClick(true)
        elseif(clickedCampaign == const.START_CAMPAIGN_BG) then
            startEngine:OnSoAButtonClick(true)
        end
    end~ num_matches
    END

    SET num_matches = 0
    PATCH_IF only_count = 0 BEGIN // This part is to replace the button appearance on the starting screen. He told me I have to change the area and bam in order to alter the presentation, but I still haven't figured out the new emplacement for now, since I didn't get it to work yet. 
        REPLACE_EVALUATE CASE_INSENSITIVE ~text
    {
        bam "CMPGSML"
        sequence lua 'getCampaignIcon(2)'
        frame lua "getCampaignHighlight(2)"
        area 865 490 116 116
        align center center
        tooltip lua "getCampaignTooltip(2)"
        enabled "not e:IsTouchUI()"
        action 
        "
            onCampaignButton(2)
        "
        actionEnter
        "
            highlightedCampaign = 2
        "
        actionExit
        "
            highlightedCampaign = nil
        "
    }~ BEGIN
            SET num_matches = num_matches + 1
            INNER_PATCH_SAVE string ~text
    {
        bam "FWLOGO" //The bam I'm using 
        sequence lua 'getCampaignIcon(2)'
        frame lua "getCampaignHighlight(2)"
        area 865 490 116 116 // should alter these coordinates
        align center center
        tooltip lua "getCampaignTooltip(2)"
        enabled "not e:IsTouchUI()"
        action 
        "
            onCampaignButton(3)
        "
        actionEnter
        "
            highlightedCampaign = 2
        "
        actionExit
        "
            highlightedCampaign = nil
        "
    }~ BEGIN
                REPLACE_TEXTUALLY ~%percent%MATCH\([0-9]+\)%percent%~ ~%MATCH\1%~
            END
        END ~text
    {
        bam "FWLOGO" //The bam I'm using 
        sequence lua 'getCampaignIcon(2)'
        frame lua "getCampaignHighlight(2)"
        area 865 490 116 116 // should alter these coordinates
        align center center
        tooltip lua "getCampaignTooltip(2)"
        enabled "not e:IsTouchUI()"
        action 
        "
            onCampaignButton(3)
        "
        actionEnter
        "
            highlightedCampaign = 2
        "
        actionExit
        "
            highlightedCampaign = nil
        "
    }~
        SET warned = 0
        PATCH_IF num_matches != num BEGIN
            PATCH_IF num_matches = 0 BEGIN
                PATCH_IF warn = 1 BEGIN
                    PATCH_WARN ~WARNING %SOURCE_FILESPEC% - pattern not found:%LNL%%pattern%~
                END
                SET warned = 1
            END ELSE PATCH_IF num >= 0 AND (num_matches > num OR num_matches < num) BEGIN
                PATCH_IF warn = 1 BEGIN
                    PATCH_WARN ~WARNING %SOURCE_FILESPEC% - pattern replaced %num_matches% time(s) instead of %num%:%LNL%%pattern%~
                END
                SET warned = 1
            END
        END
        PATCH_IF verbose = 1 AND warned = 0 BEGIN
            PATCH_PRINT ~Patching %SOURCE_FILESPEC% - pattern replaced %num_matches% time(s):%LNL%%pattern% => text
    {
        bam "FWLOGO"
        sequence lua 'getCampaignIcon(2)'
        frame lua "getCampaignHighlight(2)"
        area 865 490 116 116
        align center center
        tooltip lua "getCampaignTooltip(2)"
        enabled "not e:IsTouchUI()"
        action 
        "
            onCampaignButton(3)
        "
        actionEnter
        "
            highlightedCampaign = 2
        "
        actionExit
        "
            highlightedCampaign = nil
        "
    }~
        END
    END ELSE BEGIN
        COUNT_REGEXP_INSTANCES ~text
    {
        bam "CMPGSML"
        sequence lua 'getCampaignIcon(2)'
        frame lua "getCampaignHighlight(2)"
        area 865 490 116 116
        align center center
        tooltip lua "getCampaignTooltip(2)"
        enabled "not e:IsTouchUI()"
        action 
        "
            onCampaignButton(2)
        "
        actionEnter
        "
            highlightedCampaign = 2
        "
        actionExit
        "
            highlightedCampaign = nil
        "
    }~ num_matches
    END
END
END

-------------------------------------------------------------------------------------------------------------------

So, first I cleaned up the BGEE fold of override content, unistall and reinstalling the game to make sure there were no mod left to alter the original content and the game starts fine. I get the presentation screen, with the icon proposing SoD, like it normally would. 

Once I install my campaign mod, the game launches but without the DLC SoD content, making it impossible to access the DLC, which I need to start my mod. I only get the basic screen of BGEE. 

I have tried only the part of the coding changing the starting button on click, leaving the part that changes the icon, but it does the same problem. 

This is the part I'm trying to resolve. I'm pretty much left dumbfunded at this point. Any insight would be greatly appreciated. 

Link to comment

So after you made your uninstall... did you clear the install folder completely, as uninstall won't probably do that correctly .. and the override folder could contain essential game files... at least the non-EE BG2's did, so clearing that will not help you. Clearing the game folder will remove all modified files from the next install.

... and then after the reinstall, you also have to start the game and re-install the DLCmerger, which is a better version of the modmerger. And you do that before you install any mods.

Edited by Jarno Mikkola
Link to comment

I tried the DLC merger before with my coding, making sure to clear override, but not install, which could explain the issue. Ill just clear the whole thing and start again. 

Always doubts Ive been careful. And if it doesnt work, well ill just include my mod throught an npc in the main quest of bgee. Only downside i will not be able to replace the main map. 

Thx @Jarno Mikkola!

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...