diff options
| author | Emil A. Overbeck <emil.a.overbeck@gmail.com> | 2026-07-19 03:14:53 +0200 |
|---|---|---|
| committer | Emil A. Overbeck <emil.a.overbeck@gmail.com> | 2026-07-19 03:14:53 +0200 |
| commit | c217861ab62987b798835194786dc99424e1804e (patch) | |
| tree | 37baf5b0a9ae9141da4556515caccedc7b5ab6dc /src/game/build_graph.cpp | |
| parent | d42411ef884484c9c49482dd944a8394e78d8e15 (diff) | |
| download | forts_clone-c217861ab62987b798835194786dc99424e1804e.tar.gz forts_clone-c217861ab62987b798835194786dc99424e1804e.zip | |
Recoil and armor
Diffstat (limited to 'src/game/build_graph.cpp')
| -rw-r--r-- | src/game/build_graph.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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; |
