diff options
author | Aki <please@ignore.pl> | 2023-02-04 02:33:18 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-02-04 02:33:18 +0100 |
commit | 9a456b0e0d2f5505ced3751a0bbfc10c2dd1d233 (patch) | |
tree | a04ee380db847328e20361fffae461a8a4467a69 /sim | |
parent | fb1d3eda51cd9d89083130cf9932c7bde758756c (diff) | |
download | kurator-9a456b0e0d2f5505ced3751a0bbfc10c2dd1d233.zip kurator-9a456b0e0d2f5505ced3751a0bbfc10c2dd1d233.tar.gz kurator-9a456b0e0d2f5505ced3751a0bbfc10c2dd1d233.tar.bz2 |
Ship types JSON now support base_*_resists entries
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; |