Modding/Conditionals

From Pillars of Eternity Wiki
Jump to: navigation, search

Conditionals[edit | edit source]

Logical conditions[edit | edit source]

The Quest and Conversation structures posses a condition feature. This is used to encode logical formulas. The game will evaluate these formulas to determine if the node should be accessible. In the files this feature is contained in the <Conditionals> tags.

The Conditions can be nested arbitrarily deep and be connected with the logical operators AND, OR, NOT. In the files are two kinds of Elements: ConditionalExpression which combine different Conditions and ConditionalCall which contain game functions e.g. to check a global variable.

To evaluate the Conditions as given in the XML files the game goes from top to bottom and evaluate each part. The logical operators which will also be used from top to bottom, with each new one occurring replacing the current remembered. This encoding makes it possible to evaluate the formulas in one go without the need of a stack or multiple recursive branches. A side effect of this encoding is, that in the files occur more Operator tags than necessary to build the logical formula.

Example[edit | edit source]

data/conversation/07_gilded_vale/07_cv_fisherman.conversation contains the following code:

     <Conditionals>
       <Operator>And</Operator>
       <Components>
         <ExpressionComponent xsi:type="ConditionalCall">
           <Data>
             <FullName>Boolean IsGlobalValue(String, Operator, Int32)</FullName>
             <Parameters>
               <string>n_Clyver_Quest_Stage</string>
               <string>GreaterThan</string>
               <string>1</string>
             </Parameters>
           </Data>
           <Not>false</Not>
           <Operator>And</Operator>
         </ExpressionComponent>
         <ExpressionComponent xsi:type="ConditionalCall">
           <Data>
             <FullName>Boolean IsGlobalValue(String, Operator, Int32)</FullName>
             <Parameters>
               <string>n_Clyver_Quest_Stage</string>
               <string>LessThan</string>
               <string>4</string>
             </Parameters>
           </Data>
           <Not>false</Not>
           <Operator>And</Operator>
         </ExpressionComponent>
         <ExpressionComponent xsi:type="ConditionalCall">
           <Data>
             <FullName>Boolean HasConversationNodeBeenPlayed(String, Int32)</FullName>
             <Parameters>
               <string>assets/data/conversations/07_gilded_vale/07_cv_fishermen.conversation</string>
               <string>6</string>
             </Parameters>
           </Data>
           <Not>true</Not>
           <Operator>And</Operator>
         </ExpressionComponent>
       </Components>
     </Conditionals>


In shorter terms:

IsGlobalValue(n_Clyver_Quest_Stage, GreaterThan, 1) AND IsGlobalValue(n_Clyver_Quest_Stage, LessThan, 4) AND NOT HasConversationNodeBeenPlayed(assets/data/conversations/07_gilded_vale/07_cv_fishermen.conversation, 6)

which is in plain logical writing:

A ≥ 1 ∧ A ≤ 4 ∧ ¬B

Example 2[edit | edit source]

data/conversations/02_defiance_bay_first_fires/02_bs_controller_crucible_knight_guard_guid.conversation

     <Conditionals>
       <Operator>And</Operator>
       <Components>
         <ExpressionComponent xsi:type="ConditionalCall">
           <Data>
             <FullName>Boolean IsGlobalValue(String, Operator, Int32)</FullName>
             <Parameters>
               <string>b_Disable_Knight_Barks</string>
               <string>EqualTo</string>
               <string>0</string>
             </Parameters>
           </Data>
           <Not>false</Not>
           <Operator>And</Operator>
         </ExpressionComponent>
         <ExpressionComponent xsi:type="ConditionalExpression">
           <Operator>And</Operator>
           <Components>
             <ExpressionComponent xsi:type="ConditionalExpression">
               <Operator>Or</Operator>
               <Components>
                 <ExpressionComponent xsi:type="ConditionalCall">
                   <Data>
                     <FullName>Boolean IsGlobalValue(String, Operator, Int32)</FullName>
                     <Parameters>
                       <string>bReceivedAcolyteHeritageHillVision</string>
                       <string>EqualTo</string>
                       <string>1</string>
                     </Parameters>
                   </Data>
                   <Not>false</Not>
                   <Operator>And</Operator>
                 </ExpressionComponent>
                 <ExpressionComponent xsi:type="ConditionalCall">
                   <Data>
                     <FullName>Boolean IsGlobalValue(String, Operator, Int32)</FullName>
                     <Parameters>
                       <string>n_HH_Quest_Stage</string>
                       <string>EqualTo</string>
                       <string>0</string>
                     </Parameters>
                   </Data>
                   <Not>false</Not>
                   <Operator>And</Operator>
                 </ExpressionComponent>
               </Components>
             </ExpressionComponent>
             <ExpressionComponent xsi:type="ConditionalExpression">
               <Operator>Or</Operator>
               <Components>
                 <ExpressionComponent xsi:type="ConditionalCall">
                   <Data>
                     <FullName>Boolean IsGlobalValue(String, Operator, Int32)</FullName>
                     <Parameters>
                       <string>bReceivedAcolyteSanitariumVision</string>
                       <string>EqualTo</string>
                       <string>1</string>
                     </Parameters>
                   </Data>
                   <Not>false</Not>
                   <Operator>And</Operator>
                 </ExpressionComponent>
                 <ExpressionComponent xsi:type="ConditionalCall">
                   <Data>
                     <FullName>Boolean IsGlobalValue(String, Operator, Int32)</FullName>
                     <Parameters>
                       <string>n_Sanitarium_Quest_Stage</string>
                       <string>EqualTo</string>
                       <string>0</string>
                     </Parameters>
                   </Data>
                   <Not>false</Not>
                   <Operator>And</Operator>
                 </ExpressionComponent>
               </Components>
             </ExpressionComponent>
           </Components>
         </ExpressionComponent>
       </Components>
     </Conditionals>

In more readable terms it is:

IsGlobalValue(b_Disable_Knight_Barks, EqualTo, 0) AND ((IsGlobalValue(bReceivedAcolyteHeritageHillVision, EqualTo, 1) AND IsGlobalValue(n_HH_Quest_Stage, EqualTo, 0)) OR (IsGlobalValue(bReceivedAcolyteSanitariumVision, EqualTo, 1) AND IsGlobalValue(n_Sanitarium_Quest_Stage, EqualTo, 0)))

or if you like the programming aspect more:

b_Disable_Knight_Barks == 0 && ((bReceivedAcolyteHeritageHillVision == 1 && n_HH_Quest_Stage == 0) || (bReceivedAcolyteSanitariumVision == 1 && n_Sanitarium_Quest_Stage == 0))



Conditional Functions[edit | edit source]

There are currently (1.0.6) 79 conditional functions which can be used in a logical formula. All of them evaluate to a logical value. The following table lists all of them, including a short description.

The following is a list of all available condition checks (in version 1.0.6)

name category xml description param0 param1 param2 param3 param4
Is Active General Boolean IsActive(Guid) Checks if the Object is active (on the same map?) name:Object, description: Object to check., default: , type: Guid
Is Companion Active In Party General Boolean IsCompanionActiveInParty(Guid) Checks if the named Companion is in the current Party name:Companion, description: Companion to check., default: , type: Guid
Is Any Companion Active In Party General Boolean IsAnyCompanionActiveInParty() Checks if Party is bigger than one,
Is Slot Active General Boolean IsSlotActive(Int32) Checks if the given Party Slot is used, slot range from 0 to 5 name:Slot, description: Slot to check., default: 0
Is Player In Slot General Boolea IsPlayerInSlot(Int32) Checks if the Player Charackter is in this slot. slot range from 0 to 5 name:Slot, description: Slot to check., default: 0
Is Currently Daytime Time Boolean IsCurrentlyDaytime() Checks if ingame is daytime. Daytime is from 6 to 20 o'Clock,
Is Currently Nighttime Time Boolean IsCurrentlyNighttime() Checks if ingame is nigthtime. Nighttime is from 20 to 6 o'Clock,
Is In Combat General Boolean IsInCombat() Checks if Combat is active,
Has Combat Time Elapsed General Boolean HasCombatTimeElapsed(Single) Checks if the combat takes more or equal seconds than the given value name:Seconds, description: The length of time in seconds to compare against combat duration., default: 1.0
Is In Stealth Mode General Boolean IsInStealth() Checks stealth mode,
Has Been Detected Detectable Boolean HasBeenDetected(Guid) Checks if the Character is detected name:Object, description: The detectable, default: , type: Guid
Is In Volume General Boolean IsInVolume(Guid, Guid) Checks if the Object 1 Int32ersects with Object 2 name:Object, description: The object to check, default: , type: Guid name:Object, description: The object with a collider to check against, default: , type: Guid
Command Line Arg Set General Boolean CommandLineArg(String) Checks if the commandline contains this argument. The game code uses \bb\ and \e3\. name:Arg, description: The arg to check to see if it was set., default:
Is Global Value Globals Boolean IsGlobalValue(String, Operator, Int32) Gives the compare result of the global variable to the value name:Tag, description: Tag of the global variable to query., default: GlobalTag, type: GlobalVariable name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the global variable against this value., default: 0
Compare Globals Globals Boolean CompareGlobals(String, Operator, String) Compares 2 global variables with the operator name:Global 1, description: Tag of the first global variable to query., default: GlobalTag, type: GlobalVariable name:Operator, description: Comparison operator., default: EqualTo name:Global 2, description: Tag of the second global variable to query., default: GlobalTag, type: GlobalVariable
Has Conversation Node Been Played Conversation Boolean HasConversationNodeBeenPlayed(String, Int32) Checks if the ID of the conversation file has been played name:Conversation, description: Name of the conversation., default: , type: Conversation name:Conversation Node ID, description: Conversation node ID., default: 0
Is Quest On Node Quest Boolean IsQuestOnNode(String, Int32) Checks if the quest is currently on the given id name:Quest Name, description: Name of the quest., default: , type: Quest name:Quest Node ID, description: Quest node ID., default: 0
Is Quest Event Triggered Quest Boolean IsQuestEventTriggered(String, Int32) Checks if the quest event with the given id was triggerd, type: QuestEvent name:Quest Name, description: Name of the quest., default: , type: Quest name:Quest Event ID, description: Quest Event ID., default: -1
Is Quest Addendum Triggered Quest Boolean IsQuestAddendumTriggered(String, Int32) Checks if the quest addendum with the given id was triggerd name:Quest Name, description: Name of the quest., default: , type: Quest name:Addendum ID, description: Addendum ID to test., default: 0
Is Quest End State Triggered Quest Boolean IsQuestEndStateTriggered(String, Int32) Checks if the quest is on this endstate name:Quest Name, description: Name of the quest., default: , type: Quest name:End State ID, description: End State ID to test., default: 0
Is Quest Failed Quest Boolean IsQuestFailed(String) Checks if the quest was abborted/ failed name:Quest Name, description: Name of the quest., default: , type: Quest
Is Distance Misc Boolean IsDistance(Guid, Guid, Operator, Single) Checks the distance between A and B against the given value name:Object A, description: Object A to test., default: , type: Guid name:Object B, description: Object B to test., default: , type: Guid name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the distance between A and B against this value., default: 0
Is Easy Difficulty Boolean IsEasy() Is easy difficulty,
Is Normal Difficulty Boolean IsNormal() Is nomral difficulty,
Is Hard Difficulty Boolean IsHard() Is hard or Path Of The Damned difficulty,
Is Team Relationship Scripts\\Faction Boolean IsTeamRelationship(String, String, Relationship) Checks if the relationship between two teams is the given value. \player\ is the special Value for the player team. name:Team A, description: The first team to check, default: name:Team B, description: The second team to check, default: name:Relationship, description: How team A and B will relate to each other, default: Neutral
Reputation Rank Equals Faction Boolean ReputationRankEquals(Guid, Axis, Int32) Checks if the Rank to this Faction is at the given amount. Valid values range from 0 to 5 name:Object, description: Object to check., default: , type: Guid name:Axis, description: Type of rank to check, default: Benevolent name:Ranks, description: Ranks check amount, default: 0
Tagged Reputation Rank Equals Faction Boolean ReputationRankByTagEquals(FactionName, Axis, Int32) Checks if the Rank to this Named Faction is at a given amount. Valid values range from 0 to 5 name:Faction Name, description: Faction to modify, default: None name:Axis, description: Type of rank to check, default: Benevolent name:Ranks, description: Ranks check amount, default: 0
Reputation Rank Greater or Equal Faction Boolean ReputationRankGreater(Guid, Axis, Int32) Checks if the Rank to this Faction is greater or equal the given amount. Valid values range from 0 to 5 name:Object, description: Object to check, default: name:Axis, description: Type of rank to check, default: Benevolent name:Ranks, description: Ranks check amount, default: 0
Tagged Reputation Rank Greater or Equal Faction Boolean ReputationTagRankGreater(FactionName, Axis, Int32) Checks if the Rank to this Named Faction is greater or equal the given amount. Valid values range from 0 to 5 name:Faction Name, description: Faction to check, default: None name:Axis, description: Type of rank to increase, default: Benevolent name:Ranks, description: Ranks change amount, default: 0
Disposition Equal Faction Boolean DispositionEqual(Axis, Rank) Returns true if rank is equal to this value. name:Axis, description: The disposition type to check, default: Benevolent name:Rank, description: Returns true if rank is equal to this value., default: None
Disposition Greater or Equal Faction Boolean DispositionGreaterOrEqual(Axis, Rank) Returns true if rank is equal or greater to this value. name:Axis, description: The disposition type to check, default: Benevolent name:Rank, description: Returns true if rank is greater or equal to this value., default: None
Is Health Value Health Boolean IsHealthValue(Guid, Operator, Single) Checks Ojbect health with given operator agains value name:Object, description: Object to test., default: , type: Guid name:Operator, description: Comparison operator., default: EqualTo name:Health Value, description: Compare the object's health against this value., default: 0
Is Health Percentage Health Boolean IsHealthPercentage(Guid, Operator, Single) Checks Ojbect health with operator agains percentage (0-100) name:Object, description: Object to test., default: , type: Guid name:Operator, description: Comparison operator., type: EqualTo name:Health Percentage, description: Compare the object's health against this percentage., default: 0
Is Stamina Value Health Boolean IsStaminaValue(Guid, Operator, Single) Checks Ojbect stamina with operator agains value name:Object, description: Object to test., default: , type: Guid name:Operator, description: Comparison operator., default: EqualTo name:Stamina Value, description: Compare the object's statmina against this value., default: 0
Is Stamina Percentage Health Boolean IsStaminaPercentage(Guid, Operator, Single) Checks Ojbect stamina with operator agains percentage (0-100) name:Object, description: Object to test., default: , type: Guid name:Operator, description: Comparison operator., default: EqualTo name:Stamina Percentage, description: Compare the object's stamina against this percentage., default: 0
Is Item Count Items Boolean IsItemCount(String, Operator, Int32) Checks the count of the named item in active party inventorys and the stash with operator against the value name:Item Name, description: Name of the item, default: ItemName name:Operator, description: Comparison operator., default: EqualTo name:Count, description: Compare the item count against this value., default: 0
Is Item Equipped Items Boolean IsItemEquipped(Guid, String) Checks if the Charackter has the named item equipped name:Object, description: object, default: , type: Guid name:Item Name, description: Name of the item, default: ItemName
Is Item Equipped On Player Items Boolean IsItemEquippedOnPlayer(String) Checks if any of the active party member has the named item equipped name:Item Name, description: Name of the item, default: ItemName
Has Money Items Boolean HasMoney(Operator, Int32) Checks the amount of money with the operator against the given value name:Operator, description: Comparison operator., default: EqualTo name:Amount, description: Compare the player's money against this value., default: 0
Object Has Item Count Items Boolean ObjectHasItemCount(Guid, String, Operator, Int32) Checks the count of the named item on this Object name:Object, description: Object with an inventory., default: , type: Guid name:Item Name, description: Name of the item, default: ItemName name:Operator, description: Comparison operator., default: EqualTo name:Count, description: Compare the item count against this value., default: 0
Is Weapon Type Equipped In Primary Slot Items Boolean IsWeaponTypeEquippedInPrimarySlot(Guid, WeaponType) Checks if the Object has this weapon type equiped in the primary slot name:Object, description: object, default: , type: Guid name:Weapon Type, description: Type of Weapon, default: Arbalest
Is OCL In A State OCL Boolean IsOCLInState(Guid, State) Checks if the Chest or Door is in the given State name:Object, description: Object to test., default: , type: Guid name:State to test, description: State, default: Closed
Is Attribute Score Value RPG Boolean IsAttributeScoreValue(Guid, AttributeScoreType, Operator, Int32) Checks if the Object matches the given Attribute value to the operator name:Object, description: Object to test., default: , type: Guid name:Attribute, description: Attribute to test., default: Resolve name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's attribute score against this value., default: 0
Is Player Attribute Score Value RPG Boolean IsPlayerAttributeScoreValue(AttributeScoreType, Operator, Int32) Checks if the Player matches the given Attribute value to the operator name:Attribute, description: Attribute to test., default: Resolve name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's attribute score against this value., default: 0
Is Slot Attribute Score Value RPG Boolean IsSlotAttributeScoreValue(Int32, AttributeScoreType, Operator, Int32) Checks if the Character in the given Partyslot matches the given Attribute value to the operator name:Slot, description: slot to test., default: 0 name:Attribute, description: Attribute to test., default: Resolve name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's attribute score against this value., default: 0
Is Defense Value RPG Boolean IsDefenseValue(Guid, DefenseType, Operator, Int32) Test the objects defensetype value with the operator agains the value name:Object, description: Object to test., default: , type: Guid name:Defense Type, description: Defense to test., default: Deflect name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's defense against this value., default: 0
Is Player Defense Value RPG Boolean IsPlayerDefenseValue(DefenseType, Operator, Int32) Test the players defensetype value with the operator agains the value name:Defense Type, description: Defense to test., default: Deflect name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's defense against this value., default: 0
Is Skill Value RPG Boolean IsSkillValue(Guid, SkillType, Operator, Int32) Tests the skillvalue of the Object with the operator against the value name:Object, description: Object to test., default: , type: Guid name:Skill Type, description: Skill to test., default: Stealth name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's skill against this value., default: 0
Is Party Skill Value Count RPG Boolean IsPartySkillValueCount(SkillType, Operator, Int32, Operator, Int32) Tests the given skill value of all Partymembers and counts the passes, then checks the count with the operator against the value name:Skill Type, description: Skill to test., default: Stealth name:Skill Operator, description: Comparison operator., default: EqualTo name:Skill Value, description: Compare the object's skill against this value., default: 0 name:Party Operator, description: Compare the party count with this operator., default: EqualTo name:Party Value, description: Compare how many party members pass., default: 0
Is Player Skill Value RPG Boolean IsPlayerSkillValue(SkillType, Operator, Int32) Tests the skillvalue of the Player with the operator against the value name:Skill Type, description: Skill to test., default: Stealth name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's skill against this value., default: 0
Is Slot Skill Value RPG Boolean IsSlotSkillValue(Int32, SkillType, Operator, Int32) Checks if the Character in the given Partyslot matches the given Skill value to the operator name:Slot, description: slot to test., default: 0 name:Skill Type, description: Skill to test., default: Stealth name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the object's skill against this value., default: 0
Is Player Character Using S.I. RPG Boolean IsPlayerCharacterUsingSI() Checks if the Player is in a scrited Int32eraction,
Is Player Character Skill Check 0 RPG Boolean IsPlayerCharacterSkillCheckZero() Checks if the Player Character succeceds the script call of SetSkillCheckToken(…),
Is Class RPG Boolean IsClass(Guid, Class) Checks the class of the Object agains value name:Object, description: Object to test., default: , type: Guid name:Class, description: Class to test., default: Fighter
Is Player Class RPG Boolean IsPlayerClass(Class) Checks the class of the Player against value name:Class, description: Class to test., default: Fighter
Is Race RPG Boolean IsRace(Guid, Race) Checks the race of the Object against value name:Object, description: Object to test., default: , type: Guid name:Race, description: Race to test., default: Human
Is Player Race RPG Boolean IsPlayerRace(Race) Checks the race of the Player against value name:Race, description: Race to test., default: Human
Is Subrace RPG Boolean IsSubrace(Guid, Subrace) Checks the subrace of the Object against value name:Object, description: Object to test., default: , type: Guid name:Subrace, description: Subrace to test., default: Meadow_Human
Is Player Subrace RPG Boolean IsPlayerSubrace(Subrace) Checks the subrace of the Playcer against value name:Subrace, description: Subrace to test., default: Meadow_Human
Is Gender RPG Boolean IsGender(Guid, Gender) Checks the gender of the Object against value name:Object, description: Object to test., default: , type: Guid name:Gender, description: Gender to test., default: Male
Is Player Gender RPG Boolean IsPlayerGender(Gender) Checks the gender of the Player against value name:Gender, description: Gender to test., default: Male
Is Slot Gender RPG Boolean IsSlotGender(Int32, Gender) Checks the character gender at the given slot against value name:Slot, description: Slot to test, default: 0 name:Gender, description: Gender to test., default: Male
Has Talent or Ability RPG Boolean HasTalentOrAbility(Guid, String) Checks if the Object posses the named Ability name:Object, description: Object to test., default: , type: Guid name:Ability Name, description: Name of the ability, default: AbilityName
Is Deity RPG Boolean IsDeity(Guid, Deity) Checks if the Object has this Deity value name:Object, description: Object to test., default: , type: Guid name:Deity, description: Deity to test., default: Berath
Is Paladin Order RPG Boolean IsPaladinOrder(Guid, PaladinOrder) Checks if the Object has the named Paladin Order name:Object, description: Object to test., default: , type: Guid name:Paladin Order, description: Paladin order to test., default: BleakWalkers
Is Culture RPG Boolean IsCulture(Guid, Culture) Checks if the Object has the named culture name:Object, description: Object to test., default: , type: Guid name:Culture, description: Culture to test., default: Aedyr
Is Player Culture RPG Boolean IsPlayerCulture(Culture) Checks if the Player has the named culture name:Culture, description: Culture to test., default: Aedyr
Is Background RPG Boolean IsBackground(Guid, Background) Checks if the Object has the named background name:Object, description: Object to test., default: , type: Guid name:Background, description: Background to test., default: 0
Is Player Background RPG Boolean IsPlayerBackground(Background) Checks if the Player has the named background name:Background, description: Background to test., default: 0
Current Map Is Stronghold Stronghold Boolean CurrentMapIsStronghold() Checks if on the Strongholdmap,
Can Add Prisoner Stronghold Boolean CanAddPrisoner() Checks if Prison is build,
Stronghold Has Prisoner Stronghold Boolean StrongholdHasPrisoner(Guid) Checks if the Object is Prisoner in the Stronghold name:Object, description: Prisoner object to check against, default: , type: Guid
Stronghold Has Prisoner Stronghold Boolean StrongholdHasPrisoner(String) Checks if the Person with this name is in the Prison name:Prisoner Name, description: The name of the prisoner, default: PrisonerName
StrongholdHasUpgrade Stronghold Boolean StrongholdHasUpgrade(Type) Checks if the Stronghold upgrade is build name:Upgrade Type, description: Upgrade to check., default: None
StrongholdIsBuildingUpgrade Stronghold Boolean StrongholdIsBuildingUpgrade(Type) Checks if the Stronghold upgrade is in the works name:Upgrade Type, description: Upgrade to check., default: None
Stronghold Is Companion available Stronghold Boolean StrongholdIsCompanionAvaliable(Guid) Checks if the Object/Companion is in the Stronghold name:Object, description: Companion object to check against, default: , type: Guid
Stronghold Is Security Value Stronghold Boolean StrongholdIsSecurityValue(Operator, Int32) Checks the Stronghold Security Value with operator against value name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the stronghold's Security score against this value., default: 0
Stronghold Is Prestige Value Stronghold Boolean StrongholdIsPrestigeValue(Operator, Int32) Checks the Stronghold Prestige Value with operator against value name:Operator, description: Comparison operator., default: EqualTo name:Value, description: Compare the stronghold's Prestige score against this value., default: 0