Tribes 2 Bots
« Lagg's AI Tutorial »

Welcome Guest. Please Login or Register.
Aug 16th, 2017, 4:33pm



« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 sticky  Author  Topic: Lagg's AI Tutorial  (Read 1178 times)
Roberto
Bioderm
Administrator
ImageImageImageImageImage


member is offline

Avatar

Owrwrwrwrwr....


PM

Gender: Male
Posts: 265
xx Lagg's AI Tutorial
« Thread started on: Dec 19th, 2010, 4:52pm »

http://www.mediafire.com/?8bcf1ezvhs48isf

THIS TUTORIAL IS NOT FINISHED YET ! I AM STILL WORKING ON IT !

Questions or comments to: JPerricone@nyc.rr.com (Lagg-Alot)
_______________________________________________________________________________________________

Adding and Editing Lagg's Advanced Bots for Tribes 2 6-14-2004
_______________________________________________________________________________________________

This is not a Tribes 2 Mapping Tutorial, even though I may give some Map editing techniques.

I assume that you already know how to make/edit Maps for Tribes 2, if not there is a host of
mapping Tutorials out there.

Before I get into how you implement Lagg's Advanced Bot Support, lets go over the basics on
adding and editing the Basic Bots for a Mission.


1) Adding Basic AI Support to a Mission:
-----------------------------------------------------------------------------------------------

I was told that the editor can save a mission into a .vl2 file. This is not true at least on
my computer. So unzipping the .vl2 if your mission is in .vl2 format can be helpful (use Winzip
or similar program to unzip a .vl2 file WWW.WINZIP.COM it is free even though they ask you to pay
The evaluation program is free and works just fine forever). At this time go to the mission file
in the missions folder (in your Operating System, not in the game) and right click on it and view
it's properties. (Note; Make sure the box that say's READ ONLY is not checked !). If it is simply
uncheck it and hit APPLY then hit OK. other wise you can hit "save mission" in the game till the
cows come home and the editor will not over write a file that is marked Read Only by the Operating
System.

a) Building Basic AI Objectives
--------------------------------
To make a map Bot enabled, it helps if you are finished placing all the items (turrets,
generators, trees, inventories, flags/flipflops etc.). The next thing to do is SAVE the mission.
Then open the AI Editor and BUILD OBJECTIVES, then after you have built the objectives. "YOU MUST
SAVE THE MISSION AGAIN!". If you find that the "save mission option" is not available at this time
(always has been the case for as long as I can remember). You have to play tag with the editor and
click on something in the game (like one of the AIObjectives) and then click "APPLY". The editor
will now think that you have changed something in the mission and the "Save Mission Option" will
now be available. Now you can and must SAVE MISSION. Now go back to the AI Editor and Build the NAV
Graph (Note; sometimes this can take a while, no your computer has not crashed). When finished the
next step is to Build the LOS Graph (Note; DO NOT SAVE MISSION IN BETWEEN THE NAV AND LOS GRAPHS).
When the LOS Graph is finished then SAVE THE MISSION. You have to exit completely out of Tribes 2
and restart for the Bots to work in that mission. Don't try to "Build All Objectives" if you already
have AI Objectives in the Mission already (you must remove them first, see below).

b) Removing AI Objectives
--------------------------------
To remove all AI form a map:
First make sure you have nothing selected in the editor (some object, item or simgroup highlighted
blue in the Inspector Window). At the top of the Editor select "Window" then "AI Editor", the
Inspector Window on the right will change to the AIObjectives Simroup (team 1 by default or the last
team you had selected if you opened the AI Editor prior in this session).
Simply "left Click" on the Simgroup to select the whole thing and press the "Delete Key" on your
keyboard. Go back the the Top and select AI and switch to "edit for team 2" and repeat the process.
But we are not done Removing all the AI from the Mission yet. Press "f3" or select "Window then
Editor/Inspector" at the top and open up the "Teams Simgroup". Now Open "Team1 and find the
AIObjectives simgroup" select the whole simgroup and hit delete. Repeat process for "Team2" and
for "Team0" if applicable. Save the mission and you are finished Removing all AI from a map.

Some map editing guidelines:
--------------------------------

Set the Mission Type to "None" in your Mission File (example: // MissionTypes = CTF DnD None;).
Mission Type MUST equal "None" if you are making a Seige Map else you will have the worlds
stupidest Bots when Siege game does the random team selection at Mission start time (half the
times they will work fine and half the times they will stand there and do nothing). After you
are finished adding and editing AI to the Mission you can change the Mission Type to "Siege"
and play normally. It is best to host a LAN, GameType = "None", BotsEnabled = "0" if you are going
to be working in the Editor.

Everytime before you "Save Mission" open the Consol (by pressing the "~" key and type the following
line and then hit "Enter":

stripFields();

This strips a host of extra Dynamic Fields that are not needed in a Saved Mission File (it keeps
your mission file nice and neat). Then you may "Save Mission".

----------------------------------------------------------------------------------------------------
----------------------------------- NAV, LOS and Spawn Graphs --------------------------------------
----------------------------------------------------------------------------------------------------

The NAV Graph (stands for Navigational Graph) and LOS (stands for Line of Sight) are more important
to the Bots than the Spawn Graph. If there is no Spawn Graph all players and Bots will spawn in the
sky at the middle of the Terrain. But bots will function after they hit the ground. If there is no
NAV Graph the Bots will just stand in the spot they started and stay there all day.
You may already know the basics on how to add AIObjectives and Build the NAV (Navigation) and
LOS (Line Of Sight) Graphs. Lets cover a few facts about the Nav. When the Game Engine draws
the NAV or Spawn graph it first searches for Inventory Stations and places one Node (Green
Dot) on each Inventory (My Advanced code will also search for Vehicle Stations and place a
Node on each). The Game will then search for Vehicle Pads and Create a "Static Nome" (a series
of Nodes on the Vehicle Pad Static Shape). Then it will create the Interior Nodes and Paths and
than the Terrain Graph and Paths. After all the Nodes are placed on the Interiors, Stations and
Terrain the Game does the long drawn out process of connecting all the Nodes with paths and
Bridges (Green,Yellow, Blue and Brown Lines). The Yellow Lines are the Bridges that the Bots
will use their Jets to move on. The Bots will rarely try to walk when following a Yellow Bridge
(keep this in mind). The Brown Paths are the Hint Paths that the Bot will walk on and they
rarely use their Jets (unless stuck) to move on the Brown Paths.
The Green Lines are the Main Paths that the Bot will Walk on and are the most reliable Paths
that they will follow when navigating on or inside an Interior. The Blue Paths and Blue Nodes
are used for Terrain (Somewhat reliable, Bots will get Stuck if they try to walk on a Blue Path
that is to steep on a hill) If you have a steep hill and the Bots constantly get stuck there,
you may have to edit the map (place a big Rock there or change location of the bases and/or
Inventory Stations). Keep in mind that Bots 1) Spawn, 2) Buy Inventory, 3) Move in a straight
line to their Target.

Remove all Force Fields and their Physical Zones (or don't place Force Fields til after the Graphs
are drawn). Force Fields are problems as well as Water, Lava, Quicksand (custom water types).

Lava and Water is a big pain for the Mapper that wants to use Bots. By nature the Bots will
try to walk around or fly over Lava/Water. If the distance to fly over is to far and they can't walk
around they will walk through Water. But remember this, the Bots will Never for any reason try
to use their Jets to Fly up if they are standing in water (even if just a foot deep). So never place
an Interior over or in Water or Lava (see #4 below).

Some people brag that they use the Windows Cmd Line to build their Spawn and/or Nav graphs.
This is just fine for some but will prove fruitless for Advanced AI. There are a number benifits
by Drawing the Graphs using the Editor:

1) You get to see all the Nodes, paths, brigdes and Hint lines. And should inspect them all to be
sure that they are being placed properly (some Interriors, StaticObjects (trees and crates) will
not be recognized by the game and cause problems for the NAV Graph. Re-edit the Map and draw Graphs
again.

2) The NAV and LOS are saved together in one file, but you can alter the map to block the
NAV or the LOS seperately by using an Interior Object to block a certain path (build the NAV) then
delete the Interior Object and draw the LOS. That way the Bot will never try to walk there but will
Shoot through that area if they see an enemy.
« Last Edit: Mar 23rd, 2012, 03:30am by MetaDrax » User IP Logged

This site (short link):
www.tribes2bots.tk
Long link :
http://t2bots.conforums.com/
Roberto
Bioderm
Administrator
ImageImageImageImageImage


member is offline

Avatar

Owrwrwrwrwr....


PM

Gender: Male
Posts: 265
xx Re: Lagg's AI Tutorial
« Reply #1 on: Dec 19th, 2010, 4:53pm »

3b) When I say "Field" I am talking about a "Dynamic Field". (Example of a DynamicField:

description = "Destroy the StationInventory";
mode = "inBaseAtt";

are "DynamicFields". You can add more DynamicFields to anything in the Tribes 2 editor, but the Game Scripts
may have to be modified to do something else with the new Field. I will only discuss the Fields that are relevant
for the use of my Bots.

4b) When I say "Objective dataBlock". I am talking about the AIObjective that is in the Mission File, you
can edit any "Objective dataBlock" using the AI Editor.


Example of AIOObjective dataBlock:

new AIObjective(AIODestroyObject) { //------------------- AIOObjective "Name"
position = "-601.4 419.8 112.566"; //------------ Position of the Marker
rotation = "1 0 0 0"; //------------------------- Rotation of the Marker (used when placing AIODeployObject Objectives)
scale = "1 1 1"; //------------------------------ Size of the Marker (resizing markers have no effect on Ai Objectives)
dataBlock = "AIObjectiveMarker"; //-------------- dataBlock Name
lockCount = "0"; //------------------------------ lockCount (could be used by scripters)
homingCount = "0"; //---------------------------- homingCount (could be used by scripters)
description = "Destroy the StationInventory"; //- task Description
mode = "inBaseAtt"; //--------------------------- task Mode
targetObject = "ObjectiveInventory1"; //--------- name of the Target Object
targetClientId = "-1"; //------------------------ id Number of Target Client (if target is a client)
targetObjectId = "4352"; //---------------------- id Number of Target Object (if target is an object)
location = "-607.8 412 112.566"; //-------------- Location of the Target Object (used for repair, attack, destroy objectives)
weightLevel1 = "3200"; // ----------------------- (Weights are used to consider task being choosen by game to
weightLevel2 = "1500"; // ----------------------- assign clients, and also the base weight to complete task.
weightLevel3 = "0"; // -------------------------- Weights are very delicate and should be changed with
weightLevel4 = "0"; // -------------------------- care. See AIDefualtTasks below for more on Weights)
offense = "1"; // ------------------------------- Offense Tag used to help weights in some cases
defense = "0"; // ------------------------------- Defense Tag used to help weights in some cases
equipment = ""; // ------------------------------ Equipment that Must Be Bought (limits clients to only)
desiredEquipment = "Plasma PlasmaAmmo"; // ------ Equipment that could be Bought (client that has more of this gets +weight)
buyEquipmentSet = "randomSet"; // --------------- $AIEquipmentSet to Buy if Inventory is availible (list below)
chat = "ChatCmdAttack"; // ---------------------- Chat message bot will say about 7 seconds after he starts task (list below)
issuedByHuman = "0"; // ------------------------- Did a Human Player ask for this (from command map or verbal)
issuedByClientId = "-1"; // --------------------- Did a Bot ask for this (a bot can ask for this through scripts in some cases)
forceClientId = "-1"; // ------------------------ Force this at a higher weight (if asked by human)
locked = "1"; // -------------------------------- Locked in Editor (but has no effect)
};

Definition of AIObjectives: (Not Finished)
------------------------------------------------------------------------------------------------------
AIOAttackObject: You must move the Objective Marker for this to the spot you want the Bot to Stand
and shoot at the Target. Place the marker about one meter above the floor or ground
in the best spot you as a player would stand if you were destroying the target. Bot
will shoot at the Target if he has sight to do so but will continue moving to the
Marker location. Bot will NOT SHOOT at the target if he is to close to the
target and would damage himself if he fired his weapon. This Objective has a Max
Range of 40 and a Min range of 4 to the Target Object. By default the "desired
Equipment" field is set to "Plasma PlasmaAmmo" and "buyEquipmentSet" is set
"randomSet" which means that any Bot that has Plasma and PlasmaAmmo can do the task
and will buy a random set if Plasma PlasmaAmmo is needed. You may set the "Equipment"
field and the "buyEquipmentSet" field if you want but I it works very well with
the default settings. This AIObjective is used for Generators.
NOTE: make sure the $AIEquipmentSet that you set in ObjectivedataBlock contains the
"equipment" or the "desiredEquipment" that is required to destroy the target. Mortar,
Plasma and Blaster are the ONLY weapons bot will use for this objectiveTask.
Check with the $AIEquipmentSet lists below to confirm).
This one has been completely overhauled so bot will continue going for the target
even if he has been attacked. Bot will defend himself but the target is his priority.
Bot's first choice weapon to destroy the target is the Mortar (if safe range not to
damage himself), then Disk, Plasma and Blaster.


AIODestroyObject: You should move the Objective Marker for this to the spot you want the Bot to Stand
and shoot at the Target. Place the marker about one meter above the floor or ground
in the best spot you as a player would stand if you were destroying the target. He
will shoot at the Target if he has sight to do so but will continue moving to the
Marker location. Bot will NOT SHOOT at the target if he is to close to the
target and would damage himself if he fired his weapon. This Objective has a Max
Range of 40 and a Min range of 4 to the Target Object. By default the "desired
Equipment" field is set to "Plasma PlasmaAmmo" and "buyEquipmentSet" is set
"randomSet" which means that any Bot that has Plasma and PlasmaAmmo can do the task
and will buy a random set if Plasma PlasmaAmmo is needed. You may set the "Equipment"
field and the "buyEquipmentSet" field if you want but I it works very well with
the default settings. This AIObjective is used for InventoryStations, SolarPanels,
SentryTurrets, VehicleStations, Teleporters and could be used for Generators,
BaseTurrets and Sensors if you wanted. (NOTE: make sure the $AIEquipmentSet that you
are telling him to buy has the "equipment" or the "desiredEquipment" that is required
to destroy the target. Mortar, Plasma and Blaster are the ONLY weapons bot will use
for this objective. Check with the $AIEquipmentSet lists below to confirm).

AIOMissileObject: This Objective does the following; If bot needs equipment (MissileLauncher, Missile
LauncherAmmo) he will go buy the "buyEquipmentSet" and the move not to the Target
Object but to a Position that has LOS to the AIOMarker for this Objective. The reason
for this is that sometimes a Sensor or Turret is placed high up above the Terrain on
top of some type of Interior. And the Bot will not get a Missile Lock because his sight
to the Target will be blocked by the Interior. So you can trick the Bot into moving to
a better spot to fire Missiles by moving the AIObjectiveMarker down by 0.5 to 1.0 meters.
This will force Bot to move to a higher altitude spot to get sight to the Objective
marker and then aims at the target Object and fire his Missiles. I put a timer on this
so Bot will jump around a little and reset his position every 20 seconds just in case
he looses his missile lock. He usually gets this job done.

AIOMortarObject: I almost completely rewritten this one so Bots no longer mortar hillsides. The Bot
will move to LOS (Line Of Sight) location and fire the Mortar. Bot no longer is a
sitting duck as he moves around while firing mortars at Target. The Bot assigned to this
task will ask for someone to Laze the target for him and waits for about 20 seconds for
a Targetter. If no one lazes the target for him he will start shooting on his own.

« Last Edit: Dec 31st, 2011, 04:39am by MetaDrax » User IP Logged

This site (short link):
www.tribes2bots.tk
Long link :
http://t2bots.conforums.com/
Roberto
Bioderm
Administrator
ImageImageImageImageImage


member is offline

Avatar

Owrwrwrwrwr....


PM

Gender: Male
Posts: 265
xx Re: Lagg's AI Tutorial
« Reply #2 on: Dec 19th, 2010, 4:54pm »

AIOTouchObject: This Objective is used for Flags and FlipFlops. I have made the following changes to
touch a FlipFlop if in Siege game; If there is a Force Field within 12 meters of the
FlipFlop the bot will ignore this task (Siege game usually has a force field shielding the
objective FlipFlop).
If CTF game the bot assigned to this task will create a few more AI Objectives depending
on if he is Grabbing the flag, Carrying the flag or Picking up a dropped flag.
If carrying Flag Bot will ask for some bots to AIOEscortPlayer (protect/follow him).
If going in for the Grab Bot asks for AIOMortarLocation (some Bot with Mortar to clear the
flag area).
If picking up a dropped Flag he Just goes for it.

AIODefendLocation: You can move the Objective marker to the area that you want him to defend (say a room away
from a generator) as he will move to the "position" of the objective marker and patrol
a little.
Modified so if set to "offense = 1" in the objectives dataBlock the bot will defend a
destroyed enemy object (can you say Camping in enemy Base ?). Must be placed in the offense
teams objective simgroup and DO NOT set "dynamicField defense = 1" and a bot will defend
the destroyed enemy gen so defenders have a hard time trying to repair. For defense:
DO NOT set "offense = 1" in objective dataBlock, for Camping offense must not have
"defense = 1" in the objective dataBlock
If we are a defending with sniper gear (SniperRifle and EnergyPack) than he fights like
a sniper (far shots with laserrifle).

When you Build AI Objectives this will place one AIODefendLocation in the team that
owns the object (Defense) "AIObjective Simgroup" with the "DynamicField" for
"defense = 1" and the "DynamicField" for "offense = 0" (that means it is a team owned
Object and will only be defended if it is not badly damaged or destroyed) for each of the
following Objects:

Generator, Solar Panel, Flag, Flipflop

It will also place one AIODefendLocation in the team that does not owns the object (Offense)
"AIObjective Simgroup" with the "DynamicField" for "defense = 0" and the
"DynamicField" for "offense = 1" (that means it is an enemy team owned Object and will only be
defended if it is destroyed) for each of the following Objects:

Generator, Solar Panel

(just remember for defending team; offense = 0; defense = 1 / for offensive team; offense = 1
defense = 0;)

NOTE: Never set the "equipment" dynamic field to anything for AIODefendLocation, leave it blank.
Instead you set the "desiredEquipment" field to the weapon and ammo that you wish him to defend
with.

Example:

weightLevel1 = "3100";
weightLevel2 = "1000";
weightLevel3 = "0";
weightLevel4 = "0";
offense = "0";
defense = "1";
equipment = "";
desiredEquipment = "Plasma PlasmaAmmo";
buyEquipmentSet = "HeavyShieldSet";

This is because setting the "equipment" field to anything limits the bot to have this equipment
to do the task (Objective Task). If the Base Inventories have all been destroyed and Bots cannot
buy inventory you may see the Flag not getting defended at all. The "desiredEquipment" means that
if we have the desiredEquipment great, but if we don't have it still do the task. You will see bots
that just spawned and can't get inventory defending a flag.
« Last Edit: Dec 31st, 2011, 04:39am by MetaDrax » User IP Logged

This site (short link):
www.tribes2bots.tk
Long link :
http://t2bots.conforums.com/
Roberto
Bioderm
Administrator
ImageImageImageImageImage


member is offline

Avatar

Owrwrwrwrwr....


PM

Gender: Male
Posts: 265
xx Re: Lagg's AI Tutorial
« Reply #3 on: Dec 19th, 2010, 4:54pm »

----------------------------------------------------------------------------------------------------------------------
AIDefault Tasks: (Not Finished)
----------------------------------------------------------------------------------------------------------------------
Above we learned a lot about AIObjective Tasks and how to use them. Lets talk about AIDefaultTasks (by DefaultTasks
I am not talking about the original Bot Objective tasks that came with the Game). I am talking about the tasks (jobs)
that the Bots do all the time reguardless of what Objective Task they are assigned to. You as the Mapper will have little
control over the aiDefaultTasks (unless you get into scripting), but it is helpful to understand what is going on in the Bots
mind (Bots don't have brains). The aidefualtTasks are usually higher priority than Objective tasks and therefore more
important. Before we can understand everything about the Bots we need to talk about:

Weights:
---------------------------------------------

I would have liked to make Weights a seperate catagory, but it is so embedded into the Defualt Tasks that we should
cover it now. Every task that the Bots do (ObjectiveTasks and DefaultTasks) are all based on weight values. You have
seen above in the Objective dataBlocks weight values for the objective task. That is just the tip of the iceberg. The
PC is a number comparing machine and that is exactly how the bots know if they should shoot at you or pick up the dropped
flag. The weight value for a bot to shoot back at you if you damaged him is 4600. But if the Bot is badly damaged and he
happens to have a Corpse (dead player) next to him, and that corpse forgot to use his RepairKit the bot should step to
Corpse at weight 4650. This all happens very suddely and he picks up the RepairKit and uses it without really missing a
beat while he is still fighing you. Because the two weights are so close in comparision that the Game balances the two
Tasks (aiEngagetask and aiPickUpItemTask) switching the Bot from one task to the other a few times a second. Then
switches the Bot back to his Objective task when the fights over (unless he is dead). My point here is the Bots are very
sensitive to weight value changes in their Objective Tasks. The weights are also used to set speeds by the Game Engine
on how often the the task is run through the Processor (PC's brain). A lower value equals less processes. So if you
start changing weights in the AI Editor keep in mind that the Bot has 8 DefualtTasks (in CTF) plus his ObjectiveTask,
thats 9 tasks the game has to balance for each Bot in the Game. The game also runs a schedule every 5 seconds for
every bot to "AIReassessObjective" (a program loop that checks the objective weight of the bot's objective task to
see if another bot is closer to that task, has the equipment required. Then checks the weight of the second Bots
Objective task and if he should "Bump the first Bot off his Objective Task or not). Bots that have the required
equipment and are closer to the objective get their weight value raised for future comparisions. For 16 Bots in a Game
that is a lot of number crunching and it is running constantly.
Go easy on changing weight values if you have to change them at all. I have made a few adjustments in the Objective
weights and in the aiDefualtTask weights to get the Bots to work at peak performance. If you say want to raise the
Objective weight to destroy a gen or repair a particular Inventory. Try raising or lowering the weight in increments
of 50 and test it for a while, you can fine tune it later by increments of 10 to get the bots acting just the way you
want.

-------------------------------------------------------------------------------------------------------------------
AIEngageTask:

This defaultTask has the dirty responsibility of combat fighting with other Players and Bots. It is the most
most important task the bots have, without it there really would be no use of bots at all (except maybe to carry
Golf clubs). This task can have 4 possible weight values depending on circumstances:

$AIWeightReturnFire = 4600; // defend himself if damaged
$AIWeightFoundToughEnemy = 3000; // Shoot at an enemy if we see him
$AIWeightFoundEnemy = 1000; // If the enemy is superior we are cautious
or we have no enemy = 0; // 0 = don't fight anyone, do some other task

-------------------------------------------------------------------------------------------------------------------
AIPickupItemTask:

This tasks first checks if bot is damaged and needs a health item. If not it them checks if bot could use some
ammo or a weapon that may be on the ground. If this taks determines that bot could use something and the item is
availible (on ground) it uses 4 possible weight values depending on circumstances:

$AIWeightNeedItemBadly = 4650; // life depends on the item
$AIWeightNeedItem = 4350; // we need that item
$AIWeightFoundItem = 2500; // the item is there
we don't need item = 0; // we have no needs



----------------------------------------------------------------------------------------------------------------------
list of BuyEquipmentSet and contents: (not Even Started)
----------------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------------
list of chats: (I'll Get To It)
----------------------------------------------------------------------------------------------------------------------

This is taken right out of "cannedChatItems.cs" file. Placing the Chat in the "Chat Field" of the "ObjectivedataBlock"
will have the Bot say this chat about 7 seconds after getting assigned to the ObjectiveTask in question. When you type in
the Chat and click "Apply" in the Inspector Window, you will know right away if you misspelled because it will jump to
non-capitalized lietters. If the format jumps to or stays the way it is written here than all should be fine.


« Last Edit: Dec 31st, 2011, 04:39am by MetaDrax » User IP Logged

This site (short link):
www.tribes2bots.tk
Long link :
http://t2bots.conforums.com/
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls