How it Works
The battle circle AI basically works like this (from an enemy's perspective):
First, walk towards the player until I get within a "danger" radius

While in "danger" mode, don't get too close to another enemy, unless I am given permission to attack the player. (See Avoider.cs.)

Also while in "danger" mode, try to approach the player. If there are too many enemies in my way, I will effectively not be able to reach the player until the enemies move or the player moves.
When the player is in my "attack" radius (roughly the maximum range of my attack) ask the player if I'm allowed to attack. If so, add me to the list of current attackers on the player object. (See SwordzPlayer.cs.)

- If there are already the maximum allowed number of attackers on the list, I'm denied permission.
- If I'm denied permission, try strafing for a second or two in a random direction until I'm given permission.
- If the player moves out of attack range—even if I'm attacking—remove me from the attacker list.
- If I die, or am stunned or otherwise unable to attack, remove me from the attacker list.
The maximum allowed number of simultaneous attackers (
simultaneousAttackers in SwordzPlayer.cs) is critical in balancing your battle circle. A higher number causes an exponential increase in pressure. In the example demo I have it set at 2; less twitchy and more "cinematic" games set it at 1. If you put this number too high, you defeat the purpose of the circle, because large groups of enemies become unassailable or can only be defeated with uninteresting poke-and-run tactics.
Of similar importance is the enemy attack rate (
attackRate in EnemyMob.cs). This is not the fastest possible attack rate of the enemy, but how often they will choose to attack when given permission. As you would expect, a lower number increases pressure, but you should generally have this be several times higher than the real attack rate. You can make this rate a bit more unpredictable (and thus the amount of pressure slightly less predictable) by increasing attackRateFluctuation, which will increase or decrease the attack rate after each attack.
Using this system, you have the basic means to create that illusion of power that makes it a lot more fun for your players to fight lots of enemies at once.
Conclusion
There are tons of minor changes and additions you can make for combat inside the circle to be even more interesting:
- A "stun" or "counter" attack the player can use to put enemies out of combat for a few moments, so the player can attack other enemies in the circle
- A "dodge" move for the player to quickly travel into, out of, or within the circle
- "Push" and "pull" moves that let the player move enemies into and out of the circle
- Ranged enemies that will snipe at the player through openings in the circle, and encourage the player to force themselves through the circle to attack these enemies first
- Special "captain" enemies that increase the attack rate of enemies near them, or ignore permission to attack, and thus increase the pressure of certain portions of the circle
So get those creative juices flowing! This is just the beginning: make the battle circle a core part of your gameplay, and make your own version of the circle that fits well with your game.
No comments:
Post a Comment