I have been meaning to write this for a while now but could never find the right time or inspiration, or my page long notes with ideas and changes I planned for the mod that I wanted to mention here. They exist somewhere in my hard drives, forever buried amidst the chaos of my virtual messiness.

It is often I read questions and inquiries about certain functions of the mod. Compatibility issues, mod interactions and concerns about possible conflicts that stem from a complete lack of understanding of the inner workings of the mod. This is my fault; for immersion purposes I presented the mod in a certain manner and never really explained what was going on beneath the hood, the mod’s inner workings. Even though it is a crucial piece of information that could clarify many of potential concerns and lead users on the correct path when troubleshooting their game. I aim to rectify that here.

How does it all work? How can a gameplay feature that was exclusively designed for the player be modified and adapted to work outside its original scope? How can NPCs possibly craft, improve and enchant armor and weapons? I once wrote that the core idea of mod itself is very simple by nature, I meant that. You see, NPCs don’t craft or enchant anything, the work is all done by you.

The crafting interface and mechanics look familiar because they are the same. Same menus, same sounds, same procedures, same result. You do everything. The mod gives you the perks and the skill and you craft and enchant. It is as simple as that. The mod only creates the illusion that NPCs are doing the work. Of course, this is a bit of an oversimplification, there’s a bit more going on behind the scene. Yet, in a broad sense that is pretty much the gist of it; provide the player with the tools to do the work in a seamless and transparent manner, and restore everything to the way it was after the work is done.

As for what is actually happening behind the scenes, well there’s quite a bit more. I will delve into some of it for those of you interested.

The mod’s scripts start after choosing one of the dialogue options and end after the order is placed. Once the dialogue starts, the NPC -blacksmith or enchanter- is identified and the current player crafting or enchanting skill value is saved and replaced with the NPC’s. As far as NPCs go, only this is taken into account. I often hear of players wanting to give certain items or perks to NPCs, thinking it will allow them to craft or enhance certain equipment. An understandable, but incorrect assumption.

If the NPC Skill Rebalance option is enabled in the MCM, the skill level of the NPC is ignored and a predetermined skill value is used instead. The skill values used by NSR are based on the research done by mxSora, which is available in another article in the mod page.

Once this is done, the current player perks are saved and depending on the service requested, new perks are added to the player according to the previously acquired skill level. It is in this crucial step where many of the incompatibilities come from. The mod maintains a list of all the vanilla crafting and enchanting perks to assign to the player. If mods modify the vanilla perks referenced in this list, everything still works fine, the problems arise when new crafting or enchanting perks are introduced to the game. In this case Honed Metal will add the perks in its internal list to the player, but because of the changes to the smithing or enchanting trees which rely on the new perks introduced, the perks added to the player will be of little to no benefit. Effectively preventing the creation or modification of equipment of certain materials, or reducing the overall effectiveness of produced items and enchantments.

I address this issue in the HM_Mod script, by identifying if a specific mod is installed, and updating Honed Metal’s internal perk list with the appropriate perks from the respective mod. The procedure is very simple and I expect anyone could modify the script and add perks from any mod by simply following the examples already there and looking up the appropriate perk IDs with a tool such as TesEdit . The complexity lies not on the procedure itself but on setting up a development environment capable of compiling the whole script. This is specially true after I added support for Frostfall’s exposure system, which brings the burden of needing to have Frostfall’s SDK sources present to successfully compile the script. In future updates, I plan to move the whole compatibility code to its own separate script, like I did with the message strings; which will make adding support for a new perk overhaul mod a much simpler ordeal.

All these steps are essentially shared among the services. However, similarities end at this point. One of the challenges the mod needs to overcome has to do with identifying the crafted, enchanted or tempered equipment. Giving the players perks and skill points to let them do the work is all fine but we are trying to hide this fact. And erasing any evidence of the process is a big part of that. Naturally, in order to succeed at this we need to take away the newly created items after crafting or enchanting. And sadly, because of the intricacies of the Skyrim scripting engine, this can prove a little difficult. 

In case of crafted items, there is no problem at all. There is a handy event that triggers every time an item is crafted providing you with the ID of the item created. Removing the item using its ID is all that is needed at this point. Assuming, of course, there are no other items with the same ID or you could end up removing the wrong item. Thanks to the peculiarities of the script system this is a very real possibility and in cases like these, the mod has to do some silly hacks to work around the issue, but I digress.

The real issue appears when tempering or enchanting items. There are no events or triggers that let the scripting system know when these actions occur. How can we then identify which items were modified? The only valid alternative we have left is straightforward yet brusque: we need to compare each item before and after the process; if the items changed their stats, they were tempered or enchanted and we need to remove them.

There are two possible alternatives at this point, we could either scan every single weapon and armor in the player’s inventory and save their stats to later reevaluate each one and see if the stats changed, or we could offer the player a box in which to put the weapons they wish to modify, save their stats and then scan them for changes. Of course option two sounds more appealing, if nothing else from purely a performance point of view. But on the other hand going this route entails removing the rest of armor and weapons the player didn’t place in the box, as nothing prevents them from tempering, enchanting those without the mod ever knowing.

When taking this into account, the former option seems more appealing; but nothing is simple in Skyrim when you are stepping outside the scope of the modding capabilities the developers envisioned for the game. Eliciting the stats of weapons or armor -like temper or enchantment status- when inside an inventory or container is nigh impossible; this is not only a script limitation but an engine one as well. In fact, there is no way to get around it, the items in question must be taken out of the inventory AND equipped by a game entity allowed to equip items -be it player or NPC- in order to get the desired information out of them. And this was not even a possibility until PurpleLaunchBox created the required functions in SKSE. We have him to thank for this hack-ish yet workable solution.

If obtaining the statistics of all weapons and armor in the player’s inventory requires extracting them and equipping them on something before bringing them back, the path is suddenly clear, and it becomes easy to see option two as the obvious solution. Instead of scanning every armor and weapon we only evaluate the items given to the craftsmen, while we temporarily store the rest of the player’s equipment in a box to be safely retrieved after the order is placed. That is the method the mod currently uses. Yes, all the items you give to a blacksmith or enchanter get twice equipped on a chicken living in a hidden dark cell, occupied by a floating forge, a couple of chests and a retarded, naked Eorlund Graymane.

Once all this is done, depending on the MCM options, the mod scans for materials the containers of the NPC, obtaining types and quantities and adding them to the player, along with a predefined amount of base materials that represent the materials to be procured. These together with the materials the player already has, will be used for crafting and enchanting. After the process we will calculate the difference in materials and obtain the quantities used by the player, the craftsman, and how many where borrowed from the material pool. The price and completion time of the order will be modified depending on these numbers.

Before the materials end up in the player’s inventory, its capacity is temporarily increased to avoid over-encumbrance and the adverse effects it brings, then a specific crafting station is activated depending on the service requested. These stations are just like the ones you use in the world but have their animation flag disabled so that the regular crafting or enchanting animation is not triggered when activating them. 

If the player is unable to craft or enchant items at the moment, either because they just entered combat or any other engine specific reason, the mod will detect the station activation failure and revert all changes done so far, displaying an error message on the screen in the process, indicating what just happened. 

If all goes well the stations are activated and the player can go on with the crafting or enchanting process after which the whole stat scanning repeats and the modified items are identified, removed and placed on storage for future delivery. The mod creates a map associating the items and other values with this particular NPC and the player is restored to their previous state before initiating the process. That includes removing all the extra perks, restoring their original skill value, carry weight and returning all removed items including re-equipping armor and weapons.

Now you know why the hotkyes on your weapons are lost after a tempering session, why you hear that equipping-unequipped sound, why there were naked commentaries in the early versions of the mod and you might deduce why you are forced into first person when requesting services. You may also be able to realize why the mod can’t possibly conflict with other mods and why load order does not matter.

This is a not so brief synopsis of some of the mechanics of the mod; there are many more details I’m leaving out for the sake of simplicity, and because I can’t recall them from memory. There are other interesting tasks the mod does like keeping track of each order, their content, the price of each item, the time they’re supposed to be done, the courier letters, etc. All this for each concurrent order with each blacksmith and enchanter. But, I feel I’ve gone into enough depth for now. Besides, these are more straightforward taks; much less “inventive” and implemented in a way not to consume resources. e.g none of the scripts in the mod poll, or run in the background, they are triggered on demand when you request services and stop after.

if you’ve read this far, I hope I’ve helped you understand a little better what exactly is occurring internally when you request crafting or enchanting services. Modding often entails steeping outside of the vision developers had when releasing the modification tools for the game, and some times the solutions aren’t always pretty. This is the case here, but the end result is not terrible from a user experience point of view. And from the technical side, even though a hack is necessary to achieve success, it is done in a manner that doesn’t affect performance; which along with simplicity and clarity are my main concerns when it comes to code. I have to settle on one out of three *for now*

And I emphasize, for now, with good reason, as I plan to design a proper solution for the mod in the future. Yes, in fact, I’ve recently embarked on a literal journey across the country to pursue my passion for programming; it brings the unfortunate downside of keeping me from modding -for a considerable time most likely; but the experience I acquire will be invaluable and will allow me to implement a SKSE module to solve the main technical problem in the mod. At once eliminating all the redundancy and absurd hacks in order to create a simple, straightforward approach that will be appealing not only from a technical angle, but permeate into the end user world by eliminating quirks and allowing for further polishing and the addition of new features and functionality.

Until then, I bid you farewell.

Article information

Added on

Edited on

Written by

skyliner390

3 comments

  1. klydeking
    klydeking
    • premium
    • 9 kudos
    Very impressive. As someone who started out just downloading mods, and has spent, and MORE time "peeking under the veil" of how they work, altering them in XEdit and the CK, this just blows me away. Scripts are still voodoo to me. Thanks for reveling more of how things work.
  2. aradjha
    aradjha
    • member
    • 4 kudos
    No joke this is one amazing mod. I cannot thank you enough.

    Also, you're quite a good writer.
  3. dylanbperry
    dylanbperry
    • premium
    • 51 kudos
    Thank you for your work skyliner, and for elucidating the inner workings of Honed Metal. We are extremely grateful for your efforts, and I wish you the best of luck on your personal journey.