Results 1 to 16 of 16

Thread: Improving the garrison script

Hybrid View

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

    Default Improving the garrison script

    Now remember that I don't know the ins and outs of modding total war, but I had a look at the code for this and I think I understand how it all works. My background is web development and database programming so I think in those terms. Though, as I said, I don't know what functions are available in scripting total war.

    Here's what I gathered:

    1. Make a list of towns and give them a value of 1.
    2. Make a garrison script and apply it to towns where the value is 1.

    It would make for much easier and definately a shorter code.

    You could easily make a very advanced garrison script but have to apply to all cities you want without having to go through the effort of copying pasting, changing and applying.

    You could make a script that check what type of town it is, what buildings it contains and add the garrison accordingly, to all towns, but with just one script.

    Or am I completely sailing in wonderland here?

  2. #2

    Default Re: Improving the garrison script

    I would probably figure it all out in the end, and make it like this:

    1. The garrison spawns to all towns/castles that has any type of barracks.
    A. It checks barrack type and spawns the best available militia unit.
    B. It adds upgrades according to what is available in that town.
    C. Better barracks spawns more militia. For example, Town Watch spawns 1, Drill Square 4. But none will be spawned if the town is already full of armies.

  3. #3
    Magefsx's Avatar Campidoctor
    Join Date
    Dec 2009
    Location
    England
    Posts
    1,564

    Default Re: Improving the garrison script

    Idea one is a very short script that is unlikely to go wrong, but each would only apply for max 2 towns (due to different factions) which makes it more or less pointless
    However, idea two sounds pretty good, and is probably possible- and would also be a lot more realistic, due to not suddenly spawning a bunch of knights in a town. Perhaps you should choose the amount of militia produced by population, and choose the level of militia by building

  4. #4

    Default Re: Improving the garrison script

    The population idea is good, even more precise than my idea. I like it. Basing it off only the building would require you to assume the player actually has it upgraded in accordance to the city size, which is a bad assumption to make, so yeah, population would be a great factor.

    As for factions, couldn't the script itself get the data which faction is used and spawn accordingly?

  5. #5

    Default Re: Improving the garrison script

    Ok well as a scripter myself for not just med2 and CA games but many other games to i have to say its a bold idea you have but one that many have tried and failed .

    Why you may ask well its simple there is a big difference between a game mechanic and a after effect script such as the garrision is in med2, In latter games such etw ntw ca have gone wow those modders had the right idea and they made a garrision as a mechanic much after the fashion you want to do with med2(based on population and tech level of the city .

    The horde mechanic is the closest thing in med2 to what you wish to achieve ( i used it alot in HHB) but it wont do what you wish it either
    The limitation of there scripting and recognition to the scripting is quite limited (have you downloaded the ultimate docudemon as this is an official list of all the scripting monitors conditions and commands that the game engine will recognise).

    Basicly the effect you wish to achieve could only be done as a game mechanic and to add a game mechanic you need to open all the files hidden inthe games EXE which is actually very doable also very VERY illegal. Why you may ask why cant a script cover the field as a game mechanic would the answer is the script needs a exact location to to inact the command this can be a x,y location a settlement name (which holds its own x,y ) or a exact character name to find location .

    You could make a garrision script with many of the features you want it would require alot of work and would be a long VERY long script or series of scripts to get what you wanted but the end result would you still need a script for each and every city you wish to apply a garrision to as it needs to know where to spawn the men .

    The closest way you could get an effect like latter TW games would be to create a special unit for each of the culture types (you would need to remove units as KGCM is at the 500 unit max as its hardcoded) give these units 0 movement then add them to the settlements in the descr_strat to begin with ,then script the game to make more of these every time a settlement grows easiest being the condition of building each wall type as this is the indicator of settlement size. This would still have the limitation of not being ablee to hold a full 20 created units in the settlement as it holds these created units and wont replace them as it does in say NTW as again it wont be a game mechanic but rather a effect you add after.

    Sorry to burst your bubble on this idea but by all means try to follow it as in your failure you will learn alot along the road failure is a better teacher than success sometimes

    Heroes Hordes & beyond The official submod of KGCM (click the sig)

  6. #6

    Default Re: Improving the garrison script

    No worries, mate! Could you perhaps link me to that list of yours by the way? I've been trying to find a list of all possible commands for some time now lol

  7. #7

    Default Re: Improving the garrison script

    Certainly i must say it is limited but its not to limited with some creative thinking you may get some sort of effect as you wish (close) but usually everything has a draw back and rememeber the more complex you make a script the more pc power you will use between turns as it calculates the scripts(monitor events rather than conditions when ever possible as it requires less on the pc not a problem for those with good pcs but those with lower end will be waiting a long time between turns.)

    If you look at some of my scripts from HHB you will see i do them as simple as possible to add the effect i want without having to push the pc to hard to calculate them
    http://www.twcenter.net/forums/showt...mate+docudemon

    Heroes Hordes & beyond The official submod of KGCM (click the sig)

  8. #8

    Default Re: Improving the garrison script

    Many thanks, champ! Yeah I'll definately keep that in mind as well! Always good with tips from those who have already walked the long walk

  9. #9

    Icon5 Re: Improving the garrison script

    I love KGCM, except for the garrison script, which I find tremendously annoying. Can anyone tell me how to turn it off or delete it? (I have the 4.2 patch.)

  10. #10
    Darch's Avatar Libertus
    Join Date
    Jan 2010
    Location
    Dublin, Ireland
    Posts
    97

    Default Re: Improving the garrison script

    Sorry to hijack this thread, but I too am interested in altering the garrison scripting a little (and the campaign script in general), but before I do anything, I would like to ask a couple of questions if I may?


    • Soul Firez and/or Dave, what criteria did you use when deciding which settlements needed garrison scripting? I think I read somewhere that it was only "important" settlements that were protected by the script, so I'm just wondering how you decided if a settlement was important or not?
    • Is an AI faction actually more aggressive towards settlements it needs for victory conditions? And if so, will settlements that are required by multiple factions tend to be beseiged far more often? In theory, this should be the case, but in practice?
    • When a garrison script is activated, and the army appears, does the owning faction have to pay upkeep for this army? And therefore, if the script was activated several times in different settlements in one turn, does that faction suddenly find itself in financial trouble (ignoring the debt script for the moment)?
    • Speaking of the debt script, is it possible to make this payout happen only once every X amount of turns, in much the same way the garrison script can only be activated every 10 turns?

    Thanks in advance.

  11. #11

    Default Re: Improving the garrison script

    I think they mostly scripted main settlements, like Captitals, and for those small starting factions like Wales or Flanders, they have all their settlements scripted to avoid being crushed by the marjor factions like France, HRE or England, hehe

  12. #12
    Darch's Avatar Libertus
    Join Date
    Jan 2010
    Location
    Dublin, Ireland
    Posts
    97

    Default Re: Improving the garrison script

    Quote Originally Posted by marcovchb View Post
    I think they mostly scripted main settlements, like Captitals, and for those small starting factions like Wales or Flanders, they have all their settlements scripted to avoid being crushed by the marjor factions like France, HRE or England, hehe
    Aye, I just wondered if they had a "formula" or decided on a settlement by settlement basis. Another couple of questions I forgot to ask above;

    • How few units does a settlement need to have before the script kicks in, or does it kick in regardless of the number of units stationed there? (I thought it was the former, but I can't see it in the file).
    • This is something I would know if I paid more attention during my games... but can anyone tell me, does the AI ever move it's capital?

  13. #13

    Default Re: Improving the garrison script

    Quote Originally Posted by Darch View Post
    Sorry to hijack this thread, but I too am interested in altering the garrison scripting a little (and the campaign script in general), but before I do anything, I would like to ask a couple of questions if I may?


    • Soul Firez and/or Dave, what criteria did you use when deciding which settlements needed garrison scripting? I think I read somewhere that it was only "important" settlements that were protected by the script, so I'm just wondering how you decided if a settlement was important or not?
    • Is an AI faction actually more aggressive towards settlements it needs for victory conditions? And if so, will settlements that are required by multiple factions tend to be beseiged far more often? In theory, this should be the case, but in practice?
    • When a garrison script is activated, and the army appears, does the owning faction have to pay upkeep for this army? And therefore, if the script was activated several times in different settlements in one turn, does that faction suddenly find itself in financial trouble (ignoring the debt script for the moment)?
    • Speaking of the debt script, is it possible to make this payout happen only once every X amount of turns, in much the same way the garrison script can only be activated every 10 turns?
    Thanks in advance.

    Ok well important for the garrision script comes under 2 headings important historically eg was a major city in these periods but the second side to this is important balance wise to help stopping you from being able to steam roll the AI so expect if the city is a key city /capital or is the shield for say the start of the factions lands you can bet it will have a script to it .

    Ok well this depends on how the AIs priorities are set as to how much the required settlements for factions victory drive the AI i have it set quite high in HHB so the ai WILL GO FOR THE WIN . Therefor yes a settlement that is need by both factions will be a much contested settlement and there are some that actually have a garrision script for 2 factions (not many most cities only give garrision for the original faction )

    Yes the faction has to pay upkeep they dont pay to create the unit but must wear the cost of supporting these units and as such will if they defend there settlement then use these men to attack there attacker or a weak close settlement that fits there priorities.

    Yes it is possible to link a counter to a debt script so that it will fire less often but usual practice is to alter the amounts it fires under eg it is set to minus 5000 to fire and then gives money depending on faction (more balancing issues) that covers this amount and a little more so the faction can move on but it will be locked from buying anything between 0 and minus 5000 to prevent it just going insanely rich with money scripts (even CA use money scripts)

    Heroes Hordes & beyond The official submod of KGCM (click the sig)

  14. #14
    Darch's Avatar Libertus
    Join Date
    Jan 2010
    Location
    Dublin, Ireland
    Posts
    97

    Default Re: Improving the garrison script

    Thanks for taking the time to answer man, I really appreciate ir. Will give +rep when I have enough posts

    Edit: Rep given now that I'm over the 25 posts mark.
    Last edited by Darch; May 15, 2010 at 04:30 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
  •