Dernière mise à jour : 22/06/2017 à 15h37

Current Project : ...

Tutorials index

Enabling debug messages and color coding

Debug Code

Before we shipped U2 we disabled the message area to prevent unwanted debug messages. If you're developing for U2 these messages can be very useful, though. Here's how to enable debugging:

Open the file "UIScripts/UI.ui" with a text editor.
Search for the line ";Component=Console.MessageArea" and delete the ; character, thus reenabling the message area (it's green text on the top corner of the screen).
Remove the "read only" attribute from UI.ui (it's set cause the file has been copied from CD) and save it..
Open the User.ini file and set these two settings to false (they default to true in the shipped game):
bDisableErrorColors=false
bDisableErrorMessages=false
Save the "User.ini" file.

NPCs that encounter an error will now turn a certain color, making it easy for you to spot guys that aren't behaving properly (I'll try to dig up the meaning of each color later).

You can also debug your .u2s scripts now, as seen in the above screenshot. To print out an AI script as it's executing you add the line "debugmode xx" to the script. "debugmode 11" is especially useful here, it tells you every command an NPC is processing. If you need help with the syntax load some of the existing scripts, for example "Script/Atlantis/AidaPostM00.u2s". Uncomment the debugmode line, save the file and play the first interlude to see what Aida is doing.

You can also enable these debug messages globally by editing your "User.ini":


[U2AI.ScriptControllerBase]
DebugMode=0
//DebugMode=1 // show internal debug info
//DebugMode=2 // dump commands and log executed commands
//DebugMode=3 // 1+2
//DebugMode=4 // dump events
//DebugMode=8 // dump control flow jumps (gotos, calls, onevent etc.)
//DebugMode=11 // dump everything but events
//DebugMode=15 // dump everything
ErrorMessageFrequency=3.0 // rate at which script errors are logged to screen in-game

"Debugmode 0 " is set by default, set it to another value to get more feedback for every guy in the map.When you're making levels "debugmode 11" is probably all you'll ever need to debug your scripts. Here's some additional settings straight from the .ini that you might find useful, especially if you're writing .uc code:


[Engine.LicenseeController]
DebugFlags=0
//DebugFlags=7 // anims
//DebugFlags=16 // basic AI (incl. state changes if bTrackStateChanges, etc.)
//DebugFlags=32 // attacks / weapons
//DebugFlags=64 // events
//DebugFlags=128 // movement
//DebugFlags=176 // all except anims and events
//DebugFlags=240 // all except anims
//DebugFlags=247 // all including anims
//DebugForced=true // show forced debug messages
bTrackStateChanges=false
//bTrackStateChanges=true // log gotostate/goto information
bDebugForced=false

[U2AI.U2NPCController]
//bVisibleAI=true // show/hide AI intermediate/final destination actors

[Engine.TriggerHelper]
//bDebugMode=true // log trigger debug info

[U2.U2Pawn]
bDisableErrorColors=false
bDisableErrorMessages=false

Tutorial by Matthias Worch

2005-2016, by Hellkeeper.

Valid XHTML 1.1 CSS 2.1