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;
            }
        }
Exemple #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));
                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;
            }
        }
Exemple #3
0
        private void HandleBlueprintListPageResponse(int responseID)
        {
            DialogResponse response    = GetResponseByID("BlueprintListPage", responseID);
            int            blueprintID = (int)response.CustomData;

            if (blueprintID == -1)
            {
                ChangePage("CraftCategoriesPage");
                return;
            }

            var model = _craft.GetPlayerCraftingData(GetPC());

            model.Blueprint        = _craft.GetBlueprintByID(blueprintID);
            model.BlueprintID      = blueprintID;
            model.PlayerSkillRank  = _skill.GetPCSkillRank(GetPC(), model.Blueprint.SkillID);
            model.MainMinimum      = model.Blueprint.MainMinimum;
            model.MainMaximum      = model.Blueprint.MainMaximum;
            model.SecondaryMinimum = model.Blueprint.SecondaryMinimum;
            model.SecondaryMaximum = model.Blueprint.SecondaryMaximum;
            model.TertiaryMinimum  = model.Blueprint.TertiaryMinimum;
            model.TertiaryMaximum  = model.Blueprint.TertiaryMaximum;

            string header = _craft.BuildBlueprintHeader(GetPC(), blueprintID, false);

            SetPageHeader("BlueprintDetailsPage", header);
            ChangePage("BlueprintDetailsPage");
        }
        public override void Initialize()
        {
            var model  = _craft.GetPlayerCraftingData(GetPC());
            var device = GetDevice();

            // Entering the conversation for the first time from the blueprint selection menu.
            if (model.BlueprintID <= 0)
            {
                model.BlueprintID    = GetPC().GetLocalInt("CRAFT_BLUEPRINT_ID");
                model.Blueprint      = _craft.GetBlueprintByID(model.BlueprintID);
                GetDevice().IsLocked = true;
            }
            // Otherwise returning from accessing the device's inventory.
            else
            {
                model.Access = CraftingAccessType.None;

                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_USED, "jvm_script_1");
                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_OPEN, string.Empty);
                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_CLOSED, string.Empty);
                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_INVENTORYDISTURBED, string.Empty);
            }

            BuildMainPageHeader();
            BuildMainPageOptions();
        }
Exemple #5
0
        public bool Run(params object[] args)
        {
            NWPlaceable device            = NWPlaceable.Wrap(Object.OBJECT_SELF);
            NWPlayer    oPC               = NWPlayer.Wrap(_.GetLastOpenedBy());
            int         blueprintSelected = device.GetLocalInt("CRAFT_BLUEPRINT_ID");

            _.CreateItemOnObject("cft_choose_bp", device.Object);
            if (blueprintSelected > 0)
            {
                CraftBlueprint entity = _craft.GetBlueprintByID(blueprintSelected);

                NWItem menuItem = NWItem.Wrap(_.CreateItemOnObject("cft_craft_item", device.Object));
                menuItem.Name = "Craft Item: " + entity.ItemName;

                oPC.SendMessage(_craft.BuildBlueprintHeader(oPC, blueprintSelected));
            }

            return(true);
        }
        private void LoadCategoryResponses()
        {
            NWPlaceable device   = (NWPlaceable)GetDialogTarget();
            int         deviceID = device.GetLocalInt("CRAFT_DEVICE_ID");
            List <CraftBlueprintCategory> categories = _craft.GetCategoriesAvailableToPCByDeviceID(GetPC().GlobalID, deviceID);

            ClearPageResponses("MainPage");

            var lastBlueprintId = GetPC().GetLocalInt("LAST_CRAFTED_BLUEPRINT_ID_" + deviceID);
            var bp = _craft.GetBlueprintByID(lastBlueprintId);

            if (bp != null)
            {
                AddResponseToPage("MainPage", bp.Quantity + "x " + bp.ItemName, bp.IsActive, new Tuple <int, Type>(bp.ID, typeof(CraftBlueprint)));
            }

            foreach (CraftBlueprintCategory category in categories)
            {
                AddResponseToPage("MainPage", category.Name, category.IsActive, new Tuple <int, Type>(category.ID, typeof(CraftBlueprintCategory)));
            }
        }
Exemple #7
0
        public bool Run(params object[] args)
        {
            NWPlayer    oPC    = NWPlayer.Wrap(_.GetLastDisturbed());
            NWItem      oItem  = NWItem.Wrap(_.GetInventoryDisturbItem());
            NWPlaceable device = NWPlaceable.Wrap(Object.OBJECT_SELF);

            int            type        = _.GetInventoryDisturbType();
            string         resref      = oItem.Resref;
            string         tag         = oItem.Tag;
            int            blueprintID = device.GetLocalInt("CRAFT_BLUEPRINT_ID");
            NWItem         tools       = NWItem.Wrap(device.GetLocalObject("CRAFT_DEVICE_TOOLS"));
            CraftBlueprint blueprint   = _craft.GetBlueprintByID(blueprintID);

            if (type == INVENTORY_DISTURB_TYPE_REMOVED)
            {
                if (resref == "cft_choose_bp" || resref == "cft_craft_item")
                {
                    _item.ReturnItem(device, oItem);

                    if (tag == "CHOOSE_BLUEPRINT")
                    {
                        _dialog.StartConversation(oPC, device, "Crafting");
                    }
                    else if (tag == "CRAFT_ITEM")
                    {
                        HandleCraftItem(oPC, device);
                    }
                }
                else if (Equals(oItem, tools))
                {
                    device.DeleteLocalObject("CRAFT_DEVICE_TOOLS");
                }
            }
            else if (type == INVENTORY_DISTURB_TYPE_ADDED)
            {
                if (resref == "cft_choose_bp" || resref == "cft_craft_item")
                {
                    return(false);
                }

                if (blueprint == null)
                {
                    _item.ReturnItem(oPC, oItem);
                    oPC.SendMessage("Please select a blueprint before adding components.");
                }
                else if (oItem.CraftTierLevel > 0)
                {
                    if (blueprint.CraftTierLevel <= 0)
                    {
                        _item.ReturnItem(oPC, oItem);
                        oPC.SendMessage("Tools are not required to make this item.");
                    }
                    else if (blueprint.CraftTierLevel > oItem.CraftTierLevel || blueprint.SkillID != oItem.AssociatedSkillID)
                    {
                        _item.ReturnItem(oPC, oItem);
                        oPC.SendMessage("Those tools cannot be used with this blueprint. (Required Tool Level: " + blueprint.CraftTierLevel + ")");
                    }
                    else
                    {
                        if (tools.IsValid)
                        {
                            _item.ReturnItem(oPC, oItem);
                            oPC.SendMessage("You may only use one set of tools at a time.");
                        }
                        else
                        {
                            device.SetLocalObject("CRAFT_DEVICE_TOOLS", oItem.Object);
                        }
                    }
                }
            }
            return(true);
        }
Exemple #8
0
        public override void Initialize()
        {
            ToggleBackButton(false);

            var model = _craft.GetPlayerCraftingData(GetPC());
            var device = GetDevice();

            // Entering the conversation for the first time from the blueprint selection menu.
            if (!model.IsInitialized)
            {
                model.IsInitialized = true;
                model.Blueprint = _craft.GetBlueprintByID(model.BlueprintID);
                model.PlayerSkillRank = _skill.GetPCSkillRank(GetPC(), model.Blueprint.SkillID);

                switch ((SkillType)model.Blueprint.SkillID)
                {
                    case SkillType.Armorsmith:
                        model.PlayerPerkLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.ArmorBlueprints);
                        model.EfficiencyLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.ArmorsmithEfficiency);
                        model.OptimizationLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.ArmorsmithOptimization);
                        break;
                    case SkillType.Engineering:
                        model.PlayerPerkLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.EngineeringBlueprints);
                        model.EfficiencyLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.EngineeringEfficiency);
                        model.OptimizationLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.EngineeringOptimization);
                        break;
                    case SkillType.Weaponsmith:
                        model.PlayerPerkLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.WeaponBlueprints);
                        model.EfficiencyLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.WeaponsmithEfficiency);
                        model.OptimizationLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.WeaponsmithOptimization);
                        break;
                    case SkillType.Fabrication:
                        model.PlayerPerkLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.FabricationBlueprints);
                        model.EfficiencyLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.FabricationEfficiency);
                        model.OptimizationLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.FabricationOptimization);
                        break;
                    case SkillType.Medicine:
                        model.PlayerPerkLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.MedicalBlueprints);
                        model.EfficiencyLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.MedicineEfficiency);
                        model.OptimizationLevel = _perk.GetPCPerkLevel(GetPC(), PerkType.MedicineOptimization);
                        break;
                    default:
                        model.PlayerPerkLevel = 0;
                        break;

                }
                GetDevice().IsLocked = true;
                model.MainMinimum = model.Blueprint.MainMinimum - model.EfficiencyLevel;
                model.SecondaryMinimum = model.Blueprint.SecondaryMinimum - model.EfficiencyLevel;
                model.TertiaryMinimum = model.Blueprint.TertiaryMinimum - model.EfficiencyLevel;

                model.MainMaximum = model.Blueprint.MainMaximum + model.OptimizationLevel;
                model.SecondaryMaximum = model.Blueprint.SecondaryMaximum > 0 ? model.Blueprint.SecondaryMaximum + model.OptimizationLevel : 0;
                model.TertiaryMaximum = model.Blueprint.TertiaryMaximum > 0 ? model.Blueprint.TertiaryMaximum + model.OptimizationLevel : 0;

                if (model.MainMinimum <= 0)
                    model.MainMinimum = 1;
                if (model.SecondaryMinimum <= 0 && model.Blueprint.SecondaryMinimum > 0)
                    model.SecondaryMinimum = 1;
                if (model.TertiaryMinimum <= 0 && model.Blueprint.TertiaryMinimum > 0)
                    model.TertiaryMinimum = 1;

            }
            // Otherwise returning from accessing the device's inventory.
            else
            {
                model.Access = CraftingAccessType.None;

                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_USED, "jvm_script_1");
                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_OPEN, string.Empty);
                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_CLOSED, string.Empty);
                _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_INVENTORYDISTURBED, string.Empty);
            }


            SetPageHeader("MainPage", _craft.BuildBlueprintHeader(GetPC(), model.BlueprintID, true));
            BuildMainPageOptions();
        }