A_ChangeFlag
From ZDoom Wiki
A_ChangeFlag (string flagname, bool value)
Changes the specified flag and sets it to the given value. Not all flags will produce useful results when changed during gameplay.
Example
This imp will activate the FRIGHTENED flag when it enters its pain state, meaning it will attempt to flee from the attacker when hit.
actor CowardImp : DoomImp { states { Pain: TROO H 2 A_ChangeFlag("FRIGHTENED", 1) TROO H 2 A_Pain goto See } }