You could maybe give each character parameters that indicate their mood, in this case something like 'agression'. The agression field would then be a percentage in the range 0..100, that can be fed into the attack routine.
;----------------------------------------------------------------------- ; HandleCharacter() ;----------------------------------------------------------------------- Function HandleCharacter( c.Character ) if GameTime > TooLong then ChangeAgression( c, 1 ) chance = random(100) If (chance < c\Agression) then c\state = "attack" else c\state = "wait" endif End Function ;----------------------------------------------------------------------- ; ChangeAgression() ;----------------------------------------------------------------------- Function ChangeAgression( c.Character, amount ) newAgression = (c\Agression + amount) if ValueWithinRange(newAgression, 20, 80) then c\Agression = newAgression End Function ;----------------------------------------------------------------------- ; ValueWithinRange() ;----------------------------------------------------------------------- Function ValueWithinRange(val, min, max) return ((val >= min) and (val <= max)) End Function