#textdomain wesnoth-utbs

#! -- Count number of tents lost by player and fire defeat event when needed
#! -- Each tent lost to undead spawns a WC
#define DESTROY_TENT
    [event]
        name=capture
        first_time_only=no
        [filter]
            side=2,3,4
        [/filter]
        [terrain]
            x=$x1
            y=$y1
            terrain=Dd
        [/terrain]
        [if]
            [variable]
                name=unit.side
                equals=2
            [/variable]
            [or]
                [variable]
                    name=unit.side
                    equals=3
                [/variable]
            [/or]
            [then]
#ifdef HARD
                {UNIT_ (Soulless) () ("") $unit.side $x1 $y1}
#endif
#ifdef MEDIUM
                {RANDOM 0..100}
                [if]
                    [variable]
                        name=random
                        less_than=51
                    [/variable]
                    [then]
                        {UNIT_ (Walking Corpse) () ("") $unit.side $x1 $y1}
                    [/then]
                    [else]
                        {UNIT_ (Soulless) () ("") $unit.side $x1 $y1}
                    [/else]
                [/if]
#endif
#ifdef EASY
                {UNIT_ (Walking Corpse) () ("") $unit.side $x1 $y1}
#endif
                [if]
                    [variable]
                        name=elven_camps
                        equals=12
                    [/variable]
                    [then]
                        [message]
                            description=Nym
                            message= _ "They're raising the corpses of our fallen! What a horrible fate!"
                        [/message]
                        [message]
                            description=Elyssa
                            message= _ "Then we shall have to give them a proper cremation."
                        [/message]
                    [/then]
                [/if]
            [/then]
        [/if]
        [gold]
#ifdef EASY
            amount=10
#endif
#ifdef NORMAL
            amount=20
#endif
#ifdef HARD
            amount=30
#endif
            side=$unit.side
        [/gold]
        {VARIABLE_OP elven_camps add -1}
        [if]
            [variable]
                name=elven_camps
                equals=5
            [/variable]
            [then]
                [message]
                    description=Kaleh
                    message= _ "Too many of our people have been killed. We will surely be overwhelmed by the undead now. All is lost!"
                [/message]

                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]
        [/if]
    [/event]
#enddef
