Page 1 of 2 12 LastLast
Results 1 to 20 of 34

Thread: using a script to change ownership

  1. #1

    Default using a script to change ownership

    Does anyone know how to change ownership of a province at the start of a campaign? I'm adjusting my campaign script so that if the player isn't playing a certain faction. That faction would get another province. The province in question belongs to the slave faction and of course has a garrison. Thank you in advance for any help.

  2. #2
    Sertorio's Avatar Domesticus
    Join Date
    Jul 2011
    Location
    Castelo dos Mouros, Portugal
    Posts
    2,475

    Default Re: using a script to change ownership

    The descr_strat in data/world/maps/campaign maybe ?

  3. #3

    Default Re: using a script to change ownership

    That would change ownership when the player plays that faction also. I only want to change ownership when the ai controls the faction.

  4. #4
    Sertorio's Avatar Domesticus
    Join Date
    Jul 2011
    Location
    Castelo dos Mouros, Portugal
    Posts
    2,475

    Default Re: using a script to change ownership

    Oh....ok

  5. #5
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: using a script to change ownership

    Add a campaign script at the end of descr_strat.txt. In the campaign script, switch to the faction that should get the region using console_command control <faction>, console_command capture_settlement <settlement_name> to pass it to that faction, then switch back to the player faction. For example, let's say you want to give Rome to carthage:

    Code:
    declare_counter PlayerFaction
    
    if I_LocalFaction carthage
        set_counter PlayerFaction 1
    end_if
    
    if I_LocalFaction gauls
        set_counter PlayerFaction 2
    end_if
    
    ; etc, for all other factions
    
    
    if I_CompareCounter PlayerFaction != 1
    
      console_command control carthage
      console_command capture_settlement Rome
    
      ; pass control back to the player faction
      if I_CompareCounter PlayerFaction =  2
        console_command control gauls
      end_if
    
      ; do the same check for all the other factions (except the one you gave the settlement to)
    end_if
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  6. #6

    Default Re: using a script to change ownership

    do I have to get rid of the slave garrison?

    Here's the script as I typed it in.

    Spoiler Alert, click show to read: 

    declare_counter PlayerFaction

    if I_LocalFaction romans_scipii
    set_counter PlayerFaction 1
    end_if

    if I_LocalFaction romans_brutii
    set_counter PlayerFaction 2
    end_if

    if I_LocalFaction pontus
    set_counter PlayerFaction 3
    end_if

    if I_LocalFaction germans
    set_counter PlayerFaction 4
    end_if

    if I_LocalFaction britons
    set_counter PlayerFaction 5
    end_if

    if I_LocalFaction romans_julii
    set_counter PlayerFaction 6
    end_if

    if I_LocalFaction romans_senate
    set_counter PlayerFaction 7
    end_if

    if I_LocalFaction egypt
    set_counter PlayerFaction 8
    end_if

    if I_LocalFaction greek_cities
    set_counter PlayerFaction 9
    end_if

    if I_LocalFaction macedon
    set_counter PlayerFaction 10
    end_if

    if I_LocalFaction carthage
    set_counter PlayerFaction 11
    end_if

    if I_LocalFaction seleucid
    set_counter PlayerFaction 13
    end_if

    if I_LocalFaction scythia
    set_counter PlayerFaction 14
    end_if

    if I_LocalFaction parthia
    set_counter PlayerFaction 15
    end_if

    if I_LocalFaction gauls
    set_counter PlayerFaction 16
    end_if

    if I_LocalFaction armenia
    set_counter PlayerFaction 17
    end_if

    if I_LocalFaction dacia
    set_counter PlayerFaction 18
    end_if

    if I_LocalFaction numidia
    set_counter PlayerFaction 19
    end_if

    if I_LocalFaction spain
    set_counter PlayerFaction 20
    end_if

    if I_LocalFaction thrace
    set_counter PlayerFaction 21
    end_if

    ; etc, for all other factions


    if not I_CompareCounter PlayerFaction = 1

    console_command control romans_scipii
    console_command capture_settlement Campus_Melanchlaeni
    console_command capture_settlement Vicus_Careotae
    console_command capture_settlement Campus_Roxolani

    end_if

    ; pass control back to the player faction


    if I_CompareCounter PlayerFaction = 2
    console_command control romans_brutii
    end_if

    if I_CompareCounter PlayerFaction = 3
    console_command control pontus
    end_if

    if I_CompareCounter PlayerFaction = 4
    console_command control germans
    end_if

    if I_CompareCounter PlayerFaction = 5
    console_command control britons
    end_if

    if I_CompareCounter PlayerFaction = 6
    console_command control romans_julii
    end_if

    if I_CompareCounter PlayerFaction = 7
    console_command control romans_senate
    end_if

    if I_CompareCounter PlayerFaction = 8
    console_command control egypt
    end_if

    if I_CompareCounter PlayerFaction = 9
    console_command control greek_cities
    end_if

    if I_CompareCounter PlayerFaction = 10
    console_command control macedon
    end_if

    if I_CompareCounter PlayerFaction = 11
    console_command control carthage
    end_if

    if I_CompareCounter PlayerFaction = 13
    console_command control seleucid
    end_if

    if I_CompareCounter PlayerFaction = 14
    console_command control scythia
    end_if

    if I_CompareCounter PlayerFaction = 15
    console_command control parthia
    end_if

    if I_CompareCounter PlayerFaction = 16
    console_command control gauls
    end_if

    if I_CompareCounter PlayerFaction = 17
    console_command control armenia
    end_if

    if I_CompareCounter PlayerFaction = 18
    console_command control dacia
    end_if

    if I_CompareCounter PlayerFaction = 19
    console_command control numidia
    end_if

    if I_CompareCounter PlayerFaction = 20
    console_command control spain
    end_if

    if I_CompareCounter PlayerFaction = 21
    console_command control thrace
    end_if

    later in the script I add a faction garrison if the player isn't romans_scipii

    If I select a faction other than romans_scipii, it adds the garrison but doesn't remove the slave garrison and control stays with the rebels.
    If I select romans_scipii. I get CTD
    Last edited by Squid; January 04, 2012 at 09:55 AM. Reason: Spoilers are your friend

  7. #7
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: using a script to change ownership

    - All the conditions for passing control back to the player faction should be inside the same if block where you pass settlements
    - Please use "if ... != 1" instead of "if not ... = 1"
    - I thought the capture_settlement command is supposed to kick the original garrison out. If for some reason that isn't happening, remove the rebel garrison from descr_strat.txt and add it as part of the campaign_script, as needed
    - Any idea whether the CTD happens before or after the settlements are passed? You could try adding wait 3 between capture_settlement commands for debugging purposes
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  8. #8

    Default Re: using a script to change ownership

    I made the changes you suggested. I had assumed that the i=1 was a typo. Sorry about that.
    Here's what it looks like now.

    Spoiler Alert, click show to read: 

    console_command toggle_perfect_spy

    declare_counter PlayerFaction

    if I_LocalFaction romans_scipii
    set_counter PlayerFaction 1
    end_if

    if I_LocalFaction romans_brutii
    set_counter PlayerFaction 2
    end_if

    if I_LocalFaction pontus
    set_counter PlayerFaction 3
    end_if

    if I_LocalFaction germans
    set_counter PlayerFaction 4
    end_if

    if I_LocalFaction britons
    set_counter PlayerFaction 5
    end_if

    if I_LocalFaction romans_julii
    set_counter PlayerFaction 6
    end_if

    if I_LocalFaction romans_senate
    set_counter PlayerFaction 7
    end_if

    if I_LocalFaction egypt
    set_counter PlayerFaction 8
    end_if

    if I_LocalFaction greek_cities
    set_counter PlayerFaction 9
    end_if

    if I_LocalFaction macedon
    set_counter PlayerFaction 10
    end_if

    if I_LocalFaction carthage
    set_counter PlayerFaction 11
    end_if

    if I_LocalFaction seleucid
    set_counter PlayerFaction 13
    end_if

    if I_LocalFaction scythia
    set_counter PlayerFaction 14
    end_if

    if I_LocalFaction parthia
    set_counter PlayerFaction 15
    end_if

    if I_LocalFaction gauls
    set_counter PlayerFaction 16
    end_if

    if I_LocalFaction armenia
    set_counter PlayerFaction 17
    end_if

    if I_LocalFaction dacia
    set_counter PlayerFaction 18
    end_if

    if I_LocalFaction numidia
    set_counter PlayerFaction 19
    end_if

    if I_LocalFaction spain
    set_counter PlayerFaction 20
    end_if

    if I_LocalFaction thrace
    set_counter PlayerFaction 21
    end_if

    ; console_command toggle_perfect_spy

    ; etc, for all other factions

    if I_CompareCounter PlayerFaction != 1

    console_command control romans_scipii
    console_command capture_settlement Campus_Melanchlaeni
    console_command capture_settlement Vicus_Careotae
    console_command capture_settlement Campus_Roxolani


    ; pass control back to the player faction


    if I_CompareCounter PlayerFaction = 2
    console_command control romans_brutii
    end_if

    if I_CompareCounter PlayerFaction = 3
    console_command control pontus
    end_if

    if I_CompareCounter PlayerFaction = 4
    console_command control germans
    end_if

    if I_CompareCounter PlayerFaction = 5
    console_command control britons
    end_if

    if I_CompareCounter PlayerFaction = 6
    console_command control romans_julii
    end_if

    if I_CompareCounter PlayerFaction = 7
    console_command control romans_senate
    end_if

    if I_CompareCounter PlayerFaction = 8
    console_command control egypt
    end_if

    if I_CompareCounter PlayerFaction = 9
    console_command control greek_cities
    end_if

    if I_CompareCounter PlayerFaction = 10
    console_command control macedon
    end_if

    if I_CompareCounter PlayerFaction = 11
    console_command control carthage
    end_if

    if I_CompareCounter PlayerFaction = 13
    console_command control seleucid
    end_if

    if I_CompareCounter PlayerFaction = 14
    console_command control scythia
    end_if

    if I_CompareCounter PlayerFaction = 15
    console_command control parthia
    end_if

    if I_CompareCounter PlayerFaction = 16
    console_command control gauls
    end_if

    if I_CompareCounter PlayerFaction = 17
    console_command control armenia
    end_if

    if I_CompareCounter PlayerFaction = 18
    console_command control dacia
    end_if

    if I_CompareCounter PlayerFaction = 19
    console_command control numidia
    end_if

    if I_CompareCounter PlayerFaction = 20
    console_command control spain
    end_if

    if I_CompareCounter PlayerFaction = 21
    console_command control thrace
    end_if

    no more CTD's. The perfect spy at the beginning doesn't work now also none of the settlements change hands. I get an error on exit that says that it doesn't recognize the "end script" token.
    Last edited by Squid; January 04, 2012 at 02:09 PM.

  9. #9
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,760
    Blog Entries
    3

    Default Re: using a script to change ownership

    I've now added them twice, please put all your code within [spoiler][/spoiler] tags if its more than a couple of lines in length. You should also get into the habit of putting your code into [code][/code] tags
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  10. #10

    Default Re: using a script to change ownership

    I'm afraid I don't know how to do any of what you just told me Squid!

  11. #11
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,760
    Blog Entries
    3

    Default Re: using a script to change ownership

    See those tags I put in my last post, put your script inside the [code][/code] like [code]console_command toggle_perfect_spy

    declare_counter PlayerFaction[/code],

    That will generate the following:
    Code:
    console_command toggle_perfect_spy
     
     declare_counter PlayerFaction
    and then put the entire thing inside the [spoiler][/spoiler] tags like [spoiler][code]console_command toggle_perfect_spy

    declare_counter PlayerFaction[/code][/spoiler]

    This finally will generate:

    Spoiler Alert, click show to read: 
    Code:
    console_command toggle_perfect_spy
    
    declare_counter PlayerFaction


    For a full list of bbcodes with samples go to BB code.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  12. #12
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: using a script to change ownership

    Must be missing the end_if tag after returning control to the player faction.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  13. #13

    Default Re: using a script to change ownership

    Where do I put the end_if tag?

  14. #14
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: using a script to change ownership

    At the end, after the if I_CompareCounter PlayerFaction = 21...end_if block.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  15. #15

    Default Re: using a script to change ownership

    Ok It doesn't get any CTD's. But it gets an error that the following line doesn't have a value set.
    Spoiler Alert, click show to read: 
    Code:
    if I_CompareCounter PlayerFaction != 1


    Hey look Squid I got the code thingy to work!
    Last edited by ares7667; January 05, 2012 at 04:54 PM.

  16. #16
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: using a script to change ownership

    There is nothing wrong with that line. Please post the whole script again. I have a feeling the problem is somewhere else.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  17. #17

    Default Re: using a script to change ownership

    Here it is.

    Spoiler Alert, click show to read: 
    Code:
    script
    
    ;  console_command toggle_perfect_spy
    
    declare_counter PlayerFaction
    
    if I_LocalFaction romans_scipii
        set_counter PlayerFaction 1
    end_if
    
    if I_LocalFaction romans_brutii
        set_counter PlayerFaction 2
    end_if
    
    if I_LocalFaction pontus
        set_counter PlayerFaction 3
    end_if
    
    if I_LocalFaction germans
        set_counter PlayerFaction 4
    end_if
    
    if I_LocalFaction britons
        set_counter PlayerFaction 5
    end_if
    
    if I_LocalFaction romans_julii
        set_counter PlayerFaction 6
    end_if
    
    if I_LocalFaction romans_senate
        set_counter PlayerFaction 7
    end_if
    
    if I_LocalFaction egypt
        set_counter PlayerFaction 8
    end_if
    
    if I_LocalFaction greek_cities
        set_counter PlayerFaction 9
    end_if
    
    if I_LocalFaction macedon
        set_counter PlayerFaction 10
    end_if
    
    if I_LocalFaction carthage
        set_counter PlayerFaction 11
    end_if
    
    if I_LocalFaction seleucid
        set_counter PlayerFaction 13
    end_if
    
    if I_LocalFaction scythia
        set_counter PlayerFaction 14
    end_if
    
    if I_LocalFaction parthia
        set_counter PlayerFaction 15
    end_if
    
    if I_LocalFaction gauls
        set_counter PlayerFaction 16
    end_if
    
    if I_LocalFaction armenia
        set_counter PlayerFaction 17
    end_if
    
    if I_LocalFaction dacia
        set_counter PlayerFaction 18
    end_if
    
    if I_LocalFaction numidia
        set_counter PlayerFaction 19
    end_if
    
    if I_LocalFaction spain
        set_counter PlayerFaction 20
    end_if
    
    if I_LocalFaction thrace
        set_counter PlayerFaction 21
    end_if
    
    
    
      if I_CompareCounter PlayerFaction i = 1
    
       console_command control romans_scipii
        console_command capture_settlement Campus_Melanchlaeni
         console_command capture_settlement Vicus_Careotae
         console_command capture_settlement Campus_Roxolani
    
    
      ; pass control back to the player faction
    
    
    if I_CompareCounter PlayerFaction = 2
    console_command control romans_brutii
    end_if
    
    if I_CompareCounter PlayerFaction = 3
    console_command control pontus
    end_if
    
    if I_CompareCounter PlayerFaction = 4
    console_command control germans
    end_if
    
    if I_CompareCounter PlayerFaction = 5
    console_command control britons
    end_if
    
    if I_CompareCounter PlayerFaction = 6
    console_command control romans_julii
    end_if
    
    if I_CompareCounter PlayerFaction = 7
    console_command control romans_senate
    end_if
    
    if I_CompareCounter PlayerFaction = 8
    console_command control egypt
    end_if
    
    if I_CompareCounter PlayerFaction = 9
    console_command control greek_cities
    end_if
    
    if I_CompareCounter PlayerFaction = 10
    console_command control macedon
    end_if
    
    if I_CompareCounter PlayerFaction = 11
    console_command control carthage
    end_if
    
    if I_CompareCounter PlayerFaction = 13
    console_command control seleucid
    end_if
    
    if I_CompareCounter PlayerFaction = 14
    console_command control scythia
    end_if
    
    if I_CompareCounter PlayerFaction = 15
    console_command control parthia
    end_if
    
    if I_CompareCounter PlayerFaction = 16
    console_command control gauls
    end_if
    
    if I_CompareCounter PlayerFaction = 17
    console_command control armenia
    end_if
    
    if I_CompareCounter PlayerFaction = 18
    console_command control dacia
    end_if
    
    if I_CompareCounter PlayerFaction = 19
    console_command control numidia
    end_if
    
    if I_CompareCounter PlayerFaction = 20
    console_command control spain
    end_if
    
    if I_CompareCounter PlayerFaction = 21
    console_command control thrace
    end_if block

  18. #18
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: using a script to change ownership

    Looks like you confused ! for i and didn't get what I was saying about end_if. Try this:

    Spoiler Alert, click show to read: 
    Code:
    script
    
    ;  console_command toggle_perfect_spy
    
    declare_counter PlayerFaction
    
    if I_LocalFaction romans_scipii
        set_counter PlayerFaction 1
    end_if
    
    if I_LocalFaction romans_brutii
        set_counter PlayerFaction 2
    end_if
    
    if I_LocalFaction pontus
        set_counter PlayerFaction 3
    end_if
    
    if I_LocalFaction germans
        set_counter PlayerFaction 4
    end_if
    
    if I_LocalFaction britons
        set_counter PlayerFaction 5
    end_if
    
    if I_LocalFaction romans_julii
        set_counter PlayerFaction 6
    end_if
    
    if I_LocalFaction romans_senate
        set_counter PlayerFaction 7
    end_if
    
    if I_LocalFaction egypt
        set_counter PlayerFaction 8
    end_if
    
    if I_LocalFaction greek_cities
        set_counter PlayerFaction 9
    end_if
    
    if I_LocalFaction macedon
        set_counter PlayerFaction 10
    end_if
    
    if I_LocalFaction carthage
        set_counter PlayerFaction 11
    end_if
    
    if I_LocalFaction seleucid
        set_counter PlayerFaction 13
    end_if
    
    if I_LocalFaction scythia
        set_counter PlayerFaction 14
    end_if
    
    if I_LocalFaction parthia
        set_counter PlayerFaction 15
    end_if
    
    if I_LocalFaction gauls
        set_counter PlayerFaction 16
    end_if
    
    if I_LocalFaction armenia
        set_counter PlayerFaction 17
    end_if
    
    if I_LocalFaction dacia
        set_counter PlayerFaction 18
    end_if
    
    if I_LocalFaction numidia
        set_counter PlayerFaction 19
    end_if
    
    if I_LocalFaction spain
        set_counter PlayerFaction 20
    end_if
    
    if I_LocalFaction thrace
        set_counter PlayerFaction 21
    end_if
    
    
    if I_CompareCounter PlayerFaction != 1
    
        console_command control romans_scipii
        console_command capture_settlement Campus_Melanchlaeni
        console_command capture_settlement Vicus_Careotae
        console_command capture_settlement Campus_Roxolani
    
      ; pass control back to the player faction
    
        if I_CompareCounter PlayerFaction = 2
            console_command control romans_brutii
        end_if
        
        if I_CompareCounter PlayerFaction = 3
            console_command control pontus
        end_if
        
        if I_CompareCounter PlayerFaction = 4
            console_command control germans
        end_if
        
        if I_CompareCounter PlayerFaction = 5
            console_command control britons
        end_if
        
        if I_CompareCounter PlayerFaction = 6
            console_command control romans_julii
        end_if
        
        if I_CompareCounter PlayerFaction = 7
            console_command control romans_senate
        end_if
        
        if I_CompareCounter PlayerFaction = 8
            console_command control egypt
        end_if
        
        if I_CompareCounter PlayerFaction = 9
            console_command control greek_cities
        end_if
        
        if I_CompareCounter PlayerFaction = 10
            console_command control macedon
        end_if
        
        if I_CompareCounter PlayerFaction = 11
            console_command control carthage
        end_if
        
        if I_CompareCounter PlayerFaction = 13
            console_command control seleucid
        end_if
        
        if I_CompareCounter PlayerFaction = 14
            console_command control scythia
        end_if
        
        if I_CompareCounter PlayerFaction = 15
            console_command control parthia
        end_if
        
        if I_CompareCounter PlayerFaction = 16
            console_command control gauls
        end_if
        
        if I_CompareCounter PlayerFaction = 17
            console_command control armenia
        end_if
        
        if I_CompareCounter PlayerFaction = 18
            console_command control dacia
        end_if
        
        if I_CompareCounter PlayerFaction = 19
            console_command control numidia
        end_if
        
        if I_CompareCounter PlayerFaction = 20
            console_command control spain
        end_if
        
        if I_CompareCounter PlayerFaction = 21
            console_command control thrace
        end_if
    
    end_if
    
    end_script
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  19. #19

    Default Re: using a script to change ownership

    Well progress is being made. The Romans_scipii faction works perfectly. But any other faction gets error less CTD's.

  20. #20
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: using a script to change ownership

    Try adding wait commands to see if you can pinpoint where exactly it CTDs:
    Code:
        console_command control romans_scipii
        wait 3
        console_command capture_settlement Campus_Melanchlaeni
        wait 3
        console_command capture_settlement Vicus_Careotae
        wait 3
        console_command capture_settlement Campus_Roxolani
        wait 3
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

Page 1 of 2 12 LastLast

Posting Permissions

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