Page 1 of 2 12 LastLast
Results 1 to 20 of 39

Thread: How to disable autoresolve for the player

  1. #1
    Aikanár's Avatar no vaseline
    Join Date
    Mar 2009
    Location
    Sanctuary
    Posts
    12,516
    Blog Entries
    3

    Default How to disable autoresolve for the player

    That's a rather short one, in contrary to what might be communis opinio, disabling autoresolve for the player is a) very simple and does b) not, in any way, affect the AI! It definitely does not lead to a freeze in the AIs turn.

    All one needs to do is to add restrict_autoresolve true after the general counter section of the campaign_script.txt without any monitor.

    campaign_script.txt
    Code:
    ;
    ; Campaign script
    ;
    script
            ; ---------------------
            ; counters
    		
            declare_counter Opened_Faction_Overview_Scroll
    		declare_counter Opened_Settlement_Scroll
    		declare_counter mongols_sarkel
    		declare_counter mongols_yerevan
    		declare_counter mongols_baghdad
    		declare_counter timurids_sarkel
    		declare_counter timurids_yerevan
    		declare_counter timurids_baghdad
    		
            
            ; ---------------------
            ; start up
    
            freeze_faction_ai aztecs
    	restrict_autoresolve	true
    
            ;----------------------
            ; monitors
    That's about it, but this disables autoresolve all together.

    Another way of forcing the player to do something you intend him to do on circumstances is to force him to fight, autoresolve or withdraw by exploiting:
    Code:
    ;---- forcing player to fight/withdraw/autoresolve
    monitor_event	ScrollOpened	ScrollOpened	prebattle_scroll
    log	always ;just for testing
    disable_cursor
    generate_random_counter	pbs	1	3	;to show randomness
    campaign_wait	1
    if	I_EventCounter	pbs	=	1
    ui_flash_start	prebattle_fight_button
    campaign_wait	1	;could be longer to let the player take a longer look at the prebattle_scroll
    select_ui_element	prebattle_fight_button
    simulate_mouse_click	lclick_down
    select_ui_element	prebattle_fight_button
    simulate_mouse_click	lclick_up
    end_if
    if	I_EventCounter	pbs	=	2
    ui_flash_start	prebattle_auto_resolve_button
    campaign_wait	1
    select_ui_element	prebattle_auto_resolve_button
    simulate_mouse_click	lclick_down
    select_ui_element	prebattle_auto_resolve_button
    simulate_mouse_click	lclick_up
    end_if
    if	I_EventCounter	pbs	=	3
    ui_flash_start	prebattle_withdraw_button
    campaign_wait	1
    select_ui_element	prebattle_withdraw_button
    simulate_mouse_click	lclick_down
    select_ui_element	prebattle_withdraw_button
    simulate_mouse_click	lclick_up
    end_if
    enable_cursor
    end_monitor


    Enjoy modding
    Last edited by Aikanár; February 20, 2012 at 02:55 PM. Reason: updated


    Son of Louis Lux, brother of MaxMazi, father of Squeaks, Makrell, Kaiser Leonidas, Iskar, Neadal, Sheridan, Bercor and HigoChumbo, house of Siblesz

    Not everything that counts can be counted, and not everything that can be counted counts.

  2. #2

    Default Re: How to disable autoresolve for the player

    Why wouldn't you leave auto resolve to a player's preference? Unless it's some story telling mod where you need to railroad the player, I don't see the point.

  3. #3
    Aikanár's Avatar no vaseline
    Join Date
    Mar 2009
    Location
    Sanctuary
    Posts
    12,516
    Blog Entries
    3

    Default Re: How to disable autoresolve for the player

    The point is the possibility and how to achieve it.
    To what purpose this might be used is a different matter and up to the modders who might use it.


    Son of Louis Lux, brother of MaxMazi, father of Squeaks, Makrell, Kaiser Leonidas, Iskar, Neadal, Sheridan, Bercor and HigoChumbo, house of Siblesz

    Not everything that counts can be counted, and not everything that can be counted counts.

  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: How to disable autoresolve for the player

    Nice find!

    It actually works with the 'false' argument as well, making the long workaround obsolete, see docudemons:

    Identifier: restrict_autoresolve
    Parameters: [true|false]
    Description: Enable/disable battle autoresolve restriction
    Sample use: restrict_autoresolve true
    Class: RESTRICT_AUTORESOLVE










  5. #5
    Aikanár's Avatar no vaseline
    Join Date
    Mar 2009
    Location
    Sanctuary
    Posts
    12,516
    Blog Entries
    3

    Default Re: How to disable autoresolve for the player

    Yep, false enables autoresolve again
    One only needs such a workaround when you want to force the player to actually autoresolve.


    Son of Louis Lux, brother of MaxMazi, father of Squeaks, Makrell, Kaiser Leonidas, Iskar, Neadal, Sheridan, Bercor and HigoChumbo, house of Siblesz

    Not everything that counts can be counted, and not everything that can be counted counts.

  6. #6

    Default Re: How to disable autoresolve for the player

    I've written this script based on yours, it disables siege for the player. good fun. I think I'll compile a list of buttons and scrolls next week and post it here, as finding the right name for things is the hardest part of this feature. Thanks again
    edit:just saw they have the buttons listed in docudemons, I always do things the hard way.
    monitor_event ScrollOpened ScrollOpened siege_scroll
    and I_TurnNumber >= 1
    ;log always ;just for testing
    disable_cursor
    ui_flash_start siege_end_button
    campaign_wait 1
    select_ui_element siege_end_button
    simulate_mouse_click lclick_down
    select_ui_element siege_end_button
    simulate_mouse_click lclick_up
    enable_cursor
    end_monitor
    Last edited by alleycat; October 18, 2012 at 10:45 AM. Reason: spelling error

  7. #7
    Aikanár's Avatar no vaseline
    Join Date
    Mar 2009
    Location
    Sanctuary
    Posts
    12,516
    Blog Entries
    3

    Default Re: How to disable autoresolve for the player

    I'm glad that it's of use to you

    Enjoy modding


    Son of Louis Lux, brother of MaxMazi, father of Squeaks, Makrell, Kaiser Leonidas, Iskar, Neadal, Sheridan, Bercor and HigoChumbo, house of Siblesz

    Not everything that counts can be counted, and not everything that can be counted counts.

  8. #8
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: How to disable autoresolve for the player

    We used this script in 1648 - it basically disables the mouse\cursor when the prebattle interface comes up, in this case the hist_schlacht counter is set by scripted battles once you agree to fight them, so you can't flee either :

    Code:
        ;--- Keine Feigheit vor dem Feind ---
        declare_counter hist_schlacht
        monitor_event ScrollOpened ScrollOpened prebattle_scroll
            if I_CompareCounter hist_schlacht = 1
                campaign_wait 1
                disable_cursor
                ui_flash_start prebattle_fight_button
                campaign_wait 3
                select_ui_element prebattle_fight_button
                simulate_mouse_click lclick_down
                simulate_mouse_click lclick_up
            end_if
            enable_cursor
            set_counter hist_schlacht 0
            
        end_monitor










  9. #9
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: How to disable autoresolve for the player

    I have a problem with auto_win command. When I script slave army to attack player's settlement with auto_win the game shows prebattle window, to choose fight battle or autoresolve. And I want slave army to capture the city by auto_win. How can I solve this?

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  10. #10
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: How to disable autoresolve for the player

    You need to change this line in my script above for the auto resolve button and adjust it into your script:

    select_ui_element prebattle_fight_button
    to
    select_ui_element prebattle_auto_resolve_button


    Sample:
    Code:
        declare_counter auto_resolve_only
        monitor_event ....
            conditions for your slave attack
            set_counter auto_resolve_only 1
            other commands for your slave attack, eg spawn_army, attack
        end_monitor
    
       ;--- Battles are forced to auto resolve ---
        monitor_event ScrollOpened ScrollOpened prebattle_scroll
            if I_CompareCounter auto_resolve_only = 1
                campaign_wait 1
                disable_cursor
                ui_flash_start prebattle_auto_resolve_button
                campaign_wait 3
                select_ui_element prebattle_auto_resolve_button
                simulate_mouse_click lclick_down
                simulate_mouse_click lclick_up
            end_if
            enable_cursor
            set_counter auto_resolve_only 0
            
        end_monitor
    Last edited by Gigantus; August 03, 2014 at 10:19 AM.










  11. #11
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: How to disable autoresolve for the player

    This is the script
    Spoiler Alert, click show to read: 
    monitor_event FactionTurnStart FactionType slave
    and not I_IsFactionAIControlled hre
    and I_SettlementOwner Torrhens_Square hre
    if I_NumberUnitsInSettlement Torrhens_Square SpearMilitia = 1
    set_counter auto_resolve_only 1

    spawn_army
    faction slave
    character random_name, general, age 45, x 42, y 201, label oo1
    traits Brave 3 , GoodFighter 2
    unit SpearMilitia exp 0 armour 0 weapon_lvl 0
    unit SpearMilitia exp 0 armour 0 weapon_lvl 0
    unit SpearMilitia exp 0 armour 0 weapon_lvl 0
    unit SpearMilitia exp 0 armour 0 weapon_lvl 0
    end
    console_command auto_win attacker
    siege_settlement oo1, Torrhens_Square, attack
    end_if

    terminate_monitor
    end_monitor

    ;--- Battles are forced to auto resolve ---
    monitor_event ScrollOpened ScrollOpened prebattle_scroll
    if I_CompareCounter auto_resolve_only = 1
    campaign_wait 1
    disable_cursor
    ui_flash_start prebattle_auto_resolve_button
    campaign_wait 3
    select_ui_element prebattle_auto_resolve_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    end_if
    enable_cursor
    set_counter auto_resolve_only 0

    end_monitor


    Well, here is the log
    Spoiler Alert, click show to read: 
    00:07:41.250 [game.script] [error] Script execution error for <ui_flash_start>, at line 505, in mods/WindsOfWinter/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    ui_flash_start failed to find ui element 'prebattle_auto_resolve_button'

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  12. #12
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: How to disable autoresolve for the player

    Puzzling, both button entries are present in the EXE. I wonder if they need to be listed in a text file? Try replacing the auto_resolve with fight and then test if it gives an error message as well. It should force you to have a battle, but don't mind that - I just want to know if the old version works.

    Last edited by Gigantus; August 03, 2014 at 10:41 PM.










  13. #13
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: How to disable autoresolve for the player

    Well, fight button works correctly. Battle on battle map begins by the script.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  14. #14
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: How to disable autoresolve for the player

    Did you try to fight the battle? Did the attacker win? I wonder if the auto_win attacker command means that regardless what happens in a battle the attakcer always wins? Or does that only work with autoresolve?










  15. #15
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,760
    Blog Entries
    3

    Default Re: How to disable autoresolve for the player

    If my memory servers me, the script command auto_win attacker sets a flag so that the next auto resolved battle gets resolved in favour of the attacker's side.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  16. #16
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: How to disable autoresolve for the player

    Ah drat, any idea why the prebattle_auto_resolve_button isn't accepted? The prebattle_fight_button is fine. See post #12 for the HEX editor find.










  17. #17
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: How to disable autoresolve for the player

    Well, when I fight on battle map I got Victory message after pressing Start battle button, because rebel army has no siege equipment.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  18. #18
    Ego123's Avatar Tiro
    Join Date
    Oct 2011
    Location
    Linz, Austria & Sighetu Marmatiei, Romania
    Posts
    293

    Default Re: How to disable autoresolve for the player

    Very good script but in the naval battles i can chose only the windraw option,I don't get the autoresovle button,Is any way to fix that I want so bad to have this script in game I didn't autoresolve a battle from four yearsI'm a die-hard playerthis script fits perfect for my.

    for now all I added in campaign_script is restrict_autoresolve true

  19. #19
    Aikanár's Avatar no vaseline
    Join Date
    Mar 2009
    Location
    Sanctuary
    Posts
    12,516
    Blog Entries
    3

    Default Re: How to disable autoresolve for the player

    ^That is because there are nor "real" naval battles in M2K, all you have is autoresolve, hence why you are stuck with the withdraw option. You would have to enable autoresolve for naval battles with a monitor_event in the campaign_script.


    Son of Louis Lux, brother of MaxMazi, father of Squeaks, Makrell, Kaiser Leonidas, Iskar, Neadal, Sheridan, Bercor and HigoChumbo, house of Siblesz

    Not everything that counts can be counted, and not everything that can be counted counts.

  20. #20
    Ego123's Avatar Tiro
    Join Date
    Oct 2011
    Location
    Linz, Austria & Sighetu Marmatiei, Romania
    Posts
    293

    Default Re: How to disable autoresolve for the player

    I play this game from 5 years I know they are not real naval batlles.I just wanna find a solution to enable the autoresolve only for naval battles,could you recomand me a monitor_event specific for this?

Page 1 of 2 12 LastLast

Posting Permissions

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