# Introduction

In Lineage 2, combat is a way of life. In PvE combat, PCs fight mobs to gain various rewards. This article attempts to explain the AI behind mob target selection, and tries to illustrate how PCs can take advantage of it.
In particular, group play relies on a good understanding of how the AI work in order to come up with tactics that are more fun than just the 8-PC-on-1-mob idea. Knowing how the AI works allow each specialized class to be maximized, and this can be lead to greater enjoyment of the game.
Please note that this idea is not universal and in fact is theortical, but seems to be collaborated by observations in game. It's probably how it is programmed on the back end, but short of looking into the code, it's not possible to verify the ideas here.
(And in no way do we claim to be savants when it comes to the Hate idea. Other MMORPG probably have something similar, and someone else probably have covered it in details. It's just that I can't find it. :))

# The Mobs Hate You

In case you hadn't noticed, the mobs don't exactly love you. In fact, they downright hate you. At best they leave you alone; at worst, they come at you with a big cleaver -- or worse. But how do they know who to hit?
If you are soloing, the answer is simple: the mob selects the only idiot PC standing near it swinging a weapon at it or slinging spells at it. That's rather straightforward. But when there are 8 PCs in a party, the mob, being of only one brain, sort of have to figure out which one to hit. So how does it pick one?
In real life, a mob will probably just hit a random PC. In Lineage 2, the mobs are smarter than the average bear though, and would actually pick a PC based on a set of criteria. This set of criteria boils down into a single attribute we can call the Hate factor.

# The Hate Factor

The mobs hate you. We've established that. But what we are really interested in is how they hate you, and what it means when they hate you very, very, much.
* A practical example: 4 PCs (A, B, C and D) ganged up on one mob. The mob will keep track of the Hate Factor for all 4 PCs. Player A hit the mob for 200 points, Player B for 400 points, and Players C and D twiddled their thumbs. The Hate Factor will be 200, 400, 0 and 0 respectively. The mob will look up these statistics, and decide that it hates Player B most, and attacks Player B accordingly.
* -- The Grand High Poohbah
The idea behind the Hate Factor is that it is a set of statistics that mobs have. This set of statistics increases due to some situational factors. Mobs will then use this set of statistic to make targeting decisions just before each attack, picking the PC with the highest Hate Factor to attack.
This means, if 8 players gang up on one mob, the mob will maintain 8 Hate Factors, one for each PC. Whichever PC has the highest Hate Factors is attacked by the mob.
One important thing to remember: the mob's HP has very little to do with a mob's Hate Factor. The Hate Factor and HP are separate statistics. We will see why later.
So what adds to the Hate Factor? We can generalize into the following categories:
* Damage Done to Mob
* Healing done to PC
* Buffs to PC
* Debuffs to Mob
* Other Specialized Situations
We'll look into each in turn.

## Damage and the Hate Factor
### The Relationship

We start off with damaged dealt as this is the simplest category. The first and forthmost rule when dealing with Hate is as follows:
(The assumption here is that the Hate buildup is 1 to 1. It may not be so in practice, but for the purposes of this article it can stand)
That is pretty straight forward, right? Thereforth the mob's maximum Hate factor is equal to its maximum HP, right?
WRONG!
Consider the following situation. Player A starts beating on Mob X. Player B comes along to heal Mob X -- bad boy there. The damage dealt to Mob X by A is going to be greater than its starting HP, which is its maximum.
The thing is, the Hate Factor has to be an open-ended statistic; Hate must be allowed to build as long as the mob is alive, so that it can differentially attack a PC. Otherwise, should Player C come in to the ménage-à-trois above and deal damage equivalent to Mob X's starting HP, Mob X could be possibly reduced to a race condition where it flip flops between the two PCs -- which is fairly stupid behaviour.
While this isn't so obvious in straight damage dealing, when we discuss how healing affects the Hate Factor, it would become more obvious.
(Aside: For those of you software programmers, you would of course realise there is a practical limit to the variable storage of the statistics. Practically though, most mobs' HP never reach that limit, and it takes a perverse bunch of jokers to actively try to breach that limit. So the limit of software storing of the statistic isn't really a big issue here.)

### Implications

* Nukers just ask for trouble under these circumstances. Since Nukers have AOE spells, they can hit multiple mobs at the same time, so ALL of them get angry at the Nuker. However, a small Nuker, who doesn't do that much damage per shot, can actually be safe from Hate in a mass melee. While he is helping to thin the crowds out, each individual mob hit would build less Hate against him than against other, more powerful DDs. So Nukers can happily nuke away cleaning up the whole mess while their tougher cousins take care of individual problem mobs.
* -- The Grand High Poohbah
As long as a PC does damage to a mob, the PC's Hate Factor builds. Whoever deals most damage to the mob gets to take the mob's attacks. This has a lot of implications for groups with a lot of DDs and very few tanks.
Tanks, by definition, takes damage well but doesn't deal damage so well. So if this rule is the only rule, tanks would never be able to hold a mob's Hate in a group -- some DD schmuck will deal a few hundred/ thousand points of damage and instantly shift the Hate to the DD. The tank will be forced to play catchup, which in pure damage terms he would never be able to do so. Thankfully, tanks have a few tricks up his sleeves to do so.
The thing here is this: if a DD is dealing too much damage to a mob, he is going to get the mob's undivided attention. If the group is hunting tough mobs, it could lead to a very very dead DD very very quick. Hence, DDs do have to watch to make sure that they aren't dealing too much damage and attracting the wrong attention, and tanks have to watch to keep the mob's Hate on themselves.

## Healing and the Hate Factor
### The Relationship

Damage dealing and Hate is straight forward; you do more damage to a mob, the mob hates you more. If that was the only rule in the world, then we would only have tanks and healers, and healers would have a rather boring if critical job.
Here's where the AI steps in to keep the healers (un)happily occupied:
(The assumption here is that the Hate buildup is 1 to 1. It may not be so in practice, but for the purposes of this article it can stand)
* A practical example: Player A hits a mob 10 times, each time doing 10 damage. He creates 100 points of Hate against himself. Player B, being a kind soul passing by (and not in Player A's party), heals Player A for 200 points. She creates 200 points of Hate against herself, and the mob takes off after her.
* -- The Grand High Poohbah
Ho ho ho. Now the healers have some fun. Note that the two PCs don't even need to be in the same party; see the callout for a practical example.
While this is straightfoward in a two-player party -- either the healer or the other PC would get the Hate, it gets more... interesting... in larger parties.
Consider a party of 6, 5 DDs and 1 healers. The 5 DDs hit a mob for 50 points each, creating 50 points of Hate per DD. The healer use a group heal and heal all PCs for 50 points. So, the mob hates everyone at 50 points each, right?
WRONG!
Healing Hate is cummulative. In this case, the healer healed 5 PCs fighting the mob for 50 points each. Hence, the healer picks up 250 points of Hate. The mob will now hoof it after the healer, and the DDs would be hard pressed to draw him off, especially if the healer strikes back or continue to heal himself (which is very likely).

### Implications

In group play, this is one of two major issues healers and the group leader must be aware of. Healing PCs in the middle of combat may be essential, but can lead to a very very dead healer, especially if it's a high-level healer with low-level DDs -- a common occurance when trying to help a party member to level.
* Learning about all these shows me one desperation gambit. A healer, in times of desperation (i.e. the party got its collective behinds royally kicked..) can spam heals to draw Hate to himself. This makes the healer a temporary tank for the DDs to quickly take out the mobs, but since healers don't wear much armour, the DDs better do it REAL quick.
* -- The Grand High Poohbah
This is because the amount of healing the healer throws out in a single heal can outstrip the damage done by the DD by such a large extent that the mob cannot be drawn off by pure damage alone. In such a case -- especially against high-level group mobs -- the healer often takes too much damage.
Group Heals are also a tricky proposition. Group Heals are great in an emergency and for efficiency, but in the middle of combat throwing this out is tantamount to suicide -- the odds are good that the mobs WILL come after the healer immediately, such is the amount of Hate the healer accumulates. This is especially so when your party tackles a big group of mobs simultaneously -- every mob would head for you if you Group Heal!
The obvious solution is not to heal during combat, which is nonsense -- you have to top off your party members, otherwise it's either costly Resurrections or you (the healer) would also be dead. The trick here is to heal single party members while in combat, and save the Group Heals for non-combat situation, or to save the heals till late in the combat, when getting Hated by the mob is irrelevant as it's going to die soon.
Also, having a REAL tank (not a pseudo-tank) in the party who knows what he's doing will go a long way to saving the healer's neck. The tank knows how to keep the Hate off a healer, and he has the skills to do so, so having one in the party works wonders.

## Buffs, Debuffs and the Hate Factor
### The Relationship

So, now we've seen that direct damage (mundane and magical) and healing a party attacking the mob will increase the Hate the mob has against the party members. But Buffs and Debuffs doesn't directly harm the mob, so the buffers should be okay right?
WRONG!
Rule #3:
Now, isn't this great? Even buffers get to join in the fun! Buffs and Debuffs add a certain amount to the Hate Factor; exactly how much is unknown, and may differ from buff to buff. The only real way to figure it out is to get a party and test it exhaustively.

### Implications

* I use Curse: Weakness when leveling my wolf, and it creates Hate on the mob -- quite a lot actually. On Spore Fungus, the Hate is enough for my wolf to almost kill it without getting unwanted attention; only towards the last few points do the Fungus turn to my wolf. If online sources can be believed, Fungus have about 226 HP, so that's probably about 200 points of Hate that Curse: Weakness throws at a mob.
* -- Luthien, Elven Mystic
As most healers are also buffers, this is the second major issue for the class. Buffing is considered quite important in team play; the buffs, especially party buffs, can give each party member a huge bonus in fighting.
However, like healing, the Hate Factor accumulated through buffing in combat may be cummulative (this is not certain). If so, if a buff adds 100 points to the Hate Factor, party-buffing 8 party members will rack up 800 points of Hate, and that is very difficult to pass off to someone else.
Unlike healing though, buffing isn't a critical thing; you can (or should be able to) survive temporarily without a buff. As such, the simplest and most effective precaution a buffer can do is to insist all party members stop fighting mobs before buffing, and that nobody go and pick fights until after everyone's been buffed.
This rule can be used to your advantage though, as the comment on the right shows; Debuffs can be used as a cheap taunt to get mobs headed (and stayed) your way and at the same time decrease their abilities. Considering that casting Curse: Weakness only costs 3 MP and has a range of 600, it's rather effective!

## Situational Hating

Well, now that you know that:
   * Damaging a mob
   * Healing your Friends
   * Buffing/ Debuffing
will make the mobs hate you. But that's not the only way to make them hate you! So far, we have dealt with situations where we assume mobs are individually non-social and non-aggressive. This is of course not a very realistic world-view; Lineage 2 is filled with mobs that are especially aggressive, and many are socially active. So how does Hate come into play here?

### Hate and Aggressive Mobs

* This isn't really a big deal. Most of the time, PCs would give known aggro mob a wide berth, and only wade in when they want to engage the mob. About the only time this becomes an issue is when the mob is not known to be aggro, or worse, someone annoyed a passive mob, thus turning it into aggro mode. At that point, it depends largely whether the PC want to run or fight. Having said all these, it's good to know how the mob behaves, so that you can take advantage of it. Not to mention, it helps you understand why it's not a good idea to fight when you are in the midst of maybe a dozen mob.
* -- The Grand High Poohbah
Since we can only observe the behaviour of the mobs, we can only draw some inferences on how Hate work in these cases. The first is that each Mob has a detection radius; if a PC ends up within its detection radius, the AI checks whether the Mob actually does detect the PC (there is a chance, even for aggro mobs, that you can sneak totally by them). If the Mob doesn't detect the PC, then nothing happens; if the Mob detect the PC, it checks whether it's supposed to be aggressive. If it is, a certain (unspecificed) amount of Hate is credited against the PC, and the Mob takes off after the PC.
Yes, just being in the vicinity of an aggro Mob increases the Mob's Hate of you. That's why it is possible for other PCs to draw off a pursuing Mob by inflicting damage on it -- the Hate incurred by the damage done is more than the Hate of just being in the wrong place at the wrong time.

### Implications

If you aggro a Mob, it's already has Hate against you. If you don't (or can't) get rid of the Mob, don't deal it any more damage, or heals (unless absolutely necessary) or buffs/ debuffs (again, unless it helps, like Rooting the Mob. Doing these just makes it harder for others to draw the Mob off you. Once you commit to running away, stop thinking about hurting the Mob, just run.

### Hate and Social Mobs

So how about Social Mobs?
Well now, Social Mobs are a little more complicated. They still have a detection radius, and they still try to detect you, but if they are non-aggro they won't do much. However, Social Mobs also check if any of the mobs they are supposed to be social with that are in the radius are being attacked. If there is one, the Mob will credit some unspecificed amount of Hate against the attacking PC, and takes off after the PC.
What is not so clear is when multiple PCs (say players A, B, C and D) are attacking Mob X, how is Social Mob Y going to decide which of the four to attack? It can be totally random, but this isn't likely, because of the headaches that causes. It gets more complicated if, say, C is only healing the group. So should the Mob Y go after C (which is actually tactically sound)?
A theory -- and strictly a theory is that nearby Social Mobs would gain Hate based on what happened to the Mob being attacked. So in the situation above, Player A deals 100 points of damage to Mob X, Player B deals 300 points of damage, Player C heals a total of 100 points, and Player D de-buffed Mob X, the Hate gained by Mob X and Mob Y would be as follows:
| | Mob X | Mob Y |
| Player A | 100 | 100 |
| Player B | 300 | 300 |
| Player C | 100 | 100 |
| Player D | Presumed 200 (see above sections) | Presumed 200 (see above sections) |
So, if the above holds true, both Mob X and Mob Y would go after Player B, and subsequently each Mob would start stacking Hate individually.
It's a lot more complicated than the above, of course. For one, it's unlikely that Mob Y would simply put equal emphasis on damage received by his friend Mob X vs. damage received against itself. It's more likely that Mob Y would incur Hate for Mob X's combat at a specificed rate lower than that of what any combat that it is experiencing itself. For example, if the rate is 50%, the table would look like the following:
| | Mob X | Mob Y |
| Player A | 100 | 50 |
| Player B | 300 | 150 |
| Player C | 100 | 50 |
| Player D | Presumed 200 (see above sections) | Presumed 100 (see above sections) |
This means Mob Y would still take off after Player B... but when it becomes a grand melee, especially when nukers are involved, having a reduced rate makes it less likely that Mob Y would do something silly like ignoring a PC whacking it for thousands of points to go after a nuker who didn't even touch Mob Y yet.
Of course, it's not known exactly what this rate is, or even whether it's constant across all mobs. Another unknown is what happens if a group of PC attacking Mob X is straddled just at the edge of Mob Y's detection radius? For example, if Player B is a nuker, and he's standing outside Mob Y's detection radius while nuking Mob X, does Mob Y increase its Hate of Player B? And if Player C, a healer, heals Player A (who is in Mob Y's radius) and Player B (who isn't), how much Hate does Mob Y gain for player C?
Also, what happens when Mob Y is an aggro social mob while Mob X is a passive social mob? What happens if Mob Z comes into the picture? Or Mob S, T, U, V and W? And when Players E, F, G and H comes into play? A grand melee inevitably throws up incredible amounts of inanity.

### Implications

The relationship between Hate and Social Mobs are especially difficult to nail down. Simple situations such as two social mobs are still managable, but when you get dozens of mobs and players (such as in some dungeons), it becomes rapidly useless to talk about Hate -- the mob that turns to you is the one that Hates you more at that point in time.
At the end of the day, we can simplify Hate' and Social Mobs into this: If the Social Mob sees you being un-nice to another Mob it is friendly with, expect it to get annoyed with you. If you are in a party, which it gets annoyed with is a matter of blind luck (since the factors are not well known), so it's just best not to let the Social Mob see you.

## Specialized Hating

Lineage 2 provides some specialized Hate-related skills that makes things more interesting. These are generally used to the player's advantage, so it's foolish not to use them.
(To be continued. :)

# Theortical Hating

* Why have even more Hate possibilities? Well, Hate can be used to give NPCs/ Mobs intelligence and behaviour that are familiar to PCs. A Dark Elf NPC that attacks Light Elf preferentially is in accordance to the story background, and increases player immersion into the story. This can be done in reverse too -- Light Elf NPCs can be made to gain less Hate against Light Elf PCs, giving PCs a sense that the NPCs are reluctant to attack members of their own race. Not to mention, you can use Hate to make individual mobs or groups of mobs to be intelligent and even more deadly against PCs -- all in the name of challenge, of course.
* -- The Grand High Poohbah
Now that you have some understanding of how Hate works, we can start discussing how Hate can be used to make things more "fun" for the PCs. The following are some theortical situations that bears mentioning here, though these are by no means confirmed or even observed.

## Hating the Job

If you think through the Hate mechanism fully, you would realise it is possible to make mobs to react unequally to PCs, based on some unique identifiers that the PC has. One very easy example would be to increase Hate increments against a specific class of PC. For example, a Mob which is to have a mage-hunting behaviour can simply be tweaked to increase Hate at a greater rate against mage classes, or have a one-time boost to Hate against all mage classes in detection radius. This makes this particular mob appear to target mages more often.

## Hating the Race

Alternatively, it is possible to set up mobs to increase Hate based on PC race. A Dark Elf NPC/ Guard, for example, can be set to preferentially hunt Light Elves -- it would pick out Light Elves in a party and attack them first, all else being equal.
An Orc mob can be made to incur less Hate against Orc PCs, and can be presented to the players as the Orc mobs being afraid of the more well-developed Orcs that are the PCs. This can give even more possibilities in-game, in that parties would want to include a specific race because the party intends to explore areas that the specific race would have an advantage.

## Hating the Kharma

In a sense, we have already seen this in action; Town/ Village guards would preferentially hunt players with Kharma (Reds) and ignore other players. Given that it's programmically simpler to reuse mob combat behaviour for the guards, it's likely that the guards are special mobs set to trigger Hate when a PC with a specific flag (positive Kharma) wanders into its detection radius.
Expanding on this, we can have even more alignment-based mobs, similar to the Dungeons & Dragons mobs. Lawful mobs can be created to ignore zero Kharma PC, while being extremely aggressive towards Kharmic players. Alternatively, we can have areas where the mobs would preferentially hunt low-kharma PCs, setting the place to feel as if it is a den of evil, and giving PvP/ PKer a place which is safe for them to hunt.

## Putting the Hate Together

As you can see, focussing a mob's Hate against specific PC types or statistics can be effective in creating a specific environment. However, it is when several different focussed Hating are put together that it becomes very powerful. One area is in giving different focus to mobs that are social to each others; this give the group of mobs a dangerous level of intelligence and teamwork.
For example, a set of Mobs consisting of 3 separate Mobs (Mobs A, B, and C). These are set to spawn together as a social group, or are set to be social within a certain hunting area. The mobs are set up as follows:
   * Mob A is set to be generally aggressive
   * Mob B is set to preferentially hunting mages/ healers
   * Mob C is set to preferentially hunt Damage Dealers/ Archers.
Against PCs, a nasty situation can occur where Mob A is accidentally triggered and Mob B and Mob C are socially drawn in. Normally the PCs would set up a situation where all the Mobs would gang up against the designated Tank, but in this case, instead of that, Mob A would engage the Tank (to keep it busy), Mob C would take out the range support/ Damage Dealers, while Mob B would take out the magical support.
A well balanced party is built around the idea that each specialist can have the freedom to concentrate on its tasks, and typically they would gang up multiple PCs on one mob at a time to quickly finish off each so that they can move on with minimal drain on each PC. Such a preferential engagement based on Hate would break the teamwork by causing each component to defend itself, hence making it very difficult for a group to fight effectively. Thankfully, this behaviour is not -- yet -- known in Lineage 2 at the moment.