Fallout 4

Intro
This article is meant for those who want to create patches for weapons themselves.
To keep this article relatively short, the modelling of the scopes is not discussed.
Instead, it is assumed an existing model from the See Through Scopes mod is used.
You will be required to use the following tools:
- FO4Edit
- Nifskope
It might be usefull to first download the mod and extract the zip folder.
Then, copy the contents of the folder "00 - Main" to a place of your liking. (The DLC scopes are located in "01 - DLC\<DLC NAME>")

Note about making a weapon with STS support
If you are not planning on publishing a standalone mod with STS support, you can skip this part.[/size]
For compatibility reasons, it is important that if you plan on publishing your mod with STS comparability that the files you use from the mod are COPIED AND RENAMED. Do NOT include files from the STS mod with the same file location and name in your patch.
This will cause issues if the mod gets updated, or if you make changes to the files.
For instance, if your weapon has a scope that uses the "CSResRetPSO" reticle texture, make sure you copy and rename that texture to not cause any possible conflicts.
There are some cases of mods including old lens material files for no reason, messing up the STS mod for users who have that particular mod installed.

Article Overview
First, we will shortly discuss the overall setup for a scope.
Next, we start with making sure the weapon has a so called behavior link.
After that, we setup the ESP file and test if the scope works as intended in-game.
Then, we will calibrate the scope to be (somewhat) centered.
Finally, some other factors you might wanne tweak will be discussed.

Overall Setup
The scopes work by having two models: one model for when you are not aiming and another one for when you are aiming.
The first model is just the scope, nothing special there. The second model is a cut down version of the scope, allowing for the player to see through it.
As an example, open up a scope file of the Hunting Rifle using NifSkope, specifically, the "Long" version. (Located at "00 - Main\Meshes\Scopes\HuntingRifle\HuntingRifleOpticLong_1.nif")
Make sure to open the "_1" version of the scope.
In the top left corner you should see a play button, together with a drop-down list saying "scopeInit".
If the drop-down menu is not visible, then there should be a >> symbol next to the play button, click it.
From the drop-down menu select "scopeStartAiming". Now drag the bar that is next to the drop-down menu all the way to the left.
You will see the model change, showing the other scope model. This is how the scope works.
When you start aiming, the scope model is swapped to allow the player to see through it.

Now, on the left hand side should be the Block List. Expand the NiNode called HuntingScope.
You should now see a bunch of other nodes: a ControlManager, and a NiNode called ScopeNormal and another one called ScopeAiming.
The ControlManager handles the switching of the models. The two NiNodes, ScopeNormal and ScopeAiming contain the models for the scopes. Later, the article will explain how to tweak this control manager.

Behavior Link
For the scopes to work a so called Behavior Graph needs to linked to the weapon. This is done in the "root" weapon model.
To demonstrate this, open up FO4Edit and just open the Fallout 4 ESM. Next go to Weapons, and then find the "alien Blaster".
In the right part of the screen, look for Model field (it is close to the top). It should say "Weapons\AlienBlaster\AlienBlaster.nif".

Next, from the previously extracted files open "00 - Main\Meshes\Weapons\AlienBlaster\AlienBlaster,nif".
Under the "WEAPON" node, there should be a "BSBehaviorGraphExtraData" node (number 5) with the name "BGED".
Select that node, and as a "Behavior Graph File" it will have "UniqueBehaviors\RevolverFX\RevolverFX.hkx"
This node is what makes the scope's model swapping magic work.

Now, to make sure that YOUR weapon supports this, open up the ESP of your weapon, and look for the same 'root model'.
It could be that this is just an empty file (typical if the root model is a dummyReceiver).
Check if there is a BSBehaviorGraphExtraData node in this file. If there is and it points to RevolverFx, or RailwayRifleFx, then you're good to go.
If there isn't such a node, then you'll need to insert it yourself.
It is not advised to modify vanilla files if you dont have to. If your root model is a vanilla file you do the following:
- Copy the existing root model and rename it
- Modify the weapon record using FO4Edit to point to this 'new' root model.
Now to insert the behavior link, copy it from "AlienBlaster.nif". To copy, right click the BSBehaviorGraphExtraData node, Block > Copy Branch.
Next, go to your root model, right click the 0 NiNode > Block > Paste Branch.
Now save the file, and thats it. You're weapon now has a behavior link.

NOTE FOR WHEN YOU'RE DOING THIS FOR YOUR OWN WEAPON
You should create your own UniqueBehavior fileset if you are planning on publishing the weapon as a standalone. To do so, extract the UniqueBehaviors/RevolverFX folder from the game files. It should contain the following files.

Behaviors [Folder]
- Behavior.hkx
Characters [Folder]
- Character.hkx
RevolverFX.hkx

Rename the folder to YourWeaponFX.
Rename the RevolverFx.hkx file to YourWeaponFx.hkx
Replace the Behavior.hkx file with the Behavior.hkx file found in "00 - Main\Meshes\UniqueBehavior\RevolverFx\Behaviors\Behavior.hkx"

These files now need to be included with your mod. Finally, make sure the root model points to this behavior file as stated in the previous section

Setting up the ESP file
Make sure you have the 3dscopes ESP in your data folder, as well as the ESP for the weapon you are going to add the scopes to.
Open up FO4Edit and select both the 3dscopes ESP and your weapons ESP.
Next, from the 3dscopes esp, select the following records (might be useful to click the EditorID header once to sort all the entries):

From "Constructible Object", all "co_mod_PlasmaGun_..." records
From "Misc Item", all "miscmod_mod_PlasmaGun..." records
From "Object Modification", all "mod_PlasmaGun_Scope..." records.

Once you have select them all, right clight on any of the select records and select "Copy as new record into..."
FO4Edit will now first promt you to enter some text as either a suffix or prefix (about 3 times). Leave these boxes empty and click "ok".
You'll get a warning, click "Yes".

Now you'll need to tell FO4Edit to which ESP these records should be copied. If you are creating a weapon yourself, select your weapon's ESP file.
If you're making a patch, select "new file" (with newer FO4Edit versions, select the "new file" option without the ESM and ESL tags).
If you're selecting "new file" give the file a proper name. Next, the new file should be present in FO4Edit. Right click it, select "Add Masters" and select the weapon's ESP file you're making a patch for.
Next, we need to clean the file up a bit:

For all copied records, do the following:
Change the editorId from XXXXXX_PlasmaGun_XXXXXX to XXXXXX_YourWeaponNameHere_XXXXXX. (Where YourWeaponNameHere is ofcourse the name of your weapon)
To edit the editorId of the record, select it and look for EDID - Editor Id (should be fairly at the top). Click it, press F2, and make your changes.

For all copied "Constructible Object" records, do the following:
Scroll down until you see the CNAM - Created Object field. Search for that same record in the Object Modification part of THIS esp. When you found it, look at the FormID (the eight character piece of text of numbers and some letters, for instance 0104DB73). Go back to that CNAM field, select it, press F2 and enter that piece of text there.
Note: To see if you did it correctly, look at the two characters in front of the ESP name in the right panel in FO4Edit. It probably says something like [03] MyEspFile.esp.
Or a similar value like 0A, 05 or even B4. The first two characters of the FormID you just searched for should be the same as the two characters in front of your esp filename.
Furthermore, if you wish to do so, modify the Conditions (whichs perks are required) and the Crafting Recipe itself (the Components list).
FO4 Edit can be a bit clunky with this, so if you rather do so in the Creation Kit later, then thats fine as well.

For all copied "Misc Item" records, do the following:
Change the "FULL - Name" value from "Plasma Gun XXXXX" to "YourWeaponName XXXXX".
Also, take note of the "Value" (at the bottom of the record). This is the value in caps for the loose mod. It also determine the order in which the mods are displayed while crafting.
Mods with a lower value are higher in the list than mods with a higher value.

For all copied "Object Modification" records, do the following:
First, we need to lookup the weapons "ma_keyword". This keyword is a piece of data that tells the game to which weapon the mod belongs. Typically, a weapon mod contains a single ma_keyword in the keywords section, typically in the form of "ma_WeaponName". For the plasma gun it would be "ma_PlasmaGun". Once you found it, remember the FormID.
If you can't find it in the Keyword list of the weapon's ESP, or are not sure, just take a look at the weapon record for the weapon. Look for the "KWDA - Keywords" list. In it, there should be an entry "ma_xxxxxxxx [KYWD:--------].
This is then the weapons MA keyword. The value behind the KYWD is the FormID we need.
After you have found your MA keyword, do the following for each record:
Scroll all the way down. Change the MNAM - Target OMOD Keyword from "ma_PlasmaGun" to your MA keyword. To do so, select it, press F2 and type in the FormId you just found.
(For instance, type in 03000816, if thats the FormId of the MA keyword)
Next, change the LNAM - Loose mod value. This points to the Loose Mod object (Misc Item) we already changed.
Check which scope mod you are currently changing and find the corresponding Misc Item. For instance, the XXX_CombatScopeLong Object Modification should point to the XXX_CombatScopeLong Misc Item. Find that FormID, and enter it here.

If you have done all of that, right click the your patches/weapon's ESP file and select "Clean Masters".
Next, select the first item under that filename, the "File Header".
There now should NOT be a reference to "3dscopes.esp" there. IF there is, you didn't properly do the previous steps of cleaning up the copied records.
Check if you made any mistakes there then redo the clean masters.
The goal here is to NOT have the 3dscopes ESP as a dependency for this mod.

After you've done that, you should be able to test if the scopes are working. Start the game and load your ESP. Your weapon should now have the Plasma Gun's See Through Scopes on them, and they should be in working order.
Thats it. We are now ready to test if the scopes are working.

If that all works, you can put in the scope models you actually want. Its easiest to just use one of the existing scopes from the See Through Scopes mod.
If you want to create your own scopes, copy over an existing scope and use that as a template.
When using it as a template, use one of the ADDON scopes for reference, as they are designed to also work properly when the 3dscopes mod is NOT installed.
If you need to move the scope around, it is advised to modify the position of the "ScopeNormal"/"ScopeAiming"/"ScopeAlways" nodes, as this moves all the underlying models as well.

Calibrating the Scopes
Of course, the scope needs to be properly centered. To do so, you need to adjust a few values in the ESP and check if that makes the scope centered.
Personally, to do this, I start the game in windowed mode and take screenshots. Then in a simple tool like paint, I draw a line from the top left corner of the FO4 window to the bottem right corner, and one from the top right corner to the bottom left corner, forming a cross. The center of this cross is where the crosshair should be.
Other methods are aiming at a companion while standing close by, to show the square interaction prompt in the center of your screen.
Now, to actually move the scope around, modify the scopes object modification form as follows:

To move the reticle to the left (so the reticle currently is to far to the right) INCREASE the value of "ZoomDataCameraOffsetX"
To move the reticle to the right (so the reticle currently is to far to the left) DECREASE the value of "ZoomDataCameraOffsetX"
To move the reticle down (so the reticle currently is to far up) INCREASE the value of "ZoomDataCameraOffsetZ"
To move the reticle up (so the reticle currently is to far down) DECREASE the value of "ZoomDataCameraOffsetZ"

If the scope is to close to the camera, DECREASE the ZoomDataCameraOffsetY value (no lower than -15... otherwise you might get clipping issues)
If the scope is to far from the camera INCREASE the ZoomDataCameraOffsetY value (NOTE: typically this value is negative, so change it from -12 to -8 or something)

Now, normally you need to CLOSE FO4Edit to save your changes and restart to game for it to take effect. This is annoying, so there is a workaround:
For FO4Edit, create a shortcut to FO4Edit. Right click it, select Properties. Next, add the following to the 'Target' field: -AllowDirectSaves -IKnowWhatImDoing
This allows you to save without having to exit FO4Edit.
However, you cannot save an ESP while it is loaded in the game. To get around this, do the following before you try to save the ESP:
Open the in-game console and type "fcf" and press enter. This forces the game to let go of all the ESP's.
AFTER you have saved the ESP, open the console again and type "hlp YourEspName", where YourEspName is the name of the ESP you just edited (want to load).
This reloads the (changed) plugin. For the changes to take effect on the scope, reattach the scope on the workbench. (So change it to a standard sight, then change it back to the Combat Scope).
Repeat this editing of the ZoomDataCameraOffset values until the scope is properly centered.

Tweaks
Modifying the Default Reticle
NOTE: IF YOU ARE PUBLISHING YOUR PATCH/MOD, MAKE SURE TO USE THE ALTERNATIVE WAY AND COPY AND RENAME THE TEXTURES

Easiest way: modify the Reticle materials to an already existing default reticle.
To do so, pick a reticle setup you already like, for instance that of the Hunting Rifle. Next, open up that scope file and navigate to the reticle and dot node in NifSkope:
0 NiNode XXX > ScopeAiming > ScopeViewParts > ReticleNode
Here you find the Reticle:0 and Dot:0 objects.
To change them, expand the Reticle:0/Dot:0 node and select the BSEffectShaderProperty directly under it. Look at the Block Details section (lower left half of the screen by default). Then click the TXT icon next to "Name". Right now, it should say something like "Materials\Scope\Default\SomethingSomething.BGSM.BGEM".
Change this to another DEFAULT scope material. All available defaults can be found in the "00 - Main\Materials\Scope\Default" folder.
DO NOT change it to a material like "Materials\Scope\ReticleCrossMildot,BGSM.BGEM" as this seems to work, but will break the reticle customization in game.
Select a reticle and dot from the available default. Use the drop-down menu in the topleft corner to show the scope model while aiming to check the reticle.

Alternative way: setup a custom reticle configuration yourself.
Do the entire process above, except: rename the Material of the Reticle to "Materials\Scope\ReticleCrossCustom.BGSM.BGEM" and the Dot to "Materials\Scope\ReticleDotCustom.BGSM.BGEM". Next, for both the Reticle's and the Dot's BSEffectShaderProperty, modify the "Source Texture" to the texture you want the reticle and dot to use. If you want to make the dot a specific color, adjust the "Emissive Color" value as well.
NOTE: If you are planning on publishing it, don't forget to COPY AND RENAME the reticles you are going to use.

This utilizes a "bug" in the game engine. The ReticleDotCustom and ReticleCrossCustom are NON EXISTING. And they should be.
Because they don't exist, they can't be loaded. However, because we specified a source texture in the EffectShaderProperty, the game will fall back to that texture instead. However, that texture does need to be loaded already, otherwise this won't work. This is where a special 'non-sense' node called the "TextureLoader" comes in.
This is a node that loads the desired textures for us.
If your scope does NOT have this node (it should be the under the ScopeViewParts node), do the following:
Copy it from a scope in the addons folder, for instance "04 - Addons\Meshes\Scopes\AK2047\AK2047OpticLong_1.nif".
Paste it under the "ScopeViewParts" node.
Now, make sure it is the FIRST thing under ScopeViewParts. To do so, select the ScopeViewParts node and look for the "Children" list.
Make sure the reticle node is LAST in this list, and preferably the TextureLoader first. To do so, double click an item in that list and enter the number of the desired node.
For instance, if I have the list:

54 (HuntingScopeGlass:1)
59 (ScopeFade:0)
62 (Glass:0)
65 (ReticleNode)
89 (TextureLoader:0)

I select the first one (54) and enter 89. Next, I select the second one and enter 54. Then I select the third one and enter 59, next 62, last one 65.
The list then looks like this:

89 (TextureLoader:0)
54 (HuntingScopeGlass:1)
59 (ScopeFade:0)
62 (Glass:0)
65 (ReticleNode)

To properly finish this procedure, click the "Spells" menu item at the top > Sanitze > Reorder Blocks
If you now go back to that same list you SHOULD see that the order of the items is still the same but the numbers have changed. TextureLoader should still be at the top.
It should now also have the lowest number of all the items in that list.

Finally, expand the TextureLoader, and select its BSEffectShaderProperty. The AK2047's TextureLoader will have the CSResRetPSO.dds as a source texture.
Further down, as a NormalTexture will be the CSResDotChevron.dds. Copy the textures you picked for your reticle and dot to the source and normal texture of the TextureLoader.

Why go through all this trouble with non existing materials? To allow the reticle customization to work, without requiring a specific material file for each scope, prevent compatibility issues. Because we have specified the material, we can still perform a so called Material Swap, which is how the reticle customization works in-game.

Article information

Added on

Edited on

Written by

henkspamadres

2 comments

  1. Qrsr
    Qrsr
    • premium
    • 137 kudos
    Thanks, especially "-AllowDirectSaves" note helped me a ton ;)
  2. PKxPanz3r
    PKxPanz3r
    • premium
    • 2 kudos
    hey, just so your aware, in this tutorial all your directions are backwards or reversed, like when you say "something is on the left hand side of the page" its actually on the Right and when you say "something is on the Right hand side of the screen" its actually on the left, like in FO4 Edit the drop downs are on the Left not the Right and in Nifskope the Play button is on the Top Right not the Top Left. just figured you should know, also you need to explain that Bethesda Archive Extractor BAE is mandatory open BA2's. hopefully this comment has helped anyone who is confused by this guide like i was at first.