Vehicle Weapon AI by Dnamro

The vehicle weapon.con file will need to have an Aitemplate line for each weapon.

So in the object file, the vehicle\air\B17\weapon.con file is this:


rem *** B17BombHolder ***
ObjectTemplate.create FireArms B17BombRack
ObjectTemplate.setNetworkableInfo PlaneFireArmInfo
ObjectTemplate.aiTemplate B17Bombs
***(AI template for B17 bombs)
ObjectTemplate.projectileTemplate HeavyBomberBomb
ObjectTemplate.projectilePosition 0/0/0
ObjectTemplate.magSize 8
ObjectTemplate.numOfMag 10
ObjectTemplate.velocity 0
ObjectTemplate.autoReload 1
ObjectTemplate.reloadtime 15
ObjectTemplate.roundOfFire 4
ObjectTemplate.setAsynchronyFire 1
ObjectTemplate.setInputFire c_PIAltFire
ObjectTemplate.addFireArmsPosition -1/-0.1/0 0/0/0
ObjectTemplate.addFireArmsPosition 1/0.1/0 0/0/0
ObjectTemplate.AmmoType 9


rem *** B17_GunT_GunBarrel ***
ObjectTemplate.create FireArms B17_MG1_FB
ObjectTemplate.setNetworkableInfo PlaneFireArmInfo
ObjectTemplate.loadSoundScript Sounds/B17GunTGunBarrel.ssc
ObjectTemplate.aiTemplate B17MachineGun
****(Aitemplate forB17 machine gun)
rem -------------------------------------
ObjectTemplate.visibleBarrelTemplate e_MuzzB17
rem -------------------------------------
ObjectTemplate.projectileTemplate B17_GunT_Projectile
ObjectTemplate.setTracerTemplate Tracer_Projectile CRD_NONE/2/0/0
ObjectTemplate.projectilePosition 0/0/0
ObjectTemplate.magSize 900
ObjectTemplate.numOfMag 1
ObjectTemplate.velocity 400
ObjectTemplate.roundOfFire 10
ObjectTemplate.addFireArmsPosition 0.2/0.02/0.75 0/0/0
ObjectTemplate.addFireArmsPosition -0.2/0.02/0.75 0/0/0
ObjectTemplate.AmmoType 10
ObjectTemplate.setFireCameraShakeAnimationState FireMachineGunShake


rem *** B17_GunT_Projectile ***
*** (no aitemplate needed for projectiles)
ObjectTemplate.create Projectile B17_GunT_Projectile
ObjectTemplate.createNotInGrid 1
ObjectTemplate.loadSoundScript ../../../Common/Sounds/Projectile.ssc
rem ObjectTemplate.geometry tracklight_m1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.timeToLive CRD_NONE/2/0/0
ObjectTemplate.gravityModifier 0
ObjectTemplate.material 224
ObjectTemplate.material2 -1
ObjectTemplate.stopAtEndEffect 1
ObjectTemplate.hasCollisionEffect 1


rem *** B17_GunB_GunBarrel ***
ObjectTemplate.create FireArms B17_MG2_FB
ObjectTemplate.setNetworkableInfo PlaneFireArmInfo
ObjectTemplate.loadSoundScript Sounds/B17GunTGunBarrel.ssc
ObjectTemplate.aiTemplate B17MachineGun
***(The B17 machine guns share an Aitemplate)
rem -------------------------------------
ObjectTemplate.visibleBarrelTemplate e_MuzzB17
rem -------------------------------------
ObjectTemplate.projectileTemplate B17_GunB_Projectile
ObjectTemplate.setTracerTemplate Tracer_Projectile CRD_NONE/2/0/0
ObjectTemplate.projectilePosition 0/0/0
ObjectTemplate.magSize 900
ObjectTemplate.numOfMag 1
ObjectTemplate.velocity 400
ObjectTemplate.roundOfFire 10
ObjectTemplate.addFireArmsPosition 0.3/0/0.95 0/0/0
ObjectTemplate.addFireArmsPosition -0.3/0/0.95 0/0/0
ObjectTemplate.AmmoType 10
ObjectTemplate.setFireCameraShakeAnimationState FireMachineGunShake

rem *** B17_GunB_Projectile ***
***(no aitemplate needed for projectiles)
ObjectTemplate.create Projectile B17_GunB_Projectile
ObjectTemplate.createNotInGrid 1
ObjectTemplate.loadSoundScript ../../../Common/Sounds/Projectile.ssc
rem ObjectTemplate.geometry tracklight_m1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.timeToLive CRD_NONE/2/0/0
ObjectTemplate.gravityModifier 0
ObjectTemplate.material 224
ObjectTemplate.material2 -1
ObjectTemplate.stopAtEndEffect 1
ObjectTemplate.hasCollisionEffect 1

Now the object files vehicle\air\b17\AI\weapon folder looks like this:


rem * Machine gun *
weaponTemplate.create B17MachineGun
(AI weapon template name)
weaponTemplate.burst 1
(Burst 1 means its an automatic weapon and the bot will fire in short bursts
Burst 0 means non-auto weapon, and the bot will fire separate shots. Bots will fire more accurately and more often in this mode, even with an automatic weapon.)
weaponTemplate.indirect 0
( set to 1 for artillery. Allows the bot to fire a weapon out of its normal line of site using a weapon with indirect fire capability. But, it has to be in its AI weapon range.
Set to 0 for line of site weapons.)
weaponTemplate.minRange 5.0
(this is usually used to make sure the bots are not caught in the blast radius of its own area effect weapon, like a bazooka or a bomb. – Don’t know why the B17 machine gun is set to 5?)
weaponTemplate.maxRange 300.0
weaponTemplate.weaponActivate PINone
( I have not seen this set to anything else. I assume it could be used for a weapon that had to be activated before it could be used)
weaponTemplate.weaponFire PIFire
(PIFire is the primary fire button. PIAltFire is the Alternate fire button)

(Now these are the priorities against target categories)
weaponTemplate.setStrength Infantry 7.0
weaponTemplate.setStrength LightArmour 3.0
weaponTemplate.setStrength HeavyArmour 0.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Submarine 0.0
weaponTemplate.setStrength Air 7.0

rem * Bombs *
weaponTemplate.create B17Bombs
weaponTemplate.burst 1
weaponTemplate.indirect 1
weaponTemplate.minRange 20.0
(Now a value of 20 should keep the bot from dropping bombs if its too close to the target)
weaponTemplate.maxRange 200.0
weaponTemplate.weaponActivate PINone
weaponTemplate.weaponFire PIAltFire
(notice that the weapon bomb code has a setinputfire line to the same key)
weaponTemplate.setStrength Infantry 18.0
weaponTemplate.setStrength LightArmour 12.0
weaponTemplate.setStrength HeavyArmour 11.0
weaponTemplate.setStrength NavalArmour 8.0
weaponTemplate.setStrength Submarine 0.0
weaponTemplate.setStrength Air 1.0