ConsoleDebuggingCommands

AI Debugging - Console Commands

To use these, type them in to the console (type ~ on your keyboard, then type the command)

aimode

Shows what state the AI guys are in.

This is useful to figure out what they're trying to do.

If it says WAIT, that usually means they're stuck, so check that they have goals assigned to them ("aigoals") or that

they're not inside a barrier ("ai.showobstacles").

aigoals

This will dump out a list of AI goals to the console, and also to the debug output (TTY on ps2, DrWatson for xbox):

Team 1: Republic

100.0 Defend (8) myg1_prop_shield_generator

100.0 Conquest (7)

Team 2: CIS

300.0 Destroy (14) myg1_prop_shield_generator

300.0 Destroy (13) kas2_prop_sea_walldoor_2

100.0 Conquest (5)

Team 4: TEAM4

100.0 Deathmatch (4)

The first number (100.0) is the weight assigned to this goal. A 100 weight will be half as important as a 200 weight.

The goal name is followed by the number of units (8) currently assigned to this goal.

If its a goal with a target, like Defend, it also shows the object that its assigned to.

ai.cps

This shows the current list of CPs:

NAME SPAWN STRATEGIC VALUES

woodgate3 100.0 (rep: 10a 10d) (cis: 100a 100d)

gatepanel 100.0 (rep: 0a 0d) (cis: 0a 100d)

cp2 200.0 (rep: 0a 10d) (cis: 10a 0d)

cp1 1000.0 (rep: 200a 200d) (cis: 200a 200d)

cp6 1000.0 (rep: 0a 0d) (cis: 10a 0d)

baserush 300.0 (rep: 0a 0d) (cis: 0a 0d)

SPAWN is the spawn weighting for this CP, which controls where guys will spawn in.

STRATEGIC VALUES are the StrategicAttackValue and StrategicDefendValue that you set in the editor and in the scripts.

ai.showobstacles

Draws the barriers. You need to type "aimode" first for this to work.

ai.showconnectivitygraph

Draws the PathPlanning in the world.

Normal hubs and connections are yellow.

Dynamic connections are either red (closed) or green (open).

Oneway connections are drawn with an arrow in the center of them, and there is text that shows Jump or Jetjump flags.

ai.show

HintNodesThis draws all the hint nodes and patrol paths in different colors based on type.

If you fly close to them it will draw (in text) the type, primary and secondary stances.

There is an arrow pointing in the direction of the node.

Snipe

Patrol

Mine

Cover

Fortification

Vehicle Cover

Jet Jump

Land

------------------------------------------------------------------------------------------------------------------------------------------------------

BF2_modtools.exe

Along with the Mod tools, we’ve released an executable that you can use to run Star Wars Battlefront 2 in a mode that will allow you access to the dev console (press ~ when in the game) which will help make debugging, and developing your mod easier. This executable still has a CD check, and has been crippled in some ways so as not to be used as a stand-alone exe to run and play the game. BF2_modtools.exe can be found in the root of the BF2_ModTools folder. This .exe is completely unsupported, as is everything else in this mod tools release. See the mod tools EULA for more info.

--------------------------------------------------------------------------------------------------------------------------------------------------------

There are three different commands for this in the game (type in the console, no quotes):

"pathcost tot"

"pathcost ave"

"pathcost max"

(also "pathcost sum", explained below)

(also just "pathcost", which will turn it off)

They all (first 3) show the same information, just sorted on the different columns (I'd suggest "pathcost tot"). Type one, and you get a whole bunch of numbers on the screen. The top section deals with the individual connections, which is where you look to figure out which connections to optimize. The columns are:

Cnt - how many times this connection has been requested.

Ave - the average time taken to calculate this connection once.

Tot - the percent of all pathfinding time spent on this connection.

Max - the max time taken for one calc.

Conn - the connection name in the editor (C16 = Connection16)

So the useful information you can get out of this: the total ("tot") column shows where most of the effort of the pathfinding is going. Ideally these should be pretty consistent (and below 10). If one connection is at 35% and all the rest are below 7%, either that one leg is really slow, or a lot of people are requesting it (or both). But either way it's a good one to optimize. Look at the ave column, if that's higher than the rest (say its 0.025, the rest are 0.008) than you know that the leg is just too slow, so try to shorten it (break it into two). If the ave column is fine (<0.010), but the count column is big, then then leg is fast but its getting a lot of use, so it may be worth optimizing anyway.

Also there is a special connection in the list called "none", which is where it times paths that aren't on the graph. If the ave time for this is bad, than there are probably parts of the world not covered by nodes. I'm working on a way to make this clearer.

There are two more sections at the bottom of the screen. The first is the path queue time. This is essentially the delay from when a path is requested to when it is processed (this is less important than the section below). The first column is the number of paths requested, the second is the average queue time, and the third is the max. There are two rows, the first is the total for the entire game, and the second is only for the last 10 seconds. In an ideal world the second number (ave time) of both rows should be under 5 seconds.

The third section is the idle time of the AI players. This is the actual time that AI guys are standing around doing nothing waiting for a path. This is different than the section above since AI guys will calculate their next path while running, so they only stand around waiting (idle) if its not done yet when they stop. This section is obviously the key number that you're trying to reduce. When its 0, nobody is ever standing around. This is good. The columns for this are the same as the section above, being: count, ave, and max, and split between total game time and last 10 seconds.

You can get only the second two sections to display by typing "pathcost sum", which is better if you're trying to see the game too.

You will notice that some of the lines turn red. For the connection list, this means that you should look at this leg to consider optimizing it. For the bottom sections, this means the wait times are too much. If you can get the bottom lines to be green all the time then you've probably optimized enough.

Even if some of the top lines are red, you really only need to work on optimizing a connectivity graph if the idle time (last two lines) is red, otherwise everything is ok.

Ok example time.

Load Naboo2 and type "pathcost tot" in the console. Watch it for a minute or so until the game gets started and the numbers even out. There will be two red lines in the connection list. The first is probably "none" with around 30% in the tot column. Look at the ave column for this its 0.001, which is fine. The reason that its getting so much total time is because there are 1500+ hits in the cnt column. So ignore this one.

The other red line is C44, which is getting a bunch of hits (200+), and has an ave time of 0.006 sec. Both of these are ok numbers, but together they're using 18% (tot column) of all pathing time. If you load up naboo2 in the editor you'll see that Connection44 goes through some buildings and has a whole lot of barriers in the way. So this would be the first connection to look at if you were trying to optimize it.

But fortunately if you look at the bottom two sections, you'll see that the queue time is probably around 2 seconds, and the idle time is around 1 second. Both of these are very good numbers, and mean that an AI guy will usually wait around for only a second. So you really don't need to optimize anything on this level.

Example two. Yavin.

The AI guys used to stand around a lot on yavin, mostly because they were waiting for paths. It was really slow because of all the trees and stairs that they had to path through.

I went through yavin and optimized it, to see if this process would really work. It does. I got the idle time down from 30+ seconds to about 5 on the ps2. This is probably as good as its gonna get without clearing some of the trees out.

If you want to see the numbers when they're slow, go into sourcesafe and get the yavin1.BAR and yavin1.PLN from before this morning. The slow legs are shown very clearly. In the new graph I shortened some of the problem legs, then where it was still slow I made the barriers tighter around the trees and objects (to give more room for the paths). There is probably some more work that could be done, but the AI guys move around a lot better even now.

A few new AI console commands that may come in handy when building levels:

As always you have to turn on AI mode first by typing "aimode 1" or setting it on the command line with "/ai".

"ai.showobstacles 1"

This shows the barriers in the world as before (green boxes), but it also shows them expanded by the player's radius (blue boxes), so you know exactly where a player will fit. If two blue boxes are overlapping, the player will not path between them. It expands by the radius of whatever vehicle you're in as well, so if you get in an ATST, the blue boxes will expand to the size that an ATST can path through.

"ai.notext 1"

This turns off all the white text that follows around the guys when AI mode is on, so you can see other things.

You can also set this on the command line with "/ainotext".

"ai.showallpaths 1"

This will show the paths of every AI player in the world (red lines), so you can get an idea of where everybody is going. (if the lines go through solid objects, it's probably a good sign you're missing some barriers)

"ai.showconnectivitygraph 1"

Shows the connectivity graph in the world as yellow cylinders/lines.

Using the SetMaxFlyHeight(30) in the lua, you can now set the max height for jet- and dark-troopers.

Try "showflyerheights" to view the height in the game.

Change it with "ai.aimaxflyheight".

------------------------------------------------------------------------------------------------------------------------------------------------------------

Console debugging commands:

aidiff

Dumps the difficulty to the console, and also to the debug output (TTY on ps2, DrWatson for xbox):

Profile setting: MEDIUM

AutoBalance: ACTIVE

base lua auto = total

Player : 10 + 0 + 0 = 10

Enemy : 12 + 0 + 0 = 12

This shows the current profile difficulty setting (EASY, MEDIUM, HARD).

Then it says if AutoBalance is turned on.

You can control this with the lua EnableAIAutoBalance() command.

The modes shown are:

ACTIVE - AutoBalance is enabled and currently working.

INACTIVE - Its turned on, but not currently active. Probably because one side has infinite reinforcements.

DISABLED - not turned on.

Then it shows the difficulty setting calculation.

"Base" is the base value that it gets from the profile setting.

"Lua" is the adjustment modifier that you can set in the lua with the SetAIDifficulty() command.

"Auto" is the modifier from the auto balancer.

"Total" is the final value that it uses.

------------------------------------------------------------------------------------------------------------------------------------------------------------

The new command console commands are:

Lighting.SunColor <red> <green> <blue>

Lighting.SunDirection <heightangle> <directionangle>

Lighting.ShadowColor <red> <green> <blue>

For static/buildings:

Lighting.AmbientColor <red> <green> <blue>

For dynamic/characters:

Lighting.TopAmbientColor <red> <green> <blue>

Lighting.BottomAmbientColor <red> <green> <blue>

Any of these can be used without any parameters to just print the current value.

I added console command for all the parameters above so you can tweak the parameters on the fly here are the commands

Blur.Enable

Blur.MinDepth

Blur.MaxDepth

ColorControl.Enable

ColorControl.GammaContrast

ColorControl.GammaBrightness

ColorControl.WorldContrast

ColorControl.WorldBrightness

ColorControl.WorldSaturation

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

A useful console command is "setcontrols 0" to disable player movement.

This way you can fly around in freecam whilst keeping the player stationary.

"setcontrols 1" will turn player control back on

Map.displayall 1 will make the map display info for all teams (e.g. displays all units)

(Map.displayall 0 will turn it back off)

Not sure if I mentioned this new keyboard command to you....

ai.showhints 1 will display hint nodes in game

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

Useful console Commands

mem - displays memory usage of game systems, including the sound

snd.unused - displays sounds and samples loaded which are not referenced

snd.display - disables display / prints out snd.display options

snd.display voice - displays the active virtual voice list

snd.display chase - displays properties of the object being chased by the camera

snd.display space - listener's space

snd.view - display a sound object's settings

snd.set - set a sound object's parameter value

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

>>Ahh flyheights. These are easy. These values control how far from the center of the world the player can fly up or down. These are used on ground based maps to limit the jet classes and jedi, but is also used to keep flyers from getting too high or too far below the space battlefield. To find an appropriate height, use PrintPlayerPos in the console, fly to your desired max/min height, and punch those numbers in. It’s best to keep the Max/MinFlyHeight and the Max/MinPlayerFlyHeight in line with each other to avoid AI doing things that players can’t.

SetMinFlyHeight(-1800)

SetMaxFlyHeight(1800)

SetMinPlayerFlyHeight(-1800)

SetMaxPlayerFlyHeight(1800)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

It's possible to force the player's flyer to follow a path using the command line switch /playerflyerpathing.

Paths are displayed using the console command DrawEntityPaths.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

You can view the player's adrenaline level in the game by typing "ai.showadrenaline"

at the console.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The Camera stats section defines the coordinate for the camera shots that appear in the background when you’re waiting to spawn in-game using in game coordinates. Using free cam mode in the SPTEST.exe supplied, modders can navigate to a spot and dump the coordinates to a file called cameracoordinates.txt by typing:

dumpcamera

in the console.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Useful console commands when debugging a Jedi are:

- "combo.damage" – toggles on and off the showing of a Jedi’s saber edges that can do damage as a red bar with a sphere at the end. The bar indicates the length, while the sphere indicates the radius. Note that this is the Length and Width that come from within the Attack() sections of a combo file, NOT the length and width from the weapon ODF.

- "anim.show" – toggles on and off display of the animation(s) that the player character’s legs and upper body are playing, the total length of the animation (in frames) as well as the current frame number, and the percentage of blending out of the last animation. ESPECIALLY useful with:

- "slowmo [number]" (like "slowmo 5"). The number is the number of times slower to play the entire game…um…it’s the denominator in the speed, so if you say "slowmo 5" then the game plays at 1/5 speed, if you say "slowmo 2" then it plays at ½ speed, etc. "slowmo" by itself, or "slowmo 1" turns it off. Note that you can also speed up gameplay with "slowmo .2" or "slowmo .5", but this has no practical use for animation debugging. After inputting a "slowmo", turn off the console and check your character for bugs or animation pops.