[z2168] Refactor code to check for scripted events

(based on commit [12246] - f4b7631)

(based on commit [s1801] - f033a87)