For the people who wanted to see it, the code I've been screwing around with is here:
http://alandfaraway.org/haks/abr_creator/
and the discussion is here:
http://www.nwn2forge.org/forums/viewtopic.php?t=15
Its just testing code now, for consumables. Its not and never will be user-friendly. The problem I've run into is saving the resource once its created, as silly as that sounds. I can't seem to find a way to do that at all. As you can see I've tried all sorts of things, including manipulating the GFF struct directly.
If you actually want to try to get the plugin to work the way it is written, you'll need a template scroll, potion and wand item with the resrefs "abr_it_sr_", "abr_it_po_", and "abr_it_wa_" in the mod.
Content creation plugin
Moderators: ALFA Administrators, Staff - Technical
Content creation plugin
Last edited by Ronan on Fri Oct 27, 2006 2:27 am, edited 1 time in total.
Code that should work:
Code: Select all
private void CreateNewBlueprint() {
OEIShared.IO.IResourceRepository repository = null;
NWN2Toolset.NWN2.Data.NWN2GameModule module = NWN2Toolset.NWN2ToolsetMainForm.App.Module;
repository = module.Repository;
if(repository != null){
NWN2ItemBlueprint newBp = new NWN2ItemBlueprint();
ushort resType = OEIShared.Utils.BWResourceTypes.GetResourceType("UTI");
newBp.Resource = repository.CreateResource(new OEIShared.Utils.OEIResRef("sin"+DateTime.Now.Ticks), resType);
bp = NWN2GlobalBlueprintManager.CreateCopyOfBlueprint(newBp, module, repository, true) as NWN2ItemBlueprint;
OEIShared.IO.GFF.GFFFile gff = new OEIShared.IO.GFF.GFFFile();
gff.FileHeader.FileType = OEIShared.Utils.BWResourceTypes.GetFileExtension(resType);
bp.SaveEverythingIntoGFFStruct(gff.TopLevelStruct, true);
using (Stream stream = bp.Resource.GetStream(true)) {
gff.Save(stream);
bp.Resource.Release();
}
NWN2Toolset.NWN2.Data.Templates.INWN2Object obj = bp as NWN2Toolset.NWN2.Data.Templates.INWN2Object;
obj.Tag = bp.ResourceName.Value;
obj.LocalizedName[OEIShared.Utils.BWLanguages.CurrentLanguage] = bp.ResourceName.Value;
bp.BlueprintLocation = module.BlueprintLocation;
NWN2Toolset.NWN2.Data.TypedCollections.NWN2BlueprintCollection coll = module.GetBlueprintCollectionForType(NWN2Toolset.NWN2.Data.Templates.NWN2ObjectType.Item);
bp.BaseItem = baseItemReferences[selectBaseItem.Text];
coll.Add(bp);
clearCreatureInventory();
updateItem(bp);
NWN2Toolset.NWN2ToolsetMainForm.App.BlueprintView.ResetContents();
}
}