Results 1 to 18 of 18

Thread: Spawn Infantry in Siege Script

Hybrid View

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

    Default Spawn Infantry in Siege Script

    Hi I was just wondering if it would be possible to create a script for the Mongols that would spawn an Infantry unit for each cavalry unit when they siege a settlement?

    The idea is to allow the Mongols to have a full cavalry army (except for siege equipment) and have this script kick in and spawn a dismounted unit for each of their cavalry units when they siege a settlement to act as if they are dismounting their horsemen for sieges.

    I was thinking it would work something like this; each Mongol general has an
    Ancillary "Mongol Siege Expert" or something that triggers the script when they siege a settlement that spawns the infantry units.

    Assuming that's possible, the problem is what to do with the cavalry units? Could the script disband them, replace them with an equivilent infantry unit with the same experience, and then disband the infantry unit and spawn another cavalry unit again with the same experience all in the same turn? Or would you have to move the cavalry units to some hidden arbitary location and then back again or something?

    I'm not really very knowledgable about scripting but if this is possible I would be happy to give it a go, however I'd rather not bother if it's completely impossible/improbable.
    Last edited by HighLord z0b; June 21, 2009 at 06:43 PM.

  2. #2
    Caesar Clivus's Avatar SS Forum Moderator
    Join Date
    May 2007
    Location
    Australia
    Posts
    12,693

    Default Re: Spawn Infantry in Siege Script

    I'm pretty sure there is no way to do what you want. I dont think you can disband/kill off individual units because there is no way to tell individual units apart in the script.

    BftB2 UPDATED 22nd DECEMBER. Member of the Complete Byzantine Unit Roster team

  3. #3

    Default Re: Spawn Infantry in Siege Script

    There's no way to do this whilst retaining the cavalry units' experience unfortunately, so every time the script kicks in the unit will essentially be an entirely new one. Also, to my knowledge there's no way of assessing the experience of a unit, so you couldn't write a script that spawns a unit of Mongol Footmen of A experience if there is a Mongol Horsemen of A experience doing the attacking - especially on a unit by unit basis. Therefore you are either faced with resetting the experience of all the units that are 'dismounting' and then re-mounting again following the siege (which means you'll lose all your experienced units every time you siege) or setting an arbitary experience level on their spawn (which can be abused by the unscrupulous at the start and then will lower the experience the unit later on).

    Destroy_units mongols XX, with XX being a unit attribute assigned in EDU, can be used to get rid of the cavalry units (with the attribute being a marker such as can_swim or can_sap which is rarely used). Though you could never have units with this attribute in different armies at different locations as they would all be destroyed when you siege.

    To be honest, you'd have to make so many compromises and introduce quite a few house rules to have this working in any form.

  4. #4

    Default Re: Spawn Infantry in Siege Script

    Oh well thanks for the advice, I just wondering if something like that was possible.

    Another question; what would happen if I used a script to simply spawn some units of infantry inside a full stack? Would it even work, would the units appear next to the stack like when you build units in a settlement that is full?

  5. #5
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: Spawn Infantry in Siege Script

    I'm pretty sure that the units will appear next to the stack.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  6. #6
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Spawn Infantry in Siege Script

    As already stated the key problem is the scripting engine's inability to assess individual units and export their characteristics in any way, shape, or form. Next to the lack of variables, non-constant values, elses and elseifs, and similar programming functions, it could be seen as its biggest failing that it fails to provide any assessable statistical values or labels for units outside of battle scripting(which is very limited in campaign applications). If any of us ever found out a way to do this you can be sure we'd be screaming it from the rooftops, because the applications far outstretch this particular idea.

  7. #7
    Pnutmaster's Avatar Dominus Qualitatium
    Join Date
    Jan 2006
    Location
    Brooklyn, NY
    Posts
    1,572

    Default Re: Spawn Infantry in Siege Script

    As we're addressing the subject of unit individuality on the battlemap...

    Some of you may be aware of Germanicu5's Stake Deployment campaign_script. It uses the command "label_unit" to assign a number to each unit of an army and then deploys stakes in from of said unit with the command "unit_deploy_stakes".

    e.g.,

    label_unit 1 0 1 unit01

    ...

    unit_deploy_stakes unit01
    If we can assign a name to a unit and affect it with the "unit_deploy_stakes" command, why not "reduce_unit_strength", "kill_unit", etc (to enhance Supply and Attrition mods, for example).

    To make my point more pertinent--if we can affect a labeled unit with the command "kill_unit", we can wipe out 90% of the besieging Mongol army at the start of the battle and spawn a corresponding number of Mongol infantry (using counters to check if 75% of the army is Cavalry, etc).
    Under the patronage and bound to the service of the
    artist formerly known as Squeakus Maximus
    Stoic Pantheist of S.I.N

  8. #8

    Default Re: Spawn Infantry in Siege Script

    Thanks for everyone's advice.

    I am still wanting to edit the Mongol stacks that appear, I want them to have two stacks of full cavalry and the other stacks can be mixed cav, infantry and siege. I also want to give them spies and diplomats when they spawn. Whst files do I need to edit?

  9. #9
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Spawn Infantry in Siege Script

    Quote Originally Posted by HighLord z0b View Post
    Thanks for everyone's advice.

    I am still wanting to edit the Mongol stacks that appear, I want them to have two stacks of full cavalry and the other stacks can be mixed cav, infantry and siege. I also want to give them spies and diplomats when they spawn. Whst files do I need to edit?
    $Install Directory$/data/world/maps/campaign/imperial_campaign/campaign_script.txt

    Or the same file with similar path directory in a mod folder. You will need to unpack the game, and you should follow this lesson to create your own modfolder if you aren't building it on another mod.

    You'll want to read scripting tutorials to see how the file works, but the setup should be pretty easy to comprehend for simply changing army composition. This class ongoing in the University focuses on scripting, as does this concluded class, and numerous other tutorials. Specifically see this thread for useful scripting materials.

  10. #10
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Spawn Infantry in Siege Script

    Probably not something to be taken on by someone unfamiliar with scripting, but I will see if I can point you in the right direction.

    The condition you want is PercentageUnitCategory, but it can only be used with a named general.

    if PercentageUnitCategory cavalry > 70
    then create_units or spawn_army. Probably create_units would be best.

    The real problem is going to be figuring out which general since the e_select_character command is broken. The way to do that would probably be to use a label with the general, not with the units.

    Then you could use destroy_units (Kingdoms only) to get rid of the cavalry units.

  11. #11
    Pnutmaster's Avatar Dominus Qualitatium
    Join Date
    Jan 2006
    Location
    Brooklyn, NY
    Posts
    1,572

    Default Re: Spawn Infantry in Siege Script

    Quote Originally Posted by GrnEyedDvl View Post
    The condition you want is PercentageUnitCategory, but it can only be used with a named general.
    That would make sense. The OP said he'd only want Mongol generals with a special siege ancillary to have this "dismounting" ability.
    Under the patronage and bound to the service of the
    artist formerly known as Squeakus Maximus
    Stoic Pantheist of S.I.N

  12. #12
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Spawn Infantry in Siege Script

    Ironically I brought that up with GED a few days ago on MSN. The reduce_unit_strength thing. I posit that it would be a valuable command to use for ambushes, to better simulate the negative effects of being ambushed which are poorly shown by mere formation issues that the player can get out of easily. If the AI ambushes you, you deserve to lose 25%+ army strength, might teach you to send scouting spies.

    As for the destoy_unit and create_unit, I'm pretty sure that those labels only work in battle, and I'm guessing those commands are strat commands. So how do you propose the mongols be re-constituted inside the battle itself, has anyone tried creating units in a battle? Or otherwise how would a battle be started then aborted and then switched and started again. Lastly what5 about differences in unit specifically and not just categorically, such as turning an elite unit into a poor dismounted unit or vice versa. I think we might be stabbing in the dark with trying to make this work the way things are, but I guess it's worth a try.

  13. #13
    Pnutmaster's Avatar Dominus Qualitatium
    Join Date
    Jan 2006
    Location
    Brooklyn, NY
    Posts
    1,572

    Default Re: Spawn Infantry in Siege Script

    The Docudemons would suggest reduce_unit_strength and kill_unit may be used on the battle map.

    I forgot the limitations of the create_unit command...

    In light of this, if you were truly desperate, you could write the opposite of a garrison script. Your script would check for the special Mongol ancillary, check the percentage of infantry in the Mongol army, check the number of units in the besieged settlement, and spawn an auxiliary Mongol infantry force to besiege said settlement (# of units spawned based on the # defending the settlement and possibly the infantry percentage of the original Mongol army).

    Like garrison scripts, I would restrict this to vital settlements, representing a focus and surging of the Mongol invasion.
    Last edited by Pnutmaster; June 28, 2009 at 12:53 AM.
    Under the patronage and bound to the service of the
    artist formerly known as Squeakus Maximus
    Stoic Pantheist of S.I.N

  14. #14

    Default Re: Spawn Infantry in Siege Script

    One problem is that I don't think there's a condition that checks the actual number of units in an army under a general. PercentageUnitCategory x > 50 wouldn't be able to distinguish between 50% of an army of 10 units and 50% of 20 units. It would therefore be quite difficult to ever know precisely how many infantry units to create.

  15. #15
    Pnutmaster's Avatar Dominus Qualitatium
    Join Date
    Jan 2006
    Location
    Brooklyn, NY
    Posts
    1,572

    Default Re: Spawn Infantry in Siege Script

    Quote Originally Posted by redxavier View Post
    One problem is that I don't think there's a condition that checks the actual number of units in an army under a general. PercentageUnitCategory x > 50 wouldn't be able to distinguish between 50% of an army of 10 units and 50% of 20 units. It would therefore be quite difficult to ever know precisely how many infantry units to create.
    Right, which is why the number of Mongol units will reflect the number of units inside the settlement, which we can check with a condition. AI sieging armies are never large enough anyway. PercentageUnitCategory will tell us if the script needs to fire. If a Mongol army has at least 50% infantry, why bother?
    Under the patronage and bound to the service of the
    artist formerly known as Squeakus Maximus
    Stoic Pantheist of S.I.N

  16. #16

    Default Re: Spawn Infantry in Siege Script

    Ok, so you would spawn additional foot units and not replace the cavalry units in the army that is sieging? Upon a successful taking of the settlement would you then destroy these extra infantry units?

  17. #17
    Pnutmaster's Avatar Dominus Qualitatium
    Join Date
    Jan 2006
    Location
    Brooklyn, NY
    Posts
    1,572

    Default Re: Spawn Infantry in Siege Script

    Player's preference. I would attribute the extra units to hording/marauders/levies. Sack a city and you attract the hive. It would make the successful defense of a settlement all the more necessary. Musn't encourage the enemy!
    Under the patronage and bound to the service of the
    artist formerly known as Squeakus Maximus
    Stoic Pantheist of S.I.N

  18. #18

    Default Re: Spawn Infantry in Siege Script

    Firstly thanks AL for the links, I've done some basic modding before and I'm usually not bad with coding so hopefully I can start there. I'm going to edit SS so I don't need to set up a new mod folder, I'll just back up the old files.

    As far as the spawn script goes, I wasn't expecting to see this kind of interest after the first replies. Ironically enough this idea started in a thread in the SS forum when I suggested "could you script a kind of anti-garrison thing for the mongols?"

    I think it would be ok to leave the additional units, hopefully the AI would leave them as a garrison. Otherwise you may have to kill them and still build a garrison script.

    If the AI had a full stack cavalry army, then the script would spawn the Infantry next to the stack correct? So hopefully the AI would swap some cavalry units for the infantry rather than trying to siege the settlement with only cavalry and then waiting for the infantry to turn up as reinforcements. Although that would still probably work because I guess that the AI would just sit there and wait for the infantry as it couldn't do anything with the rams and ladders it would have probably built.
    Last edited by HighLord z0b; June 28, 2009 at 09:48 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
  •