Game Development Reference
In-Depth Information
threat ratio slightly shows that the resulting scores increase as well. However, we
can see that a ThreatRatio of 4.1 and an Urgency of 0.32 yields a lower Score than the
lower threat ratio (3.8) and lower Urgency (0.26). This exhibits the subtlety in the
combination of the two values.
In the last two lines, the threat of 10.9 isn't terribly dangerous in and of itself.
When combined with a significantly higher Urgency value (the last line), however,
the final score falls into the same range as the more threatening situations. This
would be comparable to a nonthreatening foe approaching the detonator. Whether
he can kill us or not, he becomes a priority target. In fact, if we increase the Urgency
of that last line to 0.95, the final score for that enemy becomes 11.47. That would
make it the lowest score (i.e., highest priority) of the ones shown.
P UTTING I TIN C ODE
Assuming we are now comfortable with the relationships and connections we have
established, we can now go about coding the scoring process. We looked at a portion
of this process already when we laid out the function calls that generated the time-
to-kill values. We will now put it into the whole function.
void CAgent::ScoreTarget( CDude* pTarget, sWEAPON_INFO Weapon )
{
CWeapon* pWeapon = Weapon.pWeapon;
USHORT Dist = GetDistToTarget( pTarget );
// Calculate time to kill enemy
USHORT TargetHealth = pTarget->GetHealth();
USHORT DamageIDeal = GetDamage( pWeapon, Dist );
double MyAccuracy = GetAccuracy( pWeapon, Dist );
double TimeToKillEnemy = TimeToKill( TargetHealth,
DamageIDeal,
MyAccuracy );
// Calculate time for enemy to kill me
double DamageITake = GetDamage( pTarget->GetWeapon(), Dist );
double EnemyAccuracy =
Search WWH ::




Custom Search