PDA

View Full Version : Taking items from a Character.


TimBob12
06-30-2010, 12:35 PM
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, 01:20 PM
In Kotor Tool look under Scripts....there is generic script a_take_item that you could attach to your dialog.

TimBob12
06-30-2010, 01:39 PM
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, 02:35 PM
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, 05:54 PM
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, 06:03 PM
Try this tutorial...explains it pretty well with pictures...good luck

http://www.lucasforums.com/showthread.php?t=195438&highlight=parameters

deathdisco
07-01-2010, 12:26 AM
void main()
{
object oItem = GetObjectByTag("black_market_pad");
DestroyObject(oItem, GetFirstPC());
}

How about this?

TimBob12
07-01-2010, 03:59 AM
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.