#eastern keep melvin the magnificent
from eventAPI import *
from APIUtils import *

rtmelvinFlag = 0

def fireEvent(e):
   global rtmelvinFlag
   rtmelvinFlag = getTag(e, "rtmelvinFlag")
   if (rtmelvinFlag == 2):
      helloMelvin(e)
   else:
      return 1
   return 1

def helloMelvin(e):
   global rtmelvinFlag
   showPicture(e, "Gnome_Male02")
   showMessage(e, ["You bump into Melvin again..."])
   showMessage(e, ["\"Hello there!\"", "", "He quickly hides his hands, and whatever he was holding onto, behind his back."])
   showMessage(e, ["\"Any luck?  Yeah, I know this place is devoid of anything really nice.\"", "", "\"I think that I got here a few hundred years too late.\""])
   if (poseYesNo(e, ["\"This place kinda reminds of another castle that I used to visit on occasion.  Let me tell you about the time...", "", "Will you listen to his story?"])):
      tellStory(e)
   else:
      showMessage(e, ["\"That's okay.  I have a lot more to see here.\""])
      showMessage(e, ["Without even a pause, Melvin dusts himself off and heads out the door."])
      showMessage(e, ["\"I'm sure that we will meet again.  Good luck to you, friends!\""])
   rtmelvinFlag = 3
   setTag(e, "rtmelvinFlag", rtmelvinFlag)

def tellStory(e):
   showPicture(e, "Gnome_Male02")
   showMessage(e, ["\"Okay, this is the story of how I slayed a demon and saved the life of the king.\""])
   showMessage(e, ["\"A few years back me and my brother Marvin had obtained a bundle of wands that could open any lock.  Now, we had found about a dozen of these things just sitting on the desk of some local wizard.  Being the enterprising gnomes that we are, we decided that such magic was useless sitting on a desk, so we put them to good use.  One evening we magiked our way into the castle in order to have a little look around, as castles are often places where people just leave items lying around.  You know, things that royalty might not think are important but that the rest of us might have a good use for.\""])
   showMessage(e, ["\"So, we're opening up the rooms and cataloging the contents of all the chests when the wand my brother was using ran out of charges.  He gets another one from the bundle and waves it around to pop the lock on a particularly gaudy gold chest.  Really, sometimes the royals have no taste in decor.  Well, it seems that maybe not all of the wands were for picking locks as this thing sparkles and shoots out a beam of energy that gates a demon right into the middle of the room.  We, of course, were not prepared for such an event, so neither myself or my brother had any sort of real control over the creature.  It started to tear the room apart.  Knocking over all the furniture and breaking all sorts of pottery and such.\""])
   showMessage(e, ["\"My brother, Marvin, was waving that silly wand around, trying desperatly to figure out how to get the demon back into it.  So I tackled him to stop him before he released another one of those buggers.  Good thing I knocked em out of the way, too, cause that demon then decided it wanted to wreck a different room and it burst through the door and out into the hall.  Wouldn't you know, that when that demon exploded out into the corridor, it came upon a couple of fellas all dressed in black and carrying poison knives.  It seems that someone had hired a couple of assassins to take out the king and that night just happened to be the night.\""])
   showMessage(e, ["\"Wow, were they ever scared.  They were also no match for an out-of-control demon.  It was a pretty messy encounter.  I kinda hope those fellas were so shocked that they didn't feel that much pain, cause it sure looked like it hurt.  So, the king was saved, but we still had that crazed demon on the loose.  And after all that noise I figured that we wouldn't be alone for much longer.  So, I grab another one of those wands from my brother and zap it at the ceiling above the demon.  Funny thing how those lock zapping wands will also zap the mortar that holds all the rocks in a house together.  Had about 3 floors worth of rubble fall down on that thing.  Of course, right about that time the guards finally arrived.  I tried to explain how I was just there to foil the assassination plot and that I was sorry for the amount of destruction that resulted, but at least the king was safe and all.  Marvin was at least smart enough to sneak out while I had em distracted.\""])
   showMessage(e, ["\"I think I spent about two weeks down in that dungeon before my brother, Marvin, finally got up enough courage to try one of the wands again.  Zapped me out of that dungeon quick and we left for greener pastures.  I guess the real lesson of that story is that wizards are stupid for not labeling wands properly.\""])
   showMessage(e, ["Without even a pause, Melvin dusts himself off and heads out the door."])
   showMessage(e, ["\"I'm sure that we will meet again.  Good luck to you, friends!\""])
   rtmelvinFlag = 3
   setTag(e, "rtmelvinFlag", rtmelvinFlag)
   return 1