So for this code:
INIT
DB_JailDistance(1,REAL:5);
KB Section
IF
CharacterSawCharacter(Guard, Player)
AND
CharacterGetDistanceToItem(Character_Player1, ITEM:Brazier, _CharDist)
AND
DB_JailDistance(1, _CheckDist)
AND
RealMax(_CharDist, _CheckDist, _MaxDist)
AND
NOT DB_JailDistance(1, _MaxDist)
THEN
Stuff
The first line
DB_JailDistance(1,REAL:5);
This creates a custom Database with the key:value pair of 1, 5. The 5 is set to be a real number so that it can be used in the real number comparison later.
IF
CharacterSawCharacter(Guard, Player)
AND
CharacterGetDistanceToItem(Character_Player1, ITEM:Brazier, _CharDist)
I presume the CharacterSawCharacter triggers when the guard sees the player. Once that occurs, it will start checking the ANDs in order. The first AND, CharacterGetDistanceToItem should be getting the distance between the Player1 and the Brazier, and outputting it into the variable _CharDist (as a Real number).
DB_JailDistance(1, _CheckDist)
This outputs the Real number 5 from the Database initialized earlier into a variable called _CheckDist.
RealMax(_CharDist, _CheckDist, _MaxDist)
This is the comparison function (kind of). If the character is within the cell, their distance from the item within the cell should be less than the arbitrarily set maxdistance listed in the Database. If they are outside the cell, the _MaxDist should be set to _CharDist instead since it's greater.
NOT DB_JailDistance(1, _MaxDist)
And finally, this is the gatekeeper function to the THEN stuff. Because _MaxDist was defined earlier, this line should be checking whether the key:value pair of 1, _MaxDist exists within the database. If the character is within the cell, the DB_JailDistance should evaluate to true (since _MaxDist is the Real number 5 from earlier), and then the NOT inverses it so that it doesn't reach the THEN function.
If the character is outside the cell, then the _MaxDist will be greater than whatever was in the database, making that return False (which is inverted to TRUE with the NOT), and thus continues into the THEN stuff.