#plane of air Wind encounter
from eventAPI import *
from APIUtils import *

rtPOAWind1 = 0

def fireEvent(e):
   global rtPOAWind1
   rtPOAWind1 = getTag(e, "rtPOAWind1")
   if (rtPOAWind1 == 1):
      questDone(e)
      return 1
   else:
      firstVisit(e)

def firstVisit(e):
   showMessage(e, ["There is a pedestal with a white orb sitting atop it."])
   showPicture(e, "White_Crystal")
   showMessage(e, ["You peer into the orb.  The space within appears to swirl and a face forms out of the chaos."])
   showMessage(e, ["A voice speaks to you.", "", "\"SET MEEE FREEEEEE!\""])
   showMessage(e, ["The contents of the orb swirl again and the face disappears."])
   hasStone = 0
   if (firstHasItem(e,"Mountain Stone") >= 0):
      hasStone = 1   
   if (poseYesNo(e, ["Do you attempt to break the orb?"])):
      if (hasStone):
         breakOrb(e)
      else:
         showMessage(e, ["Try as you might, your attacks have no effect upon the orb."])
         return 0

def breakOrb(e):
   global rtPOWOcean1
   global rtPOAWind1
   showMessage(e, ["You raise the stone given to you by Mountain over your head and bring it down upon the orb.  A great crash rings out and a small crack appears on the surface of the sphere."])
   showMessage(e, ["\"YESSSSSSS!\", speaks the voice from inside.", "", "\"RELEASSSE MEEE!\""])
   showMessage(e, ["You again raise the massive stone and bring it down with all of your strength upon the orb.", "", "The sphere shatters and you are knocked off of your feet by an explosion."])
   partyIdx = 0
   while (partyIdx < getPartyCount(e)):
      modifyHP(e, partyIdx, -100)
      partyIdx += 1
   showMessage(e, ["You remain on the groud and cover you head as great gusts fling debris in all directions.", "", "After some time, the violent outburst ends and a gentle breeze begins to blow."])
   showMessage(e, ["\"YOU HAVE DONE WELL!\"", "", "The voice is like that of both a shout and a whisper and it comes to you from every direction."])
   showMessage(e, ["\"I SHALL NO LONGER BE SLAVE TO FLAME'S WHIM.  NOW HE MUST APPROACH ME AS EQUAL!\""])
   showMessage(e, ["\"LET HIM SMOLDER, FOR I SHALL NOW EXERCISE MY OWN DESIRES!\""])
   showMessage(e, ["The presence spreads out to fill the entirety of the plane of air.    The trees now sway gently and birdcalls can now be heard.  It seems that your work here is complete."])
   holder = firstHasItem(e, "Mountain Stone")
   removeItem(e, holder, "Mountain Stone")
   rtPOWOcean1 = 2
   setTag(e, "rtPOWOcean1", rtPOWOcean1)
   rtPOAWind1 = 1
   setTag(e, "rtPOAWind1", rtPOAWind1)
   setExit(e, "maps/rtplaneofairb.cfg", 29, 18, 90)
   return 0

def questDone(e):
   showMessage(e, ["The pedestal has been toppled by the violence of Wind's escape and pieces of the shattered orb lay all around.", "", "There is, however, a great sense of tranquility here."])
   return 1
