Results 1 to 5 of 5

Thread: How to Make Emergent Faction Playable - NO HYBRID

  1. #1
    bk2-modder's Avatar Libertus
    Join Date
    Jun 2013
    Location
    In the greatest country on earth
    Posts
    74

    Default How to Make Emergent Faction Playable - NO HYBRID

    How to Make an Emergent Faction Playable - NO HYBRID

    Introduction:
    We all know that in making an emergent faction playable with a hybrid, that hybrid startpos is typically only stable for that emergent faction. Hybrid startposes cause other factions to experience unstable campaigns, and many modders have wondered how to make an emergent faction playable without this problem. With the scripting.lua file, it is very much possible to do this, but you will have to select two emergent factions to modify; one that will be playable, and one that won't.



    NOTE:
    This tutorial is assuming that you have at least some know-how about the startpos and have read HusserlTW's Startpos analysis and modding tutorials


    Tutorial:
    To make your emergent faction playable without a hybrid, you will need to edit 2 files: startpos.esf, and scripting.lua. So, make sure you have an ESF Editor of your choice (I typically use 1.4.5 or 1.4.3 for ETW modding) as well as a text editor capable of editing and saving .lua files.

    Step 1: Make backups of startpos.esf and scripting.lua, and choose which nation you want to make playable and which nation will be sacrificed to help make it playable. In this tutorial, I will be making Quebec playable and sacrificing Hessen.

    Step 2: Open startpos.esf in your ESF file editor; it is important that you follow all ESF editing steps properly, though this tutorial only goes over how to make the faction playable; you will have to add victory conditions and other features yourself.

    Step 3: Following HusserlTW's tutorial here, follow the steps in making an emergent faction of your choice [in this case, Quebec] playable up to the point of hybrid. Do NOT enter the game or begin to make a hybrid startpos. Keep your ESF Editor open, do not save changes yet. In summary of this step, you turn the faction of your choice into a non-emergent faction, give them their capital region ID, and make them select-able in the main menu.

    Step 4: Now, open up CAMPAIGN_ENV/CAMPAIGN_MODEL/WORLD/FACTION_ARRAY/[name of faction], and change the 14th line from FALSE to TRUE; this changes them from being emergent, which is key to this process. In the 11th and 12th lines, enter the same capitol region ID you are using for the faction your want to make playable. Also copy this faction's ID into your clipboard [i.e., right click and press COPY for JUST the ID]

    Step 5: Go to CAMPAIGN_ENV/CAMPAIGN_MODEL/WORLD/REGION_ARRAY and in the regions that you want your playable to own in-game (I am changing this for New_France), change the region ownership to the SECOND faction (in this case, Hessen) by changing the 16th line of CAMPAIGN_ENV/CAMPAIGN_MODEL/WORLD/REGION_ARRAY/[region of choice] and then changing all of the SIEGEABLE_GARRISON entry IDs to your SECOND faction's ID, just as HusserlTW's tutorial describes in the section about changing region ownership.

    Step 6: Now, you can save your startpos.esf and open up scripting.lua. In scripting lua, we want the entire secondary faction (Hessen) to be handed over to our chosen faction (Quebec) on the very start of the game, thus giving our chosen faction a fully playable government, region, and autonomy at the start.

    Step 7: When you open scripting.lua, you should get something like this:
    Spoiler Alert, click show to read: 

    What we want to do is change it to look something more like this:
    Spoiler Alert, click show to read: 

    by either deleting the lines regarding the Cherokee's first mission or moving it to fall under turn 2, and replacing them (shown below)
    Spoiler Alert, click show to read: 
    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 1 then
            if conditions.FactionName("cherokee", context) and conditions.FactionIsHuman("cherokee", context) then
                 scripting.game_interface:trigger_custom_mission("britain_protectorate",  "cherokee", "capture_city", 0, "Acadia", "",  "main_mission_capture_city_text", "main_protectorate_new_spain_reward",  2000, "", context)
            end

    with
    Spoiler Alert, click show to read: 
    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 1 and conditions.FactionIsHuman(context) then
                scripting.game_interface:grant_faction_handover("quebec", "hessen", 0, 0, context)


    Step 8: The above line says to the game that on Turn 1, when a human player is present (something that is ALWAYS the case) then a faction handover will occur, giving Hessen to Quebec. Simply replace those country names in the script with the ones you want to use, and place both the final scripting.lua and startpos.esf in your campaigns/main folder, and it should work. The final result of all this work is shown below, and, as you can see, it works!
    Spoiler Alert, click show to read: 
    [IMG] upload img[/IMG]


    UPDATE: You could, alternatively, eliminate the turn 1 scripting section and instead place your faction handover script like so:
    local function OnWorldCreated()
    scripting.game_interface:grant_faction_handover("scotland", "hessen", 0, 0, context)
    scripting.game_interface:technology_osmosis_for_playables_enable_culture("european")
    scripting.game_interface:technology_osmosis_for_playables_enable_all()
    scripting.game_interface:enable_auto_generated_missions(true)
    near the bottom of the scripting.lua file. I haven't tested it too much, but it might be more stable. Please let me know if you try this instead.
    Final Words
    I'm hoping that this tutorial helped you with making an emergent faction playable without a hybrid, and I am hoping to see more mods that use the scripting.lua, though the Empire community may be smaller now. The limitations of this method are that it takes two emergents to make one playable, but I'm sure if someone can figure out how to hand individual regions over at a time in the scripting.lua, all emergents could be added in one campaign this way. This is my first tutorial, so I may not have been entirely clear. If you want to see an example to help you, I have an example mod attached that makes Quebec playable without any victory conditions or other bells and whistles, but I must warn you that I made other changes to the scripting.lua for my other mods; it is just demonstrating how this method works. Please feel free to modify it for your own needs or mods, but please credit me if you release works using any of mine!
    Remember: I've only tested this mod for a 20 year campaign so far, and no problems, but I have experienced random crashes that don't affect the game long-term, but I'm not sure if these crashes are caused by this method or my crappy computer. You've been forewarned.
    If you have any questions, please PM me or comment in the thread below.

    Download for Example Mod (Quebec): http://www.mediafire.com/download/98mrms3s93t5srp/Quebec_Non-Hybrid_Demonstration.zip [18MB]
    Last edited by bk2-modder; August 01, 2017 at 10:03 PM.

  2. #2
    Alwyn's Avatar Frothy Goodness
    Content Director Patrician Citizen

    Join Date
    Feb 2014
    Location
    United Kingdom
    Posts
    12,291

    Default Re: How to Make Emergent Faction Playable - NO HYBRID

    Great tutorial, thank you!

  3. #3

    Default Re: How to Make Emergent Faction Playable - NO HYBRID

    Great job! Very good tutorial, it's very useful

  4. #4
    bk2-modder's Avatar Libertus
    Join Date
    Jun 2013
    Location
    In the greatest country on earth
    Posts
    74

    Default Re: How to Make Emergent Faction Playable - NO HYBRID

    It should also be possible to make it so a faction is only present on the campaign map if a human player decides to select it. In other words, you could set up a scenario where you could play as a rebellion, but that rebellion only exists if you choose to play as it. This can be accomplished with scripting lines such as those below.

    if conditions.FactionName("britain", context) and not conditions.FactionIsHuman("thirteen_colonies", context) then
    scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 6, 15, context)
    elseif conditions.FactionName("spain", context) and not conditions.FactionIsHuman("new_spain", context) then
    scripting.game_interface:grant_faction_handover("spain", "new_spain", 6, 15, context)
    elseif conditions.FactionName("france", context) and not conditions.FactionIsHuman("louisiana", context) then
    scripting.game_interface:grant_faction_handover("france", "louisiana", 6, 15, context)
    elseif conditions.FactionName("hessen", context) and not conditions.FactionIsHuman("hessen", context) then
    scripting.game_interface:grant_faction_handover("mughal", "hessen", 0, 0, context)

  5. #5

    Default Re: How to Make Emergent Faction Playable - NO HYBRID

    Quote Originally Posted by bk2-modder View Post
    How to Make an Emergent Faction Playable - NO HYBRID

    Introduction:
    We all know that in making an emergent faction playable with a hybrid, that hybrid startpos is typically only stable for that emergent faction. Hybrid startposes cause other factions to experience unstable campaigns, and many modders have wondered how to make an emergent faction playable without this problem. With the scripting.lua file, it is very much possible to do this, but you will have to select two emergent factions to modify; one that will be playable, and one that won't.



    NOTE:
    This tutorial is assuming that you have at least some know-how about the startpos and have read HusserlTW's Startpos analysis and modding tutorials


    Tutorial:
    To make your emergent faction playable without a hybrid, you will need to edit 2 files: startpos.esf, and scripting.lua. So, make sure you have an ESF Editor of your choice (I typically use 1.4.5 or 1.4.3 for ETW modding) as well as a text editor capable of editing and saving .lua files.

    Step 1: Make backups of startpos.esf and scripting.lua, and choose which nation you want to make playable and which nation will be sacrificed to help make it playable. In this tutorial, I will be making Quebec playable and sacrificing Hessen.

    Step 2: Open startpos.esf in your ESF file editor; it is important that you follow all ESF editing steps properly, though this tutorial only goes over how to make the faction playable; you will have to add victory conditions and other features yourself.

    Step 3: Following HusserlTW's tutorial here, follow the steps in making an emergent faction of your choice [in this case, Quebec] playable up to the point of hybrid. Do NOT enter the game or begin to make a hybrid startpos. Keep your ESF Editor open, do not save changes yet. In summary of this step, you turn the faction of your choice into a non-emergent faction, give them their capital region ID, and make them select-able in the main menu.

    Step 4: Now, open up CAMPAIGN_ENV/CAMPAIGN_MODEL/WORLD/FACTION_ARRAY/[name of faction], and change the 14th line from FALSE to TRUE; this changes them from being emergent, which is key to this process. In the 11th and 12th lines, enter the same capitol region ID you are using for the faction your want to make playable. Also copy this faction's ID into your clipboard [i.e., right click and press COPY for JUST the ID]

    Step 5: Go to CAMPAIGN_ENV/CAMPAIGN_MODEL/WORLD/REGION_ARRAY and in the regions that you want your playable to own in-game (I am changing this for New_France), change the region ownership to the SECOND faction (in this case, Hessen) by changing the 16th line of CAMPAIGN_ENV/CAMPAIGN_MODEL/WORLD/REGION_ARRAY/[region of choice] and then changing all of the SIEGEABLE_GARRISON entry IDs to your SECOND faction's ID, just as HusserlTW's tutorial describes in the section about changing region ownership.

    Step 6: Now, you can save your startpos.esf and open up scripting.lua. In scripting lua, we want the entire secondary faction (Hessen) to be handed over to our chosen faction (Quebec) on the very start of the game, thus giving our chosen faction a fully playable government, region, and autonomy at the start.

    Step 7: When you open scripting.lua, you should get something like this:
    Spoiler Alert, click show to read: 

    What we want to do is change it to look something more like this:
    Spoiler Alert, click show to read: 

    by either deleting the lines regarding the Cherokee's first mission or moving it to fall under turn 2, and replacing them (shown below)
    Spoiler Alert, click show to read: 
    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 1 then
            if conditions.FactionName("cherokee", context) and conditions.FactionIsHuman("cherokee", context) then
                 scripting.game_interface:trigger_custom_mission("britain_protectorate",  "cherokee", "capture_city", 0, "Acadia", "",  "main_mission_capture_city_text", "main_protectorate_new_spain_reward",  2000, "", context)
            end

    with
    Spoiler Alert, click show to read: 
    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 1 and conditions.FactionIsHuman(context) then
                scripting.game_interface:grant_faction_handover("quebec", "hessen", 0, 0, context)


    Step 8: The above line says to the game that on Turn 1, when a human player is present (something that is ALWAYS the case) then a faction handover will occur, giving Hessen to Quebec. Simply replace those country names in the script with the ones you want to use, and place both the final scripting.lua and startpos.esf in your campaigns/main folder, and it should work. The final result of all this work is shown below, and, as you can see, it works!
    Spoiler Alert, click show to read: 
    [IMG] upload img[/IMG]


    UPDATE: You could, alternatively, eliminate the turn 1 scripting section and instead place your faction handover script like so:
    local function OnWorldCreated()
    scripting.game_interface:grant_faction_handover("scotland", "hessen", 0, 0, context)
    scripting.game_interface:technology_osmosis_for_playables_enable_culture("european")
    scripting.game_interface:technology_osmosis_for_playables_enable_all()
    scripting.game_interface:enable_auto_generated_missions(true)
    near the bottom of the scripting.lua file. I haven't tested it too much, but it might be more stable. Please let me know if you try this instead.
    Final Words
    I'm hoping that this tutorial helped you with making an emergent faction playable without a hybrid, and I am hoping to see more mods that use the scripting.lua, though the Empire community may be smaller now. The limitations of this method are that it takes two emergents to make one playable, but I'm sure if someone can figure out how to hand individual regions over at a time in the scripting.lua, all emergents could be added in one campaign this way. This is my first tutorial, so I may not have been entirely clear. If you want to see an example to help you, I have an example mod attached that makes Quebec playable without any victory conditions or other bells and whistles, but I must warn you that I made other changes to the scripting.lua for my other mods; it is just demonstrating how this method works. Please feel free to modify it for your own needs or mods, but please credit me if you release works using any of mine!
    Remember: I've only tested this mod for a 20 year campaign so far, and no problems, but I have experienced random crashes that don't affect the game long-term, but I'm not sure if these crashes are caused by this method or my crappy computer. You've been forewarned.
    If you have any questions, please PM me or comment in the thread below.

    Download for Example Mod (Quebec): http://www.mediafire.com/download/98mrms3s93t5srp/Quebec_Non-Hybrid_Demonstration.zip [18MB]
    Just to clarify. Step 4 refers to the 2nd Nation (the one you will be sacrificing, in this case Hessen). IN particolar you must change the 14th line from TRUE to FALSE,in order to make the 2nd faction NOT EMERGENT. Hope this will help someone in the future.
    At step 5, do not, for any reason, change the SIEGIABLE_GARRISON under the SETTLEMENT appendix, or it will create instabilties at higher number of turns, resolting in CTD continuos during AI turn.
    I tested it for my mod and it worked.
    Last edited by franceriboli; August 15, 2022 at 10:09 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •