#textdomain wesnoth-nr
## Common code for hero deaths.

# Tallin death
#define HERODEATH_TALLIN
    [event]
        name=last breath
        [filter]
            id=Tallin
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}

        [message]
            speaker=Tallin
            message= _ "Argh! I am finished, but our campaign must... not end... crush... our... enemies... and... save... our... people..."
        [/message]

        [message]
            role=Supporter
            message= _ "No, Tallin, we can’t do it without you!"
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
#enddef

# Camerin death
#define HERODEATH_CAMERIN
    [event]
        name=last breath
        [filter]
            id=Camerin
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}

        [message]
            speaker=Camerin
            message= _ "What... how can this happen?"
        [/message]

        [message]
            speaker=Tallin
            message= _ "He was stark raving mad, but I am sure going to miss him."
        [/message]
    [/event]
#enddef

# Hamel death in scenario 2,3 and 4
#define HERODEATH_HAMEL
    [event]
        name=die
        [filter]
            id=Hamel
        [/filter]

        [message]
            speaker=Tallin
            message= _ "No! Without the dwarvish weapons we have no hope!"
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
#enddef

# Krash death events
#define HERODEATH_KRASH
    [event]
        name=last breath
        [filter]
            id=Krash
        [/filter]

        [message]
            speaker=Krash
            message= _ "(<i>Roars in pain</i>)"
        [/message]

        [message]
            speaker=Tallin
            message= _ "Krash!"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Krash
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}

        [message]
            speaker=Father Morvin
            message= _ "It’s no good, Tallin, he is gone."
        [/message]

        [message]
            speaker=Tallin
            message= _ "You wretched monsters! You are going to pay for this!"
        [/message]

        [message]
            speaker=Camerin
            message= _ "Awww, I liked that guy!"
        [/message]
    [/event]
#enddef

# Elenia death
#define HERODEATH_ELENIA
    [event]
        name=last breath
        [filter]
            id=Elenia
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}

        [message]
            speaker=Elenia
            message= _ "Alas! My wanderings have come to an end."
        [/message]

        [message]
            speaker=Tallin
            message= _ "Blast it! We have lost a valuable ally!"
        [/message]

        [message]
            speaker=Sister Thera
            message= _ "Farewell Elenia. May you find peace in your final journey."
        [/message]
    [/event]
#enddef

#define NR_WHITE_MAGE_RESPAWN_AT HUB_CANDIDATE
    # Find a respawn point, starting within 1 hex of the candidate,
    # and increading in range if no suitable hex is found.
    # Tallin is always the hub candidate now because respawning at each other
    # causes illogical and hard to balance gameplay
    [find_respawn_point]
        respawn_near={HUB_CANDIDATE}
        variable=respawn_point
    [/find_respawn_point]

    {FLASH_WHITE (
        [teleport]
            [filter]
                id=$unit.id
            [/filter]
            x=$respawn_point.x
            y=$respawn_point.y
            animate=no
        [/teleport]
    )}

    [redraw][/redraw]

    [scroll_to]
        x=$respawn_point.x
        y=$respawn_point.y
    [/scroll_to]

    [delay]
        time=500
    [/delay]

    [heal_unit]
        [filter]
            id=$unit.id
        [/filter]
        [filter_second]
            id={HUB_CANDIDATE}
        [/filter_second]

        amount=full
        animate=yes
    [/heal_unit]

    {CLEAR_VARIABLE respawn_point}
#enddef

# Death event for Thera and Morvin
# This version includes death dialog
#define HERODEATH_THERA_AND_MORVIN_WITH_DIALOG
    [event]
        name=prestart

        # These will allow their death/dialogs to play in a row, and then never again,
        # to prevent annoyance.
        {VARIABLE death_dialog_index_thera 1}
        {VARIABLE death_dialog_index_morvin 1}
    [/event]

    [event]
        name=last breath
        first_time_only=no
        [filter]
            id=Sister Thera
        [/filter]

        [switch]
            variable=death_dialog_index_thera
            [case]
                value=1
                [message]
                    speaker=Sister Thera
                    message= _ "Ahhhh! Save me, my husband!"
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "(<i>Rolls eyes</i>) Dramatic as always."
                [/message]
            [/case]
            [case]
                value=2
                [message]
                    speaker=Sister Thera
                    message= _ "Ahhhhhhh!"
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "You monsters think you are so tough don’t you? Well check this out."
                [/message]
            [/case]
            [case]
                value=3
                [message]
                    speaker=Sister Thera
                    message= _ "Ahhhhhhh!"
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "You incompetent fools, you think you can kill us? Good luck!"
                [/message]
            [/case]
            [case]
                value=4
                [message]
                    speaker=Sister Thera
                    # wmllint: local spelling Ack!
                    message= _ "Ack! Stupid slobbering beast!"
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "Your efforts to destroy us are in vain, you foul creature."
                [/message]
            [/case]
            [case]
                value=5
                [if]
                    [have_unit]
                        id=Father Morvin
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Sister Thera
                            message= _ "Oh no, Morvin! We have failed in our mission to help Tallin!"
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "Failed? Never! The word failure is not in our dictionary."
                        [/message]
                    [/then]
                [/if]
            [/case]
            [case]
                value=6
                [message]
                    speaker=Sister Thera
                    message= _ "Alas! I am dying! Morvin darling, I wish you were beside me so that I may die in your arms! So that I may feel the kiss of your lips on mine one last time!"
                [/message]
                [if]
                    [have_unit]
                        id=Father Morvin
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Father Morvin
                            message= _ "(<i>Rolls eyes</i>) Thera, do you always have to be so dramatic?"
                        [/message]

                        [message]
                            role=Supporter
                            message= _ "Um... Father? Your wife just got killed..."
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "Oh right. I CALL UPON THE LORDS OF LIGHT TO GRANT YOU LIFE!"
                        [/message]
                    [/then]
                [/if]
            [/case]
            [case]
                value=7
                [message]
                    speaker=Sister Thera
                    message= _ "You cruel creature! How dare you use your brute strength against such a frail creature as me."
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "Don’t worry, Thera, you will have plenty of opportunities to set him straight."
                [/message]
            [/case]
        [/switch]

        {NR_WHITE_MAGE_RESPAWN_AT (Tallin)}

        [switch]
            variable=death_dialog_index_thera
            [case]
                value=1
                [if]
                    [have_unit]
                        id=Father Morvin
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Father Morvin
                            message= _ "Thera, when this is all over, you should paint your face and join a theater."
                        [/message]

                        [message]
                            speaker=Sister Thera
                            message= _ "Hey, don’t you always say that life is nothing but a drama?"
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "Yes, it may be a drama, but that’s no excuse for overacting!"
                        [/message]

                        [message]
                            speaker=Sister Thera
                            message= _ "(<i>Giggle</i>) Who needs an excuse for overacting?"
                        [/message]
                    [/then]
                [/if]
            [/case]
            [case]
                value=2
                [message]
                    speaker=Sister Thera
                    message= _ "Whoa! That trick is a bit hard on the constitution."
                [/message]
                [if]
                    [have_unit]
                        id=Father Morvin
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Father Morvin
                            message= _ "Well, be grateful that you are alive."
                        [/message]

                        [message]
                            speaker=Sister Thera
                            message= _ "(<i>Giggle</i>) Thank you, honey."
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "Thank the Lords of Light, not me!"
                        [/message]
                    [/then]
                [/if]
            [/case]
            [case]
                value=3
                [message]
                    speaker=Sister Thera
                    message= _ "Ouch! That hurts. Let’s try not to do that again, shall we?"
                [/message]
            [/case]
            [case]
                value=4
                [message]
                    speaker=Sister Thera
                    message= _ "There we go, payback time!"
                [/message]
            [/case]
            [case]
                value=5
                [message]
                    speaker=Sister Thera
                    message= _ "There we go. Let’s give this one more shot!"
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "Just try not to kill yourself again."
                [/message]
            [/case]
            [case]
                value=6
                [if]
                    [have_unit]
                        id=Father Morvin
                    [/have_unit]
                    [then]
                        # wmllint: local spelling unclerical
                        [message]
                            speaker=Father Morvin
                            message= _ "Thera, you should know by now that it is very unclerical to make such a spectacle of yourself."
                        [/message]

                        [message]
                            speaker=Sister Thera
                            message= _ "Come on, honey! Those were my dying words, after all!"
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "(<i>Rolls eyes</i>) Women!"
                        [/message]
                    [/then]
                [/if]
            [/case]
            [case]
                value=7
                [if]
                    [have_unit]
                        id=Father Morvin
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Sister Thera
                            message= _ "That’s darned right!"
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "Thera! Language like that coming from you! You should really stop hanging around the dwarves so much."
                        [/message]

                        [message]
                            speaker=Sister Thera
                            message= _ "(<i>Giggle</i>) Sorry."
                        [/message]
                    [/then]
                [/if]
            [/case]
        [/switch]

        [if]
            [variable]
                name=death_dialog_index_thera
                less_than_equal_to=7
            [/variable]
            [then]
                {VARIABLE_OP death_dialog_index_thera add 1}
            [/then]
        [/if]
    [/event]

    [event]
        name=last breath
        first_time_only=no
        [filter]
            id=Father Morvin
        [/filter]

        [switch]
            variable=death_dialog_index_morvin
            [case]
                value=1
                [message]
                    speaker=Father Morvin
                    message= _ "Alas! So... close."
                [/message]

                [message]
                    speaker=Sister Thera
                    message= _ "Hey, that’s not right. The good guys aren’t supposed to die. Oh well, I’ll fix that."
                [/message]
            [/case]
            [case]
                value=2
                [message]
                    speaker=Father Morvin
                    message= _ "Argh!"
                [/message]

                [message]
                    speaker=Sister Thera
                    message= _ "You incompetent fools, you think you can kill us? Good luck!"
                [/message]
            [/case]
            [case]
                value=3
                [message]
                    speaker=Father Morvin
                    message= _ "Argh!"
                [/message]

                [message]
                    speaker=Sister Thera
                    message= _ "Oh dear. Did you just go and get yourself killed again, Morvin? Well, I’ll fix that."
                [/message]
            [/case]
            [case]
                value=4
                [message]
                    speaker=Father Morvin
                    message= _ "The forces of good can never be defeated by the likes of you!"
                [/message]

                [message]
                    speaker=Sister Thera
                    message= _ "Yeah, try taking a bath and you <i>might</i> be able to kill him for good (<i>Wink wink</i>). But for the time being, abracadabra!"
                [/message]
            [/case]
            [case]
                value=5
                [message]
                    speaker=Father Morvin
                    message= _ "Argh!"
                [/message]

                [message]
                    speaker=Sister Thera
                    message= _ "Stupid troll, maybe next time you should try killing someone who can be killed."
                [/message]
            [/case]
            [case]
                value=6
                [message]
                    speaker=Father Morvin
                    message= _ "Argh! I’ll just come back and finish you in my next life."
                [/message]

                [message]
                    speaker=Sister Thera
                    message= _ "Which might be sooner than you think."
                [/message]
            [/case]
            [case]
                value=7
                [message]
                    speaker=Father Morvin
                    message= _ "Ack! I have been brained!"
                [/message]

                [message]
                    speaker=Sister Thera
                    # wmllint: local spelling Eew
                    message= _ "Eew! Gross! Ahh never mind, I’ll get you cleaned up good."
                [/message]
            [/case]
        [/switch]

        {NR_WHITE_MAGE_RESPAWN_AT (Tallin)}

        [switch]
            variable=death_dialog_index_morvin
            [case]
                value=1
                [message]
                    speaker=Sister Thera
                    message= _ "There we go."
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "Ahh yes, that’s better."
                [/message]
            [/case]
            [case]
                value=2
                [message]
                    speaker=Father Morvin
                    message= _ "Ouch! That hurts. Let’s try not to do that again, shall we?"
                [/message]
            [/case]
            [case]
                value=3
                [if]
                    [have_unit]
                        id=Sister Thera
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Sister Thera
                            message= _ "Morvin! You bad boy, always getting into trouble."
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "Sorry, won’t do it again. Promise!"
                        [/message]
                    [/then]
                [/if]
            [/case]
            [case]
                value=4
                [if]
                    [have_unit]
                        id=Sister Thera
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Father Morvin
                            message= _ "I heard that, Thera."
                        [/message]

                        [message]
                            speaker=Sister Thera
                            message= _ "Hey, just trying to give him an incentive to drown himself."
                        [/message]
                    [/then]
                [/if]
            [/case]
            [case]
                value=5
                # no message for this case
            [/case]
            [case]
                value=6
                [message]
                    speaker=Sister Thera
                    message= _ "See?"
                [/message]

                [message]
                    speaker=Father Morvin
                    message= _ "Now where did he go?!"
                [/message]
            [/case]
            [case]
                value=7
                [if]
                    [have_unit]
                        id=Sister Thera
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Father Morvin
                            message= _ "Ahhh, Thera, you would make such a good housewife!"
                        [/message]

                        [message]
                            speaker=Sister Thera
                            # wmllint: local spelling pouty
                            message= _ "Yes, if you would ever buy me a house! (<i>Pouty face</i>)"
                        [/message]

                        [message]
                            speaker=Father Morvin
                            message= _ "Thera, don’t you think that this isn’t really a good time to talk about that?"
                        [/message]

                        [message]
                            speaker=Sister Thera
                            message= _ "(<i>Giggle</i>) Sorry!"
                        [/message]
                    [/then]
                [/if]
            [/case]
        [/switch]

        [if]
            [variable]
                name=death_dialog_index_morvin
                less_than_equal_to=7
            [/variable]
            [then]
                {VARIABLE_OP death_dialog_index_morvin add 1}
            [/then]
        [/if]
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE death_dialog_index_thera,death_dialog_index_morvin}
    [/event]
#enddef

# Death event for Thera and Morvin
# This version does NOT include death dialog
#define HERODEATH_THERA_AND_MORVIN_NO_DIALOG
    [event]
        name=last breath
        first_time_only=no
        [filter]
            id=Sister Thera
        [/filter]

        {NR_WHITE_MAGE_RESPAWN_AT (Tallin)}
    [/event]

    [event]
        name=last breath
        first_time_only=no
        [filter]
            id=Father Morvin
        [/filter]

        {NR_WHITE_MAGE_RESPAWN_AT (Tallin)}
    [/event]
#enddef

# Death events for the lich brothers
#define HERODEATH_LICH_BROTHERS
    [event]
        name=last breath
        [filter]
            id="Ro'Sothian,Ro'Arthian"
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}

        [message]
            speaker=unit
            # wmllint: local spelling outta
            message= _ "I have had enough! Come on brother, let’s get outta here."
        [/message]

        {FLASH_WHITE ()}
    [/event]

    [event]
        name=die
        [filter]
            id="Ro'Sothian,Ro'Arthian"
        [/filter]

        [message]
            speaker=Tallin
            message= _ "Dang it! They’re gone, and the creatures they control are leaving too. Without them, this is hopeless."
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
#enddef

#define HERODEATH_STALRAG
    [event]
        name=last breath
        [filter]
            id=Stalrag
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}

        [message]
            speaker=Stalrag
            message= _ "Farewell, my friends. I now go to join my fallen brothers."
        [/message]

        # not necessarily a unit has to be matched
        [role]
            type=Dwarvish Berserker,Dwarvish Ulfsurker
            role=Shinsplitter
            search_recall_list=no
            [else]
                [role]
                    type=Dwarvish Berserker,Dwarvish Ulfsurker
                    role=Shinsplitter
                    search_recall_list=only
                    [auto_recall][/auto_recall]
                [/role]
            [/else]
        [/role]

        [message]
            role=Shinsplitter
            message= _ "No, Stalrag! Without you what will become of the Shinsplitters?"
        [/message]

        [message]
            speaker=Stalrag
            message= _ "Shinsplitters... join Tallin... He is your new... leader... trust... and... serve... him... as... you... have... served... me."
        [/message]

        [message]
            speaker=Tallin
            message= _ "Your death shall not go unavenged, brave Stalrag. DEATH TO THE ORCS!!"
        [/message]

        [message]
            role=Shinsplitter
            message= _ "DIE, YOU FOUL SCUM!!"
        [/message]
    [/event]
#enddef

# Eryssa death
#define HERODEATH_ERYSSA
    [event]
        name=last breath
        [filter]
            id=Eryssa
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}

        [message]
            speaker=Eryssa
            message= _ "Alas, you must continue your mission without me!"
        [/message]

        [if]
            [have_unit]
                id=Elenia
            [/have_unit]
            [then]
                [message]
                    speaker=Elenia
                    message= _ "Eryssa, no! Please don’t die!"
                [/message]
            [/then]
        [/if]

        [message]
            speaker=Tallin
            message= _ "How could this happen? We can’t possibly go on without her..."
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
#enddef

# Macro shortcut with everyone's death macros
#define HERODEATH_EVERYONE
    {HERODEATH_TALLIN}
    {HERODEATH_CAMERIN}
    {HERODEATH_KRASH}
    {HERODEATH_ELENIA}
    {HERODEATH_THERA_AND_MORVIN_NO_DIALOG}
    {HERODEATH_STALRAG}
    {HERODEATH_LICH_BROTHERS}
    {HERODEATH_ERYSSA}

    {SUPPORTER_DEATH_HANDLER}
#enddef

# This death event tries to find a new supporter.
# In case it fails, a supporter will be availaible in the next scenario.
#define SUPPORTER_DEATH_HANDLER
    [event]
        name=die
        [filter]
            role=Supporter
        [/filter]

        [role]
            side=1
            type_adv_tree=Peasant
            [not]
                id=Tallin
            [/not]
            [not]
                # The currently dying unit would match otherwise.
                role=Supporter
            [/not]
            role=Supporter
            search_recall_list=no
            # With the current dialogue it's also fine if none is found.
            [else]
                [role]
                    side=1
                    race=human,dwarf
                    [not]
                        id=Tallin,Camerin,Stalrag,Sister Thera,Father Morvin
                    [/not]
                    [not]
                        role=Supporter
                    [/not]
                    role=Supporter
                    search_recall_list=no
                [/role]
            [/else]
        [/role]
    [/event]
#enddef
