diff options
Diffstat (limited to 'sim')
-rw-r--r-- | sim/include/kurator/sim/HitPoints.h | 6 | ||||
-rw-r--r-- | sim/src/Builder.cpp | 6 | ||||
-rw-r--r-- | sim/src/HitPoints.cpp | 15 |
3 files changed, 14 insertions, 13 deletions
diff --git a/sim/include/kurator/sim/HitPoints.h b/sim/include/kurator/sim/HitPoints.h index 0004999..7cd82f3 100644 --- a/sim/include/kurator/sim/HitPoints.h +++ b/sim/include/kurator/sim/HitPoints.h @@ -1,5 +1,7 @@ #pragma once +#include <kurator/universe/ShipType.h> + namespace kurator { @@ -9,12 +11,12 @@ namespace sim struct HitPoints { - HitPoints(double base_shield, double base_armour, double base_structure); + HitPoints(const universe::ShipType& def); struct Layer { double points; - double resists = 0.7; + double resists = 0.3; double consume(double& damage); }; diff --git a/sim/src/Builder.cpp b/sim/src/Builder.cpp index 279cd8b..64ca874 100644 --- a/sim/src/Builder.cpp +++ b/sim/src/Builder.cpp @@ -42,11 +42,7 @@ Builder::operator()(const universe::ShipType& ship_type, const int team) const ship_type.max_speed * 2.0, ship_type.max_speed * 3.0); registry.emplace<AIState>(entity, 15000.0, Point{0.0, 0.0}); - registry.emplace<HitPoints>( - entity, - ship_type.base_shield_points, - ship_type.base_armour_points, - ship_type.base_structure_points); + registry.emplace<HitPoints>(entity, ship_type); return entity; } diff --git a/sim/src/HitPoints.cpp b/sim/src/HitPoints.cpp index 251454d..f850451 100644 --- a/sim/src/HitPoints.cpp +++ b/sim/src/HitPoints.cpp @@ -1,5 +1,7 @@ #include <kurator/sim/HitPoints.h> +#include <kurator/universe/ShipType.h> + namespace kurator { @@ -7,10 +9,10 @@ namespace sim { -HitPoints::HitPoints(double base_shield, double base_armour, double base_structure) : - structure {base_structure}, - armour {base_armour}, - shield {base_shield} +HitPoints::HitPoints(const universe::ShipType& def) : + structure {def.base_structure_points, def.base_structure_resists}, + armour {def.base_armour_points, def.base_armour_resists}, + shield {def.base_shield_points, def.base_shield_resists} { } @@ -20,8 +22,9 @@ HitPoints::Layer::consume(double& damage) { if (damage <= 0.0 || points <= 0.0) return 0.0; - const double actual_damage = damage * resists; - const double left_to_deal = (actual_damage - points) / resists; + const double modifier = 1.0 - resists; + const double actual_damage = damage * modifier; + const double left_to_deal = (actual_damage - points) / modifier; points -= actual_damage; damage = left_to_deal; return actual_damage; |