IPB

Welcome Guest ( Log In | Register )

aiTemplates for dummies
xstax981
post Dec 30 2006, 12:05 PM
Post #1


Spontaneous Visitor
*****

Group: Soldiers
Posts: 1,040
Joined: 6-April 06
Member No.: 1,685



First off, lets start off defining what an aiTemplate is. If you were making a custom vehicle without aiTemplates, and tried to play it in SP, you would get a crash. An aiTemplate defines how the bots act in the vehicle. They make the AI attack in attack choppers, or transport people in transport choppers.

aiTemplates are necessary for vehicles AND weapons. You can create your own aiTemplate, or you can use existing ones, which is a lot easier to do than making your own. This tutorial will cover using existing ones.

I'm using the HIND as an example, and I'll give it an aiTemplate.

First, open up your objects_server.zip file, then look for the xpak_hind file.

Open up the xpak_hind.tweak file, and take a look at its code. You'll see the pilot seat has an aiTemplate, but not the gunner seat.

Now search for xpak_hind_gunner. Underneath that, look for the first reference of this code:

CODE

ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 1


Right below the ObjectTemplate.hasMobilePhysics 1 add this code:
CODE

ObjectTemplate.aiTemplate Ahe_Z10_Gunner


This will now allow a gunner into the HIND without crashing the game. There are many other templates you can use, like for a car passenger you could use HmmwvPassenger, or for a transport chopper passenger you can use UH60_Passenger1 or UH60_Passenger2.

You will have to apply aiTemplates to all the different positions in a vehicle that do not have aiTemplates.

But wait, there's more!

If you are creating a whole new vehicle, you also need to give the weapons the vehicle uses an aiTemplate. Without these, you can get in the vehicle position, but if you fire the weapon it will crash the game.

To do this, look up the weapon name. For example, in the HIND file, search for this:

CODE

ObjectTemplate.create GenericFireArm xpak_hind_GenericFireArm_Hydra


And then basically repeat the above, except insert some other aiTemplate, like AHE_AH1Z_Rockets

Weapons also need an aiTemplate, its basically the same thing, except you would place ObjectTemplate.aiTemplate [inserttemplatehere] underneath this first reference of this line of code:

CODE

ObjectTemplate.physicsType Point



That's basically it, I tried to make it as basic as possible, sorry if it is complicated.

Cheers

This post has been edited by xstax981: Dec 30 2006, 04:41 PM


--------------------


Yes, I love Lord Jesus Christ. :)

QUOTE (caliber_k's siggy)
Trust in the LORD with all your heart and lean not on your own understanding, in all your ways acknowledge him, and he will make your paths straight.
Proverbs 3:5-6
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies (1 - 14)
CrazyAce
post Dec 30 2006, 02:08 PM
Post #2


General
*****

Group: Soldiers
Posts: 1,733
Joined: 13-January 06
Member No.: 1,399



Short, yet simple to understand, thanx bigthumb.gif This has come in handy.

This post has been edited by CrazyAce: Dec 30 2006, 02:08 PM


--------------------
Go to the top of the page
 
+Quote Post
imtheheadhunter
post Dec 30 2006, 02:51 PM
Post #3


Debug assertion failed! Text:people == stupid!
Group Icon

Group: Mr. Admin
Posts: 1,005,138
Joined: 8-March 06
From: The freaking Twilight zone!
Member No.: 1,609



now all we need is how to set up a completely new aitemplate. wink.gif


--------------------
Go to the top of the page
 
+Quote Post
Death_EnForcer
post Dec 30 2006, 04:09 PM
Post #4


Dictator
Group Icon

Group: BFSP Team
Posts: 2,561
Joined: 17-July 04
From: New Jersey, USA
Member No.: 294



Thanks, xstax981. This is a very important subject in getting mods to work with SP/Coop. Hopefully the coders for the mods will get to understand how to fix them. Good job. bigthumb.gif
Go to the top of the page
 
+Quote Post
iflabs
post Jan 4 2007, 02:30 AM
Post #5


Private
**

Group: Soldiers
Posts: 19
Joined: 10-August 05
Member No.: 1,108



So how would you go about adding new weapons, like hydra rockets to A-10s?
Go to the top of the page
 
+Quote Post
Outsider
post Jan 4 2007, 10:52 AM
Post #6


Major
****

Group: Soldiers
Posts: 205
Joined: 18-June 05
Member No.: 672



It is actually better to make a copy of the aiTemplate, than just referencing an existing one. The aiTemplates do a lot of computations on the vehicle/weapon the first time an instance is created, this is information that is then saved and used for all instances of that template. This is information that you do not see in the aiTemplate in the script file, exactly because this is information that you do not need to provide yourself. The Hind gunner may look similar to the Cobra gunner, but the Hind gunner sits in a different object (that is it is in the Hind), but the Cobra gunner will have references to the other aiTemplates that are in the Cobra object. This is a consideration that is even more important for the weapons, as they do a lot more calculations. Making a copy also has the added benefit of you not being dependent on having the Cobra on all the maps that the Hind is on (I don't think that is actually a problem for standard BF2 vehicles, as they would always be there, but if you use a template from your CustomVehicleA in your CustomVehicleB, then you could not build a map with B without including A too).
Go to the top of the page
 
+Quote Post
Recruit_clivewil_*
post Jan 4 2007, 05:29 PM
Post #7





Guests






Outsider!!! good to see you back here. best wishes for 2007 biggrin.gif

QUOTE
It is actually better to make a copy of the aiTemplate, than just referencing an existing one.

thanks for clearing that up - i always wondered what the deal was there, whether or not i was 'clogging up the system' by creating unique ai for every vehicle i make
Go to the top of the page
 
+Quote Post
SteamChip
post Jan 7 2007, 08:05 PM
Post #8


Enlisted
*

Group: Soldiers
Posts: 1
Joined: 7-January 07
Member No.: 2,890



Now search for xpak_hind_gunner. Underneath that, look for the first reference of this code:

CODE

ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 1


Right below the ObjectTemplate.hasMobilePhysics 1 add this code:
CODE

ObjectTemplate.aiTemplate Ahe_Z10_Gunner


------------------------------------------------------------------------

If I understand this right, I add this one line of code only and I can have the hind with an AI gunner that actually fires the MG and camera missile or is there something else missing?

I want to do the same for the ahe_z10 and other attack helicopters, maybe someone has already DONE THIS?!

----------

the claymore and atmine AI hacks mentioned earlier are a BLAST
Go to the top of the page
 
+Quote Post
Exoman
post Jan 8 2007, 12:53 PM
Post #9


Major
****

Group: Soldiers
Posts: 169
Joined: 23-July 06
From: Adelaide, South Australia
Member No.: 1,919



QUOTE
The aiTemplates do a lot of computations on the vehicle/weapon the first time an instance is created, this is information that is then saved and used for all instances of that template.


Hi Outsider,

Are you saying that we should have a uinique template for everything?
For example if we take the default Cobra, it has about 4 aitemplates.
One for the chopper itself, one for the cogunner, one for the gun and one for the hyrda rockets.

So if we make a custom chopper, we should also create 4 custom unique aitemplates as well??


In terms of computer software, isn't it quicker and uses less memory to call the already saved aitemplates?
Like an aitemplate saved once and then called 10 more times is better then making 11 individuals that need to all those computations each time?


Just trying to understand if there is a right way to be doing these type of things that's all smile.gif


Go to the top of the page
 
+Quote Post
Recruit_clivewil_*
post Jan 8 2007, 04:58 PM
Post #10





Guests






QUOTE
I add this one line of code only and I can have the hind with an AI gunner that actually fires the MG and camera missile or is there something else missing?

bots won't fire the TV missiles; you will need to change their targeting type to something else i.e. laser guided, wire guided, or dumbfire before bots will launch them
Go to the top of the page
 
+Quote Post
SatNav
post Jan 8 2007, 10:34 PM
Post #11


Cesar
*******

Group: Banned
Posts: 6,918
Joined: 24-June 05
Member No.: 752



QUOTE(clivewil @ Jan 9 2007, 11:58 AM) [snapback]65125[/snapback]

bots won't fire the TV missiles; you will need to change their targeting type to something else i.e. laser guided, wire guided, or dumbfire before bots will launch them

bots will fire it once at the target but can't reguide it if the target moves.
Go to the top of the page
 
+Quote Post
Cold Fussion
post Jan 8 2007, 10:35 PM
Post #12


Major
****

Group: Soldiers
Posts: 547
Joined: 6-May 06
Member No.: 1,730



QUOTE(clivewil @ Jan 8 2007, 05:58 PM) [snapback]65125[/snapback]

QUOTE
I add this one line of code only and I can have the hind with an AI gunner that actually fires the MG and camera missile or is there something else missing?

bots won't fire the TV missiles; you will need to change their targeting type to something else i.e. laser guided, wire guided, or dumbfire before bots will launch them


elaborate please.


--------------------
..::: My DeviantART Page :::..



"With over 100 players in some of the largest online battles on the PC". - Dice.se
------------------------------------------------------------------------------------------------
"Battlefield 2 features immense, richly detailed, destructible environments" - Dice.se



Go to the top of the page
 
+Quote Post
Vampire
post Apr 24 2007, 05:16 AM
Post #13


CKUA
****

Group: Soldiers
Posts: 384
Joined: 11-June 05
Member No.: 619



I'm trying to get a good variety of vehicles onto my custom mod. I've got the Apache Longbow from SF working fine.
However I am having trouble with xpak_civ1 station wagon. Everytime I try the passenger seat I CTD.
Plus I took the POE2 German Dingo for a spin. Anytime a bot tries the gun turret I CTD.
Here is what I get first part from the log next parts from the dump file...
CODE
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_2 UnitType: 1F1E36A4

D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_1 UnitType: 1F1E425C
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_2 UnitType: 1F1E37D0
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_1 UnitType: 1F1E3230
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_2 UnitType: 1F1E36A4
[EOF]'

D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_2 UnitType: 1F1A3938

ASSERT INFORMATION:
[...]
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_1 UnitType: 1F1A3A64
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_wolf_rear_passenger_01 UnitType: 1F1A23E4
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_wolf_side_Passenger UnitType: 1F1A4130
D:\DiceCanada\BoosterPack2\Code\BF2\AI\AIDLL\AI\AIBotBehaviour\BBFire.cpp(206): Assert: AIBotBehaviour: (botUnit && botPhysical && botArmament && botControl) Bot equipment missing necessary plugins: gerjeep_dingo_passenger_2 UnitType: 1F1A3938
[EOF]'

I already tried creating a whole new AI template since all it was, was redirecting to the Vodnik. That didn't help.

This post has been edited by Vampire: Apr 24 2007, 05:50 AM


--------------------
Go to the top of the page
 
+Quote Post
Fortran80
post Apr 24 2007, 11:26 AM
Post #14


Captain
***

Group: Soldiers
Posts: 37
Joined: 2-March 07
Member No.: 3,069



QUOTE(imtheheadhunter @ Dec 30 2006, 03:51 PM) [snapback]64372[/snapback]

now all we need is how to set up a completely new aitemplate. wink.gif



Ok, well, i am no expert on AI, but here is a short explanation and run through of an AI template. The main thing to note, is that each PCO in your vehicle needs an AI setup. these are all added to your vehicles objects.ai and each section is referenced in your vehicles tweak file under its relevant PCO using "ObjectTemplate.aiTemplate YOURTEMPLATENAME" as described by xstax981 earlier. Also each weapon, not the moving part in say a turret, but the actual gun or missile itself needs its own entry in the weapons.ai file. These are then referenced in the aitemplate of the weapon in your tweak.

Here is a setup for a Land or Sea based vehicle with no weaponary. If i dont comment below the code, its because its either self-explanatory or im not sure of how it actually effects the AI, so in this case, usually best to look at a vanilla vehicle similar to yours.

CODE

rem *** Plugins ***
aiTemplatePlugIn.create Mobile NAMEOFYOURVEHICLEMobile


CODE

aiTemplatePlugIn.setPathfindingMap Vehicle

(type of pathfinding, should be Vehicle, for land/sea..aircraft uses a different setup)


CODE

aiTemplatePlugIn.maxSpeed 25.0

(Max speed you wish the Bot to drive the vehicle)


CODE

aiTemplatePlugIn.turnRadius 5.0
(Turning radius)

CODE

aiTemplatePlugIn.coverSearchRadius 50.0

CODE

aiTemplatePlugIn.create Physical NAMEOFYOURVEHICLEPhysical
(create component)

CODE

aiTemplatePlugIn.setStrType LightArmour

(set the type, ie. Infantry, LightArmour, HeavyArmour, NavalArmour, Helicopter, Airplane. These are used by the weapons.AI to tell the bots what to use the weapon against, so make sure yours is setup with the correct type for your vehicle...so for example, if you set a landbased vehicle to use Airplane or Helicopter in this section, the bots would persive it to be an aircraft and attempt to attack it accordingly)

CODE

aiTemplatePlugIn.create Cover NAMEOFYOURVEHICLECover
aiTemplatePlugIn.coverValue 2.0
aiTemplatePlugIn.create Unit NAMEOFYOURVEHICLEUnit
aiTemplatePlugIn.setStrategicStrength 0 1
aiTemplatePlugIn.setStrategicStrength 1 0


CODE

aiTemplatePlugIn.equipmentTypeName LandingCraft
(Car, Tank, ArmedCar, LandingCraft)

CODE

aiTemplatePlugIn.setHasExposedSoldier 1

(is the soldier visible/shootable from the vehicle)


This next section is farily self-explanatory..but basically you need to match the control setup or your vehicle to the following, so for example, the first line "driveTurnControl", set the control input for turning the vehicle..so usually PIYaw. The other sections including sensetivity are just that, so unless your vehicle handles wildly differently to a vanilla one, keep these type of values the same as a vanilla vehicle that is similar to your own.

[codebox]
aiTemplatePlugIn.create ControlInfo NAMEOFYOURVEHICLECtrl
aiTemplatePlugIn.driveTurnControl PIYaw
aiTemplatePlugIn.driveThrottleControl PIThrottle
aiTemplatePlugIn.aimHorizontalControl PIMouseLookX
aiTemplatePlugIn.aimVerticalControl PIMouseLookY
aiTemplatePlugIn.lookHorizontalControl PIMouseLookX
aiTemplatePlugIn.lookVerticalControl PIMouseLookY
aiTemplatePlugIn.throttleSensitivity -1.0
rem aiTemplatePlugIn.pitchSensitivity 0.021817
rem aiTemplatePlugIn.rollSensitivity -0.021817
aiTemplatePlugIn.pitchSensitivity 0.21817
aiTemplatePlugIn.rollSensitivity -0.21817
aiTemplatePlugIn.yawSensitivity -2.5
rem aiTemplatePlugIn.lookVerticalSensitivity 0.021817
rem aiTemplatePlugIn.lookHorizontalSensitivity -0.021817
aiTemplatePlugIn.lookVerticalSensitivity 0.21817
aiTemplatePlugIn.lookHorizontalSensitivity -0.21817
aiTemplatePlugIn.throttleLookAhead 1.0
aiTemplatePlugIn.pitchLookAhead 1.0
aiTemplatePlugIn.rollLookAhead 1.0
aiTemplatePlugIn.yawLookAhead 1.0
aiTemplatePlugIn.lookVerticalLookAhead 1.0
aiTemplatePlugIn.lookHorizontalLookAhead 1.0
aiTemplatePlugIn.throttleScale 1.0
rem *** Angle in radians ***
aiTemplatePlugIn.pitchScale 1.0
aiTemplatePlugIn.rollScale 1.0
aiTemplatePlugIn.yawScale 0.0020
aiTemplatePlugIn.lookVerticalScale 1.0
aiTemplatePlugIn.lookHorizontalScale 1.0
aiTemplatePlugIn.setCameraRelativeMinRotationDeg -110/-40/0
aiTemplatePlugIn.setCameraRelativeMaxRotationDeg 110/10/0

[/codebox]

This last section actually builds the AI template from the components above.

CODE

rem *** AITemplate ***
aiTemplate.create NAMEOFYOURVEHICLEAITEMPLATE

(Whatever you like, this is what you will call in the vehicles tweak file to connect the AI)

CODE

aiTemplate.addType ITBiological

CODE

aiTemplate.addType ITNaval

(ITGround for land based, ITNaval for sea based and ITAir for flying vehicles)
CODE

aiTemplate.addType ITMobile
aiTemplate.degeneration 10
aiTemplate.allowedTimeDiff 2
aiTemplate.basicTemp 6
aiTemplate.commonKnowledge 0

Not 100% but i believe the basicTemp section of this code sets how much the bots will try to use the vehicle

These next lines basically add the componenets from above, so make sure they are named the same

CODE

aiTemplate.addPlugIn NAMEOFYOURVEHICLEMobile
aiTemplate.addPlugIn NAMEOFYOURVEHICLEPhysical
aiTemplate.addPlugIn NAMEOFYOURVEHICLECover
aiTemplate.addPlugIn NAMEOFYOURVEHICLECtrl
aiTemplate.addPlugIn NAMEOFYOURVEHICLEUnit



Ok, so if your vehicle had an armament, for example, lets say it has a rotating gun turret controlled by one of the passengers. You would need to add this section into you vehicles objects.ai as well.

CODE

aiTemplatePlugIn.create Armament NAMEOFYOURVEHICLETopMgArms
aiTemplatePlugIn.setIsAntiAircraft 1

Set the name of the armament AI and sets if it is to be used against aircraft...believe the choices are 0, 1 or 2, but im not sure if it should be set higher.

The following sections are just the same lines as the vehicle...so just set them up in the same kind of way, but based on how your turret moves.

[codebox]

aiTemplatePlugIn.create Unit NAMEOFYOURVEHICLETopMgUnit
aiTemplatePlugIn.equipmentTypeName Fixed
aiTemplatePlugIn.setStrategicStrength 0 1
aiTemplatePlugIn.setStrategicStrength 1 1
aiTemplatePlugIn.setHasExposedSoldier 0

aiTemplatePlugIn.create ControlInfo NAMEOFYOURVEHICLETopMgCtrl
aiTemplatePlugIn.driveTurnControl PIYaw
aiTemplatePlugIn.driveThrottleControl PIThrottle
aiTemplatePlugIn.aimHorizontalControl PIMouseLookX
aiTemplatePlugIn.aimVerticalControl PIMouseLookY
aiTemplatePlugIn.lookHorizontalControl PIMouseLookX
aiTemplatePlugIn.lookVerticalControl PIMouseLookY
aiTemplatePlugIn.throttleSensitivity -1.0
rem aiTemplatePlugIn.pitchSensitivity 0.021817
rem aiTemplatePlugIn.rollSensitivity -0.021817
aiTemplatePlugIn.pitchSensitivity 0.21817
aiTemplatePlugIn.rollSensitivity -0.21817
aiTemplatePlugIn.yawSensitivity -2.5
rem aiTemplatePlugIn.lookVerticalSensitivity 0.021817
rem aiTemplatePlugIn.lookHorizontalSensitivity -0.021817
aiTemplatePlugIn.lookVerticalSensitivity 0.21817
aiTemplatePlugIn.lookHorizontalSensitivity -0.21817
aiTemplatePlugIn.proportionalConstant -4
aiTemplatePlugIn.derivativeConstant -1.0
aiTemplatePlugIn.throttleLookAhead 1.0
aiTemplatePlugIn.pitchLookAhead 1.0
aiTemplatePlugIn.rollLookAhead 1.0
aiTemplatePlugIn.yawLookAhead 1.0
aiTemplatePlugIn.lookVerticalLookAhead 1.0
aiTemplatePlugIn.lookHorizontalLookAhead 1.0
aiTemplatePlugIn.throttleScale 1.0
rem *** Angle in radians ***
aiTemplatePlugIn.pitchScale 5.0
aiTemplatePlugIn.rollScale 5.0
aiTemplatePlugIn.yawScale 0.0020
aiTemplatePlugIn.lookVerticalScale 1.0
aiTemplatePlugIn.lookHorizontalScale 1.0
aiTemplatePlugIn.setCameraRelativeMinRotationDeg -360/-45/0
aiTemplatePlugIn.setCameraRelativeMaxRotationDeg 360/18/0
[/codebox]
CODE


rem *** AITemplate ***
aiTemplate.create NAMEOFYOURVEHICLEGunner
aiTemplate.addType ITUnit
aiTemplate.addType ITBiological
aiTemplate.addType ITGround
aiTemplate.degeneration 15
aiTemplate.allowedTimeDiff 2
aiTemplate.basicTemp 7
aiTemplate.commonKnowledge 0
aiTemplate.secondary 1
aiTemplate.addPlugIn NAMEOFYOURVEHICLETopMgArms
aiTemplate.addPlugIn NAMEOFYOURVEHICLETopMgUnit
aiTemplate.addPlugIn NAMEOFYOURVEHICLETopMgCtrl


This last section is the same kind of thing as the vehicle....it will define the Ai template for the gunners seat, so whatever you set your "aiTemplate.create NAMEOFYOURVEHICLEGunner" line to, will be the aitemplate you use in the vehicles tweak file under the gunners PCO.

Ok and finally, say your vehicle had a fixed, non-rotating mssile launcher..ie like AA missiles on a plane. You would basically add

CODE

aiTemplatePlugIn.create Armament NAMEOFYOURVEHICLE
aiTemplatePlugIn.setIsAntiAircraft 1


to the main part of your vehicle object.ai

and add

aiTemplate.addPlugIn WHATEVERYOUCALLEDYOURCREATEARMAMENTCOMPONENT

to the section which adds the plugins for the PCO that controls the missiles, so in this post I have the missiles contolled by the driver, so it would look like this

CODE

aiTemplate.addPlugIn NAMEOFYOURVEHICLEMobile
aiTemplate.addPlugIn NAMEOFYOURVEHICLEPhysical
aiTemplate.addPlugIn NAMEOFYOURVEHICLECover
aiTemplate.addPlugIn NAMEOFYOURVEHICLECtrl
aiTemplate.addPlugIn NAMEOFYOURVEHICLEUnit
aiTemplate.addPlugIn WHATEVERYOUCALLEDYOURCREATEARMAMENTCOMPONENT


Now your vehicle is setup with the AI to fire the missile, now we would need a weapons.ai file with the following.

CODE


weaponTemplate.create NAMEOFYOURVEHICLEWEAPON
weaponTemplate.indirect 0
weaponTemplate.minRange 5.0
weaponTemplate.maxRange 600.0
weaponTemplate.setStrength Infantry    0.0
weaponTemplate.setStrength LightArmour 0.0
weaponTemplate.setStrength HeavyArmour 0.0
weaponTemplate.setStrength NavalArmour 0.0
weaponTemplate.setStrength Helicopter  7.0
weaponTemplate.setStrength Airplane    9.0
weaponTemplate.allowedDeviation 15.0


The first line "weaponTemplate.create NAMEOFYOURVEHICLEWEAPON" will be the name of the aitemplate you use for the weapon in your vehicles tweak file.

You can see the section i talked about earlier, the minRange, MaxRange are just that, how near or far the bot will fire the missile...and the lines below that are where you set what the bot will use the weapon against. So in this example, which is an AA style sidewinder AI, we can see its used only against Helicopters and Planes...which makes sense lol .

As a last point, each passenger in the vehicle, driving, or shooting or not, will need its own ai setup in the objects.ai , so as an example, here is a passenger ai from the Vodnik.

[codebox]
aiTemplatePlugIn.create Unit VodnikPassengerUnit
aiTemplatePlugIn.equipmentTypeName Fixed
aiTemplatePlugIn.setStrategicStrength 0 1
aiTemplatePlugIn.setStrategicStrength 1 1
aiTemplatePlugIn.setSelectKey PIPositionSelect3
aiTemplatePlugIn.setHasExposedSoldier 1

aiTemplatePlugIn.create ControlInfo VodnikPassengerCtrl
aiTemplatePlugIn.driveTurnControl PIYaw
aiTemplatePlugIn.driveThrottleControl PIThrottle
aiTemplatePlugIn.aimHorizontalControl PIMouseLookX
aiTemplatePlugIn.aimVerticalControl PIMouseLookY
aiTemplatePlugIn.lookHorizontalControl PIMouseLookX
aiTemplatePlugIn.lookVerticalControl PIMouseLookY
aiTemplatePlugIn.throttleSensitivity -1.0
rem aiTemplatePlugIn.pitchSensitivity 0.021817
rem aiTemplatePlugIn.rollSensitivity -0.021817
aiTemplatePlugIn.pitchSensitivity 0.21817
aiTemplatePlugIn.rollSensitivity -0.21817
aiTemplatePlugIn.yawSensitivity -2.5
rem aiTemplatePlugIn.lookVerticalSensitivity 0.021817
rem aiTemplatePlugIn.lookHorizontalSensitivity -0.021817
aiTemplatePlugIn.lookVerticalSensitivity 0.21817
aiTemplatePlugIn.lookHorizontalSensitivity -0.21817
aiTemplatePlugIn.proportionalConstant -7
aiTemplatePlugIn.derivativeConstant -1
aiTemplatePlugIn.throttleLookAhead 1.0
aiTemplatePlugIn.pitchLookAhead 1.0
aiTemplatePlugIn.rollLookAhead 1.0
aiTemplatePlugIn.yawLookAhead 1.0
aiTemplatePlugIn.lookVerticalLookAhead 1.0
aiTemplatePlugIn.lookHorizontalLookAhead 1.0
aiTemplatePlugIn.throttleScale 1.0
rem *** Angle in radians ***
aiTemplatePlugIn.pitchScale 5.0
aiTemplatePlugIn.rollScale 5.0
aiTemplatePlugIn.yawScale 0.0020
aiTemplatePlugIn.lookVerticalScale 1.0
aiTemplatePlugIn.lookHorizontalScale 1.0
aiTemplatePlugIn.setCameraRelativeDofRotationOffsetDeg 180
aiTemplatePlugIn.setCameraRelativeMinRotationDeg -40/-40/0
aiTemplatePlugIn.setCameraRelativeMaxRotationDeg 40/40/0

rem *** AITemplate ***
aiTemplate.create VodnikPassenger
aiTemplate.addType ITUnit
aiTemplate.addType ITBiological
aiTemplate.addType ITGround
aiTemplate.degeneration 10
aiTemplate.allowedTimeDiff 2
aiTemplate.basicTemp 5
aiTemplate.commonKnowledge 0
aiTemplate.secondary 1
aiTemplate.addPlugIn VodnikPassengerUnit
aiTemplate.addPlugIn VodnikPassengerCtrl
[/codebox]

Will try post a run through of an aircraft AI template later. As i said, im really no expert on AI so hopefully one of the expert AI guys here will correct any errors I have made and maybe define what the lines I havent commented on actually do. Anyway, hope this helps somebody a little with getting started on making AI templates. As others have said though, best way is to copy past an exsisting vehicle similar to yours and look through it to see how it works and how you can change it to suit your own vehicle better.


--------------------
Go to the top of the page
 
+Quote Post
SatNav
post Apr 24 2007, 07:51 PM
Post #15


Cesar
*******

Group: Banned
Posts: 6,918
Joined: 24-June 05
Member No.: 752



all positions including passengers on vehicles must give bots access to a weapon either a vehicle weapon or thier handweapon. without a weapon the game will ctd when the bot sees a enemy and tries to trigger the fire button.for positions like front passenger seats of cars for example you can make a dummy weapon that fires nothing.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 19th September 2017 - 04:25 PM