Jump to content
zilav

[WIPz] TES5Edit

Recommended Posts

4 hours ago, zilav said:

No, this works fine, tested myself. It will exit if flag is set. Something else must be wrong if it doesn't work for you, or you applied script to the wrong NPCs.

Thanks again for your help.  When I tested it on the Whiterun Crime Faction it appeared to work.  There were 0 NPCs with that flag set.  So to be sure I ran another test. 

I removed the script that was checking for the faction and replaced the 0 with a 1.

if Signature(e) <> 'NPC_' then
Exit;
 
if GetElementNativeValues(e,'ACBS\Template Flags\Use AI Packages') <> 1 then
Exit;

I ran this on the all of the NPCs in the Skyrim.esm  and it exits every time.  There should be hundreds of NPCs with that flag set.

Share this post


Link to post
Share on other sites
42 minutes ago, Dragonblood said:

I ran this on the all of the NPCs in the Skyrim.esm  and it exits every time.  There should be dozens of NPCs with that flag set.

I ran it too and it patched 147 NPCs from Skyrim.esm with both flag and faction check https://pastebin.com/raw/qM1ZqgCS

No idea what's wrong in your case. Maybe you've made some other changes in the script which caused it to fail.

Share this post


Link to post
Share on other sites
20 hours ago, zilav said:

I ran it too and it patched 147 NPCs from Skyrim.esm with both flag and faction check https://pastebin.com/raw/qM1ZqgCS

No idea what's wrong in your case. Maybe you've made some other changes in the script which caused it to fail.

No Problem.  Using the 1 does not work.  It exits every time.  

if GetElementNativeValues(e,'ACBS\Template Flags\Use AI Packages') <> 1 then
Exit;
 
However this works perfectly to get all of the NPCs with the Flag Set. 
if not  GetElementNativeValues(e,'ACBS\Template Flags\Use AI Packages') <> 0 then
Exit;
 
The function using the 0 works perfectly.   Thanks for all of your help.  The Script is working great. 

Share this post


Link to post
Share on other sites

So I have found a minor issue that prevents some work I am doing. In the creation kit you can set an enchantment value for a hazard entry and it does work fine in game but xedit freaks out whenever it sees a ench value there. Is there any way to fix this?

 

[00:08] SUM_Weapon_Des_Hazard_FireHazard "Fire" [HAZD:0611A248]
[00:08]     HAZD \ DATA - Data \ Spell -> Found a ENCH reference, expected: NULL,SPEL
[00:08] SUM_Weapon_Des_Hazard_ShockHazard "Shock" [HAZD:0611A249]
[00:08]     HAZD \ DATA - Data \ Spell -> Found a ENCH reference, expected: NULL,SPEL
[00:08] SUM_Weapon_Des_Hazard_FrostHazard "Frost" [HAZD:0611A24A]
[00:08]     HAZD \ DATA - Data \ Spell -> Found a ENCH reference, expected: NULL,SPEL

Share this post


Link to post
Share on other sites
1 hour ago, Kelsenellenelvian said:

So I have found a minor issue that prevents some work I am doing. In the creation kit you can set an enchantment value for a hazard entry and it does work fine in game but xedit freaks out whenever it sees a ench value there. Is there any way to fix this?

I'll fix that, it is just none of vanilla files use enchantment in hazard and that's where we get default allowed record types for fields.

Share this post


Link to post
Share on other sites
9 hours ago, zilav said:

I'll fix that, it is just none of vanilla files use enchantment in hazard and that's where we get default allowed record types for fields.

Awesome! Thank you so very much. That one is a huge pain in my ass. Every time I work with those entries I have to go into the creation kit and reset them. 

Share this post


Link to post
Share on other sites

I'm using TES5Edit 3.2.1 (revision 3da194b). When loading "Unofficial Skyrim Legendary Edition Patch.esp" by itself and using "Check for Errors" nothing comes up and everything is fine. If I load my entire load order and then use Check for Errors on USLEEP the following will be logged:

[00:00] Checking for Errors in [05] Unofficial Skyrim Legendary Edition Patch.esp
[00:04] IronbindExitDoorExt [REFR:000643E6] (places NorWoodDoorLoad01 "Wooden Door" [DOOR:0002C157] in GRUP Cell Persistent Children of [CELL:00000D74] (in Tamriel "Skyrim" [WRLD:0000003C]) at 19,15)
[00:04]     REFR \ XNDP - Navigation Door Link \ Teleport Marker Triangle -> <Warning: Navmesh triangle not found in "[NAVM:001058E0] (in GRUP Cell Temporary Children of IronbindBarrowExterior03BackDoor [CELL:00008FDF] (in Tamriel "Skyrim" [WRLD:0000003C] at 19,15))">
[00:05] DLC2WindhelmToSolstheim [REFR:04016FE0] (places ShipTrapdoor01 "Door" [DOOR:0002834E] in GRUP Cell Persistent Children of [CELL:00000D74] (in Tamriel "Skyrim" [WRLD:0000003C]) at 45,16)
[00:05]     REFR \ XNDP - Navigation Door Link \ Teleport Marker Triangle -> <Warning: Navmesh triangle not found in "[NAVM:000FC127] (in GRUP Cell Temporary Children of WindhelmDocksExterior01 [CELL:0000B4B9] (in Tamriel "Skyrim" [WRLD:0000003C] at 34,8))">
[00:19] All Done!

Is this a general problem of xEdit (maybe because it's a dev version)? Or a problem of USLEEP? @Arthmoor Or is it simply a case of "don't use this function if you load your entire load order in xEdit at once"?

Share this post


Link to post
Share on other sites
36 minutes ago, pStyl3 said:

Or is it simply a case of "don't use this function if you load your entire load order in xEdit at once"?

What mods override those navmeshes? It means that the triangle REFR\XNDP is pointing to doesn't exist in the current winning override of a navmesh. I added this check because such errors crash Fallout 3 and New Vegas, but not Skyrim afaik.

Share this post


Link to post
Share on other sites

If I load only USLEEP and HoamaiiClearskyHideout.esp from Clearsky Hideout and then use Check for Errors on USLEEP, this is the result:

[00:00] Checking for Errors in [05] Unofficial Skyrim Legendary Edition Patch.esp
[00:04] IronbindExitDoorExt [REFR:000643E6] (places NorWoodDoorLoad01 "Wooden Door" [DOOR:0002C157] in GRUP Cell Persistent Children of [CELL:00000D74] (in Tamriel "Skyrim" [WRLD:0000003C]) at 19,15)
[00:04]     REFR \ XNDP - Navigation Door Link \ Teleport Marker Triangle -> <Warning: Navmesh triangle not found in "[NAVM:001058E0] (in GRUP Cell Temporary Children of IronbindBarrowExterior03BackDoor [CELL:00008FDF] (in Tamriel "Skyrim" [WRLD:0000003C] at 19,15))">
[00:19] All Done!

 

USLEEP + 3DNPC.esp from Interesting NPCs has the other result:

[00:00] Checking for Errors in [05] Unofficial Skyrim Legendary Edition Patch.esp
[00:04] DLC2WindhelmToSolstheim [REFR:04016FE0] (places ShipTrapdoor01 "Door" [DOOR:0002834E] in GRUP Cell Persistent Children of [CELL:00000D74] (in Tamriel "Skyrim" [WRLD:0000003C]) at 45,16)
[00:04]     REFR \ XNDP - Navigation Door Link \ Teleport Marker Triangle -> <Warning: Navmesh triangle not found in "[NAVM:000FC127] (in GRUP Cell Temporary Children of WindhelmDocksExterior01 [CELL:0000B4B9] (in Tamriel "Skyrim" [WRLD:0000003C] at 34,8))">
[00:16] All Done!

To mention is, with 3DNPC.esp it's with version 3.41. The latest version is 3.42, I'm currently downloading that one aswell and will see if it's the same with the new version.

Share this post


Link to post
Share on other sites

Basically it's what zilav already said. Those mods are overriding navmeshes that USLEEP fixed, probably for good reason I'd imagine since both of them are likely to need to change the navmesh data themselves. It's more or less impossible to know if either of them included the navmesh fix before proceeding to edit them though.

Share this post


Link to post
Share on other sites

I am about to start working on what should be a fairly simple script and can use any help I can get. 

1. The Script will identify a Record with a particular script ( I have already learned how to do this thanks to Zilav).

2. Remove that Script.

3. Replace it with another script.  

The question I would have would be will the properties on the exiting script be removed with the script name?  

 

Share this post


Link to post
Share on other sites

You can't remove the script name, you can only remove the Script entry itself in the Scripts array. And since Properties are located in individual Script entries, they will be removed altogether.

Share this post


Link to post
Share on other sites
2 hours ago, zilav said:

You can't remove the script name, you can only remove the Script entry itself in the Scripts array. And since Properties are located in individual Script entries, they will be removed altogether.

This is what I have so far.  I am running it on an esp that have have turned into a Esm. 

Alright!   

1. The Script will identify a Record with a particular script ( I have already learned how to do this thanks to Zilav).

2. Remove that Script.

3. Replace it with another script.

4. Add ownership to some of them.

I simply can not get this right. Nothing I have attempted has worked.  I have also been attempting to set the ownership of some of the REFRs, but can not get it to work.  

{
  Replace Sripts.
}
unit ReplaceScripts;

var
  plugin: IInterface;

function Process(e: IInterface): Integer;
var
  p, r: IInterface;
begin
  // process only references
  if Signature(e) <> 'REFR' then
    Exit;
    
  // only master references
 // if Not IsMaster(e) then
 // Exit;
  
  // but work with the current winning override
 e := WinningOverride(e);
  

  // check the presense of script
if GetElementEditValues(e,'VMAD\Scripts\Script\scriptName') <> 'A1_orTreeFood' then
   Exit;

    
  
  // create a new plugin if not created yet or use the last loaded
  if not Assigned(plugin) then begin
    if MessageDlg('Create a new plugin [YES] or append to the last loaded one [NO]?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
      plugin := AddNewFile
    else
      plugin := FileByIndex(Pred(FileCount));
    if not Assigned(plugin) then begin
      Result := 1;
      Exit;
    end;
  end;

  // add masters before copying as override for parent CELL
  AddRequiredElementMasters(LinksTo(ElementByIndex(e, 0)), plugin, False);
  // and REFR itself
  AddRequiredElementMasters(e, plugin, False);

  try
    // copy reference as override
    r := wbCopyElementToFile(e, plugin, False, True);
    
    // Remove the Element

 RemoveElement(r,'VMAD\Scripts\Script');

/////////////////////////////////////////////////////////////////////////
// Dose Not Work.  I do not know what I am doing wrong and there are no error messages.
  if ElementExists(r, 'VMAD\Scripts\Script') then
    AddMessage('Parent already exists on ' + Name(r))
  else begin
    Add(r, 'VMAD\Scripts\Script', True);
    SetElementEditValues(r,'VMAD\Scripts\Script\scriptName', 'A1_orTreeFood');
  end;
// Dose Not Work.  I do not know what I am doing wrong and there are no error messages.

  if ElementExists(r, 'Ownership') then
    AddMessage('Parent already exists on ' + Name(r))
  else begin
    Add(r, 'Ownership\XOWN - Owner', True);
    SetElementEditValues(r,'Ownership\XOWN - Owner', 'TitusMedeII "Emperor Titus Mede II" [NPC_:0001D4B9]');
  end;

//////////////////////////////////////////////////////////////////////////////

  except
    on Ex: Exception do begin
      AddMessage('Failed to copy: ' + FullPath(e));
      AddMessage('    reason: ' + Ex.Message);
    end;
  end;
end;

function Finalize: integer;
begin
  if Assigned(plugin) then
    SortMasters(plugin);
end;

end.

 

Share this post


Link to post
Share on other sites

Add() is used to add new records in groups or new elements in main record. You must use ElementAssing() to add a new element in a list. There are plenty of demo scripts using it.

Share this post


Link to post
Share on other sites
11 hours ago, zilav said:

Add() is used to add new records in groups or new elements in main record. You must use ElementAssing() to add a new element in a list. There are plenty of demo scripts using it.

Ok,  I am now able to set the ownership of the REFR

Using ElementAssing() does not work. The problem was this  'Ownership\XOWN' .  It needed to be just 'Ownership'

if ElementExists(r, 'Ownership') then
  AddMessage('Parent already exists on ' + Name(r))
else begin
  Add(r, 'Ownership', True);
end;
SetElementEditValues(r,'Ownership\XOWN','TitusMedeII "Emperor Titus Mede II" [NPC_:0001D4B9]');

All I am able to do regarding the script is Remove.   I can not add anything to it.  

RemoveElement(r,'VMAD\Scripts\Script');
ElementAssign(ElementByPath(r,'VMAD\Scripts\Script'), LowInteger, nil, false);
SetElementEditValues(r,'VMAD\Scripts\Script\scriptName', 'A1_orTreeFood');

 

Share this post


Link to post
Share on other sites
16 hours ago, Dragonblood said:
RemoveElement(r,'VMAD\Scripts\Script');
ElementAssign(ElementByPath(r,'VMAD\Scripts\Script'), LowInteger, nil, false);
SetElementEditValues(r,'VMAD\Scripts\Script\scriptName', 'A1_orTreeFood');

The first argument for ElementAssign() is a list element itself, so it should be 'VMAD\Scripts'. Second is a list index to assign to (LowInteger - add a new element and prepend at the start of a list, HighInteger - append new element at the end). It returns the added element, so use it instead of writing a full path again.

entry := ElementAssign(...);
SetElementEditValues(entry, 'scriptName', 'aaa');

 

Share this post


Link to post
Share on other sites
48 minutes ago, zilav said:

The first argument for ElementAssign() is a list element itself, so it should be 'VMAD\Scripts'. Second is a list index to assign to (LowInteger - add a new element and prepend at the start of a list, HighInteger - append new element at the end). It returns the added element, so use it instead of writing a full path again.


entry := ElementAssign(...);
SetElementEditValues(entry, 'scriptName', 'aaa');

 

Thanks!  Works Great.  With the information available online this would have been hard to do without your assistance.

r := ElementAssign(ElementByPath(r,'VMAD\Scripts'),HighInteger, nil, false);
SetElementEditValues(r,'scriptName', 'A1_orTreeFood');

 

Share this post


Link to post
Share on other sites
On 28/12/2017 at 3:13 PM, Dragonblood said:

With the information available online this would have been hard to do without your assistance.

As far as I know, xEdit scripting informations are centralized here: https://www.creationkit.com/index.php?title=TES5Edit_Scripting_Functions

 

Anything you know know / learned that's not here, feel free to add it there (at least in the discussion page). 

 

Also tagging @Mator, he had a WIP tutorial at some point, (more like an actual guide, less like a reference). Not sure where it's at now, lot of things happened since then.

Share this post


Link to post
Share on other sites

Potential candidate for "check for errors" :

Unique NPCs for which the actor reference have a "Boss" location reference type will fail to fill quest aliases through "Unique Actor" filling type, on start enabled quest.

 

That's just the raw report, the fact that the quest is start game enabled or not, or the fact that the locreftype is "Boss" is likely unrelevant.

I'm not 100% sure this should go under "check for errors". I mean, it definitely is an error, but not a technical problem like a null formid or the other thing usually checked through this functionality. Maybe I should just write a custom checker for this kind of things ? (there is a few other errors related to aliases, most of them reported properly by the CK, that xEdit have no clue about). Thoughts ?

Share this post


Link to post
Share on other sites

Thanks. I'll check for extended cases (other loc ref type, start game enabled, and eventually some other relevant filling type) and send it along the 3 other issues I'd wish to see reported.

Share this post


Link to post
Share on other sites

I'd be curious to see this test esp as well since I've never heard of such a problem and I'd imagine that vanilla quests could break because of this too.

Share this post


Link to post
Share on other sites

So... turns out I jumped into conclusion a bit to quickly. Aliases filling doesn't seem to care much about the loc ref type of a unique actor. 

There was indeed a bug that prevented the alias to fill properly. But it wasn't the loc ref type, even though that's when I removed it that the quest suddenly started working.
After some trimming of all the edits I had here and there, here is a view of the plugin that solved the bug:

image.thumb.png.c9aa05642e39c22de040b303ae14f805.png

 

Now, if you'll excuse me, I think I'm just going to cry in that corner over there. The "just_achr.esp" allow the alias filled by the base NPC to fill, and the parent quest to work properly. Disabling this plugin end up in the quest not filling its aliases, and thus not working.  :wallbash:

Share this post


Link to post
Share on other sites

@Kesta No idea what to say. I can speculate that having an esp overriding esm maybe gives some priority in initialization for those records which could affect quest alias filling... but it is highly unlikely. Are you really sure there are nothing else interfering which could affect the outcome?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Support us on Patreon!

×