PDA

View Full Version : script syntax for multiple condition


jrc24
06-27-2004, 03:07 AM
how must I write that ?

I want return TRUE if I have an item AND an other item too and FALSE if not.

exemple : I want return TRUE if I have Bacca sword AND Heavy blaster, FALSE if not.

I know it begins by :

int StartingConditional()

other question : is there an index or some files where I can find some commands and "name of things" (exemple : K_STAR_MAP)

thank you

Darth333
06-27-2004, 03:16 AM
here are two examples:

int nStar = GetGlobalNumber("K_STAR_MAP");
int nResult = GetGlobalNumber("KOR_DANEL");
if ((nResult == 6) && (nStar==50))


int nResult = GetGlobalNumber("KOR_DANEL");
int nPlot = GetGlobalBoolean("K_SWG_DUSTIL1");
if ((nResult == 6) && (nPlot == FALSE))


MOst useful .nss file is nwscript.nss

You may also find useful TK012's Global Variable Comparison tool. (Check the Guide for the Newbie (http://www.lucasforums.com/showthread.php?s=&threadid=129789) sticky for special tools)

jrc24
06-27-2004, 03:24 AM
thank you for your explanation (if &&)

where can I find a item name list please ? (not item name type g_x_xxxxxx)

this type :

K_STAR_MAP
KOR_DANEL
etc...

thank you very much

Darth333
06-27-2004, 03:26 AM
Use the Global Variable Comparison tool ;)

jrc24
06-27-2004, 04:41 AM
ok I took a look on Global Variable Comparison tool, i see it can be very usefull.

but i would ask to you something

can I do that ?

int ? = GetObjectByTag("k35_itm_sithhpass");
int ? = GetObjectByTag("g_w_vbroswrd05");
if ((? == ?) && (? == ?))

if yes what must I put instead of ?

thank you very much darth333

Darth333
06-27-2004, 08:46 AM
I haven't tested this and it might not work but you could try:

int StartingConditional()
{
object oPC = GetPCSpeaker();
object oSword = GetItemPossessedBy(oPC, "g_w_vbroswrd05");
object oPass = GetItemPossessedBy(oPC, "k35_itm_sithpass");

if ((GetIsObjectValid(oSword) == TRUE) && (GetIsObjectValid(oPass) == TRUE))
{
return TRUE;
}
else
{
return FALSE;
}
}

jrc24
06-27-2004, 10:11 AM
I try that :

I speak with Zaalbar, he has g_w_vbroswrd05 and g_i_belt012

int StartingConditional() {
object oPC = GetPCSpeaker();
object oSword = GetItemPossessedBy(oPC, "g_w_vbroswrd05");
object oBelt = GetItemPossessedBy(oPC, "g_i_belt012");
if ((GetIsObjectValid(oSword) == TRUE) && (GetIsObjectValid(oBelt) == TRUE))
{
return TRUE;
}
else
{
return FALSE;
}
}

it doesn t work

----------------------

I try that too :

int StartingConditional() {
object oPC = GetPCSpeaker();
object oSword = GetItemPossessedBy(oPC, "g_w_vbroswrd05");
object oBelt = GetItemPossessedBy(oPC, "g_i_belt012");
if ((GetIsObjectValid(oSword) == TRUE) && (GetIsObjectValid(oBelt) == TRUE))
{
return TRUE;
}
return FALSE;
}

it doesn t work

-----------------------

if I write that :

int StartingConditional() {
int nStar = GetGlobalNumber("K_STAR_MAP");
int nResult = GetGlobalNumber("K_XOR_AMBUSH");
if ((nResult == 2) && (nStar==50))
{
return TRUE;
}
return FALSE;
}

it works very well

------------------------

if you see what could be the problem

thank you

tk102
06-27-2004, 10:25 AM
I've found it's less confusing to myself if I use the GetObjectByTag function for nearly everything. So instead of
oPC=GetPCSpeaker();, which is the same as GetFirstPC() in this case,

try
oPC=GetObjectByTag("Zaalbar");

jrc24
06-27-2004, 11:32 AM
yeeeeeeeeees !! with

oPC=GetObjectByTag("Zaalbar");

it works !! :D :D

a last question, if I want that the script verify if I have some items but not on a NPC but everywhere : on NPC, on FirstPC and in Inventory. :confused:

because for exemple, sith pass is not on NPC or FirstPC

if you know

thank you very much darth333 and tk102

tk102
06-27-2004, 12:18 PM
I think this should work.

int StartingConditional() {
int nFound=FALSE;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="k35_itm_sithpass") {
nFound=TRUE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}
return nFound;
}

jrc24
06-27-2004, 12:57 PM
ok I check your script in the game it works very well

It seeks the item in inventory and it find it, but it never find the item if the item is in firstpc hand or other party member hand or head or arm (for mask and armband)

what must I write if I want the script seeks in inventory and in equiped items of each party member and fisrtpc ?

thank you

tk102
06-27-2004, 01:16 PM
int StartingConditional() {
int nFound=FALSE;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="k35_itm_sithpass") {
nFound=TRUE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}

if (!nFound) {
while (GetIsObjectValid(oPC)) {
oThisItem=GetItemPossessedBy(oPC, "k35_itm_sithpass");
if (GetIsObjectValid(oThisItem)) {
nFound=TRUE;
break;
}
oPC=GetNextPC();
}
}

return nFound;
}

Bring it on jrc24!

jrc24
06-27-2004, 03:03 PM
really thank you, I learn many things today

with your last script, I can do that I wanted when I posted this thread.

but there is a thing :

oPC=GetNextPC(); doesn t work

the script seeks and finds items in firstpc inventory and in firstpc equipped items, but not in other party member equipped items

I don t need but if you know why that is not working it is very interesting

thank you

tk102
06-27-2004, 03:53 PM
Try inserting oPC=GetFirstPC();in betweenif (!nFound) {andwhile (GetIsObjectValid(oPC)) {Maybe it needs to be reminded where it left off...

jrc24
06-27-2004, 04:33 PM
no, problem persists....... :confused:

tk102
06-27-2004, 11:25 PM
Not to be daunted:
int StartingConditional() {
int nFound=FALSE;
int nIndex;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="k35_itm_sithpass") {
nFound=TRUE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}

if (!nFound) {
for (nIndex=0; nIndex<10; nIndex++) {
oPC=GetPartyMemberByIndex(nIndex);
if (GetIsObjectValid(oPC)) {
oThisItem=GetItemPossessedBy(oPC, "k35_itm_sithpass");
if (GetIsObjectValid(oThisItem)) {
nFound=TRUE;
break;
}
}
}
}
return nFound;
}

jrc24
06-28-2004, 03:27 PM
no darth333, tk102 give me the same lines a little higher

this script continues to have the same behavior :confused:

I think it is possible to get that we want by creating object for each party member and ask to script to seeks every possessed object of each party member but the script become longer and it is obvious that your system will be better if it will work.

thanks ;)

tk102
06-28-2004, 03:50 PM
Yes that is the next step. I think you can carry on from here...

Darth333
06-28-2004, 05:11 PM
I think you found the viable solution jrc24 :)

Just an observation on what i noticed in Kotor:

I've been looking at how the game deals with this. It is obvious that there are similar checks in some situations.
Per example, the sith papers you need to get to lower taris or the Krayt Dragon Pearl that you may give to the Sand people.

for the sith papers hte script is this one:
int StartingConditional()
{
return(GetIsObjectValid(GetItemPossessedBy(GetFirs tPC(),"ptar_sithpapers")));
}

That is not a problem, since the sith papers are not equippable.

For the pearl, it's this:
int StartingConditional()
{
object oPC = GetPCSpeaker();
object oDragonPearl = GetItemPossessedBy(oPC, "tat18_dragonprl");

if (GetIsObjectValid(oDragonPearl) == TRUE)
{
return TRUE;
}
else
{
return FALSE;
}
}
So basically the same thing. Now, if I recall, if you equip your lightsaber with that pearl before speaking to the sand people, they will continue to tell you to get the pearl... same thing with the gaffi stick: when the player has it, no problem but equip another npc with it and the conversation options simply don't appear.

Now, there are some checks too to see if you have sith uniform equipped or the sand people robes per example. The scripts are different. Those "items" are actually disguises (look at k_ptat_sandper.nss and k_ptar_sitharm.nss and those two disguises appear in the spells.2da file. :p

jrc24
06-28-2004, 07:35 PM
THANK YOU VERY MUCH TK102 AND DARTH333 FOR ALL THIS VERY INTERESTING INFORMATIONS !!!

:D :D :D :D :D :D :D :D :D :D

Veldrin
12-26-2004, 02:33 AM
Ok I use this script but something is wrong. Maybe in dlg file.

I wrote this script, and in dlg file in the Starting list in script line, wrote the name of script. But it doesen't work :confused:

My script:

int StartingConditional() {
int nFound=FALSE;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="k35_itm_sithpass") {
nFound=TRUE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}
return nFound;
}

Everything is like this.

Hepl pls!!!

Darkkender
12-26-2004, 06:39 AM
Originally posted by Veldrin
Ok I use this script but something is wrong. Maybe in dlg file.

I wrote this script, and in dlg file in the Starting list in script line, wrote the name of script. But it doesen't work :confused:

My script:

int StartingConditional() {
int nFound=FALSE;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="k35_itm_sithpass") {
nFound=TRUE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}
return nFound;
}

Everything is like this.

Hepl pls!!!


Well it looks like a key element of your script is missing would be part of the problem. When you use a while statement in a script or program it is set up similiar to a if (then) else statement. You need to tell the script what to do if your condition is not being met.

when tk102 used this scriptabove
int StartingConditional() {
int nFound=FALSE;
int nIndex;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="k35_itm_sithpass") {
nFound=TRUE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}

if (!nFound) {
for (nIndex=0; nIndex<10; nIndex++) {
oPC=GetPartyMemberByIndex(nIndex);
if (GetIsObjectValid(oPC)) {
oThisItem=GetItemPossessedBy(oPC, "k35_itm_sithpass");
if (GetIsObjectValid(oThisItem)) {
nFound=TRUE;
break;
}
}
}
}
return nFound;
}

it established the extra switch in the if (!nFound) portion of the script. Even though it does not appear as part of the code for the while statement it is there for the rest of the time when the while does not apply.

Veldrin
12-27-2004, 07:21 AM
This is link to my
Test mod

:http://members.lycos.co.uk/jabusan/test.MOD


Please test it and find Bugs. PLS.!!:(


What I must do? What like script? Wrote it pls!!!:(

waterhammer
12-27-2004, 12:08 PM
Veldrin, I looked at your dialog in GFF editor and I see your starting list has the condition script in the second node and no condition in the first node. This means that the first node will always get spoken and never the second node. You should put your condition first and then, if that fails, the other thing will be spoken.

Also I looked at your .nss file but it does not have this final part:

return nFound;

In fact it seems to miss a } at the end too so it could not compile for me until I added it. If you don't have the return nFound part then it will always return false.

Hope this helps.

Veldrin
12-28-2004, 12:54 AM
Ok thx. I change the script to the first line and it works:D :D

In fact I create new script:

In Firts tree script is when we HAVE item, looks like that:

int StartingConditional() {
int nFound=FALSE;
int nIndex;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="ITEMTAG") {
nFound=TRUE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}

if (!nFound) {
for (nIndex=0; nIndex<10; nIndex++) {
oPC=GetPartyMemberByIndex(nIndex);
if (GetIsObjectValid(oPC)) {
oThisItem=GetItemPossessedBy(oPC, "ITEMTAG");
if (GetIsObjectValid(oThisItem)) {
nFound=TRUE;
break;
}
}
}
}
return nFound;
}


And in the Second Tree when we HAVEN'T item scirpt is like that:
int StartingConditional() {
int nFound=TRUE;
int nIndex;
object oPC=GetFirstPC();
object oThisItem=GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oThisItem)) {
if (GetTag(oThisItem)=="ITEMTAG") {
nFound=FALSE;
break;
}
oThisItem=GetNextItemInInventory(oPC);
}

if (!nFound) {
for (nIndex=0; nIndex<10; nIndex++) {
oPC=GetPartyMemberByIndex(nIndex);
if (GetIsObjectValid(oPC)) {
oThisItem=GetItemPossessedBy(oPC, "ITEMTAG");
if (GetIsObjectValid(oThisItem)) {
nFound=FALSE;
break;
}
}
}
}
return nFound;
}