Game Development Reference
In-Depth Information
return Damage;
}
double CAgent::GetAccuracy( CWeapon* pWeapon, USHORT Dist )
{
double Accuracy = pWeapon->GetAccuracy( Dist );
return Accuracy;
}
Therefore, the entire process for determining the time it takes to dispatch a
particular enemy is:
USHORT Dist = GetDistToTarget( pTarget );
USHORT TargetHealth = pTarget->GetHealth();
USHORT DamageIDeal = GetDamage( pWeapon, Dist );
double MyAccuracy = GetAccuracy( pWeapon, Dist );
double TimeToKillEnemy = TimeToKill( TargetHealth,
DamageIDeal,
MyAccuracy );
What Goes 'Round Comes 'Round
Because we know what weapon our enemy is carrying, his accuracy rate (adjusted
for the type of Dude if necessary), and our own health, we can reverse the above
process and determine how long it would take for a particular enemy to dispatch us .
The only difference in the functions is that GetAccuracy() must account for the
Dude adjustment. By passing a pointer to the selected enemy into an overloaded
version of GetAccuracy() , we can add that bit of additional information.
double CAgent::GetAccuracy( CWeapon* pWeapon,
USHORT Dist,
CDude* pDude )
{
// Get Dude's accuracy adjustment
double AccAdjust = pDude->GetAccAdjust();
// Get weapon accuracy adjusted for Dude's skill
Search WWH ::




Custom Search