Jump to content

Adding Magic Effects (with duration, magnitude, etc) to Items via FO4Edit Script?


Recommended Posts

Say I have several items of food in a mod, and I want to add/remove a magic effect to/from all of them. Say, for example, I want to remove the radiation damage on all vanilla food.

 

I've started an xEdit script that attempts to do this, but it, well, doesn't...

unit RemoveRadsScript;

const

    RadString = 'DamageRadiationChem "Chem: Radiation Damage" [MGEF:00024056]';

Function Process(eWorking: IInterface): integer;

var 

    iEcount, i: integer;
    eEffects: IInterface;
    
    begin
        eEffects := ElementBySignature(eWorking, 'Effects');
	    iECount := ElementCount(eEffects);
        for i := 1 to iECount do
	    	begin
				eEFID := GetEditValue(ElementBySignature(ElementByIndex(eEffects, iECount)), 'EFID');
				if eEFID = RadString then
					RemoveByIndex(eEffects, iECount, FALSE);
			end;
    end;
end.

Where I assume it is failing is in the "eEffects := ElementByPath(eWorking, 'Effects');" part. Since there is no overarching signature for the magic effects, I don't know what to use instead of 'Effects', as that's what they are labeled as in xEdit, as seen here:

 

lWC6YE0.png

 

Anyone have any information on how to correct this, I would be super happy!

 

Cheers,

 

~GKX

Link to comment
Share on other sites


unit RemoveRadsScript;

const
RadString = 'DamageRadiationChem "Chem: Radiation Damage" [MGEF:00024056]';

Function Process(e: IInterface): integer;
var
i: integer;
eEffects: IInterface;
eEFID: string;
begin
eEffects := ElementByPath(e, 'Effects');
for i := 0 to ElementCount(eEffects) do begin
eEFID := GetElementEditValues(ElementByIndex(eEffects, i), 'EFID');
if eEFID = RadString then
RemoveByIndex(eEffects, i, FALSE);
end;
end;
end.
Link to comment
Share on other sites

I'm pretty new to it too, but I've been practicing a lot for the last month, and I think that I've done a little mistake in this script, in the for loop, it goes from 0 to the count when it should go from 0 to count -1, for this end there's a function, Pred(), which returns the value of the passed integer minus 1:

for i := 0 to Pred(ElementCount(eEffects)) do begin

Like in any other programming language, if the count is 5, it contains 5 index: 0, 1, 2, 3, 4. So the loop goes from 0 to 4 (5-1).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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