#bwgnomicron
from eventAPI import *
from APIUtils import *

bwgnomicron=0

def fireEvent(e):
   global bwgnomicron
   bwgnomicron = getTag(e, "bwgnomicron")
   if (bwgnomicron == 1):
      return 1
   else:
      showMessage(e, ["What the hell are you doing in here!!! If you want blood, you've got it!"], optionInput)
   fightThem(e)
   if (bwgnomicron == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Gnomicron", 1, 0, 30)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global bwgnomicron
   showMessage(e, ["You defeat the little bastard."])
   bwgnomicron = 1
   setTag(e, "bwgnomicron", bwgnomicron)

def lostFight(e):
   showMessage(e, ["The gnomicron kicks your lifeless body, just to make sure you're really dead."])

def ranAwayFight(e):
   global bwgnomicron
   showMessage(e, ["RUN!"])
   bwgnomicron = 0
   setTag(e, "bwgnomicron", bwgnomicron)
   setExit(e, "maps/bwquadrant4.cfg", 16, 14, 0)