Meh, new topic = more exposure.
Code:
# CivFlee.cog # This cog gives civilians an aversion to armed gunmen roaming amongst them. # [Grismath] #======================================================================================# symbols message startup message pulse message timer thing player local thing civ0 thing civ1 thing civ2 thing civ3 thing civ4 thing civ5 thing civ6 thing civ7 ai regular ai flee flex fTime // Length of fleeing period int X=0 local int Y=0 local end #======================================================================================# code #-------------------------------------------------------- startup: Sleep(0.5); for(X=0;X<8;X=X+1) AISetClass(civ0[X], regular); player=GetLocalPlayerThing(); SetPulse(1); return; #-------------------------------------------------------- pulse: for(X=0;X<8;X=X+1) { if(HasLOS(civ0[X], player)) { if(GetCurWeapon(player) != 1) { AISetClass(civ0[X], flee); SetTimerEx(fTime, 1337, X, 0); }}} return; #-------------------------------------------------------- timer: if(GetSenderID()==1337) { Y=GetParam(1); AISetClass(civ0[Y], regular); } return; #-------------------------------------------------------- end