aslain.dev
0%
01 Hizmetler 02 Hakkımda 03 Projeler 04 Stack 05 Blog 06 İletişim
← Tüm makaleler Metin2

Metin2 Mob AI Editing: Aggro, Fleeing and Groups

Metin2 mob AI editing decides when a monster notices and attacks a player, whether it runs away once its HP drops, and whether the mobs around it come to help. The good news: most of this behavior can be controlled with just a few columns in the mob_proto table, without recompiling the C++ source. In this guide I'll walk through which fields control aggro, fleeing and group reactions, and how to change them safely, step by step.

Where is mob behavior stored?

Every monster's core settings live in a single row of mob_proto. On most servers these rows are loaded from a text file (mob_proto.txt) and reach the game through a mob_proto.txt → mob_proto (binary/DB) conversion. The columns directly tied to AI are:

  • AI_FLAG — behavior flags like aggression, fleeing and helping (written as text and joined with |).
  • RANK and TYPE — define whether the mob is a normal monster, a metin stone or a boss; some AI decisions look at this classification.
  • AGGRESSIVE_HP_PCT and AGGRESSIVE_SIGHT — some distributions add separate columns for the aggro threshold and sight range.
  • DAMAGE_RANGE, ATT_SPEED, MOVE_SPEED — affect how aggressive the attack feels.

Important note: column names and their order vary by distribution (official, various "files" packs). So before changing anything, check the column mapping in your own source — usually in ReadMobProto or the CMobManager code. The flag names below are the common ones, but their presence depends on your source.

Tuning aggression with AI_FLAG

The AI_FLAG column is a combination of flags that define a mob's basic personality. The most used ones:

  • AGGRESSIVE — the mob attacks any player that enters its range on its own. Without this flag the mob only reacts when hit (passive).
  • COWARD — the mob flees once its HP drops below a certain ratio.
  • NOMOVE — the mob doesn't move from its spot; it hits whoever enters range but won't chase (good for towers, fixed sentries).
  • HELPER — when a nearby mob is attacked, this mob also turns on the target (group assistance).
  • BERSERK, STONESKIN, GODSPEED, DEATHBLOW — boss abilities like rage at low HP, damage reduction, speed or critical hits.
  • NOATTSHINSU / NOATTCHUNJO / NOATTJINNO — keep the mob from attacking a specific empire (like NPC village guards).

In a mob row the AI_FLAG field typically looks like this:

VNUM  NAME            ...  AI_FLAG
101   Wild Dog        ...  AGGRESSIVE
102   Guard           ...  NOMOVE
531   Captain Mob     ...  AGGRESSIVE|HELPER|BERSERK

So to make a wolf passive you remove the AGGRESSIVE flag, and to make a gate guard both aggressive and stationary you write AGGRESSIVE|NOMOVE. You join flags with | and put no spaces between them.

Changing the aggro range

How far away a mob notices a player is computed in the AI loop of the server source. An aggressive mob in the idle state periodically scans its surroundings; if it finds a valid target within range it switches to the BATTLE state. This scanning logic usually lives in char_state.cpp and char_battle.cpp, while the aggro point is handled by a function like UpdateAggrPoint on the char.cpp side.

There are two ways to widen the range:

  • By data: if your distribution has a column like AGGRESSIVE_SIGHT, raising its value is the cleanest method — no recompile needed.
  • By source: if no such column exists, you edit the fixed range in the AI scan (a hard-coded number, in meters in most sources) and recompile the game binary.

My advice: don't overdo the aggro range. A range that's too wide leads players to gather mob trains constantly and causes unfair deaths at low levels. Start with a small increase and test.

Fleeing (COWARD) behavior

A mob with the COWARD flag starts moving away from its target once its HP falls below a certain threshold. That threshold is usually hard-coded in the source (for example a fixed percentage of HP). So if you want per-mob thresholds — "the rabbit flees at 30% HP, the deer at 20%" — you'll need a small source edit to bind the flee check to a data column (for example repurposing the AGGRESSIVE_HP_PCT field for it).

A common practical tweak: stop farm mobs from fleeing. Players hate chasing half-dead mobs that run off. Just remove the COWARD flag from those mobs' rows.

Group and helper behavior

How mobs react together matters as much as a single mob's behavior. Two separate systems are at play here:

  • The HELPER flag: when a nearby friendly mob is attacked, this mob turns on the attacker too. Ideal for boss guards and "elite" packs.
  • Group spawns: mobs aren't spawned one by one but in groups defined in regen.txt and the mob_group / mob_group_group tables. A group definition is a leader plus its members; making the whole group react when the leader is hit comes from this definition combined with HELPER logic.

A sample group definition follows this logic:

Group  Bandit_Camp
{
    Vnum    1001
    Leader  "Bandit Chief"   531
    1       "Bandit"         530
    2       "Bandit"         530
    3       "Bandit Archer"  532
}

When the leader dies, in some setups the group disbands or the reward is tied to the leader. You tune group difficulty by changing the members' VNUMs or count; give the members HELPER and they all attack at once when one is hit.

A safe editing workflow

Before testing on a live server, follow this order:

  • Back up mob_proto.txt and the related tables first.
  • Change a single mob and verify it on a test server (aggro, fleeing, group).
  • Apply the change: run the mob_proto.txt → binary/DB conversion, then reload the mobs (on most servers /reload p reloads the proto; if you're not sure, a server restart is the guaranteed path).
  • If you changed source, compile and deploy the game binary.

The most common flag mistakes are writing a flag name that doesn't exist, or putting a space instead of |; in that case the mob either stays fully passive or the proto won't load. When in doubt, reference the flag table in the source (usually an FN_* or aMobAIFlag array).

Frequently Asked Questions

Can I make a mob aggressive without recompiling the source?

Yes. Just add AGGRESSIVE to the AI_FLAG field of the mob_proto.txt row and reload the proto; no C++ build is needed. Changing the aggro range, however, requires source if your distribution has no data column for it.

Why can't I change the aggro range from data?

Because not every distribution has a separate column like AGGRESSIVE_SIGHT. Without it the range is hard-coded in the source, and changing it means recompiling the game binary.

How do I make a group attack all at once when one is hit?

Give the members the HELPER flag and spawn them under the same group in regen.txt / mob_group. That way, when one member is targeted the others come to help.

Balancing mob AI takes both data and source knowledge. If you'd like me to tune your server's mob behavior, group spawns or AI source together, get in touch — let's shape your design together.

Bu kategorideki tüm yazılar →

Devamı için