My Message close
GAME JOBS
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
May 22, 2013
 
Blizzard Entertainment
Senior Software Engineer, Server
 
Blizzard Entertainment
Senior Software Engineer, Game Play
 
Blizzard Entertainment
Senior Software Engineer, Game Engine
 
NetherRealm Studios
Senior Software Engineer
 
NetherRealm Studios
Lead Software Engineer
 
Monolith Productions
Lead Mission Designer
spacer
Blogs

  Artificial Agent behaviors for Choosing/Switching Targets , Calculating Hit Chance
by Burkay Ozdemir on 03/04/13 07:11:00 pm   Featured Blogs
Post A Comment Share on Twitter Share on Facebook RSS
 
 
The following blog was, unless otherwise noted, independently written by a member of Gamasutra's game development community. The thoughts and opinions expressed here are not necessarily those of Gamasutra or its parent company.

Want to write your own blog post on Gamasutra? It's easy! Click here to get started. Your post could be featured on Gamasutra's home page, right alongside our award-winning articles and news stories.
 

A few months ago, I was searching through web about how artificial agents should switch target?, How should I calculate threat of the enemy? How should I calculate the hit chance and decide if the target has shot or not? and I’ve found almost “nothing”. So I decided to write some formulas according to my experiences in games and some real world situations.

I want to share them with you so that if you’re currently searching for same kind of thing you can find it right here!..

First lets look into threat calculation

Threat value is calculated for each soldier in the list of visible enemies by using factors below:
Distance to target
Angle difference between the defensive soldier and the enemy
The angle of the heading of the enemy and whether the enemy is firing or not
These factors are given different coefficients to balance the effectiveness of these factors in the threat level. So you can change the coefficients as you see fit.

Final formula generated by using these factors is

threat formula

  • DN is the distance normalized with maximum visibility distance.
  • If the enemy heading to the defensive soldier is lower than a minimum angle, A is 1,
  • otherwise it is 0.
  • If the enemy is firing, F is a constant value, otherwise it is 0.

Once you calculate the threat value for each seen enemy in the list, the enemy with the maximum threat can be chosen as the current target.

Lets get to the Hit Chance Calculation

To check if a shot is successful, a calculation is made based on the target distance, aim accuracy, the health of the soldier, whether the soldier is under fire or not and an additional random chance modifier.

With these bear in mind, the final formula is like this

hitchanceformula

  • DN is the distance normalized with maximum visibility distance.
  • AN is the angle difference between the aim of the defensive soldier and the enemy normalized
  • with minimum firing angle.
  • Ccoef is a coefficient depending on the cover status of the target.
  • If the soldier is under fire, U is a constant, otherwise it is 0.
  • Rnd is a random chance modifier.
  • chanceModifier is an external modifier that changes with incoming shots and the type of shooting being made (between 0 and 1)

If Hit Chance is above a certain value the shot is successful.

I think these formulas are simple and more than enough to calculate threat and hit chance for most of the artificial agent scripts. 

Hope these were usefull..till then.. For more.. http://programmerinstincts.com

Credits:
Burkay Ozdemir
Deniz Aladagli 

 
 
Comments


none
 
Comment:
 




 
UBM Tech