Bot AI help

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

jh1

New Member
Jul 21, 2004
38
0
0
Hey guys, I've been unable to find anything really helpful on bots that ISN'T about bot pathing. I need to code bot AI so it recognizes how to use a custom made Vehicle mainly focused on encroaching other players, and how to adhere to my custom game rules. Does anyone know of a good website with examples of bots with different AI coded in? I just need a starting point - :cool:
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
40
New Zealand
www.digitalconfectioners.com
Normally when bots are attached to a normal gametype which is deathmatch in UT2004, they simply run around the level and attempt to kill their targets. When you enter team based gametypes they then use a TeamAI script that governs their actions. Try doing reasearch on how game types such as CTF, Boming Run, Invasion handle their bots as they all have the AI written in this manner.
 

jh1

New Member
Jul 21, 2004
38
0
0
Does anyone know how the maxdesireability on vehicles and pickups interacts with the bots, and what the limits of its value is?
 

jh1

New Member
Jul 21, 2004
38
0
0
One more quick question - Should I implement what I want my bot to do in states? My mod is weaponless, and all damage is dealt through vehicles. So basically, I want my bot whenever it isn't in a vehicle, to run away from any players and find a vehicle.

Should I make a state depicting this if the bot is not in a vehicle? Sorry for all of the questions, This is my first bot programmed, and the bot code is a bit overwhelming :eek:
 

jh1

New Member
Jul 21, 2004
38
0
0
Sorry to keep bumping, but I've been working on this for days, and haven't made any real significant progress. Right now all I'm trying to do is extend xBot.uc using my own controller. I want my AI to:

If not in a vehicle, find one, while avoiding other pawns invehicles. This is top priority

if in vehicle, kill stuff.

As for the process of finding a vehicle, my idea is to modify the findbestpathtoward function to find a vehicle. Here's where im stuck though - it takes an actor, but how can i specify that actor to be any vehicle? Any input at all is appreciated, Thanks a lot
 

Call me Erdrik

Arch Mage
Nov 24, 1999
334
0
0
43
Spring Hill, FL, USA
www.geocities.com
jh1 said:
If not in a vehicle, find one, while avoiding other pawns invehicles. This is top priority
It depends on if the bot has no weapon at all or a dummy weapon that does nothing. I would suggest the dummy weapon as bots generate logs if they have no weapons, and this will slowly build a very large log file, possible lagging the game, among other things.

Also with the dummy weapon it would be a simple matter of setting the
SuggestDefenseStyle(), and SuggestAttackStyle() so that they will try to run away.

As for finding Vehicles, Im pretty sure all you have to do is Increase the BotDesirability of that vehicle. That added to the fact that they don't have weapons to begin with they should naturaly seek out a vehicle ...

jh1 said:
if in vehicle, kill stuff.
I would suggest sifting through the Onslaught Vehicle coding. I have been run over many a times by enemy bots in vehicles so there has to be code in there somewhere that tells them to do it. Find it and modify it so they do it more often.

jh1 said:
As for the process of finding a vehicle, my idea is to modify the findbestpathtoward function to find a vehicle. Here's where im stuck though - it takes an actor, but how can i specify that actor to be any vehicle? Any input at all is appreciated, Thanks a lot
casting. actor = Vehicle(actor)
Vehicle can be replaced with any class beneath actor.
This will set only actors of that class.

I hope this helps! ^_^
 

jh1

New Member
Jul 21, 2004
38
0
0
Thanks, a lot of that really helped, especially the idea for the dummy weapon. As for now my main problem is when the bot is in the vehicle itself - it won't fire. The main fire is a speed boost that's used to run people over- any ideas why they wouldnt be using it?
 

Call me Erdrik

Arch Mage
Nov 24, 1999
334
0
0
43
Spring Hill, FL, USA
www.geocities.com
jh1 said:
Thanks, a lot of that really helped, especially the idea for the dummy weapon. As for now my main problem is when the bot is in the vehicle itself - it won't fire. The main fire is a speed boost that's used to run people over- any ideas why they wouldnt be using it?

That is kinda strange, usually bots are trigger happy with the vehicle weapons...

I can't think of anything...
How is this speed boost implemented?
Its just a DriverWeapon right?
If so Im not sure why the bot wouldn't use it...
Could you post the code for the vehicle weapon?
Also how much code have you done in the bot?
It is possible (tho unlikely) that the stray coding in the bot is interfering...
This kind of problem usualy requires sifting through your code, adding logs, and testing to see where the logs show up or don't show up in the log file...
... err... At least thats what I normaly do. lol :D
 

jh1

New Member
Jul 21, 2004
38
0
0
Here's the function for vehicle fire (It works fine when a human does it, so it works)

Code:
function VehicleFire(bool bWasAltFire)
{
    local KarmaParams KP;
    local int i;
    local vector tempV, tempVInverse, temp2;

    temp2 = vect(0,0,0);
    KP = KarmaParams(KParams);
    // Can only start a jump when in contact with the ground.
    for(i=0; i<KP.Repulsors.Length; i++)
    {
	if( KP.Repulsors[i] != None && KP.Repulsors[i].bRepulsorInContact ){
		bOnGround = true;
	}
    }

    if (!bWasAltFire){
	if (DashWaitTime <=0){
	    tempv = vector(Controller.GetViewRotation());
            tempVInverse = tempV * -1;
            tempV.X*=1000000;
            tempV.Y*=1000000;
            tempV.Z=0;

            rot.pitch=rotator(tempv).pitch;
            rot.yaw=rotator(tempv).yaw;
            rot.pitch+=49332;
            bDashEmitter=true;
            //settotrue();
            PlaySound(BoostSound,,1.0);

	    Kaddimpulse(tempV,temp2);
	    bAttackMode=true;
	    DashCountDown = DashDuration;
	    DashWaitTime = DashDelay;
        }
    }else{
        if(!bOnGround){
            bAttackMode = true;
            smashCountdown = smashDuration;}
    }
    super.VehicleFire(bWasAltFire);
}

The bot code is still rather simple. I'm going on the assumption that to get this basic functionality, I won't need to alter much. I've coded a dummy weapon as you've suggested and fixed botdesireability variables, but that's about it.

Maybe it has to do with how i set the pawn?

Code:
class HB_AIController extends xBot;


function SetPawnClass(string inClass, string inCharacter){

    Super.SetPawnClass("HBPackages.HB_Pawn", inCharacter);
}

The only other thing I can think of is that if the vehicle is bumped, the pawn will enter the vehicle. Maybe this is affecting things?

I'm lost at this point :(

Edit: Does anyone know of any mods that use vehicle based combat in a Deathmatch setting, with bots? This would obviously be REALLY helpful to my case, for reference and such.
 
Last edited:

Call me Erdrik

Arch Mage
Nov 24, 1999
334
0
0
43
Spring Hill, FL, USA
www.geocities.com
jh1 said:
...
Code:
function VehicleFire(bool bWasAltFire)
{
    local KarmaParams KP;
    local int i;
    local vector tempV, tempVInverse, temp2;

    temp2 = vect(0,0,0);
    KP = KarmaParams(KParams);
    // Can only start a jump when in contact with the ground.
    for(i=0; i<KP.Repulsors.Length; i++)
    {
	if( KP.Repulsors[i] != None && KP.Repulsors[i].bRepulsorInContact ){
		bOnGround = true;
	}
    }

    if (!bWasAltFire){
	if (DashWaitTime <=0){
	    tempv = vector(Controller.GetViewRotation());
            tempVInverse = tempV * -1;
            tempV.X*=1000000;
            tempV.Y*=1000000;
            tempV.Z=0;

            rot.pitch=rotator(tempv).pitch;
            rot.yaw=rotator(tempv).yaw;
            rot.pitch+=49332;
            bDashEmitter=true;
            //settotrue();
            PlaySound(BoostSound,,1.0);

	    Kaddimpulse(tempV,temp2);
	    bAttackMode=true;
	    DashCountDown = DashDuration;
	    DashWaitTime = DashDelay;
        }
    }else{
        if(!bOnGround){
            bAttackMode = true;
            smashCountdown = smashDuration;}
    }
    super.VehicleFire(bWasAltFire);
}
...

Vehicle fire is in the vehicle itself... Do you have any DriverWeapons?
Is this Vehicle Subclassed under Onslaught vehicles?
Onslaught vehicles have both Driver and passanger weapon arrays.

... in anycase place a log ( log("Text"$Variable); ) after you variable declarations:
Code:
function VehicleFire(bool bWasAltFire)
{
    local KarmaParams KP;
    local int i;
    local vector tempV, tempVInverse, temp2;

    log("Text"$Variable); 
    temp2 = vect(0,0,0);
and after the impulse as well:
Code:
            bDashEmitter=true;
            //settotrue();
            PlaySound(BoostSound,,1.0);

	    Kaddimpulse(tempV,temp2);
                 log("Text"$Variable); 
	    bAttackMode=true;
Also try to find what calls vehicleFire, I believe Fire, and AltFire. and add another log there. then compile and play test it, allowing your bots to get in and drive around each other a bit. then quit and check the log file to see if the logs showed up, when they showed up, and in what order, or even at all... Also it helps to place a number or letter at the begining of the text of the log to help monitor the logs as they are shown in the log file.

Afterwards post results here ( perferably the log file as an attachment) and if you aren't able to solve it then I'll help more from that point.

;)
 
Last edited:

jh1

New Member
Jul 21, 2004
38
0
0
Thanks, it was the fault of the driver weapon. After looking into that and implementing one, it works. There's still minor bugs to be tweaked here and there (bots still don't seem to immediately run for a vehicle), but I'm getting the general behavior I wanted. Thanks a lot for your help
 

jh1

New Member
Jul 21, 2004
38
0
0
I'm trying to make my bot now able to attack karma objects (this will give you points). Any ideas? Make the karma object seen as an enemy?
 

Call me Erdrik

Arch Mage
Nov 24, 1999
334
0
0
43
Spring Hill, FL, USA
www.geocities.com
jh1 said:
I'm trying to make my bot now able to attack karma objects (this will give you points). Any ideas? Make the karma object seen as an enemy?

lol I've been away from the forum awhile, working on some of my own projects. :D
k, attack a Karma Object... What kinda Karma are we talking about? just the ragdolls or a Kactor part of another vehicle? Do you want it to dake damage and get destroyed, or do you just want the bot to attack it for the effect of knocking it around?

In any case off the top of my head I would create an invisable, pawn(maybe with a dummy controler) at the location of the desired Karma Actor. This pawn would need to have No collision, and would basicly act as a lure for the bot to shoot at it, and Karma. After spawning you would need to set the appropriate variables setting to make the bot change his enemy to the new dummy Pawn... Although this has a disadvantage in the fact that it will cuase the dummy pawn to appear on the scoreboard.

Or Maybe you can spawn a shootpoint actor (I believe it is beneath NavigationPoint) instead. The reason I didn't suggest it first is Im not sure if adding it dynamicly will cuase problems. But I believe that if you properly set the bot to target it then return to normal after it should be fine.

hope this helps ^_^