rpd:ai_behavior_mechanic
Differences
This shows you the differences between two versions of the page.
| rpd:ai_behavior_mechanic [2025/12/29 09:28] – Update wiki pages: rename files to follow naming convention, add missing pages, fix formatting issues mike | rpd:ai_behavior_mechanic [2025/12/29 09:33] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== AI Behavior Mechanic ====== | ||
| + | ==== Description ==== | ||
| + | AI Behavior refers to the artificial intelligence systems that control how non-player characters (NPCs) and monsters behave in Remixed Dungeon. The AI system is implemented as state-based behaviors that can be dynamically changed during gameplay. | ||
| + | |||
| + | ==== AI System Code ==== | ||
| + | |||
| + | The AI system is implemented using the '' | ||
| + | |||
| + | <code java> | ||
| + | // In AiState.java | ||
| + | public interface AiState { | ||
| + | void act(@NotNull Char me); | ||
| + | String status(Char me); | ||
| + | String getTag(); | ||
| + | void gotDamage(Char me, NamedEntityKind src, int dmg); | ||
| + | void onDie(@NotNull Char me); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Common AI Types ==== | ||
| + | |||
| + | ==== Wandering AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | * **Mechanics**: | ||
| + | * If enemy is in field of view (FOV), transitions to hunting | ||
| + | * Otherwise moves to random destinations | ||
| + | * If damaged, seeks revenge and transitions to hunting | ||
| + | * **Status String**: '' | ||
| + | * **Usage**: Default AI for most mobs when not in combat | ||
| + | |||
| + | ==== Hunting AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | * **Mechanics**: | ||
| + | * If enemy is in FOV and in attack range, attacks | ||
| + | * Otherwise moves toward enemy | ||
| + | * If enemy is lost, transitions back to wandering | ||
| + | * Returns to owner if too far (for pets/ | ||
| + | * **Status String**: '' | ||
| + | * **Usage**: Used when mobs are in combat, or when they spot the player | ||
| + | |||
| + | ==== Sleeping AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | * **Mechanics**: | ||
| + | * Only wakes up if enemy is in FOV (with 50% detection chance) | ||
| + | * If damaged, wakes up and transitions to hunting (with delay) | ||
| + | * Spends '' | ||
| + | * **Status String**: '' | ||
| + | * **Usage**: Initial AI for many dungeon enemies | ||
| + | |||
| + | ==== Passive AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | * **Mechanics**: | ||
| + | * Never actively seeks enemies | ||
| + | * Only attacks if damaged (after seeking revenge) | ||
| + | * Does not respond to enemies in FOV | ||
| + | * **Status String**: '' | ||
| + | * **Usage**: For neutral NPCs or defensive objects | ||
| + | |||
| + | ==== Fleeing AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | * **Mechanics**: | ||
| + | * Moves away from the enemy position | ||
| + | * Continuously tracks enemy position while fleeing | ||
| + | * If damaged, may seek revenge and transition to hunting | ||
| + | * **Status String**: '' | ||
| + | * **Usage**: Used by certain mobs when low on health or by thieves | ||
| + | |||
| + | ==== Other AI Types ==== | ||
| + | |||
| + | ==== RunningAmok AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | |||
| + | ==== Horrified AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | |||
| + | ==== ThiefFleeing AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | |||
| + | ==== ControlledAI AI ==== | ||
| + | * **Class**: '' | ||
| + | * **Behavior**: | ||
| + | |||
| + | ==== AI Implementation ==== | ||
| + | The AI system uses a state pattern managed in '' | ||
| + | |||
| + | <code java> | ||
| + | // In Mob.java | ||
| + | public void setState(String state) { | ||
| + | setState(MobAi.getStateByTag(state)); | ||
| + | } | ||
| + | |||
| + | // In Mob.java - AI state transitions | ||
| + | public void beckon(int cell) { | ||
| + | // ... code that may change AI state based on context | ||
| + | if (state.getTag().equals(" | ||
| + | // ... may change to hunting state | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== AI Transition Triggers ==== | ||
| + | * **Damage**: When a mob takes damage, it typically seeks revenge and changes to Hunting AI | ||
| + | * **Sight**: When a mob sees an enemy while sleeping or wandering, it transitions to Hunting AI | ||
| + | * **Health**: When a mob's health drops low, it may transition to Fleeing AI | ||
| + | * **Scripted Events**: Lua scripts can change AI states in certain conditions | ||
| + | |||
| + | ==== AI in Mob Initialization ==== | ||
| + | * Most mobs start with '' | ||
| + | * Some special mobs start with '' | ||
| + | * AI can be specified in the mob's JSON descriptor with " | ||
| + | |||
| + | ==== AI-Related String Resources ==== | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ==== AI Mechanics ==== | ||
| + | * **Detection** - How enemies notice the player (sight, sound, etc.) | ||
| + | * **Movement Patterns** - How enemies navigate the dungeon | ||
| + | * **Combat Tactics** - How enemies approach fighting | ||
| + | * **Escape Behavior** - When and how enemies retreat | ||
| + | * **State Transitions** - How AI changes based on game events | ||
| + | |||
| + | ==== Factors Affecting AI ==== | ||
| + | * **Distance to Player** - How far the enemy will search | ||
| + | * **Visibility** - Lighting and stealth effects | ||
| + | * **Health Status** - How the enemy behaves when injured | ||
| + | * **Environmental Awareness** - Interaction with level objects | ||
| + | * **Sound Detection** - Some actions can alert nearby enemies | ||
| + | |||
| + | ==== Player Interaction ==== | ||
| + | * **Line of Sight** - Most enemies only notice the player if they can see them | ||
| + | * **Noise** - Some actions create sound that attracts enemies | ||
| + | * **Stealth** - Certain equipment or abilities can reduce detection chances | ||
| + | * **Taunting** - Some items or abilities can manipulate enemy targeting | ||
| + | |||
| + | ==== Exploiting AI ==== | ||
| + | * **Kiting** - Moving to fight enemies one at a time | ||
| + | * **Blocking** - Using doorways to fight enemies one at a time | ||
| + | * **Distraction** - Using items to misdirect enemy attention | ||
| + | * **Ambush Tactics** - Using stealth and positioning | ||
| + | |||
| + | ==== Code References ==== | ||
| + | * Java: [[https:// | ||
| + | * Java: [[https:// | ||
| + | * Java: [[https:// | ||
| + | * Java: [[https:// | ||
| + | * Java: [[https:// | ||
| + | * Java: [[https:// | ||
| + | * Java: [[https:// | ||
| + | |||
| + | ==== See Also ==== | ||
| + | * [[rpd: | ||
| + | * [[rpd: | ||
| + | * [[rpd: | ||
| + | |||
| + | {{tag> rpd mechanics ai }} | ||
rpd/ai_behavior_mechanic.txt · Last modified: by 127.0.0.1
