#textdomain wesnoth-sota

# The enemy leader is modified to be unable to reach sea or sand. Otherwise, he tends to
# attack and die easily because of his terrible defense on those terrains. We want the
# enemy to recruit level-2 units occasionally for the whole scenario, but not every turn.
# For that reason, side 2 gets a "level 2 credit". Credit is used to recruit each unit,
# and then recharges a bit every turn. When it is high enough, another level-2 unit is
# available. (Assuming side 2 has enough gold.) The ship graphic macros are still in
# effect, and on Easy, there is an extra merman village near the deck of the ship to
# provide healing.

[scenario]
    name= _ "Blackwater"
    map_file=05_Blackwater.map

    id=05_Blackwater
    next_scenario=06_Following_the_Shadow
    victory_when_enemies_defeated=no

    [story]
        [part]
            [background_layer]
                image=story/book.webp
                scale=no
            [/background_layer]
            story=_ "29 III, 23 YW

When the captain retained his memories, I reasoned that it may have been because he was raised so soon after his death. Further experiments with the other passengers bore out that conclusion. Just think: They may be the first people on this continent to live forever!"
        [/part]
        [part]
            [background_layer]
                image=story/blackwater.webp
                scale=no
            [/background_layer]
            story=_ "Happily, the captain was fairly wealthy, so that will solve my income problems for a time. Now I must go, as the captain prepares to guide the ship into port."
        [/part]
        {JOURNEY_PART 5}
    [/story]

    {DEFAULT_SCHEDULE}
    {DEFAULT_MUSIC_PLAYLIST}
    {TURNS 28 28 28}

    # wmllint: validate-off
    [side]
        {SIDE_1_ARDONNA}
        {ARDONNA_RECRUIT_3}
        {GOLD 270 230 190}
        {INCOME 9 8 7}
        facing=se
        [unit]
            {CHARACTER_STATS_BONE_CAPTAIN}
            placement=leader
        [/unit]
    [/side]
    # wmllint: validate-on

    {STARTING_VILLAGES 2 6}

    [side]
        side=2
        controller=ai
        user_team_name= _ "Guard"
        id=Gweddyn
        type=Knight
        name= _ "Gweddyn"
        facing=nw
        recruit=Horseman, Cavalryman, Spearman, Bowman, Mage
        {GOLD 250 310 380}
        {FLAG_VARIANT loyalist}
        [unit]
            type=Mage
            gender=male
            x,y=24,14
            name= _ "Bremen"
            id=Bremen
            facing=nw
        [/unit]
        [unit]
            type=Cavalryman
            x,y=24,11
            facing=nw
        [/unit]
        [unit]
            type=Swordsman
            x,y=21,14
            facing=nw
        [/unit]
        [unit]
            type=Bowman
            x,y=24,15
            facing=nw
        [/unit]
    [/side]

#ifdef EASY
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2 (Mage) 2}
#endif

    # Dummy side for ghost
    [side]
        side=3
        team_name=good
        controller=null
        hidden=yes
        color=darkred
    [/side]

    # *************************** PRESTART ***************************
    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Kill every enemy unit"
                condition=win
            [/objective]

            {HOW_TO_LOSE_WITH_ARDONNA}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
            [note]
                description= _ "You can recruit from anywhere on the two highest decks."
            [/note]
            [note]
                description= _ "Right-click to simplify the ship graphics."
            [/note]
        [/objectives]

        [item]
            x,y=10,10
            image=items/trap-doors-closed.png
        [/item]
        [item]
            x,y=14,8
            image=items/trap-doors-closed.png
        [/item]

        # If this variable is 1 or more, side 2 can recruit a level 2 unit.
        # It costs one credit to do so. The credit rercharges a little each turn.
#ifdef HARD
        [set_variable]
            name=level_2_credit
            value=1
        [/set_variable]
#else
        [set_variable]
            name=level_2_credit
            value=0
        [/set_variable]
#endif

        # This object will keep the knight from attacking from terrible terrain,
        # which he will otherwise.
        [object]
            [filter]
                id=Gweddyn
            [/filter]
            silent=yes
            duration=forever
            [effect]
                apply_to=movement_costs
                replace=yes
                [movement_costs]
                    sand={UNREACHABLE}
                    shallow_water={UNREACHABLE}
                [/movement_costs]
            [/effect]
        [/object]

        # Remove sails and rigging if they were hidden at the end of the previous
        # scenario.
        [if]
            [variable]
                name=sails_hidden
                boolean_equals=yes
            [/variable]

            [then]
                [terrain]
                    x,y=5,12
                    terrain=^
                    layer=overlay
                [/terrain]
                [terrain]
                    x,y=14,10
                    terrain=^
                    layer=overlay
                [/terrain]
                [terrain]
                    x,y=7,10
                    terrain=^rlpS
                    layer=overlay
                [/terrain]
            [/then]
        [/if]

        {SHOW_SAILS_MENU_ITEM 1}
        {HIDE_SAILS_MENU_ITEM 1}

#ifdef EASY
        [terrain] # An extra village is available on EASY
            x,y=9,9
            terrain=Wwrt^Vm
        [/terrain]
#endif
    [/event]

    # *************************** PLAY ***************************

    # The next two events control the ability of side 2 to recruit a level-2 unit.
    [event]
        name=side 2 turn
        first_time_only=no

        [set_variable]
            name=level_2_credit
#ifdef EASY
            add=0.25
#endif
#ifdef NORMAL
            add=0.5
#endif
#ifdef HARD
            add=0.7
#endif
        [/set_variable]
        [if]
            [variable]
                name=level_2_credit
                greater_than_equal_to=1
            [/variable]
            [then]
                [allow_recruit]
                    side=2
                    type=Javelineer,Swordsman
                [/allow_recruit]
            [/then]
        [/if]
    [/event]

    [event]
        name=recruit
        first_time_only=no

        [filter]
            side=2
            level=2
        [/filter]
        [set_variable]
            name=level_2_credit
            sub=1
        [/set_variable]
        [if]
            [variable]
                name=level_2_credit
                less_than=1
            [/variable]
            [then]
                [disallow_recruit]
                    side=2
                    type=Javelineer,Swordsman
                [/disallow_recruit]
            [/then]
        [/if]
    [/event]

    [event]
        name=die
        first_time_only=no

        [filter]
            side=2
        [/filter]

        [if]
            [not]
                [have_unit]
                    side=2
                [/have_unit]
            [/not]

            [then]
                [fire_event]
                    name=closing
                [/fire_event]

                [clear_variable]
                    name=level_2_credit,sails_hidden
                [/clear_variable]
                [clear_menu_item]
                    id=show-sails,hide-sails
                [/clear_menu_item]

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

    # *************************** OPENING / ENDING ***************************
    [event]
        name=start
        [message]
            speaker=Gweddyn
            message= _ "Ho Rudic! Welcome. You are late, old friend."
        [/message]
        [message]
            speaker=Bone Captain
            message= _ "Late."
        [/message]
        [message]
            speaker=Gweddyn
            message= _ "Not talking much today? What happened?"
        [/message]
        [message]
            speaker=Bone Captain
            message= _ "Happened? Dead."
        [/message]
        [message]
            speaker=Ardonna
            message= {WHISPER ( _ "Keep quiet about that.")}
        [/message]
        [message]
            speaker=Gweddyn
            message= _ "Ha! Well, actually, you do look terrible. Very... gray, and your face is... But we’re speaking! You can’t actually be dead!"
        [/message]
        [message]
            speaker=Bone Captain
            message= _ "Yes. Dead."
        [/message]
        [message]
            speaker=Gweddyn
            message= _ "What madness is this?"
        [/message]
        [message]
            speaker=Bremen
            message= _ "It’s sorcery my lord. Dark sorcery."
        [/message]
        [message]
            speaker=Gweddyn
            message= _ "Necromancy! The penalty for that is death. Rudic, who is responsible for this?"
        [/message]
        [message]
            speaker=Bone Captain
            message= _ "She."
        [/message]
        [message]
            speaker=Ardonna
            message= _ "Ah, well. I should have known this wouldn’t be easy."
        [/message]
        [message]
            speaker=Gweddyn
            message= _ "Kill her!"
        [/message]
        [message]
            speaker=Ardonna
            message= _ "We must leave no one alive to report us, or the entire country will become unsafe. We have no choice. We must kill them all."
        [/message]
    [/event]

    [event]
        name=closing
        [message]
            speaker=Ardonna
            message= _ "We are finished."
        [/message]
        [move_unit_fake]
            x=34,30
            y=7, 10
            type=Shadow
            side=3
        [/move_unit_fake]
        [unit]
            type=Shadow
            side=3
            id=Shadow
            x,y=30,10
            facing=sw
        [/unit]
        [message]
            speaker=Shadow
            message= _ "Girl. You will follow."
        [/message]
        [message]
            speaker=Ardonna
            message= _ "What in the world are <i>you</i>?"
        [/message]
        [message]
            speaker=Shadow
            message= _ "Spirit and shadow. You will follow."
        [/message]
        [message]
            speaker=Ardonna
            message= _ "You’re a ghost... a real ghost! I will indeed follow you. Lead on."
        [/message]
        [kill]
            id=Shadow
        [/kill]
        [move_unit_fake]
            x=30,34
            y=10,7
            type=Shadow
            side=3
        [/move_unit_fake]
    [/event]

    [event]
        name=die
        [filter]
            side=2
            canrecruit=yes
        [/filter]
        [if]
            [have_unit]
                side=2
            [/have_unit]
            [then]
                [message]
                    speaker=Ardonna
                    message= _ "Blackwater Port is defeated, but we must let none escape. Finish them all."
                [/message]
            [/then]
        [/if]
    [/event]

    {HERO_DEATHS}
    {TRANSFORM_BATS_FOR_SHIP}
    {ZOMBIES}

#undef SHOW_SAILS_MENU_ITEM
#undef HIDE_SAILS_MENU_ITEM
[/scenario]
