ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

The Threat System

From ModEnc
Jump to navigation Jump to search

The threat evaluation system was supposed to make the AI appear more 'intelligent' by targeting the more important threats first. In early development stages of Tiberian Sun this was planned as a Superweapon for GDI, but was scrapped, although the logic in all its incomplete glory remains in all later games up to and including Yuri's Revenge. As with various other logics, there is a lot of speculation surrounding this system.

Related INI Flags

IsThreatRatingNode
when a Building with this flag set is placed, its owner gains the "threat rating node" which is supposed to be the activator of the intelligent threat analysis logic. Through a bug in the game code, once a house gains this ability, it will not lose it even when the building in question is destroyed.
[General]EnemyHouseThreatBonus=
An additional weight applied when the owner of the targeted unit is the house's selected enemy house.

The threat rating system also relies on multiple floating-point coefficients that are defined globally which can be applied to each unit describing its "effectiveness" and reliance on external factors such as distance from the target. These coefficients have two values, one applied under normal circumstances and one applied when the owner house has the "Threat Rating Node".


Floating-point coefficients
Coefficient name Flag name with ThreatRatingNode Flag name without ThreatRatingNode Flag name Global default value
Self Effectiveness [TechnoType]→MyEffectivenessCoefficient [General]→DumbMyEffectivenessCoefficient [General]→MyEffectivenessCoefficientDefault
Target Effectiveness [TechnoType]→TargetEffectivenessCoefficient [General]→DumbTargetEffectivenessCoefficient [General]→TargetEffectivenessCoefficientDefault
Special Threat Coefficient [TechnoType]→TargetSpecialThreatCoefficient [General]→DumbTargetSpecialThreatCoefficient [General]→TargetSpecialThreatCoefficientDefault
Special Threat Value [TechnoType]→SpecialThreatValue [TechnoType]→SpecialThreatValue
Target Strength [TechnoType]→TargetStrengthCoefficient [General]→DumbTargetStrengthCoefficient [General]→TargetStrengthCoefficientDefault
Target Distance [TechnoType]→TargetDistanceCoefficient [General]→DumbTargetDistanceCoefficient [General]→TargetDistanceCoefficientDefault


By default, when a house is created, it is considered to have Threat Rating Node. So, with Threat Rating Node always available, the dumb coefficients are never used.

Threat Calculation

The basic algorithm estimating how much threat a certain object (Attacker) poses to a Defender works like this:

float Threat = Attacker's best weapon's Verses against Defender * Target Effectiveness;
if(Attacker is currently targeting Defender) { // don't look at me, I didn't write the code
  Threat = Threat * (-1);
}

float tempValue = Special Threat Value * Special Threat Coefficient;
Threat = Threat + tempValue;

if(Defender is currently considering Attacker's owner house as the Enemy House) {
  Threat = Threat + [General]EnemyHouseThreatBonus=;
}

tempValue = Defender's best weapon's Verses against Attacker * Self Effectiveness;
Threat = Threat + tempValue;

tempValue = Target Strength * Attacker's current health percentage;
Threat = Threat + tempValue;

tempValue = Target Distance * Distance between Defender and Attacker;
Threat = Threat + tempValue;

Threat = Threat + 100000.0;

Applicability

The threat rating logic is utilised when the object is selecting a target freely and when it is deciding whether or not to retaliate. However, both of those decisions are very complex and depend on a lot of other variables.

See Also

IsThreatRatingNode

  • According to the description in this entry, this tag is actually invalid and there are doubts about it.