示例#1
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);
            }
        }
示例#2
0
        public string OnModuleExamine(string existingDescription, NWObject examinedObject)
        {
            if (examinedObject.ObjectType != OBJECT_TYPE_ITEM)
            {
                return(existingDescription);
            }

            NWItem examinedItem = NWItem.Wrap(examinedObject.Object);

            if (!IsValidDurabilityType(examinedItem))
            {
                return(existingDescription);
            }

            string description = _color.Orange("Durability: ");
            float  durability  = GetDurability(examinedItem);

            if (durability <= 0.0f)
            {
                description += _color.Red(Convert.ToString(durability));
            }
            else
            {
                description += _color.White(FormatDurability(durability));
            }

            description += _color.White(" / " + GetMaxDurability(examinedItem));

            return(existingDescription + "\n\n" + description);
        }
示例#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();
            }
        }
        public void ToggleHelmetDisplay(NWPlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            if (!player.IsPlayer)
            {
                return;
            }

            PlayerCharacter pc = _db.PlayerCharacters.Single(x => x.PlayerID == player.GlobalID);

            pc.DisplayHelmet = !pc.DisplayHelmet;
            _db.SaveChanges();

            _.FloatingTextStringOnCreature(
                pc.DisplayHelmet ? "Now showing equipped helmet." : "Now hiding equipped helmet.",
                player.Object,
                FALSE);

            NWItem helmet = NWItem.Wrap(_.GetItemInSlot(INVENTORY_SLOT_HEAD, player.Object));

            if (helmet.IsValid)
            {
                _.SetHiddenWhenEquipped(helmet.Object, !pc.DisplayHelmet == false ? 0 : 1);
            }
        }
示例#5
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;
            }
        }
示例#6
0
        public void OnModuleItemUnequipped()
        {
            NWPlayer oPC   = NWPlayer.Wrap(_.GetPCItemLastUnequippedBy());
            NWItem   oItem = NWItem.Wrap(_.GetPCItemLastUnequipped());

            if (!oPC.IsPlayer)
            {
                return;
            }

            List <PCPerk> perks = _db.StoredProcedure <PCPerk>("GetPCPerksByExecutionType",
                                                               new SqlParameter("PlayerID", oPC.GlobalID),
                                                               new SqlParameter("ExecutionTypeID", (int)PerkExecutionType.EquipmentBased));

            foreach (PCPerk pcPerk in perks)
            {
                pcPerk.Perk = _db.Perks.Single(x => x.PerkID == pcPerk.PerkID);
                string jsName = pcPerk.Perk.JavaScriptName;
                if (string.IsNullOrWhiteSpace(jsName))
                {
                    continue;
                }

                IPerk perkAction = App.ResolveByInterface <IPerk>("Perk." + jsName);
                perkAction?.OnItemUnequipped(oPC, oItem);
            }
        }
示例#7
0
        // Gets the player's quickbar slot info
        public QuickBarSlot NWNX_Player_GetQuickBarSlot(NWPlayer player, int slot)
        {
            string       sFunc = "GetQuickBarSlot";
            QuickBarSlot qbs   = new QuickBarSlot();

            NWNX_PushArgumentInt(NWNX_Player, sFunc, slot);
            NWNX_PushArgumentObject(NWNX_Player, sFunc, player.Object);
            NWNX_CallFunction(NWNX_Player, sFunc);

            qbs.Associate     = NWObject.Wrap(NWNX_GetReturnValueObject(NWNX_Player, sFunc));
            qbs.AssociateType = NWNX_GetReturnValueInt(NWNX_Player, sFunc);
            qbs.DomainLevel   = NWNX_GetReturnValueInt(NWNX_Player, sFunc);
            qbs.MetaType      = NWNX_GetReturnValueInt(NWNX_Player, sFunc);
            qbs.INTParam1     = NWNX_GetReturnValueInt(NWNX_Player, sFunc);
            qbs.ToolTip       = NWNX_GetReturnValueString(NWNX_Player, sFunc);
            qbs.CommandLine   = NWNX_GetReturnValueString(NWNX_Player, sFunc);
            qbs.CommandLabel  = NWNX_GetReturnValueString(NWNX_Player, sFunc);
            qbs.Resref        = NWNX_GetReturnValueString(NWNX_Player, sFunc);
            qbs.MultiClass    = NWNX_GetReturnValueInt(NWNX_Player, sFunc);
            qbs.ObjectType    = NWNX_GetReturnValueInt(NWNX_Player, sFunc);
            qbs.SecondaryItem = NWItem.Wrap(NWNX_GetReturnValueObject(NWNX_Player, sFunc));
            qbs.Item          = NWItem.Wrap(NWNX_GetReturnValueObject(NWNX_Player, sFunc));

            return(qbs);
        }
示例#8
0
        public string OnModuleExamine(string existingDescription, NWPlayer examiner, NWObject examinedObject)
        {
            if (examinedObject.ObjectType != OBJECT_TYPE_ITEM)
            {
                return(existingDescription);
            }
            NWItem    examinedItem = NWItem.Wrap(examinedObject.Object);
            string    description  = string.Empty;
            RuneSlots slot         = GetRuneSlots(examinedItem);

            for (int red = 1; red <= slot.FilledRedSlots; red++)
            {
                description += _color.Red("Red Slot #" + red + ": ") + examinedItem.GetLocalString("RUNIC_SLOT_RED_DESC_" + red) + "\n";
            }
            for (int blue = 1; blue <= slot.FilledBlueSlots; blue++)
            {
                description += _color.Red("Blue Slot #" + blue + ": ") + examinedItem.GetLocalString("RUNIC_SLOT_BLUE_DESC_" + blue) + "\n";
            }
            for (int green = 1; green <= slot.FilledGreenSlots; green++)
            {
                description += _color.Red("Green Slot #" + green + ": ") + examinedItem.GetLocalString("RUNIC_SLOT_GREEN_DESC_" + green) + "\n";
            }
            for (int yellow = 1; yellow <= slot.FilledYellowSlots; yellow++)
            {
                description += _color.Red("Yellow Slot #" + yellow + ": ") + examinedItem.GetLocalString("RUNIC_SLOT_YELLOW_DESC_" + yellow) + "\n";
            }
            for (int prismatic = 1; prismatic <= slot.FilledPrismaticSlots; prismatic++)
            {
                description += PrismaticString() + " Slot #" + prismatic + ": " + examinedItem.GetLocalString("RUNIC_SLOT_PRISMATIC_DESC_" + prismatic) + "\n";
            }

            return(existingDescription + "\n" + description);
        }
示例#9
0
        public void OnHitCastSpell(NWPlayer oPC)
        {
            if (!oPC.IsPlayer)
            {
                return;
            }
            NWItem        oItem   = NWItem.Wrap(_.GetSpellCastItem());
            int           type    = oItem.BaseItemType;
            List <PCPerk> pcPerks = _db.StoredProcedure <PCPerk>("GetPCPerksWithExecutionType",
                                                                 new SqlParameter("PlayerID", oPC.GlobalID));

            foreach (PCPerk pcPerk in pcPerks)
            {
                pcPerk.Perk = GetPerkByID(pcPerk.PerkID);
                if (string.IsNullOrWhiteSpace(pcPerk.Perk.JavaScriptName) || pcPerk.Perk.ExecutionTypeID == (int)PerkExecutionType.None)
                {
                    continue;
                }

                IPerk perkAction = App.ResolveByInterface <IPerk>("Perk." + pcPerk.Perk.JavaScriptName);
                if (perkAction == null)
                {
                    continue;
                }

                if (pcPerk.Perk.ExecutionTypeID == (int)PerkExecutionType.ShieldOnHit)
                {
                    if (type == BASE_ITEM_SMALLSHIELD || type == BASE_ITEM_LARGESHIELD || type == BASE_ITEM_TOWERSHIELD)
                    {
                        perkAction.OnImpact(oPC, oItem);
                    }
                }
            }
        }
示例#10
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;
            }
        }
示例#11
0
        public void OnModuleApplyDamage()
        {
            var      data        = _nwnxDamage.GetDamageEventData();
            NWObject damager     = data.Damager;
            NWItem   weapon      = NWItem.Wrap(_.GetLastWeaponUsed(damager.Object));
            int      damageBonus = weapon.DamageBonus;

            if (damager.IsPlayer)
            {
                NWPlayer  player    = NWPlayer.Wrap(damager.Object);
                int       itemLevel = weapon.RecommendedLevel;
                SkillType skill     = _skill.GetSkillTypeForItem(weapon);
                int       rank      = _skill.GetPCSkill(player, skill).Rank;
                int       delta     = itemLevel - rank;
                if (delta >= 1)
                {
                    damageBonus--;
                }
                damageBonus = damageBonus - delta / 5;

                if (damageBonus <= 0)
                {
                    damageBonus = 0;
                }
            }

            data.Base += damageBonus;
            _nwnxDamage.SetDamageEventData(data);
        }
示例#12
0
        public bool Run(params object[] args)
        {
            NWPlayer    oPC         = NWPlayer.Wrap(_.GetLastDisturbed());
            NWItem      oItem       = NWItem.Wrap(_.GetInventoryDisturbItem());
            NWPlaceable point       = NWPlaceable.Wrap(NWN.Object.OBJECT_SELF);
            int         disturbType = _.GetInventoryDisturbType();

            if (disturbType == INVENTORY_DISTURB_TYPE_ADDED)
            {
                _item.ReturnItem(oPC, oItem);
            }
            else
            {
                if (point.InventoryItems.Count <= 0 && point.GetLocalInt("FORAGE_POINT_FULLY_HARVESTED") == 1)
                {
                    string seed = point.GetLocalString("FORAGE_POINT_SEED");
                    if (!string.IsNullOrWhiteSpace(seed))
                    {
                        _.CreateObject(OBJECT_TYPE_ITEM, seed, point.Location);

                        int perkLevel = _perk.GetPCPerkLevel(oPC, PerkType.SeedPicker);
                        if (_random.Random(100) + 1 <= perkLevel * 10)
                        {
                            _.CreateObject(OBJECT_TYPE_ITEM, seed, point.Location);
                        }
                    }

                    point.Destroy();
                    _farming.RemoveGrowingPlant(point);
                }
            }
            return(true);
        }
示例#13
0
        public void DoAction(NWPlayer user, params string[] args)
        {
            if (args.Length <= 0)
            {
                user.SendMessage(_color.Red("Please specify a resref and optionally a quantity. Example: /" + nameof(SpawnItem) + " my_resref 20"));
                return;
            }
            string resref   = args[0];
            int    quantity = 1;

            if (args.Length > 1)
            {
                if (!int.TryParse(args[1], out quantity))
                {
                    return;
                }
            }

            var item = NWItem.Wrap(_.CreateItemOnObject(resref, user.Object, quantity));

            if (!item.IsValid)
            {
                user.SendMessage(_color.Red("Item not found! Did you enter the correct ResRef?"));
                return;
            }

            item.IsIdentified = true;
        }
示例#14
0
        private void ApplyFeatChanges(NWPlayer oPC, NWItem unequippingItem)
        {
            NWItem         mainHand     = oPC.RightHand;
            NWItem         offHand      = oPC.LeftHand;
            CustomItemType mainType     = mainHand.CustomItemType;
            CustomItemType offType      = offHand.CustomItemType;
            bool           receivesFeat = true;

            if (unequippingItem != null && Equals(unequippingItem, mainHand))
            {
                mainHand = NWItem.Wrap(new Object());
            }
            else if (unequippingItem != null && Equals(unequippingItem, offHand))
            {
                offHand = NWItem.Wrap(new Object());
            }

            if ((!mainHand.IsValid && !offHand.IsValid) ||
                (mainType != CustomItemType.MartialArtWeapon || offType != CustomItemType.MartialArtWeapon))
            {
                receivesFeat = false;
            }

            if (receivesFeat)
            {
                _nwnxCreature.AddFeat(oPC, FEAT_DEFLECT_ARROWS);
            }
            else
            {
                _nwnxCreature.RemoveFeat(oPC, FEAT_DEFLECT_ARROWS);
            }
        }
示例#15
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);
        }
示例#16
0
        private void RunCreateItem(NWPlayer oPC, NWPlaceable device)
        {
            var model = GetPlayerCraftingData(oPC);

            CraftBlueprint blueprint = _db.CraftBlueprints.Single(x => x.CraftBlueprintID == model.BlueprintID);
            PCSkill        pcSkill   = _db.PCSkills.Single(x => x.PlayerID == oPC.GlobalID && x.SkillID == blueprint.SkillID);

            int   pcEffectiveLevel = CalculatePCEffectiveLevel(oPC, device, pcSkill.Rank);
            float chance           = CalculateBaseChanceToAddProperty(pcEffectiveLevel, model.AdjustedLevel);
            float equipmentBonus   = CalculateEquipmentBonus(oPC, (SkillType)blueprint.SkillID);

            var    craftedItems = new List <NWItem>();
            NWItem craftedItem  = NWItem.Wrap(_.CreateItemOnObject(blueprint.ItemResref, oPC.Object, blueprint.Quantity));

            craftedItem.IsIdentified = true;
            craftedItems.Add(craftedItem);

            // If item isn't stackable, loop through and create as many as necessary.
            if (craftedItem.StackSize < blueprint.Quantity)
            {
                for (int x = 2; x <= blueprint.Quantity; x++)
                {
                    craftedItem = NWItem.Wrap(_.CreateItemOnObject(blueprint.ItemResref, oPC.Object));
                    craftedItem.IsIdentified = true;
                    craftedItems.Add(craftedItem);
                }
            }

            foreach (var component in model.MainComponents)
            {
                ComponentBonusType bonus = ComponentBonusType.Unknown;
                foreach (var ip in component.ItemProperties)
                {
                    if (_.GetItemPropertyType(ip) == (int)CustomItemPropertyType.ComponentBonus)
                    {
                        bonus = (ComponentBonusType)_.GetItemPropertyCostTableValue(ip);
                    }
                }

                if (bonus == ComponentBonusType.Unknown)
                {
                    continue;
                }

                if (_random.RandomFloat() * 100.0f + equipmentBonus <= chance)
                {
                    foreach (var item in craftedItems)
                    {
                        ApplyComponentBonus(item, bonus);
                    }
                }
            }

            oPC.SendMessage("You created " + blueprint.Quantity + "x " + blueprint.ItemName + "!");
            float xp = _skill.CalculateRegisteredSkillLevelAdjustedXP(250, model.AdjustedLevel, pcSkill.Rank);

            _skill.GiveSkillXP(oPC, blueprint.SkillID, (int)xp);
            ClearPlayerCraftingData(oPC);
        }
示例#17
0
        public void OnModuleItemUnequipped()
        {
            NWPlayer oPC   = NWPlayer.Wrap(_.GetPCItemLastUnequippedBy());
            NWItem   oItem = NWItem.Wrap(_.GetPCItemLastUnequipped());

            HandleGlovesUnequipEvent();
            ApplyStatChanges(oPC, oItem);
            RemoveWeaponPenalties(oItem);
        }
示例#18
0
        public bool Run(params object[] args)
        {
            NWPlaceable plc           = NWPlaceable.Wrap(Object.OBJECT_SELF);
            NWPlayer    oPC           = NWPlayer.Wrap(_.GetLastAttacker());
            NWItem      oWeapon       = NWItem.Wrap(_.GetLastWeaponUsed(oPC.Object));
            int         type          = oWeapon.BaseItemType;
            int         resourceCount = plc.GetLocalInt("RESOURCE_COUNT");

            if (resourceCount <= -1)
            {
                resourceCount = _random.Random(3) + 3;
                plc.SetLocalInt("RESOURCE_COUNT", resourceCount);
            }

            if (type == BASE_ITEM_INVALID)
            {
                oWeapon = oPC.RightHand;
            }

            int activityID = plc.GetLocalInt("RESOURCE_ACTIVITY");

            string improperWeaponMessage = "";
            bool   usingCorrectWeapon    = true;

            if (activityID == 1) // 1 = Logging
            {
                usingCorrectWeapon = oWeapon.CustomItemType == CustomItemType.Blade ||
                                     oWeapon.CustomItemType == CustomItemType.TwinBlade ||
                                     oWeapon.CustomItemType == CustomItemType.HeavyBlade ||
                                     oWeapon.CustomItemType == CustomItemType.FinesseBlade ||
                                     oWeapon.CustomItemType == CustomItemType.Polearm;
                improperWeaponMessage = "You must be using a blade to harvest this object.";
            }
            else if (activityID == 2) // Mining
            {
                usingCorrectWeapon = oWeapon.CustomItemType == CustomItemType.Blade ||
                                     oWeapon.CustomItemType == CustomItemType.TwinBlade ||
                                     oWeapon.CustomItemType == CustomItemType.HeavyBlade ||
                                     oWeapon.CustomItemType == CustomItemType.FinesseBlade ||
                                     oWeapon.CustomItemType == CustomItemType.Polearm ||
                                     oWeapon.CustomItemType == CustomItemType.Blunt ||
                                     oWeapon.CustomItemType == CustomItemType.HeavyBlunt;
                improperWeaponMessage = "You must be using a blade or a blunt weapon to harvest this object.";
            }

            if (!usingCorrectWeapon)
            {
                plc.IsPlot = true;
                oPC.SendMessage(_color.Red(improperWeaponMessage));
                oPC.SetLocalInt("NOT_USING_CORRECT_WEAPON", 1);
                oPC.ClearAllActions();
                oPC.DelayCommand(() => plc.IsPlot = false, 1.0f);
            }

            return(true);
        }
示例#19
0
        public void OnHitCastSpell(NWPlayer oTarget)
        {
            NWItem oSpellOrigin = NWItem.Wrap(_.GetSpellCastItem());

            // Durability system
            if (IsValidDurabilityType(oSpellOrigin))
            {
                RunItemDecay(oTarget, oSpellOrigin);
            }
        }
示例#20
0
 public override void DoAction(NWPlayer player, string pageName, int responseID)
 {
     switch (responseID)
     {
     case 1:
         NWItem item = NWItem.Wrap(_.GetItemPossessedBy(player.Object, "survival_knife"));
         _.DestroyObject(item.Object);
         EndConversation();
         break;
     }
 }
示例#21
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);
        }
示例#22
0
        public void OnChestDisturbed(NWPlaceable oChest)
        {
            int containerID = oChest.GetLocalInt("STORAGE_CONTAINER_ID");

            if (containerID <= 0)
            {
                return;
            }

            NWPlayer oPC         = NWPlayer.Wrap(_.GetLastDisturbed());
            NWItem   oItem       = NWItem.Wrap(_.GetInventoryDisturbItem());
            int      disturbType = _.GetInventoryDisturbType();
            int      itemCount   = CountItems(oChest);
            int      itemLimit   = oChest.GetLocalInt("STORAGE_CONTAINER_ITEM_LIMIT");

            if (itemLimit <= 0)
            {
                itemLimit = 20;
            }

            StorageContainer entity = _db.StorageContainers.Single(x => x.StorageContainerID == containerID);

            if (disturbType == INVENTORY_DISTURB_TYPE_ADDED)
            {
                if (itemCount > itemLimit)
                {
                    ReturnItem(oPC, oItem);
                    oPC.SendMessage(_color.Red("No more items can be placed inside."));
                }
                else
                {
                    StorageItem itemEntity = new StorageItem
                    {
                        ItemName           = oItem.Name,
                        ItemTag            = oItem.Tag,
                        ItemResref         = oItem.Resref,
                        GlobalID           = oItem.GlobalID,
                        ItemObject         = _serialization.Serialize(oItem),
                        StorageContainerID = entity.StorageContainerID
                    };

                    entity.StorageItems.Add(itemEntity);
                    _db.SaveChanges();
                }
            }
            else if (disturbType == INVENTORY_DISTURB_TYPE_REMOVED)
            {
                var record = _db.StorageItems.Single(x => x.GlobalID == oItem.GlobalID);
                _db.StorageItems.Remove(record);
                _db.SaveChanges();
            }

            oPC.SendMessage(_color.White("Item Limit: " + itemCount + " / ") + _color.Red("" + itemLimit));
        }
示例#23
0
        public void OnChestDisturbed(NWPlaceable oChest)
        {
            NWPlayer oPC = NWPlayer.Wrap(_.GetLastDisturbed());

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

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

            if (disturbType == INVENTORY_DISTURB_TYPE_ADDED)
            {
                _.CopyItem(oItem.Object, oPC.Object, TRUE);
                oItem.Destroy();
            }
            else if (disturbType == 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(ANIMATION_LOOPING_GET_LOW, 1.0f, searchDelay);
                });

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

                // Notify party members in the vicinity

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

                    player = NWPlayer.Wrap(_.GetNextPC());
                }
            }
        }
示例#24
0
文件: Gate.cs 项目: zunath/Freescape
 public void OnPurchased(NWPlayer oPC, int newLevel)
 {
     // Party members become targetable at level 2.
     if (newLevel >= 2)
     {
         NWItem item = NWItem.Wrap(_.GetItemPossessedBy(oPC.Object, "perk_gate"));
         _item.StripAllItemProperties(item);
         ItemProperty ip = _.ItemPropertyCastSpell(IP_CONST_CASTSPELL_UNIQUE_POWER, IP_CONST_CASTSPELL_NUMUSES_UNLIMITED_USE);
         _biowareXP2.IPSafeAddItemProperty(item, ip, 0.0f, AddItemPropertyPolicy.ReplaceExisting, false, false);
     }
 }
示例#25
0
        public override void Initialize()
        {
            NWItem shovel = NWItem.Wrap(GetPC().GetLocalObject("SHOVEL_ITEM"));
            string header = "This shovel has " + shovel.Charges + " uses remaining. What would you like to do?";

            SetPageHeader("MainPage", header);

            if (!CanHarvest())
            {
                SetResponseVisible("MainPage", 2, false);
            }
        }
示例#26
0
        public bool Run(params object[] args)
        {
            NWPlaceable device = NWPlaceable.Wrap(Object.OBJECT_SELF);
            NWPlayer    oPC    = NWPlayer.Wrap(_.GetLastOpenedBy());
            var         model  = _craft.GetPlayerCraftingData(oPC);

            if (model.Access != CraftingAccessType.None)
            {
                NWItem        menuItem     = NWItem.Wrap(_.CreateItemOnObject("cft_confirm", device.Object));
                NWPlaceable   storage      = NWPlaceable.Wrap(_.GetObjectByTag("craft_temp_store"));
                var           storageItems = storage.InventoryItems;
                List <NWItem> list         = null;

                if (model.Access == CraftingAccessType.MainComponent)
                {
                    menuItem.Name = "Confirm Main Components";
                    list          = model.MainComponents;
                }
                else if (model.Access == CraftingAccessType.SecondaryComponent)
                {
                    menuItem.Name = "Confirm Secondary Components";
                    list          = model.SecondaryComponents;
                }
                else if (model.Access == CraftingAccessType.TertiaryComponent)
                {
                    menuItem.Name = "Confirm Tertiary Components";
                    list          = model.TertiaryComponents;
                }
                else if (model.Access == CraftingAccessType.Enhancement)
                {
                    menuItem.Name = "Confirm Enhancement Components";
                    list          = model.EnhancementComponents;
                }

                if (list == null)
                {
                    oPC.FloatingText("Error locating component list. Notify an admin.");
                    return(false);
                }

                foreach (var item in list)
                {
                    NWItem storageItem = storageItems.Single(x => x.GlobalID == item.GlobalID);
                    _.CopyItem(storageItem.Object, device.Object, TRUE);
                }

                oPC.FloatingText("Place the components inside the container and then click the item named '" + menuItem.Name + "' to continue.");
            }

            device.IsLocked = true;
            return(true);
        }
示例#27
0
        public void OnModuleItemAcquired()
        {
            NWPlayer oPC = NWPlayer.Wrap(_.GetModuleItemAcquiredBy());

            if (!oPC.IsPlayer)
            {
                return;
            }

            NWItem item = NWItem.Wrap(_.GetModuleItemAcquired());

            ApplyItemFeatures(item);
        }
示例#28
0
        public void OnModuleItemEquipped()
        {
            NWPlayer oPC = NWPlayer.Wrap(_.GetPCItemLastEquippedBy());

            if (!oPC.IsInitializedAsPlayer)
            {
                return;                             // Players who log in for the first time don't have an ID yet.
            }
            NWItem oItem = NWItem.Wrap(_.GetPCItemLastEquipped());

            ApplyStatChanges(oPC, null);
            ApplyWeaponPenalties(oPC, oItem);
        }
示例#29
0
        public bool Run(params object[] args)
        {
            NWPlayer    oPC         = NWPlayer.Wrap(_.GetLastDisturbed());
            NWItem      item        = NWItem.Wrap(_.GetInventoryDisturbItem());
            NWPlaceable container   = NWPlaceable.Wrap(Object.OBJECT_SELF);
            int         disturbType = _.GetInventoryDisturbType();

            int structureID = container.GetLocalInt("STRUCTURE_TEMP_STRUCTURE_ID");
            PCTerritoryFlagsStructure entity = _structure.GetPCStructureByID(structureID);
            int    itemCount  = container.InventoryItems.Count;
            string itemResref = item.Resref;

            if (disturbType == INVENTORY_DISTURB_TYPE_ADDED)
            {
                if (itemCount > entity.StructureBlueprint.ItemStorageCount)
                {
                    ReturnItem(oPC, item);
                    oPC.SendMessage(_color.Red("No more items can be placed inside."));
                }
                // Only specific types of items can be stored in resource bundles
                else if (!string.IsNullOrWhiteSpace(entity.StructureBlueprint.ResourceResref) && itemResref != entity.StructureBlueprint.ResourceResref)
                {
                    ReturnItem(oPC, item);
                    oPC.SendMessage(_color.Red("That item cannot be stored here."));
                }
                else
                {
                    PCTerritoryFlagsStructuresItem itemEntity = new PCTerritoryFlagsStructuresItem
                    {
                        ItemName      = item.Name,
                        ItemResref    = itemResref,
                        ItemTag       = item.Tag,
                        PCStructureID = entity.PCTerritoryFlagStructureID,
                        GlobalID      = item.GlobalID,
                        ItemObject    = _serialization.Serialize(item)
                    };

                    entity.PCTerritoryFlagsStructuresItems.Add(itemEntity);
                    _structure.SaveChanges();
                }
            }
            else if (disturbType == INVENTORY_DISTURB_TYPE_REMOVED)
            {
                _structure.DeleteContainerItemByGlobalID(item.GlobalID);
            }

            oPC.SendMessage(_color.White("Item Limit: " + itemCount + " / ") + _color.Red(entity.StructureBlueprint.ItemStorageCount.ToString()));

            return(true);
        }
示例#30
0
        public override void Initialize()
        {
            List <SkillCategory> categories = _skill.GetActiveCategories();

            foreach (SkillCategory category in categories)
            {
                AddResponseToPage("CategoryPage", category.Name, true, new Tuple <string, dynamic>(string.Empty, category.SkillCategoryID));
            }

            Model vm = GetDialogCustomData <Model>();

            vm.Item = NWItem.Wrap(GetPC().GetLocalObject("XP_TOME_OBJECT"));
            SetDialogCustomData(vm);
        }