About bot favorite weapons

Discussions about Coding and Scripting
BloodyBastard
Novice
Posts: 9
Joined: Wed Apr 24, 2019 7:19 am

About bot favorite weapons

Post by BloodyBastard »

Hello everyone! Hope you are all right, if you're not, well, suck it up, champ, you will get better. Be strong. Those who have been afflicted with coronavirus while suffering from another illness and yet made a full recovery, congratulations, you're badass and i want your kids... Well I came here with a question...

I've made a weapons mod (well not made, but edited the Covert Forces one and added more weapons (maybe 15 i think)) and I would like a bot to prefer a MP5 for example, instead of a M60. Is it possible? I mean setting up a bot's favorite weapon using the weapons from mods? Sorry if I didn't get the question right, english is not my native language.


TL;DR It's possible to setup a bot's favorite weapon using the ones in mods? (ex: A Covert Forces' MP5 or a CS's AK47?)

Any help would be greatly appreciated.

Stay safe, Stay alive
User avatar
EvilGrins
Godlike
Posts: 9064
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA

Re: About bot favorite weapons

Post by EvilGrins »

If you can establish the part of the .ini file that lists the specific bot you want, you can manually edit what their fave weapon is.

Just a little cut & paste.

I use, as you can see in my signature, a lot of skinned Sktroopers. For their weapon of choice, I set them all up with the Dispersion Pistol... which cannot be selected in standard bot setups.
You do not have the required permissions to view the files attached to this post.
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758
BloodyBastard
Novice
Posts: 9
Joined: Wed Apr 24, 2019 7:19 am

Re: About bot favorite weapons

Post by BloodyBastard »

thank you for your reply EvilGrins, I thought this was not possible by editing the ini, but well I only tried once... I tried again, and sometimes does work and sometimes doesn't. Bot 1 prefers to use a F2000, but I've seen it a lot with the M60.

Does the 'AI Rating' parameter in the weapon files affects a bot's favorite weapon setup somehow? I think so, but I'm not completely sure.
User avatar
sektor2111
Godlike
Posts: 6134
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: About bot favorite weapons

Post by sektor2111 »

Weapon has a word in Bot's behavior. Favorite weapon increases rating until a point. If another weapon from Inventory chain does look stronger because of certain tactical situation, definitely Bot will use the most suitable one according to AIRating code. RocketLauncher is not suitable as alternate fire in a lift, Kira will take that in account even if she is loving that weapon - she is not interested in a suicidal attitude if situation is not requesting this habit.
BloodyBastard
Novice
Posts: 9
Joined: Wed Apr 24, 2019 7:19 am

Re: About bot favorite weapons

Post by BloodyBastard »

Thanks for the detailed reply sektor2111! This is an interesting thing to me, maybe I should see more about the AIRating in the game's .uc files. I'm sure I saw something about it that involves equations that determinates a bot's weapon choice. Maybe coding a weapon for UT goes farther than just adjusting the AI Rating for a weapon.

Rating values for the vanilla weapons are as follows:

Redeemer= 1.0
Rocket Launcher= 0.75
Flak Cannon= 0.75
Minigun= 0.73
Pulse Gun= 0.7
Shock Rifle= 0.63
BioRifle= 0.6
Sniper Rifle= 0.54
Ripper= 0.5

Meanwhile the ratings from some of my weapons are:

Light Machine Guns (ex M60)= 0.7
Assault Rifles (ex AK47)= 0.6
Marksman Rifles (ex Dragunov)= 0.60
Sniper Rifle Barrett= 0.65
SubMachine Guns (ex MP5)= 0.5
Shotgun= 0.6
Pistols= 0.25

Maybe I should adjust their values closer to each other? Maybe that's why a bot that is setup to prefer a MP5, prefers to hold an AK47 instead? I think I let myself go, but I hope the information serves you if you're trying to make some weapons... I guess.
User avatar
sektor2111
Godlike
Posts: 6134
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: About bot favorite weapons

Post by sektor2111 »

Weapon's rating might be different in combat because of functions involved - see UT_Eightball

Code: Select all

function float RateSelf( out int bUseAltMode )
{
	local float EnemyDist, Rating;
	local bool bRetreating;
	local vector EnemyDir;
	local Pawn P;

	// don't recommend self if out of ammo
	if ( AmmoType.AmmoAmount <=0 )
		return -2;

	// by default use regular mode (rockets)
	bUseAltMode = 0;
	P = Pawn(Owner);
	if ( P.Enemy == None )
		return AIRating;

	// if standing on a lift, make sure not about to go around a corner and lose sight of target
	// (don't want to blow up a rocket in bot's face)
	if ( (P.Base != None) && (P.Base.Velocity != vect(0,0,0))
		&& !P.CheckFutureSight(0.1) )
		return 0.1;

	EnemyDir = P.Enemy.Location - Owner.Location; 
	EnemyDist = VSize(EnemyDir);
	Rating = AIRating;

	// don't pick rocket launcher is enemy is too close
	if ( EnemyDist < 360 )
	{
		if ( P.Weapon == self )
		{
			// don't switch away from rocket launcher unless really bad tactical situation
			if ( (EnemyDist > 230) || ((P.Health < 50) && (P.Health < P.Enemy.Health - 30)) )
				return Rating;
		}
		return 0.05 + EnemyDist * 0.001;
	}

	// increase rating for situations for which rocket launcher is well suited
	if ( P.Enemy.IsA('StationaryPawn') )
		Rating += 0.4;

	// rockets are good if higher than target, bad if lower than target
	if ( Owner.Location.Z > P.Enemy.Location.Z + 120 )
		Rating += 0.25;
	else if ( P.Enemy.Location.Z > Owner.Location.Z + 160 )
		Rating -= 0.35;
	else if ( P.Enemy.Location.Z > Owner.Location.Z + 80 )
		Rating -= 0.05;

	// decide if should use alternate fire (grenades) instead
	if ( (Owner.Physics == PHYS_Falling) || Owner.Region.Zone.bWaterZone )
		bUseAltMode = 0;
	else if ( EnemyDist < -1.5 * EnemyDir.Z )
		bUseAltMode = int( FRand() < 0.5 );
	else
	{
		// grenades are good covering fire when retreating
		bRetreating = ( ((EnemyDir/EnemyDist) Dot Owner.Velocity) < -0.7 );
		bUseAltMode = 0;
		if ( bRetreating && (EnemyDist < 800) && (FRand() < 0.4) )
			bUseAltMode = 1;
	}
	return Rating;
}
Rating is calculated at certain combat moment. Here some weapons are poorly coded - even in this one for me code it's not ready...
Must check for ammo before counting ammo and definitely bUseAltMode should not be accepted in any way out of ammo, etc.