Exemplo n.º 1
0
        private void StartSmelt(NWPlaceable forge, NWPlayer pc, NWItem item)
        {
            int charges = forge.GetLocalInt("FORGE_CHARGES");

            if (item.Resref == "power_core")
            {
                item.Destroy();
                charges += 10 + CalculatePerkCoalBonusCharges(pc) + GetPowerCoreDurability(item) * 2;
                forge.SetLocalInt("FORGE_CHARGES", charges);

                NWPlaceable flames = (forge.GetLocalObject("FORGE_FLAMES"));
                if (!flames.IsValid)
                {
                    Vector   flamePosition = BiowarePosition.GetChangedPosition(forge.Position, 0.36f, forge.Facing);
                    Location flameLocation = _.Location(forge.Area.Object, flamePosition, 0.0f);
                    flames = (_.CreateObject(_.OBJECT_TYPE_PLACEABLE, "forge_flame", flameLocation));
                    forge.SetLocalObject("FORGE_FLAMES", flames.Object);
                }

                return;
            }
            else if (charges <= 0)
            {
                ReturnItemToPC(pc, item, "You must power the refinery with a power unit before refining.");
                return;
            }

            // Ready to smelt
            float baseCraftDelay = 18.0f - (18.0f * PerkService.GetCreaturePerkLevel(pc, PerkType.SpeedyRefining) * 0.1f);

            pc.IsBusy = true;
            NWNXPlayer.StartGuiTimingBar(pc, baseCraftDelay, string.Empty);

            // Any component bonuses on the ore get applied to the end product.
            var itemProperties = item.ItemProperties.Where(x =>
                                                           _.GetItemPropertyType(x) == (int)CustomItemPropertyType.ComponentBonus ||
                                                           _.GetItemPropertyType(x) == (int)CustomItemPropertyType.RecommendedLevel).ToList();

            string itemResref = item.Resref;

            var @event = new OnCompleteSmelt(pc, itemResref, itemProperties);

            pc.DelayEvent(baseCraftDelay, @event);

            _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), pc.Object, baseCraftDelay);
            pc.AssignCommand(() => _.ActionPlayAnimation(_.ANIMATION_LOOPING_GET_MID, 1.0f, baseCraftDelay));
            item.Destroy();
        }
Exemplo n.º 2
0
        private void HandleBlueprintResponse(int responseID)
        {
            DialogResponse response = GetResponseByID("BlueprintPage", responseID);
            int            blueprintID;

            switch (responseID)
            {
            case 1:     // Examine item
                blueprintID = (int)response.CustomData[string.Empty];
                CraftBlueprint entity        = _craft.GetBlueprintByID(blueprintID);
                NWPlaceable    tempContainer = NWPlaceable.Wrap(_.GetObjectByTag("craft_temp_store"));
                NWItem         examineItem   = NWItem.Wrap(_.CreateItemOnObject(entity.ItemResref, tempContainer.Object));
                GetPC().AssignCommand(() => _.ActionExamine(examineItem.Object));
                examineItem.Destroy(0.1f);
                break;

            case 2:     // Craft this item
                blueprintID = (int)response.CustomData[string.Empty];
                GetPC().SetLocalInt("CRAFT_BLUEPRINT_ID", blueprintID);
                SwitchConversation("CraftItem");
                break;

            case 3:     // Back
                ChangePage("BlueprintListPage");
                break;
            }
        }
Exemplo n.º 3
0
        private static void ToggleDualModeWeapon(NWPlayer oPC)
        {
            NWItem oOriginalItem = _.GetPCItemLastEquipped();
            NWItem oMainHandPistol;

            Player pc = DataService.Player.GetByID(oPC.GlobalID);

            if (pc.ModeDualPistol)
            {
                oMainHandPistol = CreateItemOnObject("dualpistolmain", oPC);
            }
            else
            {
                oMainHandPistol = CreateItemOnObject("blaster_b", oPC);
            }

            oMainHandPistol = CopyWeaponAppearance(oPC, oOriginalItem, oMainHandPistol, true);
            oPC.AssignCommand(() =>
            {
                ActionEquipItem(oMainHandPistol, InventorySlot.RightHand);
            });

            if (pc.ModeDualPistol)
            {
                _.DelayCommand(0.2f, () => { HandleOffhand(oPC, oMainHandPistol); });
            }

            oOriginalItem.Destroy();
        }
Exemplo n.º 4
0
        public void Main()
        {
            NWCreature looter = _.GetLastDisturbed();
            NWItem     item   = _.GetInventoryDisturbItem();
            int        type   = _.GetInventoryDisturbType();

            looter.AssignCommand(() =>
            {
                _.ActionPlayAnimation(_.ANIMATION_LOOPING_GET_LOW, 1.0f, 1.0f);
            });

            if (type == _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                ItemService.ReturnItem(looter, item);
                looter.SendMessage("You cannot place items inside of corpses.");
            }
            else if (type == _.INVENTORY_DISTURB_TYPE_REMOVED)
            {
                NWItem copy = item.GetLocalObject("CORPSE_ITEM_COPY");

                if (copy.IsValid)
                {
                    copy.Destroy();
                }

                item.DeleteLocalObject("CORPSE_ITEM_COPY");
            }
        }
Exemplo n.º 5
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player = (user.Object);

            int starcharts = item.GetLocalInt("Starcharts");

            if (starcharts == 0)
            {
                player.SendMessage("This disk is empty.");
                return;
            }

            // Get the base.
            string          starshipID     = _.GetLocalString(_.GetArea(target), "PC_BASE_STRUCTURE_ID");
            Guid            starshipGuid   = new Guid(starshipID);
            PCBaseStructure starship       = DataService.PCBaseStructure.GetByID(starshipGuid);
            PCBase          starkillerBase = DataService.PCBase.GetByID(starship.PCBaseID);

            starkillerBase.Starcharts |= starcharts;
            DataService.SubmitDataChange(starkillerBase, DatabaseActionType.Update);

            _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_IMP_CONFUSION_S), target);
            _.FloatingTextStringOnCreature("Starcharts loaded!", player);
            item.Destroy();
        }
Exemplo n.º 6
0
        public void Main()
        {
            NWCreature looter = _.GetLastDisturbed();
            NWItem     item   = _.GetInventoryDisturbItem();
            var        type   = _.GetInventoryDisturbType();

            looter.AssignCommand(() =>
            {
                _.ActionPlayAnimation(Animation.LoopingGetLow, 1.0f, 1.0f);
            });

            if (type == DisturbType.Added)
            {
                ItemService.ReturnItem(looter, item);
                looter.SendMessage("You cannot place items inside of corpses.");
            }
            else if (type == DisturbType.Removed)
            {
                NWItem copy = item.GetLocalObject("CORPSE_ITEM_COPY");

                if (copy.IsValid)
                {
                    copy.Destroy();
                }

                item.DeleteLocalObject("CORPSE_ITEM_COPY");
            }
        }
Exemplo n.º 7
0
        private void HandleBlueprintResponse(int responseID)
        {
            DialogResponse response = GetResponseByID("BlueprintPage", responseID);
            int            blueprintID;

            switch (responseID)
            {
            case 1:     // Examine item
                blueprintID = (int)response.CustomData[string.Empty];
                CraftBlueprint entity        = _craft.GetBlueprintByID(blueprintID);
                NWPlaceable    tempContainer = NWPlaceable.Wrap(_.GetObjectByTag("craft_temp_store"));
                NWItem         examineItem   = NWItem.Wrap(_.CreateItemOnObject(entity.ItemResref, tempContainer.Object));
                examineItem.Destroy();

                GetPC().AssignCommand(() => _.ActionExamine(examineItem.Object));
                break;

            case 2:     // Select Blueprint
                blueprintID = (int)response.CustomData[string.Empty];
                GetPC().SendMessage("Blueprint selected. Add necessary resources to the device and click the 'Craft Item' option.");

                NWPlaceable device = (NWPlaceable)GetDialogTarget();
                device.SetLocalInt("CRAFT_BLUEPRINT_ID", blueprintID);
                GetPC().AssignCommand(() => _.ActionInteractObject(device.Object));
                EndConversation();
                break;

            case 3:     // Back
                ChangePage("BlueprintListPage");
                break;
            }
        }
Exemplo n.º 8
0
        private void ProcessItem(NWPlayer oPC, NWItem item, Dictionary <string, PCMigrationItem> itemMap, List <int> stripItemList)
        {
            string          resref         = item.Resref;
            int             quantity       = item.StackSize;
            int             baseItemTypeID = item.BaseItemType;
            PCMigrationItem migrationItem  = itemMap[resref];

            if (itemMap.ContainsKey(resref))
            {
                item.Destroy();
                if (!string.IsNullOrWhiteSpace(migrationItem.NewResref))
                {
                    NWItem newItem = NWItem.Wrap(_.CreateItemOnObject(migrationItem.NewResref, oPC.Object, quantity));
                    if (!newItem.Possessor.IsValid)
                    {
                        PCOverflowItem overflow = new PCOverflowItem
                        {
                            ItemResref = newItem.Resref,
                            ItemTag    = newItem.Tag,
                            ItemName   = newItem.Name,
                            ItemObject = _serialization.Serialize(newItem),
                            PlayerID   = oPC.GlobalID
                        };
                        _db.PCOverflowItems.Add(overflow);
                        _db.SaveChanges();

                        newItem.Destroy();
                    }
                }
            }
            else if (stripItemList.Contains(baseItemTypeID))
            {
                _item.StripAllItemProperties(item);
            }
        }
Exemplo n.º 9
0
        private static void HandleGlovesUnequipEvent()
        {
            NWPlayer oPC   = (_.GetPCItemLastUnequippedBy());
            NWItem   oItem = (_.GetPCItemLastUnequipped());
            int      type  = oItem.BaseItemType;

            if (!oPC.IsPlayer)
            {
                return;
            }
            if (type != BASE_ITEM_BRACER && type != BASE_ITEM_GLOVES)
            {
                return;
            }

            // If fist was unequipped, destroy it.
            if (oItem.Resref == "fist")
            {
                oItem.Destroy();
            }

            // Remove any other fists in the PC's inventory.
            foreach (var fist in oPC.InventoryItems.Where(x => x.Resref == "fist"))
            {
                fist.Destroy();
            }

            // Check in 1 second to see if PC has a glove equipped. If they don't, create a fist glove and equip it.
            ForceEquipFistGlove(oPC);
        }
Exemplo n.º 10
0
        private void HandleRemoveItem()
        {
            NWPlayer    oPC     = (_.GetLastDisturbed());
            NWItem      oItem   = (_.GetInventoryDisturbItem());
            NWPlaceable device  = (Object.OBJECT_SELF);
            NWPlaceable storage = (_.GetObjectByTag("craft_temp_store"));
            var         model   = CraftService.GetPlayerCraftingData(oPC);

            if (oPC.IsBusy)
            {
                ItemService.ReturnItem(device, oItem);
                oPC.SendMessage("You are too busy right now.");
                return;
            }

            if (oItem.Resref == "cft_confirm")
            {
                oItem.Destroy();
                device.DestroyAllInventoryItems();
                device.IsLocked          = false;
                model.IsAccessingStorage = false;
                DialogService.StartConversation(oPC, device, "CraftItem");
                return;
            }

            List <NWItem> items = null;

            switch (model.Access)
            {
            case CraftingAccessType.MainComponent:
                items = model.MainComponents;
                break;

            case CraftingAccessType.SecondaryComponent:
                items = model.SecondaryComponents;
                break;

            case CraftingAccessType.TertiaryComponent:
                items = model.TertiaryComponents;
                break;

            case CraftingAccessType.Enhancement:
                items = model.EnhancementComponents;
                break;
            }

            NWItem copy     = storage.InventoryItems.SingleOrDefault(x => x.GlobalID == oItem.GlobalID);
            NWItem listItem = items?.SingleOrDefault(x => x.GlobalID == oItem.GlobalID);

            if (listItem == null || copy == null || !copy.IsValid)
            {
                return;
            }

            copy.Destroy();
            items.Remove(listItem);
        }
Exemplo n.º 11
0
        private void HandleMainPageResponses(int responseID)
        {
            var model = _craft.GetPlayerCraftingData(GetPC());
            NWPlaceable device = GetDevice();

            switch (responseID)
            {
                case 1: // Examine Base Item
                    CraftBlueprint entity = _craft.GetBlueprintByID(model.BlueprintID);
                    NWPlaceable tempContainer = (_.GetObjectByTag("craft_temp_store"));
                    NWItem examineItem = (_.CreateItemOnObject(entity.ItemResref, tempContainer.Object));
                    GetPC().AssignCommand(() => _.ActionExamine(examineItem.Object));
                    examineItem.Destroy(0.1f);
                    break;
                case 2: // Create item
                    if (!model.CanBuildItem)
                    {
                        GetPC().FloatingText("You are missing some required components.");
                        return;
                    }

                    int effectiveLevel = _craft.CalculatePCEffectiveLevel(GetPC(), model.PlayerSkillRank, (SkillType)model.Blueprint.SkillID);
                    int difficulty = effectiveLevel - model.AdjustedLevel;

                    if(difficulty <= -5)
                    {
                        GetPC().FloatingText("It's impossible to make this item because its level is too high. Use lower-level components to reduce the level and difficulty.");
                        return;
                    }

                    _craft.CraftItem(GetPC(), device);
                    model.IsAccessingStorage = true;
                    EndConversation();
                    break;
                case 3: // Select main components
                    model.Access = CraftingAccessType.MainComponent;
                    OpenDeviceInventory();
                    break;
                case 4: // Select secondary components
                    model.Access = CraftingAccessType.SecondaryComponent;
                    OpenDeviceInventory();
                    break;
                case 5: // Select tertiary components
                    model.Access = CraftingAccessType.TertiaryComponent;
                    OpenDeviceInventory();
                    break;
                case 6: // Select enhancement components
                    model.Access = CraftingAccessType.Enhancement;
                    OpenDeviceInventory();
                    break;
                case 7: // Back (return to blueprint selection)
                    _craft.ClearPlayerCraftingData(GetPC());
                    SwitchConversation("CraftingDevice");
                    break;
            }
        }
Exemplo n.º 12
0
        public void Main()
        {
            NWItem oItem = (_.GetInventoryDisturbItem());
            int    type  = _.GetInventoryDisturbType();

            if (type == _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                oItem.Destroy();
            }
        }
Exemplo n.º 13
0
        public void Main()
        {
            NWItem oItem = (_.GetInventoryDisturbItem());
            var    type  = _.GetInventoryDisturbType();

            if (type == DisturbType.Added)
            {
                oItem.Destroy();
            }
        }
Exemplo n.º 14
0
        public void OnChestDisturbed(NWPlaceable oChest)
        {
            NWPlayer oPC = (_.GetLastDisturbed());

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

            string pcName      = oPC.Name;
            NWItem oItem       = (_.GetInventoryDisturbItem());
            int    disturbType = _.GetInventoryDisturbType();

            if (disturbType == NWScript.INVENTORY_DISTURB_TYPE_ADDED)
            {
                _.CopyItem(oItem.Object, oPC.Object, NWScript.TRUE);
                oItem.Destroy();
            }
            else if (disturbType == NWScript.INVENTORY_DISTURB_TYPE_REMOVED)
            {
                SaveChestInventory(oPC, oChest, false);
                string itemName = oItem.Name;
                if (string.IsNullOrWhiteSpace(itemName))
                {
                    itemName = "money";
                }

                float minSearchSeconds = 1.5f;
                float maxSearchSeconds = 4.5f;
                float searchDelay      = _random.RandomFloat() * (maxSearchSeconds - minSearchSeconds) + minSearchSeconds;

                oPC.AssignCommand(() =>
                {
                    _.ActionPlayAnimation(NWScript.ANIMATION_LOOPING_GET_LOW, 1.0f, searchDelay);
                });

                _.ApplyEffectToObject(NWScript.DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), oPC.Object, searchDelay);

                // Notify party members in the vicinity

                NWPlayer player = (_.GetFirstPC());
                while (player.IsValid)
                {
                    if (_.GetDistanceBetween(oPC.Object, player.Object) <= 20.0f &&
                        player.Area.Equals(oPC.Area) &&
                        _.GetFactionEqual(player.Object, oPC.Object) == NWScript.TRUE)
                    {
                        player.SendMessage(pcName + " found " + itemName + ".");
                    }

                    player = (_.GetNextPC());
                }
            }
        }
Exemplo n.º 15
0
        public bool Run(params object[] args)
        {
            NWItem oItem = NWItem.Wrap(_.GetInventoryDisturbItem());
            int    type  = _.GetInventoryDisturbType();

            if (type == INVENTORY_DISTURB_TYPE_ADDED)
            {
                oItem.Destroy();
            }
            return(true);
        }
Exemplo n.º 16
0
        private void startSmelt(NWPlaceable forge, NWPlayer pc, NWItem item)
        {
            int charges = forge.GetLocalInt("FORGE_CHARGES");

            if (item.Resref == "coal")
            {
                item.Destroy();
                charges += 10 + CalculatePerkCoalBonusCharges(pc);
                forge.SetLocalInt("FORGE_CHARGES", charges);

                NWPlaceable flames = NWPlaceable.Wrap(forge.GetLocalObject("FORGE_FLAMES"));
                if (!flames.IsValid)
                {
                    Vector   flamePosition = _biowarePosition.GetChangedPosition(forge.Position, 0.36f, forge.Facing);
                    Location flameLocation = _.Location(forge.Area.Object, flamePosition, 0.0f);
                    flames = NWPlaceable.Wrap(_.CreateObject(OBJECT_TYPE_PLACEABLE, "forge_flame", flameLocation));
                    forge.SetLocalObject("FORGE_FLAMES", flames.Object);
                }

                return;
            }
            else if (charges <= 0)
            {
                ReturnItemToPC(pc, item, "You must light the forge with coal before smelting.");
                return;
            }
            item.Destroy();

            // Ready to smelt
            float baseCraftDelay = 18.0f - (_perk.GetPCPerkLevel(pc, PerkType.SpeedySmelter) * 0.1f);

            pc.IsBusy = true;
            forge.SetLocalObject("FORGE_USER", pc.Object);
            pc.SetLocalObject("FORGE", forge.Object);
            forge.SetLocalString("FORGE_ORE", item.Resref);

            _nwnxPlayer.StartGuiTimingBar(pc, baseCraftDelay, "cft_finish_smelt");

            _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), pc.Object, baseCraftDelay);
            pc.AssignCommand(() => _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, baseCraftDelay));
        }
Exemplo n.º 17
0
        private static NWItem CopyWeaponAppearance(NWPlayer oPC, NWItem oSource, NWItem oDest, bool copyPropsAndVars)
        {
            NWPlaceable oTempStorage = (GetObjectByTag("OUTFIT_BARREL"));

            oSource.SetLocalString("TEMP_OUTFIT_UUID", oPC.GlobalID.ToString());

            uint oCopy = CopyItem(oDest.Object, oTempStorage.Object, true);

            oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.WeaponModel, 0, (int)GetItemAppearance(oSource, ItemAppearanceType.WeaponModel, 0), true);
            oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.WeaponColor, 0, (int)GetItemAppearance(oSource, ItemAppearanceType.WeaponColor, 0), true);

            oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.WeaponModel, 1, (int)GetItemAppearance(oSource, ItemAppearanceType.WeaponModel, 1), true);
            oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.WeaponColor, 1, (int)GetItemAppearance(oSource, ItemAppearanceType.WeaponColor, 1), true);

            oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.WeaponModel, 2, (int)GetItemAppearance(oSource, ItemAppearanceType.WeaponModel, 2), true);
            oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.WeaponColor, 2, (int)GetItemAppearance(oSource, ItemAppearanceType.WeaponColor, 2), true);

            SetName(oCopy, GetName(oSource));
            SetDescription(oCopy, GetDescription(oSource));
            //LocalVariableService.CopyVariables(oSource, oCopy);

            NWItem oFinal = (CopyItem(oCopy, oPC.Object, true));

            oFinal.DeleteLocalString("TEMP_OUTFIT_UUID");

            if (copyPropsAndVars)
            {
                // strip all item props from new item
                foreach (ItemProperty itemProp in oFinal.ItemProperties)
                {
                    RemoveItemProperty(oFinal, itemProp);
                }
                // add all item props from original item to new item
                foreach (ItemProperty itemProp in oSource.ItemProperties)
                {
                    AddItemProperty(DurationType.Permanent, itemProp, oFinal);
                }
                // finally, copy local vars
                LocalVariableService.CopyVariables(oSource, oFinal);
            }

            DestroyObject(oCopy);
            oDest.Destroy();

            foreach (NWItem item in oTempStorage.InventoryItems)
            {
                if (item.GetLocalString("TEMP_OUTFIT_UUID") == oPC.GlobalID.ToString())
                {
                    item.Destroy();
                }
            }
            return(oFinal);
        }
Exemplo n.º 18
0
        private void FinishActionItem(IActionItem actionItem, NWPlayer user, NWItem item, NWObject target, Location targetLocation, Vector userStartPosition, CustomData customData)
        {
            user.IsBusy = false;

            Vector userPosition = user.Position;

            if (userPosition.m_X != userStartPosition.m_X ||
                userPosition.m_Y != userStartPosition.m_Y ||
                userPosition.m_Z != userStartPosition.m_Z)
            {
                user.SendMessage("You move and interrupt your action.");
                return;
            }

            if (actionItem.MaxDistance() > 0.0f)
            {
                if (_.GetDistanceBetween(user.Object, target.Object) > actionItem.MaxDistance() ||
                    user.Area.Resref != target.Area.Resref)
                {
                    user.SendMessage("Your target is too far away.");
                    return;
                }
            }

            if (!target.IsValid && !actionItem.AllowLocationTarget())
            {
                user.SendMessage("Unable to locate target.");
                return;
            }

            string invalidTargetMessage = actionItem.IsValidTarget(user, item, target, targetLocation);

            if (!string.IsNullOrWhiteSpace(invalidTargetMessage))
            {
                user.SendMessage(invalidTargetMessage);
                return;
            }

            actionItem.ApplyEffects(user, item, target, targetLocation, customData);

            if (actionItem.ReducesItemCharge(user, item, target, targetLocation, customData))
            {
                if (item.Charges > 0)
                {
                    item.ReduceCharges();
                }
                else
                {
                    item.Destroy();
                }
            }
        }
Exemplo n.º 19
0
        private void HandleAddItem()
        {
            NWPlayer    player = _.GetLastDisturbed();
            NWItem      item   = _.GetInventoryDisturbItem();
            NWPlaceable device = Object.OBJECT_SELF;
            var         model  = MarketService.GetPlayerMarketData(player);

            // Serializing containers can be tricky so for the time being we'll leave them disabled.
            if (_.GetHasInventory(item) == TRUE)
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage(ColorTokenService.Red("Containers cannot be sold on the market."));
                return;
            }

            // If selling an item, serialize it and store its information in the player's temporary data.
            if (model.IsSellingItem)
            {
                // Check the item's category. If one cannot be determined, the player cannot put it on the market.
                int marketCategoryID = MarketService.DetermineMarketCategory(item);
                if (marketCategoryID <= 0)
                {
                    ItemService.ReturnItem(player, item);
                    player.FloatingText("This item cannot be placed on the market.");
                    return;
                }

                model.ItemID               = item.GlobalID;
                model.ItemName             = item.Name;
                model.ItemRecommendedLevel = item.RecommendedLevel;
                model.ItemStackSize        = item.StackSize;
                model.ItemTag              = item.Tag;
                model.ItemResref           = item.Resref;
                model.ItemMarketCategoryID = marketCategoryID;
                model.ItemObject           = SerializationService.Serialize(item);
                model.SellPrice            = 0;
                model.LengthDays           = 7;

                item.Destroy();

                device.DestroyAllInventoryItems();
                device.IsLocked = false;
                model.IsReturningFromItemPicking = true;
                model.IsAccessingInventory       = false;
                DialogService.StartConversation(player, device, "MarketTerminal");
            }
            else
            {
                ItemService.ReturnItem(player, item);
            }
        }
Exemplo n.º 20
0
        public static NWItem DeserializeItem(string base64String, NWCreature target)
        {
            if (target == null || !target.IsValid)
            {
                throw new ArgumentException("Invalid target creature during item deserialization.");
            }

            NWItem item   = NWNXObject.Deserialize(base64String);
            var    result = _.CopyItem(item.Object, target.Object, true);

            item.Destroy();

            return(result);
        }
Exemplo n.º 21
0
        public CustomItemType GetCustomItemTypeByResref(string resref)
        {
            NWPlaceable tempStorage = (_.GetObjectByTag("TEMP_ITEM_STORAGE"));

            if (!tempStorage.IsValid)
            {
                Console.WriteLine("Could not locate temp item storage object. Create a placeable container in a non-accessible area with the tag TEMP_ITEM_STORAGE.");
                return(CustomItemType.None);
            }
            NWItem item     = (_.CreateItemOnObject(resref, tempStorage.Object));
            var    itemType = item.CustomItemType;

            item.Destroy();
            return(itemType);
        }
Exemplo n.º 22
0
        public static string GetNameByResref(string resref)
        {
            NWPlaceable tempStorage = (_.GetObjectByTag("TEMP_ITEM_STORAGE"));

            if (!tempStorage.IsValid)
            {
                Console.WriteLine("Could not locate temp item storage object. Create a placeable container in a non-accessible area with the tag TEMP_ITEM_STORAGE.");
                return(null);
            }
            NWItem item = (_.CreateItemOnObject(resref, tempStorage.Object));
            string name = item.Name;

            item.Destroy();
            return(name);
        }
Exemplo n.º 23
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.º 24
0
 public static 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.º 25
0
        public bool Run(params object[] args)
        {
            if (_.GetInventoryDisturbType() != _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                return(false);
            }

            NWPlayer    player = _.GetLastDisturbed();
            NWPlaceable device = Object.OBJECT_SELF;
            NWItem      item   = _.GetInventoryDisturbItem();

            // Check the item type to see if it's valid.
            if (!IsValidItemType(item))
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage("You cannot reassemble this item.");
                return(false);
            }

            // Only crafted items can be reassembled.
            if (string.IsNullOrWhiteSpace(item.GetLocalString("CRAFTER_PLAYER_ID")))
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage("Only crafted items may be reassembled.");
                return(false);
            }

            // DMs cannot reassemble because they don't have the necessary DB records.
            if (player.IsDM)
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage("DMs cannot reassemble items at this time.");
                return(false);
            }

            // Serialize the item into a string and store it into the temporary data for this player. Destroy the physical item.
            var model = CraftService.GetPlayerCraftingData(player);

            model.SerializedSalvageItem = SerializationService.Serialize(item);
            item.Destroy();

            // Start the Molecular Reassembly conversation.
            DialogService.StartConversation(player, device, "MolecularReassembly");

            return(true);
        }
Exemplo n.º 26
0
        public void OnModuleHeartbeat()
        {
            NWModule module = NWModule.Get();

            foreach (NWPlayer pc in module.Players)
            {
                NWItem offHand = pc.LeftHand;
                if (offHand.BaseItemType == BASE_ITEM_TORCH)
                {
                    int charges = offHand.ReduceCharges();
                    if (charges <= 0)
                    {
                        offHand.Destroy();
                        pc.SendMessage("Your torch has burned out.");
                    }
                }
            }
        }
Exemplo n.º 27
0
        private void HandleRemoveItem()
        {
            NWPlayer    player = _.GetLastDisturbed();
            NWItem      item   = _.GetInventoryDisturbItem();
            NWPlaceable device = Object.OBJECT_SELF;
            var         model  = MarketService.GetPlayerMarketData(player);

            // Done previewing an item. Return to menu.
            if (item.Resref == "exit_preview")
            {
                item.Destroy();
                device.DestroyAllInventoryItems();
                device.IsLocked                  = false;
                model.IsAccessingInventory       = false;
                model.IsReturningFromItemPreview = true;
                DialogService.StartConversation(player, device, "MarketTerminal");
            }
        }
Exemplo n.º 28
0
        public static int AddCardToCollection(NWItem card, NWObject collection)
        {
            // Adds the card represented by card to collection, destroying the card item and returning its new index in the collection.
            int CardType = card.GetLocalInt("PAZAAK_CARD_TYPE");

            // Find the first available slot in the collection.
            int index = 1;

            while (collection.GetLocalInt("CARD_" + index) != 0)
            {
                index++;
            }

            collection.SetLocalInt("CARD_" + index, CardType);
            card.Destroy();

            return(index);
        }
Exemplo n.º 29
0
        public static void RunItemDecay(NWPlayer player, NWItem item, float reduceAmount)
        {
            if (reduceAmount <= 0)
            {
                return;
            }
            if (player.IsPlot ||
                item.IsPlot ||
                item.GetLocalInt("UNBREAKABLE") == 1 ||
                !item.IsValid ||
                item.BaseItemType == BaseItem.CreatureItem ||            // Creature skin
                item.BaseItemType == BaseItem.CreatureBludgeWeapon ||    // Creature bludgeoning weapon
                item.BaseItemType == BaseItem.CreaturePierceWeapon ||    // Creature piercing weapon
                item.BaseItemType == BaseItem.CreatureSlashWeapon ||     // Creature slashing weapon
                item.BaseItemType == BaseItem.CreatureSlashPierceWeapon) // Creature slashing/piercing weapon
            {
                return;
            }

            float  durability = GetDurability(item);
            string sItemName  = item.Name;
            int    apr        = NWNXCreature.GetAttacksPerRound(player, true);

            // Reduce by 0.001 each time it's run. Player only receives notifications when it drops a full point.
            // I.E: Dropping from 29.001 to 29.
            // Note that players only see two decimal places in-game on purpose.
            durability -= reduceAmount / apr;
            bool displayMessage = Math.Abs(durability % 1) < 0.05f;

            if (displayMessage)
            {
                player.SendMessage(ColorTokenService.Red("Your " + sItemName + " has been damaged. (" + FormatDurability(durability) + " / " + GetMaxDurability(item)));
            }

            if (durability <= 0.00f)
            {
                item.Destroy();
                player.SendMessage(ColorTokenService.Red("Your " + sItemName + " has broken!"));
            }
            else
            {
                SetDurability(item, durability);
            }
        }
Exemplo n.º 30
0
        public NWItem DeserializeItem(string base64String, NWPlaceable target)
        {
            if (target == null || !target.IsValid)
            {
                throw new ArgumentException("Invalid target placeable during item deserialization.");
            }

            NWItem item = NWItem.Wrap(_nwnxObject.Deserialize(base64String));

            if (item.Object == null)
            {
                throw new NullReferenceException("Unable to deserialize item.");
            }
            var result = NWItem.Wrap(_.CopyItem(item.Object, target.Object, TRUE));

            item.Destroy();

            return(result);
        }