Пример #1
0
 private static void RemoveCachedEffectiveStats(NWItem item)
 {
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_COOLDOWN_RECOVERY");
     item.DeleteLocalFloat("STAT_EFFECTIVE_LEVEL_ENMITY_RATE");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_LUCK_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_MEDITATE_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_REST_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_MEDICINE_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_HP_REGEN_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_FP_REGEN_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_WEAPONSMITH_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_COOKING_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_ENGINEERING_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_FABRICATION_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_ARMORSMITH_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_HARVESTING_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_PILOTING_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_SCAVENGING_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_SNEAK_ATTACK_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_STRENGTH_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_DEXTERITY_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_CONSTITUTION_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_WISDOM_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_INTELLIGENCE_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_CHARISMA_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_HP_BONUS");
     item.DeleteLocalInt("STAT_EFFECTIVE_LEVEL_FP_BONUS");
 }
Пример #2
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)
            {
                ItemService.ReturnItem(player, item);
                player.FloatingText("You cannot scrap this item.");
                return(false);
            }

            // Item is a component but it was crafted. Cannot scrap crafted items.
            if (!string.IsNullOrWhiteSpace(item.GetLocalString("CRAFTER_PLAYER_ID")))
            {
                ItemService.ReturnItem(player, item);
                player.FloatingText("You cannot scrap crafted items.");
                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);
        }