Using Common Handweapon AI

By Dnamro

First of all, I use the term "**Common Handweapon AI**" to mean that I have one file that has all the AI templates for the different types of hand weapons.

This makes it a lot easier to customize and balance the hand weapon AI. A mod can have a wide variety of hand weapons, but there are really only a few different types and they need to be set up consistently so the bots will use the weapons properly. This way it is really easy to add extra weapons to the mod and you can customize the AI gameplay how you want it.

For example, since bots don't run out of ammo, you can have the bots use a variety of weapons based on distance to make it seem more realistic. Also it you have the bots use pistols up close, they will be less lethal than if they used the main weapon all the time. You can also customize the weapon AI to the map. So, if you had a night map, for example, you could have the bots use the handweapons at much shorter ranges. The special purpose weapons (Heal, revive, Ammo, repair) should be set to a strategic strength depending on the priority that you want the bots to use. I generally set them to a low priority because I want the bots fight first and then do healing, reviving, repairing or Supplying after the firefight.

Note: The strength command (**weaponTemplate.setStrength**) is a relative value, usually between **0 and 20**.

Setting up:

1. In the handweapon object folder, I added a **weapon.AI** file with all the custom handweapon AI templates in **\custom\_handweapon\_AI** folder.
2. Each template needs to have a unique name
3. Each handweapon needs to be assigned on of the Aitemplate names in this file.

<i wish the author would append a screenshot of what he meant. there is now a file and a folder with no context to their positioning with each other. Also point 3. speaks about a assignation, but no code is given, so the sentence is meaningless>

The types of hand weapons are generally:

 shotguns
 rifle
 knifes
 sniper
 rocket launcher
 grenades

Here is a example Common AI folder from a BF2142 mod:

```
rem \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
rem \*\*\* Common AI \*\*\*
rem \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
weaponTemplate.create melee\_weapon\_AI
weaponTemplate.weaponType CloseCombat
weaponTemplate.indirect 0
weaponTemplate.minRange 0.0
weaponTemplate.maxRange 2.0
weaponTemplate.optimalRangePercentage 80
weaponTemplate.setFiringPose Standing
weaponTemplate.setStrength Infantry    15.0
weaponTemplate.setStrength LightArmour 0.0
weaponTemplate.setStrength HeavyArmour 0.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.setSoundSphereRadius    0.0
weaponTemplate.deviation 0
weaponTemplate.create deployer\_AI
weaponTemplate.weaponType FireAndForget
weaponTemplate.shouldRearm 0
weaponTemplate.minRange 40.0
weaponTemplate.maxRange 100.0
weaponTemplate.optimalRangePercentage 70
weaponTemplate.setFiringPose Crouching
weaponTemplate.setStrength Infantery    10.1
weaponTemplate.setStrength LightArmour 0.0
weaponTemplate.setStrength HeavyArmour 0.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.setFiresThroughTransparent 0

rem \*\*\* Ammo \*\*\*
weaponTemplate.create ammobox\_resupply\_AI
weaponTemplate.weaponType Ammo
weaponTemplate.minRange 0.0
weaponTemplate.maxRange 60.0

rem \*\*\* Repair \*\*\*
weaponTemplate.create repair\_vehicle\_AI
weaponTemplate.weaponType Repair
weaponTemplate.minRange 0.0
weaponTemplate.maxRange 60

rem \*\*\* medic defib \*\*\*
weaponTemplate.create defib\_revive\_AI
weaponTemplate.weaponType Revive
weaponTemplate.minRange 0.0
weaponTemplate.maxRange 5.0

rem \*\*\* Heal \*\*\*
weaponTemplate.create heal\_trooper\_AI
weaponTemplate.weaponType Healing
weaponTemplate.minRange 0.0
weaponTemplate.maxRange 60.0

rem \*\*\* deploy mine \*\*\*
weaponTemplate.create mine\_drop\_AI
rem weaponTemplate.weaponType C4
weaponTemplate.indirect 0
weaponTemplate.minRange 0.0
weaponTemplate.maxRange 30.0
weaponTemplate.isThrown 1
weaponTemplate.optimalRangePercentage 1
weaponTemplate.setStrength Infantry    2.0
weaponTemplate.setStrength LightArmour 1.0
weaponTemplate.setStrength HeavyArmour 0.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.setSoundSphereRadius    30.0

rem \*\*\* Pistol
weaponTemplate.create pistol\_AI
weaponTemplate.indirect 0
weaponTemplate.minRange 2.1
weaponTemplate.maxRange 30.0
weaponTemplate.optimalRangePercentage 35
weaponTemplate.setFiringPose Crouching
weaponTemplate.setStrength Infantry    6.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength HeavyArmour 1.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0

rem \*\*\* rifle (e11c, dlt19, MG15, bowcaster, a280) \*\*\*
weaponTemplate.create rifle\_AI
weaponTemplate.indirect 0
weaponTemplate.minRange 2.1
weaponTemplate.maxRange 200.0
weaponTemplate.optimalRangePercentage 35
weaponTemplate.setFiringPose Crouching
weaponTemplate.setStrength Infantry    8.0
weaponTemplate.setStrength LightArmour 3.0
weaponTemplate.setStrength HeavyArmour 2.0
weaponTemplate.setStrength NavalArmour 1.0
weaponTemplate.setStrength Helicopter  1.0
weaponTemplate.setStrength AirPlane    1.0
weaponTemplate.allowedDeviation 15.0
weaponTemplate.deviationCorrectionTime 1
weaponTemplate.deviation 0.1

rem \*\*\* Sniper (e17d, disrupter) \*\*\*
weaponTemplate.create sniper\_rifle\_AI
weaponTemplate.weaponType Sniper
weaponTemplate.indirect 0
weaponTemplate.minRange 100.0
weaponTemplate.maxRange 300.0
weaponTemplate.optimalRangePercentage 70
weaponTemplate.setFiringPose Lying
weaponTemplate.setStrength Infantry    12.0
weaponTemplate.setStrength LightArmour 0.0
weaponTemplate.setStrength HeavyArmour 0.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.deviation 0.1

rem \*\*\* Heavy rifle (T21, MK1) \*\*\*
weaponTemplate.create heavy\_rifle\_AI
weaponTemplate.indirect 0
weaponTemplate.minRange 30.1
weaponTemplate.maxRange 100.0
weaponTemplate.optimalRangePercentage 50
weaponTemplate.setFiringPose Lying
weaponTemplate.setStrength Infantry    11.0
weaponTemplate.setStrength LightArmour 4.0
weaponTemplate.setStrength HeavyArmour 2.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.allowedDeviation 15.0
weaponTemplate.deviationCorrectionTime 1
weaponTemplate.deviation 0.1

rem \*\*\* shotgun (flechette, CR1)
weaponTemplate.create shotgun\_AI
weaponTemplate.indirect 0
weaponTemplate.minRange 2.1
weaponTemplate.maxRange 30.0
weaponTemplate.optimalRangePercentage 35
weaponTemplate.setFiringPose Crouching
weaponTemplate.setStrength Infantry    8.0
weaponTemplate.setStrength LightArmour 1.0
weaponTemplate.setStrength HeavyArmour 0.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.deviation 0.1

rem \*\*\* rocket launcher  HH15, demp15, demp
weaponTemplate.create rocket\_launcher\_AI
weaponTemplate.minRange 10.0
weaponTemplate.maxRange 160.0
weaponTemplate.optimalRangePercentage 35
weaponTemplate.setFiringPose Crouching
weaponTemplate.setStrength Infantry    3.0
weaponTemplate.setStrength LightArmour 6.0
weaponTemplate.setStrength HeavyArmour 8.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  2.0
weaponTemplate.setStrength AirPlane    1.0
weaponTemplate.setFiresThroughTransparent 0

rem \*\*\* grenade launcher PMG
weaponTemplate.create grenade\_launcher\_AI
weaponTemplate.minRange 10.0
weaponTemplate.maxRange 100.0
weaponTemplate.optimalRangePercentage 35
weaponTemplate.setFiringPose Crouching
weaponTemplate.setStrength Infantry    8.0
weaponTemplate.setStrength LightArmour 4.0
weaponTemplate.setStrength HeavyArmour 1.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.setFiresThroughTransparent 0

rem \*\*\* grenade \*\*\*
weaponTemplate.create grenade\_AI
weaponTemplate.shouldRearm 0
weaponTemplate.indirect 0
weaponTemplate.isThrown 1
weaponTemplate.minRange 45.0
weaponTemplate.maxRange 65.0
weaponTemplate.optimalRangePercentage 85
weaponTemplate.setFiringPose Standing
weaponTemplate.setStrength Infantry    5.0
weaponTemplate.setStrength LightArmour 1.0
weaponTemplate.setStrength HeavyArmour 1.0
weaponTemplate.setStrength NavalArmour 0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.setSoundSphereRadius  30.0
weaponTemplate.setExplosionRadius 10.0
weaponTemplate.allowedDeviation 2.5
weaponTemplate.setFiresThroughTransparent 0
weaponTemplate.isEmpWeapon 0
weaponTemplate.explodesOnImpact 0

rem \*\*\* grenade Anti\_vehicle\*\*\*
weaponTemplate.create grenade\_AV\_AI
weaponTemplate.shouldRearm 0
weaponTemplate.indirect 0
weaponTemplate.isThrown 1
weaponTemplate.minRange 45.0
weaponTemplate.maxRange 65.0
weaponTemplate.optimalRangePercentage 85
weaponTemplate.setFiringPose Standing
weaponTemplate.setStrength Infantry    0.0
weaponTemplate.setStrength LightArmour 5.0
weaponTemplate.setStrength HeavyArmour 6.2
weaponTemplate.setStrength NavalArmour 0
weaponTemplate.setStrength Helicopter  0.0
weaponTemplate.setStrength AirPlane    0.0
weaponTemplate.setSoundSphereRadius  30.0
weaponTemplate.setExplosionRadius 10.0
weaponTemplate.allowedDeviation 2.5
weaponTemplate.setFiresThroughTransparent 0
weaponTemplate.isEmpWeapon 0
weaponTemplate.explodesOnImpact 0

```