Results 1 to 10 of 10

Thread: [Solved] Army spawn bound to an event

Hybrid View

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

    Default [Solved] Army spawn bound to an event

    I'll post the solution in the first post for those who are as clueless as I was:

    If you want to spawn an army once a specific event triggers, this is the code you want:

    Code:
    monitor_conditions I_TurnNumber = 4
        and I_LocalFaction teutonic_order (sets the player's faction which will receive the event)
        and I_SettlementOwner Riga = teutonic_order (optional settlement control)
    
            add_events
                event historic semigall_rebellion (This event has to be set in historic_events.txt You do NOT have to add it to descr_events.txt)
                date    0 0            
            end_add_events
    
        spawn_army
      faction slave, sub_faction lithuania
                character Schabe, general, age 30, x 86, y 67 (This line will spawn a named captain)
                unit Aztec Bodyguard, exp 9 armour 1
                unit Sudovian Tribesmen, exp 0 armour 0
                unit Sudovian Tribesmen, exp 0 armour 0
                unit Sudovian Tribesmen, exp 0 armour 0
    
            end
           
    terminate_monitor
    end_monitor
    Last edited by Neige; March 09, 2012 at 04:25 PM.

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

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

    Default Re: Basic char spawn script

    Try named character not named_character.
    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

  3. #3

    Default Re: Basic char spawn script

    Still got a ctd.

  4. #4

    Default Re: Basic char spawn script

    'army' is not supposed to be there when you spawn via script.

    Mod Leader, Mapper & Bohemian Researcher

  5. #5

    Default Re: Basic char spawn script

    I rebuilt it from start.
    Here's how it looks now:

    Spoiler Alert, click show to read: 
    Code:
    declare_counter semigall_rebellion
    
    monitor_event FactionTurnStart FactionType teutonic_order
        and not IsFactionAIControlled
        and I_SettlementOwner Riga = teutonic_order
        set_counter semigallian_rebellion 1
        terminate_monitor
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
        and I_CompareCounter semigallian_rebellion = 1
        historic_event semigallian_rebellion
        spawn_army
    faction slave, sub_faction lithuania
    character Schabe, general, age 30, x 86, y 67
    unit Aztec Bodyguard, exp 9 armour 1
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    end
        
        terminate_monitor
    end_monitor



    But now I'm getting something different in the log:
    Spoiler Alert, click show to read: 
    20:41:30.766 [game.script] [error] Script execution error for <set_counter>, at line 13, in mods/dlv_teutonic_knights/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    Counter semigallian_rebellion doesn't exist
    20:41:35.660 [game.script] [error] Script execution error for <monitor_event>, at line 20, in mods/dlv_teutonic_knights/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    Counter semigallian_rebellion doesn't exist
    when testing <I_CompareCounter> condition




    What I'm trying to do (probably obvious, but I'll explain anyway) is spawn a named rebel character once a specific historic event is triggered. Maybe there's an example of a similar working script somewhere?
    Last edited by Neige; March 09, 2012 at 12:53 PM.

  6. #6

    Default Re: Basic char spawn script

    Couple of things:

    1) You forget to assign a value to the counter after you declared it = CS reports it as non-existent which appears in the log. Plus you declare semigall_rebellion while you check semigallian_rebellion...

    2) Sub factions don't work for slave characters. In order to give them proper look of your desired faction you will need to use kingdoms.exe, define second entry for strat model of slave named characters (in descr_character.txt) designating what you want it to look like (i.e. copy the entry from lithuania faction) and then create a trait with 'Effect Level 1' (assuming your entry is second in descr_character.txt) and give this trait to your character. But since you cannot give traits on spawn you need to use console_command in CS.

    3) Why do you do it via two monitors?

    Spoiler Alert, click show to read: 
    monitor_event FactionTurnStart FactionIsLocal
    and FactionType teutonic_order
    and I_SettlementOwner Riga = teutonic_order
    historic_event semigallian_rebellion
    spawn_army
    faction slave
    character Schabe, named character, age 30, x 86, y 67
    unit Aztec Bodyguard, exp 9 armour 1
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    end
    console_command give_trait Schabe SlaveAppearance 1
    terminate_monitor
    end_monitor


    If you wish Schabe to be a general you need to have him as named character since general is captain. You also need to create the trait I use, preferably making it invisible (how and why is described above).

    EDIT: If you insist on spawning the rebels on slave turn then:

    Spoiler Alert, click show to read: 
    declare_counter semigallian
    set_counter semigallian 0

    monitor_event FactionTurnStart FactionIsLocal
    and FactionType teutonic_order
    and I_SettlementOwner Riga = teutonic_order
    historic_event semigallian_rebellion
    set_counter semigallian 1
    terminate_monitor
    end_monitor

    monitor_event FactionTurnStart FactionType slave
    and I_CompareCounter semigallian = 1
    spawn_army
    faction slave
    character Schabe, named character, age 30, x 86, y 67
    unit Aztec Bodyguard, exp 9 armour 1
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    end
    console_command give_trait Schabe SlaveAppearance 1
    set_counter semigallian 0
    terminate_monitor
    end_monitor


    But note that in your original script you are firing the event during AI's slave turn which I am not sure will show up in player's turn... and giving the event and spawning later is a bit stupid. You would need to make it even more complicated by checking the condition for event, then spawning the rebels in slave turn and then firing the event in player's turn...

    EDIT2: Ok, here is probably what you want:

    Spoiler Alert, click show to read: 
    declare_counter semigallian
    set_counter semigallian 0

    monitor_event FactionTurnStart FactionIsLocal
    and FactionType teutonic_order
    and I_SettlementOwner Riga = teutonic_order
    set_counter semigallian 1
    terminate_monitor
    end_monitor

    monitor_event FactionTurnStart FactionType slave
    and I_CompareCounter semigallian = 1
    spawn_army
    faction slave
    character Schabe, named character, age 30, x 86, y 67
    unit Aztec Bodyguard, exp 9 armour 1
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    unit Sudovian Tribesmen, exp 0 armour 0
    end
    console_command give_trait Schabe SlaveAppearance 1
    set_counter semigallian 2
    terminate_monitor
    end_monitor


    monitor_event FactionTurnStart FactionIsLocal
    and I_CompareCounter semigallian 2
    historic_event semigallian_rebellion
    set_counter semigallian 0
    terminate_monitor
    end_monitor
    Last edited by Resurrection; March 09, 2012 at 02:42 PM.

    Mod Leader, Mapper & Bohemian Researcher

  7. #7

    Default Re: Basic char spawn script

    Thanks for explaining in such detail.
    It seems I was blundering in the dark much more than I realized.

    Ok, so let's set things straight. Just in case one of us has misunderstood something.

    1. I have a historic event set on turn 18 in descr_events.txt. It's called semigall_rebellion in historic_events.txt.
    2. I need the game spawn an army once this event occurs (turn 18).
    3. The army must be spawned only if Riga is under teutonic order's control.
    4. This event is intended for teutonic order only.


    I've decided that I won't trouble myself with making Schabe a general, that doen't matter at all, it'll suffice for him to be a captain named Schabe. And consequently I don't need any traits applied to him.

    So by your suggestion, this is what I am using now:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
    
        and FactionType teutonic_order
        and I_SettlementOwner Riga = teutonic_order
    
            historic_event semigall_rebellion
            spawn_army
    
                faction slave, sub_faction lithuania
                character Schabe, general, age 30, x 86, y 67, Direction N
                unit Aztec Bodyguard, exp 9 armour 1
                unit Sudovian Tribesmen, exp 0 armour 0
                unit Sudovian Tribesmen, exp 0 armour 0
                unit Sudovian Tribesmen, exp 0 armour 0
    
            end
           
    terminate_monitor
    end_monitor
    The ctd are gone, BUT I've realized the event is not working. Is there something I've forgotten?
    This is my entry in descr_events:
    Code:
    event    historic    SEMIGALL_REBELLION
    date    18
    And historic_events:
    Code:
    {SEMIGALL_REBELLION_BODY}Description...
    {SEMIGALL_REBELLION_TITLE}Semigallian Rebellion
    Why isn't the event showing up?
    Last edited by Neige; March 09, 2012 at 03:09 PM.

  8. #8

    Default Re: Basic char spawn script

    I think this must be in lower case:

    event historic semigall_rebellion
    date 18


    while the historic_events.txt is correct. It would probably work with caps too but then you would need to make it caps in CS as well.

    Mod Leader, Mapper & Bohemian Researcher

  9. #9

    Default Re: Basic char spawn script

    Doesn't seem to fix it... I'll do a quick reinstall, just in case.

  10. #10

    Default Re: Basic char spawn script

    Fixed it.

    Now, if I play the campaign without the script, I get the message on the correct turn.
    If I play it with the script, I get both the message and the army spawn on the campaign start.

    Actually, nevermind. I found a solution. A slightly different script:
    Code:
    monitor_conditions I_TurnNumber > 2
        and I_LocalFaction teutonic_order
        and I_SettlementOwner Riga = teutonic_order
    
            add_events
                event historic semigall_rebellion
                date    0 0            
            end_add_events
    
        spawn_army
      faction slave, sub_faction lithuania
                character Schabe, general, age 30, x 86, y 67
                unit Aztec Bodyguard, exp 9 armour 1
                unit Sudovian Tribesmen, exp 0 armour 0
                unit Sudovian Tribesmen, exp 0 armour 0
                unit Sudovian Tribesmen, exp 0 armour 0
    
            end
           
    terminate_monitor
    end_monitor
    Last edited by Neige; March 09, 2012 at 04:09 PM.

Posting Permissions

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