Aller au contenu

Photo

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


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

#1
Alupinu

Alupinu
  • Members
  • 528 messages
How do you destroy an entire party’s inventory? In a conv?

I can get the speaking oPC inventory and destroy it but trying to get the entire party’s inventory has proved a bit of a challenge.

Any ideas?

Modifié par Alupinu, 08 mars 2012 - 08:39 .


#2
Dann-J

Dann-J
  • Members
  • 3 161 messages
There's a LootInventory() function in "x0_i0_corpses". I know it works on loot bags, but I don't know if it works on living creatures. It transfers inventory items from one object to another (like a hidden chest, another creature, or even a store object). You may have to unequip everything first though.

You'd need a script that loops through each party member using GetFirst/NextFactionMember.

Or if you wanted to loot each individual party member's inventory by name, you could use something like the following (multiple times, once for each party member):

//ga_loot_inventory
#include "x0_i0_corpses"
void main(string sOriginTag, string sChestTag)
{
object oOrigin = OBJECT_SELF;
if (sOriginTag != "")
oOrigin = GetObjectByTag(sOriginTag);
object oChest = GetPCSpeaker();
if (sChestTag != "")
 oChest = GetObjectByTag(sChestTag);
LootInventory(oOrigin, oChest);
}

Modifié par DannJ, 08 mars 2012 - 02:29 .


#3
bealzebub

bealzebub
  • Members
  • 352 messages
Here's a script I made. Use it in a conversation and just add an objects tag and a recieving objects tag. $PC for the PC.


// ga_unequip_inventory
// takes an objects inventory and places it in a chest.
// string sName = name of object to be striped. For PC, use $PC
// string sChest = tag of the chest to place objects in.
// bealzebub 12/15/2011

void main(string sName, string sChest)
{
object oPC = GetObjectByTag(sName);
object oTarget;
oTarget = GetObjectByTag(sChest);
object oItem;
oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
   {
   AssignCommand(oTarget, ActionTakeItem(oItem, oPC));
   oItem = GetNextItemInInventory(oPC);
   }
int nInt;
for (nInt=0; nInt<NUM_INVENTORY_SLOTS; nInt++)
   {
   oItem = GetItemInSlot(nInt, oPC);
   if (GetIsObjectValid(oItem))
         AssignCommand(oTarget, ActionTakeItem(oItem, oPC));
   }
AssignCommand(oTarget, TakeGoldFromCreature(GetGold(oPC), oPC));
}

#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
Try this. Cobbled together from a couple of other scripts of mine. Compiled but not tested.

// ga_bb_destroy_inventory
// by Brendan Bellina, March, 2012

// Parms:
// bEntireParty = TRUE to delete inventory from all party members instead of just the PC Speaker

void DestroyAllItems(object oTarget, float fDelay=0.0f, int nDisplayFeedback=TRUE, int nInventoryOnly=FALSE);
void PrepItemForDestruction (object oTarget);

void PrepItemForDestruction(object oTarget)
{
SetPlotFlag(oTarget,FALSE);
SetImmortal(oTarget,FALSE);
AssignCommand(oTarget,SetIsDestroyable(TRUE,FALSE,FALSE));
}

void DestroyAllItems(object oTarget, float fDelay=0.0f, int nDisplayFeedback=TRUE, int nInventoryOnly=FALSE)
{
if (GetIsObjectValid(oTarget))
{
// Destroy items in inventory
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem))
{
PrepItemForDestruction(oItem);
DestroyObject(oItem, fDelay, nDisplayFeedback);
}
oItem = GetNextItemInInventory(oTarget);
}

if (!nInventoryOnly)
{
// Destroy items in equip slots
int nSlot = 0;
while ( nSlot <= NUM_INVENTORY_SLOTS )
{
object oItem = GetItemInSlot(nSlot,oTarget);
if (GetIsObjectValid(oItem))
{
PrepItemForDestruction(oItem);
DestroyObject(oItem, fDelay, nDisplayFeedback);
}
nSlot++;
}
}
}

void main(int bEntireParty)
{
object oPC = GetPCSpeaker();
object oPCF = GetFirstFactionMember(oPC,FALSE);

if (bEntireParty)
{
while (GetIsObjectValid(oPCF))
{
DestroyAllItems(oPCF, 0.0, FALSE, FALSE);
oPCF = GetNextFactionMember(oPC,FALSE);
}
}
else
{
DestroyAllItems(oPCF, 0.0, FALSE, FALSE);
}
}

#5
Morbane

Morbane
  • Members
  • 1 883 messages
Just in case you might find it easier to read, I will post the destroy script that I am using in my Tomb of Horrors PnP conversion. It does not destroy plot items (like Kaldor's does)

void main()
{

object oPC = GetPCSpeaker();
object oFM = GetFirstFactionMember(oPC, FALSE);
object oItem = GetFirstItemInInventory(oFM);
//object oTarget = GetObjectByTag("rip_off_box");

while (GetIsObjectValid(oFM))
{
while (GetIsObjectValid(oItem))
{
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetNextItemInInventory(oFM);
}

oItem = GetItemInSlot(INVENTORY_SLOT_CHEST, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_BOOTS, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_ARMS, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_ARROWS, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_BELT, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_BOLTS, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_BULLETS, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_CLOAK, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oFM);
CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_CWEAPON_L, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_HEAD, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_CWEAPON_R, oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_LEFTRING,oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_NECK,oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oFM);
//CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);

oFM = GetNextFactionMember(oFM, FALSE);
}

}

Modifié par Morbane, 08 mars 2012 - 08:17 .


#6
Morbane

Morbane
  • Members
  • 1 883 messages
[Botched post]


[Repaired Post]
Below incorporates Kaldor's nice and neat equipped slot destruction.

It is the shortest script I could come up with provided that I modified my previously posted script.

**Does not destroy PLOT items**

(Props to Kaldor)

Modifié par Morbane, 08 mars 2012 - 08:37 .


#7
Morbane

Morbane
  • Members
  • 1 883 messages
void main()
{
object oPC = GetPCSpeaker();
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, 08 mars 2012 - 08:56 .


#8
Alupinu

Alupinu
  • Members
  • 528 messages
Wow it’s like waking up on Christmas morning all these great scripts to choose from.
Want to thank everybody (DannJ, bealzebub, kaldor Silverwand and Morbane) for taking the time to answer/post for my little problem.
I copied/past everybodys scripts to my ts and now have the situation working to my satisfaction and hopefully it will stay that way. LOL
Thanks again everybody, got to love this community.