Weapon AI Templates Explained

Weapon AItemplates explained

> Here is every BF2 weapon aitemplate property:
>
>
> ```
> weaponTemplate.create
> weaponTemplate.indirect
> weaponTemplate.isThrown
> weaponTemplate.minRange
> weaponTemplate.maxRange
> weaponTemplate.optimalRangePercentage
> weaponTemplate.setFiringPose
> weaponTemplate.weaponActivate
> weaponTemplate.weaponFire
> weaponTemplate.setStrength Infantry
> weaponTemplate.setStrength LightArmour
> weaponTemplate.setStrength HeavyArmour
> weaponTemplate.setStrength NavalArmour
> weaponTemplate.setStrength Helicopter
> weaponTemplate.setStrength AirPlane
> weaponTemplate.fireRate
> weaponTemplate.setSoundSphereRadius
> weaponTemplate.setExplosionRadius
> weaponTemplate.setFiresThroughTransparent
> weaponTemplate.allowedDeviation
> weaponTemplate.deviation
>
> ```
> weaponTemplate.deviation
>
>

>
> Some properties only pertain to handweapons, others only to vehicle weapons. Some properties were only used for a specific class of weapon. Some properties deal with the weapon usage, other properties deal with the weapon projectile. Some properties are optional, and some properties appear to be legacy (BF1942/BFV) code that is ignored.
>
> There are some BF1942/BFV weapon aitemplate properties that may work in BF2, but they are not listed here. As well, there are some new properties in BF2142 not listed.
>
> Since building my new PC, I've been going through my data archives looking for things to purge. This is a collection of miscellaneous BF2-related items, in no particular order, I gleaned mostly from PM's to and from the DICE AI team back in the day. Some of these things may be covered in other threads, but there is likely some detail in here not seen elsewhere. I figured it'd be a good idea to get this stuff posted for public digestion and the "safety" of the internet as a more lasting archive.
>
>
> **Fixing the LookAtWrapper error w/ handheld stingers:**
> The problem is passengers that can use their hand held weapons and that some of them are heatseeking, meaning you get a different plan. Any vehicle type that is called something-fixed (including Fixed), can be passengers. The rib-passengers are of type LandingCrafFixed. I think the ordinary Fixed should work just fine, the stingers are of that type. The passengers on Transport helicopters use ParatrooperFixed as their vehicle type (look in the unit plugin). Add that wrapper, and any other BAPs that might pop up to that vehicle in AIBehaviours.ai.
>
>
>
> attrib:Outsider
>
> What does aiStrategicArea.setTakeable int int do? Does it work?
>
>
>
> aiStrategicArea.setTakeable 1 0
>
>
>
>
> aiStrategicArea.setTakeable 2 0
>
>

>
>
>
>
> First int is 1 or 2 (team). Second int is 0 or 1 (not takeable, is takeable). Can be two lines to set for both teams, don't really need it if set to 1 because default SA is takeable. If set to 0, it just means that regardless of how long time bots spend in that SA, they won't be able to conquer it, i.e. the team's SAI will never consider that SA as owned, keep sending troops there.
>
>
>
>
>
>
>
> Indirect-fired artillery in BF2?
>
> The artillery in BF1 is allowed to attack anything that its team mates had spotted. It's part of the ai artillery vehicle type. You don't need an actual spotter using the binoculars, any friendly ai character will do. If the ai artillery vehicle type code in BF1 was left in BF2, then it should work the same.
>
>
>
>
>
> What does vehiclesearchradius do? Is that why bots are getting stuck in lower decks on our newly navmeshed aircraft carrier, can't find a way up to the planes above?
>
> The vehicle search radius is sperical, but it has nothing to do with the bots trying to enter vehicles. It is used for spawning bots. When a spawn group is considered, the AI checks how many available vehicles are within the vehicleSearchRadius. Lots of them found counts in that search point's favour. I'm less sure what happens in the carrier, maybe it is the airplanes that have a very large bounding radius (which I think is counted spherical as well), and the bots think that they are close enough to enter since they are inside the bounding radius. You can try resizing the airplanes and see if the problem still persist.
>
>
>
>
>
>
>
> How do bot-driven vehicles avoid other vehicles?
>
> Groundvehicles avoid the most urgent obstacle by trying to stay out of its bounding radius. Airvehicles are a bit more suicidal and don't avoid at all.
>
>
>
>
>
>
>
> destructible statics w/ aitemplate and how they turn on or off the navmesh
>
>
>
>
> These are the lines used by the ai...
>
>
>
> ```
> ObjectTemplate.aiTemplate fence
> ObjectTemplate.usedByAi 1
> ObjectTemplate.initiallyWalkable 0
> ObjectTemplate.minCorner -2.8/-1.6/-1
> ObjectTemplate.maxCorner 2.8/1.6/1
>
> ```
>
>
>
>
>
> The minCorner, maxCorner defines a box and inside this box the navMesh will be tesselated and those triangles will then be made walkable or not depending on the state of the destructible object. If it is like a bridge where the navMesh should be walkable while the object is whole the initiallyWalkable property should be set to 1. If it's walkable only after the object is destroyed, like the fence, it should be set to 0. If there is an object in their way that is not affecting the navMesh then the bots should just try to run through it until they suicide. If an aiTemplate static blocked path is the only path, then the bots will wait. If it is a destroyed bridge and no other path available, they will wait.
>
>
>
>
>
>
>
> How exactly does OptimalRangePercentage work?
>
> optimalPercentage = botWeapon->getOptimalRangePercentage() \* 0.01f;
>
> if (botWeapon->getWeaponType() != WTCloseCombat) // not close range weapons
>
> {
>
> optimalPercentage \*= max(0.2f, botskill); (1)
>
> optimalPercentage \*= 0.8f + Random(0.0f, 0.4f); (2)
>
> }
>
> float wantedDistance = weaponMinRange + (weaponMaxRange - weaponMinRange) \* optimalPercentage;[/code]
>
>
>
> (1)The optimal range percentage is multiplied by the bot skill because bots with less skill will have more spread and so would have to get closer to an enemy to be able to hit it.
>
> (2)There is also a random component to it so that all bots with the same weapon doesn't stop and fire at exactly the same distance.
>
>
>
> f in the code above is just syntax. If not specified, by default OptimalRangePercentage is 35.
>
>
>
>
>
>
>
> What all does bot skill affect?
>
> Skill will affect the following...
>
>
>
>
> * Deviation of weapons.
> * Bots will skill < 0.3 will be slower to react to enemy threats.
> * OptimalRangePercentage like explained before
> * Fire rate of anything using the BBPHeliFire3d fire plan. (look in AIBehaviours.ai) This was added in BF2 because the helicopters were just too durn good at taking out tanks on easy setting otherwise.
> * How quickly they can turn. (think "how many bullets you can put in a his back before you will start recieving some yourself")
>
>
>
>
> Should also point out that the extra deviation that is added for bots is only half as big when bots are attacking other bots. Looks better and keeps the action higher if bots are actually hitting other bots even on easy setting.
>
>
>
>
>
> How far can ground bots see? How about bots in PCO's?
>
> View distance for bots is the same no matter if they're in a vechile or not. You can specify their view distance in aiSettings like this...
>
> aiSettings.setViewDistance 500
>
>
>
> If nothing is specified it will use the game's view distance, i.e. any bot you can see on screen can also see you.
>
>
>
>
>
> bots aiming/shooting through windows?
>
> The AI uses the bullet collision model to determine if they can see/shoot through a particular piece of geometry. So if YOU can really shoot through the window, then the bots can see you and will shoot you, and if you can't really shoot through the window, then they won't see you.
>
>
>
>
>
> It seems aiTemplatePlugIn.create Armament line is required for any vehicle position which has a vehicle camera, whether or not a weapon exists in that position?
>
> We don't remember!
>
>
>
>
>
> We recently found that the additional parameter
>
> aiTemplatePlugin.CullDistance <Distance>
>
> in the aiTemplate influences the visibility of an object for bots. An object will not be seen ( and targetted ) if beyond the cullDistance.
>
>
>
> isInitiallyWalkable also is just that, its for walking bots. I found bots will ignore a destroyed bridge when in a vehicle and happily drive into the abyss tongue.gif Happens with the vanilla woodbridges (e.g. on Wake Island ) and i'd either like to have it confirmed or a fix for it laugh.gif
>
>
>
> The bot skill is used to see how big a part of the ai weapon deviation is used (there is a default value that most weapons use, so that's why you don't normally see it). Time is also involved. A bot that keeps shooting at the same target will have its deviation decreased. A bot skill of 1 results on no additional bot deviation.
>
>
>
>
>
>
> The bots target the point that they see. They first try to see the centre of an object, if that fails, they try for the camera, and if that fails they try for a random position.
>
>