#textdomain wesnoth-trow
[scenario]
    id=17d_Cursed_Isle
    name= _ "Cursed Isle"
    next_scenario=16_The_Kalian
    victory_when_enemies_defeated=no
    map_data="{campaigns/The_Rise_Of_Wesnoth/maps/17d_Cursed_Isle.map}"

    {TURNS 37 34 31}
    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC loyalists.ogg}
    {EXTRA_SCENARIO_MUSIC elvish-theme.ogg}

    # No story
    {TROW_GC_TRACK {JOURNEY_17D_NEW} }

    {TROW_DEATHS}

    [side]
        type=Noble Commander
        id=Prince Haldric
        name= _ "Prince Haldric"
        unrenamable=yes
        side=1
        canrecruit=yes
        gold=200
        controller=human
        team_name=Haldric
        user_team_name=_"Refugees"
        fog=yes
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        type=Spectre
        id=Isorfilad
        name= _ "Isorfilad"
        side=2
        canrecruit=yes
        {GOLD 130 190 250}
        {INCOME 2 4 8}
        team_name=Undead
        user_team_name=_"Undead"
#ifdef EASY
        recruit=Ghost,Ghoul,Vampire Bat
#else
        recruit=Ghost,Ghoul,Vampire Bat,Shadow,Necrophage
#endif
        [ai]
            {NO_SCOUTS}
            aggression=0.40
            recruitment_pattern=scout,scout,fighter
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
        [/ai]
        [ai]
            [goal]
                name=protect_location
                [criteria]
                    x,y=13,16
                [/criteria]
                protect_radius=10
                value=10
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES 2 12}

    [side]
        type=Spectre
        id=Tinoldor
        name= _ "Tinoldor"
        side=3
        canrecruit=yes
        {GOLD 130 190 250}
        {INCOME 2 4 8}
        team_name=Undead
        user_team_name=_"Undead"
#ifdef EASY
        recruit=Ghost,Ghoul,Vampire Bat
#else
        recruit=Ghost,Ghoul,Vampire Bat,Wraith,Necrophage
#endif
        [ai]
            {NO_SCOUTS}
            aggression=0.40
            recruitment_pattern=scout,scout,fighter
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
        [/ai]
        [ai]
            [goal]
                name=protect_location
                [criteria]
                    x,y=13,16
                [/criteria]
                protect_radius=10
                value=10
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES 3 12}

    {campaigns/The_Rise_Of_Wesnoth/utils/trow-nlmsg.cfg}

#define TEMP_LOOT X Y
    [event]
        name=moveto
        [filter]
            side=1
            x={X}
            y={Y}
        [/filter]

        {LOOT 50 1}
    [/event]
#enddef

#define TEMP_QUEEN X Y
    [event]
        # wmllint: recognize Lady Jessene
        name=moveto
        [filter]
            side=1
            x={X}
            y={Y}
        [/filter]
        [message]
            speaker=unit
            message= _ "She’s... She’s beautiful."
        [/message]

        {UNDEAD_INTEL (Vampire Lady) "Midnight Queen" _"Midnight Queen" "unit_image" 2 ({X}) ({Y})}

        {LOYAL_UNIT 3 (Blood Bat) ({X}) ({Y})}
        {LOYAL_UNIT 2 (Blood Bat) ({X}) ({Y})}
        {LOYAL_UNIT 3 (Blood Bat) ({X}) ({Y})}

#ifdef HARD
        {LOYAL_UNIT 2 (Blood Bat) ({X}) ({Y})}
#endif

        [message]
            speaker=Midnight Queen
            message= _ "You will be made to serve... Come admire me. Feel my love."
        [/message]
        [message]
            speaker=Prince Haldric
            message= _ "She is so..."
            image=portraits/haldric-surprised.png
        [/message]
        [message]
            speaker=Lady Jessene
            message= _ "Haldric, think with your brain!"
        [/message]
        [message]
            speaker=Prince Haldric
            message= _ "Get her before she ensorcels us all!"
            image=portraits/haldric-mad.png
        [/message]
        [show_objectives]
        [/show_objectives]
        [set_variable]
            name=queen_awake
            value=1
        [/set_variable]
    [/event]

#enddef

#define TEMP_EMPTY X Y
    [event]
        name=moveto
        [filter]
            side=1
            x={X}
            y={Y}
        [/filter]
        [message]
            speaker=unit
            message= _ "The temple is quite empty."
        [/message]
    [/event]
#enddef

    [event]
        name=prestart

        {PLACE_IMAGE (scenery/temple1.png) 11 13}
        {PLACE_IMAGE (scenery/temple1.png) 10 17}
        {PLACE_IMAGE (scenery/temple1.png) 9 15}

        {OBJ_POTION_HOLY 29 24 (holy_water1)}

        [set_variable]
            name=queen_awake
            value=0
        [/set_variable]
        [recall]
            id=Lady Jessene
        [/recall]

        [recall]
            id=Burin the Lost
        [/recall]

        [recall]
            id=Sir Ruddry
        [/recall]

        [recall]
            id=Sir Ladoc
        [/recall]

        [recall]
            id=Minister Edren
        [/recall]

        {RANDOM 1..3}
        [if]
            [variable]
                name=random
                numerical_equals=1
            [/variable]
            [then]
                {TEMP_LOOT 11 13}
#ifdef EASY
                {TEMP_LOOT 10 17}
#else
                {TEMP_EMPTY 10 17}
#endif
                {TEMP_QUEEN 9 15}
            [/then]
        [/if]
        [if]
            [variable]
                name=random
                numerical_equals=2
            [/variable]
            [then]
                {TEMP_LOOT 10 17}
#ifdef EASY
                {TEMP_LOOT 9 15}
#else
                {TEMP_EMPTY 9 15}
#endif
                {TEMP_QUEEN 11 13}
            [/then]
        [/if]
        [if]
            [variable]
                name=random
                numerical_equals=3
            [/variable]
            [then]
                {TEMP_LOOT 9 15}
#ifdef EASY
                {TEMP_LOOT 11 13}
#else
                {TEMP_EMPTY 11 13}
#endif
                {TEMP_QUEEN 10 17}
            [/then]
        [/if]

        {CLEAR_VARIABLE random}

#ifdef EASY
        {OBJ_POTION_HOLY 28 26 (holy_water2)}
#endif

        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
                [show_if]
                    [not]
                        [have_unit]
                            id=Midnight Queen
                        [/have_unit]
                    [/not]
                    [have_unit]
                        id=Isorfilad,Tinoldor
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Defeat the Vampire Queen"
                condition=win
                [show_if]
                    [have_unit]
                        id=Midnight Queen
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Prince Haldric"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Lady Jessene"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [event]
        name=start
        [message]
            speaker=narrator
            message= _ "After a short trip by sea, Haldric arrives on the elves’ cursed Isle of Tears. A fog hangs in the air."
            image=wesnoth-icon.png
        [/message]

        [message]
            speaker=Burin the Lost
            message= _ "I said no more ships. Double-crossing humans! Ahh, I’ve been with you this far. Who’d have thought, a nautical dwarf."
            image=portraits/burin-annoyed.png
        [/message]

        [message]
            speaker=Prince Haldric
            message= _ "I expect we’ll be facing more undead. Be careful."
        [/message]

        [message]
            speaker=Lady Jessene
            message= _ "These will be the long dead. Not like the undead that my people used, and they are elf-dead. Be careful indeed."
        [/message]

        [message]
            speaker=Minister Edren
            message= _ "All soldiers of darkness will meet the same fate by my hand."
        [/message]
    [/event]

    [event]
        name=victory
        [message]
            speaker=Prince Haldric
            message= _ "Those elves are finally at rest. I hope that the curses they laid upon us hold no weight."
        [/message]

        [message]
            speaker=Lady Jessene
            message= _ "Haldric, you’re too paranoid."
        [/message]

        {VARIABLE_OP num_done add 1}

        [set_variable]
            name=cursed_isle
            value=1
        [/set_variable]

        [set_variable]
            name=last_done
            value="Isle"
        [/set_variable]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Isorfilad
        [/filter]
        [message]
            speaker=Isorfilad
            message= _ "A curse upon all of your kin that visit this isle."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Tinoldor
        [/filter]
        [message]
            speaker=Tinoldor
            message= _ "I wish a blight upon you and yours. May you never see peace."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Midnight Queen
        [/filter]
        [message]
            speaker=Midnight Queen
            message= _ "My soul will haunt this place until the end of time! A curse upon you!"
        [/message]
        [set_variable]
            name=queen_awake
            value=0
        [/set_variable]
        [message]
            speaker=Prince Haldric
            message= _ "Without their queen the undead are simply fading away!"
        [/message]
        {CLEAR_VARIABLE queen_awake}
        [kill]
            side=2,3
            race=undead
            fire_event=no
        [/kill]
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=die
        [filter]
            race=undead
        [/filter]
        [filter_second]
            id=Minister Edren
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "Back, back to the grave with you!"
        [/message]
    [/event]

    [event]
        name=enemies defeated
        [if]
            [variable]
                name=queen_awake
                numerical_equals=1
            [/variable]
            [then]
                [message]
                    speaker=Lady Jessene
                    message= _ "We still have to defeat that vampire queen!"
                [/message]
                [show_objectives]
                [/show_objectives]
            [/then]
            [else]
                {CLEAR_VARIABLE queen_awake}
                [endlevel]
                    result=victory
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=time over
        [message]
            speaker=Prince Haldric
            message= _ "No! The ship that was supposed to pick us up sees that there’s still fighting. It’s not stopping. We’re trapped."
            image=portraits/haldric-surprised.png
        [/message]
    [/event]
[/scenario]

#undef TEMP_LOOT
#undef TEMP_QUEEN
#undef TEMP_EMPTY
