Hey peeps, having a little trouble with conversations and scripting, now I am not 100% sure if its possible but I figure i'll ask just in case, see I wish to use one script on the ActionsTabs for multiple conversation choices. So basically the thing is if a player clicks Choice A or Choice B or Choice C they execute the same script, but in the script I want to be able to define the differences.
I've tried using GetPCChatMessage to see if that would help at all, I didn't think it would and I was right. So I was wondering is there a way to get that the conversation node so I can use that as a check to what choice the player did.
This is so I dont have to create a seperate script for each relatable item in the menu..
Cheers
- Dev
Conversation Nodes
Débuté par
Devari
, mai 31 2011 12:49
#1
Posté 31 mai 2011 - 12:49
#2
Posté 31 mai 2011 - 02:50
You need to use NWNX and the nwnx_events plugin, to get these functions:
int GetCurrentNodeType();
int GetCurrentNodeID();
int GetCurrentAbsoluteNodeID();
It's been released for both linux and windows, but as far as I know only the linux plugin offers the above functions. Linkage
Funky
int GetCurrentNodeType();
int GetCurrentNodeID();
int GetCurrentAbsoluteNodeID();
It's been released for both linux and windows, but as far as I know only the linux plugin offers the above functions. Linkage
Funky
#3
Posté 31 mai 2011 - 03:05
There is a Branch of the nwnx svn, called Events_Update
http://nwn.virusman....s/events_update
I dont know if it works, but it contains conversation node code.
http://nwn.virusman....s/events_update
I dont know if it works, but it contains conversation node code.
char* CNWNXEvents::OnRequest (char* gameObject, char* Request, char* Parameters)
{
Log(2,"Request: \\"%s\\"\\n",Request);
Log(2,"Params: \\"%s\\"\\n",Parameters);
this->pGameObject = gameObject;
this->nGameObjectID = *(dword *)(gameObject+0x4);
if (ConditionalScriptRunning)
{
if (strncmp(Request, "GET_NODE_ID", 11) == 0)
{
if (strlen(Parameters) > 2)
sprintf(Parameters, "%d", nCurrentNodeID);
return NULL;
}
else if (strncmp(Request, "GET_ABSOLUTE_NODE_ID", 20) == 0)
{
if (strlen(Parameters) > 2)
sprintf(Parameters, "%d", nCurrentAbsoluteNodeID);
return NULL;
}
else if (strncmp(Request, "GET_NODE_TYPE", 13) == 0)
{
if (strlen(Parameters) > 1)
sprintf(Parameters, "%d", nNodeType);
return NULL;
}
else if (strncmp(Request, "GET_NODE_TEXT", 13) == 0)
{
if(!pConversation) return NULL;
int nLocaleID = atoi(Parameters);
const char *pText = NULL;
if(nNodeType == StartingNode || nNodeType == EntryNode)
{
CDialogEntry *pEntry = &pConversation->EntryList[nCurrentAbsoluteNodeID];
CExoLocString *pNodeText = &pEntry->Text;
pText = pNodeText->GetStringText(nLocaleID);
}
else if(nNodeType == ReplyNode)
{
CDialogReply *pReply = &pConversation->ReplyList[nCurrentAbsoluteNodeID];
CExoLocString *pNodeText = &pReply->Text;
pText = pNodeText->GetStringText(nLocaleID);
}
else return NULL;
if(!pText) return NULL;
int len = strlen(pText);
char *pNewText = (char *) malloc(len+1);
strncpy(pNewText, pText, len);
pNewText[len]=0;
return pNewText;
return NULL;
}
else if (strncmp(Request, "SET_NODE_TEXT", 13) == 0)
{
if(!pConversation) return NULL;
int nLocaleID;
int nParamLen = strlen(Parameters);
//char *sNewText = (char *) malloc(nParamLen);
char *nLastDelimiter = strrchr(Parameters, '¬');
if (!nLastDelimiter || (nLastDelimiter-Parameters)<0)
{
Log(0, "o nLastDelimiter error\\n");
//free(sNewText);
return NULL;
}
int nTextLen = nParamLen-(nLastDelimiter-Parameters)+1;
char *sNewText = (char *) malloc(nTextLen);
if(sscanf(Parameters, "%d¬", &nLocaleID)<1)
{
Log(0, "o sscanf error\\n");
free(sNewText);
return NULL;
}
strncpy(sNewText, nLastDelimiter+1, nTextLen-1);
CExoLocStringElement *pLangEntry=NULL;
if(nNodeType == StartingNode || nNodeType == EntryNode)
{
CDialogEntry *pEntry = &pConversation->EntryList[nCurrentAbsoluteNodeID];
CExoLocString *pNodeText = &pEntry->Text;
pLangEntry = pNodeText->GetLangEntry(nLocaleID);
}
else if(nNodeType == ReplyNode)
{
CDialogReply *pReply = &pConversation->ReplyList[nCurrentAbsoluteNodeID];
CExoLocString *pNodeText = &pReply->Text;
pLangEntry = pNodeText->GetLangEntry(nLocaleID);
}
if(!pLangEntry){ free(sNewText); return NULL; } //do nothing if there is no text
if(pLangEntry->Text.Text)
{
free(pLangEntry->Text.Text);
pLangEntry->Text.Text = sNewText;
pLangEntry->Text.Length = strlen(sNewText)+1;
}
return NULL;
}
}
if (ActionScriptRunning)
{
if (strncmp(Request, "GET_SELECTED_NODE_ID", 20) == 0)
{
if (strlen(Parameters) > 1)
sprintf(Parameters, "%d", nSelectedNodeID);
return NULL;
}
else if (strncmp(Request, "GET_SELECTED_ABSOLUTE_NODE_ID", 29) == 0)
{
if (strlen(Parameters) > 1)
sprintf(Parameters, "%d", nSelectedAbsoluteNodeID);
return NULL;
}
else if (strncmp(Request, "GET_SELECTED_NODE_TEXT", 22) == 0)
{
if(!pConversation) return NULL;
int nLocaleID = atoi(Parameters);
CDialogReply *pReply = &pConversation->ReplyList[nSelectedAbsoluteNodeID];
CExoLocString *pNodeText = &pReply->Text;
const char *pText = pNodeText->GetStringText(nLocaleID);
if(!pText) return NULL;
int len = strlen(pText);
char *pNewText = (char *) malloc(len+1);
strncpy(pNewText, pText, len);
pNewText[len]=0;
return pNewText;
}
}
if (!scriptRun) return NULL; //The following functions are accessible only from event script
if ((strncmp(Request, "GET_EVENT_ID", 12) && strncmp(Request, "GETEVENTID", 10)) == 0)
{
if (strlen(Parameters) > 1)
sprintf(Parameters, "%d", nEventID);
return NULL;
}
if (strncmp(Request, "GET_EVENT_SUBID", 15) == 0)
{
if (strlen(Parameters) > 1)
sprintf(Parameters, "%d", nEventSubID);
return NULL;
}
else if (strncmp(Request, "GET_EVENT_POSITION", 18) == 0)
{
if (strlen(Parameters) > 24)
sprintf(Parameters, "%f¬%f¬%f", vPosition.x, vPosition.y, vPosition.z);
}
else if (strncmp(Request, "GET_ITEM_RADIAL", 18) == 0)
{
if (strlen(Parameters) > 1)
sprintf(Parameters, "%d", nRadial);
}
else if (strncmp(Request, "BYPASS", 6) == 0)
{
bBypass = atoi(Parameters);
}
return NULL;
}
#4
Posté 31 mai 2011 - 03:07
Cheers both of you, i'll have a look at NWNX and see if I can made head or tail of the event node stuff, cheers.





Retour en haut







