Original Post
I've been putting off working on this because I can't seem to find a clean solution for it. I've made a simple AI that moves around on command, attacks enemies with whatever weapons it has, but I'm stumped as to how to write a pursue state without duplicating code from both the walk and attack states. Doing single states that handle their own thing is fine, but when trying to combine them in different ways makes me wonder how I'm going to go about implementing them.
For example, say you order units to move to a specific location but along the way the units encounter an enemy. You'd want them to take a few shots at them before continuing on, without pursuing them. The problem is with the states changing so often it's hard to keep the orders between the different states. The only other thing I can think of is that the global state handles orders, and tells the secondary state to work on those orders. But even that is kind of messy.
Has anyone worked on something similar?
For example, say you order units to move to a specific location but along the way the units encounter an enemy. You'd want them to take a few shots at them before continuing on, without pursuing them. The problem is with the states changing so often it's hard to keep the orders between the different states. The only other thing I can think of is that the global state handles orders, and tells the secondary state to work on those orders. But even that is kind of messy.
Has anyone worked on something similar?