I've spent about an hour on this particular script and it will not function correctly. I've decided it to leave it in the hands of those better then I for I am now just wasting time.
The relavent scriptsnc_observesystem
#include "inc_common"
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
string sObservation = GetLocalString(OBJECT_SELF, "sMessage"); //Checks the trigger for the message the player is to receive
//iMsgType checks the trigger for the type of message to play. 1 = Spoken Aloud, 2 = Chat Window
if (HasDoneThisBefore(oPC)) return;
if (GetLocalInt(OBJECT_SELF, "iMsgType") != 1) //Spoken Aloud
{
SpeakThisOnce(oPC, sObservation);
int iXPBonus = GetLocalInt(OBJECT_SELF, "iXPBonus"); //XP Bonus Check
if (iXPBonus)
GiveXPToCreature(oPC, iXPBonus);
}
if (GetLocalInt(OBJECT_SELF, "iMsgType") != 2) //Chat Window
{
SayThisOnce(oPC, sObservation);
int iXPBonus = GetLocalInt(OBJECT_SELF, "iXPBonus"); //XP Bonus Check
if (iXPBonus)
GiveXPToCreature(oPC, iXPBonus);
}
}
inc_common
// 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());
AssignCommand(oPC, ActionSpeakString(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;
}
The goalNow the goal of this script is for a message to be sent OR spoken by a player. The message is taken off a string variable stored on the area or trigger it's placed on and whether or not to send in it the chat window or speak it aloud are decided by an integer, also stored on the variable.
The SymptomsNo matter what the iMsgType was set too (1 or 2), the script will act as if the variable is set to 2 and send the message to the chat window.
I commented out the 2nd "if" block (relavent to chat window messages) and when I walked over the trigger, absolutely nothing happened. My actions weren't even cleared (which I included to see if it was firing at all).
NineCoronas is frustrated and jacked up on Coffee >.<
P.S.
Can a conversation be started with an NPC via scripting that they don't actually have as their main conversation file?
P.P.S.S.
Would a script like this possibly work in a Text Appears When conditional?
#include "inc_common"
int StartingConditional()
{
object oPC = GetPCSpeaker();
if (GetIsSkillSuccessfulPrivate(oPC, SKILL_ANIMAL_EMPATHY, 26)) return FALSE;
return TRUE;
}
Modifié par NineCoronas2021, 17 août 2012 - 09:11 .