Pathing and weight/priority, so many questions

Tutorials and discussions about Mapping - Introduce your own ones!
User avatar
fudgonaut
Adept
Posts: 274
Joined: Sat Oct 05, 2013 7:20 am
Personal rank: Easy Target
Location: "The Butthole of the World"

Pathing and weight/priority, so many questions

Post by fudgonaut » Thu Nov 18, 2021 4:50 pm

After my first CTF map I swore I would never make another one. But then I went and made another one.

Now I'm thinking of making another one. My biggest obstacle and source of frustration is bot pathing, and how to get bots to move in interesting ways.

SmartAlternatePaths
When I was making my map for the NRMC I tried using SmartAlternatePaths but they did not seem to work.

I assume that is because they work differently from AlternatePaths.
  • Is there any documentation on how to use SmartAlternatePaths? I could not find any clear information.
  • Can someone who uses them explain them to me, in a way that is easily understandable?
  • From what I can tell the author of SmartAlternatePaths is somebody who went by the name Bot40 at beyondunreal, back in the day. Is he still around?

Weight/Priority/MaxDesireability
I still don't have a clear understanding of SelectionWeight when it comes AlternatePaths, Priority when it comes to DefensePoints, or MaxDesireability when it comes to weapons & pickups

What is the appropriate number range for these values? From 0.0 to 1.0? From 0 to 10? From 0 to 100?
Without any context of how the values are tabulated/calculated, any numbers I use are guess work. This trial-and-error method extremely time consuming, and my main discouragment from making more maps.


Sniping

I can never seem to get my bots to snipe
My understanding of how it works:
sniping.jpg
Place an AmbushPoint where you want your bot to snipe from
  • Set AmbushPoint > bSniping to true
  • Set AmbushPoint > SightRadius to the appropriate distance
  • For CTF go to AmbushPoint > DefensePoint > Team and set the correct Team number
Now place a DistanceViewTrigger next to the AmbushPoint
  • Make sure the AmbushPoint is within the collision radius of the DistanceViewTrigger
  • Give the DistanceViewTrigger a Tag (like "snipeThoseBlueGuys")
Now place a trigger in the area where you want the bot to shoot at
  • In CTF use a TeamTrigger (counter-intuitively, set TeamTrigger > Team to the team that you DON'T want it to detect. In other words, set it to the same team number as your sniper)
  • Give the trigger an appropriate collision radius
  • Make sure the TeamTrigger > Event matches the DistanceViewTrigger tag ("snipeThoseBlueGuys") - you should see a line connecting the two actors
Now when a Blue player hits the TeamTrigger, a Red player at the ambush point will start sniping htem. This is how I have set it up and I've never seen it work in my two maps

How do I get bots to pick up the sniper rifle?

Does the rifle have to be at the ambush point?
I've put the sniper rifle nearby (~512uu) and cranked up the MaxDesireability. When I view paths, the AmbushPoint and Sniper Rifle are connected. But bots will pass the rifle without picking it up.


Thanks in advance for any/all information - or links to resources that have this information.
You do not have the required permissions to view the files attached to this post.

User avatar
Aspide
Experienced
Posts: 109
Joined: Wed Jun 09, 2021 12:13 am

Re: Pathing and weight/priority, so many questions

Post by Aspide » Thu Nov 18, 2021 8:17 pm

Ah yes AlternatePaths, it took me so many tries to understand how they work:

-Put an AlternatePath in a path where the alternate route begins (this will require some playtesting to get the AlternatePath in the right spot)
-The Team variable doesn't refer to the team that owns the AlternatePath, but rather the base that you are attacking:
For example AlternatePaths with Team=0 will be used by bots that want to go to the red base (blue attackers or red members with the blue flag)
-SelectionWeight is the probability that this AlternatePath will be used compared to others (higher the number, higher the chances that the bot will use it). This number can go from 0-Infinity.
-bReturnOnly determines if the AlternatePath will be used by bots who have the enemy flag only or not. However this variable doesn't work that well because sometimes bots still use it if they don't have the flag.
-The SmartAlternatePath actor allows for more randomization by changing the SelectionWeigh of the other AlternatePaths when touched.

Now for DefensePoints:

-The Team variable refers to the team that owns the actor.
-Priority refers to the order the Bots will position themselves, this number can go to 0-255. I usually never change this variable.
-FortTag is for Assault only, put the tag of the objective (FortStandard) to connect them, bots will use that DefensePoint to defend the specific FortStandard.

MaxDesireability affects how much the bots want this item, this number can go from 0-Infinity BUT IF YOU CHANGE IT HIGHER THAN 10 THE BOTS WILL BECOME OBSESED WITH THIS ITEM, I don't recommend changing this variable, if you want bots to get a certain item I recommend using the BotBonus actor from Unreal Tournament Classic Pack ]I[.

And finally how to make the bots snipe:

-Put a DefensePoint where you want the bots to snipe from
-Put bSniping to True, and SightRadius to a high number like 20000.000000, don't forget to set the Team variable.
-Locate a DistanceViewTrigger near the DefensePoint and make sure it's collision radius is big enough to envelop the DefensePoint/s.
-Put a Trigger in the place where the bot will focus his/her attention when sniping (again change the collision radius of the trigger so the bot focuses on a huge area)
-The event of the Trigger has to be the same as the tag of the DistanceViewTrigger.

The logic is that the DistanceViewTrigger when triggered, triggers all pawns within its collision radius, and then they start sniping. Check CTF-Face in the editor to see how it was done.
Somewhere in Nevada...

User avatar
sektor2111
Godlike
Posts: 5877
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Pathing and weight/priority, so many questions

Post by sektor2111 » Thu Nov 18, 2021 10:03 pm

Aspide wrote:
Thu Nov 18, 2021 8:17 pm
-Put an AlternatePath in a path where the alternate route begins (this will require some playtesting to get the AlternatePath in the right spot)
Nope... They should be a bit far from Start Point or else Bot returns to the shortest route. Distance from AlternatePath to the target Flag should be shorter than any way from initial start point to the goal or else Bot is visiting it and will return on plain route. Bot first time is looking for a path heading to AlternatePath and then it goes to the Flag. If this is closer to Team Base it almost does nothing. After visiting it, it resumes route like AlternatePath never existed.
Something explained simple is here:
https://hofgamingclan.com/forums/viewto ... 3575#p3575

SmartAlternatePath
Old code was bugged and it requires some collision set or else internal code won't react at anything but working as a simple AlternatePath - nothing very smart.
I wrote another stuff even a dynamic AlternatePath which is not only changing selection and has redundant touch protection but it's moving in spot in random circles.
AlternatePath is sorted if is set bTwoWay in both directions, I don't know if Engine post v400 does an automated update. bReturnOnly is only for going back probably if it doesn't use bTwoWay or else is Two Way, I repeat: I don't know if 436 does changes during run-time. bReturnOnly is used where Bot won't need to attack through route for vary reasons (only returning) or when this route it's not recommended to be taken in attack (wasting time, etc).

TeamTrigger
Explanations from code.

Code: Select all

//=============================================================================
// TeamTrigger: triggers for all except pawns with matching team
//=============================================================================
When team is set to 0 (zero) this team won't capture attention of defender under DistanceViewTrigger.
Team described/configured is EXCEPTED from attack. If Red is supposed to kill Blue, TeamTrigger will have Zero, for triggering attack against Team 1 2 3 and it will except zero. Here reaction will depend on whatever LineOfSight and aiming code. SightRadius of DefensePoint should be normal, big values are not always helping, if map is too big, engine won't cause A.I. to be very active from my experience due to space calculations which are exhausting AI cycles.

Desire for items
An item captures attention when Pawn is closer and has a Positive value for desire, 2-3 is enough, if Pawn is far away, here is about PATHS, all paths must be connected and here is not only about those lines Red and Blue, they need to NOT BE One-Way lockers or impossible paths as I see here and there in maps. Pawn must move from Node A to Node B in the same way as from Node B to Node A and here are engaged two internal reachSpecs. Patch 469b it's showing directions and also XC_Engine24 used in Editor with XC_EditorAdds. I believe an item for capturing attention must be somewhere under 200 paths as distance. In normal well pathed stock maps, my tester tool was heading me in all places. Sooner or later Bot wants everything which has a positive desire more than 0.5 - 1. Several items are having a dynamic desire: Bot won't be interested about a MedBox if it has 100+ health. Armors in exchange are having a permanent desire and then... two of them must have a bit of distance each-other and a decent respawn-time allowing Pawn to roam around or else it will crawl around these being distracted. Another goal sorted is an InventorySpot sorted from map. These navigation actors without incoming paths will cause Pawn to camp until next roaming cycle is sorting anything else or an Armor will respawn in a closer range.

Another factor in desire can be favorite weapon as I could read in Bot Code... but I'm not sure if function "FindBestInventoryPath" takes it in account and it's not a matter of a nearby interest and more like a combat stuff.

User avatar
fudgonaut
Adept
Posts: 274
Joined: Sat Oct 05, 2013 7:20 am
Personal rank: Easy Target
Location: "The Butthole of the World"

Re: Pathing and weight/priority, so many questions

Post by fudgonaut » Thu Nov 18, 2021 11:03 pm

Hi @Aspide and @Sektor2111 thanks for taking the time to answer.

AlternatePaths
sektor2111 wrote:Distance from AlternatePath to the target Flag should be shorter than any way from initial start point to the goal
This was my understanding after you helped save CTF-Panamax from pathing doom.

The problem for me is determining the correct SelectionWeight values. Let's say I have three paths to the flagbase.
  • path1 is the shortest route.
  • path2 is twice as long as path1
  • path3 is three times longer than path1
If the SelectionWeight is the same for all three, the bots will always use path1 because it is the shortest route.

So what values should I set the SelectionWeights, for bots to choose equally between the three paths? Would it look like this:
  • path1 = 1.0
  • path2 = 2.0
  • path3 = 3.0
Is there a useful guideline that I can apply when picking values?

Like I said, the trial-and-error method takes a lot of time to test. But if this is what every mapper goes through, c'est la guerre.
sektor2111 wrote:Old code was bugged and it requires some collision set or else internal code won't react at anything but working as a simple AlternatePath - nothing very smart.
Just to confirm, you're saying that SmartAlternatePath doesn't work any better than AlternatePath?
sektor2111 wrote:I wrote another stuff even a dynamic AlternatePath which is not only changing selection and has redundant touch protection but it's moving in spot in random circles.
If I understand correclty, you have made improvements to AlternatePath, these improvements are in v469?


AmbushPoints
Aspide/Sektor from what you're saying and what I've read about AmbushPoints, it sounds like I have it set up correctly in CTF-NRMC-Gravitation

My SightRadius is set to 8192, which is enough distance in UU to reach the trigger. So I guess the reason why my bot stands like an idiot - even when the enemy is wandering through triggers - is because he does not have the sniper rifle.

MaxDesireability
sektor2111 wrote:I believe an item for capturing attention must be somewhere under 200 paths as distance.
Good to know - thank you for all the info on item pickups!
Aspide wrote:I recommend using the BotBonus actor from Unreal Tournament Classic Pack ]I[
The BotBonus actor sounds very interesting. It sounds like it could be combined with AlternatePaths to create some interesting behavior. I have figured out how to extract it and compile it (yay, I compiled my .uc first script!). I look forward to trying it out.

User avatar
sektor2111
Godlike
Posts: 5877
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Pathing and weight/priority, so many questions

Post by sektor2111 » Thu Nov 18, 2021 11:33 pm

CTFGame has a random algorithm for picking AlternatePaths. SelectionWeight can be from 0.5 (EternalCave) to whatever 5 - 10 - 100 - even more. Engine does a random calculus and it sorts an AlternatePath for Bot. Here is what it does - to me this code was heavy and... unpredictable ( FRand() ). It will be set in "RestartPlayer" - so it's not about carrier yet - the other code it's in Flag.

Code: Select all

if ( FRand() < 0.8 )
	{
		for ( N=Level.NavigationPointList; N!=None; N=N.nextNavigationPoint )
			if ( N.IsA('AlternatePath') && (AlternatePath(N).team != B.PlayerReplicationInfo.team)
				&& !AlternatePath(N).bReturnOnly )
				TotalWeight += AlternatePath(N).SelectionWeight; //Creating the sum of them
		selection = FRand() * TotalWeight; //It's a random × TotalWeight
		for ( N=Level.NavigationPointList; N!=None; N=N.nextNavigationPoint )
			if ( N.IsA('AlternatePath') && (AlternatePath(N).team != B.PlayerReplicationInfo.team) )
			{
				B.AlternatePath = AlternatePath(N);
				PartialWeight += AlternatePath(N).SelectionWeight;
				if ( PartialWeight > selection ) //Here is one suitable
					break;
			}
	}
What does it do a "SmartAlternatePath" ? Each touch of this actor makes it to adjust this SelectionWeight a bit for the rest of SmartAlternatePaths. This way TotalWeight is changed and so it's changed that "Random" multiplier. They can be toggled more often, game will work a bit more dynamic at this point. If this "Smart" actor is not delegated with "bCollideActors" function "Touch" is not called and then... it won't be smart at all. A smarter AlternatePath should do itself a check for settings and auto-fixing itself if mapper did not know what was about. Old code is not doing this check...

Radius of view.
You can examine distance between Defensepoint and TeamTrigger and try to not use very big values, you need to cover visible area to the trigger. More than that won't help.

User avatar
sektor2111
Godlike
Posts: 5877
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Pathing and weight/priority, so many questions

Post by sektor2111 » Tue Nov 30, 2021 6:19 am

Bump: I found the class of SmartAlternatePath which supports Editing an UT map even using U227 assets (requires BotPack for 227)...

Code: Select all

class SmartAlternatePath expands AlternatePath;

var(AlternatePath) float AdjustAmount, MaxSelWeight;	//Amount to adjust selection weight by
var float ReTouchTime;		//Delay so selection weights don't get altered many times if we get touched more than once in rapid succession
var(AlternatePath) bool bUseTwoWay;

event PostBeginPlay()
{
	Super.PostBeginPlay();
	SetCollision(True,False,False); //Activating Collision for calling the "Touch"
	bMovable = False; //This is not dynamic
	Enable('Touch'); //Made sure about touch capability
	if ( AdjustAmount <= 0 ) //preventing dumb settings
		AdjustAmount = 1.500000;
	if ( MaxSelWeight == 0 )
		MaxSelWeight = 50;
	SetPropertyText("bTwoWay",GetPropertyText("bUseTwoWay")); //Workaround for 227 - NavigationPoint vs AlternatePath properties
}

function Touch( actor Other )
{
	local SmartAlternatePath A;

	if ( Level.TimeSeconds - ReTouchTime >= 4 ) //This will prevent rapid succession not previous codes with missing required brackets
	{ //Block protection Open
		ReTouchTime = Level.TimeSeconds;
		foreach AllActors( class 'SmartAlternatePath', A )
		{
			if (A != Self)
			{
				A.SelectionWeight += AdjustAmount+FRand();
				if ( A.SelectionWeight > MaxSelWeight ) //Don't go too far
					A.SelectionWeight = FRand()+1;
			}
		}
	} //Block protection Closed
}

defaultproperties
{
	AdjustAmount=0.500000
	MaxSelWeight=200
	bUseTwoWay=True
	Style=STY_Translucent
	DrawScale=0.5
	Texture=Texture'TLSteel'
}