diff --git a/Villager-Jobs-and-AI.md b/Villager-Jobs-and-AI.md new file mode 100644 index 0000000..fc9236c --- /dev/null +++ b/Villager-Jobs-and-AI.md @@ -0,0 +1,60 @@ +# Villager Jobs & AI + +> **Legend** +> - βœ… Implemented β€” exists in the current codebase +> - πŸ—ΊοΈ Planned β€” design exists but not yet implemented + +--- + +## Jobs + +All jobs are assigned automatically based on **priority** (1 = highest) and **distance** (closest target wins within same priority). Jobs are "claimed" to prevent two villagers from taking the same target. + +| Job | Trigger | Work Duration | Output | +|-----|---------|--------------|--------| +| `chop` βœ… | Tree resource exists on map | 3,000 ms | +2 wood β†’ stockpile | +| `mine` βœ… | Rock resource exists on map | 5,000 ms | +2 stone β†’ stockpile | +| `farm` βœ… | Crop at max growth stage | 1,200 ms | Crop yield β†’ stockpile | + +**Default priority on spawn:** chop 1 Β· mine 2 Β· farm 3 +**Player can reorder** priorities per villager in the villager panel. + +--- + +## AI Cycle βœ… + +``` +Idle β†’ find job (priority + distance) + β†’ Walking (path to target, energy drains 0.0015/ms β‰ˆ 3/s) + β†’ Working (fixed duration, wobble animation) + β†’ Depositing (walk to nearest stockpile_zone) + β†’ back to Idle + └─ if energy < 25 β†’ Sleeping in nearest bed (energy +0.04/ms β‰ˆ 4/s) +``` + +--- + +## Energy System βœ… + +| State | Energy change | Notes | +|-------|--------------|-------| +| Walking | βˆ’0.0015 per ms | β‰ˆ βˆ’3 per second | +| Working | no drain | Standing still | +| Sleeping | +0.04 per ms | β‰ˆ full in ~25 s | +| Sleep trigger | energy < 25 | Villager seeks nearest free bed | +| Wake trigger | energy = 100 | Returns to Idle | + +Energy bar color: 🟒 > 60 Β· 🟠 30–60 Β· πŸ”΄ < 30 + +--- + +## Spawn Rules βœ… + +- One villager spawns per **free bed** (max population = number of beds) +- Spawn check every **8,000 ms** +- Movement speed: **75 px/s** +- 23 possible names (Aldric, Brix, Cora, Dwyn, …) + +--- + +← [[Game Systems Reference]]