Aller au contenu

Photo

Remove all items in PC's inventory and equipped slots?


  • Veuillez vous connecter pour répondre
12 réponses à ce sujet

#1
Hardishane

Hardishane
  • Members
  • 5 messages
I'm newly returned to NWN2 scripting after a few years forced break, as my comp did not handle the editor well Posted Image
Now that I'm back I'm creating a new module, were the PC's starting the story have lost all their equipment, anyone know a good script that removes all possessions of an entering PC, without the use of conversation? That is, removing the PC's equipment when loading the module.

I'm sure there is a post on this somwhere, but after a fruitless search, I'm resorting to this... anyone who can help me or have link to a post concerning this?

Modifié par Hardishane, 04 avril 2012 - 09:50 .


#2
kevL

kevL
  • Members
  • 4 056 messages
Here's the best thread for a while about this,

How do you Destroy a Party's Inventory (Solved)


it was meant for conversation, but can be adapted to the OnClientEnter event slot of the start module itself ( don't forget to put in a check for if it has already been run on a character, so toons don't get hit twice+ if reload )

#3
Morbane

Morbane
  • Members
  • 1 883 messages
void main()
{
object oPC = GetEnteringObject(); //this is where you decide how or why the script is run on the main PC
object oFM = GetFirstFactionMember(oPC, FALSE);
object oItem = GetFirstItemInInventory(oFM);

while (GetIsObjectValid(oFM))
{
while (GetIsObjectValid(oItem))
{
DestroyObject(oItem, 0.0f, FALSE);
oItem = GetNextItemInInventory(oFM);
}
int nSlot = 0;
while ( nSlot <= NUM_INVENTORY_SLOTS )
{
object oItem = GetItemInSlot(nSlot, oFM);
if (GetIsObjectValid(oItem))
{
DestroyObject(oItem, 0.0f, 0);
}
nSlot++;
}
oFM = GetNextFactionMember(oFM, FALSE);
}
}

Modifié par Morbane, 05 avril 2012 - 08:04 .


#4
kamal_

kamal_
  • Members
  • 5 240 messages

Morbane wrote...

void main()
{
object oPC = GetEnteringObject(); //this is where you decide how or why the script is run on the main PC
object oFM = GetFirstFactionMember(oPC, FALSE);
object oItem = GetFirstItemInInventory(oFM);

while (GetIsObjectValid(oFM))
{
while (GetIsObjectValid(oItem))
{
DestroyObject(oItem, 0.0f, FALSE);
oItem = GetNextItemInInventory(oFM);
}
int nSlot = 0;
while ( nSlot <= NUM_INVENTORY_SLOTS )
{
object oItem = GetItemInSlot(nSlot, oFM);
if (GetIsObjectValid(oItem))
{
DestroyObject(oItem, 0.0f, 0);
}
nSlot++;
}
oFM = GetNextFactionMember(oFM, FALSE);
}
}

Careful, that destroys the euipment, not "takes it" (presumably to give back later). That may not be what you want OP.

#5
Shaughn78

Shaughn78
  • Members
  • 637 messages
Look at the ginc_item include script. I believe it has some functions to take items.

Since this is at the start of a module it may not matter but that script will destroy plot items and creature slot items.

#6
Morbane

Morbane
  • Members
  • 1 883 messages
I figured "lost" meant not retrievable.

In the link KevL gave the other script I posted stores "taken" items in a container - but it could also be shortened using some code Kaldor Silverwand enlightened readers with - which I used in the script in this post.

#7
Hardishane

Hardishane
  • Members
  • 5 messages
Thx guys... the idea was that on first entry into the module all equipment are lost... as in destroyed... then they get a tag that tells the script on a later entry not to destroy the items.

I'll try all of them to see which of them fits my style of scripting... having trouble getting back into the mindsett for nwn scripting... but will get there.

Modifié par Hardishane, 05 avril 2012 - 05:55 .


#8
Morbane

Morbane
  • Members
  • 1 883 messages
EDITED to avoid confusion :blink:

Modifié par Morbane, 06 avril 2012 - 03:23 .


#9
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
The on-client enter also fires when players reload a saved game.

#10
Morbane

Morbane
  • Members
  • 1 883 messages

Lugaid of the Red Stripes wrote...

The on-client enter also fires when players reload a saved game.


In that case just to offer a quick solution:

if(GetLocalInt(oPC, "once") == TRUE) return; //goes at the very top just under declaring oPC

SetLocalInt(oPC, "once", TRUE); //goes at the very bottom

Modifié par Morbane, 06 avril 2012 - 03:26 .


#11
bealzebub

bealzebub
  • Members
  • 352 messages
If the PCs have any animal companions or familiars when they enter the area, you may run into the problem of lost animal weapons and hides. You may want to specify the PC and any possible companions instead of all faction members in your OnEnter script.

#12
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I have one that does this and puts all the equipment in a container designated by a specific tag. It also creates and equips a wizard's robe on the character.

/////////////////////////////////////
/*strips PC's gear, moves it to the chest in the evil tower, gives the PC a
wizard's robe and equips it.
*/






void main()
{

object oPC = GetFirstPC();
object oEquippedItem;
object oItemChest = GetObjectByTag("twa_item_chest");
int nCounter = 0;

while (nCounter < 19)
{
oEquippedItem = GetItemInSlot(nCounter,oPC);
AssignCommand(oPC,ActionUnequipItem(oEquippedItem));
CopyItem(oEquippedItem,oItemChest,TRUE);
DestroyObject(oEquippedItem);
nCounter++;
}



object oItem = GetFirstItemInInventory();

while (GetIsObjectValid(oItem))
{
FloatingTextStringOnCreature("worked",oPC);
CopyItem(oItem,oItemChest,TRUE);
DestroyObject(oItem);
oItem = GetNextItemInInventory();
}

CreateItemOnObject("nw_cloth005",oPC);
object oRobe = GetObjectByTag("NW_CLOTH005");
AssignCommand(oPC,ActionEquipItem(oRobe,INVENTORY_SLOT_CHEST));
}

#13
kamal_

kamal_
  • Members
  • 5 240 messages

M. Rieder wrote...

I have one that does this and puts all the equipment in a container designated by a specific tag. It also creates and equips a wizard's robe on the character.

Saved me from having to write a complete system, I only had to add some code of my own, thanks.