Results 1 to 12 of 12

Thread: Discussion of work on improving the performance of modifications

  1. #1

    Default Discussion of work on improving the performance of modifications






    Here I would like to start a discussion of various things that greatly affect the performance of the game.




    To begin with, I suggest talking about scripts - some of them quite strongly affect the performance of the game (waiting time for the next turn, etc.) and are very much in demand in various modifications - we could try replacing them with something else using this project . If anyone knows the "heavy" scripts that are needed for minor changes, you can write about them here.
    People always have been the foolish victims of deception and self-deception in politics, and they always will be, until they have learned to seek out the interests of some class or other behind all moral, religious, political and social phrases, declarations and promises
    medieval 2 total war engine overhaul project

  2. #2
    franky317's Avatar Libertus
    Join Date
    Jul 2011
    Location
    Rieti, (Ita)
    Posts
    99

    Default Re: Discussion of work on improving the performance of modifications

    surely the heaviest scripts are those where there are many conditions.


    example:


    Spoiler Alert, click show to read: 
    if not I_SettlementOwner Granada = slave
    and not I_SettlementOwner Granada = novgorod
    and not I_SettlementOwner Granada = russia
    and not I_SettlementOwner Granada = byzantium
    and not I_SettlementOwner Granada = aztecs
    and not I_SettlementOwner Granada = england
    and not I_SettlementOwner Granada = scotland
    and not I_SettlementOwner Granada = saxons
    and not I_SettlementOwner Granada = denmark
    and not I_SettlementOwner Granada = hre
    and not I_SettlementOwner Granada = poland
    and not I_SettlementOwner Granada = hungary
    and not I_SettlementOwner Granada = portugal
    and not I_SettlementOwner Granada = spain
    and not I_SettlementOwner Granada = aragon
    and not I_SettlementOwner Granada = milan
    and not I_SettlementOwner Granada = france
    and not I_SettlementOwner Granada = venice
    and not I_SettlementOwner Granada = pisa
    and not I_SettlementOwner Granada = papal_states
    and not I_SettlementOwner Granada = sicily
    and not I_SettlementOwner Granada = normans
    and not I_SettlementOwner Granada = barons
    and I_EventCounter Granada_islam = 0
    set_event_counter Granada_european 0
    set_event_counter Granada_islam 1
    set_event_counter Granada_greek 0
    change_settlement_name Granada Granada_islam




    this is a part of the city name change script, consider 199 cities for 31 factions.
    Which then come in this case are grouped into cultures ....


    in the bellumcrucis submod, another quite heavy script is Crusades' Limits Script.


    Where through various counters the crusades are identified, setting that only some factions can participate.
    All this for not having an unbalanced campaign but it is very heavy.


    example:


    Spoiler Alert, click show to read: 
    ;;;;CALIFFATO E SIRIANI
    declare_counter islami
    declare_counter islama
    declare_counter califfato
    declare_counter siriano
    set_event_counter siriano 0
    set_event_counter califfato 0
    set_event_counter islami 0
    set_event_counter islama 0


    ;;;;;;;;;;;;CALIFFATO
    monitor_event CrusadeCalled TargetFactionType timurids
    and I_EventCounter islami 0
    set_event_counter islami 1
    set_event_counter califfato 1
    end_monitor


    ;;;SIRIANI


    monitor_event CrusadeCalled TargetFactionType zenghids
    and I_EventCounter islami 0
    set_event_counter islami 1
    set_event_counter siriano 1
    end_monitor


    monitor_event FactionTurnEnd FactionIsLocal
    and I_EventCounter islami 1


    if not I_EventCounter scotland_heretic_conversion_accepted = 1
    set_religion scotland judaism
    end_if


    if not I_EventCounter hungary_heretic_conversion_accepted = 1
    set_religion hungary judaism
    end_if


    if not I_EventCounter denmark_heretic_conversion_accepted = 1
    set_religion denmark judaism
    end_if


    if not I_EventCounter saxons_heretic_conversion_accepted = 1
    set_religion saxons judaism
    end_if


    if not I_EventCounter venice_heretic_conversion_accepted = 1
    set_religion venice judaism
    end_if


    if not I_EventCounter milan_heretic_conversion_accepted = 1
    set_religion milan judaism
    end_if


    if not I_EventCounter aragon_heretic_conversion_accepted = 1
    set_religion aragon judaism
    end_if


    if not I_EventCounter spain_heretic_conversion_accepted = 1
    set_religion spain judaism
    end_if


    if not I_EventCounter portugal_heretic_conversion_accepted = 1
    set_religion portugal judaism
    end_if


    if not I_EventCounter poland_heretic_conversion_accepted = 1
    set_religion poland judaism
    end_if


    if not I_EventCounter pisa_heretic_conversion_accepted = 1
    set_religion pisa judaism
    end_if


    set_event_counter islama 1
    set_event_counter islami 0
    end_monitor


    monitor_event FactionTurnStart FactionIsLocal
    and I_EventCounter islama 1


    if not I_EventCounter scotland_heretic_conversion_accepted = 1
    set_religion scotland catholic
    end_if


    if not I_EventCounter hungary_heretic_conversion_accepted = 1
    set_religion hungary catholic
    end_if


    if not I_EventCounter denmark_heretic_conversion_accepted = 1
    set_religion denmark catholic
    end_if


    if not I_EventCounter saxons_heretic_conversion_accepted = 1
    set_religion saxons catholic
    end_if


    if not I_EventCounter venice_heretic_conversion_accepted = 1
    set_religion venice catholic
    end_if


    if not I_EventCounter milan_heretic_conversion_accepted = 1
    set_religion milan catholic
    end_if


    if not I_EventCounter aragon_heretic_conversion_accepted = 1
    set_religion aragon catholic
    end_if


    if not I_EventCounter spain_heretic_conversion_accepted = 1
    set_religion spain catholic
    end_if


    if not I_EventCounter portugal_heretic_conversion_accepted = 1
    set_religion portugal catholic
    end_if


    if not I_EventCounter poland_heretic_conversion_accepted = 1
    set_religion poland catholic
    end_if


    if not I_EventCounter pisa_heretic_conversion_accepted = 1
    set_religion pisa catholic
    end_if


    set_event_counter islama 0
    set_event_counter islami 1
    end_monitor




    monitor_event CrusadeEnds
    if not I_EventCounter scotland_conversion_accepted = 1
    set_religion scotland catholic
    end_if


    if not I_EventCounter hungary_heretic_conversion_accepted = 1
    set_religion hungary catholic
    end_if


    if not I_EventCounter denmark_heretic_conversion_accepted = 1
    set_religion denmark catholic
    end_if


    if not I_EventCounter saxons_heretic_conversion_accepted = 1
    set_religion saxons catholic
    end_if


    if not I_EventCounter venice_heretic_conversion_accepted = 1
    set_religion venice catholic
    end_if


    if not I_EventCounter milan_heretic_conversion_accepted = 1
    set_religion milan catholic
    end_if


    if not I_EventCounter aragon_heretic_conversion_accepted = 1
    set_religion aragon catholic
    end_if


    if not I_EventCounter spain_heretic_conversion_accepted = 1
    set_religion spain catholic
    end_if


    if not I_EventCounter portugal_heretic_conversion_accepted = 1
    set_religion portugal catholic
    end_if


    if not I_EventCounter poland_heretic_conversion_accepted = 1
    set_religion poland catholic
    end_if


    if not I_EventCounter pisa_heretic_conversion_accepted = 1
    set_religion pisa catholic
    end_if


    if I_EventCounter siriano = 1
    console_command diplomatic_stance hre zenghids neutral
    console_command diplomatic_stance england zenghids neutral
    console_command diplomatic_stance france zenghids neutral
    console_command diplomatic_stance sicily zenghids neutral
    console_command diplomatic_stance normans zenghids neutral
    console_command diplomatic_stance papal_states zenghids neutral
    set_event_counter siriano 0
    end_if


    if I_EventCounter califfato = 1
    console_command diplomatic_stance hre timurids neutral
    console_command diplomatic_stance england timurids neutral
    console_command diplomatic_stance france timurids neutral
    console_command diplomatic_stance sicily timurids neutral
    console_command diplomatic_stance normans timurids neutral
    console_command diplomatic_stance papal_states timurids neutral
    set_event_counter califfato 0
    end_if


    set_event_counter islami 0
    set_event_counter islama 0
    end_monitor




    this is only the script for the crusades against baghad caliphate, zengidi.




    I'm already working on this through the label function. if you want I can explain :-)

  3. #3

    Default Re: Discussion of work on improving the performance of modifications

    Maybe the script for named forts could be replaced with something simpler. Instead of characters spawned and killed each turn, names could be associated in a config file with coordinates, and thus simply displayed IG over designated tiles without any character.

  4. #4
    Lord Baal's Avatar Praefectus
    Join Date
    Apr 2011
    Location
    Republica de Venezuela
    Posts
    6,704

    Default Re: Discussion of work on improving the performance of modifications

    Now that forts can be made permanent perhaps it would not be necessary anymore and indeed could be named out of a config file.
    PROUD TO BE A PESANT. And for the dimwitted, I know how to spell peasant. <== This blue things are links, you click them and magical things (like not ending up like a fool) happens.
    Visit my utterly wall of doom here.
    Do you wanna play SS 6.4 and take your time while at it? Play with my 12 turns per year here.
    Y también quieres jugar Stainless Steel 100% en español? Mira por aca.

  5. #5

    Default Re: Discussion of work on improving the performance of modifications

    Is there anyway to expand on m2tw taking more resource from multi core processors ? I would like to see 20,000 v 20,000 troops / and larger tactical map on a modern alien computer without having lag etc. It would truly make m2tw epic.

  6. #6
    Araval's Avatar Protector Domesticus
    Join Date
    Nov 2010
    Location
    Tartu, Estonia
    Posts
    4,754

    Default Re: Discussion of work on improving the performance of modifications

    The game checks a monitor_condition in script 20 times per second which makes end turn times long for mods that have this kind of script a lot. Maybe once per second would be sufficient?

  7. #7

    Default Re: Discussion of work on improving the performance of modifications

    Quote Originally Posted by Araval View Post
    The game checks a monitor_condition in script 20 times per second which makes end turn times long for mods that have this kind of script a lot. Maybe once per second would be sufficient?
    I cannot do exactly that. But if there are some very heavy and at the same time very necessary scripts using monitor_condition, then I can try to completely transfer their functionality to the program.
    Gray Fox,
    I think it's almost impossible. I use multithreading to write the program, but for the things in the game it would probably be crazy to try to add this.
    People always have been the foolish victims of deception and self-deception in politics, and they always will be, until they have learned to seek out the interests of some class or other behind all moral, religious, political and social phrases, declarations and promises
    medieval 2 total war engine overhaul project

  8. #8

    Default Re: Discussion of work on improving the performance of modifications

    The main cause of long scripts is the lack of adequate (independent) conditions. Could the tool do something like giving a value to an event_counter depending on conditions checked out of the game? For example, if a region is local, then an associated counter would have 1 for value, and we would not have to test the settlement owner with each faction:
    Code:
    if I_EventCounter T_RegionIsLocal_81 = 1
    
        [...]
    
    end_if
    ("T" is just for "tool")

    Something more complicated could also be done by linking settlement levels with different values for the same counter:
    Code:
    if I_EventCounter T_SettlementLevel_81 = 5 ; large city
    
        [...]
    
    end_if
    Just an idea.

  9. #9

    Default Re: Discussion of work on improving the performance of modifications

    Quote Originally Posted by Erken View Post
    The main cause of long scripts is the lack of adequate (independent) conditions. Could the tool do something like giving a value to an event_counter depending on conditions checked out of the game? For example, if a region is local, then an associated counter would have 1 for value, and we would not have to test the settlement owner with each faction:
    Code:
    if I_EventCounter T_RegionIsLocal_81 = 1
    
        [...]
    
    end_if
    ("T" is just for "tool")

    Something more complicated could also be done by linking settlement levels with different values for the same counter:
    Code:
    if I_EventCounter T_SettlementLevel_81 = 5 ; large city
    
        [...]
    
    end_if
    Just an idea.
    I think it's possible to do this, but I'm not sure about expediency.
    I need to think carefully about the further direction of the project, perhaps a more correct solution would be to give modders the opportunity to write c ++ code, there are no restrictions and the project already has many different auxiliary functions, rid of low-level code.


    For example, a small code that will kill the ruler of the england faction if the capital of the faction is a level 5 castle:

    Last edited by youneuoy; August 14, 2020 at 02:19 PM.
    People always have been the foolish victims of deception and self-deception in politics, and they always will be, until they have learned to seek out the interests of some class or other behind all moral, religious, political and social phrases, declarations and promises
    medieval 2 total war engine overhaul project

  10. #10

    Default Re: Discussion of work on improving the performance of modifications

    I know nothing to c++, but your example is very easy to understand, and personally i would prefer learn the rudiments of this langage rather than continuing to suffer the limitations of the campaign_script .

    So if i correctly understand, it's more interresting for you to develop ideas allowing you to make new functions, so that modders can next do what they need with them?

    Another question : The tool perform his actions before the local turn currently, is this a necessity or could it also be done in other circumstances like we do in scripts with monitor_event?

  11. #11
    Lord Baal's Avatar Praefectus
    Join Date
    Apr 2011
    Location
    Republica de Venezuela
    Posts
    6,704

    Default Re: Discussion of work on improving the performance of modifications

    Having scripting capabilities like that alone would not only revolutionate it all, but even increase performance by making huge and large scripts only a few lines long.
    PROUD TO BE A PESANT. And for the dimwitted, I know how to spell peasant. <== This blue things are links, you click them and magical things (like not ending up like a fool) happens.
    Visit my utterly wall of doom here.
    Do you wanna play SS 6.4 and take your time while at it? Play with my 12 turns per year here.
    Y también quieres jugar Stainless Steel 100% en español? Mira por aca.

  12. #12

    Default Re: Discussion of work on improving the performance of modifications

    Quote Originally Posted by Erken View Post
    I know nothing to c++, but your example is very easy to understand, and personally i would prefer learn the rudiments of this langage rather than continuing to suffer the limitations of the campaign_script .

    So if i correctly understand, it's more interresting for you to develop ideas allowing you to make new functions, so that modders can next do what they need with them?

    Another question : The tool perform his actions before the local turn currently, is this a necessity or could it also be done in other circumstances like we do in scripts with monitor_event?
    yes, the main problem is finding all these things. It is difficult to do this when many other things have to be done in parallel. In general, this can be done. Nevertheless, there are some events even now, not exactly the same as usual in scripts, but still. For example, you can write your own code that will be executed when the campaign is loaded or when it is closed. You can also create a separate thread, and make a while loop in it, thus the function of replacing resource models works, for example(this function is about 100 lines long).
    Maybe after update 1.19 I'll start working on it. I will make a separate .dll and let modders try to write C ++ code, if they like it, we will expand these capabilities. The only drawback, in my opinion, is that you cannot just write the code into the file, it will also need to be compiled.

    I think it might look like this:
    there will be a file with code and with empty functions already written, like:
    onChangeTurnNum (), afterAutoResolve (), etc. You can add your own code to these functions. With the help of auxiliary functions, you can do anything, for example, there is already a function that allows you to get a list of factions or a list of armies in battle and also perform various operations with them., etc.
    Quote Originally Posted by Erken View Post
    So if i correctly understand, it's more interresting for you to develop ideas allowing you to make new functions, so that modders can next do what they need with them?
    well, in any case, I have to do this because modders usually do not have such skills (reverse game functions and restoring game data structures). So it would save me some time for me.
    Last edited by youneuoy; August 15, 2020 at 01:53 PM.
    People always have been the foolish victims of deception and self-deception in politics, and they always will be, until they have learned to seek out the interests of some class or other behind all moral, religious, political and social phrases, declarations and promises
    medieval 2 total war engine overhaul project

Posting Permissions

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