[PR #3986] [MERGED] bots: add a fight behaviour #5336

Closed
opened 2026-11-03 05:11:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3986
Author: @DUzzL
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: fix/issue-3971-bots-fight-behaviour


📝 Commits (5)

  • 55b70b1 bots: add a fight behaviour (survival bots that attack the nearest mob and each other)
  • 2f8def5 Merge remote-tracking branch 'origin/main' into pr-3986
  • da79a2b Merge remote-tracking branch 'origin/main' into pr-3986
  • f0518ca Merge origin/main: --attack takes several targets
  • 670454e Merge main into #3986

📊 Changes

2 files changed (+337 additions, -26 deletions)

View changed files

📝 crates/horizon-bots/src/main.rs (+334 -26)
📝 docs/server.md (+3 -0)

📄 Description

Opened by DUzzL's AI agent, not by DUzzL personally.

Fixes #3971

Adds --behaviour fight to horizon-bots, plus --pvp true|false (default true) and an attacks counter in the per-second line and the report.

  • Fight bots stay in survival and hold their spawn height (server needs gamemode=survival, force-gamemode=true, allow-flight=true).
  • The reader thread tracks entities from AddEntity, MoveEntityPos(Rot), EntityPositionSync, SetEntityData and RemoveEntities. A target is an entity that has sent a positive health (LivingEntity data index 9), so items and arrows are never attacked.
  • Each tick the bot walks to the nearest target (ties go to the lowest entity id), and attacks (Attack, then the arm swing) once 5 ticks have passed since the last attack, which is the bare-hand cooldown (20 / attack speed 4). With no target it wanders like walk.
  • Deterministic from --seed (same SplitMix64 generator; target choice has no randomness). mixed is unchanged.
  • walk was moved into a shared walk_step helper without changing behaviour. Docs: docs/server.md.

Tested: cargo fmt --check, cargo clippy -p horizon-bots --all-targets -- -D warnings and cargo test -p horizon-bots (5 passed: entity tracking through encoded packets, deltas, pvp filter and tie-break, cooldown, approach) all pass.
Not tested: a live run against a vanilla/Horizon server (no game files or server here), so the packet ids for the arm swing and the health data index come from the protocol crate and my reading of vanilla, not from a server run. tools/pr_ready.py was not run. Real players on the server count as targets even with --pvp false, since bots tell bots apart only by uuid.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3986 **Author:** [@DUzzL](https://github.com/DUzzL) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/issue-3971-bots-fight-behaviour` --- ### 📝 Commits (5) - [`55b70b1`](https://github.com/horizon-rust/horizon/commit/55b70b104f03bae3c2861b11c199db5229b3d6e4) bots: add a fight behaviour (survival bots that attack the nearest mob and each other) - [`2f8def5`](https://github.com/horizon-rust/horizon/commit/2f8def5b524c77e76b59fedf8b71047bcbb32f26) Merge remote-tracking branch 'origin/main' into pr-3986 - [`da79a2b`](https://github.com/horizon-rust/horizon/commit/da79a2ba26f1fe64ee36c551da14189e1d310891) Merge remote-tracking branch 'origin/main' into pr-3986 - [`f0518ca`](https://github.com/horizon-rust/horizon/commit/f0518ca0e1bc8a3b4a8cc3d1415cf729b2e6388f) Merge origin/main: --attack takes several targets - [`670454e`](https://github.com/horizon-rust/horizon/commit/670454eeb8f888142127537c2e762d99e4bdd8e2) Merge main into #3986 ### 📊 Changes **2 files changed** (+337 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-bots/src/main.rs` (+334 -26) 📝 `docs/server.md` (+3 -0) </details> ### 📄 Description > Opened by DUzzL's AI agent, not by DUzzL personally. Fixes #3971 Adds `--behaviour fight` to `horizon-bots`, plus `--pvp true|false` (default true) and an `attacks` counter in the per-second line and the report. - Fight bots stay in survival and hold their spawn height (server needs `gamemode=survival`, `force-gamemode=true`, `allow-flight=true`). - The reader thread tracks entities from AddEntity, MoveEntityPos(Rot), EntityPositionSync, SetEntityData and RemoveEntities. A target is an entity that has sent a positive health (`LivingEntity` data index 9), so items and arrows are never attacked. - Each tick the bot walks to the nearest target (ties go to the lowest entity id), and attacks (Attack, then the arm swing) once 5 ticks have passed since the last attack, which is the bare-hand cooldown (20 / attack speed 4). With no target it wanders like `walk`. - Deterministic from `--seed` (same SplitMix64 generator; target choice has no randomness). `mixed` is unchanged. - `walk` was moved into a shared `walk_step` helper without changing behaviour. Docs: `docs/server.md`. Tested: `cargo fmt --check`, `cargo clippy -p horizon-bots --all-targets -- -D warnings` and `cargo test -p horizon-bots` (5 passed: entity tracking through encoded packets, deltas, pvp filter and tie-break, cooldown, approach) all pass. Not tested: a live run against a vanilla/Horizon server (no game files or server here), so the packet ids for the arm swing and the health data index come from the protocol crate and my reading of vanilla, not from a server run. `tools/pr_ready.py` was not run. Real players on the server count as targets even with `--pvp false`, since bots tell bots apart only by uuid. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5336
No description provided.