Scenario event not working...

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
Lord-Knightmare
Discord Moderator
Posts: 2340
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Scenario event not working...

Post by Lord-Knightmare »

Hello, the following event does not work. I have tried it out a few times and every time I get to decimate the wolves (since, the macro does not cause the number of wolves to be infinite). Please help.

Code: Select all

[event]
      name="last breath"
      first_time_only=no

      [filter]
          side=3
      [/filter]
      
      {RANDOM 1...5}

      [switch]
            variable=random

            [case]
                value="1"
                
#ifdef EASY
                {GENERIC_UNIT 3 "Wolf" 1 34}
                {GENERIC_UNIT 3 "Wolf" 1 17}
#else
                {GENERIC_UNIT 3 "Wolf" 1 34}
                {GENERIC_UNIT 3 "Great Wolf" 1 17}
#endif
            [/case]

            [case]
                value="2"
#ifdef EASY                
                {GENERIC_UNIT 3 "Wolf" 26 5}
                {GENERIC_UNIT 3 "Wolf" 1 17}
#else
                {GENERIC_UNIT 3 "Great Wolf" 26 5}
                {GENERIC_UNIT 3 "Wolf" 1 17}
#endif
            [/case]

            [case]
                value="3"
                
#ifdef EASY
                {GENERIC_UNIT 3 "Great Wolf" 1 34}
                {GENERIC_UNIT 3 "Great Wolf" 26 5}
#else
                {GENERIC_UNIT 3 "Direwolf" 1 34}
                {GENERIC_UNIT 3 "Great Wolf" 26 5}
#endif
            [/case]

            [case]
                value="4"
                
#ifdef EASY
                {GENERIC_UNIT 3 "Great Wolf" 1 34}
                {GENERIC_UNIT 3 "Wolf" 26 5}
#else
                {GENERIC_UNIT 3 "Great Wolf" 1 34}
                {GENERIC_UNIT 3 "Great Wolf" 26 5}
#endif
            [/case]

            [case]
                value="5"
                
#ifdef EASY
                {GENERIC_UNIT 3 "Great Wolf" 26 5}
                {GENERIC_UNIT 3 "Wolf" 1 17}
#else
                {GENERIC_UNIT 3 "Great Wolf" 26 5}
                {GENERIC_UNIT 3 "Great Wolf" 1 17}
#endif
            [/case]
        [/switch]

        {CLEAR_VARIABLE random}
  [/event]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Scenario event not working...

Post by Dugi »

You could try to print the contents of the random variable to see what it contains. You would see that it contains nothing.

The issue is in the command for the generation of random numbers. To specify the range, write 1..5, not 1...5 , two dots are enough.

Also all of your quotation marks are unnecessary. You also have an unnecessary code duplicity in five cases, the first spawn didn't need to be defined once for easy difficulty and once for other difficulties when they are the same and can be written before the #ifdef (I don't care that it's ugly, the problem is that code duplicity increases the time needed for any maintenance).

Your event causes two side 3 wolves appear with every kill of a side 3 unit, so the number of wolves the player is facing will increase indefinitely, are you sure you wanted that?
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Scenario event not working...

Post by zookeeper »

Lord-Knightmare wrote:{RANDOM 1...5}
One period too many. :eng:
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2340
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Scenario event not working...

Post by Lord-Knightmare »

One period too many.
Thank you.
Your event causes two side 3 wolves appear with every kill of a side 3 unit, so the number of wolves the player is facing will increase indefinitely, are you sure you wanted that?
Yeah, that's what I wanted. I want to stop the player from thinking that the level is an opportunity to milk XP points for his/her units. However, the next level is kind of hard, so he/she should try to get veterans (while keeping in mind that the exponential increase in wolves is eventually bad for them).
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Horus2
Posts: 407
Joined: September 26th, 2010, 1:05 pm

Re: Scenario event not working...

Post by Horus2 »

Shameless thread thievery!

Normally i am all into experimenting with WML till i pass out, but the mapmaking contest makes finding the answer somewhat more urgent.

I tried to make a 2v2 multiplayer map with a new scenario objective. Nothing difficult i though; the goal is to reduce one of the opponents villages to 4 or less, from the fifth turn on. I made this so far:

Code: Select all

[objectives]
        side=0
        [objective]
            description= _ "One of your enemies controls less than 5 villages from turn 5"
            condition=win
        [/objective]
        [objective]
            description= _ "You or your ally control less than 5 villages from turn 5"
            condition=lose
        [/objective]
    [/objectives]

    [event]
        name=side turn end
        first_time_only=no
        [set_variable]
            name=currentvils
            value=[villages]
        [/set_variable]
        [if]
            [variable]
                name=currentvils
                less_than=5
            [/variable]
            [variable]
                name=turn_number
                greater_than=4
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    message=$currentvils|
                [/message]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]
        [/if]
    [/event]
I encountered two issues.

Obviously the value for the variable "currentvils" is a text now. If there is an easy way to import the status of the number of villages held by current player, i don't know about it. Probably can be done with events triggering at captures, but that is more time-consuming and i have no previous experiences with event tags, so i first i would like to hear whether there is a trivial method.
Secondly, the scenario objectives at the start is shown to be the usual defeating the enemy leader, but when opened from the menu, it shows my own mission objectives as it should. I am even more clueless about this one. What should i do to make it overwrite the default objective?

Thank you for your help!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Scenario event not working...

Post by zookeeper »

Horus2 wrote:Obviously the value for the variable "currentvils" is a text now. If there is an easy way to import the status of the number of villages held by current player, i don't know about it. Probably can be done with events triggering at captures, but that is more time-consuming and i have no previous experiences with event tags, so i first i would like to hear whether there is a trivial method.
Sure, just use [store_villages] to store all the villages owned by the current side:

Code: Select all

[event]
    name=side turn end
    first_time_only=no

    [store_villages]
        owner_side=$side_number
        variable=ownedvillages
    [/store_villages]

    [if]
        [variable]
            name=ownedvillages.length
            less_than=5
        [/variable]
        [then]
            # ...
Horus2 wrote:Secondly, the scenario objectives at the start is shown to be the usual defeating the enemy leader, but when opened from the menu, it shows my own mission objectives as it should. I am even more clueless about this one. What should i do to make it overwrite the default objective?
That's a bit weird and sounds like it's probably a bug, but it seems you can workaround it by putting your [objectives] in a prestart event.
Post Reply