Osiris API Tips Queries

From Divinity Engine Wiki
Revision as of 11:02, 2 August 2017 by Larian octaaf (talk | contribs) (Created page with "<h3>Queries</h3> <p>Queries request information about the state of the world from Osiris. They can be used in the part of a rule that checks conditions. Queries almost always...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Queries

Queries request information about the state of the world from Osiris. They can be used in the part of a rule that checks conditions. Queries almost always succeed, except if you pass an initialised value as an [out] parameter and it does not match the value the query would returns. Below, this will be called the Default Return Value. If a query can also fail under other circumstances, this will be mentioned.


CharacterGetEquippedItem

Full definitions

  • query CharacterGetEquippedItem([in](CHARACTERGUID)_Character, [in](STRING)_Slotname, [out](GUIDSTRING)_ItemGUID)

Description

Returns in _ItemGUID the item equipped by _Character in slot _Slotname, if any.

Return values

  • <b><b>Success/Failure: </b></b>Fails if _Character does not exist, or if no item is equipped in _Slotname.
  • _ItemGuid: The item equipped by _Character in _Slotname.
  • </ul>

    Notes

    • The valid values for _Slotname are: Helmet, Amulet, Breast, Belt, Gloves, Leggings, Boots, Weapon, Shield, Ring, Ring2.

    See also

    • CharacterUnequipItem

    CharacterGetHenchmanPresetPrice

    Full definitions

    • query CharacterGetHenchmanPresetPrice([in](STRING)_Preset, [in](CHARACTERGUID)_Character[out](INTEGER)_Price)

    Description

    Returns the price of the preset scaled to the level of _Character.

    Return values

    • _Price: The price of the preset scaled to the level of _Character.

    Notes

    • Presets come from the folder ".../DOS2/Data/Mods/Shared/CharacterCreation/HenchmanPresets/"
    • Presets can be customized using the following documentation: link

    See also

    • CharacterApplyHenchmanPreset

    CharacterIsAlly

    Full definitions

    • query CharacterIsAlly([in](CHARACTERGUID)_Character, <i><b>[in]</b>(CHARACTERGUID)</i><b>_OtherCharacter</b>,<i><b> [out]</b></i>(INTEGER)_Bool)
    • </ul>

      Description

      Returns whether _Character is an ally of _OtherCharacter.

      Return values

      • <b><b>Success/Failure:</b></b> Default return value.
      • _Bool: 1 if _Character and _OtherCharacter are allies, 0 if not.
      • </ul>

        Notes

        • Also works outside combat.
        • If _Character or _OtherCharacter is dead or dying, the result solely depends on the characters' alignments (factions). If they are alive, it is also influenced by temporary hostile relations, e.g. induced by attacking a neutral character.

        See also

        • CharacterIsNeutral
        • CharacterIsEnemy

        CharacterIsEnemy

        Notes

        • See CharacterIsAlly for detailed information, except that this query returns whether the characters are enemies.

        See also

        • CharacterIsAlly
        • CharacterIsEnemy

        CharacterIsNeutral

        Notes

        • See CharacterIsAlly for detailed information, except that this query returns whether the characters are neutral.

        See also

        • CharacterIsAlly
        • CharacterIsEnemy

        CharacterIsPartyFollower

        Full definitions

        • query CharacterIsPartyFollower([in](CHARACTERGUID)_Character, [out](INTEGER)_Bool)

        Description
        </div>

        Returns whether _Character is a character that follows a player character around. An NPC can be instructed to do so through CharacterFollowCharacter.

        Return values

        • <b><b>Success/Failure: </b></b>Fails if _Character does not exist.
        • _Bool: 1 if _Character is a party follower, 0 if not.
        • </ul>

          Notes

          • CharacterIsPlayer will also return true for party followers.

          See also

          • CharacterIsPlayer
          • CharacterFollowCharacter

          CharacterIsPlayer

          Full definitions

          • query CharacterIsPlayer([in](CHARACTERGUID)_Character, [out](INTEGER)_Bool)

          Description
          </div>

          Returns whether _Character is player-controlled.

          Return values

          • <b><b>Success/Failure: </b></b>Fails if _Character does not exist.
          • _Bool: 1 if _Character is player-controlled, 0 if not.
          • </ul>

            Notes

            • Apart from avatars and recruited companions, player-controlled characters also include summons and followers.

            See also

            • CharacterIsPartyFollower
            • CharacterIsSummon
            • CharacterFollowCharacter

            CharacterIsSummon

            Full definitions

            • query CharacterIsSummon([in](CHARACTERGUID)_Character, [out](INTEGER)_Bool)

            Description

            Returns whether _Character is a summon. Summon can be player-controlled or not.

            Return values

            • <b><b>Success/Failure: </b></b>Fails if _Character does not exist.
            • _Bool: 1 if _Character is a summon, 0 if not.
            • </ul>

              Notes


              • Summons can also be distinguished by the fact that hey have the SUMMON tag.
              • If you wish to know whether a summon is player-controlled, also check CharacterIsPlayer.

              See also

              • CharacterIsPlayer

              GetClosestAlivePlayer

              Full definitions

              • query GetClosestAlivePlayer([in](GUIDSTRING)_Target, [out](CHARACTERGUID)_Player)

              Description
              </div>

              Gets the closest player to _Target that is alive and stores it in _Player.

              Return values

              • <b><b><b>Success/Failure: </b></b></b>Fails if no living player is found.
              • _Player: The found player character.
              • </ul>

                Notes

                • Be careful if you check for extra conditions on the returned player: if any of those conditions fail, no other players will be considered.
                • If you want to start a dialog, use ProcGetClosestAvailableCharacterTo

                See also

                • Helper ProcGetClosestAvailableCharacterTo

                GetDistanceTo

                Full definitions

                • query GetDistanceTo([in](GUIDSTRING)_Object1, [in](GUIDSTRING)_Object2, [out](REAL)_Dist)

                Description

                Calculates the distance between _Object1 and _Object2.

                Return values

                • Success/Failure: Fails if if either _Object1 or _Object2 is in a container or in an inventory. Use ItemIsInInventory to check for this.
                • _Dist: The distance in metres.

                Notes

                • /

                See also

                • ItemIsInInventory

                GetInventoryOwner

                Full definitions

                • query GetInventoryOwner([in](ITEMGUID)_Item, [out](GUIDSTRING)_Owner)

                Description

                Returns the inventory/container that holds _Item in _Owner.

                Return values

                • Success/Failure: Fails if _Item is not in anyone's inventory nor in a container.
                • _Owner: The character or item in whose inventory the item currently resides.

                Notes

                • This call returns the outermost container. I.e., if a character has crate in their inventory, and the crate contains a pouch with the item, this call will return the character.

                See also

                • ItemIsInInventory

                GetRandomPositionInTrigger

                Full definitions

                • query GetRandomPositionInTrigger([in](TRIGGERGUID)_Trigger, [out](REAL)_X, [out](REAL)_Y, [out](REAL)_Z)

                Description

                Returns a random position that is valid on the AI-grid inside _Trigger.

                Return values

                • Success/Failure: Default return value.
                • _Trigger: A box trigger inside which the random position should be gotten.
                • _X, _Y, _Z: the coordinates of the random position

                Notes

                • This routine will first get a random position in the trigger, and if this random position is not valid on the AI-grid, the coordinates will be snapped to a nearby valid position on the AI-grid.
                • This call does not work for polytriggers

                See also

                • /

                HasActiveStatus

                Full definitions

                • query HasActiveStatus([in](GUIDSTRING)_Target, [in](STRING)_Status, [out](INTEGER)_Bool)

                Description

                Returns whether _Target is currently under the influence of _Status.

                Return values

                • Success/Failure: Default return value.
                • _Bool: 0 if _Target is currently not under the influence of _Status, 1 if it is.

                Notes

                • /

                See also

                • HasAppliedStatus

                HasAppliedStatus

                Full definitions

                • query HasAppliedStatus([in](GUIDSTRING)_Target, [in](STRING)_Status, [out](INTEGER)_Bool)

                Description

                Returns whether _Status has been applied to _Target. _Target may or may not yet actually be under its influence.

                Return values

                • <b>Success/Failure: </b>Default return value.
                • _Bool: 0 if _Status has not been applied to _Target, 1 if it has been.
                • </ul>

                  Notes

                  • In virtually all cases, use HasActiveStatus instead. The main purpose of this query is for crime reactions, and is only needed due to frame delays between code and Osiris.

                  See also

                  • HasActiveStatus

                  IsSpeakerReserved

                  Full definitions

                  • query IsSpeakerReserved([in](GUIDSTRING)_Speaker, [out](INTEGER)_success)

                  Description

                  Returns whether _Speaker is already in a dialog.

                  Return values

                  • <b>Success/Failure: </b>Default return value.
                  • _success: 0 if _Speaker is currently not in a dialog, 1 otherwise.
                  • </ul>

                    Notes

                    • /

                    See also

                    • DialogStartRequested
                    • Proc_StartDialog

                    ItemIsInInventory

                    Full definitions

                    • query ItemIsInInventory([in](ITEMGUID)_Item, [out](INTEGER)_Bool)

                    Description

                Returns whether _Item is in an inventory. This includes both character and container inventories.

                Return values

                • <b>Success/Failure: </b>Default return value.
                • _Bool: 0 if _Item is not in an inventory (as defined above), 1 if it is.
                • </ul>

                  Notes

                  • /

                  See also

                  • GetInventoryOwner