Okay, I am not a scripter so I make heavy use of LilacSoul's Script Generator (before anyone complains about me not learning scripting...cut me some slack, please...I work and go to school fullt time, plus I am married and have a 2 year old, and have a social life).
I cannot, for the life of me figure out why the below script won't work. It is supposed to check and see if the PC has any of the items in his inventory and if he/she does, make a conversation node appear. The node is a PC node, not an NPC one.
Here's the script (apologies, I don't recall how to post in a window):
int GetNumItems(object oTarget,string sItem)
{
int nNumItems = 0;
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem) == TRUE)
{
if (GetTag(oItem) == sItem)
{
nNumItems = nNumItems + GetNumStackedItems(oItem);
}
oItem = GetNextItemInInventory(oTarget);
}
return nNumItems;
}
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.c...=4683&id=625 */
int StartingConditional()
{
object oPC = GetPCSpeaker();
if (GetNumItems(oPC, "NW_IT_TRAP033") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP013") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP021") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP017") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP029") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP025") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP001") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP009") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP034") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP014") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP022") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP018") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP030") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP026") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP002") < 1) return FALSE;
if (GetNumItems(oPC, "NW_IT_TRAP010") < 1) return FALSE;
return TRUE;
}
Thanks for any help you can provide!
TAW script needs fixing
Débuté par
UnrealJedi
, juin 07 2012 12:27
#1
Posté 07 juin 2012 - 12:27
#2
Posté 07 juin 2012 - 12:54
The posted code will return true only if oPC has at least 1 of each specified item.
int StartingConditional()
{
object oPC = GetPCSpeaker();
object oItem = GetFirstItemInInventory(oPC);
while(oItem != OBJECT_INVALID)
{
string sTag = GetTag(oItem);
if(sTag == "NW_IT_TRAP033" || sTag == "NW_IT_TRAP013" ||
sTag == "NW_IT_TRAP021" || sTag == "NW_IT_TRAP017" ||
sTag == "NW_IT_TRAP029" || sTag == "NW_IT_TRAP025" ||
sTag == "NW_IT_TRAP001" || sTag == "NW_IT_TRAP009" ||
sTag == "NW_IT_TRAP034" || sTag == "NW_IT_TRAP014" ||
sTag == "NW_IT_TRAP022" || sTag == "NW_IT_TRAP018" ||
sTag == "NW_IT_TRAP030" || sTag == "NW_IT_TRAP026" ||
sTag == "NW_IT_TRAP002" || sTag == "NW_IT_TRAP010")
return TRUE;
oItem = GetNextItemInInventory(oPC);
}
return FALSE;
}
This should do it, in the "Text appears when" tab.
EDIT: The solution proposed by Lightfoot8 is faster and more efficient. I proposed this one in a hurry because speed does not usually matter much in a convo script.
Kato
int StartingConditional()
{
object oPC = GetPCSpeaker();
object oItem = GetFirstItemInInventory(oPC);
while(oItem != OBJECT_INVALID)
{
string sTag = GetTag(oItem);
if(sTag == "NW_IT_TRAP033" || sTag == "NW_IT_TRAP013" ||
sTag == "NW_IT_TRAP021" || sTag == "NW_IT_TRAP017" ||
sTag == "NW_IT_TRAP029" || sTag == "NW_IT_TRAP025" ||
sTag == "NW_IT_TRAP001" || sTag == "NW_IT_TRAP009" ||
sTag == "NW_IT_TRAP034" || sTag == "NW_IT_TRAP014" ||
sTag == "NW_IT_TRAP022" || sTag == "NW_IT_TRAP018" ||
sTag == "NW_IT_TRAP030" || sTag == "NW_IT_TRAP026" ||
sTag == "NW_IT_TRAP002" || sTag == "NW_IT_TRAP010")
return TRUE;
oItem = GetNextItemInInventory(oPC);
}
return FALSE;
}
This should do it, in the "Text appears when" tab.
EDIT: The solution proposed by Lightfoot8 is faster and more efficient. I proposed this one in a hurry because speed does not usually matter much in a convo script.
Kato
Modifié par Kato_Yang, 07 juin 2012 - 01:19 .
#3
Posté 07 juin 2012 - 12:56
The reason is that once it get to any one of the items listed that you have non of the items It returns FALSE and the script stops running.
Change all of the if (GetNumItems(oPC, "NW_IT_TRAP010") < 1) return FALSE; lines to
If (GetItemPossesedBy( oPC, "NW_IT_TRAP033") != OBJECT_INVALID) return TRUE;
Had to run back to work so excuse any minor errors in that line.
Change all of the if (GetNumItems(oPC, "NW_IT_TRAP010") < 1) return FALSE; lines to
If (GetItemPossesedBy( oPC, "NW_IT_TRAP033") != OBJECT_INVALID) return TRUE;
Had to run back to work so excuse any minor errors in that line.
#4
Posté 07 juin 2012 - 02:36
I believe the majority of the nwn community is in the same boat.UnrealJedi wrote...
, plus I am married and have a 2 year old, and have a social life.





Retour en haut







