private void HandleBlueprintListPageResponse(int responseID) { DialogResponse response = GetResponseByID("BlueprintListPage", responseID); int blueprintID = (int)response.CustomData; if (blueprintID == -1) { ChangePage("CraftCategoriesPage"); return; } var model = CraftService.GetPlayerCraftingData(GetPC()); model.Blueprint = CraftService.GetBlueprintByID(blueprintID); model.BlueprintID = blueprintID; model.PlayerSkillRank = SkillService.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 = CraftService.BuildBlueprintHeader(GetPC(), blueprintID, false); SetPageHeader("BlueprintDetailsPage", header); ChangePage("BlueprintDetailsPage"); }
private void LoadCategoryResponses() { NWPlaceable device = (NWPlaceable)GetDialogTarget(); int deviceID = device.GetLocalInt("CRAFT_DEVICE_ID"); List <CraftBlueprintCategory> categories = CraftService.GetCategoriesAvailableToPCByDeviceID(GetPC().GlobalID, deviceID); ClearPageResponses("MainPage"); var lastBlueprintId = GetPC().GetLocalInt("LAST_CRAFTED_BLUEPRINT_ID_" + deviceID); var bp = CraftService.GetBlueprintByID(lastBlueprintId); if (bp != null) { AddResponseToPage("MainPage", bp.Quantity + "x " + bp.ItemName, bp.IsActive, new Tuple <int, Type>(bp.ID, typeof(CraftBlueprint))); } AddResponseToPage("MainPage", "Scrap Item"); foreach (CraftBlueprintCategory category in categories) { AddResponseToPage("MainPage", category.Name, category.IsActive, new Tuple <int, Type>(category.ID, typeof(CraftBlueprintCategory))); } }
public override void Initialize() { ToggleBackButton(false); var model = CraftService.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 = CraftService.GetBlueprintByID(model.BlueprintID); model.PlayerSkillRank = SkillService.GetPCSkillRank(GetPC(), model.Blueprint.SkillID); switch ((SkillType)model.Blueprint.SkillID) { case SkillType.Armorsmith: model.PlayerPerkLevel = PerkService.GetCreaturePerkLevel(GetPC(), PerkType.ArmorBlueprints); break; case SkillType.Engineering: model.PlayerPerkLevel = PerkService.GetCreaturePerkLevel(GetPC(), PerkType.EngineeringBlueprints); break; case SkillType.Weaponsmith: model.PlayerPerkLevel = PerkService.GetCreaturePerkLevel(GetPC(), PerkType.WeaponBlueprints); break; case SkillType.Fabrication: model.PlayerPerkLevel = PerkService.GetCreaturePerkLevel(GetPC(), PerkType.FabricationBlueprints); break; case SkillType.Medicine: model.PlayerPerkLevel = PerkService.GetCreaturePerkLevel(GetPC(), PerkType.MedicalBlueprints); break; case SkillType.Lightsaber: model.PlayerPerkLevel = PerkService.GetCreaturePerkLevel(GetPC(), PerkType.LightsaberBlueprints); // Lightsabers do not have Optimisation or Efficiency perks. break; default: model.PlayerPerkLevel = 0; break; } GetDevice().IsLocked = true; model.MainMinimum = model.Blueprint.MainMinimum; model.SecondaryMinimum = model.Blueprint.SecondaryMinimum; model.TertiaryMinimum = model.Blueprint.TertiaryMinimum; model.MainMaximum = model.Blueprint.MainMaximum; model.SecondaryMaximum = model.Blueprint.SecondaryMaximum > 0 ? model.Blueprint.SecondaryMaximum : 0; model.TertiaryMaximum = model.Blueprint.TertiaryMaximum > 0 ? model.Blueprint.TertiaryMaximum : 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, "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", CraftService.BuildBlueprintHeader(GetPC(), true)); BuildMainPageOptions(); }
private void HandleMainPageResponses(int responseID) { var model = CraftService.GetPlayerCraftingData(GetPC()); NWPlaceable device = GetDevice(); switch (responseID) { case 1: // Examine Base Item CraftBlueprint entity = CraftService.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 = CraftService.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; } CraftService.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) CraftService.ClearPlayerCraftingData(GetPC()); SwitchConversation("CraftingDevice"); break; } }