Results 1 to 6 of 6

Thread: Automatic Protectorate Handover Question

  1. #1

    Default Automatic Protectorate Handover Question

    I enjoy TROM, but I'm not a big fan of the protectorates sticking around -- let's face it, they're goofy!

    So I poked into the scripting file and noticed the following

    Spoiler Alert, click show to read: 

    Code:
    local function OnFactionTurnStart(context)
    	if conditions.TurnNumber(context) == 2 then
    		if conditions.FactionName("britain", context) and conditions.FactionIsHuman("britain", context) then
    			scripting.game_interface:trigger_custom_mission("britain_protectorate", "britain", "protectorate_region_capture", 0, "georgia_usa+cherokee_territory+new_france", "", "mission_text_text_main_protectorate_thirteen_colonies_text", "mission_text_text_main_protectorate_thirteen_colonies_reward", 0, "thirteen_colonies", context)
    		elseif conditions.FactionName("spain", context) and conditions.FactionIsHuman("spain", context) then
    			scripting.game_interface:trigger_custom_mission("spain_protectorate", "spain", "protectorate_region_capture", 0, "trinidad_tobago+tejas+curacao", "", "mission_text_text_main_protectorate_new_spain_text", "mission_text_text_main_protectorate_new_spain_reward", 0, "new_spain", context)
    		elseif conditions.FactionName("france", context) and conditions.FactionIsHuman("france", context) then
    			scripting.game_interface:trigger_custom_mission("france_protectorate", "france", "protectorate_region_capture", 0, "michigan_territory+algonquin_territory+cherokee_territory", "", "mission_text_text_main_protectorate_louisiana_text", "mission_text_text_main_protectorate_louisiana_reward", 0, "louisiana", context)
    		end
    	elseif conditions.TurnNumber(context) == 5 then
    		scripting.game_interface:enable_auto_generated_missions(true)
    	end
    	
    	if conditions.FactionName("britain", context) and not conditions.FactionIsHuman("britain", context) then
    		scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 6, 15, context)
    	elseif conditions.FactionName("spain", context) and not conditions.FactionIsHuman("spain", context) then
    		scripting.game_interface:grant_faction_handover("spain", "new_spain", 6, 15, context)
    	elseif conditions.FactionName("france", context) and not conditions.FactionIsHuman("france", context) then
    		scripting.game_interface:grant_faction_handover("france", "louisiana", 6, 15, context)
    	end
    end


    I tried replacing it with a few variations:

    Spoiler Alert, click show to read: 


    First this:
    Code:
    local function OnFactionTurnStart(context)
    	if conditions.TurnNumber(context) == 0 then
    		scripting.game_interface:enable_auto_generated_missions(true)
    	end
    	
    if conditions.FactionName("britain", context)  then
    		scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 6, 15, context)
    	elseif conditions.FactionName("spain", context) then
    		scripting.game_interface:grant_faction_handover("spain", "new_spain", 6, 15, context)
    	elseif conditions.FactionName("france", context)  then
    		scripting.game_interface:grant_faction_handover("france", "louisiana", 6, 15, context)
    	end
    end
    Then this, which I pulled out of the stand alone mod that does what I'm attempting to do:

    Code:
    local function OnFactionTurnStart(context)
    	if conditions.TurnNumber(context) == 3 then
    		scripting.game_interface:enable_auto_generated_missions(true)
    	end
    	
    	if conditions.FactionName("britain", context) then
    		scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 1, 1, context)
    	elseif conditions.FactionName("spain", context) then
    		scripting.game_interface:grant_faction_handover("spain", "new_spain", 1, 1, context)
    	elseif conditions.FactionName("france", context) then
    		scripting.game_interface:grant_faction_handover("france", "louisiana", 1, 1, context)
    	end
    end
    And finally a melange:

    Code:
    local function OnFactionTurnStart(context)
    	if conditions.TurnNumber(context) == 0 then
    		scripting.game_interface:enable_auto_generated_missions(true)
    	end
    	
    	if conditions.FactionName("britain", context) then
    		scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 1, 1, context)
    	elseif conditions.FactionName("spain", context) then
    		scripting.game_interface:grant_faction_handover("spain", "new_spain", 1, 1, context)
    	elseif conditions.FactionName("france", context) then
    		scripting.game_interface:grant_faction_handover("france", "louisiana", 1, 1, context)
    	end
    
    if conditions.FactionName("britain", context) and not conditions.FactionIsHuman("britain", context) then
    		scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 6, 15, context)
    	elseif conditions.FactionName("spain", context) and not conditions.FactionIsHuman("spain", context) then
    		scripting.game_interface:grant_faction_handover("spain", "new_spain", 6, 15, context)
    	elseif conditions.FactionName("france", context) and not conditions.FactionIsHuman("france", context) then
    		scripting.game_interface:grant_faction_handover("france", "louisiana", 6, 15, context)
    	end
    end
    I also tried a further variation, where I varied the turn counter at which the hand over would occur, from one to zero, which I won't bother to display here.



    All the variations I tried reliably handed over the protectorates to my player country, regardless of which country I was playing. The ai, however, never received their colonies. All variations required me to hit end turn once, which is hardly ideal.

    I'd like to do two things:

    1) Have protectorates disappear for the AI as well as myself
    2) Have it happen on the first turn without needing to hit end turn

    If I could get a few hints as to where I'm going wrong, I'd be extremely grateful.

    I'm guessing that I need to use OnWorldCreated* in some fashion to deal with my #2, but I'm completely stumped on #1. This is far more frustrating than reverting to the default ui textures -- mostly because I'm totally lost at this point. Thanks for the help!

    Oh, and if I ever get it running, I'll toss it up here for other folks -- no doubt it'll be obsolete pdq, but I figure that it'd at least be there for a bit.

    *I tried condition.OnWorldCreated(context), but it didn't do anything. Back to the failing board!
    Last edited by Aeon221; June 29, 2009 at 09:27 PM.

  2. #2

    Default Re: Automatic Protectorate Handover Question

    Couple of things:

    2) Despite the existence of the trigger you mention, I'm not sure that there's a way to execute a script on "Turn 0". You may ask around the scripting mod board.

    1) This should be possible -- I am almost certaint there's already a script that does this -- have a look around.

    Personally, I would really like to see protectorates for the AI operate under the same rules as for the player, but the AI be "motivated" to take the necessary trigger terretories.

    Sage

    Quote Originally Posted by Aeon221 View Post
    I enjoy TROM, but I'm not a big fan of the protectorates sticking around -- let's face it, they're goofy!

    So I poked into the scripting file and noticed the following

    Spoiler Alert, click show to read: 

    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 2 then
            if conditions.FactionName("britain", context) and conditions.FactionIsHuman("britain", context) then
                scripting.game_interface:trigger_custom_mission("britain_protectorate", "britain", "protectorate_region_capture", 0, "georgia_usa+cherokee_territory+new_france", "", "mission_text_text_main_protectorate_thirteen_colonies_text", "mission_text_text_main_protectorate_thirteen_colonies_reward", 0, "thirteen_colonies", context)
            elseif conditions.FactionName("spain", context) and conditions.FactionIsHuman("spain", context) then
                scripting.game_interface:trigger_custom_mission("spain_protectorate", "spain", "protectorate_region_capture", 0, "trinidad_tobago+tejas+curacao", "", "mission_text_text_main_protectorate_new_spain_text", "mission_text_text_main_protectorate_new_spain_reward", 0, "new_spain", context)
            elseif conditions.FactionName("france", context) and conditions.FactionIsHuman("france", context) then
                scripting.game_interface:trigger_custom_mission("france_protectorate", "france", "protectorate_region_capture", 0, "michigan_territory+algonquin_territory+cherokee_territory", "", "mission_text_text_main_protectorate_louisiana_text", "mission_text_text_main_protectorate_louisiana_reward", 0, "louisiana", context)
            end
        elseif conditions.TurnNumber(context) == 5 then
            scripting.game_interface:enable_auto_generated_missions(true)
        end
     
        if conditions.FactionName("britain", context) and not conditions.FactionIsHuman("britain", context) then
            scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 6, 15, context)
        elseif conditions.FactionName("spain", context) and not conditions.FactionIsHuman("spain", context) then
            scripting.game_interface:grant_faction_handover("spain", "new_spain", 6, 15, context)
        elseif conditions.FactionName("france", context) and not conditions.FactionIsHuman("france", context) then
            scripting.game_interface:grant_faction_handover("france", "louisiana", 6, 15, context)
        end
    end


    I tried replacing it with a few variations:

    Spoiler Alert, click show to read: 


    First this:
    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 0 then
            scripting.game_interface:enable_auto_generated_missions(true)
        end
     
    if conditions.FactionName("britain", context)  then
            scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 6, 15, context)
        elseif conditions.FactionName("spain", context) then
            scripting.game_interface:grant_faction_handover("spain", "new_spain", 6, 15, context)
        elseif conditions.FactionName("france", context)  then
            scripting.game_interface:grant_faction_handover("france", "louisiana", 6, 15, context)
        end
    end
    Then this, which I pulled out of the stand alone mod that does what I'm attempting to do:

    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 3 then
            scripting.game_interface:enable_auto_generated_missions(true)
        end
     
        if conditions.FactionName("britain", context) then
            scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 1, 1, context)
        elseif conditions.FactionName("spain", context) then
            scripting.game_interface:grant_faction_handover("spain", "new_spain", 1, 1, context)
        elseif conditions.FactionName("france", context) then
            scripting.game_interface:grant_faction_handover("france", "louisiana", 1, 1, context)
        end
    end
    And finally a melange:

    Code:
    local function OnFactionTurnStart(context)
        if conditions.TurnNumber(context) == 0 then
            scripting.game_interface:enable_auto_generated_missions(true)
        end
     
        if conditions.FactionName("britain", context) then
            scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 1, 1, context)
        elseif conditions.FactionName("spain", context) then
            scripting.game_interface:grant_faction_handover("spain", "new_spain", 1, 1, context)
        elseif conditions.FactionName("france", context) then
            scripting.game_interface:grant_faction_handover("france", "louisiana", 1, 1, context)
        end
     
    if conditions.FactionName("britain", context) and not conditions.FactionIsHuman("britain", context) then
            scripting.game_interface:grant_faction_handover("britain", "thirteen_colonies", 6, 15, context)
        elseif conditions.FactionName("spain", context) and not conditions.FactionIsHuman("spain", context) then
            scripting.game_interface:grant_faction_handover("spain", "new_spain", 6, 15, context)
        elseif conditions.FactionName("france", context) and not conditions.FactionIsHuman("france", context) then
            scripting.game_interface:grant_faction_handover("france", "louisiana", 6, 15, context)
        end
    end
    I also tried a further variation, where I varied the turn counter at which the hand over would occur, from one to zero, which I won't bother to display here.



    All the variations I tried reliably handed over the protectorates to my player country, regardless of which country I was playing. The ai, however, never received their colonies. All variations required me to hit end turn once, which is hardly ideal.

    I'd like to do two things:

    1) Have protectorates disappear for the AI as well as myself
    2) Have it happen on the first turn without needing to hit end turn

    If I could get a few hints as to where I'm going wrong, I'd be extremely grateful.

    I'm guessing that I need to use OnWorldCreated* in some fashion to deal with my #2, but I'm completely stumped on #1. This is far more frustrating than reverting to the default ui textures -- mostly because I'm totally lost at this point. Thanks for the help!

    Oh, and if I ever get it running, I'll toss it up here for other folks -- no doubt it'll be obsolete pdq, but I figure that it'd at least be there for a bit.

    *I tried condition.OnWorldCreated(context), but it didn't do anything. Back to the failing board!

  3. #3
    Serenissima's Avatar Tiro
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    226

    Default Re: Automatic Protectorate Handover Question

    The second script you tried hands over the colonies to their AI owners for me. It happens in the turn after one gets ones' own colonies back (tested playing as Britain), but it does happen.
    Most Serene.

  4. #4

    Default Re: Automatic Protectorate Handover Question

    Yeah, all my test games were two turns. When I played to turn three as Prussia, all three ai countries received their protectorates. I was using the third script I posted.

    I'm not sure why it takes so long, but they both work fine. Weird.

  5. #5
    Civis
    Join Date
    Mar 2009
    Location
    Delaware, U.S.A
    Posts
    167

    Default Re: Automatic Protectorate Handover Question

    Your script goes after specific protectorate. Is there enough script methods for the following

    1. Identify the protectorates of a specific nation
    2. Perform the hand over once a nation as been someone's protectorate for x turns

    In other words, take your idea and make the handover process dynamic

  6. #6

    Default Re: Automatic Protectorate Handover Question

    Quote Originally Posted by Marechal_Davout View Post
    Your script goes after specific protectorate. Is there enough script methods for the following

    1. Identify the protectorates of a specific nation
    2. Perform the hand over once a nation as been someone's protectorate for x turns

    In other words, take your idea and make the handover process dynamic
    Good question! Why don't you find out! =D

Posting Permissions

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