游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

以特殊AI让玩家挑战敌人群体攻击的方法

发布时间:2014-03-27 16:55:02 Tags:,,,,

作者:Kenneth Backus

混战是电子游戏领域最喜爱的消遣方式之一,被许多知名与不知名的游戏系列所采用,如果执行得当还可以产生一种紧张感和扣人心弦的体验。许多游戏开发者会认为某款游戏“如果拥有大量坏人就会更棒”,有时候的确如此,但通常情况下还要看整体效果,有时候同时与大量“坏蛋”过招并没有像一次仅同一人战斗那样令人兴奋或富有深度。

许多混战游戏在设置与多名对手而战的场景时并不使用任何特殊AI。这通常意味着同时与两人对打的难度要数倍于与一人过招,因为他们会同时攻击,而你只能还击其中一人。最糟糕的是,当与敌人群殴时,这就意味着玩家的最理想策略是将敌人引向一个单线队列,然后在后退过程中将他们各个击破。这听起来并不是那么好玩或令人兴奋,不是吗?

demo(from gamedevelopment)

demo(from gamedevelopment)

在上图这款游戏中,进入“战斗循环”状态,游戏中的AI代码就会告诉敌人有意包围玩家,并且只在玩家有机会还击时才进行攻击。这会迫使敌人以一种对玩家来说更有趣的方式和节奏来战斗……尽管这实际上是一种很糟糕的战术!

你会想使用战斗循环的主要原因就是让玩家觉得他们同时与许多敌人战斗,但却无需面临同时与多名敌人交手的挑战。因此,这实际上是一种错觉。你有意为玩家简化这种战斗,这样他们就可以体验到同时与多人战斗的美妙感,并且知道自己不会有幸命之忧,就好像许多功夫电影一样。

每款游戏使用战斗循环的方法未必都要如出一辙,如果你选择使用这一方法,就要花时间令它适用于你的游戏。一方面,你中以采用“电影式”的战斗循环,就像《刺客信条》或《蝙蝠侠:阿卡姆疯人院》的做法一样,让敌人耐心等待轮到自己的回合,给予玩家处理即将到来的战斗这种提醒。另一方面,你若采用类似于《暗黑之魂》这种“危险性”战斗循环,就要让敌人尽量不会相互妨碍,但却有可能将玩家一举歼灭。

我使用了“电影式”以及“危险性”这个词来描述玩家进入循环时所预期的体验,它应该是让玩家感觉舒适、令人兴奋的视听体验呢,或者应该是玩家应该试图避免的薄弱姿态?

这个概念可以进一步简化为简单地管理好玩家所面临的压力。这是玩家回应战斗循环中的敌人所需要的动力。低压力的循环会让玩家等待回应下一轮攻击,或者在不受到立即回击的情况下继续攻击特定的敌人。高压力的循环会迫使玩家在进入该循环时就马上选择“战斗或逃跑”策略,所以一开始就必须事先考虑好是否要进入这种循环。虽然身处如此危险的循环,玩家还是必须决定要攻击谁,回击谁,以及何时及如何逃跑。

它的运行方式

战斗循环AI基本上运行方式如下(从敌人的视角来看):

首先,要走向玩家直到进入一个“危险”半径。

battlecircle_600_01(from gamedevtuts)

battlecircle_600_01(from gamedevtuts)

身处“危险”模式时,不要过于接近另一名敌人,除非我得到了攻击该玩家的许可。

battlecircle_600_02(from gamedevtuts)

battlecircle_600_02(from gamedevtuts)

同样在“危险”模式状态时,要尽量接近玩家。如果有太多敌人挡我的道,我将无法接近玩家,除非敌人移动或玩家移动。

当玩家处于我的“攻击”半径(几乎是我的最大攻击距离)时要询问玩家是否可以开始攻击。如果可以,就要将我添加到玩家目标的当前攻击者列表中。

battlecircle_600_03(from gamedevtuts)

battlecircle_600_03(from gamedevtuts)

*如果列表中已经存在最大数量的攻击者,那么我就拒绝批准。

*如果我拒绝了批准,就要向随机方向扫射一两下,直到获得批准。

*如果玩家移出了我的攻击范围——即便我还在攻击,那就要将我从攻击者列表中移除。

*如果我死了,或者受到惊吓或因其他原因而无法攻击,那就将我从攻击者列表中移除。

同时攻击者的最大数量是平衡战斗循环的关键。较高的数量会导致玩家压力成倍增长。在我所展示的样本中,我将这一数量设置为2,将较不紧张和更为“电影式”的游戏设置为1。如果你把这一数据设置得过高,你就会破坏这个循环,因为庞大的敌人群体会变得无懈可击,或者可能需要采用无趣的战略才能击败。

敌人攻击率attackRate也很重要。这并不是敌人的最快可能攻击率,而是他们得到允许时所选择的攻击频率。较低数据会减少压力,但你应该让它比实际攻击率更高数倍。你可以通过增加attackRateFluctuation让这一频率更具不可预测性(因此压力也较为不具可预测性),这会增加或减少每次攻击的攻击率。

使用这一系列,你就掌握了让玩家以更有趣的方式同时与多名敌人战斗的基本方法。

总结

你还可以进行一系列微调整让这些战斗循环更有趣:

*添加“打昏”或“反击”以便玩家将敌人暂时放倒,这样玩家就可以攻击这个循环中的其他敌人。

*让玩家采取“躲避”措施,以便快速进入或逃离这个循环。

*采用“推”和“拉”举措,让玩家将敌人引进或推出该循环。

*远程攻击的敌人会在循环泊入口狙击玩家,这会鼓励玩家迫使自己通过该循环首先攻击这些敌人。

*特殊的敌人“首领”可以增加其附近敌人的攻击率,或者忽略攻击许可,因此会增加这个循环特定环节的压力。(本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转载,如需转载请联系:游戏邦

Battle Circle AI: Let Your Player Feel Like They’re Fighting Lots of Enemies

by Kenneth Backus

Melee fighting is a favorite pastime in videogameland, the core of countless series both well-known and obscure, and a tense and gripping experience when done right. Many a game developer has taken a game of two beings biffing it out until one can biff no more and thought, “this would be so much better if there were tons of baddies!” Sometimes this is true, but often the sum is greater than its parts, and fighting lots of “baddies” at once isn’t as exciting, deep, or nuanced as fighting one at a time.

Many melee combat games don’t use any particularly special AI when fighting multiple opponents. This often means that fighting two opponents is exponentially harder than fighting one, because they’ll both attack at the same time but you can only really retaliate against one of them. In the worst cases, when fighting hordes of enemies, this can mean that the optimal strategy is to lead the enemy into a single-file line, then attack them one at a time while backpedaling! That doesn’t feel very fantastic or exciting, does it?

Skip to 0:53.

Enter the “battle circle”. This is a piece of AI code that tells enemies to intentionally encircle themselves around the player and only attack when the player has a chance to react. This forces enemies to fight in a style and tempo that’s a lot more fun for the player… even if it’s actually a really bad fighting tactic!

The main reason you’d want to use battle circles is to let the player feel like they’re fighting many enemies at once, without actually facing the real challenge of fighting many enemies at once. Thus, at its very core, a battle circle is an illusion. You’re intentionally making things easier for the player so they can experience the fantasy of taking on a bunch of dudes at once and knowing you’re going to come out alive, just like in any martial arts movie.

Skip to 1:13.

A battle circle doesn’t have to work the same way for every game; if you choose to use one you must spend time tailoring it to your game. On one end of the spectrum, you have “cinematic” battle circles, like in Assassin’s Creed or Batman: Arkham Asylum, where enemies patiently wait their turn before attempting to attack, and give the player plenty of warning to deal with incoming attacks. On the other end, you have “dangerous” battle circles, like in Dark Souls, where enemies will try to stay out of each other’s way, but otherwise have no problem mobbing you en masse.

I use the words “cinematic” and “dangerous” to describe the sort of experience the player is expected to have when inside the circle; is it more of an exciting audiovisual experience that the player should feel comfortable in, or should it be a vulnerable position the player should try to avoid?

This concept can be simplified further as simply managing the amount of pressure on the player. Specifically, this is the amount of motivation the player has to react to the enemies in the battle circle. A low-pressure circle will let the player wait for incoming attacks to counter, or proceed to attack a particular enemy without immediate retribution. A high-pressure circle will force the player to pick “fight or flight” as soon as they are in the circle, so that entering the circle in the first place should be a premeditated tactical decision. While inside such a dangerous circle, the player must immediately decide who to attack, who to counter, and when and how to escape.

I’ve provided a fully-functional, if minimalistic arena-style beat-em-up in the example Unity files. If you don’t use Unity, you should still have a rough idea of how to adapt the battle circle code to whatever language and engine you’re using. The files you’ll be interested in are EnemyMob.cs and SwordzPlayer.cs.

Here’s the battle circle in action. Click the demo to give it focus, then use the arrow keys to move and press X to biff.

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.(source:gamedevelopment


上一篇:

下一篇: