diff options
author | Aki <please@ignore.pl> | 2023-01-08 01:05:29 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-01-08 01:05:29 +0100 |
commit | fdd6d1a4e9191daf6c136cc1570bc69a6a9e264c (patch) | |
tree | bf8a5f005a4cf47a18b90bd20b7316aa35536d2e /sim | |
parent | 85e4741a6b39e436befacaf9778619696c9c5a33 (diff) | |
download | kurator-fdd6d1a4e9191daf6c136cc1570bc69a6a9e264c.zip kurator-fdd6d1a4e9191daf6c136cc1570bc69a6a9e264c.tar.gz kurator-fdd6d1a4e9191daf6c136cc1570bc69a6a9e264c.tar.bz2 |
Added naive resists
Diffstat (limited to 'sim')
-rw-r--r-- | sim/include/kurator/sim/HitPoints.h | 3 | ||||
-rw-r--r-- | sim/src/HitPoints.cpp | 4 | ||||
-rw-r--r-- | sim/src/TurretControl.cpp | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/sim/include/kurator/sim/HitPoints.h b/sim/include/kurator/sim/HitPoints.h index d63620d..b9a8523 100644 --- a/sim/include/kurator/sim/HitPoints.h +++ b/sim/include/kurator/sim/HitPoints.h @@ -10,7 +10,8 @@ namespace sim struct HitPoints { double structure; - void deal(double damage); + double structure_resists = 0.7; + double deal(double damage); bool is_alive() const; double total() const; }; diff --git a/sim/src/HitPoints.cpp b/sim/src/HitPoints.cpp index bcb7e97..d83c369 100644 --- a/sim/src/HitPoints.cpp +++ b/sim/src/HitPoints.cpp @@ -7,10 +7,12 @@ namespace sim { -void +double HitPoints::deal(double damage) { + damage *= structure_resists; structure -= damage; + return damage; } diff --git a/sim/src/TurretControl.cpp b/sim/src/TurretControl.cpp index 6513f39..e2596c8 100644 --- a/sim/src/TurretControl.cpp +++ b/sim/src/TurretControl.cpp @@ -42,9 +42,9 @@ TurretControl::update(entt::registry& registry, entt::dispatcher& dispatcher, co control.rounds = def.rounds; if (control.rounds > 0 && consume(remaining_dt, control.delay)) { auto& target_points = registry.get<HitPoints>(state.target); - const auto damage = def.effective_damage(distance); + auto damage = def.effective_damage(distance); if (damage > 0.0) { - target_points.deal(damage); + damage = target_points.deal(damage); dispatcher.trigger(Hit{damage, control.owner, state.target}); } control.delay = def.rate_of_fire; |