Results 1 to 14 of 14

Thread: Forcing a battle to be autoresolved

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Forcing a battle to be autoresolved

    UPDATE: not possible it would seem. With disable_entire_ui, "entire" does not include UI elements on scrolls; it does not disable scrolls or their buttons, only the 'main' UI elements like turn end button and so forth. Therefore, presumably, disable_ui doesn't work on scroll buttons either.

    Does anybody know how to disable the prebattle scroll's "Fight" and (optionally) "Withdraw" buttons, thus forcing the player to use autoresolve?

    I have tried disable_ui commands on those buttons but nothing seems to work on that scroll. I also tried disabling the entire ui and then enabling just the autoresolve button.

    Thanks in advance.

    EDIT: To expand on what I have tried...

    Firstly, I found that the PreBattle scroll actually opens twice. Or at least that [monitor_event ScrollOpened ScrollOpened prebattle_scroll] triggers twice when armies clash.

    So my script looks like this:
    Code:
    set_event_counter pb_scroll_opened_count 0
    
    monitor_event ScrollOpened ScrollOpened prebattle_scroll
    
      inc_event_counter pb_scroll_opened_count 1
    
      if I_EventCounter pb_scroll_opened_count == 2
        ;historic_event nazgul
        disable_ui prebattle_fight_button
        set_event_counter pb_scroll_opened_count 0
      end_if
      
    end_monitor
    I thought that perhaps the double-triggering was somehow interfering with disable_ui so I have added a counter such that disable_ui will only be performed on the second opening.

    The historic_event is there to confirm that this part of the script is actually being reached. So yes: disable_ui is being invoked but it is doing nothing. Other buttons wouldn't disable either when I tried those instead. And the same behaviour if I remove all of my double-trigger handling code.

    Turning this monitor into a PreBattlePanelOpen one instead had the exact same behaviour: double-trigger and no effect.

    Oh, and I also tried simulating a click on the autoresolve instead of disabling the other buttons...

    Code:
    set_event_counter pb_scroll_opened_count 0
    
    monitor_event ScrollOpened ScrollOpened prebattle_scroll
    
      inc_event_counter pb_scroll_opened_count 1
    
      if I_EventCounter pb_scroll_opened_count == 2
        select_ui_element prebattle_auto_resolve_button
        simulate_mouse_click lclick_down
        simulate_mouse_click lclick_up
    
        set_event_counter pb_scroll_opened_count 0
      end_if
      
    end_monitor
    That did nothing also.

    This is in Kingdoms.
    Last edited by Withwnar; May 12, 2018 at 11:22 PM.

  2. #2
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Forcing a battle to be autoresolved

    Aha! Some success at least... this will get that second example working:

    A wait prior to the click simulation...

    Code:
    set_event_counter pb_scroll_opened_count 0
    
    monitor_event ScrollOpened ScrollOpened prebattle_scroll
    
      inc_event_counter pb_scroll_opened_count 1
    
      if I_EventCounter pb_scroll_opened_count == 2
        wait 0.1
        select_ui_element prebattle_auto_resolve_button
        simulate_mouse_click lclick_down
        simulate_mouse_click lclick_up
    
        set_event_counter pb_scroll_opened_count 0
      end_if
      
    end_monitor
    ...presumably to give the scroll time to open first*. No joy with using disable_ui here though, even with longer wait times.

    * It seems that this monitor triggers before the scroll is ready to receive select_ui_element and simulate_mouse_click operations.
    Last edited by Withwnar; May 30, 2011 at 02:54 AM.

  3. #3

    Default Re: Forcing a battle to be autoresolved

    This is an interesting idea and one I do not see that anyone has modded.

    My only question ... Why would you want to do just have auto-battle?
    You can drop humans anywhere and they'll thrive-only the rat does as well.Jeannette Desor

    Man in Black: [as he is unsuccessfully fighting Fezzik] Look, are you just fiddling around with me or what?
    Fezzik: I just want you to feel you're doing well. I hate for people to die embarrassed.

  4. #4
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Forcing a battle to be autoresolved

    A comrade said he thought he saw it done but couldn't remember where. The disabled Fight button I mean.

    Why? A settlement is going to be attacked by a creature (no battle model) and I'm trying to reduce troop numbers to simulate some being killed in the fight. Disasters were another option but they kill too much population.

    While I'm at it can anybody confirm that reduce_unit_strength doesn't work in Kingdoms battle script? I get hangs no matter what I try and some posts I have seen suggest that this is a known issue.

  5. #5
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Forcing a battle to be autoresolved

    I believe unit_label is only ever exported by battle events, so reduce_unit_strength can only be used in battles.

  6. #6
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Forcing a battle to be autoresolved

    Thanks, yes, I was referring to battles. (Not autoresolve.)

  7. #7
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Forcing a battle to be autoresolved

    If you like you can show the script you're using and I'll tell you if I think it looks like it should work.

  8. #8
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Forcing a battle to be autoresolved

    Thanks for the offer Taiji, good onya. I'm utterly new to battle scripting so this could be very wrong...

    Code:
    monitor_event BattleConflictPhaseCommenced TrueCondition
    
      label_unit 1 0 0 general
      label_unit 1 0 1 unit1
    
      reduce_unit_strength unit1 50    ;HANG!
      
    end_monitor
    These guys are the defenders and there are definitely two units in this army. unit1 is an infantry unit.

    I saw a post mentioning wrapping the reduce_unit_strength in an I_UnitFormation IF statement...

    Code:
      if I_UnitFormation unit1 = square 
        reduce_unit_strength unit1 50    ;HANG!
      end_if
    ... but I believe that that was to avoid calling reduce_unit_strength on a unit that does not exist, which the I_UnitFormation condition would safely catch and thus avoid. I tried it anyway but not really needed in my trial because I know that the unit exists. It didn't help.

  9. #9
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Forcing a battle to be autoresolved

    That looks OK to me, but I've never used that command. You could check the vanilla battle scripts to see if that command is used anywhere. Also maybe try sticking a little wait between the commands:

    label_unit 1 0 0 general
    label_unit 1 0 1 unit1
    battle_wait 0.1
    reduce_unit_strength unit1 50
    Last edited by Taiji; May 31, 2011 at 08:36 AM.

  10. #10
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Forcing a battle to be autoresolved

    Thanks mate, I'll try the waits and report back.

    I couldn't find any use of this command anywhere, including in the unpacked M2TW.

    That "known issue" I mentioned was from Alpaca's script-o-rama:
    Don't try anything with reduce_unit_strength. Unfortunately it freezes the game.
    The only usages I have found on the web are from RTW - presumably it worked fine there.

  11. #11
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Forcing a battle to be autoresolved

    Maybe he's right in suggesting he's already tried everything possible

    ... Maybe try applying the command during the deployment phase (BattleDeploymentPhaseCommenced)
    Last edited by Taiji; May 31, 2011 at 09:02 AM.

  12. #12
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Forcing a battle to be autoresolved

    No joy. I tried [battle_wait 1.0] prior to the reduce_unit_strength call. Then I tried moving the label_unit calls into BattleDeploymentPhaseCommenced, then both label_unit and reduce_unit_strength calls into BattleDeploymentPhaseCommenced. Hangs every time.

    Thanks very much Taiji, +rep sir. If this can be solved I'd love to hear it but I can do without it this time.

  13. #13
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Forcing a battle to be autoresolved

    While thrashing around I would try using the command with no unit specified, no percentage specified, and them appearing in the opposite order. But it's up to you, and you're welcome

  14. #14
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Forcing a battle to be autoresolved

    I gave it a quick try: "parsing error" in the log straight away.

    Well, while I'm speaking battle script I may as well mention some things I found along the way. They might be of use to other novice battle scripters...

    • terminate_battle crashes the campaign script. It took me a while to whittle down to this as being the culprit; then I found a post - and again by Alpaca! - saying the same thing. Oh well... "confirmed!".
    • ScrollClosed post_battle_scroll triggers BEFORE BattleConflictPhaseCommenced. ...what? ScrollOpened post_battle_scroll triggers AFTER BattleConflictPhaseCommenced, as expected.

Posting Permissions

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