fix issue where ships cancel their attacks and advance if on low health in balancing target
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#include "BehaviorTargeting.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "FactionComponent.h"
|
||||
#include "HealthComponent.h"
|
||||
#include "ModuleOwnerComponent.h"
|
||||
#include "PositionComponent.h"
|
||||
#include "SensorRangeComponent.h"
|
||||
@@ -55,10 +54,9 @@ void AttackEvaluator::evaluate(EntityAdmin& admin)
|
||||
|
||||
// Pass C: per-ship target selection.
|
||||
admin.forEach<AttackBehavior, PositionComponent, FactionComponent,
|
||||
SensorRangeComponent, HealthComponent>(
|
||||
SensorRangeComponent>(
|
||||
[&](entt::entity e, AttackBehavior& attack, const PositionComponent& pos,
|
||||
const FactionComponent& faction, const SensorRangeComponent& sensor,
|
||||
const HealthComponent& health)
|
||||
const FactionComponent& faction, const SensorRangeComponent& sensor)
|
||||
{
|
||||
const float sensorRange_tiles = sensor.value_tiles;
|
||||
|
||||
@@ -135,13 +133,14 @@ void AttackEvaluator::evaluate(EntityAdmin& admin)
|
||||
}
|
||||
}
|
||||
|
||||
if (!keptCurrent) { attack.currentTarget = bestTarget; }
|
||||
if (!keptCurrent)
|
||||
{
|
||||
attack.currentTarget = bestTarget;
|
||||
}
|
||||
|
||||
const bool healthy =
|
||||
(health.maxHp > 0.0f)
|
||||
&& (health.hp / health.maxHp >= BehaviorScores::kLowHpFraction);
|
||||
attack.score = (healthy && attack.currentTarget)
|
||||
attack.score = attack.currentTarget
|
||||
? BehaviorScores::kAttack
|
||||
: BehaviorScores::kInactive;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user