Trouble comes again and hits hard

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
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Trouble comes again and hits hard

Post by toms »

Anyone has an idea what´s wrong?
It is very hard to find and the error just says "unknown scenario". :(

Please list every little thing, and especially typos, as I´d not find them for ages.

Thanks in advance to everyone who dares to seek in this mess. :P

Code: Select all

[scenario]
 id=game
 name=_"The game of Vrax"
 
 map_data=_"ssssssssssssssssssssssssssssssssssssssss
sssssssssssssssssssCssssssssssssssssssss
sssssfffffffffggggC2Cggggfffffffffssssss
sssgfffffffffffgggCRCgggfffffffffffgssss
sgggfffffffffffgwggRggwgfffffffffffgggss
sgggggffffffffggggwRwggggffffffffgggggss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCgggggRgggggogogogogrrrrgss
sggggggggggggggggggRggggggggggggggggggss
sgrrrrgCgCgCgCggngnRngnggogogogogrrrrgss
sggggggggggggggggggRngggggggggggggggggss
ssgggfgfgfgfgfggggC1Cggggfgfgfgfgfgggsss
ssssfffffffffffsg|CCC|gsfffffffffffsssss
sssssssssssssssss|s|s|ssssssssssssssssss"

 music="frantic.ogg"
 
 victory_when_enemies_defeated=no
 next_scenario=null
 turns=20
 
 {@campaigns/test/utils.cfg}
 
 [story]
  [part]
  story=_"Vrax started a 'Game of the rogues' with Tith. But not for only a victory: it was a game between life and death for Tith."
  [/part]
 [/story]

[side]
type=Thief
description=Tith
side=1
controller=human
canrecruit=0
recruit=
gold=100
team_name=players
[/side]
[side]
type=Lich
description=Vrax
side=2
controller=ai
canrecruit=0
recruit=
gold=100
team_name=players
 [ai] #this makes him quiet and let him stay
 aggression=-10
 village_value=-10
 caution=1.0
 passive_leader=yes
 [/ai]
[/side]
[side]
no_leader=yes
team_name=players
[/side]

##################################################################################################

#define CREATE_CHECKER TYPE SIDE X Y
[unit]
  side={SIDE}
  type={TYPE}
  x={X}
  y={Y}
  [status]
    stone=on
  [/status]
[/unit]
#enddef

#define LABEL X Y TEXT
[label]
x,y={X},{Y}
text={TEXT}
[/label]
#enddef

#define REPLACE_IF N
[if]
{VAR i numerical_equals ({N})}
 [then]
  [if]
  {VAR right_{N} not_equals 0}
   [then]
   {VARIABLE randunit ($right_{N})}
   [/then]
  [/if]
 [/then]
[/if]
#enddef

# *use:
#
# {VARIABLE tried[$i].(unit type) 1}

#define VAR_IF_FORMAT VAR EQ MAKE VALUE
[if]
{VAR ({VAR}) equals ({EQ})}
 [then]
  {VARIABLE_OP ({MAKE}) format ({VALUE})} #  *
 [/then]
[/if]
#enddef

#define AI_PLACE
{VARIABLE i 0}
{VARIABLE x 26}
#iterate over the play hexes
[while]
{VAR i less_than 5}
 [do]
  [while]
  {VAR have equals 0}
   [do]
    {VARIABLE i add 1}
   #this checks if a unit has already been tried
   #format the variable name for each type
    {VARIABLE_OP randunit random (Orcish Grunt,Elvish Fighter,Footpad,Skeleton,Fencer)}
    {VAR_IF_FORMAT randunit (Orcish Grunt) checktried (tried[$i].orc)}
    {VAR_IF_FORMAT randunit (Elvish Fighter) checktried (tried[$i].elf)}
    {VAR_IF_FORMAT randunit (Footpad) checktried (tried[$i].footpad)}
    {VAR_IF_FORMAT randunit (Skeleton) checktried (tried[$i].skel)}
    {VAR_IF_FORMAT randunit (Fencer) checktried (tried[$i].fencer)}
    [if]
    {VAR $checktried numerical_equals 0} #variable name already formatted. Yea.
     [then]
     {VARIABLE have 1}
     [/then]
     [else]
     {RANDOM 0..3}
      [if]
      {VAR random numerical_equals 0}
       [then]
       {VARIABLE have 1}
       [/then]
      [/if]
     [/else]
    [/if]
   [/do]
  [/while]
  {VARIABLE $checktried 1}
  {VARIABLE_OP x add 2}
  #this replaces the random unit if the ai has already found the right
  {REPLACE_IF 1}
  {REPLACE_IF 2}
  {REPLACE_IF 3}
  {REPLACE_IF 4}
  #this stores the unit type for the field
  {VARIABLE_OP type format $i|_type_2}
  {VARIABLE $type $randunit}
  #creates the figure if it's not the first turn where just the code is set
  [if]
  {VAR turn numerical_equals 1}
   [else]
   {CREATE_CHECKER $randunit 2 $x_2 $y_2}
   [/else]
  [/if]
 [/do]
[/while]
{AI_CHECK}
{CLEAR_VARIABLE type}
{CLEAR_VARIABLE i}
{CLEAR_VARIABLE randunit}
#enddef

# need a workaround for the double dollar sign. (variable name is already a variable)

#define GETTYPE VAR N SIDE
[if]
{VAR i numerical_equals ({N})}
 [then]
  {VARIABLE ({VAR}) ({N}_type_{SIDE})}
 [/then]
[/if]
#enddef

#define AI_CHECK
{VARIABLE i 0}
{VARIABLE x_2 34}
[while]
{VAR i less_than 5}
 [do]
  {VARIABLE_OP i add 1}
  {VARIABLE_OP x_2 add 2}
  {GETTYPE type 1 1}
  {GETTYPE type 2 1}
  {GETTYPE type 3 1}
  {GETTYPE type 4 1}
  {GETTYPE type_2 1 2}
  {GETTYPE type_2 2 2}
  {GETTYPE type_2 3 2}
  {GETTYPE type_2 4 2}
  [if]
  {VAR $type equals $type_2}
   [then]
    {VARIABLE_OP right format (right_|$i)}
    {VARIABLE $right $type}
    {VARIABLE_OP check format $i|_check}  #store the right type for field
    {VARIABLE $check 1}
    {PLACE_IMAGE misc/dot.png $x_2 $y_2}
   [/then]
   [else]
   #image
   [/else]
  [/if]
 [/do]
[/while]
[if]
{VAR 1_check numerical_equals 0}
 [or]
 {VAR 2_check numerical_equals 0}
 [/or]
 [or]
 {VAR 3_check numerical_equals 0}
 [/or]
 [or]
 {VAR 4_check numerical_equals 0}
 [/or]
 [else]
 [message]
 description=Vrax
 message=_"This was your last game, Tith."
 [/message]
 [endlevel]
 result=defeat
 [/endlevel]
 [/else]
[/if]
#enddef

#define HUMAN_CHECK
{VARIABLE i 0}
{VARIABLE x_1 4}
[while]
{VAR i less_than 5}
 [do]
  {VARIABLE_OP i add 1}
  {VARIABLE_OP x_1 add 2}
  {GETTYPE type 1 1}
  {GETTYPE type 2 1}
  {GETTYPE type 3 1}
  {GETTYPE type 4 1}
  {GETTYPE type_2 1 2}
  {GETTYPE type_2 2 2}
  {GETTYPE type_2 3 2}
  {GETTYPE type_2 4 2}
  [if]
  {VAR $type equals $type_2}
   [then]
    {VARIABLE_OP right format (right_|$i)}
    {VARIABLE $right $type}
    {VARIABLE_OP check format $i|_check}  #store the right type for field
    {VARIABLE $check 1}
    {PLACE_IMAGE misc/dot.png $x_1 $y_1}
   [/then]
   [else]
   #image
   [/else]
  [/if]
 [/do]
[/while]
[if]
{VAR 1_check numerical_equals 0}
 [or]
 {VAR 2_check numerical_equals 0}
 [/or]
 [or]
 {VAR 3_check numerical_equals 0}
 [/or]
 [or]
 {VAR 4_check numerical_equals 0}
 [/or]
 [else]
 [message]
 description=Tith
 message=_"You have lost."
 [/message]
 [kill]
 animate=yes
  [filter]
  description=Vrax
  [/filter]
 [/kill]
 [endlevel]
 result=defeat
 [/endlevel]
 [/else]
[/if]
#enddef

#define HUMAN_PLACE NUMBER X Y PLACE_X PLACE_Y
[event]
name=moveto
 [filter]
 side=1
 x,y={X},{Y}
 [/filter]
 [message]
 speaker=Tith
 message=_"I want to place..."
  [option]
  message=_"...an Orcish Grunt"
   [command]
    {VARIABLE place (Orcish Grunt)}
   [/command]
  [/option]
  [option]
  message=_"...an Elvish Fighter"
   [command]
    {VARIABLE place (Elvish Fighter)}
   [/command]
  [/option]
  [option]
  message=_"...a Footpad"
   [command]
    {VARIABLE place Footpad}
   [/command]
  [/option]
  [option]
  message=_"...a Skeleton"
   [command]
    {VARIABLE place Skeleton}
   [/command]
  [/option]
  [option]
  message=_"...a Fencer"
   [command]
    {VARIABLE place Fencer}
   [/command]
  [/option]
 [/message]
 [teleport]
 x,y=20,38
  [filter]
  description=Tith
  [/filter]
 [/teleport]
 [if]
 {VAR turn numerical_equals 1}
  [then]
   {VAR ({NUMBER}_type_1) $place}
    {CREATE_CHECKER $place 1 ({X}) ({Y})}
  [/then]
  [else]
   {CREATE_CHECKER $place 1 ({PLACE_X}) ({PLACE_Y})}
  [/else]
 [/if]
 {VARIABLE_OP moves add -1}
[/event]
#enddef  

# -------------------------------------------------------------------------------------------

[event]
name=prestart
{VARIABLE turn 0}
{VARIABLE side 0}
 [objectives]
  [objective]
  description=_"Win the Game of Rogues against Vrax"
  condition=win
  [/objective]
  [objective]
  description=_"You lose the game or it is a draw."
  condition=lose
  [/objective]
 [/objectives]
 #LABELS!!
[/event]

[event]
name=start
 {LABEL 17 36 ("1")}
 {LABEL 19 36 ("2")}
 {LABEL 21 36 ("3")}
 {LABEL 23 36 ("4")}
 [message]
 description=Vrax
 message=_"Good luck. You will need it."
 [/message]
 [message]
 description=Tith
 message=_"You don't know which enemy you are challenging. And you can lose too."
 [/message]
 {AI_PLACE} #generates code only
 {VARIABLE y_1 36}
 {VARIABLE y_2 6}  #he actually starts at 8 but he already adds 2 to y in the first turn
[/event]

#some things are necessary to set on beginning of every turn
[event]
name=side turn
{VARIABLE_OP sideturn add 1}
{VARIABLE_OP turn add 1}
[if]
{VAR sideturn numerical_equals 3}
 [then]
 {VARIABLE sideturn 1}
 {VARIABLE_OP y_1 add -2}
 [/then]
 [else]
 {VARIABLE_OP y_2 add 2} 
 [/else]
[/if]
#ai plays if the human player has moved everywhere
[if]
{VAR turn numerical_equals 2}
 [then]
  [if]
  {VAR moves greater_than 0}
   [then]
    [message]
    description=Vrax
    message=_"It's still your turn, Tith."
    [/message]
   [/then]
   [else]
   {HUMAN_CHECK}
   {AI_PLACE}
   [/else]
 [/then]
[/event]


{HUMAN_PLACE 17 36 8 $y_1}
{HUMAN_PLACE 19 36 10 $y_1}
{HUMAN_PLACE 21 36 12 $y_1}
{HUMAN_PLACE 23 36 14 $y_1}

[/scenario]
First read, then think. Read again, think again. And then post!
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

If it says "unknown scenario" perhaps the scenario is in the wrong place or there is a typo in your campaign .cfg ?
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I checked the campaign file and I couldn´t find anything. :/
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

After the really basic errors (files in wrong place or not included, typos in id's etc) it's usually a case of using macros while giving them the wrong number of arguments. It's probably fastest to cut away pieces of code and see when it stops to give errors. Then you have the part where the error most likely is, and you can go through that checking for every detail.

Also, you seem to use at least AI_CHECK before it is defined. That shouldn't cause visible errors, but worth noting anyway.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Thank you. I got it already working with all macros cut out. Then I´ve put some in again and it still worked. After putting all in, this suddenly caused errors:

Code: Select all

[if]      <-computer says this if is not closed
 {VAR turn numerical_equals 2}
  [then]
   [if]
   {VAR moves greater_than 0}
    [then]
     [message]
     description=Vrax
     message=_"It's still your turn, Tith."
     [/message]
    [/then]
    [else]
   # {HUMAN_CHECK}
   # {AI_PLACE}
    [/else]
   [/if]
  [/then]
 [/if]
[/event]
First read, then think. Read again, think again. And then post!
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Ok.

The part below causes the error shown by the previous post.

Code: Select all


#define HUMAN_PLACE NUMBER X Y PLACE_X PLACE_Y
[event]
name=moveto
 [filter]
 side=1
 x,y={X},{Y}
 [/filter]
 [message]
 speaker=Tith
 message=_"I want to place..."
  [option]
  message=_"...an Orcish Grunt"
   [command]
    {VARIABLE place (Orcish Grunt)}
   [/command]
  [/option]
  [option]
  message=_"...an Elvish Fighter"
   [command]
    {VARIABLE place (Elvish Fighter)}
   [/command]
  [/option]
  [option]
  message=_"...a Footpad"
   [command]
    {VARIABLE place Footpad}
   [/command]
  [/option]
  [option]
  message=_"...a Skeleton"
   [command]
    {VARIABLE place Skeleton}
   [/command]
  [/option]
  [option]
  message=_"...a Fencer"
   [command]
    {VARIABLE place Fencer}
   [/command]
  [/option]
 [/message]
 [teleport]
 x,y=20,38
  [filter]
  description=Tith
  [/filter]
 [/teleport]
 [if]
 {VAR turn numerical_equals 1}
  [then]
   {VAR ({NUMBER}_type_1) $place}
    {CREATE_CHECKER $place 1 ({X}) ({Y})}
  [/then]
  [else]
   {CREATE_CHECKER $place 1 ({PLACE_X}) ({PLACE_Y})}
  [/else]
 [/if]
 {VARIABLE_OP moves add -1}
[/event]
#enddef  
Does this help?
First read, then think. Read again, think again. And then post!
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

No, that works now. Now there are just errors where I find the reason earlier or later.


Current problem:

What can be the reason why [variable] works and the macro {VAR NAME OP ARG} not? Only in some parts of the file it does not, and the macro is right.
First read, then think. Read again, think again. And then post!
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Nobody wants to help me? :( Or does just nobody know?

I managed to fix the other stuff on my own, but here I got my serious crisis:

Code: Select all

#define AI_PLACE
{VARIABLE i 0}
{VARIABLE x 26}
#iterate over the play hexes
[while]
[variable]
name=i
less_than=5
[/variable]
 [do]
 #loop for finding a unit that has not been tried
  [while]
  {VAR have numerical_equals equals 0}
   [do]
    {VARIABLE i add 1}
   #this checks if a unit has already been tried
   #format the variable name for each type
    {VARIABLE_OP randunit random (Orcish Grunt,Elvish Fighter,Footpad,Skeleton,Fencer)}
    {VAR_IF_FORMAT randunit (Orcish Grunt) checktried (tried[$i].orc)}
    {VAR_IF_FORMAT randunit (Elvish Fighter) checktried (tried[$i].elf)}
    {VAR_IF_FORMAT randunit (Footpad) checktried (tried[$i].footpad)}
    {VAR_IF_FORMAT randunit (Skeleton) checktried (tried[$i].skel)}
    {VAR_IF_FORMAT randunit (Fencer) checktried (tried[$i].fencer)}
    [if]
    [variable]
    name=$checktried  #variable name already formatted. Yea.
    numerical_equals=0
    [/variable]
     [then]
     {VARIABLE have 1}
     [/then]
     [else]    #low chance to mistake
     ##ifdef EASY
     #{RANDOM 0..3}
     ##else
     {RANDOM 0..4}
     ##endif
      [if]
      {VAR random numerical_equals 0}
       [then]
       {VARIABLE have 1}
       [/then]
      [/if]
     [/else]
    [/if]
   [/do]
  [/while]
  {VARIABLE $checktried 1}
  {VARIABLE_OP x add 2}
  #this replaces the random unit if the ai has already found the right
  {REPLACE_IF 1}
  {REPLACE_IF 2}
  {REPLACE_IF 3}
  {REPLACE_IF 4}
  #this stores the unit type for the field
  {VARIABLE_OP type format ($i|_type_2)}
  {VARIABLE $type $randunit}
  #creates the figure if it's not the first turn where just the code is set
  [if]
  {VAR turn numerical_equals 1}
   [else]
   {CREATE_CHECKER $randunit 2 $x_2 $y_2}
   [/else]
  [/if]
 [/do]
[/while]
{AI_CHECK}
{CLEAR_VARIABLE type}
{CLEAR_VARIABLE i}
{CLEAR_VARIABLE randunit}
#enddef
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

It's quite frankly a bit difficult considering the amount of unfamiliar macros you're using. Some seem to be defined earlier in the thread, but it's still quite tedious to start expanding all of that in one's head...if you'll isolate the problem as much as you can and also tell whether that causes an error or if it just doesn't work as it should (and if so, how should it work?), I can have a look at it tonight (5-6 hours from now).
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Well. I tried to cut some pieces out.
But always somewhere else appeared a "bug" and nothing was wrong. It had all to do with variables. ( [/set_variable] missing)

I suspect, no I fear it´s a typo hiding somewhere...
First read, then think. Read again, think again. And then post!
User avatar
Ranger M
Art Contributor
Posts: 1965
Joined: December 8th, 2005, 9:13 pm
Location: England

Post by Ranger M »

My suggestion:

Save another copy somewhere, and then strip the in game one down to the basics, that works, and then add bits of the code to it untill it breaks, and check that section.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

toms wrote:Well. I tried to cut some pieces out.
But always somewhere else appeared a "bug" and nothing was wrong. It had all to do with variables. ( [/set_variable] missing)

I suspect, no I fear it´s a typo hiding somewhere...
I bet it's a case of a wrong number of arguments being given to a macro, a macro missing the ending } or some other pretty similar typo. It's usually the case when an error is reported on an ok part of the WML and when that is removed, the error (usually a missing end tag error, like you said) appears somewhere else...
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I have found one: {VARIABLE i add 1} should use VARIABLE_OP. That´s fixed now, but there is still a problem. With experiments of outcutting parts, I figured out that the following part causes the problem (in unkwon relation)

Code: Select all

[while]
  {VAR have numerical_equals equals 0}
   [do]
     #this checks if a unit has already been tried
     #format the variable name for each type
    {VARIABLE_OP randunit random (Orcish Grunt,Elvish Fighter,Footpad,Skeleton,Fencer)}
    {VAR_IF_FORMAT randunit (Orcish Grunt) checktried (tried[$i].orc)}
    {VAR_IF_FORMAT randunit (Elvish Fighter) checktried (tried[$i].elf)}
    {VAR_IF_FORMAT randunit (Footpad) checktried (tried[$i].footpad)}
    {VAR_IF_FORMAT randunit (Skeleton) checktried (tried[$i].skel)}
    {VAR_IF_FORMAT randunit (Fencer) checktried (tried[$i].fencer)}
    [if]
    [variable]
    name=$checktried  #variable name already formatted. Yea.
    numerical_equals=0
    [/variable]
     [then]
     {VARIABLE have 1}
     [/then] 
      [else]    #low chance to mistake
       ##ifdef EASY
       #{RANDOM 0..3}
       ##else
      {RANDOM 0..4}
       ##endif
      [if]
      {VAR random numerical_equals 0}
       [then]
       {VARIABLE have 1}
       [/then]
      [/if]
     [/else]
    [/if]
   [/do]
  [/while]
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Code: Select all

{VAR have numerical_equals equals 0}
This looks a bit suspicious.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

zookeeper wrote:

Code: Select all

{VAR have numerical_equals equals 0}
This looks a bit suspicious.
Whooops, why did I not realize that earlier? :oops: Although that´s a funny one. :D
First read, then think. Read again, think again. And then post!
Post Reply