Results 1 to 8 of 8

Thread: Scripting Problem in Spawning Army

  1. #1
    julianus heraclius's Avatar The Philosopher King
    Join Date
    May 2006
    Location
    Australia
    Posts
    5,388

    Default Scripting Problem in Spawning Army

    I am having problems with this particular part of my script. It is designed to spawn an baggage train army. The problem is that every time I load a saved game it loads the spawned army again.

    I thought that set_counter SupplyWagonReinforcement 1 would prevent this from happening.

    Any thoughts?




    monitor_event CharacterTurnEnd Trait SupplyWagon = 0
    and FactionType sassanids
    and FactionIsLocal
    and I_CompareCounter SupplyWagonReinforcement = 0
    console_command add_money sassanids, -20000
    console_command kill_character "Ardumanish"
    spawn_army
    faction sassanids
    character Ardumanish, named character, command 1, influence 0, management 0, subterfuge 0, age 25, x 224, y 117
    unit palmyran camel rider, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    end
    console_command give_trait "Ardumanish" SassanPahlavan 1
    console_command give_trait "Ardumanish" Zoroastrian 1
    console_command give_trait "Ardumanish" LoyaltyStarter 1
    console_command give_trait "Ardumanish" OfficeGanjvar 1
    console_command give_trait "Ardumanish" SupplyWagon 1
    console_command give_trait "Ardumanish" TurnsAlive 1
    console_command give_ancillary "Ardumanish" office_ganjvar
    console_command give_ancillary "Ardumanish" supplywagon
    console_command give_ancillary "Ardumanish" merchant
    console_command kill_character "Vahyazdata"
    spawn_army
    faction sassanids
    character Vahyazdata, named character, command 1, influence 0, management 0, subterfuge 0, age 25, x 241, y 110
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit azadan savaran#1, exp 0 armour 0 weapon_lvl 0
    unit azadan savaran#1, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    end
    console_command give_trait "Vahyazdata" SassanPahlavan 1
    console_command give_trait "Vahyazdata" Zoroastrian 1
    console_command give_trait "Vahyazdata" LoyaltyStarter 1
    console_command give_trait "Vahyazdata" OfficeGanjvar 1
    console_command give_trait "Vahyazdata" SupplyWagon 1
    console_command give_trait "Vahyazdata" TurnsAlive 1
    console_command give_ancillary "Vahyazdata" office_ganjvar
    console_command give_ancillary "Vahyazdata" supplywagon
    console_command give_ancillary "Vahyazdata" merchant
    console_command kill_character "Zamolxis"
    spawn_army
    faction sassanids
    character Zamolxis, named character, command 1, influence 0, management 0, subterfuge 0, age 25, x 305, y 114
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit baggage cart, exp 0 armour 0 weapon_lvl 0
    unit parthian cataphract#1, exp 2 armour 1 weapon_lvl 1
    unit parthian cataphract#1, exp 2 armour 1 weapon_lvl 1
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    unit sassanid light cavalry#1, exp 0 armour 0 weapon_lvl 0
    end
    console_command give_trait "Zamolxis" SassanPahlavan 1
    console_command give_trait "Zamolxis" Zoroastrian 1
    console_command give_trait "Zamolxis" LoyaltyStarter 1
    console_command give_trait "Zamolxis" OfficeGanjvar 1
    console_command give_trait "Zamolxis" SupplyWagon 1
    console_command give_trait "Zamolxis" TurnsAlive 1
    console_command give_ancillary "Zamolxis" office_ganjvar
    console_command give_ancillary "Zamolxis" supplywagon
    set_counter SupplyWagonReinforcement 1
    terminate_monitor
    end_monitor

    Avatar & Signature by Joar

  2. #2
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Scripting Problem in Spawning Army

    I am a bit confused: "every time I load a saved game it loads the spawned army again" The way that is written seems as if you are surprised that a spawned army still exists when you load a save game where the army already spawned.

    Surely that's not the issue you are trying to solve?

    Technically nothing can happen anyhow as you terminate the monitor after it has executed. That's apart from apparently not having declared the SupplyWagonReinforcement counter in the first place - but then the counter is redundant because of the termination.

    A second view brings the kill command to the forefront: you are killing a named character only to use the name in the next spawn. If the character was leading an army then the army will still exist after he spawns again with a new army.

    You may want to have a look into using the create_unit command instead which allows you add units to an existing character\settlement. It does have the restriction that it obviously cannot add beyond 20 units, eg if the army has 18 units and you want to add 5 only the first 2 of those 5 will be added.










  3. #3
    julianus heraclius's Avatar The Philosopher King
    Join Date
    May 2006
    Location
    Australia
    Posts
    5,388

    Default Re: Scripting Problem in Spawning Army

    Quote Originally Posted by Gigantus View Post
    I am a bit confused: "every time I load a saved game it loads the spawned army again" The way that is written seems as if you are surprised that a spawned army still exists when you load a save game where the army already spawned.

    Surely that's not the issue you are trying to solve?

    Technically nothing can happen anyhow as you terminate the monitor after it has executed. That's apart from apparently not having declared the SupplyWagonReinforcement counter in the first place - but then the counter is redundant because of the termination.

    A second view brings the kill command to the forefront: you are killing a named character only to use the name in the next spawn. If the character was leading an army then the army will still exist after he spawns again with a new army.

    You may want to have a look into using the create_unit command instead which allows you add units to an existing character\settlement. It does have the restriction that it obviously cannot add beyond 20 units, eg if the army has 18 units and you want to add 5 only the first 2 of those 5 will be added.
    Just to be clear, the SupplyWagonReinforcement has been declared in the script. I was under the assumption that by setting the counter to 1 then the army would not spawn next time the game was loaded. I have found a way around it by using I_TurnNumber instead. Could you please elaborate about the "terminate monitor" and so noting happening?
    But thanks for your help.

    Avatar & Signature by Joar

  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Scripting Problem in Spawning Army

    Your assumption about the counter was correct, eg setting it to zero would invalidate the initial condition required and thus stop the script from executing. The reason why I said it's obsolete and will not be the issue is because of the terminate_monitor line you have in your script.

    Have a look at the last three lines of your script. That's where the terminate_monitor line is, which means there simply is no way that the script can repeat, regardless what you do as the script will no longer get accessed, it's released from memory.

    Hence my speculation that your issue is not related to the script.

    I_TurnNumber - remember that turn numbers start with zero: the first round, the game start is turn zero. Which means if you set it to 1 then nothing will happen at the start, only in the next round. Still don't think that's your underlying issue.

    The way I read your script it will fire instantly at game start as long the player controls the sassanid faction. The zero trait condition means there will be at least one character that matches the criteria unless all characters in descr_strat have a level of that trait. Which then leads to the question why you need to kill characters in the moment of game start if you can set them up already in descr_strat. Or leave them out and then spawn.

    Maybe if you tell me step by step what your goal is and how you want to get there and I'll give it a shot?










  5. #5
    julianus heraclius's Avatar The Philosopher King
    Join Date
    May 2006
    Location
    Australia
    Posts
    5,388

    Default Re: Scripting Problem in Spawning Army

    I am trying to spawn baggage units at the start of the game that are not normally recruited. They are meant to be one off's, apart from gaining access to then via the create_unit command when capturing certain settlements. Yes, I can see there is no need to kill characters. So the declare and set counters were designed to prevent the spawning from happening again when a saved game is loaded. While I could use the create_unit command I am aware of the space limitations in settlements and so wanted the units to be created outside of settlements.

    Avatar & Signature by Joar

  6. #6
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Scripting Problem in Spawning Army

    I think your easiest solution is to preplace them in descr_strat with a general (not a named character). If they are only meant for the player then a simply FactionturnStart event and a FactionIsLocal condition together with a faction conditional spawn of only the carts will do exactly that. And the terminate line will make sure it happens only once:
    Code:
    monitor_event FactionTurnStart FactionIsLocal
        if not I_IsFactionAIControlled sassanids    ; faction is not AI controlled, hence it's the player's faction
            console_command add_money sassanids, -20000
            spawn_army
                faction sassanids
                character Ardumanish, general, age 25, x 224, y 117
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
            end
        end_if
        if not I_IsFactionAIControlled [next faction]
            console_command add_money [next faction], -20000
            spawn_army
                faction [next faction]
                character Ardumanish, general, age 25, x 224, y 117        ; adjust name and co-ordinates
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
                unit baggage cart, exp 0 armour 0 weapon_lvl 0
            end
        end_if
        terminate_monitor
    end_monitor










  7. #7
    julianus heraclius's Avatar The Philosopher King
    Join Date
    May 2006
    Location
    Australia
    Posts
    5,388

    Default Re: Scripting Problem in Spawning Army

    Thanks for that. It is a bit more complicated as I need a character as they will be given an ancillary called "supply train" which when tranferred to another character will assist in improving the supplies of their field army. But this looks great. Much appreciated.

    Avatar & Signature by Joar

  8. #8
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Scripting Problem in Spawning Army

    You're welcome.

    Switching back to named characters and giving traits should not be an issue I guess. The latter to be done between 'end' of the spawn and 'end_if' of the sequence.










Posting Permissions

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