Currently in Morbane's Tomb of Horrors, (the foundation we branched from), there is a script that takes a player's - or even the entire party's - equipment, destroys it, and then places a copy in a chest tagged as rip_off_box.
Here is the code:
void main()
{
object oPC =(GetPCSpeaker()==OBJECT_INVALID?GetEnteringObject():GetPCSpeaker());
object oItem = GetFirstItemInInventory(oPC);
object oTarget = GetObjectByTag("rip_off_box");
while (GetIsObjectValid(oPC))
{
while (GetIsObjectValid(oItem))
{
CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, FALSE);
oItem = GetNextItemInInventory(oPC);
}
int nSlot = 0;
while ( nSlot <= NUM_INVENTORY_SLOTS )
{
object oItem = GetItemInSlot(nSlot, oPC);
if (GetIsObjectValid(oItem))
{
CopyItem(oItem, oTarget);
DestroyObject(oItem, 0.0f, 0);
}
nSlot++;
}
}
oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(GetObjectByTag("throne_scepter")))
{
DestroyObject(GetObjectByTag("throne_scepter"));
oItem = GetNextItemInInventory(oTarget);
}
if(GetLocalInt(GetObjectByTag("throne_scepter"), "cruel") == 1)
CreateObject(OBJECT_TYPE_PLACEABLE, "scepter", GetLocation(GetWaypointByTag("wp_scepter_return")));
}
Some problems that came up in testing:
1: The player might lose irreplaceable keys, runestones and other objects necessary to proceed in the module.
2: If the player being targeted by the "cruelty" script has a packed inventory and/or a few bags of holding, they are going to lose gear *forever*. Anything over the maximum a chest can hold is apparently discarded.
The first option explored was to make a series of rip-off chests for each place the Tomb can steal a player's gear... but that didn't solve the problem of destroyed items when a pack-rat hits the trap - or the designated vendor-trash-player, since the script starts with inventory and then works it's way to worn gear, (it empty's bags of holding into rip_off_box) - which will make it almost certain the player will have his items permanently destroyed and be left with stacks of Kobold Short swords, beetle legs and leather armor when they finally open the chest.
Given these problems, I've been working all afternoon and evening on a script which will ONLY take equipped items - here is what I have so far: (Yes, I am slow. I am learning, but at a glacial pace - my degree says "fine art" and it shows).
//Script to strip equipment and place it in a chest based on dialog. Sabranic 5/7/16
void main()
{
object oPC = GetPCSpeaker();
object oItem0 = GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oPC);
object oItem1 = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
object oItem2 = GetItemInSlot(INVENTORY_SLOT_LEFTRING, oPC);
object oItem3 = GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
object oItem4 = GetItemInSlot(INVENTORY_SLOT_ARMS, oPC);
object oItem5 = GetItemInSlot(INVENTORY_SLOT_CLOAK, oPC);
object oItem6 = GetItemInSlot(INVENTORY_SLOT_BOOTS, oPC);
object oItem7 = GetItemInSlot(INVENTORY_SLOT_BELT, oPC);
object oItem8 = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
object oItem9 = GetItemInSlot(INVENTORY_SLOT_NECK, oPC);
object oTarget = GetObjectByTag("rip_off_box");
while (GetIsObjectValid(oItem0))
{
CopyItem(oItem0, oTarget);
DestroyObject(oItem0, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem1))
{
CopyItem(oItem1, oTarget);
DestroyObject(oItem1, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem2))
{
CopyItem(oItem2, oTarget);
DestroyObject(oItem2, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem3))
{
CopyItem(oItem3, oTarget);
DestroyObject(oItem3, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem4))
{
CopyItem(oItem4, oTarget);
DestroyObject(oItem4, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem5))
{
CopyItem(oItem5, oTarget);
DestroyObject(oItem5, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem6))
{
CopyItem(oItem6, oTarget);
DestroyObject(oItem6, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem7))
{
CopyItem(oItem7, oTarget);
DestroyObject(oItem7, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem8))
{
CopyItem(oItem8, oTarget);
DestroyObject(oItem8, 0.0f, FALSE);
}
while (GetIsObjectValid(oItem9))
{
CopyItem(oItem9, oTarget);
DestroyObject(oItem9, 0.0f, FALSE);
}
//Prevents the Scepter from being destroyed and thus making the module unwinnable.
while (GetIsObjectValid(GetObjectByTag("throne_scepter")))
{
DestroyObject(GetObjectByTag("throne_scepter"));
oItem1 = GetNextItemInInventory(oTarget);
}
while (GetIsObjectValid(GetObjectByTag("throne_scepter")))
{
DestroyObject(GetObjectByTag("throne_scepter"));
oItem2 = GetNextItemInInventory(oTarget);
}
if(GetLocalInt(GetObjectByTag("throne_scepter"), "cruel") == 1)
CreateObject(OBJECT_TYPE_PLACEABLE, "scepter", GetLocation(GetWaypointByTag("wp_scepter_return")));
}
Instead of the expected result, the script takes only the right ring, destroys it, and then creates 142 of them and dumps them in the rip_off_box.
I can destroy individual items as I made a pile of scripts to do just that - but I am missing how I need to increment through the whole process so that each step only fires once. I also need to create a version of this that fires for the whole group - including NPC's and other players in the game at the same time, for both the Tomb and the Larger campaign it will be attached to. (The party will have a chance of being captures and tossed in a dungeon).
Thanks for any advice or tips, I am trying to get better at this.





Retour en haut








