Auto-attack: next target, melee/ranged rule after arts; chain range = cast range

- autoattack: when the target dies, the nearest enemy within close range
  (contact distance + a step) takes over; after an art the hero auto-attacks
  if the art was melee (walked up / cast close by), or ranged with a ranged
  weapon, or ranged with an enemy already in melee range; measured action
  codes and weapon classes in game/engine/orders.h
- chainlightning: jumps reach Blitzschlag's cast range (20 ray segments of
  30, the art code's hit check) via the shared NearestHostile search
- guards: burning bone render hook had the wrong signature (device plus a
  4x4 matrix by value, ret 0x44) and corrupted the stack when fire arrows hit
- crash reports follow the ebp chain before the raw stack scan

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
khallaandClaude Opus 5.5 committed 2026-10-16 09:16:47 +02:00
1 parent 5338527b49
commit 16c2844400
8 files changed
+275 -60

No files matched your search

+33
View File
@@ -52,3 +52,36 @@ wind-up, 0.64 s attack, 0.43 s recovery).
with a held button; the tick only restarts the attack after casts.
- Self / ally arts pointed at an enemy lose their target
(`src/mods/arttarget.cpp`) and therefore do not start auto-attack.
## Next target, and auto-attack after arts (2026-10-16)
User requests: when the target dies, go on with the next enemy close by;
after a melee art always auto-attack, after a ranged art only with a ranged
weapon.
Measured with a temporary log (distance hero → target when the hero started
the swing or cast, battlemage with a staff):
- +0x150 low word: 1 walking (also walking up to a target), 3 weapon attack,
4 casting a spell. The "1 art" above was the walk up; 8 (seen after it on
2026-10-15) is presumably a combat move. Names in `game/engine/orders.h`.
- Weapon swings started at 117..149 after walking up from up to 1382: the
game's contact distance (`0x4dbaa0`, mean of both body radii by object
type; heroes 110 with a weapon, 80 without).
- Spells (Blitzschlag 0x21, art 5) started at once from 647..803: no walk-up.
Their cast limit, if any, is beyond that.
Rules (`autoattack.cpp`):
- Close range = `ContactDistance(hero, hero) + 100` (≈ 210) with a melee
weapon; 600 with a ranged one (TODO: measure a ranged hero). Ranged weapon =
weapon class (`0x546df0`) 6 throwing, 7 bow, 12 crossbow, 13 pistol.
- The target died: the nearest living hostile creature within close range
(`game::NearestHostile`) becomes the target, else auto-attack stops.
- An art order (not a buff / ally / corpse art) is watched until the hero
starts it (action 4 or 8). It is melee if the hero walked first, ranged if
it starts farther away than contact distance + 100, else as remembered for
that art (default melee). Melee: auto-attack its enemy target, or the
nearest enemy close by. Ranged: the same with a ranged weapon; with a melee
weapon only an enemy already in close range (the art's target if it is,
else the nearest), otherwise auto-attack stops. Until the art starts, no attack orders are sent.
+12
View File
@@ -55,3 +55,15 @@ ends (a lone enemy is hit once). Two enemies: it bounces between them.
First version (bolts copied for every jump, not using the game's chain)
replaced the same day: it doubled the jumps.
## Jump range = cast range (2026-10-16)
User request: a jump reaches as far as a cast. Blitzschlag's hit check is in
the art code (cCreature art switch `0x5222c0`, case 0x21): the ray from the
caster towards the target is laid out in segments of 30, at most 20, each on
passable ground (`0x636b60`); the bolt is created on the target only if the
ray reaches it, otherwise the visible ray just stops. So the cast range is
20 × 30 = 600. `CastRange()` in `chainlightning.cpp` returns it for every jump
(also the first hop of extra chains), instead of the game's jump search radius
(squared 100000, about 316). It is the one place to make the range dynamic
later. Jumps do not check the ground in between.