public void addToPotionItems(NWN2ItemBlueprint bp) { NWN2BlueprintStoreItemInfo storeItem = new NWN2BlueprintStoreItemInfo(); storeItem.Item = bp.Resource; storeItem.Infinite = true; storeItem.Droppable = false; storeItem.Pickpocketable = false; PotionItems.Add(storeItem); }
/// <summary> /// Create a new blueprint /// </summary> /// <param name="objectType">The type of the blueprint that is about to be created</param> /// <param name="locationType">The location where the blueprint will be placed</param> /// <returns>The new blueprint</returns> private static INWN2Blueprint createNewBlueprint(NWN2ObjectType objectType, NWN2BlueprintLocationType locationType) { INWN2Blueprint cBlueprint = null; IResourceRepository userOverrideDirectory = null; NWN2Campaign activeCampaign = NWN2CampaignManager.Instance.ActiveCampaign; INWN2BlueprintSet instance = null; switch (locationType) { case NWN2BlueprintLocationType.Global: userOverrideDirectory = NWN2ResourceManager.Instance.UserOverrideDirectory; if (userOverrideDirectory != null) { userOverrideDirectory = NWN2ResourceManager.Instance.OverrideDirectory; } instance = NWN2GlobalBlueprintManager.Instance; break; case NWN2BlueprintLocationType.Module: instance = NWN2Toolset.NWN2ToolsetMainForm.App.Module; userOverrideDirectory = NWN2Toolset.NWN2ToolsetMainForm.App.Module.Repository; break; case NWN2BlueprintLocationType.Campaign: userOverrideDirectory = (activeCampaign != null) ? activeCampaign.Repository : null; instance = activeCampaign; break; default: throw new Exception("Unknown object type in CreateNewBlueprint()" + locationType.ToString()); } if ((userOverrideDirectory == null) || (instance == null)) { return null; } switch (objectType) { case NWN2ObjectType.Creature: cBlueprint = new NWN2CreatureBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Creature, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTC")); break; case NWN2ObjectType.Door: cBlueprint = new NWN2DoorBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Door, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTD")); break; case NWN2ObjectType.Item: cBlueprint = new NWN2ItemBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Item, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTI")); break; case NWN2ObjectType.Placeable: cBlueprint = new NWN2PlaceableBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Placeable, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTP")); break; case NWN2ObjectType.Trigger: cBlueprint = new NWN2TriggerBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Trigger, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTT")); break; default: throw new Exception("Unknown object type in CreateNewBlueprint()"); } NWN2BlueprintCollection blueprintCollectionForType = instance.GetBlueprintCollectionForType(objectType); INWN2Object obj2 = cBlueprint as INWN2Object; obj2.Tag = cBlueprint.ResourceName.Value; obj2.LocalizedName[BWLanguages.CurrentLanguage] = cBlueprint.ResourceName.Value; cBlueprint.BlueprintLocation = instance.BlueprintLocation; blueprintCollectionForType.Add(cBlueprint); GFFFile file = new GFFFile(); file.FileHeader.FileType = BWResourceTypes.GetFileExtension(cBlueprint.Resource.ResourceType); cBlueprint.SaveEverythingIntoGFFStruct(file.TopLevelStruct, true); using (Stream stream = cBlueprint.Resource.GetStream(true)) { file.Save(stream); cBlueprint.Resource.Release(); } return cBlueprint; }
static public void AddBlueprint(NWN2ItemBlueprint ibp) { ibp.BlueprintLocation = mod.BlueprintLocation; ibp.Resource = mod.Repository.CreateResource(new OEIShared.Utils.OEIResRef(ibp.TemplateResRef.Value), ibp.ResourceType); mod.GetBlueprintCollectionForType(NWN2Toolset.NWN2.Data.Templates.NWN2ObjectType.Item).Add(ibp); }
public Consumable(int ip, int spellId, int spellLevel, int casterLevel, CNWSpell spell, bool adjustCost = true, string iconName = null) { blueprint = new NWN2ItemBlueprint(); string tag = tagPrefix + spellId.ToString() + "_" + casterLevel.ToString(); ushort resType = OEIShared.Utils.BWResourceTypes.GetResourceType("UTI"); blueprint.Resource = Globals.repository.CreateResource(new OEIShared.Utils.OEIResRef(tag), resType); blueprint.TemplateResRef = new OEIShared.Utils.OEIResRef(tag); blueprint.Tag = tag; blueprint.ResourceName = new OEIShared.Utils.OEIResRef(tag); blueprint.BaseItem = new OEIShared.IO.TwoDA.TwoDAReference("baseitems", "Name", true, baseType); string name = ConsumableName(spell, spellId, spellLevel, casterLevel); blueprint.LocalizedName = new OEIShared.Utils.OEIExoLocString(); blueprint.LocalizedName[OEIShared.Utils.BWLanguages.BWLanguage.English] = name; blueprint.LocalizedDescriptionIdentified = new OEIShared.Utils.OEIExoLocString(); blueprint.LocalizedDescriptionIdentified[OEIShared.Utils.BWLanguages.BWLanguage.English] = baseDescription + Environment.NewLine + Environment.NewLine + Globals.GetTlkEntry((uint)spell.GetSpellDescription()) + Environment.NewLine + Environment.NewLine + GetAuraDescription(spellLevel, spell); if (ip >= 0) blueprint.Properties.Add(itemProperty(ip)); blueprint.Classification = baseCategory; if (iconName == null) iconName = findIconName(spellId, spell, spellLevel); int iconId = Globals.getIconId(iconName); if (iconId == 0) flagIconMissingForSpell(spellId, GetSpellName(spell)); blueprint.Icon = new TwoDAReference("nwn2_icons", "ICON", false, iconId); blueprint.CalculateBaseCosts(); if (adjustCost) blueprint.AdditionalCost = cost(spellLevel, casterLevel) - (int)blueprint.Cost; }
/// <summary> /// Create an instance inventory item from a blueprint /// </summary> /// <param name="blueprint">The blueprint to create the instance inventory item from</param> /// <param name="droppable">Whether the item should be dropable</param> /// <param name="pp">Whether the item should be pickpocketable</param> /// <returns>The instance inventory item</returns> private static NWN2InstanceInventoryItem createInstanceItemInfo(NWN2ItemBlueprint blueprint, bool droppable, bool pp) { NWN2InstanceInventoryItem itemInfo = new NWN2InstanceInventoryItem(); itemInfo.Item = NWN2ItemInstance.CreateFromBlueprint(blueprint); itemInfo.Droppable = droppable; itemInfo.Pickpocketable = pp; itemInfo.InInventory = true; return itemInfo; }
/// <summary> /// Create a blueprint inventory item from a blueprint /// </summary> /// <param name="item">The blueprint we want to turn into a Blueprint inventory Item</param> /// <param name="droppable">Whether the item should be dropable</param> /// <param name="pp">Whether the item should be pickpocketable</param> /// <returns>The blueprint inventory item</returns> private static NWN2BlueprintInventoryItem createBlueprintItemInfo(NWN2ItemBlueprint item, bool droppable, bool pp) { NWN2BlueprintInventoryItem itemInfo = new NWN2BlueprintInventoryItem(); itemInfo.Item = item.Resource; itemInfo.Droppable = droppable; itemInfo.Pickpocketable = pp; itemInfo.InInventory = true; return itemInfo; }
private void Validate(NWN2ItemBlueprint item) { // Custom validation of only blueprints here. // Validation of all NWN2ItemTemplates (in areas, inventories, blueprints). Validate((NWN2ItemTemplate)item, item.ResourceName.ToString()); }