objectives

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
Limabean
Posts: 369
Joined: August 26th, 2008, 2:14 pm
Location: New Hampshire, USA

objectives

Post by Limabean »

In a multiplayer scenario i'm working on, I need to change the objectives. I want to give the players two ways to win:
1. survive until turn 54.
2. defeat enemy leaders and survive until turn 42.

Here is my code:

Code: Select all

[event]
name=prestart

[objectives]
[objective]
description=Survive until turn 54 or defeat all enemy leaders and survive until turn 42.
condition=win
[/objective]
[objective]
description=Death of your leader
condition=lose
[/objective]
[/objectives]
[/event]

My objectives do appear in the "scenario Objectives" whenever I check them, but the game doesn't recognize them. It still just ends the game when you "Defeat all enemy leaders", the default objective. Is there some extra code I need to use to get the game to recognize my objectives?

sorry if this is a newbie question, but it wasn't on the wiki page I was using:
http://www.wesnoth.org/wiki/InterfaceActionsWML
User avatar
A Guy
Posts: 793
Joined: May 24th, 2008, 1:55 am

Re: objectives

Post by A Guy »

You need to put victory_when_enemies_defeated=no inside the [multiplayer] tag.
I'm just... a guy...
I'm back for now, I might get started on some work again.
User avatar
Limabean
Posts: 369
Joined: August 26th, 2008, 2:14 pm
Location: New Hampshire, USA

Re: objectives

Post by Limabean »

thanks, I think that works now
sid6.7
Posts: 161
Joined: July 11th, 2006, 4:09 am
Location: USA
Contact:

Re: objectives

Post by sid6.7 »

for each [objective]

you need an [event] with an [endlevel] telling the game specifically what you want to do when each event occurs..

for a game ending with a death you need a die event.
for a game ending with a survive till 42 turns are up you need a turn event.

i think those are in the wiki go back and check...
User avatar
Limabean
Posts: 369
Joined: August 26th, 2008, 2:14 pm
Location: New Hampshire, USA

Re: objectives

Post by Limabean »

hmmm, I checked endlevel and objectives in the WML Reference, but I can't find anywhere where the details are spelled out for me.

Is this kind of like what you're talking about?

Code: Select all

[objective]
description=Survive until turn 54
condition=win
[event]
name=turn 54
[endlevel]
result=victory
[/endlevel]
[/event]
[/objective]
sorry if this is obvious, i'm a noob when it comes to WML.

Also, how would I make an objective that has two requirements for victory, like "defeat enemy leaders and survive until turn 42"?
User avatar
A Guy
Posts: 793
Joined: May 24th, 2008, 1:55 am

Re: objectives

Post by A Guy »

You could do something like this.

Code: Select all

[objectives]
<insert crap here>
[/objectives]

[event]
   name=start
   [set_variable]
      name=turn_limit
      value=54
   [/set_variable]
[/event]

[event]
   name=turn refresh
   first_time_only=no
   [if]
      [not]
         [have_unit]
            canrecruit=yes
            side=<insert sides here>
         [/have_unit]
      [/not]
      [then]
         [set_variable]
            name=turn_limit
            value=42
         [/set_variable]
      [/then]
   [/if]
[/event]

[event]
   name=turn $turn_limit
   [message]
      speaker=narrator
      message= _ "Congratulations, you've survived, yadda yadda yadda..."
   [/message]
   [endlevel]
      result=victory
   [/endlevel]
[/event]
God help me if there's an error in there.
I'm just... a guy...
I'm back for now, I might get started on some work again.
User avatar
Jequ
Posts: 196
Joined: February 18th, 2008, 1:28 pm

Re: objectives

Post by Jequ »

Why not just:

[objectives]
[objective]
description="put the message to the player about what you need to win the scenario here"
condition=win
[/objective]
[/objectives]

[event]
turn=54
[endlevel]
result=victory
[/endlevel]
[/event]
opensourcejunkie
Posts: 547
Joined: August 11th, 2008, 3:19 pm

Re: objectives

Post by opensourcejunkie »

[objective]
description=Survive until turn 54
condition=win
[event]
name=turn 54
[endlevel]
result=victory
[/endlevel]
[/event]
[/objective]
This code won't work because [event]s cannot be placed inside of [objective] tags. I think it's important to note here that the [objectives][/objectives] tags are used simply to convey the scenario goals to the user, not to actually code those win/lose conditions into the scenario. So, as Jequ and A Guy pointed out, the [event] tags that check for the win/lose conditions are a completely separate entity.
what if the Bible's claims about Christ depicted accurate, verifiable history? given some research, you might be surprised at the evidence...
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: objectives

Post by AI »

A Guy wrote:God help me if there's an error in there.
There is :P

You can't use $variables inside event names, so do this instead:

Code: Select all

[objectives]
<insert crap here>
[/objectives]

[event]
   name=prestart
   [modify_turns]
      value=54
   [/modify_turns]
[/event]

[event]
   name=die
   first_time_only=no
   [filter]
      canrecruit=yes
   [/filter]
   [if]
      [not]
         [have_unit]
            canrecruit=yes
            side=<insert sides here>
         [/have_unit]
      [/not]
      [then]
         [modify_turns]
            value=42
         [/modify_turns]
      [/then]
   [/if]
[/event]

[event]
   name=time over
   [message]
      speaker=narrator
      message= _ "Congratulations, you've survived, yadda yadda yadda..."
   [/message]
   [endlevel]
      result=victory
   [/endlevel]
[/event]
sid6.7
Posts: 161
Joined: July 11th, 2006, 4:09 am
Location: USA
Contact:

Re: objectives

Post by sid6.7 »

Limabean wrote:hmmm, I checked endlevel and objectives in the WML Reference, but I can't find anywhere where the details are spelled out for me.

Is this kind of like what you're talking about?

Code: Select all

[objective]
description=Survive until turn 54
condition=win
[event]
name=turn 54
[endlevel]
result=victory
[/endlevel]
[/event]
[/objective]
sorry if this is obvious, i'm a noob when it comes to WML.

Also, how would I make an objective that has two requirements for victory, like "defeat enemy leaders and survive until turn 42"?
the event goes outside the [objective] tags

as far as i know..objectives are single issue only
i've not seen a double [event] that can include both as the condition of victory
unless of course thats now allowed in version 1.5.x
User avatar
Limabean
Posts: 369
Joined: August 26th, 2008, 2:14 pm
Location: New Hampshire, USA

Re: objectives

Post by Limabean »

AI wrote:
A Guy wrote:God help me if there's an error in there.
There is :P

You can't use $variables inside event names, so do this instead:

Code: Select all

[objectives]
<insert crap here>
[/objectives]

[event]
   name=prestart
   [modify_turns]
      value=54
   [/modify_turns]
[/event]

[event]
   name=die
   first_time_only=no
   [filter]
      canrecruit=yes
   [/filter]
   [if]
      [not]
         [have_unit]
            canrecruit=yes
            side=<insert sides here>
         [/have_unit]
      [/not]
      [then]
         [modify_turns]
            value=42
         [/modify_turns]
      [/then]
   [/if]
[/event]

[event]
   name=time over
   [message]
      speaker=narrator
      message= _ "Congratulations, you've survived, yadda yadda yadda..."
   [/message]
   [endlevel]
      result=victory
   [/endlevel]
[/event]
Thanks everyone, that seems to work, but I admit I have no idea what most of that code actually does. :wink:
User avatar
A Guy
Posts: 793
Joined: May 24th, 2008, 1:55 am

Re: objectives

Post by A Guy »

Okay, allow me to explain.

We want to set a turn at which you will win. We want this to be able to change. Since we can change variables mid-game, we will use a variable. We need to set the variable, so we will do that in the start.

We want the variable to change when both leaders die, so we will set a condition. We want the game to keep checking for whether both leaders are dead, so we will use the turn refresh event. We want the game to repeatedly check, so we need to set first_time_only=no in order to make the event repeat. Now, if the game does not find any leader belonging to the sides specified in the filter, then the variable (turn_limit) will be changed.

We need to specify that we want the value of a variable to be used, so we use the $ sign (meaning that the game should use the value of the variable, instead of using the name). So the game will make the event happen on the turn that is in the variable.

Only one flaw I noticed... If both leaders die after turn 42, then the game cannot be won. To counter this, you can do something like...

Code: Select all

[event]
   name=time over
   [endlevel]
      result=victory
   [/endlevel]
[/event]
So you'll still win even if both leaders die after turn 42.
I'm just... a guy...
I'm back for now, I might get started on some work again.
Post Reply