Files
sacred_k/docs/chain-lightning.md
T
khallaandClaude Opus 5.5 1fd89524d3 Skills, auto-attack, aura and chain lightning rework, Esc, cache fix
- Skill bar: no art selection; slot 0 is the right-click art, keys 0-6 cast
  slots directly; cooldown labels in exact seconds; slot 0 set apart.
- Arts regenerate on their own (casting no longer refills the group).
- Auto-attack after targeting or casting at a hostile creature, at the speed
  of a held button.
- Auras can be recast while active (renew, no second visual).
- Blicke wie Klingen hits every enemy in range, physical, with life leech.
- Blitzschlag steers the game's own chain: 3 + level/5 hits, 1 + level/10
  chains, re-hits a lone enemy.
- Weapon sets: click selects, drag only from the selected set; the leftmost
  set is clickable (signed hit tests).
- Esc closes open windows before opening the game menu.
- HUD: standalone buttons and texts are centred.
- Record cache sized for widened views (town lag while walking).
- Shared game code: orders, fx events, text drawing, cooldowns, effects.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-16 00:11:38 +02:00

2.9 KiB

Chain lightning (src/mods/chainlightning.cpp)

Rebalancing request (user, 2026-10-15) for the Battlemage's Blitzschlag (art 0x21, icon GUI_SPELL_BLITZSCHLAG; 0x0e has the same icon):

  • hits per chain N = 3 + level / 5 (the first target included);
  • chains B = 1 + level / 10, all starting at the first target ("hero -> T1 -> A1 -> A2 ..., T1 -> B1 -> B2 ...");
  • a chain that finds no new target hits the previous one again (a lone enemy takes N hits).

How the game casts it (measured with an object / hit log, 2026-10-15)

About 0.3 s after the cast order (0x105, art 0x21) the caster's art code (0x5222c0, Blitzschlag part around 0x526c91..0x527102):

  • builds the visual path: up to 20 segment objects of type 799 (0x31f), each created linked to the previous one (CreateAt third argument), ids kept at caster +0x263;
  • creates the bolt object, type 872 (0x368), at the target, linked to the last segment, copies the caster's +0x2b5 to its +0x39, and sends it a cEventFX 0x60 (0x41e0a0: [2] caster id, [3] target id, [4..7] position, [8..13] two strings, [14] damage, [16..29] damage block);
  • plays sound 0x7db.

The bolt object then sends the hit (cEvent_creature 5 from 0x5b52d3, attacker = caster, +0x14 = 0x368, +0x18 = the bolt object's id).

The game's own chain (measured 2026-10-15)

The game's Blitzschlag already chains. The 0x60 event's [14] is the number of hits left in the chain (3 at level 1, from the art level, 0x4d24f0). After its hit, a bolt with hits left looks for the next target in its update (cObjectManager::FindJumpTarget 0x6005d0, called at 0x5b469f with (position, 100000 = squared range, caster, current target): the nearest creature, excluding only caster and current target), builds the arc (segment objects 799 created at 0x5b4aff, each set up with a cEventFX), and creates the next bolt at the target (0x5b4d7c) with [14] - 1. No target: the chain ends (a lone enemy is hit once). Two enemies: it bounces between them.

The mod

  • The first bolt of a hero's cast (the first 0x60 bolt setup after the cast order) gets [14] = N = 3 + level / 5 (level = cooldown entry level + bonus levels of the art cast).
  • The jump search call (0x5b469f) goes to NextTarget (thunk passing the bolt in ebp): for bolts of our chains (bolt id -> chain, filled when a bolt of a chain is set up at the target the chain said it jumps to) the next target is the nearest enemy within the game's range not hit by this chain yet, else another enemy, else the current one again (a lone enemy takes all N hits). Other bolts use the game's search.
  • B = 1 + level / 10 chains: while the first bolt is set up, B - 1 more bolts are created at the first jump targets of the other chains (copies of the event with [14] = N - 1); their first hop has no arc.

First version (bolts copied for every jump, not using the game's chain) replaced the same day: it doubled the jumps.