Forums Index >> Modding >> Making a New AI (tutorial)
Page : <1> :
You don't know how much this has helped me! Thanks I'll try it out! XD
-CUC-
- b20
Tried it and it works perfectly! What do you mean?
//-----------------------------------------
//-----Custom Tanks------------------------
//-----------------------------------------
new TankAIData(CustomAI) // RENAME CustomAI TO WHATEVER YOUR NEW AI WILL BE CALLED
{
homeRange = 1000; // how far from "home" will it wonder
targetRange = 200; // how far away does it have to be before targeting an enemy
disengageRange = 500; // at what distance will it disengage an enemy
aim = 0; // how accurate? Degrees variance from dead-on aim <--Nice, dead-on aim...
aimSpeed = 1; // 0-1, 1=instantanous, 0=never move (0.2 -> 2/3 sec to get 99% there,0.1 -> 2/3 sesc to get 90% there)
triggerHappy = 0; // angle in degrees at which tank will not fire (smaller number, more frugal) <-- Tank will not fire! But I could be wrong, it just won't fire often.
longShotScale = 0; // fire less often at a distance -- scales reload times (bigger = slower)<-- Tank will not fire! But I could be wrong, it just won't fire often.
fleeDamage = 0; // at what damage level (0-1, 0 undamaged) will it turn and flee to re-group <--Always fleeing...
fleeOnTime = 0; // how long to keep fleeing turned on (in ms) <--...for no time at all. That's just weird...
fleeOffTime = 0; // how long to keep fleeing turned off after re-engaging (in ms)
scanDelay = 0; // how long to delay between enemy scans (in ms)
follow = true; // will it follow a target outside "home" area?
SnipeWeight = 0; // selection weight for sniping attacks
ramWeight = 10; // selection weight for ram attacks <-- Will not like to fire. It likes to bump...
flankWeight = 0; // selection weight for flanking attacks
backWeight = 0; // selection weigth for back-track attacks
OcWeight = 10.0; // obsessive-compulsive factor -- larger # means sticks with current target more
revengeWeight = 10.0; // larger # means go after tank that just shot us
};
That should clear it up.
Well Big Show did say you have to EDIT it! Lol :)
- b20
Page : <1> :
Well since CUC requested it, here it is.
// ---------------------------------------------------------------------------------------------
//------------NEW AI TUTORIAL------------------------------------------------------
//----------------------------------------------------------------------------------------------
1. Download the tankDB.cs and tankAI.cs file over by the 'other stuff' section of PTT.
Put those files in the game/server/scripts folder!
2. Open up the tankAI.cs file you just downloaded.
3. Add this at the very end of this file:
//-----------------------------------------
//-----Custom Tanks------------------------
//-----------------------------------------
new TankAIData(CustomAI) // RENAME CustomAI TO WHATEVER YOUR NEW AI WILL BE CALLED
{
homeRange = 1000; // how far from "home" will it wonder
targetRange = 200; // how far away does it have to be before targeting an enemy
disengageRange = 500; // at what distance will it disengage an enemy
aim = 0; // how accurate? Degrees variance from dead-on aim
aimSpeed = 1; // 0-1, 1=instantanous, 0=never move (0.2 -> 2/3 sec to get 99% there,0.1 -> 2/3 sesc to get 90% there)
triggerHappy = 0; // angle in degrees at which tank will not fire (smaller number, more frugal)
longShotScale = 0; // fire less often at a distance -- scales reload times (bigger = slower)
fleeDamage = 0; // at what damage level (0-1, 0 undamaged) will it turn and flee to re-group
fleeOnTime = 0; // how long to keep fleeing turned on (in ms)
fleeOffTime = 0; // how long to keep fleeing turned off after re-engaging (in ms)
scanDelay = 0; // how long to delay between enemy scans (in ms)
follow = true; // will it follow a target outside "home" area?
SnipeWeight = 0; // selection weight for sniping attacks
ramWeight = 10; // selection weight for ram attacks
flankWeight = 0; // selection weight for flanking attacks
backWeight = 0; // selection weigth for back-track attacks
OcWeight = 10.0; // obsessive-compulsive factor -- larger # means sticks with current target more
revengeWeight = 10.0; // larger # means go after tank that just shot us
};
4. EDIT, Save and close that file.
5. Now open up your tankDB.cs file that we downloaded earlier.
6. Add this at the end of that file:
datablock TankData(CustomAITank : LightTank) //REMEMBER TO CHANGE CustomAITank to whatever you want
{
brainShapeFile = "~/data/shapes/tanks/bot03.dts";
ai = CustomAI; //[b] here goes the AI name we talked about earlier
};
Now, see where it says (CustomAITank : LightTank)? You can change 'LightTank' to whatever tank your new AI will "use".
In this instance LightTank can be one of the following:
LightTank
MediumTank
HeavyTank
BabyBoss
BossTank
When done editing, close that file.
7. Start up ThinkTanks and create a server with how many bots you want there to be. Exit thinktanks and go to your prefs.cs file ( located in game/server folder). Find this:
$pref::Server::Bot0 = "CustomAITank";
$pref::Server::Bot1 = "GoldLightTank";
$pref::Server::Bot2 = "GoldLightTank";
$pref::Server::Bot3 = "GoldNoneTank";
$pref::Server::Bot4 = "GoldNoneTank";
$pref::Server::Bot5 = "GoldNoneTank";
Now depending on how many bots you chose, it won't look like it is above.
Then change it so it looks like this:
$pref::Server::Bot0 = "CustomAITank";
$pref::Server::Bot1 = "CustomAITank";
$pref::Server::Bot2 = "CustomAITank";
$pref::Server::Bot3 = "GoldNoneTank";
$pref::Server::Bot4 = "GoldNoneTank";
$pref::Server::Bot5 = "GoldNoneTank";
REMEMBER TO CHANGE CustomAITank TO THE NAME YOU CHOSE EARLIER.
8. Delete your prefs.cs.dso file
9. Start up ThinkTanks and create a server And watch your new AI Tank!
10. Repeat these steps until you have the amount of desired new AI.
Last edited: Wednesday, July 20, 2005 at 7:37:10 AM