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 LoadCraftPage(int blueprintID) { var model = CraftService.GetPlayerCraftingData(GetPC()); model.BlueprintID = blueprintID; SwitchConversation("CraftItem"); }
public override void Back(NWPlayer player, string beforeMovePage, string afterMovePage) { var model = CraftService.GetPlayerCraftingData(player); model.IsConfirmingReassemble = false; SetResponseText("SalvagePage", 1, "Reassemble Component(s)"); }
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); }
private void SalvagePageResponses(int responseID) { var player = GetPC(); var model = CraftService.GetPlayerCraftingData(player); switch (responseID) { case 1: // Reassemble Component(s) NWItem fuel = _.GetItemPossessedBy(player, "ass_power"); // Look for reassembly fuel in the player's inventory. if (!fuel.IsValid) { player.SendMessage(ColorTokenService.Red("You must have a 'Reassembly Fuel Cell' in your inventory in order to start this process.")); return; } if (model.IsConfirmingReassemble) { // Calculate delay, fire off delayed event, and show timing bar. float delay = CraftService.CalculateCraftingDelay(player, (int)SkillType.Harvesting); NWNXPlayer.StartGuiTimingBar(player, delay, string.Empty); var @event = new OnReassembleComplete(player, model.SerializedSalvageItem, model.SalvageComponentTypeID); player.DelayEvent(delay, @event); // Make the player play an animation. player.AssignCommand(() => { _.ClearAllActions(); _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, delay); }); // Show sparks halfway through the process. _.DelayCommand(1.0f * (delay / 2.0f), () => { _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_COM_BLOOD_SPARK_MEDIUM), NWGameObject.OBJECT_SELF); }); // Immobilize the player while crafting. Effect immobilize = _.EffectCutsceneImmobilize(); immobilize = _.TagEffect(immobilize, "CRAFTING_IMMOBILIZATION"); _.ApplyEffectToObject(DURATION_TYPE_PERMANENT, immobilize, player); // Clear the temporary crafting data and end this conversation. model.SerializedSalvageItem = string.Empty; EndConversation(); } else { model.IsConfirmingReassemble = true; SetResponseText("SalvagePage", 1, "CONFIRM REASSEMBLE COMPONENT(S)"); } break; } }
private void MainPageResponses(int responseID) { var player = GetPC(); var model = CraftService.GetPlayerCraftingData(player); DialogResponse response = GetResponseByID("MainPage", responseID); model.SalvageComponentTypeID = (int)response.CustomData; LoadSalvagePage(); ChangePage("SalvagePage"); }
public override void EndDialog() { var model = CraftService.GetPlayerCraftingData(GetPC()); if (model.IsAccessingStorage) { return; } CraftService.ClearPlayerCraftingData(GetPC()); }
private void OpenScrapperInventory() { var model = CraftService.GetPlayerCraftingData(GetPC()); NWPlaceable container = _.CreateObject(OBJECT_TYPE_PLACEABLE, "cft_scrapper", GetPC().Location); container.IsLocked = false; model.IsAccessingStorage = true; GetPC().AssignCommand(() => _.ActionInteractObject(container.Object)); EndConversation(); }
private void LoadSalvagePage() { var player = GetPC(); var model = CraftService.GetPlayerCraftingData(player); NWPlaceable tempStorage = _.GetObjectByTag("TEMP_ITEM_STORAGE"); var item = SerializationService.DeserializeItem(model.SerializedSalvageItem, tempStorage); var componentType = DataService.ComponentType.GetByID(model.SalvageComponentTypeID); string header = ColorTokenService.Green("Item: ") + item.Name + "\n\n"; header += "Reassembling this item will create the following " + ColorTokenService.Green(componentType.Name) + " component(s). Chance to create depends on your perks, skills, and harvesting bonus on items.\n\n"; // Always create one item with zero bonuses. header += componentType.Name + " (No Bonuses) [RL: 0] " + GetChanceColor(100) + "\n"; // Now check specific custom properties which are stored as local variables on the item. header += ProcessPropertyDetails(item.HarvestingBonus, componentType.Name, "Harvesting Bonus", 3); header += ProcessPropertyDetails(item.PilotingBonus, componentType.Name, "Piloting Bonus", 3); header += ProcessPropertyDetails(item.ScanningBonus, componentType.Name, "Scanning Bonus", 3); header += ProcessPropertyDetails(item.ScavengingBonus, componentType.Name, "Scavenging Bonus", 3); header += ProcessPropertyDetails(item.CooldownRecovery, componentType.Name, "Cooldown Recovery", 3); header += ProcessPropertyDetails(item.CraftBonusArmorsmith, componentType.Name, "Armorsmith", 3); header += ProcessPropertyDetails(item.CraftBonusWeaponsmith, componentType.Name, "Weaponsmith", 3); header += ProcessPropertyDetails(item.CraftBonusCooking, componentType.Name, "Cooking", 3); header += ProcessPropertyDetails(item.CraftBonusEngineering, componentType.Name, "Engineering", 3); header += ProcessPropertyDetails(item.CraftBonusFabrication, componentType.Name, "Fabrication", 3); header += ProcessPropertyDetails(item.HPBonus, componentType.Name, "HP", 5, 0.5f); header += ProcessPropertyDetails(item.FPBonus, componentType.Name, "FP", 5, 0.5f); header += ProcessPropertyDetails(item.EnmityRate, componentType.Name, "Enmity", 3); header += ProcessPropertyDetails(item.LuckBonus, componentType.Name, "Luck", 3); header += ProcessPropertyDetails(item.MeditateBonus, componentType.Name, "Meditate", 3); header += ProcessPropertyDetails(item.RestBonus, componentType.Name, "Rest", 3); header += ProcessPropertyDetails(item.MedicineBonus, componentType.Name, "Medicine", 3); header += ProcessPropertyDetails(item.HPRegenBonus, componentType.Name, "HP Regen", 3); header += ProcessPropertyDetails(item.FPRegenBonus, componentType.Name, "FP Regen", 3); header += ProcessPropertyDetails(item.BaseAttackBonus, componentType.Name, "Base Attack Bonus", 3, 6f); header += ProcessPropertyDetails(item.StructureBonus, componentType.Name, "Structure Bonus", 3); header += ProcessPropertyDetails(item.SneakAttackBonus, componentType.Name, "Sneak Attack", 3); header += ProcessPropertyDetails(item.DamageBonus, componentType.Name, "Damage", 3); header += ProcessPropertyDetails(item.StrengthBonus, componentType.Name, "STR", 3); header += ProcessPropertyDetails(item.DexterityBonus, componentType.Name, "DEX", 3); header += ProcessPropertyDetails(item.ConstitutionBonus, componentType.Name, "CON", 3); header += ProcessPropertyDetails(item.WisdomBonus, componentType.Name, "WIS", 3); header += ProcessPropertyDetails(item.IntelligenceBonus, componentType.Name, "INT", 3); header += ProcessPropertyDetails(item.CharismaBonus, componentType.Name, "CHA", 3); header += ProcessPropertyDetails(item.DurationBonus, componentType.Name, "Duration", 3); SetPageHeader("SalvagePage", header); // Remove the temporary copy from the game world. item.Destroy(); }
public bool Run(params object[] args) { NWPlaceable device = (Object.OBJECT_SELF); NWPlayer oPC = (_.GetLastOpenedBy()); var model = CraftService.GetPlayerCraftingData(oPC); if (model.Access != CraftingAccessType.None) { NWItem menuItem = (_.CreateItemOnObject("cft_confirm", device.Object)); NWPlaceable storage = (_.GetObjectByTag("craft_temp_store")); var storageItems = storage.InventoryItems.ToList(); 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); }
private void BuildMainPageOptions() { var model = CraftService.GetPlayerCraftingData(GetPC()); int maxEnhancements = model.PlayerPerkLevel / 2; bool canAddEnhancements = model.Blueprint.EnhancementSlots > 0 && maxEnhancements > 0; AddResponseToPage("MainPage", "Examine Base Item"); AddResponseToPage("MainPage", "Create Item", model.CanBuildItem); AddResponseToPage("MainPage", "Select Main Components"); AddResponseToPage("MainPage", "Select Secondary Components", model.Blueprint.SecondaryMinimum > 0); AddResponseToPage("MainPage", "Select Tertiary Components", model.Blueprint.TertiaryMinimum > 0); AddResponseToPage("MainPage", "Select Enhancement Components", canAddEnhancements); AddResponseToPage("MainPage", "Change Blueprint"); }
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); }
private void SalvagePageResponses(int responseID) { var player = GetPC(); var model = CraftService.GetPlayerCraftingData(player); switch (responseID) { case 1: // Reassemble Component(s) if (model.IsConfirmingReassemble) { // Calculate delay, fire off delayed event, and show timing bar. float delay = CraftService.CalculateCraftingDelay(player, (int)SkillType.Harvesting); NWNXPlayer.StartGuiTimingBar(player, delay, string.Empty); player.DelayEvent <ReassembleComplete>(delay, player, model.SerializedSalvageItem, model.SalvageComponentTypeID); // Make the player play an animation. player.AssignCommand(() => { _.ClearAllActions(); _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, delay); }); // Show sparks halfway through the process. _.DelayCommand(1.0f * (delay / 2.0f), () => { _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_COM_BLOOD_SPARK_MEDIUM), Object.OBJECT_SELF); }); // Immobilize the player while crafting. Effect immobilize = _.EffectCutsceneImmobilize(); immobilize = _.TagEffect(immobilize, "CRAFTING_IMMOBILIZATION"); _.ApplyEffectToObject(DURATION_TYPE_PERMANENT, immobilize, player); // Clear the temporary crafting data and end this conversation. model.SerializedSalvageItem = string.Empty; EndConversation(); } else { model.IsConfirmingReassemble = true; SetResponseText("SalvagePage", 1, "CONFIRM REASSEMBLE COMPONENT(S)"); } break; } }
private void OpenDeviceInventory() { var model = CraftService.GetPlayerCraftingData(GetPC()); NWPlaceable device = GetDevice(); device.IsLocked = false; model.IsAccessingStorage = true; _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_USED, string.Empty); _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_OPEN, "script_2"); _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_CLOSED, "script_3"); _.SetEventScript(device.Object, EVENT_SCRIPT_PLACEABLE_ON_INVENTORYDISTURBED, "script_4"); device.SetLocalString("SCRIPT_2", "Placeable.CraftingDevice.OnOpened"); device.SetLocalString("SCRIPT_3", "Placeable.CraftingDevice.OnClosed"); device.SetLocalString("SCRIPT_4", "Placeable.CraftingDevice.OnDisturbed"); GetPC().AssignCommand(() => _.ActionInteractObject(device.Object)); EndConversation(); }
public bool Run(params object[] args) { // Should only fire when a player walks away from the device. // Clean up temporary data and return all items placed inside. NWPlayer player = (_.GetLastClosedBy()); NWPlaceable device = (Object.OBJECT_SELF); var model = CraftService.GetPlayerCraftingData(player); device.DestroyAllInventoryItems(); device.IsLocked = false; model.IsAccessingStorage = false; foreach (var item in model.MainComponents) { _.CopyItem(item.Object, player.Object, _.TRUE); item.Destroy(); } foreach (var item in model.SecondaryComponents) { _.CopyItem(item.Object, player.Object, _.TRUE); item.Destroy(); } foreach (var item in model.TertiaryComponents) { _.CopyItem(item.Object, player.Object, _.TRUE); item.Destroy(); } foreach (var item in model.EnhancementComponents) { _.CopyItem(item.Object, player.Object, _.TRUE); item.Destroy(); } _.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); player.Data.Remove("CRAFTING_MODEL"); return(true); }
public void Main() { // Should only fire when a player walks away from the device. // Clean up temporary data and return all items placed inside. NWPlayer player = (_.GetLastClosedBy()); NWPlaceable device = (_.OBJECT_SELF); var model = CraftService.GetPlayerCraftingData(player); device.DestroyAllInventoryItems(); device.IsLocked = false; model.IsAccessingStorage = false; foreach (var item in model.MainComponents) { _.CopyItem(item.Object, player.Object, true); item.Destroy(); } foreach (var item in model.SecondaryComponents) { _.CopyItem(item.Object, player.Object, true); item.Destroy(); } foreach (var item in model.TertiaryComponents) { _.CopyItem(item.Object, player.Object, true); item.Destroy(); } foreach (var item in model.EnhancementComponents) { _.CopyItem(item.Object, player.Object, true); item.Destroy(); } _.SetEventScript(device.Object, EventScript.Placeable_OnUsed, "script_1"); _.SetEventScript(device.Object, EventScript.Placeable_OnOpen, string.Empty); _.SetEventScript(device.Object, EventScript.Placeable_OnClosed, string.Empty); _.SetEventScript(device.Object, EventScript.Placeable_OnInventoryDisturbed, string.Empty); player.Data.Remove("CRAFTING_MODEL"); }
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; } }
private void HandleAddItem() { NWPlayer oPC = (_.GetLastDisturbed()); NWItem oItem = (_.GetInventoryDisturbItem()); if (oItem.Resref == "cft_confirm") { return; } if (oPC.IsBusy) { ItemService.ReturnItem(oPC, oItem); oPC.SendMessage("You are too busy right now."); return; } var model = CraftService.GetPlayerCraftingData(oPC); var mainComponent = DataService.Get <Data.Entity.ComponentType>(model.Blueprint.MainComponentTypeID); var secondaryComponent = DataService.Get <Data.Entity.ComponentType>(model.Blueprint.SecondaryComponentTypeID); var tertiaryComponent = DataService.Get <Data.Entity.ComponentType>(model.Blueprint.TertiaryComponentTypeID); NWPlaceable storage = _.GetObjectByTag("craft_temp_store"); List <NWItem> list = null; ComponentType allowedType = ComponentType.None; bool reachedCap = false; bool reachedEnhancementLimit = false; string componentName = string.Empty; switch (model.Access) { case CraftingAccessType.MainComponent: allowedType = (ComponentType)model.Blueprint.MainComponentTypeID; reachedCap = model.MainMaximum < model.MainComponents.Count + 1; list = model.MainComponents; componentName = mainComponent.Name; break; case CraftingAccessType.SecondaryComponent: allowedType = (ComponentType)model.Blueprint.SecondaryComponentTypeID; reachedCap = model.SecondaryMaximum < model.SecondaryComponents.Count + 1; list = model.SecondaryComponents; componentName = secondaryComponent.Name; break; case CraftingAccessType.TertiaryComponent: allowedType = (ComponentType)model.Blueprint.TertiaryComponentTypeID; reachedCap = model.TertiaryMaximum < model.TertiaryComponents.Count + 1; list = model.TertiaryComponents; componentName = tertiaryComponent.Name; break; case CraftingAccessType.Enhancement: allowedType = ComponentType.Enhancement; reachedCap = model.Blueprint.EnhancementSlots < model.EnhancementComponents.Count + 1; reachedEnhancementLimit = model.PlayerPerkLevel / 2 < model.EnhancementComponents.Count + 1; list = model.EnhancementComponents; componentName = "Enhancement"; break; } if (list == null) { ItemService.ReturnItem(oPC, oItem); oPC.FloatingText("There was an issue getting the item data. Notify an admin."); return; } if (reachedCap) { ItemService.ReturnItem(oPC, oItem); oPC.FloatingText("You cannot add any more components of that type."); return; } if (reachedEnhancementLimit) { ItemService.ReturnItem(oPC, oItem); oPC.FloatingText("Your perk level does not allow you to attach any more enhancements to this item."); return; } var props = oItem.ItemProperties.ToList(); var allowedItemTypes = new List <CustomItemType>(); CustomItemType finishedItemType = ItemService.GetCustomItemTypeByResref(model.Blueprint.ItemResref); foreach (var ip in props) { if (_.GetItemPropertyType(ip) == (int)CustomItemPropertyType.ComponentItemTypeRestriction) { int restrictionType = _.GetItemPropertyCostTableValue(ip); allowedItemTypes.Add((CustomItemType)restrictionType); } } if (allowedItemTypes.Count > 0) { if (!allowedItemTypes.Contains(finishedItemType)) { oPC.FloatingText("This component cannot be used with this type of blueprint."); ItemService.ReturnItem(oPC, oItem); return; } } foreach (var ip in props) { if (_.GetItemPropertyType(ip) == (int)CustomItemPropertyType.ComponentType) { int compType = _.GetItemPropertyCostTableValue(ip); if (compType == (int)allowedType) { oItem.GetOrAssignGlobalID(); NWItem copy = (_.CopyItem(oItem.Object, storage.Object, TRUE)); list.Add(copy); return; } } } oPC.FloatingText("Only " + componentName + " components may be used with this component type."); ItemService.ReturnItem(oPC, oItem); }
private void RunCreateItem(NWPlayer player) { foreach (var effect in player.Effects) { if (_.GetEffectTag(effect) == "CRAFTING_IMMOBILIZATION") { _.RemoveEffect(player, effect); } } var model = CraftService.GetPlayerCraftingData(player); CraftBlueprint blueprint = DataService.CraftBlueprint.GetByID(model.BlueprintID); BaseStructure baseStructure = blueprint.BaseStructureID == null ? null : DataService.BaseStructure.GetByID(Convert.ToInt32(blueprint.BaseStructureID)); PCSkill pcSkill = SkillService.GetPCSkill(player, blueprint.SkillID); int pcEffectiveLevel = CraftService.CalculatePCEffectiveLevel(player, pcSkill.Rank, (SkillType)blueprint.SkillID); int itemLevel = model.AdjustedLevel; int atmosphereBonus = CraftService.CalculateAreaAtmosphereBonus(player.Area); float chance = CalculateBaseChanceToAddProperty(pcEffectiveLevel, itemLevel, atmosphereBonus); float equipmentBonus = CalculateEquipmentBonus(player, (SkillType)blueprint.SkillID); if (chance <= 1.0f) { player.FloatingText(ColorTokenService.Red("Critical failure! You don't have enough skill to create that item. All components were lost.")); CraftService.ClearPlayerCraftingData(player, true); return; } int luckyBonus = PerkService.GetCreaturePerkLevel(player, PerkType.Lucky); var craftedItems = new List <NWItem>(); NWItem craftedItem = (_.CreateItemOnObject(blueprint.ItemResref, player.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 = (_.CreateItemOnObject(blueprint.ItemResref, player.Object)); craftedItem.IsIdentified = true; craftedItems.Add(craftedItem); } } // Recommended level gets set regardless if all item properties make it on the final product. // Also mark who crafted the item. This is later used for display on the item's examination event. foreach (var item in craftedItems) { item.RecommendedLevel = itemLevel < 0 ? 0 : itemLevel; item.SetLocalString("CRAFTER_PLAYER_ID", player.GlobalID.ToString()); BaseService.ApplyCraftedItemLocalVariables(item, baseStructure); } if (RandomService.Random(1, 100) <= luckyBonus) { chance += RandomService.Random(1, luckyBonus); } int successAmount = 0; foreach (var component in model.MainComponents) { var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems); successAmount += result.Item1; chance = result.Item2; } foreach (var component in model.SecondaryComponents) { var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems); successAmount += result.Item1; chance = result.Item2; } foreach (var component in model.TertiaryComponents) { var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems); successAmount += result.Item1; chance = result.Item2; } foreach (var component in model.EnhancementComponents) { var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems); successAmount += result.Item1; chance = result.Item2; } // Structures gain increased durability based on the blueprint if (baseStructure != null) { foreach (var item in craftedItems) { var maxDur = DurabilityService.GetMaxDurability(item); maxDur += (float)baseStructure.Durability; DurabilityService.SetMaxDurability(item, maxDur); DurabilityService.SetDurability(item, maxDur); } } player.SendMessage("You created " + blueprint.Quantity + "x " + blueprint.ItemName + "!"); int baseXP = 750 + successAmount * RandomService.Random(1, 50); float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(baseXP, model.AdjustedLevel, pcSkill.Rank); bool exists = DataService.PCCraftedBlueprint.ExistsByPlayerIDAndCraftedBlueprintID(player.GlobalID, blueprint.ID); if (!exists) { xp = xp * 1.50f; player.SendMessage("You receive an XP bonus for crafting this item for the first time."); var pcCraftedBlueprint = new PCCraftedBlueprint { CraftBlueprintID = blueprint.ID, DateFirstCrafted = DateTime.UtcNow, PlayerID = player.GlobalID }; DataService.SubmitDataChange(pcCraftedBlueprint, DatabaseActionType.Insert); } SkillService.GiveSkillXP(player, blueprint.SkillID, (int)xp); CraftService.ClearPlayerCraftingData(player, true); player.SetLocalInt("LAST_CRAFTED_BLUEPRINT_ID_" + blueprint.CraftDeviceID, blueprint.ID); }
private void LoadSalvagePage() { var player = GetPC(); var model = CraftService.GetPlayerCraftingData(player); NWPlaceable tempStorage = _.GetObjectByTag("TEMP_ITEM_STORAGE"); var item = SerializationService.DeserializeItem(model.SerializedSalvageItem, tempStorage); var componentType = DataService.Get <ComponentType>(model.SalvageComponentTypeID); string header = ColorTokenService.Green("Item: ") + item.Name + "\n\n"; header += "Reassembling this item will create the following " + ColorTokenService.Green(componentType.Name) + " component(s). Chance to create depends on your perks, skills, and harvesting bonus on items.\n\n"; // Always create one item with zero bonuses. header += componentType.Name + " (No Bonuses) [RL: 0] " + GetChanceColor(100) + "\n"; // Start by checking attack bonus since we're not storing this value as a local variable on the item. foreach (var prop in item.ItemProperties) { int propTypeID = _.GetItemPropertyType(prop); if (propTypeID == ITEM_PROPERTY_ATTACK_BONUS) { // Get the amount of Attack Bonus int amount = _.GetItemPropertyCostTableValue(prop); header += ProcessPropertyDetails(amount, componentType.Name, "Attack Bonus", 3); } } // Now check specific custom properties which are stored as local variables on the item. header += ProcessPropertyDetails(item.CustomAC, componentType.Name, "AC", 3); header += ProcessPropertyDetails(item.HarvestingBonus, componentType.Name, "Harvesting Bonus", 3); header += ProcessPropertyDetails(item.PilotingBonus, componentType.Name, "Piloting Bonus", 3); header += ProcessPropertyDetails(item.ScanningBonus, componentType.Name, "Scanning Bonus", 3); header += ProcessPropertyDetails(item.ScavengingBonus, componentType.Name, "Scavenging Bonus", 3); header += ProcessPropertyDetails(item.CastingSpeed, componentType.Name, "Activation Speed", 3); header += ProcessPropertyDetails(item.CraftBonusArmorsmith, componentType.Name, "Armorsmith", 3); header += ProcessPropertyDetails(item.CraftBonusWeaponsmith, componentType.Name, "Weaponsmith", 3); header += ProcessPropertyDetails(item.CraftBonusCooking, componentType.Name, "Cooking", 3); header += ProcessPropertyDetails(item.CraftBonusEngineering, componentType.Name, "Engineering", 3); header += ProcessPropertyDetails(item.CraftBonusFabrication, componentType.Name, "Fabrication", 3); header += ProcessPropertyDetails(item.HPBonus, componentType.Name, "HP", 5, 0.5f); header += ProcessPropertyDetails(item.FPBonus, componentType.Name, "FP", 5, 0.5f); header += ProcessPropertyDetails(item.EnmityRate, componentType.Name, "Enmity", 3); header += ProcessPropertyDetails(item.ForcePotencyBonus, componentType.Name, "Force Potency", 3); header += ProcessPropertyDetails(item.ForceAccuracyBonus, componentType.Name, "Force Accuracy", 3); header += ProcessPropertyDetails(item.ForceDefenseBonus, componentType.Name, "Force Defense", 3); header += ProcessPropertyDetails(item.ElectricalPotencyBonus, componentType.Name, "Electrical Potency", 3); header += ProcessPropertyDetails(item.MindPotencyBonus, componentType.Name, "Mind Potency", 3); header += ProcessPropertyDetails(item.LightPotencyBonus, componentType.Name, "Light Potency", 3); header += ProcessPropertyDetails(item.DarkPotencyBonus, componentType.Name, "Dark Potency", 3); header += ProcessPropertyDetails(item.ElectricalDefenseBonus, componentType.Name, "Electrical Defense", 3); header += ProcessPropertyDetails(item.MindDefenseBonus, componentType.Name, "Mind Defense", 3); header += ProcessPropertyDetails(item.LightDefenseBonus, componentType.Name, "Light Defense", 3); header += ProcessPropertyDetails(item.DarkDefenseBonus, componentType.Name, "Dark Defense", 3); header += ProcessPropertyDetails(item.LuckBonus, componentType.Name, "Luck", 3); header += ProcessPropertyDetails(item.MeditateBonus, componentType.Name, "Meditate", 3); header += ProcessPropertyDetails(item.RestBonus, componentType.Name, "Rest", 3); header += ProcessPropertyDetails(item.MedicineBonus, componentType.Name, "Medicine", 3); header += ProcessPropertyDetails(item.HPRegenBonus, componentType.Name, "HP Regen", 3); header += ProcessPropertyDetails(item.FPRegenBonus, componentType.Name, "FP Regen", 3); header += ProcessPropertyDetails(item.BaseAttackBonus, componentType.Name, "BAB", 3, 6); header += ProcessPropertyDetails(item.StructureBonus, componentType.Name, "Structure Bonus", 3); header += ProcessPropertyDetails(item.SneakAttackBonus, componentType.Name, "Sneak Attack", 3); header += ProcessPropertyDetails(item.DamageBonus, componentType.Name, "Damage", 3); header += ProcessPropertyDetails(item.StrengthBonus, componentType.Name, "STR", 3); header += ProcessPropertyDetails(item.DexterityBonus, componentType.Name, "DEX", 3); header += ProcessPropertyDetails(item.ConstitutionBonus, componentType.Name, "CON", 3); header += ProcessPropertyDetails(item.WisdomBonus, componentType.Name, "WIS", 3); header += ProcessPropertyDetails(item.IntelligenceBonus, componentType.Name, "INT", 3); header += ProcessPropertyDetails(item.CharismaBonus, componentType.Name, "CHA", 3); header += ProcessPropertyDetails(item.DurationBonus, componentType.Name, "Duration", 3); SetPageHeader("SalvagePage", header); // Remove the temporary copy from the game world. item.Destroy(); }