PDA

View Full Version : Script to know what I'm wearing


GeorgNihilus
05-22-2007, 07:18 PM
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, 07:24 PM
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, 07:33 PM
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, 07:38 PM
Okay, i stand corrected, lol, I've never seen that script before.

stoffe
05-22-2007, 08:08 PM
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, 02:23 PM
Clever :)

GeorgNihilus
05-24-2007, 09:32 AM
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
Ok guys now let us say I want to use these scripts for KOTOR I ... so Im 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
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
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
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
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, 07:22 PM
thanks guys ;) ... it's working, still I have to do some more testing in different characters ... of both games ... :nod:

GeorgNihilus
06-26-2007, 07:10 PM
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, 07:40 PM
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, 06:03 PM
Thanks Stoffe, very helpful as usual ... ;)

GeorgNihilus
07-28-2007, 03:12 PM
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, 03:21 PM
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, 03:59 PM
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
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, 04:11 PM
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, 04:27 PM
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, 08:22 PM
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 ...