Unfortunately, I've run into a snag; the script is supposed to place a variable on the player that says that the stash has already been found, but for some reason the script is either not placing that variable on the player or the script is not reading that the variable is there, and it will cycle through to the next skill check (instead of performing one, and if that fails, then the other as I intended).
I'm using a library script to simplify it somewhat as I was going to place the final results on the vault.
If someone could take a look and maybe figure out why it's doing this it'd be greatly appreciated. I'm at wits end.
Library Script
// Thanks to Axe_Murderer for helping me with these.
// int HasDoneThisBefore( object oPC )
// Determines if a given PC has interacted with OBJECT_SELF before.
int HasDoneThisBefore( object oPC );
int HasDoneThisBefore( object oPC )
{
return GetLocalInt( oPC, GetTag( OBJECT_SELF ));
}
// void SayThisOnce( object oPC, string sObservation )
// Causes a given PC to make an observation verbally unless he has done it
// already once before by interacting with OBJECT_SELF some time earlier.
void SayThisOnce( object oPC, string sObservation );
void SayThisOnce( object oPC, string sObservation )
{ if( GetLocalInt( oPC, GetTag( OBJECT_SELF )) || (sObservation == "") ) return;
SetLocalInt( oPC, GetTag( OBJECT_SELF ), TRUE );
AssignCommand(oPC, ClearAllActions());
SendMessageToPC(oPC, sObservation);
}
// void SpeakThisOnce( object oPC, string sObservation )
// Causes a given PC to make an observation verbally unless he has done it
// already once before by interacting with OBJECT_SELF some time earlier.
void SpeakThisOnce( object oPC, string sObservation );
void SpeakThisOnce( object oPC, string sObservation )
{ if( GetLocalInt( oPC, GetTag( OBJECT_SELF )) || (sObservation == "") ) return;
SetLocalInt( oPC, GetTag( OBJECT_SELF ), TRUE );
AssignCommand(oPC, ClearAllActions());
SendMessageToPC(oPC, sObservation);
}
// Function to do a private version of this skill check, no result
// is told to the PC
// From the NWN Lexicon
int GetIsSkillSuccessfulPrivate(object oTarget, int nSkill, int nDifficulty)
{
// Do the roll for the skill
if(GetSkillRank(nSkill, oTarget) + d20() >= nDifficulty)
{
// They passed the DC
return TRUE;
}
// Failed the check
return FALSE;
}Stash script
#include "inc_common"
// Created By: NineCoronas 5/21/2012 9:45 pm
// Special thanks to Lightfoot8, Meaglyn, Fester Pot, and GhostOfGod for putting
// up with my incessant questions and providing assistance. You guys rock!
//
// Usage: This system allows the user to set up 'Secret Stashes' anywhere, using
// triggers, waypoints, and variables, which can only be discovered upon passing
// private search and spot checks. It will first run a search check, and if the
// pc fails that, run a spot check. If successful, the script spawns in the
// stash and the pc will speak a message saying he/she found something. If desired
// the pc can also be awarded some xp along with an accompanying message. If the
// PC does not succeed either skill check, he/she will be none the wiser.
//
// INSTRUCTIONS
// 1) Make sure you have a unique container with a unique tag in the palette.
// Now, lay down a trigger and give it a unique tag where you'd like the PC to
// find the secret stash.
// 2) Lay down a waypoint where you'd like the container to spawn. Give it the
// same tag as the trigger.
// 3) Open the "Variables" menu on the trigger. Now we will begin adding the
// necessary variables.
// REQUIRED VARIABLES
// * Create a String named "StashType" without the quotations. In the value
// section, type the tag of the placeable container you want to spawn in.
// * Create an Integer named "iSearchDC" without the quotations. In the value
// section, type the value that will be the search DC. I.E. "25" for a DC
// of 25.
// * Create an Integer named "iSpotDC" without the quotations. In the value
// section, type the value that will be the spot DC. I.E. "25" for a DC of
// 25.
// OPTIONAL VARIABLES
// * Create a String named "StashMessage" without the quotations. In the
// value section, type out the message you wish the player to receive in
// the chat window upon finding the stash.
// * Create an Integer named "iXPBonus" without the quotations. In the value
// section, type in the amount of xp you would like the player to be
// awarded upon finding the stash.
//
// NOTES
// * Keep in mind that a Level 1 player with 1 point in either Spot or search
// is capable of passing a DC of 21. Usually, however, they will have 4,
// and thus a DC of 24 would be passable.
// * The skill checks will not be made if the player has no skill ranks in
// either skill.
// * This script will fire only once per player.
//
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oTarget = GetWaypointByTag(GetTag(OBJECT_SELF));
location lTarget = GetLocation(oTarget);
string sStash = GetLocalString(OBJECT_SELF, "StashType"); //Checks the trigger for the tag of container placeable to be created
string sObservation = GetLocalString(OBJECT_SELF, "StashMessage"); //Checks the trigger for the message the player is to receive
int iSearchDC = GetLocalInt(OBJECT_SELF, "iSearchDC"); //Checks the trigger for the search DC
int iSpotDC = GetLocalInt(OBJECT_SELF, "iSpotDC"); //Checks the trigger for the spot DC
int iXPBonus = GetLocalInt(OBJECT_SELF, "iXPBonus"); //Checks the trigger for the XP to be awarded to the player
if (HasDoneThisBefore(oPC)) return;
if (GetIsSkillSuccessfulPrivate(oPC, SKILL_SEARCH, iSearchDC)) //Player's Skill Rank + d20 vs. DC
{
CreateObject(OBJECT_TYPE_PLACEABLE, sStash, lTarget); //Creates the stash at the waypoint with the same tag as the trigger
AssignCommand(oPC, PlayVoiceChat(VOICE_CHAT_LOOKHERE)); //"I found something!"
if (GetLocalInt(OBJECT_SELF, "iXPBonus")) //Checks to see if the iXPBonus integer is set, if it isn't, script moves on
{
GiveXPToCreature(oPC, iXPBonus); //Gives the amount of xp stored on the integer to the player
}
if (GetLocalString(OBJECT_SELF, sObservation)!= "") //Checks to see if the there is a message to send to the player, if not, script moves on
{
SayThisOnce(oPC, sObservation); //Sends the message stored on the string to the player, only once
}
return;
}
if (GetIsSkillSuccessfulPrivate(oPC, SKILL_SPOT, iSpotDC))
{
CreateObject(OBJECT_TYPE_PLACEABLE, sStash, lTarget);
AssignCommand(oPC, PlayVoiceChat(VOICE_CHAT_LOOKHERE));
if (GetLocalInt(OBJECT_SELF, "iXPBonus"))
{
GiveXPToCreature(oPC, iXPBonus);
}
if (GetLocalString(OBJECT_SELF, sObservation)!= "")
{
SayThisOnce(oPC, sObservation); //Sends the message stored on the string to the player, only once
}
return;
}
}Thanks in advance!





Retour en haut







