Results 1 to 10 of 10

Thread: Script delays end turn time?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    alhoon's Avatar Comes Rei Militaris
    Join Date
    Apr 2008
    Location
    Chania, Greece
    Posts
    24,233

    Default Script delays end turn time?

    I'm expanding the script in my mod... Using the wonderful script replicator from Greeneyeddvl, I can expand it quite much very, very quickly.

    However, I'm worried that this will increase the endturn time. So I would like to know, what increases the end turn time and how much?

    Script size?
    CharacterTurnEnd/start monitors?
    SettlementTurnStart/end monitors?
    if clauses?
    generation of random counters or increasing counters?



    I have already found out that creating units (via script or at the settlements themselves) increases the end turn, as do battles the AI does with other AI factions.
    alhoon is not a member of the infamous Hoons: a (fictional) nazi-sympathizer KKK clan. Of course, no Hoon would openly admit affiliation to the uninitiated.
    "Angry Uncle Gordon" describes me well.
    _______________________________________________________
    Beta-tester for Darthmod Empire, the default modification for Empire Total War that does not ask for your money behind patreon.
    Developer of Causa Belli submod for Darthmod, headed by Hammeredalways and a ton of other people.
    Developer of LtC: Random maps submod for Lands to Conquer (that brings a multitude of random maps and other features).

  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: Script delays end turn time?

    The worst impact on performance comes from using monitor_conditions instead of monitor_events. I have a fairly large garrison script around here someplace that actually runs fairly fast.

    Another thing you can do is stack your If statements up inside a single monitor where possible.

  3. #3

    Default Re: Script delays end turn time?

    does game work without monitor_conditions? can i delete this file or simply replace it with monitor_events?
    Last edited by dudio; April 16, 2009 at 09:13 AM.

  4. #4

    Default Re: Script delays end turn time?

    monitor_conditions is not a file. It is used the same as monitor_event except the engine will read it after every pass through of the script. monitor_event gets read once and ignored until that type of event occurs again. Conditions can happen at ANY given time which is why monitor conditions is constantly monitored by the engine and thus slowing your end turn down. More or Less...

    monitor_conditions slows the end turn down considerably. And as the game progresses CharacterEndTurn (StartTurn) will also start to slow the game as thier are more and more of that character type on the map.

    With all my scripts, i try to have monitor_event fire only during the players turn, this cause no turn lag at all. I have 70,000+ line scripts that causes no turn lag. Every script is different and not all scripts can be converted to run only during the players turn, but if possible that will eliminate any turn lag all together.
    ...longbows, in skilled hands, could reach further than trebuchets...

  5. #5
    alhoon's Avatar Comes Rei Militaris
    Join Date
    Apr 2008
    Location
    Chania, Greece
    Posts
    24,233

    Default Re: Script delays end turn time?

    Thanks. So... avoid monitor conditions like the plague. Check.

    Now the if thing... whould I break up if clauses to monitor events or it's better to if loops?

    I.e which is faster?

    VERSION 1:

    monitor_event FactionTurnStart FactionIsLocal
    and I_TurnNumber >= 10

    (Do something!)
    end_monitor.

    monitor_event FactionTurnStart FactionIsLocal
    and I_TurnNumber >= 20

    (Do something again!)
    end_monitor.

    monitor_event FactionTurnStart FactionIsLocal
    and I_TurnNumber >= 30

    (Do something yet again!)
    end_monitor.


    VERSION 2:

    monitor_event FactionTurnStart FactionIsLocal
    and I_TurnNumber >= 10

    (Do something!)

    if I_TurnNumber >= 20
    (Do something again!)
    end_if

    if I_TurnNumber >= 30
    (Do something yet again!)
    end_if

    end_monitor.
    alhoon is not a member of the infamous Hoons: a (fictional) nazi-sympathizer KKK clan. Of course, no Hoon would openly admit affiliation to the uninitiated.
    "Angry Uncle Gordon" describes me well.
    _______________________________________________________
    Beta-tester for Darthmod Empire, the default modification for Empire Total War that does not ask for your money behind patreon.
    Developer of Causa Belli submod for Darthmod, headed by Hammeredalways and a ton of other people.
    Developer of LtC: Random maps submod for Lands to Conquer (that brings a multitude of random maps and other features).

  6. #6

    Default Re: Script delays end turn time?

    I would use your 2nd method. Although i would enclose the first condition (I_TurnNumber >= 10) inside an if statement aswell.

    But with that said, keep in mind that if the turn is say turn 25, then all conditions before that will fire true, meaning the turn number IS >= 10 and IS also >= 20. Both theses if statements will fire true. You may want to add another line such as...

    if I_TurnNumber >= 20
    and I_TurnNumber < 30
    (Do something again!)
    end_if

    That will stop multiple if statements firing true.
    ...longbows, in skilled hands, could reach further than trebuchets...

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

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

    Default Re: Script delays end turn time?

    Counters are also powerful if you think you need to cut down on lag. You can remove the necessity of determining which faction the player is by some simple monitors to determine that at the campaign start. For instance:

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
    		and FactionType song
    	set_counter song_local_faction 1
    	set_counter jin_local_faction 0
    	set_counter goryeo_local_faction 0
    	set_counter khitans_local_faction 0
    	set_counter dali_local_faction 0
    	set_counter mongols_local_faction 0
    	set_counter khmer_local_faction 0
    	set_counter tibet_local_faction 0
    	set_counter daiviet_local_faction 0
    	set_counter xixia_local_faction 0
    	set_counter taira_local_faction 0
    	set_counter minamoto_local_faction 0
    	set_counter champa_local_faction 0
    	set_counter pagan_local_faction 0
    	set_counter ghurid_local_faction 0
    terminate_monitor
    end_monitor
    This monitor will fire at the beginning and set a local faction counter. Then in future iterations where you need to check for the faction being local and being a specific faction, you can substitute the counter. This also helps nested if statements, because for if statements to work you need to use I_ conditions, as the exports of the event are not exported to the if. This script won't work as intended:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
    		and I_CompareCounter exhaustion_kills_faction == 1
    
        if FactionType song
    	give_everything_to_faction song slave true
        end_if
    end_monitor
    Even though FactionTurnEnd exports faction so any "and" statements whose condition requires the faction will run, including FactionType among others, that export is not transferred to "if" statements. This is remedied by simply setting counters to act in place of the condition, like so:

    Code:
    ;If player chooses Decline, set to Cultural
    monitor_conditions I_EventCounter policy2_declined == 1
    	set_counter policy_timer 20
    	set_counter military_policy 0
    	set_counter economic_policy 0
    	set_counter cultural_policy 1
    	set_counter recovery_policy 0
    	set_counter current_policy 3
    	set_counter policy_change 1
    	inc_counter military_exhaustion_compiler -1
    	set_counter last_policy_delay 3
    	set_event_counter policy2_declined 0
    	historic_event cultural_policy
    	
    	if I_CompareCounter song_local_faction == 1
    		destroy_buildings song hinterland_policy_effects false
    	end_if
    	if I_CompareCounter jin_local_faction == 1
    		destroy_buildings jin hinterland_policy_effects false
    	end_if
    	if I_CompareCounter goryeo_local_faction == 1
    		destroy_buildings goryeo hinterland_policy_effects false
    	end_if
    	if I_CompareCounter khitans_local_faction == 1
    		destroy_buildings khitans hinterland_policy_effects false
    	end_if
    	if I_CompareCounter dali_local_faction == 1
    		destroy_buildings dali hinterland_policy_effects false
    	end_if
    	if I_CompareCounter mongols_local_faction == 1
    		destroy_buildings mongols hinterland_policy_effects false
    	end_if
    	if I_CompareCounter khmer_local_faction == 1
    		destroy_buildings khmer hinterland_policy_effects false
    	end_if
    	if I_CompareCounter tibet_local_faction == 1
    		destroy_buildings tibet hinterland_policy_effects false
    	end_if
    	if I_CompareCounter daiviet_local_faction == 1
    		destroy_buildings daiviet hinterland_policy_effects false
    	end_if
    	if I_CompareCounter xixia_local_faction == 1
    		destroy_buildings xixia hinterland_policy_effects false
    	end_if
    	if I_CompareCounter taira_local_faction == 1
    		destroy_buildings taira hinterland_policy_effects false
    	end_if
    	if I_CompareCounter minamoto_local_faction == 1
    		destroy_buildings minamoto hinterland_policy_effects false
    	end_if
    	if I_CompareCounter champa_local_faction == 1
    		destroy_buildings champa hinterland_policy_effects false
    	end_if
    	if I_CompareCounter pagan_local_faction == 1
    		destroy_buildings pagan hinterland_policy_effects false
    	end_if
    	
    end_monitor

  8. #8
    alhoon's Avatar Comes Rei Militaris
    Join Date
    Apr 2008
    Location
    Chania, Greece
    Posts
    24,233

    Default Re: Script delays end turn time?

    Quote Originally Posted by Tsarsies View Post
    I would use your 2nd method. Although i would enclose the first condition (I_TurnNumber >= 10) inside an if statement aswell.

    But with that said, keep in mind that if the turn is say turn 25, then all conditions before that will fire true, meaning the turn number IS >= 10 and IS also >= 20. Both theses if statements will fire true. You may want to add another line such as...

    if I_TurnNumber >= 20
    and I_TurnNumber < 30
    (Do something again!)
    end_if

    That will stop multiple if statements firing true.
    I know. It was just an example. Thanks for the replies.
    alhoon is not a member of the infamous Hoons: a (fictional) nazi-sympathizer KKK clan. Of course, no Hoon would openly admit affiliation to the uninitiated.
    "Angry Uncle Gordon" describes me well.
    _______________________________________________________
    Beta-tester for Darthmod Empire, the default modification for Empire Total War that does not ask for your money behind patreon.
    Developer of Causa Belli submod for Darthmod, headed by Hammeredalways and a ton of other people.
    Developer of LtC: Random maps submod for Lands to Conquer (that brings a multitude of random maps and other features).

  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: Script delays end turn time?

    AL has the right of it there but you have to be careful how and when you set the counter that fires the event. AL is firing it manually when the user clicks the Declined button on a scroll. If you are going to set them automatically you need to be sure you know exactly when they will fire.

  10. #10
    alhoon's Avatar Comes Rei Militaris
    Join Date
    Apr 2008
    Location
    Chania, Greece
    Posts
    24,233

    Default Re: Script delays end turn time?

    So, conditions delay the end turn, because they are constantly checked, right?

    So, if I use conditions like this, it wouldn't cause much of a delay, right?

    monitor_conditions I_EventCounter TEST_declined = 1
    set_event_counter TEST_dec 1
    set_event_counter TEST_declined 0
    end_monitor

    monitor_event FactionTurnStart FactionIsLocal
    and I_EventCounter TEST_dec = 1

    (Do something)

    end_monitor


    It will constantly keep looking for the TEST_declined condition, but the script would fire only at the start of the players turn.



    Also, is there a way to monitor yes/no answers from the player without using conditions?

    I mean, if there's this pop-up message where the player chooses yes or no, and the player press "no" would this work?

    monitor_event FactionTurnStart FactionIsLocal
    and I_EventCounter TEST_declined = 1
    (Do something)
    end_monitor

    If yes, then it would eliminate the need to monitor conditions for much of the game.
    alhoon is not a member of the infamous Hoons: a (fictional) nazi-sympathizer KKK clan. Of course, no Hoon would openly admit affiliation to the uninitiated.
    "Angry Uncle Gordon" describes me well.
    _______________________________________________________
    Beta-tester for Darthmod Empire, the default modification for Empire Total War that does not ask for your money behind patreon.
    Developer of Causa Belli submod for Darthmod, headed by Hammeredalways and a ton of other people.
    Developer of LtC: Random maps submod for Lands to Conquer (that brings a multitude of random maps and other features).

Posting Permissions

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