#Alnurti Plot events
from eventAPI import getTag, setTag, playSpecAudio, showPicture, optionInput, giveItems, callEvent, removeItem
from APIUtils import showMessage, poseYesNo, firstHasItem

AlnurtiPlt1 = 0

def fireEvent(e):
    AlnurtiPlt = getTag(e, "AlnurtiPlt1")
    if(AlnurtiPlt == 0):
        return 1
    if(AlnurtiPlt > 3):
        return 1
    showPicture(e, "Alnurti")
    if(AlnurtiPlt == 1):
        greetAlnurti(e)
    if(AlnurtiPlt == 2):
        getToMTower(e)
    if(AlnurtiPlt == 3):   #Set to 3 in Mtower
        thanksSucker(e)
    return 0

def greetAlnurti(e):
    showMessage(e,
        ["Greetings.  I have a difficult task for you, if you are willing. But first, listen to what I have to say before you decide.",
         "I apologize for this, but I have lots of enemies, and none of them must overhear or eavesdrop on us. Let me introduce myself",
         "I am Alnurti the Warlock. I apologize for being hooded, but an accident destroyed my face, and I want to spare you from this hideous view.",
         "Anyway, I bet you know what Figurines are. Some are very common like Wolf Figurines; others are rare like Dragon Figurines. ",
         "And there are the unique ones, designed to invoke deities. I have no idea why they were created, and many have been lost in the past few centuries, ",
         "but I was able to find the whereabouts of the Thor Figurine. "])
    showMessage(e,
        ["Thor is one of these ancient mighty gods, and his Figurine lies hidden in Old Mage Tower in the North East of your city. ",
         "Long time ago, a necromancer named Itrunal lived here, and he had the Thor Figurine in his possession, but he never used it.",
         "Maybe he was killed before that megalomaniac could use it.  I don't know, because the records were destroyed.",
         "It is my mission to seek out and destroy Deity Figurines to prevent another Itrunal from using them. Whoever wields this power is indeed mighty.",
         " Whoever has them all is invincible. Don't worry about me. I am not mighty enough to use it. But I know ways to destroy the Thor Figurine. ",
         "I would venture into Old Mage Tower myself, but I am too old to go on such an adventure. "])
    showMessage(e,
        ["This is an important mission, and I am very desperate. Therefore, I make you the following proposal: ",
         "Bring me this Figurine, and you can keep each and every treasure you find in there, and I know of some ancient treasures that lie in Old Mage Tower.",
         "While the path into the tower was mystically blocked by ancient magics, I have means of opening them for you, and will do so before you reach it"])

    setTag(e,"AlnurtiPlt1", 2)
    getToMTower(e)

def getToMTower(e):
    showMessage(e,
       ["You have proven your valor in liberating Rennibister from the ExorArcanists, now I ask you help keep the world safe from those who would abuse the power",
        " of these figurines. Go to the Mage Tower and liberate the Thor Figurine before someone untrustworthy beats us to it!"])

def thanksSucker(e):
    showMessage(e,
        ["\"Wonderful. This will be a heavy blow to anyone who wants to use this power! Thank you for everything.\""])
    holder = firstHasItem(e, "Thor Figurine")
    if holder >= 0:
        removeItem(e, holder, "Thor Figurine")
    setTag(e, "AlnurtiPlt1", 4)
    showMessage(e, ["With that, Alnurti walks out the doors of the palace, Thor figurine in tow."])
    showMessage(e, ["Suddenly, a strange mist begins to fill the room, and a Spectre appears!"])
    showPicture(e, "Spectre")
    showMessage(e, 
        ["You did so well, and yet so poorly. We, the Spectres, were the guardians of the Thor Figurine. Now that it is recovered, we can have our eternal rest.",
         "Thank you for this. But listen: You gave this precious item to this strange Alnurti. He tried to enter the tower and was driven out. ",
         "We could not see much, but one thing is for certain; he bears much evil inside. And he has the powerful potential to awaken Thor - and to subdue him to his will.",
         "Your time has not come, yet, to face Alnurti in battle. But you will, that much we know. You must not allow him to awaken Thor! ",
         "For if he does, there will be a DARK RESURRECTION of evil from which no one may survive!"] )
    
    #play the outro movie, and go forth (load Event?)
    callEvent(e,8000,["pics/intro/finale.mpg"]);
