#Trap #3 - Poison Darts
# 3d4+6, poison 2d4+2/40 ticks, save vs. DX for half damage, 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, ["Before you know what's going on, you are hit by darts shooting out of the walls!"], optionInput)
        for partyIdx in range(getPartyCount(e)):
            dmg = -dice(3, 4, 6)
            if (not savingThrow(e, "dex", partyIdx, 0)):
                dmg /= 2
            modifyHP(e, partyIdx, dmg)
            die = 4
            if (not savingThrow(e, "con", partyIdx, 0)):
                die = 2
            poison(e, partyIdx, 2, die, 0, 40, 1, dice(40, 8, 360))
    return 1
