Hello. So I have things in my game for my NPC AI that I’ve been thinking of as actions, but it is basically a large chunk of code in a method known as something like “Find Food” or “Run From Enemy”. Obviously running from an enemy is far more important than finding food, and the NPC can only focus on one of these at a time, so how do I give an action such as that a priority over other less helpful actions? Of course, I could do something such as the code below, but that looks like a horrible way to do it and I’d have to modify all the code everytime I add a new action for the NPC to take.
//Bad looking way for letting the NPC choose which action to take.
if (Enemy != null){
EvadeEnemy ();
} else{
FindFood ();
}