Coding errors?

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.
Kingslayer
Posts: 46
Joined: October 5th, 2010, 9:42 am

Re: Coding errors?

Post by Kingslayer »

Code: Select all

#textdomain wesnoth-The_Founding_of_Elensefar

[scenario]
     id=01_Raiding_the_Outpost
     Name= _ "Raiding the Outpost"
     map_data="{~add-ons/The_Founding_of_Elensefar/maps/01_Raiding_the_Outpost.map}"
     {TURNS 28 24 22}
     Next_scenario=null
     {DEFAULT_SCHEDULE}
     {VICTORY_AND_DEFEAT_MUSIC}


     # If the prince sends units towards Cerdaec, it could be
     # impossible for him to gain experience.
     # A crude way to stop AI from crossing the river.
#define AVOID_FLANK_AID
     [avoid]
	x,y=15-17,11-22
     [/avoid]
#enddef

[side]
	type=Sergeant
        side=1
        controller=human
        team_name=1
        user_team_name= _ "Southbay"
	name= _ "Cerdaec"
	id=Cerdaec
        description=Cerdaec
        user_description=Cerdaec
        gender=male
        canrecruit=no
        unrenamable=true
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_QUICK}
        [/modifications]
	income=1
	gold=0
	[unit]
	   type=Spearman
	   x,y=9,13
           [modifications]
               {TRAIT_LOYAL}
	       {TRAIT_RESILIENT}
           [/modifications]
	[/unit]
[/side]




[side]
	side=2
	type=General
	id=Prince of Southbay
	name= _ "Prince of Southday"
	{GOLD 150 125 100}
	unrenamable=yes
	canrecruit=yes
	recruit=Swordsman,Longbowman,Dragoon,Red Mage,White Mage,Pikeman
	[ai]
	   recruitment_pattern=fighter,fighter,archer,mixed fighter,healer,scout
	   village_value=0.2
	   villages_per_scout=5
	{ATTACK_DEPTH 2 2 1}
	[/ai]
	team_name=1
	user_team_name= _ "Southbay"
	{AVOID_FLANK_AID}
[/side]

[side]
	side=3
	type=Bandit
	id=Haelyn
	name= _ "Haelyn"
	{GOLD 100 125 150}
	{INCOME 2 4 6}
	unrenamable=yes
	canrecruit=yes
	recruit=Thug,Poacher,Footpad,Thief
	team_name=2
	user_team_name= _ "Wesfolk"
	[ai]
	  recruitment_patter=fighter,archer,archer,scout
	{ATTACK_DEPTH 2 2 3}
	[/ai]
[/side]

[event]
	name=prestart

	[music]
	  name=vengeful.ogg
	  append=yes
	[/music]

[objectives]
	side=1
	[objective]
	  description= _ "Cerdaec gains fighting experience (levels up)"
	  condition=win
	[/objective]
	[objective]
	  description= _ "Defeat Wesfolk Leader"
	  condition=win
	[/objective]
	[objective]
	  description= _ "Death of Cerdaec"
	  condition=lose
	[/objective]
	[objective]
	  description= _ "Death of the Prince of Southbay"
	  condition=lose
	[/objective]
	[objective]
	  description= _ "Fail to have Cerdaec gain enough experience (does not level up)"
	condition=lose
	[/objective]
	[objective]
	  description= _ "Turns run out"
	  condition=lose
	[/objective]

	note={NEW_GOLD_CARRYOVER_NOTE_40}
[/objectives]
[/event]

[event]
	name=start
	[message]
	  speaker=Prince of Southbay
	  message= _ "Alright men, you have your orders. Kill these Wesfolk scum. Leave none alive!"
	[/message]
	[message]
	  speaker=Prince of Southbay
	  message= _ "You, over there! I want you to hold that side of the river, and try to wrap around them if you can. Understand?"
	[/message]
	[message]
	  speaker=Cerdaec
	  message= _ "Yes, sir! (I hope this is not a mistake...)"
	[/message]
	[message]
	  speaker=Prince of Southbay
	  message= _ "Charge!"
	[/message]
[/event]

[event]
	name=last breath
	[filter]
	   id=Cerdaec
	[/filter]
	[message]
	  speaker=Cerdaec
	  message= _ "My first...real battle. Ugh"
	[/message]
	[endlevel]
          result=defeat
	[/endlevel]
[/event]

[event]
	name=enemies defeated
	[if]
	[filter]
	id=Cerdaec
	[and]
	level=1
	[/and]
	[/filter]
	[then]
	[endlevel]
	  result=defeat
	[/endlevel]
	[/then]
	[else]
	[endlevel]
	  result=victory
	[/endlevel]
	[/else]
	[/if]
[/event]



[/scenario]
How can I make that last event work? I want it to be that if Cerdaec is level 1 you lose
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Coding errors?

Post by zookeeper »

Kingslayer wrote:How can I make that last event work? I want it to be that if Cerdaec is level 1 you lose
Take a look at what you're allowed to put inside [if]. Putting a [filter] tag there doesn't do anything.
Kingslayer
Posts: 46
Joined: October 5th, 2010, 9:42 am

Re: Coding errors?

Post by Kingslayer »

Right...so how should I do it? I have tried every combination of [haveunit]/[and] that I can think of...
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Coding errors?

Post by Max »

why not just look for examples in mainline scenarios?

get a decent text editor - e.g. NotePad++ which can search (recursively) in a folder (wesnoth/data) for all occurrences of a given text...

Code: Select all

[if]
	[have_unit]
		id=whatever
		level=1
	[/have_unit]
	[then]
		[message]
			speaker=whatever
			message= _ "you lost because..."
		[/message]
		[endlevel]
			result=defeat
		[/endlevel]
	[/then]
	[else]
		[endlevel]
			result=victory
		[/endlevel]
	[/else]
[/if]
probably needs victory_when_enemies_defeated=no set...
Kingslayer
Posts: 46
Joined: October 5th, 2010, 9:42 am

Re: Coding errors?

Post by Kingslayer »

I have victory_when_enemies_defeated=no, But I can't even get the
[event]
name=enemies defeated
[/event]
to trigger

Code: Select all

#textdomain wesnoth-The_Founding_of_Elensefar

[scenario]
     id=01_Raiding_the_Outpost
     Name= _ "Raiding the Outpost"
     map_data="{~add-

ons/The_Founding_of_Elensefar/maps/01_Raiding_the_Outpost.map}"
     {TURNS 28 24 22}
     Next_scenario=null
     {DEFAULT_SCHEDULE}
     {VICTORY_AND_DEFEAT_MUSIC}
     victory_when_enemies_defeated=no

     # If the prince sends units towards Cerdaec, it could be
     # impossible for him to gain experience.
     # A crude way to stop AI from crossing the river.
#define AVOID_FLANK_AID
     [avoid]
	x,y=15-17,11-22
     [/avoid]
#enddef

[side]
	type=Sergeant
        side=1
        controller=human
        team_name=1
        user_team_name= _ "Southbay"
	name= _ "Cerdaec"
	id=Cerdaec
        description=Cerdaec
        user_description=Cerdaec
        gender=male
        canrecruit=no
        unrenamable=true
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_QUICK}
        [/modifications]
	income=1
	gold=0
	[unit]
	   type=Spearman
	   x,y=9,13
           [modifications]
               {TRAIT_LOYAL}
	       {TRAIT_RESILIENT}
           [/modifications]
	[/unit]
[/side]




[side]
	side=2
	type=General
	id=Prince of Southbay
	name= _ "Prince of Southday"
	{GOLD 150 125 100}
	unrenamable=yes
	canrecruit=yes
	recruit=Swordsman,Longbowman,Dragoon,Red Mage,White 

Mage,Pikeman
	[ai]
	   recruitment_pattern=fighter,fighter,archer,mixed 

fighter,healer,scout
	   village_value=0.2
	   villages_per_scout=5
	{ATTACK_DEPTH 2 2 1}
	[/ai]
	team_name=1
	user_team_name= _ "Southbay"
	{AVOID_FLANK_AID}
[/side]

[side]
	side=3
	type=Bandit
	id=Haelyn
	name= _ "Haelyn"
	{GOLD 100 125 150}
	{INCOME 2 4 6}
	unrenamable=yes
	canrecruit=yes
	recruit=Thug,Poacher,Footpad,Thief
	team_name=2
	user_team_name= _ "Wesfolk"
	[ai]
	  recruitment_patter=fighter,archer,archer,scout
	{ATTACK_DEPTH 2 2 3}
	[/ai]
[/side]

[event]
	name=prestart

	[music]
	  name=vengeful.ogg
	  append=yes
	[/music]

[objectives]
	side=1
	[objective]
	  description= _ "Cerdaec gains fighting experience 

(levels up)"
	  condition=win
	[/objective]
	[objective]
	  description= _ "Defeat Wesfolk Leader"
	  condition=win
	[/objective]
	[objective]
	  description= _ "Death of Cerdaec"
	  condition=lose
	[/objective]
	[objective]
	  description= _ "Death of the Prince of Southbay"
	  condition=lose
	[/objective]
	[objective]
	  description= _ "Fail to have Cerdaec gain enough 

experience (does not level up)"
	condition=lose
	[/objective]
	[objective]
	  description= _ "Turns run out"
	  condition=lose
	[/objective]

	note={NEW_GOLD_CARRYOVER_NOTE_40}
[/objectives]
[/event]

[event]
	name=start
	[message]
	  speaker=Prince of Southbay
	  message= _ "Alright men, you have your orders. Kill 

these Wesfolk scum. Leave none alive!"
	[/message]
	[message]
	  speaker=Prince of Southbay
	  message= _ "You, over there! I want you to hold that 

side of the river, and try to wrap around them if you can. 

Understand?"
	[/message]
	[message]
	  speaker=Cerdaec
	  message= _ "Yes, sir! (I hope this is not a 

mistake...)"
	[/message]
	[message]
	  speaker=Prince of Southbay
	  message= _ "Charge!"
	[/message]
[/event]

[event]
	name=last breath
	[filter]
	   id=Cerdaec
	[/filter]
	[message]
	  speaker=Cerdaec
	  message= _ "My first...real battle. Ugh"
	[/message]
	[endlevel]
          result=defeat
	[/endlevel]
[/event]

[event]
	name=enemies defeated
	[if]
	   [have_unit]
	      id=Cerdaec
 	     level=1
 	   [/have_unit]
	   [then]
 	     [message]
 	        speaker=narrator
	         message= _ "More text here"
	      [/message]
	      [endlevel]
	         result=defeat
	      [/endlevel]
	   [/then]
	   [else]
 	     [endlevel]
    	     result=victory
   	    [/endlevel]
  	 [/else]
	[/if]
[/event]




[/scenario]
Post Reply