Exemplo n.º 1
0
        public bool Run(params object[] args)
        {
            NWPlaceable container = NWPlaceable.Wrap(Object.OBJECT_SELF);
            NWPlayer    oPC       = NWPlayer.Wrap(_.GetLastDisturbed());
            NWItem      oItem     = NWItem.Wrap(_.GetInventoryDisturbItem());
            int         type      = _.GetInventoryDisturbType();

            if (type == INVENTORY_DISTURB_TYPE_ADDED)
            {
                container.AssignCommand(() => _.ActionGiveItem(oItem.Object, oPC.Object));
                return(true);
            }

            int            overflowItemID = oItem.GetLocalInt("TEMP_OVERFLOW_ITEM_ID");
            PCOverflowItem overflowItem   = _db.PCOverflowItems.Single(x => x.PCOverflowItemID == overflowItemID);

            _db.PCOverflowItems.Remove(overflowItem);
            _db.SaveChanges();

            oItem.DeleteLocalInt("TEMP_OVERFLOW_ITEM_ID");

            if (container.InventoryItems.Count <= 0)
            {
                container.Destroy();
            }
            return(true);
        }
Exemplo n.º 2
0
        public bool Run(params object[] args)
        {
            NWPlaceable container = (Object.OBJECT_SELF);
            NWPlayer    oPC       = (_.GetLastDisturbed());
            NWItem      oItem     = (_.GetInventoryDisturbItem());
            int         type      = _.GetInventoryDisturbType();

            if (type == NWScript.INVENTORY_DISTURB_TYPE_ADDED)
            {
                container.AssignCommand(() => _.ActionGiveItem(oItem.Object, oPC.Object));
                return(true);
            }

            int            overflowItemID = oItem.GetLocalInt("TEMP_OVERFLOW_ITEM_ID");
            PCOverflowItem overflowItem   = _data.Get <PCOverflowItem>(overflowItemID);

            _data.SubmitDataChange(overflowItem, DatabaseActionType.Delete);
            oItem.DeleteLocalInt("TEMP_OVERFLOW_ITEM_ID");

            if (!container.InventoryItems.Any())
            {
                container.Destroy();
            }
            return(true);
        }
Exemplo n.º 3
0
        public void OnCorpseDisturb(NWPlaceable corpse)
        {
            NWPlayer oPC = NWPlayer.Wrap(_.GetLastDisturbed());

            if (!oPC.IsPlayer && !oPC.IsDM)
            {
                return;
            }

            NWItem oItem       = NWItem.Wrap(_.GetInventoryDisturbItem());
            int    disturbType = _.GetInventoryDisturbType();

            if (disturbType == INVENTORY_DISTURB_TYPE_ADDED)
            {
                _.ActionGiveItem(oItem.Object, oPC.Object);
                oPC.FloatingText("You cannot put items into corpses.");
            }
            else
            {
                PCCorpseItem dbItem = _db.PCCorpseItems.SingleOrDefault(x => x.GlobalID == oItem.GlobalID);
                if (dbItem == null)
                {
                    return;
                }

                _db.PCCorpseItems.Remove(dbItem);
                _db.SaveChanges();
            }
        }
Exemplo n.º 4
0
 public void ReturnItem(NWObject target, NWItem item)
 {
     if (_.GetHasInventory(item) == TRUE)
     {
         NWObject possessor = item.Possessor;
         possessor.AssignCommand(() =>
         {
             _.ActionGiveItem(item, target);
         });
     }
     else
     {
         _.CopyItem(item.Object, target.Object, TRUE);
         item.Destroy();
     }
 }
Exemplo n.º 5
0
        public bool Run(params object[] args)
        {
            int type = _.GetInventoryDisturbType();

            if (type != INVENTORY_DISTURB_TYPE_ADDED)
            {
                return(true);
            }
            NWPlaceable device      = Object.OBJECT_SELF;
            NWPlayer    player      = _.GetLastDisturbed();
            NWItem      item        = _.GetInventoryDisturbItem();
            var         componentIP = item.ItemProperties.FirstOrDefault(x => _.GetItemPropertyType(x) == (int)CustomItemPropertyType.ComponentType);

            // Not a component. Return the item.
            if (componentIP == null)
            {
                _item.ReturnItem(player, item);
                player.FloatingText("You cannot scrap this item.");
                return(false);
            }

            // Remove the item properties
            foreach (var ip in item.ItemProperties)
            {
                var ipType = _.GetItemPropertyType(ip);
                if (ipType != (int)CustomItemPropertyType.ComponentType)
                {
                    _.RemoveItemProperty(item, ip);
                }
            }

            // Remove local variables (except the global ID)
            int varCount = _nwnxObject.GetLocalVariableCount(item);

            for (int index = varCount - 1; index >= 0; index--)
            {
                var localVar = _nwnxObject.GetLocalVariable(item, index);

                if (localVar.Key != "GLOBAL_ID")
                {
                    switch (localVar.Type)
                    {
                    case LocalVariableType.Int:
                        item.DeleteLocalInt(localVar.Key);
                        break;

                    case LocalVariableType.Float:
                        item.DeleteLocalFloat(localVar.Key);
                        break;

                    case LocalVariableType.String:
                        item.DeleteLocalString(localVar.Key);
                        break;

                    case LocalVariableType.Object:
                        item.DeleteLocalObject(localVar.Key);
                        break;

                    case LocalVariableType.Location:
                        item.DeleteLocalLocation(localVar.Key);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }

            if (!item.Name.Contains("(SCRAPPED)"))
            {
                item.Name = item.Name + " (SCRAPPED)";
            }

            device.AssignCommand(() =>
            {
                _.ActionGiveItem(item, player);
            });

            return(true);
        }