Cajunwolf prompted me to start a list of useful debugger commands. There are
many. I've enclosed optional parameters in square brackets. You enter these
commands from the game console (press ~). There is also an autocomplete
feature that is very useful. Once a command is started, pressing the tab key
will finish the command as far as possible. If there is more than one possible
completion, pressing tab twice will show a list of possible completions.
Hitting tab one more time will show a list with parameters as well. A bool or
boolean is a 0 or 1. The three I use the most are:
- game.enableFreeCamera bool
- game.useHud bool
- renderer.vertexFogEnable bool
So I can move around freely and view the map clearly. Here are a few that
display useful debugging information onscreen. To turn on AI deubugging:
- game.showAIStats [bool] - turn off/on ai debugging.
Once AI debugging is on, you can selectively turn on or off certain debugging
information with these:
- ai.showAll bool
- ai.showBot bool
- ai.showStrategic bool
- ai.showBotStats [bool]
- ai.showBotUrgencies [bool]
- ai.showBotSpawnCoord [bool]
- ai.showBotSense [bool]
- ai.showStrategies [bool]
- ai.showSAIStats [bool]
- ai.showStrategicAreas [bool]
- ai.aiMeshRendering [bool]
Collision meshes are displayed with:
- standardMesh.drawCollisionLods [-1,0,1]
-1 turns it off, 0 & 1 render the different collision mesh lods. And you
can view object portals with:
These commands are interactive and should not be used at the same time:
- game.aiSensingDebugingActive [bool]
- game.aiPathfindingDebugingActive [bool]
The AI sense debugging is useful to determine the exact coordingates of an
object. Position an object in the center of the screen and click fire. With AI
pathfinding debugging active, click the fire button to mark a starting
position (a white circle) and again to mark the ending position of a path. Its
also useful for determining the exact coordinate of a spot on the terrain,
since the coordinates are displayed onscreen. Also, when AI pathfinding or
senseing debugging is active, you can use these commands to tune the
information displayed:
- aiTools.pathfindingVehicle [0-4]
- aiTools.pathfindingMode [local,strategic,full]
- aiTools.sensingMode [0-4]
If you would like the camera to follow the bots around, use:
- ai.attachCamera
- ai.attachCameraCycle
The first command will attach the camera to the first bot, the second will
cycle from bot to bot. I'm sure there are many more. If you know any, please
feel free to add to this list. I had a much larger list, but can't seem to
find it ATM.
I've put together a debugging toolkit that demonstrates the use of many of
these commands. It's a small collection of scripts that allow you to to use
the function keys F1-F4 to view various settings without using the bf
debugger. It's also an example of how to use varialbes, constants, conditional
and looping statements in con scripts. It's a work in progress and I plan on
making it easier to use in the near future, but for now you can download it
HERE.
To use it, you could place the toolkit files directly into your map's root
folder, but I would suggest packing them into a map extention instead. You do
this by:
1. Create a folder tree that lools like: Bf1942\Levels\<Your_Maps_Name>
2. Put the con scripts in the <Your_Maps_Name> folder (replace
Your_Maps_Name with the actual name of your map).
3. Pack the folder tree into an rfa with a 3 digit extention number. e.g. To
use with the stock Berlin map, the rfa name would look like: Berlin_999.rfa.
The extention number should be higher than those of any existing map extention.
I pick 999 to guarentee that my scripts are loaded.
4. Copy the rfa file to levels folder of the mod you are working on.
5. Play the map in single player mode.
When the game starts, the F1-F4 keys do:
[color=orange]
F1 - Cycle chase camera from bot to bot
F2 - Toggle thru the different AI debugging states - release chase camera
F3 - Toggle thru pathfinding and sensing debugging - release chase camera
F4 - Toggle thru various mesh rendering states - release chase camera
Do not choose a spawn location when the game starts, just close the ingame map
and press F1 once. This turns on AI stats and puts you in freecam mode so you
can move around. Most of the AI debugging information is turned off, but you
will see when the bots are taking aim:
Pressing F1 again turns on the strategic areas:
Strategic area informaion is very useful since it displayers the SA
tempuratures for each team, which vehicles it accepts, how many bots are
present, available to attack and defend, how many that are assigned and the
present state of the SA for team.
Pressing F1 again turns on bot stats, and one more time indludes the bots
spawn point:
Bot stats, although somewhat congestive, are useful when the bots are not
behaving properly. If a bot is just standing around, check the bots behaviour.
If the behaviour is set to idle, the bot has no orders to follow, which can be
caused by bad pathfinding or faulty strategies.. If the behaviour is set to
change, there might be a kit or vehicle it wants to us, but can't. Or if the
behaviour is set to fire, the bot might be considering exactly how.
Pressing F1 again displays the bots sensing mechanism:
Pressing F1 again turns on bot urgencies, which I'm unsure of. If anybody know
what this does, please tell me. Yet one more time displays the active
strategies in the upper left hand corner of the screen and again to display
the SAI stats, which I also don't quite understand. Finally, press F1 one last
time to turn off AI stats completely.
Press the F2 key to turn of pathfinding debugging. With pathfinding debuggin
on, left click the mouse to mark a starting position. The exact coordinates of
the point and wether or not it is valid is dsiplayed on the left side of the
screen. Left click again to pick the ending coordinate. If there is a valid
path between them, there will be a magenta line connecting them:
This script could use some work. ATM, it uses the tank pathmaps to calcualte
the validity of the coords. You can set the vehicle from the cosole with:
aiTools.pathfindingVehicle <0-4>, if you wish. Pressing F2 again turns
on sensing debuggin:
While sensing debugging is active, left click to display information about the
object directly in front of you. Its a good way to find out the name of an
standard mesh used by the object.
Pressing F2 again fills the screen with circles, a pair for every object the
bots can sense and how long it took to do it:
Press F2 again and the bots viewing range is displayed as well as the bots
sensing mechanism:
Press F2 one last time to turn all this nonsense off. The first time you press
the F3 key, the aimeshes are displayed:
The mysterious aimeshes play a role in the pathfinding process. Cajunwolf,
Dnamro and others are still discovering more about them every day. Press F3
again will display portal information:
Press F3 again to render in wireframe mode:
The next 2 times you press F3, the collision lod's are displayed:
And again to turn it off. The F4 key generates the pathfinding files, which
are written to:
<game directory>\BF1942\Levels\<map name>\Pathfinding
Where <game directory> is where you have battlefield installed and
<map name> is the name of your map. Although I could do this with a one
line script, I used the while and endwhile construct to demonstate the use of
a loop.
THANK YOU SO MUCH!
This is a lot of work you have done here and has already advanced my AI
knowledge 10 fold. With out the command to show the AiMeshes we talked about the
other night I might have never known that I have one of my own AiMeshes working
in game! I danced a cajun waltz around the room when I saw it I'll tell ya! Now
to get it designed right to properly path the object is another project.
In using the various commands/scripts I can troubleshoot in detail SAI/pathing
problems in a map. I have already learned that what I though was the cause of a
particular problem can be something else all together. I mean you can see in
detail now how a tweak to a strategy, SA, behavior, or even object placement can
effect the SAI as a whole by flipping through the various stats to see what is
happing at any given moment. You say object placement??...well I have noticed
when applying this to a crowded map how when the AI seemed to be stalling it was
taking the bots a long time to figure out what all the objects were and how to
get around them. I moved or removed many of the objects and the SAI picked up
the pace at once. Goes to show you never know and it always boils down to a
map-to-map basis.
I think this is a real breakthrough and is going to bring AI for Battlefield to
the next level. The tool is great to put it mildly and there is only one quirk I
need to mention or caution people about. Be sure and have all the commands off
before you quit the game. In some cases it will crash bf or lock it up when it
tries to quit. With this in mind people need to remember that this is a WIP or
beta by FourCentsShy and should be used with caution. If you don't know what all
this does then don't do it in other words.
Learn a little more first.
Once again Four,
THANKS
Just an added thought here as I think it is kind of on topic. We all wonder why
EA seems to put so much time to the multiplayer aspects of the game and I am
sure that the market has a lot to do with it, but I am learning more and more
each day and one thing is that doing this game from an on line multiplayer
environment is really the easy part. Getting AI to work right for a given map is
where the time and work come in. I don't think EA could have released the game
in the time frame they did had they fully implemented the AI support. It just
would have taken to much time and manpower. With this being said and
FourCentsShy's discoveries about the commands that run the debugging tool I
think we are going to see there is a lot more to the AI than we think. Dnamro
and they others have proved this already with the RealPlayer Mods. Now that we
have a faster better way to check the effects of or modifications other than the
change it try it, do it again and again technique we can learn more quickly.
HDN has discovered
some
very impressive commands. The thread topic:
aiSettings.setBotSkill 1.0
This command definitely improves bot accuracy and response time. HDN suggests
putting the command in the AIbehaviours.con, which is in the mods Game.rfa
file. This will effect all the maps in the mod, but you should make a backup
of any mod archives before changing them. On a per map basis, you can also add
the command to the AI.con in the maps root folder:
Bf1942\Levels\<YourMapsName>\AI.con
His post included a link to an even more impressive command:
Editor.saveFolderToArchive Bf1942/Levels/<YourMapsName> 1 1
This command creates a compressed archive of your map, which is much smaller
than what most utilities can produce. Copy your map files and subfolders into
the game directory with the correct path that should look something like this:
<game dir>\Bf1942\Levels\<YourMapsName>
Replace <game dir> with the path to the folder where battlefield
executable is installed and <YourMapsName> is the name of your map. If
you were using winRFA to extract the map, you would extract it directly into
the game directory, which is usually:
C:\Program Files\EA GAMES\Battlefield 1942
With all the maps files correctly in place, the maps rfa file isn't needed, in
fact, all the files in it are ignored unless they are missing from the
unarchived folder. The files in this folder are read before any archive, no
matter what mod you are using. You should remove them when you are done. But
while you are here, this a great place to do some quick last minute editing.
The maps con files can be edited while the game is running and any changes
take effect the next time the map loads. When you're ready, run the command
mentioned above and the compressed archive is saved into:
<game dir>\Bf1942\Levels
Remember to move or delete the map files when your done or any changes made
directly to the map's rfa files will seemingly have no effect, including
textures and pathfinding maps.
Good information Four. I need a clarification on one thing though, "The
maps con files can be edited while the game is running and any changes take
effect the next time the map loads". Can you explain this one a little
bit better?
Just a little tip to pass along to those who might not be aware, the bf1942
folder in the game directory FourCents is speaking of is the same one created
when you run the pathing engine to generate pathmaps. Therefore one can just
place their working map in this folder and make all edits necessary without
having to extract and repack all the time. Like FourCents mentioned above the
game runs ALL map code in this folder unless something is missing and then and
only then will it read from the map archive in the levels folder. If you want
to run the Botinator for example, just extract the map to C:\Program Files\EA
GAMES\Battlefield 1942 (or Battlefield Vietnam)" and run the Botinator on
the map from there. Now you do not have to pack the map..just start in COOP
and run the map. Once you have it the way you want it just run the archive
command and you will have a rfa in the same folder. This will need to be moved
to the games\mods levels folder.
| Good information Four. I need a clarification on one thing
though, "The maps con files can be edited while the game is running
and any changes take effect the next time the map loads". Can you
explain this one a little bit better?
|
Since the map is unpacked, I can start the game, load the map and look for
problems. I edit the con files while the game is running and fix any problems
then. To see the changes, I escape to the main menu and start the map again. I
use 2 computers to develop/debug any maps. One I use to edit with, the other
runs the map. Battlefield can be very possessive of the mouse pointer, which
makes it hard to both edit and run the game from just one. Not having to
unpack and repack the maps, as well as, start and stop BF makes the process
that much faster.
I've discovered a few more tidbits to add to the list.
Making compressed map archives from the command line.
Packing the maps from the command line means you can create a batch file to
pack all the maps in a mod. It also makes them 30-40% smaller than winRFA or
the others. Here's how:
Copy the unpacked map into the game directory so that the directroy tree looks
like this:
<game dir>\Bf1942\Levels\<map name>
Where <game dir> is the folder where BF is installed, usually in:
C:\Program Files\EA GAMES\Battlefield 1942\
and <map name> is the name of the map and is called the map's root
folder. The map's root folder should contain all the files you want to include
in the archive, like the init.con and the GameTypes folder to name a couple.
If you use winRFA to unpack a map, then unpack it directly into the game
folder.
From a console window, change directories into the game folder and run this
command:
bf1942_r +makeArchive Bf1942/Levels/<map name> 1 1
This will create a compressed archive and place it in:
<game dir>\Bf1942\Levels\
You can actually play any unpacked map without the rfa installed, but only
single player game mode. Thats also why you should remove the map folder when
you are done. While in place, it will load before any packed map, no matter
what mod is being played. This fact also makes it an excellent place to unpack
a map for editing.
While the console window is handy, you can also create the contentCrc32.con
from here. First, run the command:
bf1942 +generateMapListForCrcContent 1 +game <mod name>
Notice I'm using the game executable, not the debugger. The debugger does not
work for this. The command above creates a batch file in the game directory
called:
getcrc-<mod name>.bat
The <mod name> is the actuall name of the mod. Run this batch file and
the contentCrc32.con will be created in the mods root folder.
necro's quick and short tutorial to editing objecttemplates (or aitemplates)
from the console.
objectTemplate.active
sets the object template you want to edit, wether its a pco, rotational bundle,
projectile, whatever. Whereever you see objecttemplate.create is something you
can set active.
now you can change settings exactly as you would directly in the con files.
Taking advantage of command completion you can see exactly what commands are
valid for each template.
to edit a child of an object (eg anywhere you see ot.addtemplate) you simply
type
objectTemplate.children.childx
where x is the number of the child, starting from 0. That is the first
addtemplate is child0, second is child1, 17th is child16.
objectTemplate.children.child0.position
will change the "setposition" of the child. Similarly, substiuting
position for rotation changes the "setrotation" attribute. Command
completion will tell you the other things you can change for childern, theres
only about 8.
to view your changes you need to load a new instance of the template. For
projectiles this isnt a problem, just fire another one. For almost everything
else you will need to do
object.create <objectname>
this will create an object about 10m infront of your crosshair, faceing north.
to save your changes type
objectTemplate.save <objectname>
this will save the entire object in <bfpath>\objects\<path_to_object.con>
If, for example, we were editing the f4phantom in bfv, with a default install
path, then it would place the file in
C:\Program Files\EA GAMES\battlefield vietnam\objects\vehicals\air\f4phantom\objects.con
inside the objects.con that is created is ALL the templates required for the
vehical. That includes everything in the F4's folder (for the example). Simply
copy and paste the relevent parts into your working copy, delete the file bf
made and your done.
all these commands can be used with aitemplates in the same way.
I did a little testing today, and will expand a bit on Four's post RE: using
the bf1942_r executable to compress mod archives. Using the DesertCombat map
as a test bed, I saved over 100MB using this method and I can still play
online due to the lack of content checking for mods (my next experiment). On
average this will save 35-40% in your final file sizes.
Simply follow the same procedure as with the map files outlined by Four's.
I'll use the texture.rfa as my example since it's the worst disk hog of them
all, the rest work in the same manner, followed by a couple of notes. So, you
extract your texture.rfa to the main battlefield directory
ie C:\Program Files\EA GAMES\Battlefield 1942\
You will now have a texture folder there ie: C:\Program Files\EA
GAMES\Battlefield 1942\texture\
Now, from a console window, change directories into the game folder and run
this command:
bf1942_r +makeArchive texture 1 1
After a couple minutes you will have your new texture.rfa in the games root
dir along with your texture folder that you started with. You will know when
it is done working when a texture.lst file appears in the root dir as well.
*Note* when doing the standardMesh.rfa, rename the directory that is already
there to contain the .samples files prior to extracting. Otherwise your .sm's
will be added to that directory. And of course don't forget to change it back
when you're done.
*Note* when doing the game.rfa, be sure to move your maps working folder prior
to extracting thee game.rfa. Use this line to compress it:
bf1942_r +makeArchive bf1942 1 1
After it is compiled, simply rename it to game.rfa.
On one last note here, I tried to use both the bfvietnam.exe and
bfvietnam_debug.exe to do the same for BF:V, but to no avail. However, you can
use the bf1942_r.exe to do it. Just move you extracted files into the
Battlefield 1942\ root directory and run it the same way as for BF42. So for a
BfVietnam map you'd have the directory structure:
C:\Program Files\EA GAMES\Battlefield 1942\BfVietnam\levels\<mapname>
and use the command:
bf1942_r +makeArchive BfVietnam/Levels/<map name> 1 1
The Battlefield Vietnam debugger will make compressed archives. I haven't had
any luck with using it from a command prompt, but there is still the game
console to work with. The command used in the game console has an extra
parameter that I haven't figured out yet, but it seems to have little effect.
The command is:
Editor.saveFolderToArchive BfVietnam/levels/<map name> 1 1 "any
string works here"
The compressed archive is saved in:
<game dir>\BfVietnam\Levels
There is also another command line parameter that I've been looking at: +restoreFolder
It seems to be the compliment of the the +makeArchive parameter, but I have
had little luck with it so far. If anybody can figure this one out, please let
us all know. It could be handy.
From the debugger console, the tab does auto-completion of commands. Hitting
the tab once will complete the command as far as it can. Hitting it again will
present you with a list of possible completions and again to show what
arguements follow. I've spent many hours going thru them all looking for
anything that might be useful. One thing to note, this will not show all
possible commands. Some are only available for certain objects or templates. If
you want to see what commands are available for a particular object or template,
either make one active or create one. Then the tab will show you what all the
possible completion for that object or template are.
The debug logs may be huge, but here are a few commands that make them even
larger:
ai.pathfindingDebugLevel [uint]
aiStrategicArea.enableDebug [bool]
aiStrategy.enableDebug [bool]
animationStateMachine.debugMode bool
game.debugDamage [bool]
Here are a few more console commands that provide onscreen information:
game.drawDebug [bool]
game.clearDebugLines
The first command, drawDebug, will eventually flood the screen with lines that
do not get cleared. The second command, clearDebugLines, is needed to erase the
existing lines.
This command is a cheat, since it displays both teams in the minimap, but might
be useful while developing it:
hud.toggleDebugMap
These 2 commands provide performance information onscreen:
console.showFPS [bool]
console.showStats [bool]
These can be used to turn different types of rendering on or off:
renderer.drawObjects [bool]
renderer.drawOpaqueObjects [bool]
renderer.drawSky [bool]
renderer.drawTerrain [bool]
renderer.drawTranslucent [bool]
renderer.drawTransparentObjects [bool]
renderer.drawTrees [bool]
These commands dump files into various places off the game's root folder:
aiStrategicArea.saveAll
animationStateMachine.saveAnimationCache
Editor.saveAllObjects [string]
Editor.saveAllSpawners
Editor.saveAllTemplates
Editor.saveAllTemplatesAndObjects
Editor.saveAllUsedTemplates filename
Editor.saveSpawners bool bool bool
geometryTemplate.saveAll
lodSelectorTemplate.saveAll
materialManager.dumpMaterialList
object.saveAll
objectTemplate.saveAll
sky.saveAll
TerrainEditor.saveHeightMap
TerrainEditor.saveRoadMap
weather.saveAll
I'm still going thru them all looking for more goodies. I've been playing with
the weather commands, but have had no luck with them yet. I did notice that when
I entered:
weather.initWeather
Another group of commands appeared that go with it:
wPart.acceleration
wPart.active
wPart.centerAroundObject
wPart.close
wPart.color
wPart.displacement
wPart.fadeInValue
wPart.fadeZ
wPart.getTexture
wPart.numParticles
wPart.partSize
wPart.pointSpriteMaxSize
wPart.pointSpriteMinSize
wPart.radius
wPart.random
wPart.removeAll
wPart.scale
wPart.setTexture
wPart.speed
wPart.type
It appears that the weather was meant to be like an effect, but may never have
been implimented in bf. It's not used anywhere in the game. If anybody has any
luck with this, please post. I would love to see a battle in a rain storm.
found something on the weather commands:
the code
| CODE |
weather.initweather
weather.saveall weather.con
|
on gazala, (works on all other maps, i think) this will give you the file
"weather.con" in the bf-root folder, containing this lines:
| CODE |
rem
rem *** Weather Data Base ***
rem
Weather.initWeather
WPart.type 0
WPart.radius 0
WPart.speed 0/-5/0
WPart.numParticles 0
WPart.setTexture 0
WPart.setTexture 1
WPart.setTexture 2
WPart.setTexture 3
WPart.setTexture 4
WPart.setTexture 5
WPart.setTexture 6
WPart.setTexture 7
WPart.setRndDir 1
WPart.displace 0/0/0
|
still don't know, how to correctly code it to have any effect on the map.
tried this without success:
init.con of the map:
run Init/Weather (right under the other run Init/... calls)
init/weather.con:
| CODE |
rem
rem *** Weather Data Base ***
rem
Weather.initWeather
WPart.type 1
WPart.radius 1000
WPart.partSize 1 100
WPart.color 150/10/10/100
WPart.speed 1/1/1
WPart.numParticles 10000
WPart.setTexture 0
WPart.setTexture 1
WPart.setTexture 2
WPart.setTexture 3
WPart.setTexture 4
WPart.setTexture 5
WPart.setTexture 6
WPart.setTexture 7
WPart.setRndDir 1
WPart.displace 1/1/1
WPart.active 1
|
Almost all of these commands are only available using the debugger. There are
a few things that make me think that the weather was not completed or
implimented ingame. Many of the commands in the file saved with
weather.saveAll are incorrect. The debugger complains about them in the logs
and the console shows a few different commands and arguments. The other thing
that makes me wonder is after correcting the errors and adding all the useful
commands to the file:
rem *** Weather Data Base ***
rem
Weather.initWeather
WPart.type 0
WPart.radius 200
WPart.partSize 100
WPart.speed 0/-5/0
WPart.scale 2/2/2
WPart.fadeZ 0.5
WPart.color 150/10/10/100
WPart.numParticles 1000
WPart.setTexture 0 weather.tga
WPart.setTexture 1 weather.tga
WPart.setTexture 2 weather.tga
WPart.setTexture 3 weather.tga
WPart.setTexture 4 weather.tga
WPart.setTexture 5 weather.tga
WPart.setTexture 6 weather.tga
WPart.setTexture 7 weather.tga
WPart.random 0.9
WPart.displacement 1/1/1
WPart.acceleration 2.0
WPart.fadeInValue 2.0
WPart.pointSpriteMinSize 1.0
WPart.pointSpriteMaxSize 100.0
WPart.centerAroundObject camera
WPart.active 1
Still nothing happens. I've tried variations for most of the arguements. The
weather.tga is a solid bright red 256x256 image. Maybe its the wrong size or
should be a dds. I don't know. I chose it so that if anything happened at all,
I was sure to notice it. This file also loads without a peep from the debugger
in the logs. It does mention having succesfully loaded the weather.tga.
I checked the Repel map the Gen Disarray mentioned. The Sandstorm is pretty
kewl, but the weather and wPart commands are never used. The sandstorm was
coded as a PCO, with the actual sandstorm attached as an effect. It was
intreging how they coded it, but I wonder why.
probably something they wanted to add, but was too much of a strain on
resources. Ive also noticed a few cool looking objecttemplates you can create
in the bfv debugger
objectTemplate.create Lensflare <string>
objectTemplate.create FloatingBundle <string>
theres a few unique commands for the lensflare but i havent been able to get
it to work. I havent tried the floatingbundle but im guessing its a rotating
bundle that always points in the same direction (within constraints)
I've finally gone thru the Battlefield Vietnam executable and wrote down all
the command I could find. I have them broken down in catagories and used the
debugger so I could include the arguements for each command.
You can get them At
My Site.
There were some data structures that were just too wild to go into. Those would
be listed as commands that end abruptly at a period. In the object template,
they are armor, armorEffects, physics and children. I also didn't go out of my
way to get all the methods listed for the object class, since all of those
metheds are listed in the objectTemplate class.
--> Void means it doesnt return anything.
ie setposition doesnt return a value to the console but getposition returns a
vec3 (x/y/z variable)