First I cast a script effect spell from an activator, it has a huge area, requires no LOS and the script effect always applies:
begin scripteffectstartif getdead == 1 if isactor == 1 if getitemcount PTDeathToken == 0 additem PTDeathToken 1 printtoconsole "Token added" ; added this line for testing and 'Token added' is printed exactly as often as it should be (amount of dead people in cell without token) endif endifendifend
That works well, the tokens are added. Five frames after I cast another spell that consists of a powerful area fire damage effect, a scripted effect that pushes actors away that get hit by the spell and a scripted effect that checks for the tokens. The spell requires LOS, has the same area settings as the fire damage effect and the script effect always applies:
begin scripteffectstartif getitemcount PTDeathToken == 0 if getdead == 1 if isactor == 1 if getiscreature == 1 modpcmiscstat 5 1 additem PTDeathToken 1 else modpcmiscstat 6 1 additem PTDeathToken 1 endif endif endifendif
And that script causes problems. The first time dead people are hit by this spell everything works fine. If they have a token nothing happens, if they don't have a token they get one and the misc stat is modified. But when the spell hits them again afterwards they sometimes get another token and the misc stat is also altered again. The weird thing is that it only seems to happen sometimes. But it shouldn't happen at all or not? I can clearly see that the tokens are added so if they get hit by the spell getitemcount == 0 should make it impossible for the script to run. I tried with getitemcount < 1, I tried to use getself and a lot of other stupid things. The first script doesn't have this problem by the way although the conditions are almost exactly the same.
I would appreciate any help.
EDIT: If anyone has a better idea how to check whether the fire damage effect that is part of the spell caused an actor's death I'd like to hear it.