Results 1 to 19 of 19

Thread: dynamic settlement name in create_unit?

Hybrid View

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

    Default dynamic settlement name in create_unit?

    So a few hours ago I got this terrific idea about tying recruitment of new units to generals.
    The idea is simple: every time a faction gets a new general (throgh marriage, adoption or coming of age) an army (dependent of faction leaders authority, the characters loyalty and the settlements recruitment level via building) is spwaned with him.

    I ironed out the details of this idea and warmed myself up for some scripting by skimming through the docudemons while I made a staggering discovery: the create_unit command I was planing to use requires a specific settlement/character.

    Since characters can pop up in every settlement I would have to make the script for every single settlement on the whole map.

    Is there any way arround that?
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  2. #2
    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: dynamic settlement name in create_unit?

    Nope.

  3. #3

    Default Re: dynamic settlement name in create_unit?

    Oh great.

    A quick calculation proposes aprox 3.000.000 lines of code...
    I think this project died befor it realy started

    At least for the grand campaing.

    One of the kingdomes campaign with far less factions, regions and no era tied recruitment would work, maybe.

    Ok, another calculation based on the BritishIsle campaing proposes 140.000 lines...
    Damn, I fear this idea is doomed
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  4. #4
    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: dynamic settlement name in create_unit?

    3 million? I seriously doubt that lol

    I would even seriously doubt 140k.

  5. #5

    Default Re: dynamic settlement name in create_unit?

    Well, lets say we have 200 regions
    25 factions
    castle/city
    human/ai
    3 eras
    10 levels of recruitment
    and all in all 5 lines of code for each level of recruitment

    thats 200 * 25 * 2 * 2 * 3 * 10 * 5 = 3.000.000
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  6. #6

    Default Re: dynamic settlement name in create_unit?

    The garrison script i have recently finished (have not as yet uploaded it) covers 30 factions, 200 settlements (3 times each), 150+ unit variations of spawn and has about 70,000 lines of code. Ofcourse, its not perfect, a few minor things to iron out i am sure. But thats just to show you that your idea is doable in less then 3 million lines of code!

    Keep in mind, i did not type out every single line either, alot of it is copy paste, then fill in the parts you need to be different. (like the unit names and settlement names in my script), alot of it is really repeated with just different data. I also used alot of counters to get rid of a lot of code and also keep the script firing with no turn lag. Once you get a basis of the script working for one settlement you only need change the variables and such for each settlement.

    So your idea is easily doable in less then 3 million lines of code. and more than likely less than 100,000 lines of code!
    ...longbows, in skilled hands, could reach further than trebuchets...

  7. #7

    Default Re: dynamic settlement name in create_unit?

    Well, first to say I am glad, that Im not the only one with such ambitous projects

    Yeah, with a good code structure you can probably save a lot of lines.
    But I have a question to you: has your garrision script a influence on how long turns need to load?
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  8. #8

    Default Re: dynamic settlement name in create_unit?

    Do you mean does my script, being 70,000 lines or so of code, slow the wait between turns down... NO, well, very little if any at all. All monitors fire during the players turn, except for a few that fire during the AI turn. The more monitors firing during the AI turn the slower the turn wait. You can have hundreds of monitors running during the players turn with no loss to turn wait. Or so i have experienced anyway.
    ...longbows, in skilled hands, could reach further than trebuchets...

  9. #9
    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: dynamic settlement name in create_unit?

    It also runs better if you stay away from monitor_conditions as much as you can.

  10. #10

    Default Re: dynamic settlement name in create_unit?

    Hm, seems Im in desperate need of help in srcipting (that syntax errors in the script file doesnt cause MTW2 to crash doesnt help either).

    For starters, whats wrong with this piece of code?
    Code:
    monitor_event SettlementTurnStart
    		if SettlementName Caernarvon
    			create_unit Caernarvon, Helwyr, num 2, exp 0, arm 0, wep 0
    		end_if
    	end_monitor
    Is SettlementTurnStart/End even triggered in the players turn?
    Last edited by Zombimode; August 29, 2008 at 02:53 PM.
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

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

    Default Re: dynamic settlement name in create_unit?

    The first line goes through each of the settlements in the game; but the second line doesn't know which settlement to compare "Caernarvon" to.

    That's why you have to use monitor_conditions. Monitor_event exports things like settlementname, which inner clauses can then use; and monitor_conditions consumes stuff exported by monitor_event.

    Like so:

    Code:
    monitor_event SettlementTurnStart SettlementName Caernarvon
    			create_unit Caernarvon, Helwyr, num 2, exp 0, arm 0, wep 0
    end_monitor
    Event
    Condition


    Conditions work by comparing the current temporary data, given to it by someone else, to the keywords you provide.
    Last edited by SigniferOne; August 29, 2008 at 02:59 PM.


    "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

  12. #12

    Default Re: dynamic settlement name in create_unit?

    Ah, that was very helpfull (and it makes sense), thanks a lot

    An unrelatet question: I get confused with FactionIsLocal, IsFactionAIControlled and I_IsFactionAIControlled

    They all seem to do the same thing (checking if a faction is AI or player controlled), so why have all three?
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  13. #13
    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: dynamic settlement name in create_unit?

    Because FactionIsLocal can be true for 1 faction. IsFactionAIControlled can be true for up to 30 factions. The I_ condition has its own uses.

  14. #14

    Default Re: dynamic settlement name in create_unit?

    This is my first true scripting project (all I have done before were some easy money scripts), and I am very glad the people in this forum respond so kind to noobish questions like mine. Your help is very appreciated

    But it seems I still get it wrong.

    Code:
    declare_counter troops
    
    monitor_event CharacterComesOfAge FactionIsLocal and FactionLeaderAttribute Authority = X (ofcourse the actual code has real number, and this monitor_event is repeated 11 times for all posible Authority values, and they all set the counter troops 1)
    			set_counter troops 1
    end_monitor
    
    if I_CompareCounter troops = 1
    		create_unit Caernarvon, Helwyr, num 2, exp 0, arm 0, wep 0
                    set_counter troops 2
    end_if
    I just cant see the mistake here.
    CharacterComesOfAge has both the exports faction and character_record, so FactionIsLocal and FactionLeaderAttribute Authority should work.
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  15. #15
    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: dynamic settlement name in create_unit?

    Change FactionIsLocal to CharacterIsLocal.

  16. #16

    Default Re: dynamic settlement name in create_unit?

    Thanks for that answer and for your toutorials at TWmodsquad. Those were pretty helpful too

    But I have one more question. The first version of script is now nearly complete, save for one bug.

    Code:
    monitor_event SettlementTurnStart SettlementName Caernarvon and not IsFactionAIControlled
    		do lots of stuff
    end_monitor
    My goal is here, that the "lots of stuff" should only work if the settlement in question is controlled by the player.

    I have tried "FactionIsLocal" instead of "not IsFactionAIControlled", but with the same effect: the monitor conditions seem to be fullfilled on every turn, player or AI.

    Edit:
    Oh, apparently I have another problem:
    One of the conditions I use for my monitors is I_CompareCounter
    A typical monitor from my script:
    Code:
    monitor_event event condition and I_CompareCounter troops = 1
    But I_CompareCounter troops = 1 seem to be comletely ignored.
    I've deleted every line, that set the troops counter to 1, but every monitor works, without anything that could set the troops counter to 1.
    And yes, troops is declared at the start.

    Im completely lost....

    Edit2: ok, found the mistake with I_CompareCounter: it works when I use it with an if-clause
    Last edited by Zombimode; August 30, 2008 at 07:18 AM.
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

  17. #17

    Default Re: dynamic settlement name in create_unit?

    Ok, I found my mistake: I cames down to lacking knowlegde, what exactly IsFactionAIControlled and FactionIsLocal do, and how excatly monitor_event SettlemenTurnStart works.

    Now Im using I_SettlementOwner to identify the players faction and now everything works fine
    "Worüber man nicht sprechen kann, darüber muss man schweigen."
    -Wittgenstein

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

    Default Re: dynamic settlement name in create_unit?

    FactionIsLocal will trigger for the faction that is controlled by you the Human.


    "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

  19. #19

    Default Re: dynamic settlement name in create_unit?

    the I_CompareCounter should work with or with out and if-clause. It always works fine for me. Although as a general rule, all 'I_' conditions are more used with an if-clause. But don't be afraid to try them outside general guidelines. Just ensure you are declaring the counter at the top of your script.

    declare_counter SomeCounter

    ... declaring a counter that way declares AND sets it to zero. if you need the counter to start at a different value, simply add

    set_counter SomeCounter 2

    beneath your declaration. hope that helps with counters.

    Also, IsFactionAIControlled needs more information when used. I think you need to declare which faction your curious about. as...

    IsFactionAIControlled England

    The script checks to make sure that England is the faction in question regarding this part of the script and that it is also controlled by the AI.

    so the monitor

    monitor_event FactionTurnStart IsFactionAIControlled England
    some more code
    end_monitor

    will only fire true if it is the start of englands turn, regardless if it is AI or human controlled...

    Where as FactionIsLocal always regards the human player.

    Hope that helps somewhat...
    ...longbows, in skilled hands, could reach further than trebuchets...

Posting Permissions

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