Larian Banner
Previous Thread
Next Thread
Print Thread
#630750 14/10/17 04:08 AM
Joined: Oct 2017
Location: Spokane, WA
T
stranger
OP Offline
stranger
T
Joined: Oct 2017
Location: Spokane, WA
I am trying to figure out how to implement a script that closes a door if no one (player or npc) is in the box trigger. So when player or npc walks off of the BoxTrigger the door will close.

This will be my first script so if you could help me as to how to setup the script that would be helpful as well. Thanks!


Twitch Partner - Jedi - Rocket Surgeon - Sponsored by Soylent
Joined: Mar 2016
Location: Belgium
T
addict
Offline
addict
T
Joined: Mar 2016
Location: Belgium
I have documented the Osiris calls related to registering triggers and getting events from entering/leaving them: https://docs.larian.game/Osiris/API/TriggerRegisterForCharacter (you can find related calls starting from that page).

Since you want to track all characters' presence in that trigger, it's best to use an event trigger as mentioned in the Notes on that page. You can then use the following Osiris code:

Code
QRY
QRY_DoorIsOpenOrOpening((ITEMGUID)_Door)
AND
DoorIsOpening(_Door, 1)
THEN
DB_NOOP(1);

QRY
QRY_DoorIsOpenOrOpening((ITEMGUID)_Door)
AND
ItemIsOpen(_Door, 1)
THEN
DB_NOOP(1);

IF
// anyone leaves the trigger
CharacterLeftTrigger(_, TRIGGERGUID_S_YourBoxTrigger_UUID)
AND
// no one is left in the trigger
NOT DB_InRegion(_, TRIGGERGUID_S_YourBoxTrigger_UUID)
AND
// the door is currently open or opening
QRY_DoorIsOpenOrOpening(ITEMGUID_S_YourDoor_UUID)
THEN
ItemClose(ITEMGUID_S_YourDoor_UUID);

For details on how to structure your Osiris code, please see https://docs.larian.game/Osiris_Design_Patterns#Program_Initialisation

Edit: For a more concrete start on setting up your story scripting, see Windemere's https://docs.larian.game/Tutorial_-_Implementing_a_Basic_Quest

Last edited by Tinkerer; 14/10/17 03:25 PM. Reason: Added link to Windemere's basic quest tutorial

Moderated by  Larian_Koala 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5