Difference between revisions of "Osiris API Tips Queries"

From Divinity Engine Wiki
Jump to: navigation, search
(Blanked the page)
Line 1: Line 1:
<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 succeed, except if you pass an initialised value as an <b><i>[out]</i></b> parameter and it does not match the value the query would returns. Below, this will be called the <b>Default Return Value</b>. If a query can also fail under other circumstances, this will be mentioned.<br>
 
</p>
 
<p><br>
 
</p>
 
<div>
 
<div>
 
<h4 style="font-size:1.1em;color:rgb(36,53,93)">CharacterGetEquippedItem</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>CharacterGetEquippedItem</b>(<i><b>[in]</b>(CHARACTERGUID)</i><b>_Character</b>,<i><b> [in]</b>(STRING)</i><b>_Slotname</b>,<i><b> [out]</b></i>(<i>GUIDSTRING</i>)<b>_ItemGUID</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Returns in <b>_ItemGUID</b> the item equipped by <b>_Character</b> in slot <b>_Slotname</b>, if any.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b><b>Success/Failure</b>: </b></b>Fails if <b>_Character</b> does not exist, or if no item is equipped in <b>_Slotname</b>.<br>
 
</li>
 
<li><b>_ItemGuid</b>: The item equipped by <b>_Character</b> in <b>_Slotname.</b><br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>The valid values for <b>_Slotname</b> are: <b>Helmet</b>, <b>Amulet</b>, <b>Breast</b>, <b>Belt</b>, <b>Gloves</b>, <b>Leggings</b>, <b>Boots</b>, <b>Weapon</b>, <b>Shield</b>, <b>Ring</b>, <b>Ring2</b>.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterUnequipItem</b><br>
 
</li></ul>
 
<div>
 
<h4>CharacterGetHenchmanPresetPrice</h4>
 
<div style="font-size:13.3333px">
 
<p style="font-size:13.3333px"><u>Full definitions</u></p>
 
<ul style="font-size:13.3333px"><li>query&nbsp;<b>CharacterGetHenchmanPresetPrice</b>(<i><b>[in]</b></i>(STRING)<b>_Preset</b>,<b>&nbsp;</b><i style="font-size:13.3333px"><b>[in]</b>(CHARACTERGUID)</i><b style="font-size:13.3333px">_Character</b><span style="font-size:13.3333px">,&nbsp;<b><i>[out]</i></b><i>(INTEGER)</i><b>_Price</b></span>)</li></ul>
 
<u style="font-size:13.3333px">Description</u><br style="font-size:13.3333px">
 
<p style="font-size:13.3333px">Returns the price of the preset scaled to the level of&nbsp;<b>_Character</b>.<br>
 
</p>
 
<p style="font-size:13.3333px"><u>Return values</u></p>
 
<ul style="font-size:13.3333px"><li><b>_Price</b>: The price of the preset scaled to the level of&nbsp;<b>_Character.</b><br>
 
</li></ul>
 
<p style="font-size:13.3333px"><u>Notes</u></p>
 
<ul style="font-size:13.3333px"><li>Presets come from the folder&nbsp;<b>".../DOS2/Data/Mods/Shared/CharacterCreation/HenchmanPresets/"</b></li>
 
<li>Presets can be customized using the following documentation:&nbsp;<b>link</b></li></ul>
 
<div>
 
<p style="font-size:13.3333px"><u>See also</u></p>
 
<ul style="font-size:13.3333px"><li><b>CharacterApplyHenchmanPreset</b><br>
 
</li></ul>
 
</div>
 
</div>
 
</div>
 
<div>
 
<div>
 
<h4>CharacterIsAlly</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>CharacterIsAlly</b>(<i><b>[in]</b>(CHARACTERGUID)</i><b>_Character</b>,<i><b> </b></i><i><b><i><b>[in]</b></i></b><i>(CHARACTERGUID)</i></i><b><b>_OtherCharacter</b></b><i><b>,<i><b> </b></i>[out]</b></i>(INTEGER)<b>_Bool</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Returns whether <b>_Character</b> is an ally of <b>_OtherCharacter</b>.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b><b>Success/Failure</b>:</b></b> Default return value.<br>
 
</li>
 
<li><b>_Bool</b>: <b>1</b> if <b>_Character</b> and <b>_OtherCharacter </b>are allies, <b>0</b> if not<b>.</b><br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>Also works outside combat.</li>
 
<li>If <b>_Character</b> or <b>_OtherCharacter</b> 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.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterIsNeutral</b></li>
 
<li><b>CharacterIsEnemy<br>
 
</b></li></ul>
 
<h4>CharacterIsEnemy</h4>
 
<p><u>Notes</u></p>
 
<ul><li>See <b>CharacterIsAlly</b> for detailed information, except that this query returns whether the characters are enemies.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterIsAlly</b></li>
 
<li><b>CharacterIsEnemy<br>
 
</b></li></ul>
 
<h4>CharacterIsNeutral</h4>
 
<p><u>Notes</u></p>
 
<ul><li>See <b>CharacterIsAlly</b> for detailed information, except that this query returns whether the characters are neutral.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterIsAlly</b></li>
 
<li><b>CharacterIsEnemy<br>
 
</b></li></ul>
 
<h4>CharacterIsPartyFollower</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>CharacterIsPartyFollower</b>(<i><b>[in]</b>(CHARACTERGUID)</i><b>_Character</b>,<i><b> </b></i><i><b>[out]</b></i>(INTEGER)<b>_Bool</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Returns whether <b>_Character</b> is a character that follows a player character around. An NPC can be instructed to do so through <b>CharacterFollowCharacter</b>.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b><b>Success/Failure</b>: </b></b>Fails if <b>_Character</b> does not exist<b>.</b><br>
 
</li>
 
<li><b>_Bool</b>: <b>1</b> if <b>_Character</b> is a party follower, <b>0</b> if not<b>.</b><br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li><b>CharacterIsPlayer</b> will also return true for party followers.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterIsPlayer</b></li>
 
<li><b>CharacterFollowCharacter</b></li></ul>
 
<h4>CharacterIsPlayer</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>CharacterIsPlayer</b>(<i><b>[in]</b>(CHARACTERGUID)</i><b>_Character</b>,<i><b> </b></i><i><b>[out]</b></i>(INTEGER)<b>_Bool</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Returns whether <b>_Character</b> is <i>player-controlled</i>.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b><b>Success/Failure</b>: </b></b>Fails if <b>_Character</b> does not exist<b>.</b><br>
 
</li>
 
<li><b>_Bool</b>: <b>1</b> if <b>_Character</b> is <i>player-controlled</i>, <b>0</b> if not<b>.</b><br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>Apart from avatars and recruited companions, <i>player-controlled</i> characters also include summons and followers.</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterIsPartyFollower</b></li>
 
<li><b>CharacterIsSummon</b></li>
 
<li><b>CharacterFollowCharacter</b></li></ul>
 
<h4>CharacterIsSummon</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>CharacterIsSummon</b>(<i><b>[in]</b>(CHARACTERGUID)</i><b>_Character</b>,<i><b> </b></i><i><b>[out]</b></i>(INTEGER)<b>_Bool</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Returns whether <b>_Character</b> is a summon. Summon can be <i>player-controlled</i> or not.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b><b>Success/Failure</b>: </b></b>Fails if <b>_Character</b> does not exist<b>.</b><br>
 
</li>
 
<li><b>_Bool</b>: <b>1</b> if <b>_Character</b> is a summon, <b>0</b> if not<b>.</b><br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li><br>
 
</li>
 
<li>Summons can also be distinguished by the fact that hey have the <b>SUMMON</b> tag.</li>
 
<li>If you wish to know whether a summon is <i>player-controlled</i>, also check <b>CharacterIsPlayer</b>.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterIsPlayer</b></li></ul>
 
<h4>GetClosestAlivePlayer</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <span style="font-family:arial,sans-serif"><b>GetClosestAlivePlayer</b></span>(<i><b>[in]</b>(GUIDSTRING)</i><b>_Target</b>, <i><b>[out]</b>(CHARACTERGUID)</i><b>_Player</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<div>
 
<p>Gets the closest player to <b>_Target</b> that is alive and stores it in <b>_Player</b>.</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b><b><b>Success/Failure</b>: </b></b></b>Fails if no living player is found.<br>
 
</li>
 
<li><b>_Player</b>: The found player character.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>Be careful if you check for extra conditions on the returned player: if any of those conditions fail, no other players will be considered.</li>
 
<li>If you want to start a dialog, use <b><span style="font-family:arial,sans-serif">ProcGetClosestAvailableCharacterTo</span></b></li></ul>
 
<p><u>See also</u></p>
 
<ul><li>Helper <b><span style="font-family:arial,sans-serif">ProcGetClosestAvailableCharacterTo</span></b></li></ul>
 
<div>
 
<div>
 
<h4>GetDistanceTo</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <span style="font-family:arial,sans-serif"><b>GetDistanceTo</b></span>(<i><b>[in]</b>(GUIDSTRING)</i><b>_Object1</b>, <i><b>[in]</b>(GUIDSTRING)</i><b>_Object2</b>, <i><b>[out]</b>(REAL)</i><b>_Dist</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Calculates the distance between <b>_Object1</b> and <b>_Object2</b>.</p>
 
<p><u>Return values</u></p>
 
<ul><li><b>Success/Failure</b>: Fails if <span style="font-family:arial,sans-serif">if either <b>_Object1</b> or _<b>Object2</b> is in a container or in an inventory. Use <b>ItemIsInInventory</b> to check for this.</span></li>
 
<li><b>_Dist</b>: The distance in metres.</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li><span style="font-family:arial,sans-serif">/</span><br>
 
</li></ul>
 
<p><u>See also<br>
 
</u></p>
 
<ul><li><b>ItemIsInInventory</b><br>
 
</li></ul>
 
<h4>GetInventoryOwner</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>GetInventoryOwner</b>(<i><b>[in]</b>(ITEMGUID)</i><b>_Item</b>, <i><b>[out]</b>(GUIDSTRING)</i><b>_Owner</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Returns the inventory/container that holds <b>_Item</b> in <b>_Owner</b>.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b>Success/Failure</b>: Fails if <b>_Item</b> is not in anyone's inventory nor in a container.<br>
 
</li>
 
<li><b>_Owner</b>: The character or item in whose inventory the item currently resides.<br>
 
</li></ul>
 
<p><u>Notes<br>
 
</u></p>
 
<ul><li>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.<br>
 
</li></ul>
 
<p><u>See also<br>
 
</u></p>
 
<ul><li><b>ItemIsInInventory</b><br>
 
</li></ul>
 
<h4>GetRandomPositionInTrigger</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>GetRandomPositionInTrigger</b>(<i><b>[in]</b>(TRIGGERGUID)</i><b>_Trigger</b>, <i><b>[out]</b>(REAL)</i><b>_X</b>, <i><b>[out]</b>(REAL)</i><b>_Y</b>, <i><b>[out]</b>(REAL)</i><b>_Z</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Returns a random position <i>that is valid on the AI-grid</i> inside <b>_Trigger</b>.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b>Success/Failure</b>: Default return value.<br>
 
</li>
 
<li><b>_Trigger</b>: A box trigger inside which the random position should be gotten.<br>
 
</li>
 
<li><b>_X</b>, <b>_Y</b>, <b>_Z</b>: the coordinates of the random position<br>
 
</li></ul>
 
<p><u>Notes<br>
 
</u></p>
 
<ul><li>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.</li>
 
<li>This call does not work for polytriggers</li></ul>
 
<p><u>See also<br>
 
</u></p>
 
<ul><li>/<br>
 
</li></ul>
 
<h4>HasActiveStatus</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>HasActiveStatus</b>(<i><b>[in]</b>(GUIDSTRING)</i><b>_Target</b>, <i><b>[in]</b>(STRING)</i><b>_Status</b>,<i><b> [out]</b>(INTEGER)</i><b>_Bool</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Returns whether <b>_Target</b> is currently under the influence of <b>_Status</b>.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b>Success/Failure</b>: Default return value.<br>
 
</li>
 
<li><b>_Bool</b>: 0 if <b>_Target</b> is currently not under the influence of <b>_Status</b>, 1 if it is.<br>
 
</li></ul>
 
<p><u>Notes<br>
 
</u></p>
 
<ul><li>/</li></ul>
 
<p><u>See also<br>
 
</u></p>
 
<ul><li><b>HasAppliedStatus</b><br>
 
</li></ul>
 
<h4>HasAppliedStatus</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>HasAppliedStatus</b>(<i><b>[in]</b>(GUIDSTRING)</i><b>_Target</b>, <i><b>[in]</b>(STRING)</i><b>_Status</b>,<i><b> [out]</b>(INTEGER)</i><b>_Bool</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Returns whether <b>_Status</b> has been applied to <b>_Target</b>. <b>_Target</b> may or may not yet actually be under its influence.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b>Success/Failure</b>: </b>Default return value.</li>
 
<li><b>_Bool</b>: 0 if <b>_Status</b> has not been applied to <b>_Target</b>, 1 if it has been.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>In virtually all cases, use <b>HasActiveStatus</b> instead. The main purpose of this query is for crime reactions, and is only needed due to frame delays between code and Osiris.<br>
 
</li></ul>
 
<p><u>See also<br>
 
</u></p>
 
<ul><li><b>HasActiveStatus</b><br>
 
</li></ul>
 
<h4>IsSpeakerReserved<br>
 
</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b>IsSpeakerReserved</b>(<i><b>[in]</b>(GUIDSTRING)</i><b>_Speaker</b>, <i><b>[out]</b>(INTEGER)</i><b>_success</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Returns whether <b>_Speaker</b> is already in a dialog.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b>Success/Failure</b>: </b>Default return value.</li>
 
<li><b>_success</b>: <b>0</b> if <b>_Speaker</b> is currently not in a dialog, <b>1</b> otherwise.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>/</li></ul>
 
<p><u>See also<br>
 
</u></p>
 
<ul><li><b>DialogStartRequested</b></li>
 
<li><b>Proc_StartDialog<br>
 
</b></li></ul>
 
<h4>ItemIsInInventory</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>query <b><span style="font-family:arial,sans-serif">Item</span>IsInInventory</b>(<i><b>[in]</b>(ITEMGUID)</i><b>_Item</b>, <i><b>[out]</b>(INTEGER)</i><b>_Bool</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Returns whether <b>_Item</b> is in an inventory. This includes both character and container inventories.<br>
 
</p>
 
<p><u>Return values</u></p>
 
<ul><li><b><b>Success/Failure</b>: </b>Default return value.</li>
 
<li><b>_Bool</b>: 0 if <b>_Item</b> is not in an inventory (as defined above), 1 if it is.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>/</li></ul>
 
<p><u>See also<br>
 
</u></p>
 
<ul><li><b>GetInventoryOwner</b></li></ul>
 
<div>
 
<hr>
 
</div>
 

Revision as of 11:08, 2 August 2017