Overview
DuelCombatAI is a specialized tick-based combat controller that takes over an AI agent’s behavior during arena duels. It uses the EmbeddedHyperscapeService to execute game actions and makes priority-based combat decisions: heal, attack, or switch style.
DuelCombatAI operates at the same 600ms tick rate as the game’s combat system, ensuring synchronized attack timing.
Architecture
Lifecycle
processPlayerCombatTick → processAutoAttackOnTick) drives the actual attack cadence once combat is established. The AI only needs to re-engage when:
- Combat has dropped
- Target has changed
executeAttack on every cooldown cycle creates a redundant second driver that competes for the same cooldown slot, silently dropping attacks (especially for slow weapons like 2h swords).
Combat Phases
DuelCombatAI operates in four distinct phases:Decision Priority
Each tick, the AI evaluates actions in this order:- Heal - If HP below threshold, eat food
- Buff - If opening phase, use buff potions
- Strategy - Apply LLM-planned tactics (if enabled)
- Attack - Re-engage if combat dropped or target changed
Configuration
Default Configuration
LLM Strategy Planning
WhenuseLlmTactics: true, the AI uses LLM to generate combat strategies:
Strategy Object
Planning Triggers
Strategy replanning occurs when:- First tick (initial strategy)
- HP changes by more than 20%
- Opponent drops below 25% HP
- Entering desperate phase
LLM Prompt
Background Planning
Critical: Strategy planning runs in the background and NEVER blocks the tick loop:Trash Talk System
AI agents taunt opponents during combat using health-triggered and ambient messages.Health Threshold Taunts
Triggered when HP crosses these milestones:- “Not even close!”
- “I’ve had worse”
- “Is that all?”
- “Still standing”
- “GG soon”
- “You’re done!”
- “Sit down”
- “One more hit…”
Ambient Taunts
Random taunts every 5-12 ticks with no specific trigger:- “Let’s go!”
- “Fight me!”
- “Too slow”
- “Bring it”
- “Nice try lol”
Opening Taunts
Fired immediately when the duel starts:- “You’re going down”
- “Let’s dance”
- “Ready to lose?”
- “This won’t take long”
LLM-Generated Trash Talk
When anAgentRuntime is provided, trash talk uses the agent’s character bio and communication style:
- Model:
TEXT_SMALL - Max tokens: 30
- Temperature: 0.9 (high creativity)
- Timeout: 3 seconds
TRASH_TALK_COOLDOWN_MS)
Fallback Behavior
If LLM fails or times out, the system uses scripted fallback taunts to ensure trash talk always works.Attack Timing Fix (commit 51453dae)
Problem
Previously, DuelCombatAI manually tracked attack speed and calledexecuteAttack on every cooldown cycle:
- Silent attack drops for slow weapons (2h swords, halberds)
- Desynchronization between AI and combat system
- Missed attacks due to cooldown conflicts
Solution
The AI now only re-engages when combat has dropped or the target changed:TWO_HAND_SWORD Default Style (commit 51453dae)
Added missing default attack style for two-handed swords inWeaponStyleConfig.ts:
Statistics Tracking
DuelCombatAI tracks combat statistics for analysis:Environment Variables
Food Detection
DuelCombatAI automatically detects food items in inventory:Potion Detection
Buff potions are detected by name patterns:Performance Characteristics
- Tick Rate: 600ms (synchronized with game combat system)
- LLM Timeout: 3 seconds maximum
- Planning Cooldown: 8 seconds between strategy replans
- Trash Talk Cooldown: 8 seconds between messages
- Background Processing: All LLM calls are fire-and-forget, never block ticks
Integration Example
Debugging
Enable debug logging to see combat AI decisions:Related Documentation
AI Agents Overview
ElizaOS integration and plugin architecture
Combat System
Core combat mechanics and tick-based system
Actions Reference
All available agent actions including combat
Configuration
Environment variables for combat AI