#Trap #76  falling rocks
#Added with Tales of the North MOD
#8d5+2, save vs. DX for 1/3 damage
from eventAPI import *
from APIUtils import *

def fireEvent(e):
   lFlagS = getTag(e, "lFlagS")
   if (not issetany(lFlagS, 0x00000300)):
      return 1
   if (isclearall(lFlagS, 0x00000002)):
      showMessage(e, ["You movements jar loose rubble within the cave walls and ceiling which tumble down upon you. You must move carefully so as not to collapse the entire cave."], optionInput)
      for partyIdx in range(getPartyCount(e)):
         dmg = dice(8, 5, 2)
         if (savingThrow(e, "dex", partyIdx, 0) > 0):
            dmg = dmg / 3
         modifyHP(e, partyIdx, -dmg)
   return 1
