This file is indexed.

/usr/share/games/wesnoth/1.10/data/campaigns/The_South_Guard/scenarios/06b_The_Long_March.cfg is in wesnoth-1.10-tsg 1:1.10.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
#textdomain wesnoth-tsg
[scenario]
    id=06b_The_Long_March

    name= _ "The Long March"
    next_scenario=07b_Pebbles_in_the_Flood

    {SCENARIO_MUSIC heroes_rite.ogg}
    {EXTRA_SCENARIO_MUSIC the_dangerous_symphony.ogg}

    # Note: the map contains a large grid of roads but only one path through the
    # forest will be picked when the scenario starts. When editing the map, make
    # sure not to create any dead ends in the roads, and preferably also make
    # sure to not have sets of three dirt hexes all adjacent to each other.
    map_data="{campaigns/The_South_Guard/maps/06b_The_Long_March.map}"

    {campaigns/The_South_Guard/utils/sg_deaths.cfg}

    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}
    {DAWN}
    {MORNING}
    {AFTERNOON}

    victory_when_enemies_defeated=no
    {TURNS 30 25 20}

    # The South Guard

    [side]
        side=1
        type=Horseman Commander
        id=Deoran
        name= _ "Deoran"
        unrenamable=yes
        team_name=South_Guard
        user_team_name=_"South Guard"
        controller=human
        {CUSTOM_SG_FLAG}

        fog=yes
        shroud=yes
        share_view=yes
        share_maps=yes

        {GOLD 125 100 80}
        {INCOME 6 4 2}

        canrecruit=yes
        recruit=Bowman, Spearman, Cavalryman, Thug, Footpad
    [/side]

    # We're not using an extra side for the ambusher elves
    # - they will be on the undead side by default (so the undead
    # don't trigger ambushes), then change to the active elven side
    # and are being petrified to prevent any action
    #
    # note: this means that elves can trigger ambushes, which should
    # be treated as if they "ran for reinforcements" - thus these elves
    # switch to their side just as if the player had triggered the ambush
    # (this is a better solution than undead triggering ambushes, and
    # should occur less often)

    # The Undead Hordes (Part II)

    [side]
        side=2
        no_leader=yes

        team_name=undead
        user_team_name=_"Undead"
        controller=ai

        fog=no
        shroud=no

        canrecruit=yes
        [ai]
            aggression=2.0
            grouping=no
            attack_depth=1
            village_value=0
            [target]
                side=1
                value=20
            [/target]
        [/ai]
        {FLAG_VARIANT undead}
    [/side]

    # When discovering an ambusher, the ambusher will be moved to this side so
    # it may move and attack normally

    [side]
        side=3
        no_leader=yes
        team_name=elves
        user_team_name=_"Elves"
        controller=ai

        [ai]
            aggression=0.7
            caution=0.4
            [target]
                side=1
                value=5.0
            [/target]
        [/ai]
        {FLAG_VARIANT long}
    [/side]

    # This prestart event iterates through the labyrinth and picks a random
    # route through it, stores the path in $secret_path, covers everything with
    # forest and then places the ford on the endpoint of the chosen path.
    [event]
        name=prestart

        {VARIABLE previous_path_hex.x 18}
        {VARIABLE previous_path_hex.y 36}
        {VARIABLE new_path_hex.x 18}
        {VARIABLE new_path_hex.y 35}
        {VARIABLE secret_path.x 18}
        {VARIABLE secret_path.y 35}

        [while]
            [variable]
                name=new_path_hex.y
                greater_than=10
            [/variable]

            [do]
                [if]
                    [have_location]
                        terrain=R*

                        [filter_adjacent_location]
                            x,y=$new_path_hex.x,$new_path_hex.y
                            adjacent=sw,s,se
                        [/filter_adjacent_location]

                        [not]
                            x,y=$previous_path_hex.x,$previous_path_hex.y
                        [/not]
                    [/have_location]

                    [then]
                        [store_locations]
                            terrain=R*

                            [filter_adjacent_location]
                                x,y=$new_path_hex.x,$new_path_hex.y
                                adjacent=sw,s,se
                            [/filter_adjacent_location]

                            [not]
                                x,y=$previous_path_hex.x,$previous_path_hex.y
                            [/not]

                            variable=new_road_branches
                        [/store_locations]
                    [/then]

                    [else]
                        [store_locations]
                            terrain=R*

                            [filter_adjacent_location]
                                x,y=$new_path_hex.x,$new_path_hex.y
                                adjacent=nw,n,ne
                            [/filter_adjacent_location]

                            [not]
                                x,y=$previous_path_hex.x,$previous_path_hex.y
                            [/not]

                            variable=new_road_branches
                        [/store_locations]
                    [/else]
                [/if]

                {VARIABLE previous_path_hex.x $new_path_hex.x}
                {VARIABLE previous_path_hex.y $new_path_hex.y}

                [if]
                    [variable]
                        name=new_road_branches.length
                        numerical_equals=1
                    [/variable]

                    [then]
                        {VARIABLE new_path_hex.x $new_road_branches.x}
                        {VARIABLE new_path_hex.y $new_road_branches.y}
                    [/then]

                    [else]
                        [if]
                            [variable]
                                name=new_road_branches.length
                                greater_than=1
                            [/variable]

                            [then]
                                {RANDOM 1..$new_road_branches.length}
                                {VARIABLE_OP random sub 1}

                                {VARIABLE new_path_hex.x $new_road_branches[$random].x}
                                {VARIABLE new_path_hex.y $new_road_branches[$random].y}
                            [/then]
                        [/if]
                    [/else]
                [/if]

                #[item]
                #    x,y=$new_path_hex.x,$new_path_hex.y
                #    image=misc/capture.png
                #[/item]

                [store_locations]
                    x,y=$new_path_hex.x,$new_path_hex.y

                    [or]
                        find_in=secret_path
                    [/or]

                    variable=secret_path
                [/store_locations]
            [/do]
        [/while]

        [store_locations]
            find_in=secret_path

            variable=secret_path_unrevealed
        [/store_locations]

        [store_locations]
            terrain=R*
            y=10-35

            variable=secret_path_to_hide
        [/store_locations]

        {FOREACH secret_path_to_hide i}
            [store_locations]
                terrain=*^F*

                [and]
                    x,y=$secret_path_to_hide[$i].x,$secret_path_to_hide[$i].y
                    radius=1
                [/and]

                variable=adjacent_forests
            [/store_locations]

            {RANDOM "1..$adjacent_forests.length"}
            {VARIABLE_OP random sub 1}

            [terrain]
                x,y=$secret_path_to_hide[$i].x,$secret_path_to_hide[$i].y
                terrain=$adjacent_forests[$random].terrain
            [/terrain]
        {NEXT i}

        {VARIABLE ford_mask_x $new_path_hex.x}
        {VARIABLE_OP ford_mask_x sub 1}

        # This mask creates the ford at the end of the road
        [terrain_mask]
            x=$ford_mask_x
            y=3
            mask="usage=mask
border_size=0

Ww, Wwf, Ww
Ww, Wwf, Ww
Ww, Wwf, Ww
Ww, Wwf, Ww
Ww, Wwf, Ww
Ww, Wwf, Ww
Ww, Wwf, Ww
Ww, Wwf, Ww
"

            [rule]
                old=!,W*
                use_old=yes
            [/rule]
        [/terrain_mask]

        # This mask creates a straight road leading north of the ford
        [terrain_mask]
            x=$ford_mask_x
            y=0
            border=yes
            mask="usage=map
border_size=1

_f, _f, Re, _f
_f, _f, Re, _f
_f, _f, Re, _f
_f, _f, Re, _f
_f, _f, Re, _f
_f, _f, Re, _f
_f, _f, Re, _f
_f, _f, Re, _f
"

            [rule]
                old=W*,D*
                use_old=yes
            [/rule]
        [/terrain_mask]

        {NAMED_GENERIC_UNIT 3 (Naga Warrior) $new_path_hex.x 6 (Fssth) (_"Fssth")} {GUARDIAN}

#ifdef NORMAL
        {NAMED_GENERIC_UNIT 3 (Naga Fighter) $new_path_hex.x 6 (Wizzi) (_"Wizzi")} {GUARDIAN}
#endif

#ifdef HARD
        {NAMED_GENERIC_UNIT 3 (Naga Warrior) $new_path_hex.x 6 (Wizzi) (_"Wizzi")} {GUARDIAN}
#endif

        {CLEAR_VARIABLE new_road_branches,secret_path_to_hide,adjacent_forests}

        {VARIABLE urza_dialogue 0}
    [/event]

    [event]
        name=prestart

#ifdef EASY
        {VARIABLE num_of_ambushers 12}
#endif

#ifdef NORMAL
        {VARIABLE num_of_ambushers 16}
#endif

#ifdef HARD
        {VARIABLE num_of_ambushers 20}
#endif

        # This places a bunch of lvl1 elves along the secret path, the player
        # will probably bump into all of these.
        {SCATTER_UNITS $num_of_ambushers "Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Scout,Elvish Fighter" 3 (
            terrain=*^F*
            x=3-34
            y=13-31

            [filter_adjacent_location]
                find_in=secret_path
            [/filter_adjacent_location]

            [not]
                find_in=secret_path
            [/not]

            [not]
                [filter]
                [/filter]
            [/not]

            [not]
                [filter_adjacent_location]
                    [filter]
                    [/filter]
                [/filter_adjacent_location]
            [/not]
        ) (
            side=2
            generate_name=yes
            random_traits=yes
            upkeep=loyal

            [modifications]
                [object]
                    [effect]
                        apply_to=new_ability

                        [abilities]
                            [hides]
                                id=elvish_ambush
                                affect_self=yes

                                [filter_self]
                                    # only effective as long as the unit
                                    # is on the ambusher side
                                    side=2

                                    [filter_location]
                                        terrain=*^F*
                                    [/filter_location]
                                [/filter_self]
                            [/hides]
                        [/abilities]
                    [/effect]
                [/object]
            [/modifications]
        )}

        # This places lvl2 elves in the forest, away from the secret path. The
        # player will mostly only bump into these if he wanders away from the
        # path, although a few might occasionally be close enough to join an
        # ambush by the lvl1 elves next to the path.
        {SCATTER_UNITS 30 "Elvish Hero,Elvish Captain,Elvish Marksman,Elvish Ranger,Elvish Druid,Elvish Sorceress" 2 (
            terrain=*^F*
            x=3-34
            y=13-31

            [not]
                radius=3
                find_in=secret_path
            [/not]

            [not]
                [filter]
                [/filter]
            [/not]

            [not]
                [filter_adjacent_location]
                    [filter]
                    [/filter]
                [/filter_adjacent_location]
            [/not]
        ) (
            side=2
            generate_name=yes
            random_traits=yes
            upkeep=loyal

            [modifications]
                [object]
                    [effect]
                        apply_to=new_ability

                        [abilities]
                            [hides]
                                id=elvish_ambush
                                affect_self=yes

                                [filter_self]
                                    # only effective as long as the unit
                                    # is on the ambusher side
                                    side=2

                                    [filter_location]
                                        terrain=*^F*
                                    [/filter_location]
                                [/filter_self]
                            [/hides]
                        [/abilities]
                    [/effect]
                [/object]
            [/modifications]
        )}
    [/event]

    [event]
        name=start

        [message]
            speaker=narrator
            message= _ "Deoran and Urza Afalas led their men quickly from Mebrin’s fortress..."
            image=wesnoth-icon.png
        [/message]

        [recall]
            id=Urza Afalas
        [/recall]
        [recall]
            id=Sir Gerrick
        [/recall]
        [recall]
            id=Minister Hylas
        [/recall]
        [recall]
            id=Jarek
        [/recall]

        [message]
            speaker=Deoran
            message= _ "Will this forest ever end? How can we know what path to take?!"
        [/message]
        [message]
            speaker=Urza Afalas
            message= _ "You have to follow me! I have often traveled these woods avoiding the elves with my comrades, and I know a secret path through it."
        [/message]
        [message]
            speaker=Sir Gerrick
            message= _ "Can we trust him? His people are murderers and thieves!"
        [/message]
        [message]
            speaker=Minister Hylas
            message= _ "Do we have any choice? Our food is running out, and it will be winter soon..."
        [/message]
        [message]
            speaker=Minister Hylas
            message= _ "Beware! I sense that there are many undead creatures chasing us. We should move quickly."
        [/message]
        [message]
            speaker=Urza Afalas
            message= _ "Let us go quickly, then. I will show you the way."
        [/message]

        {MOVE_UNIT (id=Urza Afalas) 18 35}

        [message]
            speaker=Urza Afalas
            message= _ "Remember that these woods are crawling with elves, and I don’t think they’ll receive us too kindly. Stay on the path and perhaps we can avoid at least most of them."
        [/message]

        [objectives]
            side=1
            [objective]
                description= _ "Move Deoran through the woods and over the river"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Deoran"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Sir Gerrick"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Minister Hylas"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Urza Afalas"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]

            note= _ "At the start of each turn, Urza Afalas will reveal as much of the secret path as is within his vision range."
        [/objectives]
    [/event]

    # This event stores the vision range of Urza Afalas into
    # $urza_movement_area and then reveals any parts of the secret path within
    # it.
    #
    # Note: the mechanism inside the loop is very fragile and the ordering of
    # the commands is important. Be sure to test thoroughly after making any
    # changes to it.
    [event]
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                id=Urza Afalas
            [/filter]

            kill=no
            variable=stored_Urza_Afalas
        [/store_unit]

        {VARIABLE urza_movement_area.x $stored_Urza_Afalas.x}
        {VARIABLE urza_movement_area.y $stored_Urza_Afalas.y}

        {VARIABLE urza_moves $stored_Urza_Afalas.max_moves}

        [while]
            [variable]
                name=urza_moves
                greater_than=0
            [/variable]

            [do]
                [store_locations]
                    find_in=delayed_2_mp_hexes

                    variable=previous_2_mp_hexes
                [/store_locations]

                [store_locations]
                    terrain=*^F*,Hh,Ss,Ww

                    [filter_adjacent_location]
                        find_in=urza_movement_area
                    [/filter_adjacent_location]

                    [not]
                        find_in=urza_movement_area
                    [/not]

                    [not]
                        find_in=secret_path
                    [/not]

                    [not]
                        find_in=previous_2_mp_hexes
                    [/not]

                    variable=delayed_2_mp_hexes
                [/store_locations]

                [store_locations]
                    find_in=urza_movement_area
                    radius=1

                    [filter_radius]
                        terrain=R*,Gg,C*,K*,*^V*

                        [or]
                            terrain=*^F*
                            find_in=secret_path
                        [/or]
                    [/filter_radius]

                    variable=urza_movement_area
                [/store_locations]

                [store_locations]
                    find_in=urza_movement_area

                    [or]
                        find_in=previous_2_mp_hexes
                    [/or]

                    variable=urza_movement_area
                [/store_locations]

                {CLEAR_VARIABLE previous_2_mp_hexes}

                {VARIABLE_OP urza_moves sub 1}
            [/do]
        [/while]

        # extend the movement area by one to expand the area to represent the
        # vision range instead
        [store_locations]
            find_in=urza_movement_area
            radius=1

            variable=urza_movement_area
        [/store_locations]

        # marks the area visibly on the map, useful for debugging
        #{FOREACH urza_movement_area i}
        #    [label]
        #        x,y=$urza_movement_area[$i].x,$urza_movement_area[$i].y
        #        text=$turn_number
        #    [/label]
        #{NEXT i}

        # store all yet unrevealed hidden road hexes within the area and reveal
        # them
        [store_locations]
            [not]
                terrain=R*
            [/not]
            y=10-35
            find_in=urza_movement_area

            [and]
                find_in=secret_path
            [/and]

            variable=secret_path_to_reveal
        [/store_locations]

        [store_locations]
            find_in=secret_path_unrevealed

            [not]
                find_in=secret_path_to_reveal
            [/not]

            variable=secret_path_unrevealed
        [/store_locations]

        [scroll_to_unit]
            id=Urza Afalas
        [/scroll_to_unit]

        {FOREACH secret_path_to_reveal i}
            [terrain]
                x,y=$secret_path_to_reveal[$i].x,$secret_path_to_reveal[$i].y
                terrain=Re
            [/terrain]
        {NEXT i}

        [redraw]
        [/redraw]

        # This makes Urza Afalas say different things based on how much of the
        # path is still unrevealed
        [if]
            [variable]
                name=secret_path_to_reveal.length
                greater_than=0
            [/variable]

            [variable]
                name=turn_number
                greater_than=1
            [/variable]

            [variable]
                name=urza_dialogue
                less_than=4
            [/variable]

            [then]
                [if]
                    [variable]
                        name=secret_path_unrevealed.length
                        less_than=10
                    [/variable]

                    [variable]
                        name=urza_dialogue
                        equals=3
                    [/variable]

                    [then]
                        [message]
                            speaker=Urza Afalas
                            message= _ "Just a little further!"
                        [/message]
                    [/then]

                    [else]
                        [if]
                            [variable]
                                name=secret_path_unrevealed.length
                                less_than=20
                            [/variable]

                            [variable]
                                name=urza_dialogue
                                equals=2
                            [/variable]

                            [then]
                                [message]
                                    speaker=Urza Afalas
                                    message= _ "We’re almost there!"
                                [/message]
                            [/then]

                            [else]
                                [if]
                                    [variable]
                                        name=secret_path_unrevealed.length
                                        less_than=30
                                    [/variable]

                                    [variable]
                                        name=urza_dialogue
                                        equals=1
                                    [/variable]

                                    [then]
                                        [message]
                                            speaker=Urza Afalas
                                            message= _ "Come on! Hurry!"
                                        [/message]
                                    [/then]

                                    [else]
                                        [if]
                                            [variable]
                                                name=secret_path_unrevealed.length
                                                less_than=40
                                            [/variable]

                                            [variable]
                                                name=urza_dialogue
                                                equals=0
                                            [/variable]

                                            [then]
                                                [message]
                                                    speaker=Urza Afalas
                                                    message= _ "Keep moving!"
                                                [/message]
                                            [/then]
                                        [/if]
                                    [/else]
                                [/if]
                            [/else]
                        [/if]
                    [/else]
                [/if]

                {VARIABLE_OP urza_dialogue add 1}
            [/then]
        [/if]

        [if]
            [have_location]
                y=10
                find_in=secret_path_to_reveal
            [/have_location]

            [then]
                [message]
                    speaker=Urza Afalas
                    message= _ "From here you can see the banks of the river! Across it we will find the sun again, and an end to these cursed trees!"
                [/message]
            [/then]
        [/if]

        {CLEAR_VARIABLE urza_movement_area,delayed_2_mp_hexes,previous_2_mp_hexes,secret_path_to_reveal,stored_Urza_Afalas}
    [/event]

    [event]
        name=turn refresh
        first_time_only=no

        [if]
            [variable]
                name=side_number
                equals=2
            [/variable]

            [then]
                {MODIFY_UNIT side,race=2,elf moves 0}
            [/then]
        [/if]
    [/event]

    [event]
        name=moveto

        [filter]
            side=1

            [filter_adjacent]
                side=2
                race=elf
            [/filter_adjacent]
        [/filter]

        {MODIFY_UNIT (
            side=2
            race=elf
            [filter_location]
                x,y=$x1,$y1
                radius=4
            [/filter_location]
        ) side 3}

        [redraw][/redraw]

        [message]
            race=elf
            [filter_location]
                [filter_adjacent_location]
                    x,y=$x1,$y1
                [/filter_adjacent_location]
            [/filter_location]
            message= _"You humans have kidnapped Mebrin the Sage. You will pay for your crimes."
        [/message]
        [message]
            id=Deoran
            message= _"Your sage Mebrin is the criminal. He practices necromancy and now commands an army of undead. By the laws of Wesnoth, the punishment for his crimes is death!"
        [/message]
        [message]
            race=elf
            [filter_location]
                [filter_adjacent_location]
                    x,y=$x1,$y1
                [/filter_adjacent_location]
            [/filter_location]
            message= _"It is you who is a criminal and who is in a company of criminals. We will not let you kill Mebrin!"
        [/message]

        [event]
            name=moveto
            delayed_variable_substitution=yes

            [filter]
                side=1

                [filter_adjacent]
                    side=2
                    race=elf
                [/filter_adjacent]
            [/filter]

            {MODIFY_UNIT (
                side=2
                race=elf
                [filter_location]
                    x,y=$x1,$y1
                    radius=4
                [/filter_location]
            ) side 3}

            [redraw][/redraw]

            [message]
                race=elf
                [filter_location]
                    [filter_adjacent_location]
                        x,y=$x1,$y1
                    [/filter_adjacent_location]
                [/filter_location]
                message= _ "We cannot allow you bandits and criminals to pass through our lands!"
            [/message]
            [message]
                speaker=Urza Afalas
                message= _ "We wish only to return to our homes!"
            [/message]
            [message]
                race=elf
                [filter_location]
                    [filter_adjacent_location]
                        x,y=$x1,$y1
                    [/filter_adjacent_location]
                [/filter_location]
                message= _ "Nevertheless, we will have vengeance for Mebrin!!"
            [/message]

            [event]
                name=moveto
                delayed_variable_substitution=yes

                [filter]
                    side=1

                    [filter_adjacent]
                        side=2
                        race=elf
                    [/filter_adjacent]
                [/filter]

                {MODIFY_UNIT (
                    side=2
                    race=elf
                    [filter_location]
                        x,y=$x1,$y1
                        radius=4
                    [/filter_location]
                ) side 3}

                [redraw][/redraw]

                [message]
                    race=elf
                    [filter_location]
                        [filter_adjacent_location]
                            x,y=$x1,$y1
                        [/filter_adjacent_location]
                    [/filter_location]
                    message= _ "Get them!"
                [/message]

                [event]
                    name=moveto
                    first_time_only=no
                    delayed_variable_substitution=yes

                    [filter]
                        side=1

                        [filter_adjacent]
                            side=2
                            race=elf
                        [/filter_adjacent]
                    [/filter]

                    {MODIFY_UNIT (
                        side=2
                        race=elf
                        [filter_location]
                            x,y=$x1,$y1
                            radius=4
                        [/filter_location]
                    ) side 3}

                    [redraw][/redraw]
                [/event]
            [/event]
        [/event]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            side=3

            [filter_adjacent]
                side=2
                race=elf
            [/filter_adjacent]
        [/filter]

        {MODIFY_UNIT (
            side=2
            race=elf
            [filter_adjacent]
                x,y=$x1,$y1
            [/filter_adjacent]
        ) side 3}

        [redraw][/redraw]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [if]
            [variable]
                name=turn_number
                greater_than=1
            [/variable]

            [then]
                {VARIABLE max_undead_spawns $turn_number}
                {VARIABLE_OP max_undead_spawns sub 2}

                [if]
                    [variable]
                        name=max_undead_spawns
                        greater_than=4
                    [/variable]

                    [then]
                        {VARIABLE max_undead_spawns 5}
                    [/then]

                    [else]
                        {VARIABLE max_undead_spawns $turn_number}
                    [/else]
                [/if]

                {VARIABLE got_a_quick_one_this_turn no}

                {VARIABLE i 0}
                [while]
                    [variable]
                        name=i
                        less_than=$max_undead_spawns
                    [/variable]

                    [do]
                        {VARIABLE_OP undead_spawn_x rand "11..22"}

                        # If there's already been a quick unit (ghost or bat)
                        # spawned this turn, don't make any more
                        [if]
                            [variable]
                                name=got_a_quick_one_this_turn
                                equals=yes
                            [/variable]

                            [then]
#ifdef EASY
                                {VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Necrophage"}
#else
                                {VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Deathblade,Necrophage"}
#endif
                            [/then]

                            [else]
#ifdef EASY
                                {VARIABLE_OP undead_spawn_type rand "Ghost,Bone Shooter,Revenant,Blood Bat,Necrophage"}
#else
                                {VARIABLE_OP undead_spawn_type rand "Wraith,Bone Shooter,Revenant,Deathblade,Blood Bat,Dread Bat,Necrophage"}
#endif
                            [/else]
                        [/if]

                        # This checks whether the current spawn is going to be a
                        # "quick" one, so on the next repeat the above [if] will
                        # know whether we've already gotten a quick one this turn
                        {VARIABLE quick_spawn_types "Ghost,Wraith,Blood Bat,Dread Bat"}
                        [if]
                            [variable]
                                name=quick_spawn_types
                                contains=$undead_spawn_type
                            [/variable]

                            [then]
                                {VARIABLE got_a_quick_one_this_turn yes}
                            [/then]
                        [/if]

                        [unit]
                            side=2
                            type=$undead_spawn_type
                            x=$undead_spawn_x
                            y=45
                        [/unit]

                        {VARIABLE_OP i add 1}
                    [/do]
                [/while]

                {CLEAR_VARIABLE i,max_undead_spawns,got_a_quick_one_this_turn,undead_spawn_type,undead_spawn_x}
            [/then]
        [/if]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Urza Afalas
        [/filter]
        [message]
            speaker=unit
            message= _ "Now I pay for my crimes. But how many others will also suffer for them?"
        [/message]
        [kill]
            x,y=$x1,$y1
            animate=yes
        [/kill]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    # Deoran exits the forest.

    [event]
        name=moveto
        [filter]
            id=Deoran
            y=1-6

            [filter_location]
                [not]
                    terrain=W*
                [/not]
            [/filter_location]
        [/filter]
        [message]
            speaker=Deoran
            message= _ "Thank heaven we have escaped that awful forest!"
        [/message]
        [message]
            speaker=Sir Gerrick
            message= _ "Indeed, Afalas, you’ve earned my trust today."
        [/message]
        [message]
            speaker=Urza Afalas
            message= _ "I can only hope for mercy when I return to Westin."
        [/message]

        [message]
            speaker=narrator
            message= _ "But there was a dark cloud looming behind Deoran and his men..."
            image=wesnoth-icon.png
        [/message]

        {CLEAR_VARIABLE secret_path}

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
[/scenario]