#textdomain wesnoth
[binary_path]
    path=data/campaigns/Under_the_Burning_Suns
[/binary_path]
[binary_path]
    path=data/campaigns/The_Rise_Of_Wesnoth
[/binary_path]
[+units]
#ifhave campaigns/Under_the_Burning_Suns/units/units.cfg
    {campaigns/Under_the_Burning_Suns/utils/kaleh-abilities.cfg}
    {campaigns/Under_the_Burning_Suns/units/units.cfg}
    {campaigns/Under_the_Burning_Suns/units/elves/Kaleh.cfg}
#endif
[/units]
[test]
    name="Test scenario"
    map_data="Mm, Mm, Mm, Mm, Mm^Xm, Mm^Xm, Mm^Xm, Gg, Ww, Gg, Dd, Gg, Aa, Gg, Aa, Gg, Hh, Gg, Mm, Gg, Uu, Gg, Wo, Wo, Ch, Wo, Wo, Wo, Gg, Wo, Wo, Wo, Md, Wo, Wo, Wo, Rd, Wo, Wo
Mm, Mm, Mm, Mm, Mm^Xm, Mm^Xm, Mm^Xm, Gg^Vl, Ww^Vm, Gg, Dd^Vda, Gg, Aa^Vea, Aa^Vla, Aa^Vha, Gg, Hh^Vhh, Gg, Mm^Vhh, Gg, Uu^Vu, Gg, Wo, Wo, Ch, Wo, Wo, Wo, Gg^Fet, Wo, Wo, Wo, Md, Wo, Wo, Wo, Rd^Vov, 3 Wo, Wo
Mm, Mm, Mm, Mm, Mm, Mm^Xm, Gg, Gg, Gg, Uu^Vud, Gg, Dd^Vdt, Gg, Gg^Ve, Gg, Gg^Vh, Gg^Vo, Ha^Vhha, Gg, Gs^Vht, Wo, Wo, Cud, Ch, Wo, Wo, Ds, Gg, Wo, Wo^Fet, Hd^Fet, Md^Fet, Wo^Fet, Wo, Re^Kov, Rd^Cov, Wo, Wo, Wo
Mm, Mm, Gg, Gg, Gg, Gg, Gg, Ch, Ch, Ch, Ch, Gg, Gg, Gg, Gg, Gg, Gg^Vo, Gg^Vo, Gg^Em, Ss^Vhs, Gg, Cud, Wo, Wo, Dd, Ds, Wo, Wo, Ha, Hd, Wo, Wo, Ql^Fet, Re^Fet, Wo, Wo, Uu^Fp, Uu, Uu
Mm, Mm, Gg, Gg, Gg, Gg, Gg, Ch, 1 Kh, Ch, Ww, Gg, Gg, Mm^Vhh, Gg, Gg, Gg, Gg, Gg^Es, Gs^Fp, Gs^Fp, Gs^Fp, Gs^Fp, Dd, Wo, Wo, Gs, Ha, Wo, Wo, Mm, Ql, Wo, Wo, Uh^Fp, Uh^Fp, Wo^Fp, Wo^Fp, Wo
Mm, Mm, Gg, Gg, Gg, Gg, Gg, Ch, Ch, Ch, Gg, Ww, Gg, Gg, Gg, Gg, Gg, Gg, Gg^Em, Gs^Fp, Gs^Fp, Gs^Fp, Gs^Fp, Wo, Gs, Gs, Gg^Vh, Ww, Ww^Fp, Mm, Ww, Wo, Rr, Rr, Wo^Fp, Wo^Fp, Gg^Fp, Gg^Fp, Gg
Mm, Mm, Gg, Gg, Gg, Gg, Gg, Ch, Ch, Ch, Gg^Em, Gg, Gg, Gg, Rr, Gg, Rr, Rr, Rr, Gs^Fp, Gs^Fp, Gs^Fp, Gs^Fp, Gs^Fp, Gg^Vh, Rr, Gg, Ww^Fp, Ww^Fp, Hh^Fp, Hh^Ft, Hh^Ft, Wo, Wo, Wo, Gg^Fp, Wo, Gg, Gg
Mm, Mm, Gg, Gg, Gg^Es, Gg, Gg, Gg^Ve, Gg, Gg^Ve, Gg, Gg, Gg, Gg, Gg, Gg, Rr, Gg, Rr, Gg^Efm, Gg, Gg, Gg^Efm, Gg^Em, Gg^Em, Gg, Gg^Fdw, Ww^Fdw, Ww^Fp, Ww^Fp, Ww^Ft, Gg^Ft, Wo, Mm^Xm, Wo, Gg, Wo, Ha, Ha
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gs, Gg, Gg, Rr, Gg^Em, Gg, Gg^Efm, Gg, Gg^Efm, Gg^Efm, Gg, Gg, Gg^Es, Gg^Fdw, Aa^Fdw, Gg^Fp, Gg, Gg, Wo, Mm^Xm, Wo, Gg, Wo, Ha, Ha
Gg, Gg, Gs^Fp, Gg, Gg, Gg, Gg, Gg, Gg^Es, Gg, Gg, Gs, Gg, Gs, Gg, Gs, Gg, Gg, Re, Gg^Efm, Gg^Efm, Gg^Efm, Gg, Gg^Efm, Gg^Efm, Gg, Gg, Gg^Em, Aa^Fdw, Aa^Fdw, Gg, Gg, Wo, Aa, Wo, Gg, Wo, Hh, Hh
Gg, Gg, Gg, Gg, Gs^Ft, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg^Es, Gs, Gs, Gs, Gg, Re, Gg^Efm, Re, Gg^Efm, Gg, Gg, Gg, Gg, Gg^Em, Gg, Gg, Gg, Gg, Gg, Gg, Wo, Aa, Wo, Md, Wo, Hh, Hh
Gg, Gg, Dd^Do, Gg, Gg, Gg, Gg, Gg^Es, Gg, Gg, Gg, Gs^Es, Gg, Gg, Rd, Gg, Gg^Es, Re, Re, Re, Gg^Efm, Gg, Ch, Ch, Ch, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Wo, Ai, Wo, Md, Wo, Ss^Bw|, Ss^Bw|
Gg, Gg, Gg, Gg, Gg^Fet, Gg, Gg, Gg, Gs^Fpa, Ds^Fp, Gs^Fp, Gg, Gg, Rd, Gg, Rd, Gg, Gg, Gg, Gg, Gg, Gg, Ch, Ch, Ch, Gg, Gg, Gg, Ww, Gg, Wo, Gg, Wo, Ai, Wo, Mm, Wo, Ss, Ss
Xu, Xu, Xu, Gg, Gg, Gg, Gg, Gg, Re^Fp, Gg^Fet, Gg^Fp, Ss^Vm, Gg, Rd, Rd, Rd, Gg, Re, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Wo^Bw\, Wo^Bw/, Wo^Bw|, Ww, Gg, Wo, Dd, Wo, Mm, Wo, Ss, Ss
Xu, Xu, Xu, Ce, Ce, Ke, Ce, Gg, Gg, Re^Fp, Gg^Ve, Gg^Vh, Gg, Gg, Gg, Gg, Ce, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Ss^Bw/, Ww, Ss^Bw|, Ss^Bw\, Gg, Wo, Dd, Wo, Qxu, Wo, Rr, Rr
Xu, Xu, Uu^Uf, Xu, Ce, Ce, Xu, Gg, Uh, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Ke, Ce, Gg, Gg, Gg, Gg, Gg^Es, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Ss^Bw\, Wo, Ds, Wo, Qxu, Wo, Rr, Rr
Xu, Xu, Uu^Uf, Xu, Xu, Xu, Xu, Xu, Uu, Gg, Uh, Gg, Gg, Gg^Es, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Ss, Gg, Gg, 2 Kh, Gg, Gg, Wo, Ds, Wo, Rd, Wo, Uh, Uh
Xu, Xu, Qxu, Qxu, Cud, Xu, Uu, Uu^Ii, Uu^Vu, Gg, Xu, Gg, Gg, Gg, Gg^Ve, Gg, Ch, Gg, Gg, Chr, Chr, Gg, Chw, Ww, Gg, Chs, Chs, Gg, Cud, Gg, Gg, Gg, Wo, Gs, Wo, Rd, Wo, Uh, Uh
Xu, Xu, Xu, Qxu, Ql, Cud, Uh, Uu^Vu, Uu^Uf, Xu, Ql, Gg^Ve, Xu, Gg, Gg, Gg, Kh, Ch, Gg, Khr, Gg, Gg, Khw, Chw, Gg, Khs, Gg, Gg, Kud, Cud, Ww^Bw/, Ww^Bw/, Wo, Gs, Wo, Re, Wo, Uu, Uu
Xu, Xu, Qxu, Qxu, Ql, Ql, Ql, Xu, Xu, Xu, Xu, Xu, Xu, Xu, Xu, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Wo, Gg, Wo, Re, Wo, Uu, Uu
Xu, Xu, Qxu, Qxu, Ql, Ql, Ql, Xu, Xu, Xu, Xu, Xu, Xu, Xu, Xu, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Wo, Gg, Wo, Re, Wo, Uu, Uu"
    turns=-1
    id=test

    {DAWN}
    {MORNING}
    {AFTERNOON}
    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}
    current_time=3

    victory_music="loyalists.ogg,underground.ogg,revelation.ogg"
    defeat_music="sad.ogg"

    [side]
        no_leader=yes
        [leader]
            name= "Kaleh"
            type=Kaleh
            variation=Youth
            [modifications]
                [object]
                    [effect]
                        apply_to=image_mod
                        add="BLEND(255,0,255,25%)"
                    [/effect]
                [/object]
            [/modifications]
            random_gender=yes
            id="test"
            max_hitpoints=90
            experience=99
            alignment=liminal
        [/leader]
        side=1
        controller=human
        recruit="Ghost,Troll Whelp,Assassin,Elvish Hero,Elvish Fighter,Elvish Archer,Horseman,Mage,Elvish Shaman,Red Mage,Spearman,Swordsman,Duelist,Fencer,Elvish Captain,Elvish Ranger,Elvish Shyde,Thief,Rogue,White Mage,Mage of Light,Elvish Sharpshooter,Silver Mage,Vampire Bat,Blood Bat,Dread Bat,Soulless,Walking Corpse,Fire Dragon"
        gold=2000
        village_support=5
        team_name="1"
        shroud=yes
        recall_cost=42
        [village]
            x,y=9,7
        [/village]
        [village]
            x,y=7,7
        [/village]
        [unit]
            alignment=lawful
            x,y=8,11
            type=Elvish Outrider
            max_hitpoints=12000
            hitpoints=12000
            max_experience=9999
            experience=9000
            max_moves=120
            vision=12
            jamming=5
            level=10
            name= "UI testing Outrider called Isor"
            [status]
                #dehydrated=yes
                #entangled=yes
                poisoned=yes
                #entangled=yes
                slowed=yes
            [/status]
            [+modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
                {TRAIT_DEXTROUS}
                [object]
                    silent=yes
                    [effect]
                        apply_to=remove_attacks
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=sword
                        #textdomain wesnoth-units
                        description=_"sword"
                        #textdomain wesnoth
                        icon=attacks/greatsword-elven.png
                        type=blade
                        [specials]
                            [drains]
                                id=life_vortex
                                name="Life Vortex"
                                description="Each successful strike in a battle involving this attack causes the attacker to gain the health that his attack removed from the target.  This has no effect against nonliving targets."
                                value=0
                                add=100
                                apply_to=both
                            [/drains]
                            [heal_on_hit]
                                id=entropy
                                name="Entropy"
                                description="Each successful strike in a battle involving this attack causes the attacker to lose 4 HP.  This has no effect against nonliving targets."
                                [filter_opponent]
                                    [not]
                                        status=not_living
                                    [/not]
                                [/filter_opponent]
                                sub=4
                                apply_to=both
                            [/heal_on_hit]
                        [/specials]
                        range=melee
                        damage=9
                        number=5
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=bow
                        #textdomain wesnoth-units
                        description=_"bow"
                        #textdomain wesnoth
                        icon=attacks/bow-elven.png
                        type=pierce
                        [specials]
                            [drains]
                                id=empathic_weapon
                                name="Empathic Weapon"
                                description="All damage dealt by this attack to a living target is dealt to the user as well"
                                multiply=-2
                            [/drains]
                            [heal_on_hit]
                                id=rejuvenating_weapon
                                name="Rejuvenating Weapon (10)"
                                description="Each successful strike with this weapon heals the user for 10 HP"
                                value=10
                            [/heal_on_hit]
                        [/specials]
                        range=ranged
                        damage=9
                        number=3
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=longbow
                        #textdomain wesnoth-units
                        description=_"longbow"
                        #textdomain wesnoth
                        icon=attacks/bow-elven-magic.png
                        type=pierce
                        [specials]
                            {WEAPON_SPECIAL_MARKSMAN}
                            [drains]
                                id=drains
                                name="drains 20%"
                                description="This unit drains health from living units, healing itself for 20% of the amount of damage it deals (rounded down)."
                                value=20
                            [/drains]
                            [heal_on_hit]
                                id=drains
                                name="sacrifice 5"
                                description="Each successful attack costs this unit 5 HP."
                                sub=5
                            [/heal_on_hit]
                        [/specials]
                        range=ranged
                        damage=10
                        number=5
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=life bomb
                        description="life bomb"
                        type=impact
                        [specials]
                            [heal_on_hit]
                                id=drains
                                name="life copy 20"
                                description="When this attack hits a living unit, the user is healed for 20 HP."
                                [filter_opponent]
                                    [not]
                                        status=not_living
                                    [/not]
                                [/filter_opponent]
                                value=20
                            [/heal_on_hit]
                        [/specials]
                        damage=3
                        number=2
                        range=ranged
                    [/effect]
                [/object]
            [/modifications]
            [abilities]
                {ABILITY_SKIRMISHER}
                {ABILITY_ILLUMINATES}
            [/abilities]
        [/unit]

        [unit]
            x,y=9,7
            type="Silver Mage"
            generate_name=yes
        [/unit]
        [unit]
            x,y=4,8
            type="Elvish Avenger"
            id=statue
            generate_name=yes
            hitpoints=4
            vision=15
            ellipse=none
            [status]
                petrified=yes
            [/status]
            overlays="wesnoth-icon.png~CROP(10,10,20,20)"
        [/unit]
        [unit]
            x,y=14,6
            type=Footpad
            generate_name=yes
            [modifications]
                [trait]
                    id=feral
                    availability="musthave"
                    male_name="feral"
                    female_name="female^feral"
                    description="Receive at most 40% defense in villages"
                    [effect]
                        apply_to=defense
                        replace=yes
                        [defense]
                            village=-60
                        [/defense]
                    [/effect]
                [/trait]
                [trait]
                    id=overpowered
                    name="overpowered"
                    availability=musthave
                    [effect]
                        apply_to=attack
                        increase_attacks=1
                        increase_damage=1
                    [/effect]
                [/trait]
            [/modifications]
        [/unit]
        [unit]
            x,y=12,8
            type="Thief"
            generate_name=yes
            hitpoints=9
            [status]
                poisoned=yes
                entangled=yes
            [/status]
        [/unit]
        [unit]
            # Unhealable unit
            x,y=9,8
            type="Peasant_unhealable"
            name="Unhealable"
            image_icon="misc/key.png"
            generate_name=yes
            [status]
                unhealable=yes
            [/status]
        [/unit]
        [unit]
            # A unit without a portrait.
            x,y=18,9
            type="Wolf Rider"
            generate_name=yes
        [/unit]
        [unit]
            x,y=17,10
            type="Elvish Druid"
            generate_name=yes
        [/unit]
        [unit]
            # A unit with an old small portrait.
            x,y=19,10
            type="Thief"
            generate_name=yes
        [/unit]
        [unit]
            x,y=17,11
            type="Elvish Shyde"
            profile="portraits/elves/shyde.png~BLIT(items/gold-coins-large.png)"
            generate_name=yes
        [/unit]
        [unit]
            # A unit whose portrait is only shown on the right side.
            x,y=18,11
            type="White Mage"
            gender="female"
            generate_name=yes
        [/unit]
        [unit]
            # A unit with a cold attack
            x,y=19,11
            type="Dark Adept"
            generate_name=yes
            [modifications]
                [object]
                    silent=yes
                    [effect]
                        apply_to=halo
                        halo=halo/darkens-aura.png
                    [/effect]
                    [effect]
                        apply_to=new_ability
                        [abilities]
                            [illuminates]
                                id=illumination
                                value=-25
                                min_value=-25
                                cumulative=no
                                name= "darkens"
                                female_name= "female^darkens"
                                description= "darkens and stuff"
                                affect_self=yes
                            [/illuminates]
                        [/abilities]
                    [/effect]
                    [effect]
                        apply_to=attack
                        name=chill wave
                        increase_attacks=12
                        [set_specials]
                            mode=append
                            [heal_on_hit]
                                id=sacrifice
                                name="Sacrifice"
                                description="This unit sacrifices its own life in order to make more attacks."
                                value=-5
                            [/heal_on_hit]
                        [/set_specials]
                    [/effect]
                    [effect]
                        apply_to=attack
                        name=shadow wave
                        increase_attacks=18
                        [set_specials]
                            mode=append
                            [heal_on_hit]
                                id=sacrifice
                                name="Greater Sacrifice"
                                description="This unit sacrifices its own life in order to make more attacks."
                                value=-6
                            [/heal_on_hit]
                        [/set_specials]
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
        [unit]
            # Drain tester
            x,y=20,7
            type="Elvish Champion"
            generate_name=yes
            {IS_HERO}
            [modifications]
                [object]
                    silent=yes
                    [effect]
                        apply_to=remove_attacks
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=sword
                        #textdomain wesnoth-units
                        description=_"sword"
                        #textdomain wesnoth
                        icon=attacks/greatsword-elven.png
                        type=blade
                        [specials]
                            [drains]
                                id=life_vortex
                                name="Life Vortex"
                                description="Each successful strike in a battle involving this attack causes the attacker to gain the health that his attack removed from the target.  This has no effect against nonliving targets."
                                value=0
                                add=100
                                apply_to=both
                            [/drains]
                            [heal_on_hit]
                                id=entropy
                                name="Entropy"
                                description="Each successful strike in a battle involving this attack causes the attacker to lose 4 HP.  This has no effect against nonliving targets."
                                [filter_opponent]
                                    [not]
                                        status=not_living
                                    [/not]
                                [/filter_opponent]
                                sub=4
                                apply_to=both
                            [/heal_on_hit]
                        [/specials]
                        range=melee
                        damage=9
                        number=5
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=bow
                        #textdomain wesnoth-units
                        description=_"bow"
                        #textdomain wesnoth
                        icon=attacks/bow-elven.png
                        type=pierce
                        [specials]
                            [drains]
                                id=empathic_weapon
                                name="Empathic Weapon"
                                description="All damage dealt by this attack to a living target is dealt to the user as well"
                                multiply=-2
                            [/drains]
                            [heal_on_hit]
                                id=rejuvenating_weapon
                                name="Rejuvenating Weapon (10)"
                                description="Each successful strike with this weapon heals the user for 10 HP"
                                value=10
                            [/heal_on_hit]
                        [/specials]
                        range=ranged
                        damage=9
                        number=3
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=longbow
                        #textdomain wesnoth-units
                        description=_"longbow"
                        #textdomain wesnoth
                        icon=attacks/bow-elven-magic.png
                        type=pierce
                        [specials]
                            {WEAPON_SPECIAL_MARKSMAN}
                            [drains]
                                id=drains
                                name="drains 20%"
                                description="This unit drains health from living units, healing itself for 20% of the amount of damage it deals (rounded down)."
                                value=20
                            [/drains]
                            [heal_on_hit]
                                id=drains
                                name="sacrifice 5"
                                description="Each successful attack costs this unit 5 HP."
                                sub=5
                            [/heal_on_hit]
                        [/specials]
                        range=ranged
                        damage=10
                        number=5
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=life bomb
                        description="life bomb"
                        type=impact
                        [specials]
                            [heal_on_hit]
                                id=drains
                                name="life copy 20"
                                description="When this attack hits a living unit, the user is healed for 20 HP."
                                [filter_opponent]
                                    [not]
                                        status=not_living
                                    [/not]
                                [/filter_opponent]
                                value=20
                            [/heal_on_hit]
                        [/specials]
                        damage=3
                        number=2
                        range=ranged
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
    [/side]

    [label]
        x,y=20,12
        text="Enhance Vision"
        tooltip="Set the unit's vision to 15."
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=20,12
        [/filter]
        [message]
            speaker=unit
            message="Now my Vision value is 15 and I can see 16 hex fields wide."
        [/message]
        [modify_unit]
            [filter]
                x,y=20,12
            [/filter]
            vision=15
        [/modify_unit]
    [/event]

    [label]
        x,y=18,7
        text="Hero or not?"
        tooltip="Toggle the hero status."
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=18,7
        [/filter]
        [if]
            [variable]
                name=unit.ellipse
                equals="misc/ellipse-hero"
            [/variable]
            [then]
                [message]
                    speaker=unit
                    message="I am no longer a hero!"
                [/message]
                {UNMAKE_HERO $unit.id}
            [/then]
            [else]
                [message]
                    speaker=unit
                    message="I am now a hero!"
                [/message]
                {MAKE_HERO $unit.id}
            [/else]
        [/if]
    [/event]

    [label]
        x,y=14,10
        text="Vision Test"
        tooltip="Visibility Check of (8,15)"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=14,10
        [/filter]
        [message]
            speaker=narrator
            icon=wesnoth-icon.png
            message="Checking visibility of (8,15)..."
        [/message]
        [if]
            [have_location]
                x,y=8,15
                [filter_vision]
                    side=1
                    respect_fog=no
                [/filter_vision]
            [/have_location]
            [then]
                [if]
                    [have_location]
                        x,y=8,15
                        [filter_vision]
                            side=1
                            visible=no
                            respect_fog=no
                        [/filter_vision]
                    [/have_location]
                    [then]
                        [message]
                            speaker=narrator
                            icon=wesnoth-icon.png
                            message="HORRORS FILTERS ARE ALL TRUE!"
                        [/message]
                    [/then]
                    [else]
                        [message]
                            speaker=narrator
                            icon=wesnoth-icon.png
                            message="You can see it, can't you?"
                        [/message]
                        [if]
                            [have_location]
                                x,y=8,15
                                [filter_vision]
                                    side=1
                                [/filter_vision]
                            [/have_location]
                            [then]
                                [if]
                                    [have_location]
                                        x,y=8,15
                                        [filter_vision]
                                            side=1
                                            visible=no
                                        [/filter_vision]
                                    [/have_location]
                                    [then]
                                        [message]
                                            speaker=narrator
                                            icon=wesnoth-icon.png
                                            message="HORRORS FILTERS ARE ALL TRUE!"
                                        [/message]
                                    [/then]
                                    [else]
                                        [message]
                                            speaker=narrator
                                            icon=wesnoth-icon.png
                                            message="Clear sailing!"
                                        [/message]
                                    [/else]
                                [/if]
                            [/then]
                            [else]
                                [if]
                                    [have_location]
                                        x,y=8,15
                                        [filter_vision]
                                            side=1
                                            visible=no
                                        [/filter_vision]
                                    [/have_location]
                                    [then]
                                        [message]
                                            speaker=narrator
                                            icon=wesnoth-icon.png
                                            message="But the fog, it blinds you!"
                                        [/message]
                                    [/then]
                                    [else]
                                        [message]
                                            speaker=narrator
                                            icon=wesnoth-icon.png
                                            message="HORRORS FILTERS ARE ALL FALSE!"
                                        [/message]
                                    [/else]
                                [/if]
                            [/else]
                        [/if]
                    [/else]
                [/if]
            [/then]
            [else]
                [if]
                    [have_location]
                        x,y=8,15
                        [filter_vision]
                            side=1
                            visible=no
                        [/filter_vision]
                    [/have_location]
                    [then]
                        [message]
                            speaker=narrator
                            icon=wesnoth-icon.png
                            message="It is invisible!"
                        [/message]
                    [/then]
                    [else]
                        [message]
                            speaker=narrator
                            icon=wesnoth-icon.png
                            message="HORRORS FILTERS ARE ALL FALSE!"
                        [/message]
                    [/else]
                [/if]
            [/else]
        [/if]
    [/event]

    [event]
        name=attack
        [filter]
            type="Elvish Shyde"
        [/filter]
        {MODIFY_UNIT (id=$second_unit.id) side 1}
    [/event]
    [event]
        name=prestart
        {VARIABLE teleports_on no}
    [/event]
    [label]
        x,y=20,13
        text="Teleport switch"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=20,13
        [/filter]

        [if]
            [variable]
                name=teleports_on
                boolean_equals=no
            [/variable]
            [then]
                [tunnel]
                    id="one"
                    bidirectional=yes
                    always_visible=yes
                    [source]
                        x=8
                        y=6
                    [/source]
                    [target]
                        x=20
                        y=12
                    [/target]
                    [filter]
                    [/filter]
                [/tunnel]
                [tunnel]
                    id="two"
                    bidirectional=no
                    [source]
                        x=20
                        y=14
                    [/source]
                    [target]
                        x=21
                        y=4
                    [/target]
                    [filter]
                    [/filter]
                [/tunnel]
                {VARIABLE teleports_on yes}
                [message]
                    speaker=narrator
                    icon=wesnoth-icon.png
                    message="Teleporters activated"
                [/message]
            [/then]
            [else]
                [tunnel]
                    id="one,two"
                    remove=yes
                [/tunnel]
                {VARIABLE teleports_on no}
                [message]
                    speaker=narrator
                    icon=wesnoth-icon.png
                    message="Teleporters deactivated"
                [/message]
            [/else]
        [/if]
    [/event]

    [side]
        type=Orcish Warlord
        id="Urug-Telfar"
        side=2
        controller=ai
        canrecruit=yes
        recruit="Orcish Grunt,Troll Whelp,Wolf Rider,Orcish Archer,Orcish Assassin,Saurian Skirmisher,Naga Fighter"
        gold=40
        income=10
        team_name="2"
        [leader]
            type=Orcish Warlord
            id="Asir-Ulrug"
            x=28
            y=18
        [/leader]
        [unit]
            x,y=12,13
            type="Orcish Archer"
            generate_name=yes
            jamming=5
        [/unit]
        [unit]
            x,y=10,7
            type="Orcish Archer"
            generate_name=yes
        [/unit]
        [unit]
            x,y=18,12
            type="Ghost"
            name="Steadfast tester"
            [modifications]
                [object]
                    silent=yes
                    [effect]
                        apply_to=new_ability
                        [abilities]
                            {ABILITY_STEADFAST}
                        [/abilities]
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
        [village]
            x,y=26,5
        [/village]
        [unit]
            x,y=24,7
            type="Silver Mage"
            name= "Hidden Teleporter"
        [/unit]
        [unit]
            x,y=18,10
            type="Soulless"
            [modifications]
                [object]
                    silent=yes
                    [effect]
                        apply_to=attack
                        increase_damage=50
                    [/effect]
                    [effect]
                        apply_to=hitpoints
                        increase_total=30
                    [/effect]
                    [effect]
                        apply_to=defense
                        replace=yes
                        [defense]
                            flat=10
                        [/defense]
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
        [unit]
            x,y=20,5
            type="Ancient Wose"
            id="rithrandil"
            name="Rithrandil"
            profile="portraits/rithrandil.png"
            [modifications]
                [object]
                    [effect]
                        apply_to=movement
                        set=0
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
        [unit]
            # Drain tester (for undead and default drain)
            x,y=21,7
            type="Lich"
            generate_name=yes
        [/unit]
        [unit]
            # Drain tester
            x,y=21,8
            type="Elvish Sharpshooter"
            generate_name=yes
            [modifications]
                [object]
                    silent=yes
                    [effect]
                        apply_to=attack
                        name=sword
                        [set_specials]
                            mode=append
                            [heal_on_hit]
                                id=fiery
                                name="fiery 4"
                                name_inactive="fiery 4"
                                description="A successful hit against this unit costs the opponent 4 HP."
                                description_inactive="A successful hit against this unit costs the opponent 4 HP."
                                sub=4
                                apply_to=opponent
                            [/heal_on_hit]
                        [/set_specials]
                    [/effect]
                    [effect]
                        apply_to=new_attack
                        name=lifebow
                        description="lifebow"
                        icon=attacks/bow-elven-magic.png
                        type=pierce
                        [specials]
                            {WEAPON_SPECIAL_MARKSMAN}
                            [drains]
                                id=drains
                                name="drains 100%"
                                description="This unit drains health from living units, healing itself for 100% of the amount of damage it deals (rounded down)."
                                value=100
                            [/drains]
                        [/specials]
                        range=ranged
                        damage=4
                        number=5
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
    [/side]
    [side]
        side=3
        controller=ai
        team_name="1,2"
        type="Gryphon Master"
        name="Friendly Explorer"
        canrecruit=yes
        fog=yes
        shroud=yes
        share_maps=no
        share_view=no
    [/side]
    [event]
        name=turn refresh
        first_time_only=no
        [if]
            [variable]
                name=side_number
                equals=3
            [/variable]
            [then]
                # This is to work around a broken idle_ai (it moves)
                [end_turn]
                [/end_turn]
            [/then]
        [/if]
    [/event]
    [label]
        x,y=1,1
        text="Explore the map"
    [/label]

    [event]
        name=moveto
        [filter]
            side=1
            [filter_adjacent]
                id=rithrandil
            [/filter_adjacent]
        [/filter]

        [message]
            id=rithrandil
            message="Hello there"
        [/message]
    [/event]

#ifdef DEBUG_MODE
    [event]
        name=select
        first_time_only=no
        [filter]
            type="Wolf Rider"
        [/filter]
        [message]
            speaker=narrator
            icon=wesnoth-icon.png
            message="Select event triggered on Wolf Rider"
        [/message]
    [/event]
#endif

#ifhave ~add-ons/Wesnoth_Lua_Pack/_main.cfg
    {~add-ons/Wesnoth_Lua_Pack/utils.cfg}
    {WLP_QUICK_DEBUG}
#endif

    [label]
        x,y=14,7
        text="Custom dialog"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=14,7
        [/filter]
        [lua]
            code=<<
local types = { "Ancient Lich", "Ancient Wose", "Elvish Avenger" }
local x = a > b -- Just a dummy line added to show that > doesn't mess up the parsing!
local result = wesnoth.synchronize_choice(function()
    -- Human choice
    local helper = wesnoth.require "lua/helper.lua"
    local T = helper.set_wml_tag_metatable {}
    local _ = wesnoth.textdomain "wesnoth"
    local dialog = {
      T.helptip { id = "helptip_large" },
      T.tooltip { id = "tooltip_large" },
      T.grid { T.row {
        T.column { T.grid {
          T.row { T.column { horizontal_grow = true, T.listbox { id = "the_list",
            T.list_definition { T.row { T.column { horizontal_grow = true,
              T.toggle_panel { T.grid { T.row {
                T.column { horizontal_alignment = "left", T.label { id = "the_label" } },
                T.column { T.image { id = "the_icon" } }
              } } }
            } } }
          } } },
          T.row { T.column { T.grid { T.row {
            T.column { T.button { id = "ok", label = _"OK" } },
            T.column { T.button { id = "cancel", label = _"Cancel" } }
          } } } },
          T.row { T.column {
            T.toggle_button { id = "flip", label = "Flip" }
          } }
        } },
        T.column { T.image { id = "the_image" } }
      } }
    }

    local function preshow()
        local function select()
            local i = wesnoth.get_dialog_value "the_list"
            local ut = wesnoth.unit_types[types[i]].__cfg
            local profile = string.gsub(ut.profile, "([^/]+)$", "transparent/%1")
            if wesnoth.get_dialog_value "flip" then profile = profile .. "~FL()" end
            wesnoth.set_dialog_value(profile, "the_image")
        end
        wesnoth.set_dialog_callback(select, "the_list")
        wesnoth.set_dialog_callback(select, "flip")
        for i,v in ipairs(types) do
            local ut = wesnoth.unit_types[v].__cfg
            wesnoth.set_dialog_value(ut.name, "the_list", i, "the_label")
            wesnoth.set_dialog_value(ut.image, "the_list", i, "the_icon")
        end
        wesnoth.set_dialog_value(2, "the_list")
        select()
        wesnoth.set_dialog_canvas(2, {
            T.rectangle { x = 20, y = 20, w = 20, h = 20, fill_color= "0,0,255,255" },
            T.rectangle { x = 30, y = 30, w = 20, h = 20, fill_color = "255,0,0,255" }
        })
    end

    local li = 0
    local r = wesnoth.show_dialog(dialog, preshow, function ()
        li = wesnoth.get_dialog_value "the_list"
    end)
    return { button = r, list_item = li }
end, function()
    -- AI choice
    return { button = -1, list_item = math.random(#types) }
end)

if result.button == -1 then
    local ev = wesnoth.current.event_context
    wesnoth.transform_unit(wesnoth.get_units{x=ev.x1, y=ev.y1}[1], types[result.list_item])
    wesnoth.fire("redraw", {})
end
            >>
        [/lua]
    [/event]

    [label]
        x,y=3,2
        text="objectives test"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=3,2
        [/filter]
        [lua]
            code=<<
                local obj_note = string.rep("w", 5000)
                wesnoth.wml_actions.objectives({ note = obj_note })
            >>
        [/lua]
    [/event]

    [event]
        name=moveto
        [filter]
            x,y=1,1
        [/filter]
        [modify_side]
            side=3
            share_maps=yes
        [/modify_side]
        [message]
            speaker=unit
            message="We should now be sharing maps with side 3!"
        [/message]
        [label]
            x,y=1,1
            text="Rename our kind friends"
        [/label]
        [event]
            name=moveto
            [filter]
                x,y=1,1
            [/filter]
            [modify_side]
                side=3
                user_team_name="Neutral"
            [/modify_side]
            [message]
                side=3
                message="That’s right! We’re neutral!"
            [/message]
            [label]
                x,y=1,1
                text=""
            [/label]
        [/event]
    [/event]

    [event]
        name=preload
        first_time_only=no
        [lua]
            code=<<
                local wml_actions = wesnoth.wml_actions
                function wml_actions.my_lua_action(t)
                    wesnoth.fire("label", { text =
                        string.format("Lua says:\n%d units and %d gold on side %d",
                            #wesnoth.get_units { side = t.on_side },
                            wesnoth.sides[t.on_side].gold,
                            t.on_side),
                        x = t.x, y = t.y })
                end
                function wml_actions.check_substitution(t)
                    wesnoth.set_variable("substitution_variable", 1)
                    if t.value ~= "Number 2" then
                        wesnoth.message("Substitution is not delayed! " .. tostring(t.value))
                    end
                end
                local function get_child(cfg, name)
                    for i = 1, #cfg do
                        local v = cfg[i]
                        if v[1] == name then return v[2] end
                    end
                end
                function has_teleport(u)
                    return wesnoth.unit_ability(u, "teleport")
                end
                local old_unit_status = wesnoth.theme_items.unit_status
                function wesnoth.theme_items.unit_status()
                    local u = wesnoth.get_displayed_unit()
                    if not u then return {} end
                    local s = old_unit_status()
                    if u.status.entangled then
                        table.insert(s, { "element", {
                            image = "misc/key.png",
                            tooltip = "entangled: This unit is entangled. It cannot move but it can still attack."
                        } })
                    end
                    return s
                end
            >>
        [/lua]
    [/event]

    [event]
        name=turn refresh
        first_time_only=no
        [lua]
            code=<<
                for i,u in ipairs(wesnoth.get_units()) do
                    if u.status.entangled then
                        u.moves = 0
                    end
                end
            >>
        [/lua]
    [/event]

    [event]
        name=prestart
        [lua]
            code=<<
                local args = ...
                local team = wesnoth.sides[args.side];
                team.gold = team.gold + args.gold;
            >>
            [args]
                side=1
                gold=-1900
            [/args]
        [/lua]
        [modify_unit]
            [filter]
                x,y=14,6
            [/filter]
            [object]
                [effect]
                    apply_to=image_mod
                    add="PAL(FFDC02,EA9752,C4793A,C35029,6B2C29,A34C29,D5561F,343424,353624,BF5746 > BCBCBC,7D7D7D,5E5E5E,434343,232323,3B3B3B,494949,232323,232323,484848)"
                [/effect]
                [effect]
                    apply_to=image_mod
                    add="B(50)~R(-50)"
                [/effect]
            [/object]
            [object]
                [effect]
                    apply_to=new_attack
                    name=lightning
                    description="lightning"
                    icon=attacks/lightning.png
                    # Testcase for custom attack types and ranges
                    type=electrical
                    range=very_long
                    [specials]
                        {WEAPON_SPECIAL_MAGICAL}
                    [/specials]
                    damage=14
                    number=4
                [/effect]
            [/object]
        [/modify_unit]
        [music]
            name="traveling_minstrels.ogg"
            ms_before=12000
        [/music]
        [set_menu_item]
            description="Calculate unit worth"
            id=test98
            [show_if]
                [have_unit]
                    x=$x1
                    y=$y1
                [/have_unit]
            [/show_if]
            [command]
                [unit_worth]
                    x=$x1
                    y=$y1
                [/unit_worth]
                [message]
                    x,y=$x1,$y1
                    message="I seem to be worth $unit_worth| gold!
This is based on the following facts:
I cost $cost gold and am at $health|% health.
My best advancement costs $next_cost gold and I’m $experience|% there."
                [/message]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            description="Lua"
            id=test99
            [filter_location]
                [filter]
                    type=Kaleh
                [/filter]
            [/filter_location]
            [command]
                [message]
                    speaker=narrator
                    message="Enter Lua code"
                    [text_input]
                        variable=code
                    [/text_input]
                [/message]
                [set_variables]
                    name=tag
                    mode=replace
                    [value]
                        code=$code
                    [/value]
                [/set_variables]
                [insert_tag]
                    name=lua
                    variable=tag
                [/insert_tag]
            [/command]
        [/set_menu_item]

        [set_menu_item]
            description="Show movement range"
            id=show_movement_range
            [filter_location]
                [filter]
                [/filter]
            [/filter_location]
            [command]
                [store_reachable_locations]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]

                    variable=unit_reach
                [/store_reachable_locations]

                {FOREACH unit_reach i}
                    [item]
                        x,y=$unit_reach[$i].x,$unit_reach[$i].y
                        image=misc/waypoint.png
                    [/item]
                {NEXT i}

                [event]
                    name=select,side turn,moveto

                    {FOREACH unit_reach i}
                        [remove_item]
                            x,y=$unit_reach[$i].x,$unit_reach[$i].y
                            image="misc/waypoint.png"
                        [/remove_item]
                    {NEXT i}

                    [redraw]
                    [/redraw]

                    {CLEAR_VARIABLE unit_reach}
                [/event]
            [/command]
        [/set_menu_item]

        [set_menu_item]
            description="Show attack range"
            id=show_attack_range
            [filter_location]
                [filter]
                [/filter]
            [/filter_location]
            [command]
                [store_reachable_locations]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]

                    range=attack
                    variable=unit_reach
                [/store_reachable_locations]

                [lua]
                    code=<<
                        local location_set = wesnoth.require 'lua/location_set.lua'
                        local items = wesnoth.require 'lua/wml/items.lua'
                        local locs = location_set.of_wml_var 'unit_reach'
                        locs:iter(function(x, y)
                            items.place_image(x, y, 'misc/waypoint.png~CS(255,-127,-127)')
                        end)
                    >>
                [/lua]

                [event]
                    name=select,side turn,moveto

                    {FOREACH unit_reach i}
                        [remove_item]
                            x,y=$unit_reach[$i].x,$unit_reach[$i].y
                            image="misc/waypoint.png~CS(255,-127,-127)"
                        [/remove_item]
                    {NEXT i}

                    [redraw]
                    [/redraw]

                    {CLEAR_VARIABLE unit_reach}
                [/event]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            description="Reload and execute Lua code"
            id=reload_and_execute_lua_code
            # This command expects a (custom) file data/lua/code.lua of the form
            #
            # local code = {}
            # function code.main()
            #    wesnoth.message("hello world")
            # end
            # return code
            #
            # The file is not in the repository to allow adding custom stuff to it.
            [command]
                [lua]
                    code=<< wesnoth.dofile("lua/code.lua").main() >>
                [/lua]
            [/command]
        [/set_menu_item]
    [/event]

    [event]
        name=prerecruit
        [message]
            speaker=narrator
            message= "testing prerecruit"
            image=wesnoth-icon.png
        [/message]
    [/event]

    [event]
        name=prestart

        [gold]
            side=1
            amount=42
        [/gold]
    [/event]

    [event]
        name=start

        [gold]
            side=1
            amount=1000
        [/gold]

        [lua]
            code = <<
                wesnoth.set_village_owner(20, 1, 1)
                local u = wesnoth.get_units({ lua_function = "has_teleport" })[1]
                local t, c = wesnoth.find_path(u, 23, 7)
                for i,l in ipairs(t) do
                    wesnoth.fire("item",
                        { x = l[1], y = l[2], image = "items/buckler.png" })
                end
                wesnoth.fire("label",
                    { x = 23, y = 7, text = string.format("Move cost: %d", c) })
            >>
        [/lua]
    [/event]

    [event]
        name=test1
        first_time_only=no
        [select_unit]
            type=Elvish Avenger
            fire_event=yes
        [/select_unit]
    [/event]

    [event]
        name=select
        first_time_only=no
        [filter]
            type=Elvish Avenger
            [filter_wml]
                [status]
                    petrified=yes
                [/status]
            [/filter_wml]
        [/filter]

        [message]
            speaker=unit
            message="Oh hi"
        [/message]
    [/event]

    [event]
        name=prestart
        [time_area]
            id=cave
            {UNDERGROUND}
            terrain=U*^*,Q*,Xu,Kud,Cud
            x= 0-14
            y=13-20
        [/time_area]
        [label]
            x,y=8,11
            text="Filter Area"
            tooltip="Test filtering areas
<b>filter</b> with area=test_area
<span color='#bcb088'><b>x,y=8,11</b></span>"
        [/label]
        [time_area]
            x,y=8,11
            id=test_area
            {DEFAULT_SCHEDULE_24H}
            current_time=13
        [/time_area]
    [/event]

    [event]
        name=prestart
        [sound_source]
            id=birds
            sounds=ambient/birds1.ogg,ambient/birds2.ogg,ambient/birds3.ogg
            delay=0
            chance=100
            check_fogged=true
            loop=-1
            x=21
            y=5
            full_range=3
            fade_range=5
        [/sound_source]
    [/event]

    [event]
        name="new turn"
        first_time_only=no
        [my_lua_action]
            on_side=1
            x,y=13,3
        [/my_lua_action]
    [/event]

    [event]
        name="new turn"
        [set_variable]
            name=substitution_variable
            value=0
        [/set_variable]
        [check_substitution]
            value="Number $($substitution_variable*2)"
        [/check_substitution]
    [/event]

    [label]
        x,y=4,3
        text="randomness"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=4,3
        [/filter]
        {VARIABLE_OP minus_one rand -1..-1}
        {VARIABLE_OP zero rand 0..0}
        {VARIABLE_OP bool rand 0..1}
        {VARIABLE_OP one rand 1..1}
        {VARIABLE_OP below_ten rand 0..9}
        {VARIABLE_OP ascii rand one,two,three}
        {VARIABLE_OP mixed rand 0..3,one,two,three,4..9,zero}
        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message="Today, 0..0 = $zero, −1..−1 = $minus_one, 1..1 = $one and 0..1 = $bool.
Also, 0..9 = $below_ten, one,two,three = $ascii and the bonus answer is $mixed."
        [/message]
    [/event]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y,canrecruit,side=10,5,yes,1
        [/filter]
        [message]
            speaker=unit
            message="What am I supposed to be doing again?"
        [/message]
        [show_objectives]
            side=1
        [/show_objectives]
    [/event]
    [event]
        name=start
        [get_global_variable]
            side=global
            namespace="demo.sub.name.space"
            from_global=saved_unit
            to_local=store
        [/get_global_variable]
        [if]
            [not]
                [variable]
                    name=store.x
                    equals=$empty
                [/variable]
            [/not]
            [then]
                [set_variable]
                    name=store.moves
                    value=$store.max_moves
                [/set_variable]
                [set_variable]
                    name=store.hitpoints
                    value=$store.max_hitpoints
                [/set_variable]
                [unstore_unit]
                    variable=store
                    find_vacant=no
                [/unstore_unit]
                [message]
                    speaker=narrator
                    message="Unit recalled from storage."
                [/message]
            [/then]
        [/if]
        [get_global_variable]
            side=global
            namespace="demo.sub.name"
            from_global=savings
            to_local=estate
        [/get_global_variable]
        [if]
            [not]
                [variable]
                    name=estate
                    equals=$empty
                [/variable]
            [/not]
            [then]
                [store_gold]
                    side=1
                    variable=cur
                [/store_gold]
                [set_variable]
                    name=blah
                    value=$estate
                    sub=$cur
                [/set_variable]
                [if]
                    [variable]
                        name=blah
                        greater_than=0
                    [/variable]
                    [then]
                        [gold]
                            amount=$blah
                            side=1
                        [/gold]
                    [/then]
                [/if]
            [/then]
        [/if]
        [get_global_variable]
            side=global
            namespace=demo.sub
            from_global=greeting
            to_local=greeting
        [/get_global_variable]
        [objectives]
            [objective]
                condition=win
                description= "Defeat the enemy leader (he’s at 29,16!)"
                [show_if]
                    [have_unit]
                        x,y,canrecruit,side=29,16,yes,2
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                condition=win
                description= "Defeat the enemy leader (he’s at 28,18!)"
                [show_if]
                    [have_unit]
                        x,y,canrecruit,side=28,18,yes,2
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                condition=win
                description= "Defeat the enemy leader (I have no clue where he is)"
                [show_if]
                    [not]
                        [have_unit]
                            canrecruit,side=yes,2
                            [and]
                                x,y=29,16
                                [or]
                                    x,y=28,18
                                [/or]
                            [/and]
                        [/have_unit]
                    [/not]
                [/show_if]
            [/objective]
            [objective]
                condition=lose
                description=$greeting
                [show_if]
                    [not]
                        [variable]
                            name=greeting
                            equals=$empty
                        [/variable]
                    [/not]
                [/show_if]
            [/objective]
        [/objectives]
        [get_global_variable]
            namespace=demo
            side=global
            from_global=villages
            to_local=territory
        [/get_global_variable]
        [if]
            [not]
                [variable]
                    name=territory[0].x
                    equals=$empty
                [/variable]
            [/not]
            [then]
                {FOREACH territory i}
                    [capture_village]
                        side=$territory[$i].owner_side
                        x,y=$territory[$i].x,$territory[$i].y
                    [/capture_village]
                {NEXT i}
            [/then]
        [/if]
        {CLEAR_VARIABLE store}
        {CLEAR_VARIABLE estate}
        {CLEAR_VARIABLE greeting}
        {CLEAR_VARIABLE territory}
        [clear_global_variable]
            namespace=demo.sub.name.space
            side=global
            global=saved_unit
            immediate=yes
        [/clear_global_variable]
        [clear_global_variable]
            namespace=demo.sub.name
            side=global
            global=savings
        [/clear_global_variable]
        [clear_global_variable]
            namespace=demo.sub
            side=global
            global=greeting
        [/clear_global_variable]
        [clear_global_variable]
            namespace=demo
            side=global
            global=villages
        [/clear_global_variable]
    [/event]

    [label]
        x,y=7,5
        text="Memory phone"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=7
            y=5
            side=1
        [/filter]
        [get_global_variable]
            side=global
            namespace="demo.sub"
            from_global=greeting
            to_local=greeting
        [/get_global_variable]
        [if]
            [not]
                [variable]
                    name=greeting
                    equals=$empty
                [/variable]
            [/not]
            [then]
                [message]
                    speaker=narrator
                    message=$greeting
                [/message]
                [message]
                    speaker=narrator
                    message=Is this greeting really okay?
                    [option]
                        message="Yes"
                    [/option]
                    [option]
                        message="No"
                        [command]
                            [message]
                                speaker=narrator
                                message=How would you like to be greeted?
                                [text_input]
                                    variable=greeting
                                [/text_input]
                            [/message]
                            [if]
                                [not]
                                    [variable]
                                        name=greeting
                                        equals=$empty
                                    [/variable]
                                [/not]
                                [then]
                                    [message]
                                        speaker=narrator
                                        message="Excellent! ""$greeting|"" will appear as your failure condition next time you play this scenario."
                                    [/message]
                                [/then]
                            [/if]
                        [/command]
                    [/option]
                [/message]
            [/then]
            [else]
                [message]
                    speaker=narrator
                    message=How would you like to be greeted?
                    [text_input]
                        variable=greeting
                    [/text_input]
                [/message]
                [if]
                    [not]
                        [variable]
                            name=greeting
                            equals=$empty
                        [/variable]
                    [/not]
                    [then]
                        [message]
                            speaker=narrator
                            message=Excellent! $greeting will appear as your failure condition next time you play this scenario.
                        [/message]
                    [/then]
                [/if]
            [/else]
        [/if]
        [set_global_variable]
            side=global
            namespace="demo.sub"
            from_local=greeting
            to_global=greeting
            immediate=yes
        [/set_global_variable]
    [/event]

    [label]
        x,y=9,5
        text="Temporal Clone"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=9
            y=5
            side=1
        [/filter]
        [store_unit]
            [filter]
                x=9
                y=5
                side=1
            [/filter]
            variable=store
            kill=no
            mode=replace
        [/store_unit]
        [set_global_variable]
            side=global
            namespace="demo.sub.name.space"
            from_local=store
            to_global=saved_unit
            immediate=yes
        [/set_global_variable]
        [unstore_unit]
            variable=store
            find_vacant=no
            advance=false
        [/unstore_unit]
        {CLEAR_VARIABLE store}
        [message]
            speaker=unit
            message="I have been saved and will appear here the next time this scenario is started."
        [/message]
    [/event]

    [label]
        x,y=10,6
        text="Bank Teller"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=10
            y=6
            side=1
        [/filter]
        [store_gold]
            side=1
            variable=account
        [/store_gold]
        [set_global_variable]
            side=global
            namespace="demo.sub.name"
            from_local=account
            to_global=savings
            immediate=yes
        [/set_global_variable]
        {CLEAR_VARIABLE account}
        [message]
            speaker=unit
            message="I have deposited our assets into our savings account. We will have access to them on future playthroughs of this scenario."
        [/message]
    [/event]

    [event]
        name=capture
        first_time_only=no
        [filter]
            side=1
        [/filter]
        [store_villages]
            owner_side=1
            variable=empire
        [/store_villages]
        [set_global_variable]
            namespace=demo
            side=global
            from_local=empire
            to_global=villages
            immediate=yes
        [/set_global_variable]
        {CLEAR_VARIABLE empire}
    [/event]

    [event]
        name=moveto
        [filter]
            x=11
            y=6
            side=1
            [not]
                id=Baldras
            [/not]
        [/filter]

        [message]
            speaker=narrator
            message= "You can come if you wish, but the leader is only interested in speaking to Baldras."
            image=wesnoth-icon.png
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            x,y,side=17,7,1
        [/filter]
        [modify_side]
            side=2
            gold=1000
            income=100
            recruit=Orcish Assassin,Orcish Warrior,Orcish Crossbowman,Wolf Rider,Orcish Archer
            [ai]
                time_of_day=morning,afternoon
                aggression=1.0
                caution=0.0
                recruitment_pattern=fighter,fighter,fighter,fighter
                {NO_SCOUTS}
            [/ai]
            [ai]
                time_of_day=dawn,dusk
                aggression=1.0
                caution=0.0
                recruitment_pattern=archer,archer,archer,archer
                {NO_SCOUTS}
            [/ai]
            [ai]
                time_of_day=first_watch,second_watch,underground
                aggression=1.0
                caution=0.0
                recruitment_pattern=scout,scout,scout,scout
                {NO_SCOUTS}
            [/ai]
        [/modify_side]
        {REMOVE_LABEL $x1 $y1}
        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message="Now the orcs will fight until death; nothing shall stop their bloodthirsty warriors!"
        [/message]
        [modify_turns]
            current=5
        [/modify_turns]
        [redraw]
        [/redraw]
        [delay]
            time=400
        [/delay]
        [move_units_fake]
            [fake_unit]
                type="Orcish Slurbow"
                side=2
                x=24,19
                y=6,7
                skip_steps=2
            [/fake_unit]
            [fake_unit]
                type="Orcish Grunt"
                side=2
                x=26,20
                y=5,6
                skip_steps=1
            [/fake_unit]
            [fake_unit]
                type="Orcish Grunt"
                side=2
                x=27,20
                y=11,7
                skip_steps=0
            [/fake_unit]
        [/move_units_fake]
        [unit]
            type="Orcish Slurbow"
            side=2
            x,y=19,7
            facing=sw
        [/unit]
        [unit]
            type="Orcish Grunt"
            side=2
            x,y=20,6
            facing=sw
        [/unit]
        [unit]
            type="Orcish Grunt"
            side=2
            x,y=20,7
            facing=sw
        [/unit]
    [/event]

    [label]
        x,y=14,12
        text="Health insurance"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x,y=14,12
        [/filter]
        {LOG "$unit.name (id $unit.id|) requested health insurance!"}
        {FULL_HEAL (x,y=$x1|,$y1)}
        [object]
            id=brief_health
            silent=yes
            duration=turn
            [filter]
                x,y=14,12
            [/filter]
            [effect]
                apply_to=hitpoints
                increase_total=50%
            [/effect]
        [/object]
    [/event]

    [label]
        x,y=17,7
        text="Open the hell"
    [/label]

    [label]
        x,y=19,9
        text="dialog"
    [/label]

    [label]
        x,y=18,4
        text="Gamestate Inspector"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y,side=18,4,1
        [/filter]

        [inspect]
            name="moveto(18,4)"
        [/inspect]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y,side=19,9,1
        [/filter]

        [message]
            speaker=unit
            message="Hello world"
        [/message]
    [/event]

    [label]
        x,y=20,9
        text="parrot"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y,side=20,9,1
        [/filter]

        [message]
            speaker=unit
            message="Who’s the parrot"
            [text_input]
                text="test"
                variable="parrot"
            [/text_input]
        [/message]

        [message]
            speaker=unit
            message="Set the parrot settings."
            [text_input]
                label="Parrot message"
                variable="text"
            [/text_input]

            [option]
                message="Parrot is in denial"
                [command]
                    [message]
                        speaker=$parrot
                        message="Why are you looking at me, I’m no parrot!!!"
                    [/message]
                    [message]
                        speaker=narrator
                        image=wesnoth-icon.png
                        message="A short time passes..."
                    [/message]
                [/command]
            [/option]

            [option]
                message="Parrot accepted its fate"
            [/option]
        [/message]

        [message]
            speaker=$parrot
            message=$text
        [/message]
    [/event]

    [label]
        x,y=18,8
        text="drink"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y,side=18,8,1
        [/filter]

        [message]
            speaker=unit
            message="Pick your drink"
            [option]
                message="Soda"
            [/option]
            [option]
                message="Water"
                [command]
                    [message]
                        speaker=narrator
                        image=wesnoth-icon.png
                        message="Water is nice"
                    [/message]
                [/command]
            [/option]
        [/message]
    [/event]

    [label]
        x,y=18,10
        text="poison"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y,side=18,10,1
        [/filter]

#wmlindent: start ignoring
        [lua]
            # Uses the special syntax as described at
            # http://www.wesnoth.org/wiki/DescriptionWML
            # The ; doesn't seem to work in the old gui so no need to port it.
            #
            # On 800x480 a scrollbar should appear.
            code = <<
                local ec = wesnoth.current.event_context
                wesnoth.message(string.format("Unit moved from %d,%d to %d,%d", ec.x2, ec.y2, ec.x1, ec.y1))
                local helper = wesnoth.require "lua/helper.lua"
                local result = helper.get_user_choice(
                    { speaker = "unit", message = "Pick your poison" },
                    { "&items/potion-red.png=Something red=Take a sip and enjoy",
                      "*&items/potion-blue.png=Nice blue=Surely you’ll like that one",
                      "&items/potion-yellow.png=<span color='yellow'>Oh noes yellow</span>=Oh I’m sure you’ll love that one",
                      "&scenery/well.png=A nice well=Grab a bucket and fetch some water",
                      "&items/holy-water.png=Oh nice bottle=Feel the divinity",
                      -- Should have an empty first column and a second column on two lines.
                      "=Well a nice and black drink.\nToo dark too see?=Take a sip and pass the bottle along" })
                wesnoth.message(string.format("User selected choice %d.", result))
            >>
        [/lua]
#wmlindent: stop ignoring
    [/event]

    [label]
        x,y=17,9
        text="Manual"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y,side=17,9,1
        [/filter]

#wmlindent: start ignoring
        [message]
            speaker=unit
            message="Battle for Wesnoth User’s Manual
================================

Preface
-------

The Battle for Wesnoth is a turn-based strategy game with a fantasy theme.

Build up a great army, gradually training raw recruits into hardened veterans. In later games, recall your toughest warriors and form a deadly host against whom none can stand! Choose units from a large pool of specialists, and hand pick a force with the right strengths to fight well on different terrains against all manner of opposition.

Wesnoth has many different sagas waiting to be played out. You can battle orcs, undead, and bandits on the marches of the Kingdom of Wesnoth; fight alongside dragons in the lofty peaks, elves in the green reaches of the Aethenwood, dwarves in the great halls of Knalga, or even merfolk in the Bay of Pearls. You can fight to regain the throne of Wesnoth, or use your dread power over the Undead to dominate the land of mortals, or lead your glorious Orcish tribe to victory against the humans who dared despoil your lands.

You will be able to select from among over two hundred unit types (infantry, cavalry, archers, and mages are just the beginning) and fight actions ranging from small-unit ambushes to clashes of vast armies. You can also challenge your friends – or strangers – and fight in epic multi-player fantasy battles.

Battle for Wesnoth is open-source software, and a thriving community of volunteers cooperates to improve the game. You can create your own custom units, write your own scenarios, and even script full-blown campaigns. User-maintained content is available from an add-on server, and the very best of it is incorporated into Battle for Wesnoth’s official releases.

Getting Started
---------------

The World
~~~~~~~~~

The known portion of the Great Continent, on which Wesnoth abides, is generally divided into three areas: the Northlands, which are generally lawless; the kingdom of Wesnoth and its occasional principality, Elensefar; and the domain of the Southwest Elves in the Aethenwood and beyond.

The Kingdom of Wesnoth lies in the center of this land. Its borders are the Great River to the north, the Dulatus Hills in the east and south, the edge of the Aethenwood to the southwest, and the Ocean to the west. Elensefar, a once-province of Wesnoth, is bordered by the Great River to the north, a loosely defined line with Wesnoth to the east, the Bay of Pearls to the south, and the ocean to the west.

The Northlands is the wild country north of the Great River. Various groups of orcs, dwarves, barbarians and elves populate the region.  To the north and east lies the forest of Lintanir, where the great kingdom of the North-Elves keeps to its own mysterious affairs.

Over the land are scattered villages where you can heal your troops and gather the income required to support your army. You will also have to cross mountains and rivers, push through forests, hills and tundra, and cross open grassland. In each of these areas different creatures have adapted to live there and can travel more easily and fight better when they are in familiar terrain.

The Creatures
^^^^^^^^^^^^^

In the world of Wesnoth there dwell humans, elves, dwarves, orcs, drakes, saurians, mermen, nagas, and many other races yet more obscure and wondrous. In accursed lands walk undead and ghosts and specters; monsters lurk in its ruins and dungeons.  Each has adapted to particular terrains. Humans inhabit primarily the temperate grasslands. In the hills, mountains and underground caves orcs and dwarves are most at home. In the forests the elves reign supreme. In the oceans and rivers mermen and nagas dominate.

For game purposes, the races group into factions; for example, orcs often cooperate with trolls, and elves or dwarves with humans. Some other factions reflect divisions within human society — loyalists vs. outlaws, for example. In most campaigns, you will control units drawn a single faction. But sometimes factions make alliances with others, so you may face more than one faction in a scenario."
        [/message]
#wmlindent: stop ignoring
    [/event]

    {PLACE_IMAGE items/book1.png 2 2}
    {PLACE_IMAGE items/book2.png 3 2}
    {PLACE_IMAGE items/book3.png 4 2}
    {PLACE_IMAGE items/book4.png 5 2}
    {PLACE_IMAGE items/flower1.png 2 3}
    {PLACE_IMAGE items/flower2.png 3 3}
    {PLACE_IMAGE items/flower3.png 4 3}
    {PLACE_IMAGE items/flower4.png 5 3}
    {PLACE_IMAGE scenery/rock1.png 2 4}
    {PLACE_IMAGE scenery/rock2.png 3 4}
    {PLACE_IMAGE scenery/rock3.png 4 4}
    {PLACE_IMAGE scenery/rock4.png 5 4}
    {PLACE_IMAGE items/dragonstatue.png 2 5}
    {PLACE_IMAGE items/ornate1.png 3 5}
    {PLACE_IMAGE items/ornate2.png 4 5}
    {PLACE_IMAGE items/barrel.png 5 5}
    {PLACE_IMAGE scenery/monolith1.png 2 6}
    {PLACE_IMAGE scenery/monolith2.png 3 6}
    {PLACE_IMAGE scenery/monolith3.png 4 6}
    {PLACE_IMAGE scenery/monolith4.png 5 6}
    {PLACE_IMAGE scenery/well.png 2 7}
    {PLACE_IMAGE scenery/leanto.png 3 7}
    {PLACE_IMAGE items/ball-green.png 4 7}
    {PLACE_IMAGE items/ball-blue.png 5 7}
    {PLACE_IMAGE items/box.png 2 8}
    {PLACE_IMAGE scenery/well.png 10 5}

    {OBJ_RING_REGENERATION 10 4 OBJ1}
    {OBJ_RING_REGENERATION 10 40 OBJ1}
    {OBJ_RING_SLOW 11 4 OBJ2}
    {OBJ_POTION_HEALING 12 4 OBJ3}
    {OBJ_POTION_POISON 13 5 OBJ4}
    {OBJ_POTION_HOLY 14 4 OBJ5}
    {OBJ_POTION_STRONG 15 4 OBJ6}
    {OBJ_POTION_DECAY 11 5 OBJ7}
    {OBJ_TRIDENT_STORM 12 5 OBJ8}
    #{OBJ_SWORD_FIRE 13 5 OBJ9}
    #{OBJ_SCEPTRE_FIRE 14 5 OBJ10}

    [event]
        name=moveto
        [filter]
            side=1
        [/filter]

        [modify_side]
            side=1
#wmlindent: start ignoring
            shroud_data="|111111111111
|1111111111111
|1111111111111
|11111111111111
|11111111111111
|001111111111111
|111111111111111
|1111111111111111
|111111111111111
|1111111111111111
|1111111111111111
|11111111111111111
|11111111111111111
|11111111111111111
|1111111111111111
|1111111111111111
|111111111111111
|111111111111111
|11111111111111
|11111111111111
|1111111111111
|
|
|
|
|
|
|
|
|
|
|
|00000000000001111111
|000000000000011111111
|00000000000001111111
|000000000000000111111
|00000000000000011111
"
#wmlindent: stop ignoring
        [/modify_side]
    [/event]

    [item]
        x,y=8,16
        image="units/merfolk/warrior.png~BLIT(items/cage.png)"
    [/item]
    [label]
        x,y=8,16
        text="Local ToD item test"
    [/label]

    [item]
        x,y=9,1
        # This doesn't work, image doesn't do animation
        #image="scenery/fire1.png~CS(0,0,50):150,scenery/fire2.png~CS(0,0,50):150,scenery/fire3.png~CS(0,0,50):150,scenery/fire4.png~CS(0,0,50):150,scenery/fire5.png~CS(0,0,50):150,scenery/fire6.png~CS(0,0,50):150,scenery/fire7.png~CS(0,0,50):150,scenery/fire8.png~CS(0,0,50):150"
        image="scenery/fire1.png~CS(0,0,50)"
    [/item]
    [item]
        x,y=11,1
        halo="scenery/fire1.png~CS(0,0,50):150,scenery/fire2.png~CS(0,0,50):150,scenery/fire3.png~CS(0,0,50):150,scenery/fire4.png~CS(0,0,50):150,scenery/fire5.png~CS(0,0,50):150,scenery/fire6.png~CS(0,0,50):150,scenery/fire7.png~CS(0,0,50):150,scenery/fire8.png~CS(0,0,50):150"
    [/item]

    [item]
        x,y=8,8
        image="items/orcish-flag.png"
    [/item]
    [label]
        x,y=8,8
        text="Northerners unleashed!"
    [/label]

    [item]
        x,y=10,10
        halo="scenery/fire1.png:150,scenery/fire2.png:150,scenery/fire3.png:150,scenery/fire4.png:150,scenery/fire5.png:150,scenery/fire6.png:150,scenery/fire7.png:150,scenery/fire8.png:150"
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=8
            y=8
        [/filter]
        [terrain]
            x=28,30,29
            y=15,15,17
            terrain=Ch
        [/terrain]

        {VARIABLE_OP xx1 rand 10..20}
        {VARIABLE_OP yy1 rand 10..17}

        [unit]
            side=2
            x,y="$xx1","$yy1"
            type="Orcish Warlord"
            id="Bozo"
            generate_name=yes
        [/unit]

        [message]
            speaker="Bozo"
            message="Mwahahahahah! I appeared at $xx1, $yy1!"
        [/message]
    [/event]

    [item]
        x,y=4,4
        image="items/orcish-flag.png"
    [/item]
    [label]
        x,y=10,9
        text="Let’s fight"
        tooltip="Trigger attack animation."
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=10
            y=9
            side=1
        [/filter]
        # Check than [delay] does not cause [animate_unit] to skip the animation.
        [delay]
            time=400
        [/delay]
        [animate_unit]
            flag=attack
            hits=hit
            [primary_attack]
            [/primary_attack]
        [/animate_unit]
    [/event]
    [label]
        x,y=4,4
        text="Open, Sesame!"
    [/label]
    [label]
        x,y=5,8
        text="Let there be fog!"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=5
            y=8
            side=1
        [/filter]
        [store_side]
            side=1
            variable=side1_store
        [/store_side]
        [if]
            [variable]
                name=side1_store.fog
                equals="no"
            [/variable]
            [then]
                [modify_side]
                    side=1
                    fog=yes
                [/modify_side]
                [redraw][/redraw]
                [label]
                    x,y=5,8
                    text="Torches, attack!"
                [/label]
            [/then]
            [else]
                [modify_side]
                    side=1
                    fog=no
                [/modify_side]
                [redraw][/redraw]
                [label]
                    x,y=5,8
                    text="Let there be fog!"
                [/label]
            [/else]
        [/if]
        {CLEAR_VARIABLE side1_store}
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=4
            y=4
        [/filter]
        [terrain]
            x=1,2
            y=2,2
            terrain=Re
        [/terrain]
        [label]
            x,y=2,2
            text="Math test"
        [/label]
        [event]
            name=moveto
            first_time_only=no
            [filter]
                side=1
                x,y=2,2
            [/filter]
            [message]
                speaker=narrator
                image=wesnoth-icon.png
                message="Enter a number."
                [text_input]
                    variable=number
                    text=0
                [/text_input]
            [/message]
            [message]
                speaker=narrator
                message="What should we do with the number $number|?"
                [option]
                    message="Round it"
                    [command]
                        [message]
                            speaker=narrator
                            image=wesnoth-icon.png
                            message="How should we round $number|?
`(any integer)
`ceil
`floor"
                            [text_input]
                                variable=round
                            [/text_input]
                        [/message]
                        {VARIABLE rounded $number}
                        [set_variable]
                            name=rounded
                            round=$round
                        [/set_variable]
                        [message]
                            speaker=narrator
                            image=wesnoth-icon.png
                            message="Rounding $number| to $round| results in $rounded|."
                        [/message]
                    [/command]
                [/option]
                [option]
                    message="Add something"
                    [command]
                        [message]
                            speaker=narrator
                            [text_input]
                                label="Amount to add"
                                variable=amount
                            [/text_input]
                        [/message]
                        {VARIABLE total $number}
                        [set_variable]
                            name=total
                            add=$amount
                        [/set_variable]
                        [message]
                            speaker=narrator
                            message="Adding $amount| to $number| results in $total|."
                        [/message]
                    [/command]
                [/option]
                [option]
                    message="Multiply"
                    [command]
                        [message]
                            speaker=narrator
                            [text_input]
                                label="Amount to multiply"
                                variable=amount
                            [/text_input]
                        [/message]
                        {VARIABLE total $number}
                        [set_variable]
                            name=total
                            multiply=$amount
                        [/set_variable]
                        [message]
                            speaker=narrator
                            message="$number| * $amount| = $total|."
                        [/message]
                    [/command]
                [/option]
                [option]
                    message="Divide by something"
                    [command]
                        [message]
                            speaker=narrator
                            [text_input]
                                label="Divisor"
                                variable=divisor
                            [/text_input]
                        [/message]
                        {VARIABLE total $number}
                        [set_variable]
                            name=total
                            divide=$divisor
                        [/set_variable]
                        [message]
                            speaker=narrator
                            message="Dividing $number| by $divisor| results in $total|."
                        [/message]
                    [/command]
                [/option]
                [option]
                    message="Modulo"
                    [command]
                        [message]
                            speaker=narrator
                            [text_input]
                                label="Modulo"
                                variable=modulo
                            [/text_input]
                        [/message]
                        {VARIABLE total $number}
                        [set_variable]
                            name=total
                            modulo=$modulo
                        [/set_variable]
                        [message]
                            speaker=narrator
                            message="$number| % $modulo| = $total|."
                        [/message]
                    [/command]
                [/option]
                [option]
                    message="ints&amp;floats"
                    [command]
                        [set_variable]
                            name=int
                            ipart=$number
                        [/set_variable]
                        {VARIABLE_OP float fpart $number}
                        [message]
                            speaker=narrator
                            message="$number| = $int| + $float|"
                        [/message]
                    [/command]
                [/option]
            [/message]
        [/event]
        [label]
            x,y=1,2
            text="Crash test"
        [/label]
        [event]
            name=moveto
            [filter]
                x,y=1,2
            [/filter]
            {VARIABLE_OP unset0 round 0}
            {VARIABLE_OP unset1 multiply 5}
            {VARIABLE_OP unset2 add 3}
            {VARIABLE_OP unset3 fpart unset4}
            {VARIABLE_OP unset5 value 3}
            {VARIABLE_OP unset6 string_length unset7}
            {VARIABLE new_var "$($unset_var1+$unset_var2)"}
            {VARIABLE new_var "$($unset_var1/$unset_var2)"}
            {VARIABLE new_var "$($unset_var1*$unset_var2)"}
        [/event]
    [/event]

    {PLACE_IMAGE "units/human-outlaws/poacher.png~TC(2,magenta)" 20 14}
    {PLACE_IMAGE items/cage.png 20 14}

    [item]
        x,y=8,5
        image="items/orcish-flag.png"
    [/item]
    [label]
        x,y=8,5
        text="Reveal the Way"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=8
            y=5
        [/filter]
        [remove_shroud]
            side=1
            x="0-38"
            y="0-20"
        [/remove_shroud]
    [/event]

    [item]
        x,y=12,6
        image="terrain/color-hex.png~RC(red>purple)~RC(blue>black)"
    [/item]
    [label]
        x,y=12,6
        text="change coloring"
    [/label]

    [color_range]
        id=blonde
        rgb=255,255,0,255,255,128,0,0,0
    [/color_range]
    [color_palette]
        thief=133,167,202,73,102,151,215,240,240,185,206,228,41,61,95,97,124,171
    [/color_palette]
    [event]
        name=prerecruit
        first_time_only=no
        [filter]
            type="Thief"
        [/filter]
        {RANDOM "RC(thief>red)","RC(thief>green)","RC(thief>blue)","RC(thief>blonde)","RC(thief>mauve_troll)","NOP()"}
        [object]
            silent=yes
            [effect]
                apply_to=image_mod
                replace=$random
            [/effect]
        [/object]
    [/event]

    [color_range]
        id=mauve_troll
        rgb=ED6F9B,C63567,380113
    [/color_range]
    [color_range]
        id=aqua_troll
        rgb=7AA09A,3B765F,002121
    [/color_range]
    [color_range]
        id=green_troll
        rgb=869280,466546,001715
    [/color_range]
    [color_range]
        id=grey_troll
        rgb=7E808B,3E5451,00101A
    [/color_range]

    [color_palette]
        troll_skin=A8A8A8,747F73,616153,374336,172830,9A9A9A,999999,596F60,596E5F,4E4F3F,4E5040,4D4F3F,1E3325,1F3325,001B22,001A21
    [/color_palette]

    [event]
        name=prerecruit
        first_time_only=no
        [filter]
            type="Troll Whelp"
        [/filter]

        [fire_event]
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
            name=apply_troll_skin
        [/fire_event]
    [/event]

    [event]
        name=apply_troll_skin
        first_time_only=no
        {RANDOM "RC(troll_skin>mauve_troll)","RC(troll_skin>aqua_troll)","RC(troll_skin>aqua_troll)","RC(troll_skin>green_troll)","RC(troll_skin>grey_troll)","NOP()"}
        [object]
            silent=yes
            [filter]
                x=$x1
                y=$y1
            [/filter]
            [effect]
                apply_to=image_mod
                replace=$random
            [/effect]
        [/object]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=12
            y=6
            type="Thief"
        [/filter]
        [object]
            id=bleach
            name= "Potion of bleach"
            image=items/potion-red.png
            duration=scenario
            description="Oooh tingly!!!"
            [effect]
                apply_to=image_mod
                add="RC(thief>blonde)"

                [color_palette]
                    thief=133,167,202,73,102,151,215,240,240,185,206,228,41,61,95,97,124,171
                [/color_palette]
            [/effect]
        [/object]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=12
            y=6
            [not]
                type="Thief"
            [/not]
        [/filter]
        [message]
            speaker=narrator
            image=portraits/elves/captain.png
            message="Send me a thief to spy on the blondes"
        [/message]
    [/event]

    [item]
        x,y=8,7
        image="items/chest-plain-closed.png"
    [/item]
    [label]
        x,y=8,7
        text="BOOM!"
    [/label]

    [event]
        name="moveto"
        first_time_only=no
        [filter]
            x,y=8,7
        [/filter]
        [terrain]
            x="7,9"
            y="7,7"
            terrain="Gg"
        [/terrain]
    [/event]

    [item]
        x,y=9,3
        image="items/gohere.png"
    [/item]
    [label]
        x,y=9,3
        text="Win"
    [/label]
    [label]
        x,y=7,3
        text="Timeshift"
    [/label]

    [label]
        x,y=14,9
        text="The silly dance"
    [/label]
    [event]
        name="moveto"
        first_time_only=no
        [filter]
            x,y=14,9
        [/filter]
        [animate_unit]
        [/animate_unit]
        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name="moveto"
        first_time_only=no
        [filter]
            x,y=9,3
        [/filter]
        {VARIABLE endlevel_test.result "victory"}
        {VARIABLE endlevel_test.bonus "yes"}
        [insert_tag]
            name=endlevel
            variable=endlevel_test
        [/insert_tag]
    [/event]
    [event]
        name="moveto"
        first_time_only=no
        [filter]
            x,y=7,3
        [/filter]
        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message="Message 1 of 2: prepare for timeshift"
        [/message]
        [end_turn]
        [/end_turn]
        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message="Message 2 of 2: timeshift imminent"
        [/message]
    [/event]

    [event]
        name=start

        [unit]
            side=1
            x,y="recall","recall"
            type=Lich
        [/unit]

        [unit]
            side=1
            x,y="recall","recall"
            type=Arch Mage
        [/unit]

        [unit]
            side=1
            x,y="recall","recall"
            type=Ancient Wose
        [/unit]

        [unit]
            side=1
            x,y="recall","recall"
            type=Fire Dragon
        [/unit]

        [lua]
            code=<<
                wesnoth.put_recall_unit { type = "Elvish Lady" }
                local u = wesnoth.get_recall_units()[2]
                local l = wesnoth.get_units { side = 1, canrecruit = true }[1]
                local x, y = wesnoth.find_vacant_tile(l.x, l.y, u)
                u.side = 3
                wesnoth.put_unit(u, x, y)
                local ul = wesnoth.get_recall_units()
                local t = {}
                for i,u in ipairs(ul) do table.insert(t, u.type) end
                wesnoth.message(string.format("Recall list: %s", table.concat(t, ',')))
            >>
        [/lua]
    [/event]

    [label]
        x,y=15,15
        text="This is not a forest"
    [/label]

    [label]
        x,y=4,10
        text="This label is not immutable"
        immutable="no"
    [/label]

    [label]
        x,y = 25,6
        text = "Let it snow"
    [/label]

    [event]
        # When moving to the specified coordinates,
        # the area will be transformed to a snow landscape,
        # but the water area should remain as is.
        name="moveto"
        first_time_only=yes
        [filter]
            x,y=25,6
        [/filter]

        [terrain_mask]
            x,y=20,1
            border=no
#wmlindent: start ignoring
            mask="
_s, _s, _s, _s, Aa, Aa, _s, _s, _s, _s
_s, _s, _s, Aa, Aa, Aa, Aa, _s, _s, _s
_s, _s, Aa, Aa, Aa, Aa, Aa, Aa, _s, _s
_s, Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa, _s
Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa
Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa
_s, Aa, Aa, Aa, Aa, Aa, Aa, Aa, Aa, _s
_s, _s, Aa, Aa, Aa, Aa, Aa, Aa, _s, _s
_s, _s, _s, Aa, Aa, Aa, Aa, _s, _s, _s
_s, _s, _s, _s, Aa, Aa, _s, _s, _s, _s
"
#wmlindent: stop ignoring
            [rule]
                old=Gg^Vh
                new=Aa
                terrain=Aa^Vha
            [/rule]
            [rule]
                old=Gs^Fp
                new=Aa
                terrain=Aa^Fpa
            [/rule]
            [rule]
                old=Hh
                new=Aa
                terrain=Hh
            [/rule]
            [rule]
                old=Gg, Re, Gg^Efm
                new=Aa
                # Don't specify terrain and it just uses the new terrain
            [/rule]
            # default: Will match everything, since 'old' and 'new' aren't specified.
            # Set 'use_old=yes' to signal no change.
            [rule]
                use_old=yes
            [/rule]
        [/terrain_mask]
    [/event]

    [label]
        x,y = 9,13
        text = "Plant palms"
    [/label]

    [event]
        # Replace all trees with tropic forest but leave the base terrain intact
        name="moveto"
        first_time_only=yes
        [filter]
            x,y=9,13
        [/filter]

        [terrain_mask]
            x,y=8,11
            border=no
#wmlindent: start ignoring
            mask="
^Ft, ^Ft, ^Ft, ^Ft
^Ft, ^Ft, ^Ft, ^Ft
^Ft, ^Ft, ^Ft, ^Ft
^Ft, ^Ft, ^Ft, ^Ft
"
#wmlindent: stop ignoring
            [rule]
                old=*^F*
                layer=overlay
            [/rule]
            # default: Will match everything, since 'old' and 'new' aren't specified.
            # Set 'use_old=yes' to signal no change.
            [rule]
                use_old=yes
            [/rule]
        [/terrain_mask]
        [terrain]
            x=12
            y=12
            terrain=Aa^Ft
            layer=overlay
        [/terrain]
    [/event]

    [label]
        x,y = 10,13
        text = "Flood"
    [/label]
    [event]
        # replace the base terrain while leaving the overlay intact
        name="moveto"
        first_time_only=yes
        [filter]
            x,y=10,13
        [/filter]

        [terrain_mask]
            x,y=8,11
            border=no
#wmlindent: start ignoring
            mask="
Ww, Ww, Ww, Ww
Ww, Ww, Ww, Ww
Ww, Ww, Ww, Ww
Ww, Ww, Ww, Ww
"
#wmlindent: stop ignoring
            [rule]
                old=*^Ve*
                layer=base
            [/rule]
            [rule]
                layer=base
                replace_if_failed=true  # if just replacing the base failed, replace the whole terrain
                # this will make the human village disappear.
            [/rule]
            # default: Will match everything, since 'old' and 'new' aren't specified.
            # Set 'use_old=yes' to signal no change.
            [rule]
                use_old=yes
            [/rule]
        [/terrain_mask]
        [terrain]
            x=12
            y=12
            terrain=Ds
            layer=base
        [/terrain]

        [label]
            x,y = 11,14
            text = "Sunken"
        [/label]
        [label]
            x,y = 10,14
            text = "Still there"
        [/label]
    [/event]

    [event]
        name=moveto

        [filter]
            [filter_location]
                area="test_area"
            [/filter_location]
        [/filter]

        [message]
            speaker=unit
            message="You entered a different time Zone"
        [/message]
    [/event]

    [event]
        name=start
        [set_menu_item]
            id=test0
            description="Perform Calculation"
            [filter_location]
                [filter]
                    has_weapon=missile
                [/filter]
            [/filter_location]
            [command]
                [message]
                    speaker=unit
                    message="I will prepare the incantation; what dost thou desire to know?"
                    [text_input]
                        label="Formula="
                        variable="formula"
                    [/text_input]
                [/message]
                [message]
                    speaker=narrator
#wmlindent: start ignoring
                    message="Formula:
<span color='green'>    $formula</span>
Result:
<span color='red'>    $(debug_print( 'Result: ', ($formula) ))</span>
"
#wmlindent: stop ignoring
                [/message]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            id=test1
            description="Summon Troll"
            [show_if]
                [not]
                    [have_unit]
                        x,y=$x1,$y1
                    [/have_unit]
                [/not]
            [/show_if]
            [filter_location]
            [/filter_location]
            [command]
                {NAMED_LOYAL_UNIT $side_number (Troll) $x1 $y1 (MagicTroll) ("Magic Troll")}
                [fire_event]
                    name=apply_troll_skin
                    [primary_unit]
                        x=$x1
                        y=$y1
                    [/primary_unit]
                [/fire_event]
                [sound]
                    name=magic-holy-miss-3.ogg
                [/sound]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            id=test2
            image="buttons/WML-custom.png~BLEND(255,127,0,1.0)"
            description="Dismiss Troll"
            [show_if]
                [have_unit]
                    x,y=$x1,$y1
                    type=Troll
                    side=$side_number
                [/have_unit]
            [/show_if]
            [command]
                [kill]
                    x,y=$x1,$y1
                    animate=yes
                [/kill]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            id=terraform
            image="buttons/WML-custom.png~BLEND(0,255,127,1.0)"
            description="Identify terrain"
            [filter_location]
                x=4-12
                y=11-14
            [/filter_location]
            [command]
                [store_locations]
                    x,y=$x1,$y1
                    variable=location
                [/store_locations]
                [switch]
                    variable=location.terrain
                    [case]
                        value=Gg,Gt,Gs
                        {VARIABLE type grass}
                    [/case]
                    [case]
                        value=Gg^Fet,Gs^Ft,Gs^Fpa,Ds^Fp,Re^Fp,Gg^Fp
                        {VARIABLE type forest}
                    [/case]
                    [case]
                        value=Ss^Vm,Gg^Vh,Gg^Ve
                        {VARIABLE type village}
                    [/case]
                    [else]
                        {VARIABLE type other}
                    [/else]
                [/switch]
                [message]
                    speaker=narrator
                    image=wesnoth-icon.png
                    message="The current terrain is of type $type"
                [/message]
                {CLEAR_VARIABLE location,type}
            [/command]
        [/set_menu_item]
    [/event]

    [label]
        x,y=10,10
        text="Keep out!!!"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=10, 10
        [/filter]
        [deprecated_message]
            message="Moving to this location is no longer supported... bye bye"
        [/deprecated_message]
        [kill]
            x,y=10,10
            animate=yes
        [/kill]
    [/event]

    [label]
        x,y=7,10
        text="Earn 100 XP!"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=7
            y=10
        [/filter]
        {VARIABLE_OP unit.experience add 100}
        [unstore_unit]
            variable=unit
            text="100 XP"
            red,green,blue=200,200,50
        [/unstore_unit]
    [/event]

    [label]
        x,y=7,11
        text="test anim"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=7
            y=11
        [/filter]
        [object]
            [effect]
                apply_to=new_attack
                name=ruby of fire
                description="ruby of fire"
                icon=attacks/fireball.png
                type=fire
                range=ranged
                [specials]
                    {WEAPON_SPECIAL_MAGICAL}
                [/specials]
                damage=14
                number=4
            [/effect]

            [effect]
                apply_to=new_animation
                [standing_anim]
                    alpha=0.0~1.0

                    [frame]
                        begin=-2000
                        end=0
                    [/frame]
                [/standing_anim]
            [/effect]
        [/object]
    [/event]

    [label]
        x,y=5,5
        text="promotions"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=5
            y=5
        [/filter]
        {ADVANCE_UNIT x,y=5,5 (Grand Marshal,Yeti,Fire Dragon) }
    [/event]

    [label]
        x,y=5,6
        text="role test"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=5,6
        [/filter]
        [role]
            x,y=5,6
            role=talking_guy
        [/role]
        [message]
            role=talking_guy
            message="I have the role!"
        [/message]
    [/event]

    [label]
        x,y=32,3
        text="forfeit"
    [/label]
    [event]
        name=moveto
        [filter]
            x,y=32,3
        [/filter]
        [event]
            name=new turn
            first_time_only=no
            [end_turn]
            [/end_turn]
        [/event]
        [message]
            side=2
            message="No more turns for you!"
        [/message]
        [end_turn]
        [/end_turn]
    [/event]

    [label]
        x,y=10,2
        text="map change"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=10,2
        [/filter]
        [message]
            side=2
            message="Suddenly, Elves Besieged!"
        [/message]
        [replace_map]
            map="{campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map}"
            shrink=yes
            expand=yes
        [/replace_map]
    [/event]

    [label]
        x,y=10,3
        text="map change2"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=10,3
        [/filter]
        [message]
            side=2
            message="Suddenly, Blackwater Port!"
        [/message]
        [replace_map]
            map="{campaigns/Heir_To_The_Throne/maps/02_Blackwater_Port.map}"
            shrink=yes
            expand=yes
        [/replace_map]
    [/event]

    [label]
        x,y=9,2
        text="map change3"
    [/label]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=9,2
        [/filter]
        [message]
            side=2
            message="Suddenly, Caves!!"
        [/message]
        [replace_map]
            map="{campaigns/Heir_To_The_Throne/maps/15_The_Lost_General.map}"
            shrink=yes
            expand=yes
        [/replace_map]
        [replace_schedule]
            {UNDERGROUND}
            {DEEP_UNDERGROUND}
        [/replace_schedule]
    [/event]

    [label]
        x,y=23,10
        text="livingness"
        tooltip="<b>Tooltip for the livingness label</b>

Moving to this hex will show you: 

<span color='red'><b>not_living</b> Subsums every of the following:</span>
<span color='yellow'><b>unpoisonable</b> - Some more text here.</span>
<span color='brown'><b>undrainable</b></span> - You see that markup works here.
<span color='green'><b>unplagueable</b> - And so on</span>"
    [/label]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x,y=23,10
        [/filter]

        [while]
            [variable]
                name="choice"
                not_equals="done"
            [/variable]
            [do]
                [store_unit]
                    variable="wml_unit"
                    [filter]
                        x=$x1,y=$y1
                    [/filter]
                [/store_unit]
                [message]
                    speaker=narrator
                    message="Unit statuses in WML:

not_living: $wml_unit.status.not_living
unpoisonable: $wml_unit.status.unpoisonable
undrainable: $wml_unit.status.undrainable
unplagueable: $wml_unit.status.unplagueable"
                [/message]
                [lua]
                    code=<<
                        local args = ...
                        local unit = wesnoth.get_unit(args.x1, args.y1)
                        local raw_msg = "Unit statuses in Lua:\n\nnot_living: %s\nunpoisonable: %s\nundrainable: %s\nunplagueable: %s"
                        local msg = string.format(raw_msg, unit.status.not_living, unit.status.unpoisonable, unit.status.undrainable, unit.status.unplagueable)
                        wesnoth.wml_actions.message({speaker = "narrator", message = msg})

                        wesnoth.wml_actions.message({speaker = "narrator", message = "Do you want to change any of that?",
                            { "option", { message = "Flip not_living",
                                { "command", {
                                    { "set_variable", { name = "choice", value = "not_living" } } } } } },
                            { "option", { message = "Flip unpoisonable",
                                { "command", {
                                    { "set_variable", { name = "choice", value = "unpoisonable" } } } } } },
                            { "option", { message = "Flip undrainable",
                                { "command", {
                                    { "set_variable", { name = "choice", value = "undrainable" } } } } } },
                            { "option", { message = "Flip unplagueable",
                                { "command", {
                                    { "set_variable", { name = "choice", value = "unplagueable" } } } } } },
                            { "option", { message = "Nope",
                                { "command", {
                                    { "set_variable", { name = "choice", value = "done" } } } } } }
                        })
                        local choice = wesnoth.get_variable("choice")
                        -- debug :unit will reapply musthave traits, breaking these modifications for undead
                        -- if you want something more permanent, give the unit an object
                        if choice == "not_living" then
                            unit.status.not_living = not unit.status.not_living
                        elseif choice == "unpoisonable" then
                            unit.status.unpoisonable = not unit.status.unpoisonable
                        elseif choice == "undrainable" then
                            unit.status.undrainable = not unit.status.undrainable
                        elseif choice == "unplagueable" then
                            unit.status.unplagueable = not unit.status.unplagueable
                        end
                    >>
                    [args]
                        x1=$x1
                        y1=$y1
                    [/args]
                [/lua]
            [/do]
        [/while]
        {CLEAR_VARIABLE choice}
        {CLEAR_VARIABLE wml_unit}
    [/event]

    # Capture connected villages near 13,2 for team 2
    [event]
        name=prestart

        [store_locations]
            x,y=13,2
            radius=2
            [filter_radius]
                terrain=*^V*
            [/filter_radius]
            variable=temp_villages_area
        [/store_locations]

        {FOREACH temp_villages_area i}
            [capture_village]
                side=2
                x,y=$temp_villages_area[$i].x,$temp_villages_area[$i].y
            [/capture_village]
        {NEXT i}

        # Then put goblins on the northernmost villages

        [store_locations]
            find_in=temp_villages_area
            y=1
            variable=temp_villages_area
        [/store_locations]

        [lua]
            code = <<
                local helper = wesnoth.require "lua/helper.lua"
                for i, v in ipairs(helper.get_variable_proxy_array "temp_villages_area") do
                    wesnoth.put_unit({ type = "Goblin Spearman", side = 2 }, v.x, v.y)
                end
                wesnoth.set_variable "temp_villages_area"
            >>
        [/lua]
    [/event]

    [event]
        name=prestart
        [label]
            x,y=2,11
            text="Fogged oasis"
            visible_in_fog=yes
        [/label]
    [/event]

    [event]
        name=prestart
        [label]
            x,y=2,14
            text="Shrouded label"
            visible_in_shroud=yes
        [/label]
    [/event]
#define DYNAMIC_EVENT_SETUP TYPE VAR
    [set_variables]
        name={VAR}
        [literal]
            name={TYPE}
            [set_variable]
                name={VAR}
                add=1
            [/set_variable]
            [message]
                id=statue
                message="dynamic " + {TYPE} + " event ${VAR}|!"
                [option]
                    message="Continue!"
                [/option]
                [option]
                    message="Stop annoying me..."
                    [command]
                        [set_variables]
                            name={VAR}
                            mode=replace
                            [value]
                                name=moveto
                                [filter]
                                    side=1
                                    [filter_location]
                                        radius=1
                                        [filter]
                                            id=statue
                                        [/filter]
                                    [/filter_location]
                                [/filter]
                                [message]
                                    id=statue
                                    message="No more dynamic events! Sorry..."
                                [/message]
                            [/value]
                        [/set_variables]
                        {MODIFY_UNIT id=statue status.petrified true}
                    [/command]
                [/option]
            [/message]
            [insert_tag]
                name=event
                variable={VAR}
            [/insert_tag]
        [/literal]
    [/set_variables]
#enddef

    [event]
        name=prestart
        [set_menu_item]
            id=dynamic_ev
            description="Start Dynamic Events!"
            [filter_location]
                [filter]
                    id=statue
                [/filter]
            [/filter_location]
            [command]
                {DYNAMIC_EVENT_SETUP "new turn" ev}
                [insert_tag]
                    name=event
                    variable=ev
                [/insert_tag]
                [set_menu_item]
                    id=dynamic_ev
                    [show_if]
                        [not]
                        [/not]
                    [/show_if]
                [/set_menu_item]
                [unpetrify]
                    id=statue
                [/unpetrify]
            [/command]
        [/set_menu_item]

#define SHOW_IMAGE_PATH_TEST FUNCTOR_AND_PARAMS
    [set_variable]
        name=functor
        value={FUNCTOR_AND_PARAMS}
    [/set_variable]
    [scroll_to_unit]
        check_fogged=yes
        id=Urug-Telfar
    [/scroll_to_unit]
    [message]
        speaker=narrator
        image="units/orcs/warlord.png~RC(magenta>blue)~$functor"
        message="I have been affected by the power of $functor|! To the Dark Gods with that wose-born creature!"
        caption=Urug-Telfar
    [/message]
    [scroll_to_unit]
        x,y=$x1,$y1
    [/scroll_to_unit]
    [clear_variable]
        name=functor
    [/clear_variable]
#enddef
        [set_menu_item]
            id=imagepath_tests
            description="Image tricks"
            [filter_location]
                [filter]
                    type=Elvish Shyde,Elvish Druid,Elvish Sorceress,Elvish Enchantress,Elvish Sylph,Elvish Shaman
                [/filter]
            [/filter_location]
            [command]
                [message]
                    speaker=unit
                    message="What glamour should I cast upon our foe?"
                    [option]
                        message="Flip around!"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "FL(horiz,vert)"}
                        [/command]
                    [/option]
                    [option]
                        message="Scale up"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "SCALE(200,200)"}
                        [/command]
                    [/option]
                    [option]
                        message="Scale down"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "SCALE(40,40)"}
                        [/command]
                    [/option]
                    [option]
                        message="Blur 3"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "BL(3)"}
                        [/command]
                    [/option]
                    [option]
                        message="More red!"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "R(255)"}
                        [/command]
                    [/option]
                    [option]
                        message="More green!"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "G(255)"}
                        [/command]
                    [/option]
                    [option]
                        message="More blue!"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "B(255)"}
                        [/command]
                    [/option]
                    [option]
                        message="Black and white!"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "GS()"}
                        [/command]
                    [/option]
                    [option]
                        message="Other team"
                        [command]
                            {VARIABLE_OP team rand 1..9}
                            {SHOW_IMAGE_PATH_TEST "TC($team,magenta)"}
                            {CLEAR_VARIABLE team}
                        [/command]
                    [/option]
                    [option]
                        message="And other team again"
                        [command]
                            {VARIABLE_OP rc rand 1..9}
                            {SHOW_IMAGE_PATH_TEST "RC(magenta>$rc)"}
                            {CLEAR_VARIABLE rc}
                        [/command]
                    [/option]
                    [option]
                        message="Psychedellic!"
                        [command]
                            {SHOW_IMAGE_PATH_TEST "CROP(10,10,50,50)~CS(255,-40,100)~O(50%)~BL(2)~SCALE(125,125)"}
                        [/command]
                    [/option]
                    [option]
                        message="Shrooms!"
                        [command]
                            # Shutz, this sounds like some obscure CPU architecture's data registers
                            {VARIABLE_OP rc   rand 1..9}
                            {VARIABLE_OP cs.r rand 0..255}
                            {VARIABLE_OP cs.g rand 0..255}
                            {VARIABLE_OP cs.b rand 0..255}
                            {VARIABLE_OP op   rand 25%,50%,75%,100%,125%,150%,175%,200%,225%,250%,275%,300%,500%}
                            {VARIABLE_OP bl   rand 1..10}
                            {VARIABLE_OP sc.w rand 50..200}
                            {VARIABLE_OP sc.h rand 50..200}

                            {SHOW_IMAGE_PATH_TEST "RC(magenta>$rc|)~CS($cs.r|,$cs.g|,$cs.b|)~O($op)~BL($bl)~SCALE($sc.w|,$sc.h|)"}

                            {CLEAR_VARIABLE rc,cs,op,bl,sc}
                        [/command]
                    [/option]
                [/message]
            [/command]
        [/set_menu_item]
#undef SHOW_IMAGE_PATH_TEST
    [/event]
    [event]
        #at an attack end, remove the attack: bugs #12428 and #12990
        name=attack end
        first_time_only=no
        [filter_attack]
            range=ranged
        [/filter_attack]
        [filter_second]
            side=2
            canrecruit=yes
        [/filter_second]
        [object]
            [filter]
                x,y=$x1,$y1
            [/filter]
            description="You just lost the attack you used."
            silent=yes
            [effect]
                apply_to=remove_attacks
                range=ranged
            [/effect]
            [then]
                [message]
                    canrecruit,side=yes,2
                    message="Cowards! Fight me in real combat!"
                [/message]
            [/then]
        [/object]
    [/event]
    [event]
        name=prestart
        [unit]
            type=Saurian Soothsayer
            side,x,y=3,30,15
            id=assert
            name="Neutral healer guy"
        [/unit]
        [set_menu_item]
            description = "Menu 1"
            id = "Menu_1"
            [show_if]
                [have_unit]
                    x,y=$x1,$y1
                    side=$side_number
                    [not]
                        [filter_wml]
                            attacks_left=0
                        [/filter_wml]
                    [/not]
                [/have_unit]
            [/show_if]
            [filter_location]
                terrain=C*,C*^*,*^C*,K*,K*^*,*^K*
            [/filter_location]
            [command]
                [message]
                    message = "Menu 1 (only clickable on own units on castle terrain)"
                    x,y = $x1,$y1
                [/message]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            description = "Menu 2"
            id = "Menu_2"
            use_hotkey = no
            [show_if]
                [have_unit]
                    x,y=$x1,$y1
                    side=$side_number
                [/have_unit]
            [/show_if]
            [command]
                [message]
                    message = "Menu 2 (use_hotkey = no, so I cannot assign hotkeys to it.)"
                    x,y = $x1,$y1
                [/message]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            description = "menu 3"
            id = "menu_3"
            [default_hotkey]
                key="f6"
            [/default_hotkey]
            [command]
                [message]
                    message = "menu 3: default hotkey is F6."
                    speaker = narrator
                [/message]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            description = "menu 4"
            id = "menu 4"
            use_hotkey = "only"
            [command]
                [message]
                    message = "menu 4, only acessible via hotkeys"
                    speaker = narrator
                [/message]
            [/command]
        [/set_menu_item]
    [/event]
    [event]
        name=start

        [store_locations]
            x=5-8
            variable=x_locs
        [/store_locations]
        [store_locations]
            x,y=5-8,0-99
            variable=xy_locs
        [/store_locations]
        [set_variable]
            name=x_len
            value=$x_locs.length
        [/set_variable]
        [set_variable]
            name=xy_len
            value=$xy_locs.length
        [/set_variable]

        [if]
            [variable]
                name=x_len
                numerical_not_equals=$xy_len
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    image=wesnoth-icon.png
                    message="Single-dimensional [store_locations] is broken, as $x_len does not equal $xy_len|. See bug #21488"
                [/message]
            [/then]
        [/if]

        {CLEAR_VARIABLE x_locs}
        {CLEAR_VARIABLE xy_locs}
        {CLEAR_VARIABLE x_len}
        {CLEAR_VARIABLE xy_len}
    [/event]
[/test]

[+units]
    [unit_type]
        id=Peasant_unhealable
        [base_unit]
            id=Peasant
        [/base_unit]
        image_icon="misc/key.png"
    [/unit_type]
[/units]

[+language]
    range_very_long= _ "very long"
    type_electrical= _ "electrical"
[/language]

# vim: tabstop=4: shiftwidth=4: expandtab: softtabstop=4: autoindent:
# kate: indent-mode normal; space-indent on;