From c217861ab62987b798835194786dc99424e1804e Mon Sep 17 00:00:00 2001 From: "Emil A. Overbeck" Date: Sun, 19 Jul 2026 03:14:53 +0200 Subject: Recoil and armor --- src/game/build_graph.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/game/build_graph.cpp') diff --git a/src/game/build_graph.cpp b/src/game/build_graph.cpp index 032bbf5..a1195af 100644 --- a/src/game/build_graph.cpp +++ b/src/game/build_graph.cpp @@ -291,6 +291,21 @@ int BuildGraph::kill_grounded() { // Destruction // ============================================================================= +void BuildGraph::apply_recoil(float x, float y, float radius, + float dx, float dy, float strength) { + if (radius <= 0.0f || strength <= 0.0f) return; + + for (auto& n : nodes) { + if (n.is_foundation) continue; // pinned: the ground eats the recoil + float ox = n.x - x, oy = n.y - y; + float d = std::sqrt(ox*ox + oy*oy); + if (d >= radius) continue; + float f = 1.0f - d / radius; // linear falloff, as in apply_splash + n.vx += dx * strength * f; + n.vy += dy * strength * f; + } +} + void BuildGraph::apply_splash(float x, float y, float radius, float damage, float knockback) { if (radius <= 0.0f) return; -- cgit v1.3