Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm looking for a way to create a convincing Berserker enemy in a Roguelike I've been creating for some time. You may assume a game like NetHack for this when considering what kinds of actions can be taken and text messages that can be alerted.

I ask this for two reasons:

  1. I've been trying to solve this problem for over a year and have failed. Examples to follow.
  2. I see a general lack of examples on this SE that show what a mapping of an entity's states, in total, looks like. It would be helpful to the community to have such an example.

What I need:

When I say Berserker I mean an enemy that can swing into a blind rage and attack other entities that it is in conflict with with violence and bloodlust. Not simply switching to attacking targets randomly, as is done in many RPGs. To this end, feel free to assume the addition of any status effects or buffs you wish. Just make sure you detail the pertinent information for those states.

A berserk entity needs to express his rage in a way that isn't simply a status change with some strength increases. This is a very shallow solution to the problem. The entity doesn't end up feeling like a Berserker at all.

What I've Tried:

I've tried 3 different ideas over the last year. And none of them satisfy. A solution to the problem could be all new, or a 'fix' for one of these. I am mainly including them to get the juices flowing.

  1. The first thing I tried was a simple Berserk state that increased the strength of the entity, randomized its target (from list of enemies), had him shout obscenities, so on. Once in this state, the enemy would remain in it until death.
  2. The next thing I attempted was really a modification of the above. The enemy felt very flat, and there was no way to calm him or knock him out of his rage which seemed unrealistic. I added the ability to calm (with a spell and other effects) and also added a condition that would return the enemy to a normal state, from which he could transition to others such as fleeing. This created more depth, but made the Berserker state seem even more shallow and less destructive.
  3. From here I scrapped it all and aimed for something more emergent. Essentially a buff that the enemy could cast on itself based on a transition state. Once cast, this would change the enemies behavior (for targeting) and increase their damage while randomly issuing insults from the enemy. Then, he could enter any other states and stay enraged. So he might flee, but still taunt. He might heal, but still be enraged and deal lots of damage. This is better, but the underlying issue still remains. He doesn't really seem berserked, just pissed. Mainly because you typically encounter the enemy alone, and not with other enemies the berserker doesn't like, so the randomization aspect is down played.

How else can I make the guy seem Berserked, and not just pissed/foul-mouthed?


I realize this is a borderline list question. So I impose these requirements: It must be a very detailed complete answer that shows all the states and conditions for transitioning. And it must be more than a guess. You should test this in your own roguelike, or it should otherwise be obvious why this is a probable 'best' solution at getting the idea of Berserk status across.

I also won't take offense if this is closed. I realized it dances the edge.

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

Berserker-psychology

  • He is pissed/aggressive. (Therefore, he needs a reason and a target to be pissed.)
  • When he's pissed, he gets more dangerous (Also, if he isn't pissed anymore, he's back to normal.)

Trigger - The reason he goes berserk

  • He gets insulted
  • He gets hurt (or more interestingly, he gets hurt a certain critical amount)

Effect

  • He gets stronger
  • He gets faster
  • He gets more health
  • He starts shouting insults
  • He starts following the person who dealt the damage

Player-Defense

  • Player can kill the berserk
  • Environmental damage kills the berserk (lead him into a trap)
  • Player can slow the berserk
  • Other NPC/Player/Enemy hurts the berserk critical -> berserk follows now the new target
  • Over time the berserk calms down (if he does not get hit again)

How this would play

The player meets the enemy. a) Player deals multiple-times small damage (the enemy fights back, but does not go berserk), b) Player deals big damage, the enemy loses a lot of health, but goes berserk. The player must now flee. While fleeing he can a) deal further damage, b) slow the berserk. If a) the enemy stays berserk or dies. If b) the enemy calms down (slowing him, does not deal critical damage). When he's calmed down, you can attack him again critically. Maybe he dies now :-)

Note: If you don't agree with my statement, that the berserk does attack the target that hurt him, you could change that so, that the berserk attacks the nearest character. This would be interesting, if he got attacked from a distance. (For a sword-fighter it would be the same.)

share|improve this answer
4  
Some more possible ideas: 1. Have the berserker attack his target and anyone between him and the target. Even better if you can make other enemies notice this and scramble out of the way. 2. Missed attacks, or seeing others on his side killed, might also serve as triggers. So two barbarians attack you: you kill one, and the other goes berserk. 3. Lose the potty-mouth. A single shout when the berserk mode is triggered is probably OK, but after that I'd imagine him too focused on attacking to bother with talking. Maybe add a simple attack cry (e.g. "Die!") when he reaches melee distance. –  Ilmari Karonen Feb 29 '12 at 10:00
    
@IlmariKaronen I like these notes. Especially #1. That feels very much like someone in a big group loses his crap and everyone runs for cover. That SCREAMS going berserk to me. The answer itself here is a very good start, but I'm not sure it feels that berserk on its own and I'd love to see some notes on the other states that you would transition to. A lot of what makes good AI that feels alive is how entities transition and what they do. Just flat going from upset to fighting as normal is a bit jarring. –  DampeS8N Feb 29 '12 at 14:09
    
I think most importantly you need an animation supporting the berserk state of the character (he gets a red head, gets bigger, etc.). Visual feedback is much more important than AI-behavior in conveying the emotional state of a character. –  Fabian Feb 29 '12 at 18:24
    
The AI states would be: Calm -> GettingAngry (an animation && deals some damage to all near objects) -> Attack/Chase -> BeingExhausted (he's especially vulnerable) -> Calm –  Fabian Feb 29 '12 at 18:34
    
@Fabian That would depend on the visual integrity of the roguelike. In this case, we're talking text glyphs. So the best I could do is a red/flashing character. That's why this problem is hard, because I don't really have anything more than a behavior to clue the player into what is happening. I can label them on inspection as berserk, but what meaning will that bring? Actions speak louder. –  DampeS8N Feb 29 '12 at 19:18
show 2 more comments

I suppose the answer depends on just what you think of as a "berserker".

The historical Berserkers were shock troops who focused their attention on engaging and slaying their opponents with little regard to anything else, including their own safety or that of others on their side. Different sources disagree on just how indiscriminate they were in their killing: some describe them as willfully slaying anyone and everyone around them, while others merely describe them as fearless warriors. Here's a fairly middle-of-the-road quote from the Ynglinga saga, via Wikipedia:

"His (Odin's) men rushed forwards without armour, were as mad as dogs or wolves, bit their shields, and were strong as bears or wild oxen, and killed people at a blow, but neither fire nor iron told upon them. This was called Berserkergang."

So, my conception of a berserker would be something like this:

  • Completely fearless, probably oblivious to pain. Willing to engage enemies of any level.
  • Highly focused on fighting, to the exclusion of anything else going on around them.
  • Not completely indiscriminate in killing, but probably willing to attack friendlies (perhaps without even noticing) if they get in his way. Might also attack friendlies if there are no enemies around, but should still prefer enemy targets if there are any.
  • Disdainful of subtle or cautious tactics: charge the enemy and hack them to bits is the name of the game here. Prefers mêlée combat, but might use sufficiently powerful ranged weapons (like guns, preferably on full auto and fired while running towards the enemy) if available.
  • Unnaturally strong and tough — maybe not Superman-level tough, but they should definitely get some attack and defense bonuses, and perhaps a slight speed boost.

So, how would I translate these traits into game AI behavior? Well, here are a few ideas:

  • This should be kind of a no-brainer, but a berserker should never run away, even if he's down to a single hit point and bleeding. Just turn that code off. Ditto for any other "defensive" tactics.

  • Prioritize tactical options in this order: 1. Attack. 2. Move towards target. 3. Everything else. In particular, berserkers should not stop to pick up items if there are enemies in sight, even if the items are, say, better weapons than they currently have. (However, switching from bare hands to an already held mêlée weapon might be reasonably prioritized even over attacking.)

  • If both attacking and chasing after the target can ever be valid tactical options at the same time, consider giving your berserkers the ability to do both at the same time (an attack "in passing"), even if your creatures can't normally do that (possibly with an accuracy penalty to compensate). That way, your berserkers won't have to slow down their charge to take attacks of opportunity.

  • Target selection: I'd suggest just picking the nearest visible enemy (regardless of level) and having the berserker chase him, at least unless another enemy comes significantly closer (say, half the distance to current target). Keep chasing the target even if you temporarily lose line of sight, as long as the target doesn't get too far away. This should give some feeling of single-mindedness. Once the target is in mêlée range, attack him.

  • Pathfinding: If there are friendlies between the berserker and his target, consider letting him just attack them and hack his way through. It's up to you how eager to do that you'll make him — at least he should do it if there's no other path to the target, but you might even consider making him ignore friendlies entirely in pathfinding.

  • The above probably works best if you also make the (non-berserker) friendlies try to flee out of the square that the berserker will be next moving into (and maybe the next square or two in his path, too). Of course, if there's too much crowding, they might not be able to flee in time...

  • If there are no enemy targets around, consider letting the berserker attack nearby (adjacent, or maybe one or two squares away) friendlies instead. Of course, said friendlies should try to flee. On any turn where the berserker has no enemy target and doesn't make an attack, make him move around randomly and give him a random per-turn chance of calming down and reverting to normal state.

  • Weapon choice: As I noted above, real berserkers were big on mêlée combat. Don't use ranged weapons, unless they're particularly common and powerful in your game (e.g. guns in a modern setting). If you do let your berserkers use ranged or area-effect weapons, let them fire them while chasing their target (see "in passing" attacks above). Obviously, collateral damage should be ignored (by the berserker — making other enemies scramble to stay out of the line between you and a berserker with a gun would be a very nice touch).

  • And, of course, the berserker should have appropriate attack, defense and speed buffs. They should probably also be immune to any fatigue or fear effects. If blinded or confused, just have them make random attacks in the hope of hitting something.

You noted that you want berserking to be a state that can sometimes be entered by normal enemies (with a propensity to it). Thus, you'll need to decide what will trigger it. IRL, traditionally described triggers include combat, heavy exertion and stress. Some potential triggers for a game might include:

  • seeing enemies,
  • attacking,
  • being attacked,
  • being seriously wounded,
  • seeing others in combat,
  • seeing others get killed, or
  • seeing traces of combat (bloodstains, dead bodies).

None of those should probably IMO be an automatic trigger; rather, there should be a random chance for each such event to trigger the berserk state, with the odds perhaps varying based on individual propensity and the severity of the event. Also, combinations of several triggers might make berserking more likely: for example, the presence of a visible enemy might be a precondition for any of the other events to trigger berserking, while low hit points might increase the odds for the other triggers.

Also, you might consider introducing a "rage meter" instead of just a simple on/off berserk state. For example, a newly triggered berserk might start at, say, rage = 1, with attacking and being attacked increasing the meter, and not seeing any enemies decreasing it. At low rage, a berserk would simply be fearless and buffed, but would generally avoid attacking friendlies, while increased rage would increase the buffs but also make the berserker's attacks less and less discriminate. When the rage meter goes down to zero, the berserker calms down and goes back to normal.

As for the obscene shouts, I'd mostly get rid of them: I see a berserker as being too focused on attacking to bother with any silly taunts. I suppose you could have him shout something when the berserk state is triggered, and maybe roar or make a simple war cry when closing to mêlée range, but that would seem enough for me.


Edit: After re-reading what I wrote above, I guess that real gist of what I'm trying to say is this: don't focus too much on the berserker AI itself. In the end, it's likely to turn out pretty simple, probably much simpler than your normal enemy AI. Instead, focus on how the other enemies will behave when they see a berserker nearby — that's where the really interesting dynamics will arise.

share|improve this answer
1  
Re target selection, once he starts chasing someone he could have a very narrow field of view, so he rushes past other enemies without even seeing them. –  Peter Taylor Feb 29 '12 at 15:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.