#Trap #6 - Noxious Gas
# 1d8, poison 2d2/4 ticks, save vs. CN for half poison
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, ["A noxious gas settles over the party, causing choking and nausea."], optionInput)
        for partyIdx in range(getPartyCount(e)):
            modifyHP(e, partyIdx, -dice(1, 8, 0))
            die = 2
            if (not savingThrow(e, "con", partyIdx, 0)):
                die = 1
            poison(e, partyIdx, 2, die, 0, 4, 1, dice(4, 6, 240))
    return 1
