x0_i0_secret

Library for secret/hidden items.

These use a trigger instead of an invisible item with an OnHeartbeat. This method is considerably less CPU-intensive and more flexible in determining the shape of the area in which the secret item can be detected. The trade-off is that you have to create one additional waypoint to specify where the item should appear.

Process:
- Create a trigger marking off the area where the secret item can be detected. There are several varieties already pre-created in the blueprints for different items.

- Edit the properties of the trigger as follows:
   o Set the tag to something unique;
   o On the "Scripts" tab, for "On Enter", pick "x0_o2_sec_"
   o On the "Advanced" tab, put an integer into the "Key Tag" field: this will be the DC for detection;

- Create a waypoint named "LOC_" and place it where you want the item to appear. Note that some items (like the trap door) have their orientation reversed; test to make sure the item appears with the desired orientation.

- If you are creating a secret transport object like a door or portal, create a waypoint named "DST_" and place it where you want the user to appear after use. Associates will be brought along for the ride even within the same area.

- Both the secret item and the detection trigger will be sent a user-defined event with the value EVENT_SECRET_REVEALED. To cause a reset, you can simply choose the 'x0_o2_sec_reset' script as the user-defined event handler for the detection trigger, or you can put something else in if you want to do something fancy.

- You can get a reference to the revealed secret item by using "GetSecretItemRevealed()".

NOTE: This file includes x0_i0_common.

Constants

NameValueBrief Description
EVENT_SECRET_REVEALED2801User-defined event that the item generates when found (can be used to cause a reset) -- this goes to both the item itself and to the detection trigger.
sDestinationPrefixDST_Prefix for the waypoint marking the destination of a secret door.
sDetectTriggerVarnameSECRET_TRIGGERVariable that holds the detection trigger of this secret item.
sFoundPrefixFOUND_Prefix on player to indicate whether they have found this item before. If they have, don't make them search again.
sLocationPrefixLOC_Prefix for the waypoint marking where the secret item should appear.
sOpenVarnameIS_OPENVariable that indicates whether this item is open/closed.
sRevealedVarnameIS_REVEALEDVariable that indicates whether this item is revealed or not.
sSecretItemVarnameSECRET_ITEMVariable that holds the tag of the item this detection item reveals.

Functions

NameBrief Description
DetectSecretItemDetection function for a secret item. Uses the specified skill (defaults to SKILL_SEARCH; use any of the SKILL_ constants here) and uses the key tag of the trigger as the DC of the detection check.
DetectSecretItemByClassDetection function that reveals an item only to members of the specified class. Compares the PC's level in the class plus a small modifier against the value of the key tag of the trigger.
GetIsSecretItemOpenReturns whether the secret item is currently open. Should be called from the secret item itself after being revealed.
GetIsSecretItemRevealedReturns whether the associated secret item is currently revealed. Should be called from the detect trigger, not the item itself. (If you have the item itself, it is definitely revealed!)
GetSecretItemRevealedReturns the associated secret item.
QuickDetectSecretInternal function. Used to avoid a bit of duplicate code in the Detect... functions.
ResetSecretItemReset function for a secret item. When called, this destroys the item and resets the invisible detection object going again. This WILL cause any treasure and locks/traps on the door to regenerate.
RevealSecretItemReveal function for a secret item. When called, this item creates the secret item from blueprint in the location of the item waypoint. Any item blueprint resref can be used here.

Some common items are the ones in the placeables palette listed under "Secret Items".
SetIsSecretItemOpenSet whether the secret item is open or not.
UseSecretTransportUse a secret transport to transport a PC and associates.


  author: Mistress