Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Script to know what I'm wearing

Page: 1 of 1
 GeorgNihilus
05-22-2007, 7:18 PM
#1
Hi guys (and girls...) well I'm looking for a script that checks if my PC or other party member is using a specific robe, for example if the PC is using a master robe tunic or Visas is in her underwear ... just to add some new dialogs ...
Surely this is piece a cake for some of u :)

Thanks on advance ...
 Master Zionosis
05-22-2007, 7:24 PM
#2
I'm not aware of a script that checks if your wearing a certain robe, but there is a script that checks to see if you have a particular item in your inventory.
 tk102
05-22-2007, 7:33 PM
#3
or Visas is in her underwear ... just to add some new dialogs ... Ha ha ha...

Okay, you'd probably want this in a conditional script like the following:

int StartingConditional() {
string sShirtTag = GetScriptStringParameter();
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY,OBJECT_SELF);
if (!GetIsObjectValid(oWearingThis)) { // underwear
return (sShirtTag=="");
}
return (GetTag(oWearingThis)==sShirtTag);
}

Here you would pass the tag of the object you want to check for in the "String Param" field of DLGEditor or leave it blank if you want to check for underwear. The use of OBJECT_SELF in the GetItemInSlot means that it will check the person who is speaking the dialog. You could change that with GetObjectByTag or whatever.
 Master Zionosis
05-22-2007, 7:38 PM
#4
Okay, i stand corrected, lol, I've never seen that script before.
 stoffe
05-22-2007, 8:08 PM
#5
If you want to be able to check for a particular type of clothing instead of an exact piece of clothing (e.g. any "jackboots and bathrobe" master robe instead of "Handmaiden's Robe"), and be able to check the player or a specific party member you can expand on tk102's script to handle that as well. Something like this might work:



int StartingConditional() {
int iBaseItem = GetScriptParameter(1);
int iWho = GetScriptParameter(2);
object oWho = OBJECT_SELF;

switch (iWho) {
case NPC_PLAYER: oWho = GetFirstPC(); break;
case NPC_ATTON: oWho = GetObjectByTag("atton"); break;
case NPC_BAO_DUR: oWho = GetObjectByTag("baodur"); break;
case NPC_CANDEROUS: oWho = GetObjectByTag("mand"); break;
case NPC_DISCIPLE: oWho = GetObjectByTag("disciple"); break;
case NPC_G0T0: oWho = GetObjectByTag("g0t0"); break;
case NPC_HANDMAIDEN: oWho = GetObjectByTag("handmaiden"); break;
case NPC_HANHARR: oWho = GetObjectByTag("hanharr"); break;
case NPC_HK_47: oWho = GetObjectByTag("hk47"); break;
case NPC_KREIA: oWho = GetObjectByTag("kreia"); break;
case NPC_MIRA: oWho = GetObjectByTag("mira"); break;
case NPC_T3_M4: oWho = GetObjectByTag("t3m4"); break;
case NPC_VISAS: oWho = GetObjectByTag("visasmarr"); break;
}


string sShirtTag = GetScriptStringParameter();
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY, oWho);

if (iBaseItem > 0) {
return (GetBaseItemType(oWearingThis) == iBaseItem);
}

return ( sShirtTag == (GetIsObjectValid(oWearingThis) ? GetTag(oWearingThis) : "") );
}



If the P1 parameter is set to a value other than 0 it will check if the equipped item uses that base item type. The number is the line number in the baseitems.2da file of the item type (which is set in the BaseItem field in the UTI template for the clothing/robe/armor).

The P2 parameter should be set to who to check. The number you set here corresponds to the party slot to check:
Player = -1
ATTON = 0
BAO_DUR = 1
CANDEROUS = 2
G0T0 = 3
HANDMAIDEN = 4
HK_47 = 5
KREIA = 6
MIRA = 7
T3_M4 = 8
VISAS = 9
HANHARR = 10
DISCIPLE = 11

Set the P2 parameter to any other value and it will check the dialog owner instead.
 tk102
05-23-2007, 2:23 PM
#6
Clever :)
 GeorgNihilus
05-24-2007, 9:32 AM
#7
Wow guys :urpdude: gonna test them soon ... awesome scripts ... with these may be I can set some sort of undecent proposal to Visas ... or may be the handmaiden ja ja

thanks a lot ... :thmbup1:
 GeorgNihilus
06-02-2007, 11:54 AM
#8
Ok guys now let us say I want to use these scripts for KOTOR I ... so Iґm getting a GetScriptStringParameter() error in line 2 of tk102's first script; guess cause I don't know how to pass if it's possible parameters in KOTOR I, do I need a totally diferent script in this case??? :confused:

Thanks a lot again :thmbup1:
 tk102
06-02-2007, 12:16 PM
#9
GetScriptStringParameter is only available in TSL. One workaround would be to write separate hard-coded scripts for each unique tag you want to search for.


int StartingConditional() {
// you only need to change the following line... use "" for underwear
string sShirtTag = "myshirt";

// the rest remains the same...
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY,OBJECT_SELF);
if (!GetIsObjectValid(oWearingThis)) { // underwear
return (sShirtTag=="");
}
return (GetTag(oWearingThis)==sShirtTag);
}
 GeorgNihilus
06-13-2007, 10:56 AM
#10
So ... I want to check in K1 if Bastila is using a jedi tunic or her underwear, so I must combine tk102's and Stoffe's scripts to get it, but I don't know the party number to check for Bastila, and I can't pass 2 parameters in K1 ... so how can I script this ??? :)
 tk102
06-13-2007, 11:21 AM
#11
So ... I want to check in K1 if Bastila is using a jedi tunic or her underwear, so I must combine tk102's and Stoffe's scripts to get it, but I don't know the party number to check for Bastila, and I can't pass 2 parameters in K1 ... so how can I script this ??? :)
In K1, you have to be specific with your script because you cannot pass parameters to it.

Script that returns TRUE if Bastila is in her underwear:int StartingConditional() {
object oBastila = GetObjectByTag("Bastila");
object oWearingThis=GetItemInSlot(INVENTORY_SLOT_BODY, oBastila);
if (!GetIsObjectValid(oWearingThis)) {
return TRUE;
}
return FALSE;
}
Script that returns TRUE if Bastila is wearing something that has the word "robe" in its tag:int StartingConditional() {
object oBastila = GetObjectByTag("Bastila");
object oWearingThis=GetItemInSlot(INVENTORY_SLOT_BODY, oBastila);
string sWearingThis;
int ix=-1;
if (GetIsObjectValid(oWearingThis)) {
sWearingThis=GetTag(oWearingThis);
ix=FindSubString(sWearingThis, "robe");
if (ix>-1) {
return TRUE;
}
}
return FALSE;
}

Script that returns TRUE for either underwear or "robe":int StartingConditional() {
object oBastila = GetObjectByTag("Bastila");
object oWearingThis=GetItemInSlot(INVENTORY_SLOT_BODY, oBastila);
string sWearingThis;
int ix=-1;
if (GetIsObjectValid(oWearingThis)) {
sWearingThis=GetTag(oWearingThis);
ix=FindSubString(sWearingThis, "robe");
if (ix>-1) {
return TRUE;
}
}
else {
return TRUE;
}
return FALSE;
}
 stoffe
06-13-2007, 11:31 AM
#12
ix=FindSubString(sWearingThis, "robe");
if (ix>-1) {
return TRUE;
}



Alternatively, you can also check the base item type of the equipped item to determine if it is a robe being worn, like:


int StartingConditional() {
object oBastila = GetObjectByTag("Bastila");
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY, oBastila);

if (GetIsObjectValid(oWearingThis)) {
int iType = GetBaseItemType(oWearingThis);
return ((iType == BASE_ITEM_JEDI_ROBE)
|| (iType == BASE_ITEM_JEDI_KNIGHT_ROBE)
|| (iType == BASE_ITEM_JEDI_MASTER_ROBE));

}
else {
return TRUE;
}
}
 GeorgNihilus
06-19-2007, 7:22 PM
#13
thanks guys ;) ... it's working, still I have to do some more testing in different characters ... of both games ... :nod:
 GeorgNihilus
06-26-2007, 7:10 PM
#14
So, what if I want to EQUIP a given robe to a character after ending a dialog, for example to Mira, so she looks with that robe after speaking ... i.e.

PC -Hi Mira, I been thinking this will fit you well in you.
Mira - what? ah let's see... nice outfit ...
PC - take it ... put it on so I see if it fits you...
Mira - OK give it to me ... that's it; hope you like it ...
(end conversation)

and Mira appears with that robe, let's say a jal shey type robe or whatever ...

my question is: can this be scripted? is there such function/s? :giveup:

thanks on advance ;)
 stoffe
06-26-2007, 7:40 PM
#15
So, what if I want to EQUIP a given robe to a character after ending a dialog, for example to Mira, so she looks with that robe after speaking ... i.e.



Something like this can be used to give a robe to someone and make them equip it, assuming the script is run from a dialog with the NPC who should equip the robe:

void main() {
ActionEquipItem(CreateItemOnObject("a_robe_11"), INVENTORY_SLOT_BODY, TRUE);
}
 GeorgNihilus
06-27-2007, 6:03 PM
#16
Thanks Stoffe, very helpful as usual ... ;)
 GeorgNihilus
07-28-2007, 3:12 PM
#17
So guys, now I'm trying to check if the PC in K1 is in his/her undies, using this script:

//:: k_con_pcundi
/*
/*
//:: Created by:

int StartingConditional()
{
object oPC = GetPCSpeaker();
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY, oPC);
if (!GetIsObjectValid(oWearingThis)) {
return TRUE;
}
return FALSE;
}

... and I get this error:

Compiling: k_con_pcundi.nss
k_con_pcundi.nss (15): Warning: End of file reached while processing comment
Total execution time: 16 ms

by the way line 15 is the next after the last closing "}"

processing comment??? :confused: help please ... :(
 glovemaster
07-28-2007, 3:21 PM
#18
Try:

int StartingConditional(){
object oPC = GetPCSpeaker();
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY, oPC);
if (!GetIsObjectValid(oWearingThis)) {
return TRUE;
}
else {
return FALSE;
}
}
 stoffe
07-28-2007, 3:59 PM
#19
The problem is the comment section at the top... you have an opening block comment marker (/*) but no closing block comment marker (*/), effectively commenting out the whole script, leaving nothing to compile.

So, this would work:

//:: k_con_pcundi
//:: Created by:

int StartingConditional()
{
object oPC = GetPCSpeaker();
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY, oPC);
if (!GetIsObjectValid(oWearingThis)) {
return TRUE;
}
return FALSE;
}


However, you don't really need the if-statement in this case, you can just return the negated value from GetIsObjectValid() directly, since it returns TRUE/FALSE. Like:


int StartingConditional() {
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY, GetFirstPC());
return !GetIsObjectValid(oWearingThis);
}


* * *

Try:

else {
return FALSE;
}


It's not wrong to use else there, but not really necessary either. The original script would work in the same way since you'd return if the IF statement is true and thus never reaching the lower return FALSE unless you really should return false.
 GeorgNihilus
07-28-2007, 10:32 PM
#20
Hmmm ... if I only could count back from 10 to 1 ... thanks both of you :thmbup1: ... your script works glovemaster; I didn't know that I have to close comment with */ ... :roleyess: so I was compiling nothing it seems ...
 GeorgNihilus
07-30-2007, 4:11 PM
#21
Now I'm trying to check if Bastila is wearing any armor 7 type robes with this but it's not working :rolleyes: ... even it compiles without errors.

// k_con_bastrobe7
// should return true if Bastila is wearing some of the armor 7 robes...
// Created by:

int StartingConditional() {
object oBastila = GetObjectByTag("Bastila");
object oWearingThis = GetItemInSlot(INVENTORY_SLOT_BODY, oBastila);

if (GetIsObjectValid(oWearingThis)) {
int iType = GetBaseItemType(oWearingThis);
return (iType == BASE_ITEM_ARMOR_CLASS_7);
}
else {
return FALSE;
}
}

what's wrong??
thanks on advance :thmbup1:
 stoffe
07-30-2007, 4:27 PM
#22
Now I'm trying to check if Bastila is wearing any armor 7 type robes with this but it's not working :rolleyes: ... even it compiles without errors.

// k_con_bastrobe7

what's wrong??


There is nothing wrong with that script from what I can tell. What happens in the game, it always acts like she isn't wearing the armor?

Check that the compiled script is in the override folder or the module, that it is actually being run (check for typos in the script name, make sure the name is valid etc) and that Bastila is in the area when the script is run, and that the armor she is wearing actually is of the base item type you check for.
 GeorgNihilus
07-30-2007, 8:22 PM
#23
Yes, she acts like the script is ignored :nod: ... I've changed the tag, template ResRef and the texture variation fields in the .uti file making actually a new outfit ... (a new .uti file dropped to /Override)

can that tag change o texture variation affect the base item? :confused:

thanks as usual ...
Page: 1 of 1