To expand on what sdfgeoff said, a very common technique for creating AI is finite state machines (FSMs). These are defined by states, and the transitions between states. The main focus is on the state. Each state has a set of transitions with different triggering events. An overall AI system then runs the state machine for each ai controlled character. When you run a character’s FSM you are checking the triggers to other states, and if one is triggered, you change the FSM to that new state. In this way the AI character keeps changing states based on those triggered transitions.
I hope this is more insightful than it is confusing