Content creation plugin

Development of standard ALFA palettes (ABR)

Moderators: ALFA Administrators, Staff - Technical

Locked
Ronan
Dungeon Master
Posts: 4611
Joined: Sun Feb 20, 2005 9:48 am

Content creation plugin

Post by Ronan »

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.
Last edited by Ronan on Fri Oct 27, 2006 2:27 am, edited 1 time in total.
paazin
Fionn In Disguise
Posts: 3544
Joined: Thu Apr 15, 2004 1:07 am
Location: UTC +2
Contact:

Post by paazin »

The selected post does not exist?
People talk of bestial cruelty, but that's a great injustice and insult to the beasts; a beast can never be so cruel as man, so artistically cruel.
Ronan
Dungeon Master
Posts: 4611
Joined: Sun Feb 20, 2005 9:48 am

Post by Ronan »

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();
            }            
        }
Locked