Yes, it just checks Player1 and Player2's stats and generates global flags every time dialog is either initiated (from a trigger, for example) or requested, like when you click on someone. Probably unnecessary redundancy, because presumably initiated dialog covers all the possibilities, but I'd keep both to be safe.

If you want to make companion stats to count, you'll probably have to add some code like:

IF
DB_Companion(_Companion)
THEN
DB_CharacterToCount(_Companion)

And also the NOT version for when you dismiss a companion. We don't have companions count because it feels like it'd be too easy for people to access essentially every dialog option by spreading skills and attributes across the four characters.