Author Topic: Force PC to drop an item from item container  (Read 256 times)

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Force PC to drop an item from item container
« on: July 31, 2013, 08:37:56 pm »


               Maybe I'm missing something simple...

Is there a way to make the PC drop an item from her inventory?

CopyItem with an OBJECT_INVALID target inventory won't work I think since this item will be in an item container in the PCs inventory. I think in that case it will just move from the container to the base inventory. And fire onAcquire.

I'd like to drop it on the ground, but I'd like the variables copied so CopyObject won't do it.

I suppose I could copy the new item again with OBJECT_INVALID and get the result I want. But that will also fire
the acquire event an extra time.

Is that it or is there something I missed?


Thanks,

meaglyn
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Force PC to drop an item from item container
« Reply #1 on: July 31, 2013, 10:22:18 pm »


               // duplicates the item and returns a new object
// oItem - item to copy
// oTargetInventory - create item in this object's inventory. If this parameter
//                    is not valid, the item will be created in oItem's location
// bCopyVars - copy the local variables from the old item to the new one
// * returns the new item
// * returns OBJECT_INVALID for non-items.
// * can only copy empty item containers. will return OBJECT_INVALID if oItem contains
//   other items.
// * if it is possible to merge this item with any others in the target location,
//   then it will do so and return the merged object.
object CopyItem(object oItem, object oTargetInventory=OBJECT_INVALID, int bCopyVars=FALSE)



We use this to put items picked up by PCs back in the auction chest during bidding:


// This method copies a randomised item + fixes its description
object GetRandItemCopy( object oItem,object targetLocation){
            string sMods = GetItemPropString(oItem);
            string sDescription = GetDescription(oItem);
            object copiedObject = CopyItem(oItem,targetLocation,TRUE);
            int nMod = StringToInt(sMods);
            sMods = GetSubString(sMods, FindSubString(sMods, " ") + 1, 10000);

            switch (GetLocalInt(oItem, "Modified")) {
                case 1: {
                    // Is a modified item
                    SetDescription(copiedObject,sDescription);
                }
                break;

                case 2: {
                    // Is a randomised item
                    SetDescription(copiedObject,sDescription);
                }
                break;

                case 3:{
                    // Is an augmenter
                    SetDescription(copiedObject,sDescription);
                }
                break;
                default : SetDescription(copiedObject,sDescription);
            }
    return copiedObject;
}

Oh, on rereading, I guess your core problem is not being able to put it directly on the ground. You can just put it in a place with no walkmesh and then kill the place, dumping the item onto the ground. Sorry, kind of out of patience after the other thread, which took a while to put together. ::

Funky
               
               

               


                     Modifié par FunkySwerve, 31 juillet 2013 - 09:26 .
                     
                  


            

Legacy_painofdungeoneternal

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
Force PC to drop an item from item container
« Reply #2 on: July 31, 2013, 10:44:18 pm »


               Can't you just make them drop it with an action?

http://www.nwnlexico...tionPutDownItem

( this requires some work as its an action to ensure it's done ( to add the word "force" to it), which I think is somewhat covered here http://www.nwnlexico...=SetCommandable even though i think to "force" it, it probably requires more work )
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Force PC to drop an item from item container
« Reply #3 on: August 01, 2013, 01:26:36 am »


               Thanks Funky.

I may try an invisible placeable right at the PC's location which I then destroy that could work.
It's a shame there isn't a little bit more control over items with inventory.

@Pain. I'm trying to have it just drop because the item container was overfilled or the container broke. Don't want the PC to bend down and put it on the ground. I may just live with it going into the
inventory if the invis plc thing is too cumbersome.

thanks for the input,

meaglyn