Jump to content
⚠ Known Issue: Media on User Profiles ×

Posting this so anyone else with the same question can get answers.


ShinraStrife

Recommended Posts

I was asked how I compiled scripts and inserted them into records with FO4Edit. I posted this topic so others can get an idea of what is involved.
EDIT: All data of VMAD Parameter 3 has been accounted for and should be accurate. (big thanks to DominusSicarum) - 11/30/2015 10:50 PM EST

 

I saw you got the script working with Pex Upgrader tool. While I'm perfectly fine creating scripts, I have 0 experiance using TESV Edit so I was wondering if you could run through the process you did to add scripts to fallout4 If you would be so kind? =)

 

Its very much a work in progress. For instance to attach a script to a magic effect you have do do a bit of hex editing.

Here is an example:

 

I want to add a script that gives a player an item, and attach that script to a magic effect so it can be used with consumable items.

 

I first build the script in Notepad++ , compile it in Skyrim CK and convert the PEX file to fo4 with the PexUpgrade tool:

 

http://s14.postimg.org/p2jud1y4f/Screenshot_192.png

http://s14.postimg.org/egzz11rsv/Screenshot_196.png

 

As you can see in the screenshot the scripts name is: Shinra_Craftable_Alcohol_SCR.psc, it has a property called Caps001, and the property is a reference to a MiscObject.

 

Now we want to build the magic effect and set the item received to an enpty wine bottle, this can be tricky depending on what type of record you are attaching a script to as not all of the record structures have been figured out yet. The value we need to edit is in the VMAD sub-record at Parameter 3.

 

It looks like a bunch of garbage at first:

 

http://s14.postimg.org/q7dwifklb/Screenshot_193.png

 

But if we copy the data into a hex editor things become much more clearer:

 

http://s4.postimg.org/8xq4y39xn/Screenshot_197.png

 

This is basically all we need to know for attaching something simple to the magic effect:

 

01 00 1C 00 53 68 69 6E 72 61 5F 43 72 61 66 74 61 62 6C 65 5F 41 6C 63 6F 68 6F 6C 5F 53 43 52 00 01 00 07 00 43 61 70 73 30 30 31 01 01 00 00 FF FF ED ED 0D 00

 

The purple data is the number of scripts to be connected to the magic effect stored in Little-Endian (I elaborate below): We have one script attached.

 

The red data is the length of the string that contains our scripts file name stored in Little-Endian (I elaborate below): Our string is 28 characters, or 1C in hexadecimal.

 

The orange data is our scripts name (In an ANSI encoded string). In this case that would be: Shinra_Craftable_Alcohol_SCR

 

The grey data is the status of the script: 00 is a local script (default and used for most scripts), 01 would be inherited with altered properties, 02 would be inherited and then removed.

 

The dark orange data is the number of properties defined in our script stored in Little-Endian (I elaborate below): We have one property.

 

The green data is our declared variables string length stored in Little-Endian (I elaborate below): The length of our declared variable's name is 7 characters, so its still 07 in hexadecimal (You can use an online converter or a hex editor to convert from decimal to hex or the other way around if you aren't good with calculating the differences in your head)

 

The blue data is the name of our declared variable from the script we are attaching (also in ANSI encoding): Caps001

 

The light purple data is composed of multiple parts:

 

The first bit declares the type of variable stored in the property 01 is for objects, 02 is for strings, 03 is for integers, 04 is for floats, 05 is for booleans, 11 is for an array of objects, 12 is for an array of strings, 13 is for an array of integers, 14 is for an array of floats, and 15 is for an array of booleans.

The second bit is the status of the property: 01 is for property edited (default for most properties) 02 is for removed.

The last 4 bits are only used if the type of variable in our property is an array: the first 2 bits in the last 4 bits is for the item count and the last 2 bits of the last 4 bits are for the items in the array.

 

The pink data is slightly confusing to people who have never messed around with hexadecimal code before: ED ED 0D 00

 

This data is the value of our property, Caps001 as a FormID stored in Little-Endian format

 

Little-Endian explanation: Basically, when an offset (or a formid) gets stored (an offset is 4 bytes, a byte is 2 hexadecimal integers; Examples: A5, 0F, 36, 6C) it is stored in Little-endian which is just a fancy word for writing stuff backwards, however only the position of the bytes are reversed, not the actual value of the bytes themselves:

 

So lets say this is our offset: A5 0F 36 6C

 

This is the right and wrong way to convert it to Little-Endian:

Right- 6C 36 0F A5

Wrong- C6 63 F0 5A

 

That means our last set of data is actually 00 0D ED ED, which is the formid of an empty wine bottle.

 

Some of these values I guessed on judging by the way Skyrim's record was setup. It SHOULD be correct, given that there's not much Bethesda would change here, however if you find any inconsistencies please comment below and I will correct it.

When the script is combined with the magic effect you get something like this ingame:
http://s16.postimg.org/g9zpl3k0j/enb2015_11_24_03_14_20.png

I hope this helped the asker and anyone else interested in scripting. If you got any questions leave em below. :D

 

 

Edited by ShinraStrife
Link to comment
Share on other sites

01 00

I think this might be amount of scripts attached.

 

SlowTimeJet has two. So beginning of the data is 02 00.

abProtectronRaceEffect has two as well. 02 00 again.

 

CritPlasmaEffect has 4 (FXEquipItemOnEffectScript, FXScatterImpactEffectsOnDeath, AttachAshPile, FXaddItemOnEffectScript) and first two bits(?) are 04 00.

Edited by DominusSicarum
Link to comment
Share on other sites

 

01 00

I think this might be amount of scripts attached.

 

SlowTimeJet has two. So beginning of the data is 02 00.

abProtectronRaceEffect has two as well. 02 00 again.

 

CritPlasmaEffect has 4 (FXEquipItemOnEffectScript, FXScatterImpactEffectsOnDeath, AttachAshPile, FXaddItemOnEffectScript) and first two bits(?) are 04 00.

 

 

Yes I think that too. I had forgotten that I posted this XD I'll update it now.

Link to comment
Share on other sites

The 00 after script name (orange data) might be null termination. Which makes sence, since it's basically a string.

Or (after looking through skyrim's structure for this field) it's script's flag. It's either local (00), inherited (01), removed (02), inherited and removed (03). I have no idea what these do, but then again, I'm new to papyrus and ck in general.

 

01 01 00 00 FF FF - and this - property type and it's flags. Bold is value. I'm guessing that 00 00 ff ff corresponds to auto? Value is in little endian, btw.

 

First bit is type:

00 - None.

01 - Object.

02 - String.

03 - Int32.

04 - Float.

05 - Boolean.

 

0b - Array of Object.

0c - Array of String.

0d - Array of Int32.

0e- Arrray of Float.

0f - Array of Boolean.

 

As for arrays - I'm not sure how their value gets written.

 

Second bit is edited flag. Better not touch it and let it stay at 01, I think.

 

04 01 9a 99 19 3e this is how float variable with value of 0.150000 should look.

 

 

 

That should hold true, if they didn't change anything since skyrim.

Edited by DominusSicarum
Link to comment
Share on other sites

I don't think they'd change it. If its working why fix it XD

 

Anyways thanks for shedding light on the subject. I'll add each one to the post after I can verify the values are still usable in fo4

Edited by ShinraStrife
Link to comment
Share on other sites

Ugh. I was successful in attaching a script without properties to a magic effect, but damageav doesn't seem to work.

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Debug.Notification("Script fired!")
	akCaster.DamageActorValue("health", 20.0)
	akTarget.DamageActorValue("health", 20.0)
EndEvent

Either I'm doing something wrong, or there's no more damageav function. Debug message works though. Sigh.

 

After I digged through actor.pex, actorbase.pex and actorvalue.pex I didn't find anything even related to setting actor values. Wtf.

Link to comment
Share on other sites

Ugh. I was successful in attaching a script without properties to a magic effect, but damageav doesn't seem to work.

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Debug.Notification("Script fired!")
	akCaster.DamageActorValue("health", 20.0)
	akTarget.DamageActorValue("health", 20.0)
EndEvent
Either I'm doing something wrong, or there's no more damageav function. Debug message works though. Sigh.

 

After I digged through actor.pex, actorbase.pex and actorvalue.pex I didn't find anything even related to setting actor values. Wtf.

I'll dig through the scripts tomorrow and see if I can find an answer for you

Link to comment
Share on other sites

Newbie here to modding Bethesda games, but intrigued at messing with fiddly code...

 

I'm curious if there is a third-party papyrus compiler that could be used instead of the CK, or if that's an absolute requirement in digging into all this? I own Skyrim, so it's not a problem, but as I am not too interested in diving back into it specifically, it'd be installing a whole setup just to compile a script.

 

Thanks,

Ecu

Link to comment
Share on other sites

Newbie here to modding Bethesda games, but intrigued at messing with fiddly code...

 

I'm curious if there is a third-party papyrus compiler that could be used instead of the CK, or if that's an absolute requirement in digging into all this? I own Skyrim, so it's not a problem, but as I am not too interested in diving back into it specifically, it'd be installing a whole setup just to compile a script.

 

Thanks,

Ecu

 

The problem with using a 3rd party compiler is you would need all the source scripts that came with skyrim (because there are a lot of base functions that papyrus wont know about unless you have those source scripts) so I think you are stuck with skyrims compiler.

 

You don't have to edit the scripts inside of the CK though. What I do is link the compiler to Notepad++ so I can do everything from there and dont even need to go into the CK: http://www.creationkit.com/Notepad%2B%2B_Setup

Link to comment
Share on other sites

  • 1 month later...

This is good stuff guys -cut and paste with FoEDit works, but it's frustrating hit and miss process, as soon as I get my skyrim working, SD crash, I'll take a look at the editor -Also adding Fallout 4 to the skyrim directory for VMAD seems unnecessary, for just this purpose. It's a common call and I doubt there are copyright issues with just grabbing Virtual machine.pas

 

Take care

Link to comment
Share on other sites

  • Recently Browsing   0 members

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