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.

What am I doing wrong here?

Page: 1 of 1
 TheGreenGoblin
07-26-2006, 10:47 PM
#1
I'm trying to create a script to tell Carth to equip an armor I want, here's the script I made (I'm just using p_carth001 for testing), but it doesn't seem to be working. Am I totally off base here, or am I inputting something incorrectly.



void main()
{
object oNPC=GetObjectByTag("p_carth001");
object oOldobject = GetItemInSlot(INVENTORY_SLOT_BODY,OBJECT_SELF);
object oNewobject = CreateItemOnObject("g_a_class9001",OBJECT_SELF);
if (GetIsObjectValid (oOldobject))
{
DestroyObject(oOldobject);
}

AssignCommand(oNPC,ActionEquipItem(oNewobject,INVE NTORY_SLOT_BODY,TRUE));

}
 Darth333
07-26-2006, 10:55 PM
#2
Hehe I seem to recognize this script...

Where did you attached the script? It's either that or a problem with your .uti fileas the script seems ok (I've used it without problems). Edit: duh! It looks like the problem was with the resref of your object and the tag of the npc. hehe I didn't checked those, just the syntax.


Note that the "Oldobject" will get destroyed with this script. If you simply want to unequip the oldobject use:
AssignCommand(oNPC, ActionUnequipItem(oOldobject, TRUE));

But even then, I believe that you don't need this line and that if you equip a new item, the old one will be automatically unequipped.
 TheGreenGoblin
07-27-2006, 12:41 AM
#3
Hehe I seem to recognize this script...

Where did you attached the script? It's either that or a problem with your .uti fileas the script seems ok (I've used it without problems).


Well, right now, I'm just trying to test it by having the script go off by attaching it to Trask's dialogue, specifically when he tells you to hurry up and grab your gear. I'm not any good with triggers, and using dialogue has worked for me in the past. But, the Carth that comes over the comm isn't changing no matter what I try.


What I'm hoping to accomplish is having the Carth's on the Spire in Republic Officer's Uniform as well as the one during the celebration. I've already altered the armor line in the appeareance 2da, so I'm not sure why it isn't working.
 oldflash
07-27-2006, 1:59 AM
#4
I lost 1 day to discover that part with objects is case sensitive. Just to be sure copy from .uti or .utc tag or xresref and paste into script.
 TheGreenGoblin
07-27-2006, 7:51 AM
#5
I lost 1 day to discover that part with objects is case sensitive. Just to be sure copy from .uti or .utc tag or xresref and paste into script.


What do you mean, as in if p_carth was written like P_Carth, or g_a_class9001, G_A_Class9001. If so I've already checked the names of those files and they're perfect. If not, would you mind elaborating?
 oldflash
07-27-2006, 9:31 AM
#6
What do you mean, as in if p_carth was written like P_Carth, or g_a_class9001, G_A_Class9001. If so I've already checked the names of those files and they're perfect. If not, would you mind elaborating?
Seems to be difference betwen g_a_class9001 and G_A_Class9001 at leat for scripts. If item tag is "g_a_class9001" script check for "G_A_Class9001" will return false.
To be sure I don't any more problems I was using this function.

// 61: Convert sString into lower case
// * Return value on error: ""
string GetStringLowerCase(string sString);
 EnderWiggin
07-27-2006, 10:02 AM
#7
I see the problem!

At least... I think I see it.

Here you tell p_carth001 - the party member Carth to equip your item. Now, that's the problem. The comm Carth isn't p_carth001. It's another random Carth filename.

Use TK102's FindRefs program or KT's search function to find all the utc files pointing to Carth. This one probably will be in the RIM files.

Replace p_carth001 with the cutscene Carth *.utc tag and it should work like a charm.

Hope this helps!

Oops... sorry!

_EW_
 Tupac Amaru
07-27-2006, 10:09 AM
#8
object oNPC=GetObjectByTag("p_carth001");It looks like you used the name of the template file. This script function requires an object's tag, not its file name. Normally, the tag for the different Carths in the game is just 'Carth'.
 stoffe
07-27-2006, 11:32 AM
#9
object oNPC=GetObjectByTag("p_carth001");
object oOldobject = GetItemInSlot(INVENTORY_SLOT_BODY,OBJECT_SELF);


Another thing that may cause trouble: Depending on what object runs your script you may get a mismatch between who possesses the armor and who tries to equip it. You create the item on OBJECT_SELF (i.e. the object running the script), but tell Carth to equip it. If the script isn't running on the Carth object he doesn't have the armor to equip.

Try something like this variant where you make sure you both create, destroy and equip on the same NPc:


void CreateAndEquip() {
object oArmor = CreateItemOnObject("g_a_class9001");

object oRemove = GetItemInSlot(INVENTORY_SLOT_BODY);
if (GetIsObjectValid(oRemove))
DestroyObject(oRemove, 0.5);

ActionEquipItem(oArmor, INVENTORY_SLOT_BODY, TRUE);
}

void main() {
AssignCommand(GetObjectByTag("Carth"), CreateAndEquip());
}
 TheGreenGoblin
07-27-2006, 12:27 PM
#10
Worked like a charm! Thanks so much everyone for the help!
 Princess Artemis
07-27-2006, 1:25 PM
#11
Here you tell p_carth001 - the party member Carth to equip your item. Now, that's the problem. The comm Carth isn't p_carth001. It's another random Carth filename.

Use TK102's FindRefs program or KT's search function to find all the utc files pointing to Carth. This one probably will be in the RIM files.

Replace p_carth001 with the cutscene Carth *.utc tag and it should work like a charm.

Just to clarify, since TheGreenGoblin has it working now, p_carth001.utc is the Endar Spire Carth (and about 10 other Carths). p_carth.utc is the party Carth and he only spawns on Taris.
Page: 1 of 1