Jump to content

Possible to enumerate a mods added items via script?


RoyBatterian

Recommended Posts

You clearly don't know anything about programming/scripting, then. :smile:

That made me chuckle.

 

 

 

I believe my friend luthien was being sarcastic.

Not at all. I even tested the idea just for posterity's sake.

 

 

Here's a script I attached to a start-game-enabled quest:

 

scn lutModScanTest

long scanindex     ; Yes, there really are long integers in this scripting engine.
short modcount
ref itemref

begin gamemode

    if(getgamerestarted)
        con_scof "modscanoutput.txt"
        set modcount to 0
        while(modcount < getnumloadedmods)
            set scanindex to 0
            while(scanindex < 16777216)
                set itemref to buildref modcount scanindex
                if(isreference itemref)
                else
                    if(gettype itemref == 40)
                        printc "[%i] : %n" itemref itemref
                    endif
                endif
                let scanindex += 1
            loop
            let modcount += 1
        loop
    endif
    
end ; gamemode

I loaded up the game with only the DLCs and pre-order packs active (plus my plugin holding the quest for the script) and the game locked up for about 20 minutes generating this output: http://pastebin.com/raw.php?i=PqjqFGAS

 

The problem is not difficulty, as I've just shown; the problem is practicality. The value 16777216 used above isn't pulled out of thin air. The script checks for weapon base forms (as an example) for IDs ranging from 0x000000 to 0xFFFFFF. While it's true that you'll probably never see a normal plugin with FormIDs in even the 0x200000 range (FalloutNV.esm doesn't even hit 0x180000), a common practice when merging plugins into a master is to renumber them starting at a unique value in order to avoid conflicts with existing IDs. NVEC, for example, has FormIDs in the 0x480000 range. That means that in order to pull all forms from the load order you have to check 16.7 million values for each plugin.

 

Obviously, doing this in a single frame is insane. However, you have to remember that my machine took 20 minutes just doing that for the DLCs. If you ran that scan in chunks it would take even longer to complete. I don't think there's any viability in an initialization method that takes an hour in-game to finish.

 

 

 

Have I proven myself yet? (Now I'm being sarcastic. :smile:)

Link to comment
Share on other sites

TES5Edit/FNVEdit builds reference information on loading. You could easily enumerate forms in these programs and save whatever sort of output you want. If you wanted weapons you could process the WEAP group in all loaded mods and add each processed record to a stringlist. If there are 600 weapons it'd take about 10 seconds.

Link to comment
Share on other sites

TES5Edit/FNVEdit builds reference information on loading. You could easily enumerate forms in these programs and save whatever sort of output you want. If you wanted weapons you could process the WEAP group in all loaded mods and add each processed record to a stringlist. If there are 600 weapons it'd take about 10 seconds.

Great. And then what?

The whole idea is doing it in-game - finding all the items of certain types from all the mods currently loaded, and that it would work with ANY mod setup. What luthienanarion suggested does exactly that but, for reasons he already explained, would be impractical.

Edited by jazzisparis
Link to comment
Share on other sites

 

TES5Edit/FNVEdit builds reference information on loading. You could easily enumerate forms in these programs and save whatever sort of output you want. If you wanted weapons you could process the WEAP group in all loaded mods and add each processed record to a stringlist. If there are 600 weapons it'd take about 10 seconds.

Great. And then what?

The whole idea is doing it in-game - finding all the items of certain types from all the mods currently loaded, and that it would work with ANY mod setup. What luthienanarion suggested does exactly that but, for reasons he already explained, would be impractical.

 

 

A TES5Edit script would function exactly the same way, it just would have to be run again if/when you added any mods to your load order.

Link to comment
Share on other sites

Yes but the reason I wondered if it could be done in game via script, was to automate the process of adding the items to containers to be accessed by the player regardless of what load order they were using. While it is certainly less time consuming to use TES/FNV Edit to do such a task, I would still have to create and fill all the containers by hand. It just seems impractical either way to do so in a timely manner. Hand editing would take just as long or longer to do than letting a script run in game to do it, which luthienanarion has already demonstrated takes a completely unreasonable amount of time to execute even with just the base game.

 

Perhaps later on when I have the ability to make plugins for NVSE I could make something which could do so in a reasonable amount of time in game. Of course if someone would like to take the idea who already has the skill and know how to do, then I wouldn't complain about it and actually would be quite happy if they did. Seems like a lot of work though for a "cheat", and I doubt anyone else besides me would actually bother with it.

 

I think this was more an exercise in "what if" :)

Link to comment
Share on other sites

Perhaps later on when I have the ability to make plugins for NVSE I could make something which could do so in a reasonable amount of time in game. Of course if someone would like to take the idea who already has the skill and know how to do, then I wouldn't complain about it and actually would be quite happy if they did. Seems like a lot of work though for a "cheat", and I doubt anyone else besides me would actually bother with it.

 

I think this was more an exercise in "what if" :smile:

It's a good thing I know a thing or two about programming/scripting, then.

 

I wrote an NVSE plugin function to test that, too:

BBoundObjectListHead* objects = g_data->Get()->boundObjectList;
TESBoundObject* object = objects->first;
do{
	object = object->next;
	if(object->GetTypeID() == type)
	{
		_MESSAGE("%d", object->refID);
		list->AddAt(DYNAMIC_CAST(object, TESBoundObject, TESForm), eListEnd);
	}
}while(object != objects->last);
(Ian will probably shoot me for this.)

 

This function scans the DataHandler's list of bound objects and dumps the IDs of weapons to a log file.

This output was instantaneous: http://pastebin.com/raw.php?i=N9xw7F7Z (The IDs are in decimal.)

 

Non-object record types are even easier to scan. As an example, this dumps loaded races:

tList<TESRace> races = g_data->Get()->raceList;
for(tList<TESRace>::Iterator iter = races.Begin(); !iter.End(); ++iter)
{
	TESRace* tempRace = iter.Get();
	if(tempRace) _MESSAGE("%s", tempRace->GetName());
}
If you want to check these methods out yourself, g_data in my examples is a pointer of the DataHandler class defined in GameData.h in the NVSE source.

My weapon-scan example could probably have dumped the names of the weapon forms instead of the IDs if I had typcasted them or something. /shrug

 

 

I'll see if I can polish these methods into a useful function or two that you can call in your scripts to load an array or formlist with data of whatever type you want.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...