Jump to content

Adding a Hazard to a static object with xedit


Recommended Posts

Is there an easy way to add a hazard to a static object so it will be present on all the objects throughout the worldspace that have that Form ID?

 

I am using Fo4edit, I don't know much at all about Creation Kit. There is an option to Add Script to static objects, but not many other options as far as adding references to spells or hazards.

 

At the moment, I have been hand placing the hazards in the same location as the objects, but that method is going to take a VERY long time.

 

an example is how the radioactive barrels have a radiation Hazard.

 

 

Link to comment
Share on other sites

Find all references to a given object you want to attach a hazard to. Build ref info for Fallout4.esm, then go to the "referenced by" tab of the STAT record you want to attach a hazard to, select all REF type references and copy as new record into a new (or existing) plugin.

 

Navigate into your plugin, expand all worldspace and interior cells and select all of of the records in one of either section - do not try to operate on both worldspace and interior cells simultaneously, it won't work.

 

Then use this script to replace their reference bases with the load order corrected FormID of a HAZD record you want to attach:

{
  Replace FormIDs with intReplace in strSubR subrecords
}
unit UserScript;

const
    intReplace = 'your load-order corrected FormID goes here';
    strSubR = 'NAME';

var
  ReplaceCount: integer;

function Initialize: integer;
begin
  ReplaceCount := 0;
end;

procedure SearchAndReplace(e: IInterface; i: integer);
begin
  if not Assigned(e) then Exit;

  // remove rfIgnoreCase to be case sensitive
  Inc(ReplaceCount);
  AddMessage('Replacing in ' + FullPath(e));
  SetEditValue(e, i);
end;

function Process(e: IInterface): integer;
begin
    if not Assigned(ElementBySignature(e, strSubR)) then begin
        Add(e, strSubR, True);
        ElementAssign(ElementByPath(e, strSubR), LowInteger, ElementByPath(e, strSubR), False);
        SearchAndReplace(ElementBySignature(e, strSubR), intReplace);
    end
    else
    begin
        SearchAndReplace(ElementBySignature(e, strSubR), intReplace);
    end;
end;

function Finalize: integer;
begin
  AddMessage(Format('Replaced %d occurences.', [ReplaceCount]));
end;

end.

That should work out. You essentially place a HAZD at the exact same spot where the pivot point (the small yellow axis you can see in the CK) of the STAT record is.

 

You might have to clean up invalid reference properties or links of your original references (some might set the scale of your HAZD to something you didn't expect or link to something you don't expect) but Creation Engine might also simply ignore invalid reference properties. Can't say for sure.

Edited by payl0ad
Link to comment
Share on other sites

hmm, thanks. I'm still sifting through and finding all the placed objects in the cells. World space did not have too many.

 

I think I can figure out what you are saying. It's all kinda new to me. When it comes to Cells, they are not all interiors are they? I understand I must compile the placed object refs from cells and worldspace separately and do the script for each list..I think.

 

I have noticed that All radiation hazards were hand placed along with the barrels, So I wonder why the devs didn't use this method if it is more efficient? I guess they were basically hand placing everything anyway, so there would be no need unless they wanted to place a hazard as an afterthought.

 

Thanks.

Btw Ireally like your PIRAD mod.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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