#textdomain wesnoth-low
[scenario]
    name= _ "Human Alliance"
    id=14_Human_Alliance

    random_start_time=no
    allow_new_game=no
    force_lock_settings=yes

    experience_modifier=100
    next_scenario=15_The_Treaty

    {LOW_MAP 14_Human_Alliance.map}

    #out of turns leads to victory
    {TURNS 18 20 22}
    victory_when_enemies_defeated=no

    {DEFAULT_SCHEDULE_AFTERNOON}

    #     #TODO split the villages instead of leaving them unassigned in MP?
#ifndef MULTIPLAYER
    {STARTING_VILLAGES_ELF   1}
#endif
    {STARTING_VILLAGES_HUMAN 2}
    {STARTING_VILLAGES_TROLL 3}

    {INTRO_AND_SCENARIO_MUSIC revelation.ogg loyalists.ogg}
    {EXTRA_SCENARIO_MUSIC the_city_falls.ogg}
    {EXTRA_SCENARIO_MUSIC knolls.ogg}
    {EXTRA_SCENARIO_MUSIC heroes_rite.ogg}
    {EXTRA_SCENARIO_MUSIC breaking_the_chains.ogg}
    {EXTRA_SCENARIO_MUSIC northerners.ogg}
    {EXTRA_SCENARIO_MUSIC siege_of_laurelmor.ogg}
    {EXTRA_SCENARIO_MUSIC elvish-theme.ogg}
    {EXTRA_SCENARIO_MUSIC casualties_of_war.ogg}

    [story]
#ifdef MULTIPLAYER
        [part]
            delay=4000
            title= _ "<i>The Legend of Wesmere</i>,
Chapter Four"
        [/part]
#endif
        [part]
            title= _ "Chapter Four,
<i>The Alliance</i>"
            #delay=4000
            #show_title=yes
        [/part]
        [part]
            story= _ "With the human-elf alliance revived, our heroes hurried to the battlefield..."
            delay=4000
            {TO_HUMAN_ALLIANCE}
        [/part]
        [part]
            show_title=yes
            {TO_HUMAN_ALLIANCE_BATTLE}
        [/part]
    [/story]

#define PLAYER_GOLD
    {GOLD 550 400 350}
#enddef
#define MULTIPLAYER_GOLD
    {GOLD 65 50 40}
#enddef

    [side]
        side=1
        {PLAYABLE}
        fog=no
        shroud=no
        no_leader=yes
        save_id=Kalenz

        [unit]
            {KALENZ}
            # wmllint: recognize Kalenz
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            x=25
            y=11
        [/unit]

#ifndef MULTIPLAYER
        {PLAYER_GOLD}
        [unit]
            {LANDAR}
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
            x=25
            y=13
        [/unit]
        [unit]
            {CLEODIL}
            extra_recruit=Elvish Shaman, Elvish Scout, Wose
            x=27
            y=12
        [/unit]
        [unit]
            {OLURF}
            extra_recruit=Dwarvish Fighter, Dwarvish Thunderer, Dwarvish Scout, Dwarvish Guardsman
            x=36
            y=10
        [/unit]
#else
        {MULTIPLAYER_GOLD}
#endif
    [/side]
    [event]
        name=prestart
        {RECALL_LOYALS}
    [/event]

    [side]
        fog=no
        side=2
        allow_player=yes
        no_leader=yes

        [unit]
            id=Aldar
            type=General
            name= _ "Aldar"
            profile="portraits/aldar.png"
            x=42
            y=27
            canrecruit=yes
            extra_recruit=Fencer, Heavy Infantryman,Dragoon,Longbowman,Duelist,Halberdier,Horseman,Cavalier,Cavalryman, Royal Guard, Mage, Swordsman, Bowman, White Mage, Red Mage, Spearman
        [/unit]

#ifdef MULTIPLAYER
        controller=3
#else
        controller=human
#endif

        {GOLD 550 500 450}
        team_name=player
        user_team_name= _ "Player"

        {LOYALIST_SETUP}
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        side=3
        allow_player=no
        team_name=orcs
        user_team_name= _ "Enemies"
        no_leader=yes
        {INCOME 220 280 360}
        {GOLD   520 630 800}
        fog=no

        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,fighter,fighter,archer,mixed fighter
            {ATTACK_DEPTH 4 5 6}
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
            grouping=no
        [/ai]

        [unit]
            type=Orcish Warlord
            id=Pirror
            name=_ "Pirror"
            canrecruit=yes
            x=10
            y=2
#ifdef EASY
            extra_recruit=Orcish Grunt, Orcish Assassin, Orcish Crossbowman, Goblin Pillager, Goblin Knight
#endif

#ifdef NORMAL
            extra_recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Knight, Orcish Slayer, Orcish Warrior, Goblin Spearman
#endif

#ifdef HARD
            extra_recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer, Goblin Spearman, Goblin Impaler, Goblin Rouser, Direwolf Rider
#endif
        [/unit]

        [unit]
            type=Orcish Warlord
            id=Tan-Grub
            name=_ "Tan-Grub"
            profile="portraits/orcs/transparent/warlord.png"
            canrecruit=yes
            x=10
            y=33
#ifdef EASY
            extra_recruit=Orcish Grunt, Orcish Assassin, Orcish Crossbowman, Goblin Pillager, Goblin Knight
#endif

#ifdef NORMAL
            extra_recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Knight, Orcish Slayer, Orcish Warrior, Goblin Spearman
#endif

#ifdef HARD
            extra_recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer, Goblin Spearman, Goblin Impaler, Goblin Rouser, Direwolf Rider
#endif
        [/unit]

        [unit]
            x=46
            y=5
            type=Great Troll
            id=Grol
            name=_ "Grol"
            canrecruit=yes
            #TODO think about adding troll shamans
#ifdef EASY
            extra_recruit=Troll Whelp, Troll
#endif
#ifdef NORMAL
            extra_recruit=Troll Whelp, Troll, Troll Rocklobber
#endif
#ifdef HARD
            extra_recruit=Troll Whelp, Troll, Troll Rocklobber, Troll Warrior
#endif
        [/unit]
    [/side]

    [side]
        side=4
        no_leader=yes
        team_name=player
        user_team_name= _ "Player"
        controller=human
        fog=no
        save_id=Galtrid
#ifdef MULTIPLAYER
        {MULTIPLAYER_GOLD}
#else
        {PLAYER_GOLD}
#endif

        [unit]
            # wmllint: recognize Galtrid
            {GALTRID}
            x=15
            y=12
        [/unit]

#ifndef MULTIPLAYER
        [unit]
            # wmllint: recognize El_Isomithir
            {EL_ISOMITHIR}
            x=13
            y=15
        [/unit]

        [unit]
            # wmllint: recognize Eradion
            {ERADION}
            x=15
            y=15
        [/unit]
#endif
    [/side]

    [event]
        name=prestart

        [objectives]
            side=0
            [objective]
                description= _ "Last for the end of turns"
                condition=win
                show_turn_counter=yes
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Landar"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Olurf"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Cleodil"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Aldar"
                condition=lose
            [/objective]

            [gold_carryover]
                bonus=no
                carryover_percentage=80
            [/gold_carryover]
        [/objectives]
    [/event]

    [event]
        name=side 1 turn 1
        [message]
            id=Kalenz
            message= _ "Tremble, orcs! The vengeance of the Elves is upon you!!"
        [/message]
        [message]
            id=Aldar
            message= _ "So it is true! The elves have come to our aid!"
        [/message]
        [message]
            id=Olurf
            message= _ "Hey! Do I look like an elf?"
        [/message]
        [message]
            id=Landar
            message= _ "I can scarce believe I am fighting besides these betrayers."
        [/message]
        [message]
            id=Cleodil
            message= _ "We cannot be choosy about our allies when our need is dire."
        [/message]
        [message]
            id=Kalenz
            message= _ "Indeed not. Save your anger for our enemies, Landar."
        [/message]
        [message]
            id=Landar
            message= _ "I shall. But when our need is not so dire, there must be a reckoning..."
        [/message]
        [message]
            id=Tan-Grub
            #canrecruit=yes
            #race=orc
            message= _ "An elven army to the north? And they have dwarves with them? We must defeat them in detail before they combine, which means attacking before our reinforcements arrive. Maybe we can beat the humans before the elves can intervene. Overrun city and castle!"
        [/message]

        [message]
            speaker=narrator
            message= _ "The brazen cry of a war-horn is heard in the distance."
            sound=horn-signals/horn-2.ogg
            image="portraits/goblins/transparent/rouser-2.png"
        [/message]

        [unit]
            id=Aldun
            name= _ "Aldun"
            type=Horseman
            random_traits=yes
            side=2
            x=33
            y=24
            facing=sw
        [/unit]
        {MOVE_UNIT id=Aldun 21 16}

        [message]
            id=Aldun
            message= _ "General Aldar has received your message. He asks that you engage the orcish reinforcements from the north, preventing them from joining with their fellows here. Those fresh troops must not be allowed to enter the battle! Our reinforcements should arrive in a few days."
        [/message]
        [message]
            id=Kalenz
            message= _ "Very well... But have you any word of the elvish troops marching to join us? We are too few to defeat the enemy without them."
        [/message]
        [message]
            id=Aldun
            message=_"We have no news from the Ka’lian."
        [/message]

        [message]
            id=Galtrid
            message= _ "Kalenz! We come to fight beside you!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Where is the rest of the elvish army? They were promised and should be here!"
        [/message]
        [message]
            id=Eradion
            message= _ "The Great Council has decided it was too risky to send troops here. But some of us dissented and have come to fight beside you."
        [/message]
        [message]
            id=Landar
            message= _ "That is well! If the Ka’lian is too fearful or blind to see what is needed, we must do it ourselves."
        [/message]
        [message]
            id=Cleodil
            message= _ "It is not well that we have become so divided as this."
        [/message]
        [message]
            id=Kalenz
            message= _ "No, it is not. But if we do not defeat these orcs here and now our divisions will all be moot. I will take every sword-arm I can get and be glad of them."
        [/message]
    [/event]

#ifdef MULTIPLAYER
    [side]
        #Landar's side
        side=5
        team_name=player
        user_team_name= _ "Player"
        fog=no
        shroud=no
        no_leader=yes
        {PLAYABLE}

        [unit]
            {LANDAR}
            x=27
            y=12
            extra_recruit=Elvish Fighter, Elvish Archer, Elvish Scout
        [/unit]
        {MULTIPLAYER_GOLD}
    [/side]
    [side]
        #Olurf's side
        side=6
        fog=no
        shroud=no
        no_leader=yes

        [unit]
            {OLURF}
            x=36
            y=10
        [/unit]
        {PLAYABLE}

        {MULTIPLAYER_GOLD}

        team_name=player
        user_team_name= _ "Player"
        extra_recruit=Dwarvish Fighter, Dwarvish Scout, Dwarvish Guardsman, Dwarvish Thunderer
    [/side]
    [side]
        #Cleodil's side
        side=7
        fog=no
        shroud=no
        {PLAYABLE}
        no_leader=yes
        [unit]
            {CLEODIL}
            x=25
            y=13
        [/unit]

        {MULTIPLAYER_GOLD}

        team_name=player
        user_team_name= _ "Player"
        extra_recruit=Elvish Shaman, Wose, Elvish Scout
    [/side]
    [side]
        #El'Isomithir's side
        side=8
        fog=no
        shroud=no
        {PLAYABLE}
        no_leader=yes
        [unit]
            {EL_ISOMITHIR}
            x=13
            y=15
        [/unit]

        {MULTIPLAYER_GOLD}
        team_name=player
        user_team_name= _ "Player"
        #extra_recruit=Elvish Shaman, Wose, Elvish Scout
    [/side]
    [side]
        #Eradion's side
        side=9
        fog=no
        shroud=no
        {PLAYABLE}

        no_leader=yes
        [unit]
            {ERADION}
            x=15
            y=15
        [/unit]

        {MULTIPLAYER_GOLD}
        team_name=player
        user_team_name= _ "Player"
        #extra_recruit=Elvish Shaman, Wose, Elvish Scout
    [/side]

#endif

    #### reenforcements for the player ####

    [event]
        name=turn 9

        {FOREACH l3_store_kalenz i}
            [unstore_unit]
                find_vacant=yes
                variable=l3_store_kalenz[$i]
                x=9
                y=15
            [/unstore_unit]
            [role]
                role=l3_store
                id=$l3_store_kalenz[$i].id
            [/role]
            {MODIFY_UNIT (id=$l3_store_kalenz[$i].id) facing ne}
        {NEXT i}
        {CLEAR_VARIABLE i}

#ifdef MULTIPLAYER
        {FOREACH l3_store_landar i}
            [unstore_unit]
                find_vacant=yes
                variable=l3_store_landar[$i]
                x=9
                y=15
            [/unstore_unit]
            [role]
                role=l3_store
                id=$l3_store_landar[$i].id
            [/role]
            {MODIFY_UNIT (id=$l3_store_landar[$i].id) facing ne}
            {MODIFY_UNIT (id=$l3_store_landar[$i].id) side 13}
        {NEXT i}
        {CLEAR_VARIABLE i}
#endif

        [if]
            [not]
                [variable]
                    name=l3_store_kalenz.length
                    numerical_equals=0
                [/variable]
            [/not]
#ifdef MULTIPLAYER
            [or]
                [not]
                    [variable]
                        name=l3_store_landar.length
                        numerical_equals=0
                    [/variable]
                [/not]
            [/or]
#endif
            [then]
                [message]
                    role=l3_store
                    message= _ "Kalenz! We come to fight beside you!"
                [/message]
                [message]
                    id=Kalenz
                    message= _ "Where is the rest of the elvish army? They were promised and should be here!"
                [/message]
                [message]
                    role=l3_store
                    message= _ "The Great Council has decided it was too risky to send troops here. But some of us dissented and have come to fight beside you."
                [/message]
                [message]
                    id=Landar
                    message= _ "That is well! If the Ka’lian is too fearful or blind to see what is needed, we must do it ourselves."
                [/message]
                [message]
                    id=Cleodil
                    message= _ "It is not well that we have become so divided as this."
                [/message]
                [message]
                    id=Kalenz
                    message= _ "No, it is not. But if we do not defeat these orcs here and now our divisions will all be moot. I will take every sword-arm I can get and be glad of them."
                [/message]
            [/then]
        [/if]
        #TODO else -- the player has to know that the kalian refused help.
        {CLEAR_VARIABLE l3_store_kalenz}
#ifdef MULTIPLAYER
        {CLEAR_VARIABLE l3_store_landar}
#endif
    [/event]

    [event]
        name=time over

        [unit]
            type=Paladin
            id=Kulrad
            name=_ "Kulrad"
            side=2
            x=38
            y=30
        [/unit]

        {GENERIC_UNIT 2 Knight 43 33}
        {GENERIC_UNIT 2 Knight 43 36}

        {GENERIC_UNIT 2 Horseman 38 34}
        {GENERIC_UNIT 2 Horseman 42 35}
        {GENERIC_UNIT 2 Horseman 39 34}
        {GENERIC_UNIT 2 Horseman 43 37}
        {GENERIC_UNIT 2 Horseman 41 37}
        {GENERIC_UNIT 2 Horseman 41 39}

        [message]
            id=Kulrad
            message= _ "I see foul orcs to be ridden down! Charge!"
        [/message]
        [message]
            race=orc
            canrecruit=yes
            message= _ "More of the cursed horse-pokers!! Run, let’s get out of here!"
        [/message]

        #TODO move the message in a macro
        [message]
            speaker=narrator
            message= _ "The not-at-all-brazen cry of a war-horn is heard in the distance."
            #TODO rethink about which signal to use here
            sound=horn-signals/horn-8.ogg
            image="portraits/goblins/transparent/rouser-2.png"
        [/message]

        [endlevel]
            result=victory
            bonus=no
            save=no
        [/endlevel]
    [/event]

    # [event]
    #     name=enemies defeated
    #     [message]
    #         id=Aldar
    #         message= _ "This is only a pause in their onslaught. Reform, men, and bind your wounds as you may. They’ll be back."
    #     [/message]
    #     #TODO CRAB
    #     #[modify_ai]
    #     #
    #     #[/modify_ai]
    # [/event]

    [event]
        name=victory
        [message]
            id=Kalenz
            message= _ "We have thwarted the Orcs once again!"
        [/message]
        [message]
            id=Cleodil
            message= _ "And we revived the alliance with the Humans, which is no small thing."
        [/message]
        [message]
            id=Kalenz
            message= _ "Indeed it is not. As always, Cleodil, you speak with the wisdom and care that befits a healer. That is a good reminder for those who must walk the path of steel and warfare, and touches my heart."
        [/message]
        [message]
            id=Olurf
            message= _ "A good fight against foul enemies. These orcs make a dwarf’s hackles rise; I might even fight them for free, next time."
        [/message]
        [message]
            id=Aldar
            message= _ "The King is here! Hail Haldric II, King of Wesnoth!"
        [/message]
        #TODO Landar is quiet?
        [kill]
            id=Aldun
        [/kill]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Aldar
        [/filter]
        [message]
            speaker=unit
            message= _ "Tath will fall! We have failed!"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Grol
        [/filter]
        [message]
            speaker=unit
            message= _ "I die? Great Chief never said anything about fighting elves and dwarves!"
        [/message]
    [/event]

    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}
[/scenario]

#undef PLAYER_GOLD
#undef MULTIPLAYER_GOLD
