In which I admit to completely copping out.
I need to get the discrete event simulation working. I feel I understand the concept but it’s not something I’ve ever done before so I am having some trouble figuring out how to approach it.
So I did graphical stuff instead!
Made the hitpoint bars smaller and made them green instead of red. Changed the selection marker to a blue circle underneath the units. Went ahead and raised the resolution to 800×600, since that’s what the final game will run at.
Now, one thing that is kind of stopping me is that I need to figure out exactly how units act both when they have explicit orders from the player and when they don’t.
Here’s what I’m thinking. Comments welcome.
The current problem is that you can grab a group of units and give them an attack order and they will dutifully go and kill the unit you clicked on, but then they’ll just stand around even if his buddies are right there. And his buddies will stand around too. Obviously, units need to take the initiative and engage if they have no other orders. But units without explicit orders shouldn’t stray too far from where the player put them.
Thus, when you give units move orders, you are not only moving them, you are setting their anchor point. If units do not have orders, there should be a range within which they will move and engage enemies. Archers should never move, they should simply snipe at anything that comes into range, but warriors and barbarians should probably have a range of about three tiles…if an enemy moves into that range, the warrior or barbarian moves to intercept and attack. If the enemy moves out of that range, the warrior or barbarian breaks off contact and returns to their anchor point.
Now, three tiles is less than the range of archers (eight tiles). Thus, if a unit is attacked by the enemy (rather than simply has an enemy come into its range), it can go as far as it needs to in order to engage that enemy, but once that enemy is dead it returns to its anchor point.
These autonomous attacks happen only if the unit has no standing orders from the player. Thus, if you grab a group of units and tell them to move through a group of enemy units, they will not engage as they are attacked because your move order overrides that.
I think that should be close enough to how a “real” RTS feels. Please feel free to tell me how you think it should work.
You might consider the idea of setting stances for the units. I know it’s more work to have different behaviors, but it’s the next step. So, it sounds like this is the default or perhaps the “aggressive” stance. I just say think about stances because you’ll want to add stances later, so you might as well accommodate that while you’re coding up the behaviors.
Yep, it’s more work 🙂
Actually, I’m pretty sure the stance I described is the “defensive” stance. An aggressive stance would allow units to move anywhere to pursue enemies once they are engaged.
And adding new stances will be pretty darn easy with the discrete event simulation. I’m sure I’ll get them in eventually, but right now I just want a very basic system that works well enough.