#Main RingQuest Plot Event #5
# Riddle for, and acquisition of, Cloak of the True Hero
from eventAPI import getTag, showPicture, stringInput, optionInput, setTag, giveItems
from APIUtils import isclearall, showMessage

def fireEvent(e):
    RingPlt1 = getTag(e, "RingPlt1")
    if (not isclearall(RingPlt1, 0x10000)):
        return 0
    if (not isclearall(RingPlt1, 0x8000)):
        return 0
    showPicture(e, "Elf_Male")
    answer = stringInput(e,
        ["The image of an ancient Elven mage appears before you.",
         "",
         "\"Before I can grant you the Cloak you seek, you must answer me one question...",
         "",
         "\"Four traits are embodied in the True Hero.  The first three are Valor, Bravery and Wisdom.  What is the fourth?\""])
    if (answer.lower() == "mercy"):
        RingPlt1 |= 0x18000
        setTag(e, "RingPlt1", RingPlt1)
        showMessage(e,
            ["\"Correct!  Take the Cloak you've earned, and wear it with pride!\"",
             "",
             "The apparition disappears."], optionInput)
        giveItems(e, ["Cloak of the True Hero"])
        return 1
    else:
        showMessage(e,
            ["\"Incorrect!  The answer lies within these walls, return when you have found it.\"",
             "",
             "The apparition disappears."], optionInput)
    return 1
