Auto End Turn Event

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
ancestral
Inactive Developer
Posts: 1108
Joined: August 1st, 2006, 5:29 am
Location: Motion City

Auto End Turn Event

Post by ancestral »

To me, it seems Wesnoth should be smart enough to know when my turn is done. Like, when my units don’t have any moves left.

So, I present to you, an auto end turn event. (Note… this is especially handy in many multiplayer scenarios.)

The event ends the turn if any units on the current side have no movement and cannot make any attacks. It’s designed to end a turn when it’s assumed there are no more moves to take. (If there are valid moves, then it’s still up to you to tell the game when you want to end your turn!) It also won’t allow undo on the last move.

I’d like to add recall and recruit support by checking the recall list, and if the current side’s leader is on a keep and can afford any units. I’d also like to add support for units who have a few moves but not enough to move to a new tile. (If you can think of any other cases where, in a standard game, you’d choose not end your turn right away, let me know.)

Code: Select all

[event]
  name=moveto,attack end
  first_time_only=no
  [filter_condition]
  [not]
    [have_unit]
      side=$side_number
      [and]
        [not]
          [filter_wml]
            moves=0
          [/filter_wml]
        [/not]
        [or]
          [filter_adjacent]
            is_enemy=yes
          [/filter_adjacent]
          [not]
            [filter_wml]
              attacks_left=0
            [/filter_wml]
          [/not]
        [/or]
      [/and]
    [/have_unit]
  [/not]
  [/filter_condition]
  [end_turn]
  [/end_turn]
[/event]
Wesnoth BestiaryPREVIEW IT HERE )
Unit tree and stat browser
CanvasPREVIEW IT HERE )
Exp. map viewer
User avatar
Ravana
Forum Moderator
Posts: 3317
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Auto End Turn Event

Post by Ravana »

Turn time limit is for that..
User avatar
artisticdude
Moderator Emeritus
Posts: 2424
Joined: December 15th, 2009, 12:37 pm
Location: Somewhere in the middle of everything

Re: Auto End Turn Event

Post by artisticdude »

8)
Ravana wrote:Turn time limit is for that..
In MP, yes, but In SP campaigns there is no timer. :wink:
"I'm never wrong. One time I thought I was wrong, but I was mistaken."
Jozrael
Posts: 1035
Joined: June 2nd, 2006, 1:39 pm
Location: NJ, USA.

Re: Auto End Turn Event

Post by Jozrael »

What if I recruit last :o?
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Auto End Turn Event

Post by Max »

i guess you'd have to check the undo stack as well which i'm pretty sure you'd need engine support for this...
User avatar
Boldek
Posts: 576
Joined: April 14th, 2011, 6:37 pm

Re: Auto End Turn Event

Post by Boldek »

The real problem (for me) is that a big part about wesnoth, or SP and hotseat any way, is that it's alot about thinking. What happens if the player wants to undo, or is chatting advice to the player after him? Methinks a lot more problems will arise from having the turns timed than it appears. Yeah, this cleans up the "Where the dickens has Boldek gone to? is he AFK?" chats, I think the timer does it best.
Guys I never thought I'd come back to this forum after 8 years this is wild
Post Reply