Page 1 of 6 123456 LastLast
Results 1 to 20 of 103

Thread: Legion recruitment script

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Legion recruitment script

    Thought I'd move the legion script thread away from the rebellion script one to avoid confusion.



    Quote Originally Posted by HouseOfHam View Post
    Is that something that only 1 faction would have? Would you want it to happen for the player/AI/both?

    The code would look something like this (substitute actual EDU unit types as necessary):

    Code:
    monitor_event UnitTrained TrainedUnitCategory infantry
               and UnitType first cohort
               and FactionType romans
               and SettlementName Rome
        ; 1st cohort already recruited
        console_command create_unit Rome "regular cohort" 9
        console_command create_unit Rome "cavalry alae" 2
        console_command create_unit Rome "auxiliary infantry cohort" 4
        console_command create_unit Rome "archer cohort" 2
        console_command create_unit Rome "siege weapon" 1
        console_command add_money romans, -10000       ; Cost of the extra units
        console_command add_population Rome -700       ; Reduce population by the appropriate amount
     end_monitor
    Then do the same for every settlement that can recruit the 1st cohort.

    Where exactly does this bit of code go with its changes?
    Last edited by tone; September 16, 2009 at 07:39 AM.


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

  2. #2

    Default Re: Proposed Factions Rebellions and Scripting

    Two questions:

    1) do you need a seperate monitor_event...end monitor entry pairs for each legion or do all the legions go inside one set of monitor_event......end_monitor entries

    2) can you have more than one settlement listed per legion? assuming that we want this.

    3) can we have it so that the legion is put outside the settlement ?spawned? so that it doesn't immediately get split up by the AI and it's wonderful strategies?

    4) It doesn't seem to be working...just tried these changes to the background script (triggered by recruiting some triarii):


    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; Rome Surrectum 2 Background Script ;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    script
    ; Anything following a semicolon is a comment.
    ; Remove the adviser portrait from screen.
    select_ui_element advisor_dismiss_button
    simulate_mouse_click lclick_up
    ; Wait for it to go away.
    while I_AdvisorVisible
    end_while
    suspend_unscripted_advice true
    ; Open the adviser message bubble automatically whenever advance_advice_thread is called.
    ; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
    ; Do NOT mix both methods, though, or the advisor will show and then immediately close before
    ; you get a chance to read the text.
    declare_show_me
    ; Very useful for debugging - uncomment to use
    ;console_command toggle_perfect_spy
    ; Handle saved game reloads
    monitor_event GameReloaded TrueCondition
    terminate_script
    end_monitor
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; This is where to put your own code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    monitor_event UnitTrained TrainedUnitCategory infantry
    and UnitType roman triarii
    and FactionType romans_brutii
    and SettlementName Rome
    ; 1st cohort already recruited
    console_command create_unit Rome "legio i germanica" 9
    console_command create_unit Rome "ala i venetia" 2
    console_command create_unit Rome "cohors ii thracia" 2
    console_command create_unit Rome "roman antesignani" 2
    console_command create_unit Rome "roman cretan archer" 2
    console_command create_unit Rome "scorpion" 1
    console_command add_money romans, -18624 ; Cost of the extra units
    console_command add_population Rome -700 ; Reduce population by the appropriate amount
    end_monitor
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; End of your code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Spin forever - Do not let the script terminate or any monitors you have set up will immediately get thrown away.
    while I_TurnNumber < 99999
    suspend_unscripted_advice true
    end_while
    end_script
    Last edited by tone; September 16, 2009 at 08:26 AM.


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

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

    Default Re: Legion recruitment script

    Looks like you've already figured out where to put it.

    The max number of units you can spawn with 1 console_command create_unit command is 5. Anything more than that would still only spawn 5.

    1) A separate monitor for each city would be the safest bet, though you could try writing it like this:
    Code:
    monitor_event UnitTrained TrainedUnitCategory infantry
                          and UnitType roman triarii
               and FactionType romans_brutii
    
      if SettlementName Rome
        ; 1st cohort already recruited
        console_command create_unit Rome "legio i germanica" 5
        console_command create_unit Rome "legio i germanica" 4
        console_command create_unit Rome "ala i venetia" 2
        console_command create_unit Rome "cohors ii thracia" 2
        console_command create_unit Rome "roman antesignani" 2
        console_command create_unit Rome "roman cretan archer" 2
        console_command create_unit Rome "scorpion" 1
        console_command add_money romans_brutii, -18624       ; Cost of the extra units
        console_command add_population Rome -700       ; Reduce population by the appropriate amount
      end_if
    
      if SettlementName Capua
        ; 1st cohort already recruited
        console_command create_unit Capua "legio i germanica" 5
        console_command create_unit Capua "legio i germanica" 4
        console_command create_unit Capua "ala i venetia" 2
        console_command create_unit Capua "cohors ii thracia" 2
        console_command create_unit Capua "roman antesignani" 2
        console_command create_unit Capua "roman cretan archer" 2
        console_command create_unit Capua "scorpion" 1
        console_command add_money romans_brutii, -18624       ; Cost of the extra units
        console_command add_population Capua -700       ; Reduce population by the appropriate amount
      end_if
    
      ; etc.
    
    end_monitor
    2) Yes, you can spawn some of the units in Rome and others elsewhere. Just be sure to check settlement ownership if you want to spawn them somewhere else.

    3) Yes, but then you'll need to use the spawn_army command instead (see this tutorial). The 1st cohort would still remain in the settlement.

    4) Other than exceeding the 5 unit cap and the faction id in the add_money command, I can't see anything wrong with your code just by looking at it. I'll have to try it myself when I get home - writing this from work.
    Last edited by HouseOfHam; September 16, 2009 at 06:29 PM.
    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

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

    Default Re: Legion recruitment script

    Idk wtf is going on anymore...

    First, tried starting the game using the launcher. Picked Rome and RomeTW.exe:

    Noticed there was no advisor pop-up when starting a new campaign, so that told me that maybe the campaign script wasn't being run. Also, the background script triggers in export_descr_advice.txt didn't work (i.e. clicking on a settlement didn't offer to start the background script).

    Looked in descr_strat...

    - There should not be a perfect_spy.txt line before campaign_script.txt at the end.

    - Removed perfect_spy.txt, but still wasn't getting the advisor popup, so changed campaign_script.txt to
    Code:
    script
    
    console_command add_money 1
    
    advance_advice_thread BackgroundScriptThread
    campaign_wait 1
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_up
    
    end_script
    (i.e. added the "add_money 1") to see if it was being called at all. It wasn't.

    - Started a new campaign and checked the starting funds. In descr_strat.txt, it says 10000 for romans_brutii, but I only got 2500. Any idea why that happened?

    Then, tried starting the game as Other faction and picked Rome. Got a CTD on campaign start.

    So, I'm a bit confused as to what's going on, cause it used to work...

    My best guess is that since the launcher is using -modlay_faction switch, you will also have to copy export_descr_advice.txt to all the Play_faction folders, fix descr_strat.txt everywhere, and make all the same changes in all the background_script.txt files.
    Last edited by HouseOfHam; September 16, 2009 at 07:17 PM.
    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

  5. #5

    Default Re: Legion recruitment script

    Hmmmm.....I think the problem is longer standing than that. It definitely pre-dates the launcher and the move to subversion and would explain a number of things:

    1) We've never been able to reload campaigns and get the perfect_spy to work
    2) DVK tried adding a money monitor to add money to AI factions if they were running low or cutting them if they got above 100,000 - it never worked

    Now if I add anything to the campaign_script.txt file like

    console_command add_money 1
    it just causes a CTD, even for the default campaign using RTW and not BI. Without it the campaign runs fine, but as you say, it's clearly not running the background script. I even tried changing the entries in:

    export_descr_advice.txt
    campaign_script.txt
    background_script.txt

    and copied in exactly what you'd posted in your background script tutorial, but no success. I wonder what could be causing this? I know that the export_descr_advice.txt has been edited from vanilla to remove references to certain buildings.....could it be something to do with this? Are there any other files that might be being referenced?


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

  6. #6

    Default Re: Legion recruitment script

    Had a problem with the -show_err when I tried scripting in the rebellion test. It produced no output and had to figure out the problems myself. Don't know the cause of this. Will look into making this work in the weekend and try to also add in a smaller rebellion (Socii war most probably). That is if you don't manage to do that by then - get the script to work I mean.
    Last edited by MihaiV; September 17, 2009 at 03:21 AM.

  7. #7

    Default Re: Legion recruitment script

    thanks - that'd be great.


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

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

    Default Re: Legion recruitment script

    What is the reason for the additional per-faction mod folders? Is there anything other than starting funds and/or army composition that's different? Because if that's all it is, it could easily be adjusted via the campaign script right in the vanilla folder.
    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

  9. #9
    apple's Avatar Searching for 42
    Join Date
    Feb 2008
    Location
    Stockholm Sweden
    Posts
    11,780

    Default Re: Legion recruitment script

    Unit upkeep, music and other things.
    Son of Legio
    Father of Paedric & Remlap
    Roma Surrectum II, Ages of Darkness II, Rome Total Realism & RTR: Imperium Surrectum Developer

    Mundus Bellicus - TWC - ModDB - Discord - Steam

  10. #10

    Default Re: Legion recruitment script

    Different EDBs (e.g. AI gets the Rome legion script and Marian reforms triggered more easily, buildings probably take less time than for the player), and different EDUs for stats (attack, defence and costs)...also when it comes to creating the swap faction campaigns (like having a playable Syracuse or Bosporan Kingdom) it'll make it easier.

    The problem though is that I'm getting the problem even in the non-mod-foldered campaign


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

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

    Default Re: Legion recruitment script

    You can comment out the last 2 lines in descr_strat.txt, so it doesn't even call the campaign script, and you'll still get that CTD. You'll have to go back and check units, buildings, traits, etc. For the time being, you can only work on the script in the mod folders. I'd suggest starting with Play_Rome, since that seems like the most important one for RS2.

    ps: Got this error when exiting the game: Script Error in Play_Rome/data/export_descr_character_traits.txt, at line 14246, column 35. No level declared
    Last edited by HouseOfHam; September 17, 2009 at 01:16 PM.
    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

  12. #12

    Default Re: Legion recruitment script

    strange - you mean you're getting a CTD whatever?
    mine works perfectly - the only time I get a CTD is if I add the "add_money" console command to the campaign script, whichever campaign


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

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

    Default Re: Legion recruitment script

    Ok, I've fixed the script in Play_Rome and added a legion recruitment example in Rev. 320.
    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

  14. #14

    Default Re: Legion recruitment script

    what was the problem?


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

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

    Default Re: Legion recruitment script

    Same as in the vanilla folder, a perfect_spy.txt line before campaign_script.txt at the end of descr_strat.txt.
    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

  16. #16

    Default Re: Legion recruitment script

    I recruited a triarii unit and look what turns up! Not bad.

    The only problem here now is that the script won't recruit any unit once the city is full. In this instance it didn't recruit two cretan archers and a scorpion.
    as there were already 4 units inside Rome...is there any way round this?

    also we may need to make the AI check for funds before recruiting otherwise it could easilygo massively overdrawn if it recruits a legion in a load of different places at once.

    Last edited by tone; September 17, 2009 at 11:06 PM.


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

  17. #17

    Default Re: Legion recruitment script

    Other ideas for the recruitment script. Is something like this possible HoH?

    1) AI recruits a first cohort over 1-2 turns (should really be two turn recruitment for the whole legion?)
    2) At the end of the recruitment, the script checks whether there are any other units in the settlement and disbands them or moves them out
    3) The script then goes on to recruit the remaining 19 units in the settlement
    4) Can it then recruit a named character (using the subfaction idea) to head up this army?

    I see DVK has written this:
    The problem is the result of the 'cloned character' phenomenon....where a character is created who is considered a 'family member', but who really isn't. The game tries to adopt this character, but clones him instead. It's fine until one of the characters dies, then the game CTD's. The solution to this is to make the character a 'sub_faction' character like so:

    character sub_faction romans_brutii, Lucius Paullus, named character, command 0, influence 0, management 0, subterfuge 0, age 72

    Substituting the name of the faction you are creating the character FOR. So if this was a rebel (thrace) character, it would be:

    character sub_faction thrace, Lucius Paullus, named character, command 0, influence 0, management 0, subterfuge 0, age 72

    For whatever reason, the game won't try to adopt this character, and recognizes that he is NOT a family member. By making the character quite old (as you can see, the examples are 72 years old), this also guarantees (fairly well, anyway) that the character will never be made an heir or faction leader, because he won't live long enough for that to happen.
    5) Could it then move that character and his army out of the settlement (or would the script have to know in advance the name of the character? if so could we provide it with a list of names, etc, etc) and garrison it with say 6 auxiliary units or something?


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

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

    Default Re: Legion recruitment script

    1) It doesn't matter how many turns it takes to recruit the 1st cohort. The extra units will only be created when the script detects recruitment has been completed.
    2) Not possible. There are no commands/conditions to check the number of units in a settlement.
    3) -//-
    4) The problem isn't quite how DVK describes it. When you spawn a character via script, the game doesn't check if there is already another character by that name and it doesn't add the new character's name to its list of names already in use. So, there is a relatively unlikely but existing possibility that it might spawn (via birth, adoption, or marriage) another character with the same name, thus creating a clone. When one of these cloned characters dies, you get a CTD. Anyhow, whether you use faction or sub_faction doesn't really make a difference, because you can still only use that name once, or you have to use console_command kill_character with that name before spawning to prevent cloning. Oh, you can't spawn a named character in a settlement.
    5) In my previous attempts, I haven't been able to move a character (and his army) out of a settlement, even though it's been said to be possible. The amount of work and script complexity would increase too much to make it use a list of names rather than just 1 name.
    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: Legion recruitment script

    OK, can we use a named character with 3 names for the Romans? i.e cognomens?

    e.g. Marcus Licinius Crassus

    So from what I understand, every army spawned from that settlement will have a leader by the same name? therefore if the spawning is happening relatively regularly, the named character will be killed quite often and regenerated back near his "home settlement"

    From your tutorial on army spawning it seems that the only real disadvantage compared to using the create_unit command is this:

    - n is an absolute value and doesn't auto-adjust no matter what the unit size is set to in the game's options. You can spawn a unit with 240 soldiers even when unit size is set to small (60 soldiers)
    I guess we'd get round that by giving people alternative scripts if they play on large rather than huge armies.

    Advantages of using the spawn army command are this:

    1) Legion is created intact, and gets a named character as its commander (= AI bonuses for battles and so on)

    2) It's created outside the settlement, so the settlement can continue to recruit auxilia to garrison it, which will increase the challenge for the player fighting Rome

    3) Whether there are units in the settlement or not, a full legion will still be recruited

    4) Way better than the current situation of having a hotch potch of different legions (I hope, although of course once those armies start taking casualties they'll probably join forces, which would represent the sorts of vexillation transfers that really went on).


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

  20. #20
    Calvin's Avatar Countdown: 7 months
    Citizen

    Join Date
    May 2007
    Location
    UK, and USA soon enough
    Posts
    3,348

    Default Re: Legion recruitment script

    Res Gestae has a 'field of mars' outside of capital cities which is where scripted legions appear when recruited. We could have something similar.
    Developer for Roma Surrectum 2 || Follow my move to the USA in Calvin's Corner
    Son of Noble Savage || Proud patron of [user]Winter[/user], [user]Lord of the Knights[/user] and [user]fergusmck[/user]

Page 1 of 6 123456 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
  •