Results 1 to 14 of 14

Thread: Replacing units

Hybrid View

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

    Default Replacing units

    Allright.
    Currently, I'm not making any project that needs this, but I plan on doings so, a mod for Medieval II Kingdoms which will cover a timespan from the late 16th century to the mid or early 18th century.
    So, what I want is some sort of script that will allow me to make an event that replaces certain units with another.
    Like... Matchlock Musketeers with Flintlock Musketeers, upon the triggering of the "Flintlock invented" event.
    Why?
    Sure, in real life, not everyone switched to the other type of gun, pirates continued using matchlocks right into the 18th century.
    So, logically, a good player would disband all those matchlock musketeers, and train flintlock ones, right? Yes, but what about the dumb AI? The AI would never do something as that.
    So, to somehow achieve realism, we have to "cheat", and force everyone to replace the units, instead of teaching the AI how to do that.

    So, is it possible, or not?

  2. #2

    Default Re: Replacing units

    the easy way would be to remove the units from the later tier buildings in the EDB.


  3. #3

    Default Re: Replacing units

    Quote Originally Posted by dannyxx30 View Post
    the easy way would be to remove the units from the later tier buildings in the EDB.
    Really?

    I'm planning it something like this:
    Spoiler Alert, click show to read: 

    recruit_pool "Arquebusiers" 4 0.7 6 0 requires factions { england, france, hre, denmark, spain, milan, venice, papal_states, sicily, poland, russia, hungary, } and not event_counter flintlock_invented 1
    recruit_pool "Matchlock Musketeers" 3 0.5 4 0 requires factions { spain, venice, milan, sicily, hungary, hre, poland, denmark, scotland, france, england, } and not event_counter flintlock_invented 1
    recruit_pool "Flintlock Musketeers" 3 0.5 4 0 requires factions { spain, venice, milan, sicily, hungary, hre, poland, denmark, scotland, france, england, } and event_counter flintlock_invented 1
    recruit_pool "Skirmishers" 1 0.3 2 0 requires factions { hungary, hre, poland, scotland, france, england, } and event_counter flintlock_invented 1


    (Btw, Skirmisher is an early sniper-type of unit, kind of a sharpshooting gunner)

  4. #4

    Default Re: Replacing units

    So, there's no script that allows me to replace X unit with Y unit?

  5. #5

    Default Re: Replacing units

    Quote Originally Posted by LEGIONARIVS HVNGARIVS View Post
    So, there's no script that allows me to replace X unit with Y unit?
    I dont touch scripts im afraid.


  6. #6

    Default Re: Replacing units

    Quote Originally Posted by dannyxx30 View Post
    I dont touch scripts im afraid.
    Hmmm... then, apparently I have two options. Either just ignore the problem and laugh at the AI's failure to modernize it's army in the future, or wait for someone who is experienced with scripts and can explain.

    The first one seems to be a more tempting option

  7. #7
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Replacing units

    There is no "replace" command such as this. All you could do with script is destroy all of the old ones...

    Code:
    destroy_units england Matchlock Musketeers
    ..which will wipe out every single unit of that type in that faction. So repeat it for the other factions.

    You could then use script to spawn some Flintlock Musketeers into some settlements...

    Code:
    create_unit London, Flintlock Musketeers, num 1, exp 0, arm 0, wep 0
    
    or 
    
    console_command create_unit London "Flintlock Musketeers" 1
    ...but where and how many? You might be able to use some script to count how many there are in each settlement but it would be a lot of script.

  8. #8

    Default Re: Replacing units

    Thanks
    I know it's tedious, but then, I could just try to get a count script for all 199 settlements. That could work.

    Or, I could just ignore the problem.
    After all, the new event wouldn't allow for the training of outdated units, so they would be probably killed in battles, only to be replaced by the more advanced units.
    Another way to get around this would be making Flintlock Musketeers stronger AND cheaper (yes, the same time) than Matchlock Musketeers. Combine it with the previous thing I wrote (disabling outdated units after triggering event), it would make a lot of sense on the long run to destroy your outdated units and train newer ones.
    Last edited by Reimu Hakurei; February 07, 2012 at 02:36 AM.

  9. #9
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Replacing units

    I'd just let the AI/player handle the creation of new units. Muuuuch easier.

    To count units in settlements you can use I_NumberUnitsInSettlement (?) but it doesn't work if the unit Type contains spaces - which many do!

  10. #10

    Default Re: Replacing units

    Quote Originally Posted by Withwnar View Post
    I'd just let the AI/player handle the creation of new units. Muuuuch easier.
    Good idea.
    At least we can laugh at them still using Matchlock Musketeers in 1750, despite the fact they can't even train or retrain them anymore

    Quote Originally Posted by Withwnar View Post
    To count units in settlements you can use I_NumberUnitsInSettlement (?) but it doesn't work if the unit Type contains spaces - which many do!
    I could handle that problem easily by replacing spaces with _s.

  11. #11
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Replacing units

    Quote Originally Posted by LEGIONARIVS HVNGARIVS View Post
    Good idea.
    Oh, I thought it was your idea. I was just agreeing with you. If you did the destroy_units part then the AI might be tempted to create the new Musketeers sooner.

    Quote Originally Posted by LEGIONARIVS HVNGARIVS View Post
    I could handle that problem easily by replacing spaces with _s.
    That's right. I always do that for any units I create for this reason. I_NumberUnits... is a really handy condition, when it can work.

  12. #12

    Default Re: Replacing units

    Quote Originally Posted by Withwnar View Post
    Oh, I thought it was your idea. I was just agreeing with you. If you did the destroy_units part then the AI might be tempted to create the new Musketeers sooner.
    Too bad that Total War doesn't allow you to upgrade your units like that (replacing the outdated ones with newer ones)
    So, all we can do is choose between the two.
    Don't know about musketeers, but I'm definitely going to use destroy_units on Arquebusiers.

    Quote Originally Posted by Withwnar View Post
    That's right. I always do that for any units I create for this reason. I_NumberUnits... is a really handy condition, when it can work.
    Units in the original Medieval 1 Total War also had names with _s instead of spaces.

  13. #13

    Default Re: Replacing units

    All units have 2 id's, their "EDU name" wich uses spaces and their "text_string" names that don't.
    Various scripting commands don't always use the same name.

    I'd just destroy all the old ones via script.
    Disable the recruitment of the old unit, and spawn 3 of the new unit in all the settlements.

    Personally I wouldn't bother counting and just blanket cover it all.
    If you really want to have some differentiation either give more important regions some more and smaller ones less or base it on buildings in the region.

    Alternativly you could give the matchlocks an armor upgrade that makes them look like low quality flint locks.

  14. #14
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default Re: Replacing units

    Just remember to use the
    if I_SettlementOwner [settlemnt] [faction]
    and I_NumberUnitsInSettlement [settlement]
    ...
    end_if
    call for each spawn and you can have this for all factions in 1 monitor with no other counters.
    Last edited by Kiliç Alì; February 09, 2012 at 09:38 AM.

    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

Posting Permissions

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