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.

Taking items from a Character.

Page: 1 of 1
 TimBob12
06-30-2010, 11:35 AM
#1
Hi there,
It's me again with more modding problems. I never really realised how powerful scripting was but now I'm stuck. I know how to give a character an item but I can't for the life of me find how to take an item from a character. I am using a datapad system to check whether dialog responses should be there and I want to take a datapad.

I would be extremely grateful to anyone that helps.

Thanks in advance

TimBob12
 newbiemodder
06-30-2010, 12:20 PM
#2
In Kotor Tool look under Scripts....there is generic script a_take_item that you could attach to your dialog.
 TimBob12
06-30-2010, 12:39 PM
#3
I now have this but I am getting an error for the first paramater of the ActionTakeItem command.

void main()
{
ActionTakeItem( "black_market_pad", GetFirstPC());
}
 newbiemodder
06-30-2010, 1:35 PM
#4
I'm not a good scripting person either, but looking at this command actiontakeitem I think maybe it should be like this

void main() {

object oItem = GetObjectByTag("black_market_pad");

object oTake = GetFirstPC();

ActionTakeItem(oItem, oTake);

}

Try that I'm not sure if it will compile

The a_take_item script from kotortool looks like this:

// a_take_item
// Parameter Count: 2
// Param1 - The quantity of the item to take from the player.
// Param2 - item's tag (as a string)
// This script takes the quantity of the item designated
// in the parameter from the player.
//
// KDS, 07/23/04
void main() {

int nQuantity = GetScriptParameter( 1 );
int i;
string sItem = GetScriptStringParameter();

if(nQuantity == 0) nQuantity = 1;

object oItem = GetItemPossessedBy (GetPartyLeader(),sItem);
if (GetIsObjectValid(oItem))
{
int nStackSize = GetItemStackSize(oItem);
if(nQuantity < nStackSize)
{
nQuantity = nStackSize - nQuantity;
SetItemStackSize(oItem, nQuantity);
}
else if(nQuantity > nStackSize || nQuantity == nStackSize)
{
DestroyObject(oItem);
}
}
}


Where if you are using a dialog editor you just put the script name on the script line and use the parameter boxes to fill in your specifics.
 TimBob12
06-30-2010, 4:54 PM
#5
It now compiles but doesn't remove the item. I was thinking of using the built in script but can't find the parameters boxes. I am using DLGEditor.

Thanks again
 newbiemodder
06-30-2010, 5:03 PM
#6
Try this tutorial...explains it pretty well with pictures...good luck

http://www.lucasforums.com/showthread.php?t=195438&highlight=parameters)
 deathdisco
06-30-2010, 11:26 PM
#7
void main()
{
object oItem = GetObjectByTag("black_market_pad");
DestroyObject(oItem, GetFirstPC());
}

How about this?
 TimBob12
07-01-2010, 2:59 AM
#8
Newbiemodder: Thanks but just realised that's for TSL only. That arrives in the post next week. Im modding KOTOR.

deathdisco: It compiles with a parameter 2 mismatch error.

Hmmm. I'll have a think today.

Edit: Hey thanks guys but just found that it was a simple typo in the dialogue. Thanks again for helping me with the scripts.
Page: 1 of 1