This will be very helpful, thanks a lot! Btw, should the token have any particular properties? All I'm guessing is that it should remove itself when the actor dies or otherwise stops being affected by the script.
Edit: Thanks for the tips on the explosion! I am trying to create a "fear" system, where if your character is wearing Power Armor some enemies will flee!
You should not use FOSE for this as even with a Depth of 0 it will catch Actors that are in completely different areas then the player -> then forcing you to use GetLOS and multiple other functions just to try to prevent actors not in direct sight and distance from being effected -> something that Explosions will not have an issue with as they obey LOS by default and any actors not within thier radius will not be effected as well -> its just easier for this type of effect.
Also avoid Tokens especially when they are used in combat situations as any item added to actors resets their AI and in most cases it causes them to do nothing instead of continuing with the Fight or Flight response...
An effect that just does something similar to below will get the job done on a singluar level -> if you want a mob mentality then just use an Explosion to capture the refs around the player you also need to keep track of the number of refs passed into the quest -> very simple If Quest.Target1 == 0 set Quest.Target1 to GetSelf, Set Count to Count + 1 holding multiple targets and a current ref count (my own scripts keep reference over 30 targets I know of a few other people who keep up with 100 or more A bit much to be honest) then what you do is decide how many is to many and do an AV check for Confidence and Aggression to determine who would run and who would fight then from in the quest apply the flee magic effect.
Zero Tokens to have to clean up or worry about actors that ran into another cell and evaded high process causing issues with dynamic reference bloat, and if the actors run away with the script applied it does not matter because FO3 respawns with base stats instead of modified stats so there is zero lasting impact on save games.
In the ScriptEffectStart block
Set Active to 1
Set Aggression to GetAV Aggression
Set Confidence to GetAV Confidence
SetAV Aggression 0
SetAV Confidence 0
ForceFlee
In the ScriptEffectFinish block
If Active
SetAV Aggression Aggression
SetAV Confidence Confidence
EVP
Endif
As far as the quest script goes I would set it to only process every second and just use a switch variable to either pop the ref collection magic effect and flip the switch so the next second it will do the fear processing and flip the switch back -> in this way the quest script is light weight not being an every game frame effect and having it do stuff once per second would be imperceptible to the player.