Difference between revisions of "Osiris API Tips"

From Divinity Engine Wiki
Jump to: navigation, search
(Blanked (delete). All this content and more is in the Osiris API documentation)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<br>
+
 
<div><img src="https://www.google.com/chart?chc=sites&amp;cht=d&amp;chdp=sites&amp;chl=%5B%5BTable+of+contents'%3D20'f%5Cv'a%5C%3D0'10'%3D749'0'dim'%5Cbox1'b%5CF6F6F6'fC%5CF6F6F6'eC%5C0'sk'%5C%5B'%5D'a%5CV%5C%3D12'f%5C%5DV%5Cta%5C%3D10'%3D0'%3D750'%3D297'dim'%5C%3D10'%3D10'%3D750'%3D297'vdim'%5Cbox1'b%5Cva%5CF6F6F6'fC%5CC8C8C8'eC%5C'a%5C%5Do%5CLauto'f%5C&amp;sig=6OQlG6gOnnBFfFkmejXWTLbCWDE" data-type="toc" data-props="align:left;maxDepth:6;width:750;" width="750" height="300" style="display:block;text-align:left;margin-right:auto;"></div>
 
<h2>Subpages<br>
 
</h2>
 
<ul><li>
 
<h3><a href="https://sites.google.com/a/larian.com/larian-wikisite/osiris-api-tips-crimes">Osiris API for crimes</a><br>
 
</h3>
 
</li></ul>
 
<h2>Main Osiris API</h2>
 
<h3>Events</h3>
 
<p>Events are a way for Osiris to inform script that something happened. All event parameters have <i><b>[in]</b></i> semantics.<br>
 
</p>
 
<div>
 
<div>
 
<div>
 
<div>
 
<h4>CharacterBlockedBy</h4>
 
<u>Full definitions</u></div>
 
<div>
 
<ul><li>event <b>CharacterBlokedBy</b>(<i>(CHARACTERGUID)</i><b>_Defender</b>, <i>(CHARACTERGUID)</i><b>_Attacker</b>, <i>(CHARACTERGUID)</i><b>_AttackerOwner</b>)</li></ul>
 
</div>
 
<div><br>
 
<u>Description</u></div>
 
<div><span style="background-color:transparent;font-size:1em">Thrown when a character blocks an attack from another character.</span><u><br>
 
</u><br>
 
<u>Parameters</u><br>
 
<ul><li><b>_Defender</b>: The character that received/defended the attack.</li>
 
<li><b>_Attacker</b>: The character that attacked the <b>_Defender</b>.</li>
 
<li><b>_AttackerOwner</b>: The character that owns the <b>_Attacker</b> character.</li></ul>
 
<b><br>
 
</b><u>Notes</u><br>
 
<ul><li><b>_AttackerOwner </b>can be the same character as <b>_Attacker</b>, <b>_AttackOwner </b>will be different in the case of summoned characters.</li></ul>
 
<br>
 
<u>See also</u><br>
 
<ul><li><b>CharacterMissedBy</b></li></ul>
 
<h4>CharacterMissedBy</h4>
 
<u>Full definitions</u><br>
 
<ul><li><span style="font-size:13.3333px">event&nbsp;</span><b>CharacterMissedBy</b>(<i>(CHARACTERGUID)</i><b>_Defender</b>, <i>(CHARACTERGUID)</i><b>_Attacker</b>, <i>(CHARACTERGUID)</i><b>_AttackerOwner</b>)</li></ul>
 
</div>
 
<div><br>
 
</div>
 
<div><u>Description</u><br>
 
Thrown when a character misses an attack from another character.<br>
 
<br>
 
<u>Parameters</u><br>
 
<ul><li><b style="background-color:transparent;font-size:1em">_Defender</b><span style="background-color:transparent;font-size:1em">: The character that received/defended the attack.</span></li>
 
<li><b style="background-color:transparent;font-size:1em">_Attacker</b><span style="background-color:transparent;font-size:1em">: The character that attacked the <b>_Defender</b>.</span></li>
 
<li><b style="background-color:transparent;font-size:1em">_AttackerOwner</b><span style="background-color:transparent;font-size:1em">: The character that owns the <b>_Attacker </b>character.</span></li></ul>
 
<br>
 
<u>Notes</u><br>
 
<ul><li><b style="background-color:transparent;font-size:1em">_AttackerOwner </b><span style="background-color:transparent;font-size:1em">can be the same character as </span><b style="background-color:transparent;font-size:1em">_Attacker</b><span style="background-color:transparent;font-size:1em">, </span><b style="background-color:transparent;font-size:1em">_AttackOwner </b><span style="background-color:transparent;font-size:1em">will be different in the case of summoned characters.</span></li></ul>
 
<br>
 
<u>See also</u><br>
 
<ul><li><b style="background-color:transparent;font-size:1em">CharacterBlockedBy</b></li></ul>
 
<h4>CharacterCriticalHitBy</h4>
 
<u>Full definitions</u><br>
 
<ul><li><span style="font-size:13.3333px">event&nbsp;</span><b>CharacterCriticalHitBy</b>(<i>(CHARACTERGUID)</i><b>_Defender</b>, <i>(CHARACTERGUID)</i><b>_Attacker</b>, <i>(CHARACTERGUID)</i><b>_AttackerOwner</b>)</li></ul>
 
</div>
 
<div><br>
 
</div>
 
<div><u>Description</u><br>
 
<ul><li>Thrown when a character receives a critical hit from an attack of another character.</li></ul>
 
<br>
 
<u>Parameters</u><br>
 
<ul><li><b>_Defender</b>: The character that received/defended the attack.</li>
 
<li><b>_Attacker</b>: The character that attacked the <b>_Defender</b>.</li>
 
<li><b>_AttackerOwner</b>: The character that owns the <b>_Attacker </b>character.</li></ul>
 
<br>
 
<u>Notes</u><br>
 
<ul><li><b>_AttackerOwner </b>can be the same character as <b>_Attacker</b>, <b>_AttackOwner </b>will be different in the case of summoned characters.</li></ul>
 
<br>
 
<u>See also</u><br>
 
<ul><li><b>CharacterBlockedBy</b></li></ul>
 
<h4>CharacterKilledBy</h4>
 
<h4>
 
<div></div>
 
</h4>
 
<h4>
 
<div></div>
 
</h4>
 
<u>Full definitions</u><br>
 
<ul><li><span style="font-size:13.3333px">event&nbsp;</span><b>CharacterKilledBy</b>(<i>(CHARACTERGUID)</i><b>_Defender</b>, <i>(CHARACTERGUID)</i><b>_Attacker</b>, <i>(CHARACTERGUID)</i><b>_AttackerOwner</b>)</li></ul>
 
</div>
 
<div><br>
 
</div>
 
<div><u>Description</u><br>
 
<ul><li>Thrown when a character is killed by another character.</li></ul>
 
<br>
 
<u>Parameters</u><br>
 
<ul><li><b>_Defender</b>: The character that received/defended the attack.</li>
 
<li><b>_Attacker</b>: The character that attacked the <b>_Defender</b>.</li>
 
<li><b>_AttackerOwner</b>: The character that owns the <b>_Attacker </b>character.</li></ul>
 
<br>
 
<u>Notes</u><br>
 
<ul><li><b>_AttackerOwner </b>can be the same character as <b>_Attacker</b>, <b>_AttackOwner </b>will be different in the case of summoned characters.</li></ul>
 
<br>
 
<u>See also</u><br>
 
<ul><li><b>CharacterBlockedBy</b></li></ul>
 
<h4>CharacterEnteredRegion</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>CharacterEnteredRegion</b>(<i>(CHARACTERGUID)</i><b>_Character</b>, <i>(STRING)</i><b>_Region</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Thrown when a character enters a level because it was placed there in the editor, it was teleported there via script, or it was created/spawned there via script.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_Character</b>: the character that entered the level/region<br>
 
</li>
 
<li><b>_Region</b>: the name of the level/region (as entered in the <i>Levelname</i> property of the <i>Level -&gt; Edit Level Data...</i> menu entry in the editor.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>For characters statically placed in a level using the editor, this event is thrown only once when the level is first entered. It is not thrown again when loading save games from within that level. <i><b>TODO</b></i>: check what happens if the players are teleported out of a level and then back into it (never done in DivinityOrigins mod).<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li>/</li></ul>
 
<h4>CharacterSawCharacter</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>CharacterSawCharacter</b>(<i>(CHARACTERGUID)</i><b>_Character</b>,<i> (CHARACTERGUID)</i><b>_OtherCharacter</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Thrown when one <b>_Character</b> sees <b>_OtherCharacter</b>. Note that this event is only thrown if <b>_Character</b> has been registered as an event generator.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_Character</b>: the character that does the seeing.</li>
 
<li><b>_OtherCharacter</b>: the character that is seen<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>By default, only player-controlled characters are event generators. Once you call <b>CharacterCanSee</b> with an NPC as first parameter, an event generator is also registered for this NPC and it will also start throwing <b>CharacterSawCharacter</b> events. This event generator may only work temporarily though, so in general only rely on these events be thrown for player characters.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CharacterCanSee</b></li>
 
<li><b>CharacterLostSightOfCharacter<br>
 
</b></li></ul>
 
<h4>CharacterStoppedUsingItem</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>CharacterStoppedUsingItem</b>(<i>(CHARACTERGUID)</i><b>_Character</b>, <i>(ITEMGUID)</i><b>_Item</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Thrown when a character stopped using an item, <b>or</b> if a character tried to use an item and failed.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_Character</b>: the character that used or tried to use <b>_Item</b>.</li>
 
<li><b>_Item</b>: the item that was used or attempted to be used<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>/</li></ul>
 
<p><u>See also</u></p>
 
<ul><li>/</li></ul>
 
<h4>CombatStarted</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>CombatStarted</b>(<i>(INTEGER)</i><b>_CombatID</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Thrown once a new combat has started and has been completely initialised. I.e., all initial participants have been added, and combat is ready to start.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_CombatID</b>: A handle that identifies the combat. Should always be &gt; 0.</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>This event can also be thrown for an ongoing combat after one or more participants left. In this case, first a new <b>ObjectEnteredCombat</b> event will be thrown for every participant still in the combat, followed by a new <b>CombatStartedEvent</b> with the same _<b>CombatID</b> as before. During these new <b>ObjectEventeredCombat</b> events and <b>CombatStarted</b> event, the combat must again be considered to be not completely initialised yet.</li>
 
<li>This event will also be thrown when two combats are merged.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>ObjectEnteredCombat</b></li>
 
<li><b>ObjectLeftCombat<br>
 
</b></li></ul>
 
<h4>DialogStartRequested</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>DialogStartRequested</b>(<i>(GUIDSTRING)</i><b>_Target</b>,<i>(GUIDSTRING)</i><b>_Player</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Thrown whenever a player tries to start a conversation with another object.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_Target</b>: The object to which the conversation request is directed.</li>
 
<li><b>_Player</b>: The player that initiated the conversation<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>Do not use this event directly. Overload <b>PROC_GLOBAL_DialogStartRequested</b> or <b>PROC_GLOBAL_DialogStartRequested_AfterGenerics</b> instead, so that certain common behaviours are guaranteed to hold in all cases.</li>
 
<li>This event can only be thrown if the target can accept dialog requests, i.e. if <b>SetHasDialog</b>(<b>_Target</b>,<b>1</b>) is currently active.</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>SetHasDialog</b><br>
 
</li>
 
<li>helper <b>PROC_GLOBAL_DialogStartRequested</b><br>
 
</li>
 
<li>helper <b>PROC_GLOBAL_DialogStartRequested_AfterGenerics</b></li></ul>
 
<h4>GameStarted</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <span style="font-family:arial,sans-serif"><b>GameStarted</b></span>(<i>(String)</i><b>_LevelName</b>, <i>(INTEGER)</i><b>_IsEditorMode</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Thrown when a level has been loaded and is ready at both the server and client side.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_LevelName</b>: The identifier name of the level that has been loaded<br>
 
</li>
 
<li><b>_IsEditorMode</b>: Indicates whether the game is run in the editor or not<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>The logic of Osiris is split into a server and a client side, even in single player mode. Some important things that run on the client side are visual effects and physics.<br>
 
</li>
 
<li>An example of something that is done only when the client side is ready, is playing the effect of the source collars on the characters in the tutorial and Fort Joy levels (since they're visual effects, and hence do not work if started when only the server side is ready)<br>
 
</li>
 
<li>See <b>RegionStarted</b> for an event that is thrown when the level is ready on the server side.</li>
 
<li>This event is also thrown when loading a savegame, so add additional logic for code that should be executed only the first time when this level is started (or trigger it from the INIT section of a story goal instead).<br>
 
</li></ul>
 
<div>
 
<div>
 
<p><u>See also</u></p>
 
<ul><li><b>RegionStarted</b></li></ul>
 
<h4>ObjectEnteredCombat</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>ObjectEnteredCombat</b>(<i>(GUIDSTRING)</i><b>_Object</b>, <i>(INTEGER)</i><b>_CombatID</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Thrown when an object (character or item) enters a combat.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_Object</b>: The object that has entered the combat<br>
 
</li>
 
<li><b>_CombatID</b>: A handle that identifies the combat. Should always be &gt; 0.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>This can be a combat that is still being set up, or an existing combat joined by a character that wandered too close.</li>
 
<li>If the combat is still being set up, not all information may be available yet (e.g., other initial objects may still be added after this one), and you cannot use APIs such as <b>JumpToTurn</b> yet. If you wish to perform some action when a combat has completely started, use <b>CombatStarted</b> instead.</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>CombatStarted</b></li>
 
<li><b>ObjectLeftCombat<br>
 
</b></li></ul>
 
<h4>ObjectFlagSet</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>ObjectFlagSet</b>(<i>(STRING)</i><b>_FlagName</b>, <i>(GUIDSTRING)</i><b>_Speaker</b>, <i>(INTEGER)</i><b>_DialogInstance</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Thrown when the flag <b>_FlagName</b> is set on object <b>_Speaker</b> in the context indicated by <b>_DialogInstance</b>.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_FlagName</b>: The flag that is set. <br>
 
</li>
 
<li><b>_Speaker</b>: The object on which the (character) flag is set.</li>
 
<li><b>_DialogInstance</b>: If the flag was set using a dialog node, <b>_DialogInstance</b> contains the dialog's instance ID. If the flag was set from story, <b>_DialogInstance</b> will contain whatever was passed as last parameter to <b>ObjectSetFlag</b>. If the flag was set from behaviour script, <b>DialogInstance</b> will be zero.</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>/<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>ObjectSetFlag</b></li>
 
<li><b>ObjectClearFlag<br>
 
</b></li></ul>
 
<h4>ObjectLeftCombat</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>ObjectLeftCombat</b>(<i>(GUIDSTRING)</i><b>_Object</b>, <i>(INTEGER)</i><b>_CombatID</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Thrown when an object (character or item) leaves a combat.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_Object</b>: The object that has left the combat<br>
 
</li>
 
<li><b>_CombatID</b>: A handle that identifies the combat. Should always be &gt; 0.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>Reasons why characters may leave combat is because they died, because they got too far from the other participants, or because story forced them to leave.</li></ul>
 
<p><u>See also</u><br>
 
</p>
 
<ul><li><b>CombatStarted</b></li>
 
<li><b>ObjectEnteredCombat</b></li></ul>
 
<h4>ObjectSourcePointAddRequest</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>ObjectSourcePointAddRequest</b>(<i>(GUIDSTRING)</i><b>_Target</b>, <i>(INTEGER)</i><b>_Amount</b>)</li></ul>
 
<u>Description</u><br>
 
<p>Thrown for every attempt to add source to an object, even if the object cannot hold more source. It is thrown before the source has been added.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_Target</b>: The object to which source gets added. In case of a character, this means there is an attempt to add source points. In case of an item, this means there is an attempt to add charges.<br>
 
</li>
 
<li><b>_Amount</b>: The number of source points/charges that is being added.<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>As mentioned in the description, this is triggered even when <b>_Target</b> currently already holds its maximum of source.<br>
 
</li></ul>
 
<p><u>See also</u></p>
 
<ul><li>/</li></ul>
 
<h4>RegionStarted</h4>
 
<p><u>Full definitions</u></p>
 
<ul><li>event <b>RegionS</b><span style="font-family:arial,sans-serif"><b>tarted</b></span>(<i>(String)</i><b>_LevelName</b>)</li></ul>
 
<u>Description</u><br>
 
</div>
 
<p>Thrown when the level has been loaded and is ready at the server side, but not yet at the client side.<br>
 
</p>
 
<p><u>Parameters</u></p>
 
<ul><li><b>_LevelName</b>: The identifier name of the level that has been loaded<br>
 
</li></ul>
 
<p><u>Notes</u></p>
 
<ul><li>See <b>GameStarted</b> for usage information that also applies to this call.</li></ul>
 
<p><u>See also</u></p>
 
<ul><li><b>GameStarted</b></li></ul>
 
<div>
 
<hr>
 
</div>
 

Latest revision as of 11:03, 17 September 2017