Counting event difficulties

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
Chefu
Posts: 23
Joined: February 4th, 2011, 5:37 pm

Counting event difficulties

Post by Chefu »

Hi all,
As some of you know, I am trying to revive the Orbivm project. So far, this has meant bugfixes for the Imperial Era and porting some campaigns 1.8. I am currently fixing up the campaign "Up from Slavery". I am having problems with a scenario where you have to kill a specific number of enemy units and I can't figure out how to fix it. Below is the code that seems to be the problem:

Code: Select all

    [event]
        name=die
        first_time_only=no
        [filter]
            side=2
        [/filter]
        [message]
                    id=Grarivus
                    message= _ "one more!"
                [/message]
        [set_variable]
            variable=units_slain
            add=1
        [/set_variable]
    [/event]
The event is firing because Gravirus says "one more!" every time I kill an enemy. However units_slain does not seem to get incremented. Using debug, I checked the current values of the variable and it is always 0 regardless of how many units I kill.

Thanks for any help :D

Note: if you need more code let me know. The campaign isn't on the addons server yet.
2nd note: This code is for Wesnoth 1.8 if that wasn't clear from above.
Current maintainer of the Orbivm project (as of February 2011)
Orbivm Forums
SigurdFireDragon
Developer
Posts: 546
Joined: January 12th, 2011, 2:18 am
Location: Pennsylvania, USA

Re: Counting event difficulties

Post by SigurdFireDragon »

Code: Select all

[set_variable]
     name=units_slain
     add=1
[/set_variable]
just a change of 'variable=units_slain' to 'name=units_slain' should do it.
Also you could use the macro VARIABLE_OP as follows instead of the above:
{VARIABLE_OP units_slain add 1}
Co-Author of Winds of Fate
My Add-ons: Random Campaign, Custom Campaign, Ultimate Random Maps, Era of Legends, Gui Debug Tools
Erfworld: The comic that lead me to find Wesnoth.
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Counting event difficulties

Post by Max »

here's something quite similar (HTTT, scenario 23):

Code: Select all

    [event]
        name=last breath
        first_time_only=no
        [filter]
            side=2,3,4,5
        [/filter]

        {VARIABLE_OP units_to_slay add -1}

        [if]
            [variable]
                name=units_to_slay
                numerical_equals=0
            [/variable]

            [then]
                [message]
                    speaker=Delfador
                    message= _ "We are routing their forces! Let's see if the Clan has had enough. Their help in guarding our flanks will be invaluable."
                [/message]
                {BONUS_VICTORY}
            [/then]
            [else]
                [print]
                    text= _ "Still $units_to_slay clan members to defeat!"
                    size=18
                    red,green,blue=255,255,255
                [/print]
            [/else]
        [/if]
    [/event]
i'd prefer [print] - it doesn't interrupt like [message] does...
User avatar
Chefu
Posts: 23
Joined: February 4th, 2011, 5:37 pm

Re: Counting event difficulties

Post by Chefu »

Thanks guys! It works now. Your ideas and suggestions have helped me clean up some of the logic for the scenario as well :)
Current maintainer of the Orbivm project (as of February 2011)
Orbivm Forums
Post Reply