MonsterAIRule

Time-based and event-triggered AI Unit overrides for monsters

Defines conditional rules that can temporarily override a monster's AI Unit based on time, date, or server events. This allows monsters to change their entire behavior pattern during specific periods.

File Location

GameServer/Data/Monster/MonsterAIRule.xml

Dependencies

Depends On
Purpose

Rules override monsters with different AI Units

Defines monsters' default AI Units

Used By
Purpose

Monster AI System

Evaluated every AI tick to check for active rules

How It Works

MonsterAIRule allows you to temporarily replace a monster's AI Unit based on conditions:

  1. Normal behavior: Monster uses its BasicAI (from MonsterAIGroup.xml)

  2. Rule activates: When a rule's condition is met, the monster switches to the rule's Unit

  3. Behavior changes: The monster now uses a completely different AI personality

  4. Rule expires: After WaitTime + ContinuanceTime, monster reverts to BasicAI

circle-info

This is an AI Unit override system, not a stat modifier. Rules completely replace the monster's behavior pattern (Automata, Elements, timing) for the duration of the rule.

Rule Evaluation

Rules are evaluated every AI tick (MonsterAIProc) for every active monster:

  1. Check if rule condition is valid (date/time/event match)

  2. Check if WaitTime has elapsed since condition became valid

  3. Check if we're still within WaitTime + ContinuanceTime

  4. If all checks pass, override the monster's CurrentAI with the rule's Unit

Current Status

circle-exclamation

Configuration Structure

Rule Attributes

Attribute
Type
Required
Description

Number

int

Yes

Unique rule identifier

Class

int

Yes

Monster class ID to apply rule to (all monsters of this class)

Description

string

No

Human-readable rule description

Unit

int

Yes

AI Unit to override with (from MonsterAIUnit.xml)

Condition

int

Yes

Condition type: 1 = Date/Time, 71 = Crywolf Start, 72 = Crywolf End

WaitTime

int

Yes

Seconds to wait after condition becomes true before activating

ContinuanceTime

int

Yes

Seconds the rule stays active after WaitTime expires

Month

int/string

Conditional

Month (1-12) or * for any month

Day

int/string

Conditional

Day (1-31) or * for any day

WeekDay

int/string

Conditional

Weekday (0=Sunday, 6=Saturday) or * for any day

Hour

int/string

Conditional

Hour (0-23) or * for any hour

Minute

int/string

Conditional

Minute (0-59) or * for any minute

circle-info

Wildcard *: Use * to ignore a date/time field. For example, Hour="*" matches all hours.

Condition Types

Condition
Description
Date/Time Fields Used

1

Specific Date/Time

All date/time attributes apply

71

Crywolf Event Start

Not implemented (always returns false)

72

Crywolf Event End

Not implemented (always returns false)

circle-exclamation

Important Behavior

Timing Logic

The rule activation follows this timeline:

Example: Halloween rule with WaitTime="10" and ContinuanceTime="3600"

  • October 31, 00:00:00 → Condition becomes true

  • October 31, 00:00:10 → Rule activates (10 second wait)

  • October 31, 01:00:10 → Rule expires (3600 second duration)

Date/Time Matching

  • All specified fields must match: If you set Month="10" and Hour="20", the rule only activates on October at 8 PM

  • Wildcards ignore fields: Month="*" means the rule ignores the month completely

  • ValidRange calculation: The WaitTime + ContinuanceTime defines how long the condition can remain true

  • Minute-precision: Time matching is precise to the minute

Multiple Rules Per Monster

If multiple rules target the same monster class:

  • The last valid rule in the array takes precedence

  • Rules are evaluated in order from first to last

  • Only one AI Unit override can be active at a time

Performance Impact

Rules are evaluated every AI tick for every active monster. Keep the number of rules reasonable (under 50) to avoid performance issues.

Examples

Make Golden Goblins (class 8) super aggressive on Halloween night:

  • Activates on October 31 at midnight

  • Switches Golden Goblins to AI Unit 101 (aggressive hunter behavior)

  • Lasts for 86400 seconds (24 hours)

  • All Golden Goblins on the server are affected

Common Issues

triangle-exclamation
circle-exclamation
circle-exclamation

Use Cases

Time-Based Events

  • Night aggression: Make monsters more aggressive at night (Unit with lower DelayTime, aggressive Automata)

  • Weekend bosses: Spawn event bosses only on weekends

  • Hourly rotations: Rotate monster behavior every few hours

Seasonal Events

  • Halloween: Spooky behavior on October 31

  • Christmas: Festive monster patterns in December

  • Anniversary: Special AI during server anniversary dates

Dynamic Difficulty

  • Peak hour challenge: Harder AI during peak player hours

  • Off-peak relaxation: Easier AI during low-population times

  • Weekly cycles: Escalating difficulty through the week

When NOT to Use MonsterAIRule

MonsterAIRule is powerful but not always the right tool:

Need
Better Solution

Permanent behavior changes

Modify MonsterAIGroup.xml directly

HP-based skill triggers

Use MonsterSkill.xml

Timed spawns/despawns

Use MonsterSetBase.xml Type 3 (event-based spawns)

Event-specific monsters

Create event-specific monster classes

Simple stat changes

Modify Monster.xml stats directly

For comprehensive monster control:

Last updated