Jump to content

[LE] Using Hearthfires Workbenches To Add New Items


Allannaa

Recommended Posts

I'm pretty sure this has been asked and answered before, and I'm pretty sure there is a tutorial out there somewhere but I can't find it anymore. (I've just spent four hours "googling" and searching here... I have no life, apparently!)

 

How the heck do you use the workbenches to create or add your own items to a HF house?

 

I know you can stick something -- let's say a table -- into the cell, place it where you want it, and then make it enable-able (is that a word?) from the primary item you select at the proper workbench.

 

But how the heck do you extrapolate that to, for instance, having the table ITSELF be the primary item you create?

 

If anyone has a tutorial for this, that isn't a video (I can't hear, so vids aren't an option because they make no sense without, well, the instructions lol) or if anyone knows how to do this, I'd love some links or info!

 

I'm *not* looking for a mod to do this for me, I just want help to figure out how to do it myself.

 

Thanks!

Link to comment
Share on other sites

You have a better chance to understand this by watching a 'Video Tutorial' instead of reading a post (you might even learn a few more things).

A few years back i runned across a video that was very well explained, it should still be out there.


Have a happy modding.

Link to comment
Share on other sites

Hey Allannaa, its been a while. Good to see you around again.

 

In my opinion the easiest solution is to not try and do exactly what Hearthfires does. But rather a similar approach.

 

Create a recipe (COBJ record) for use at the desired Hearthfires workbench. I recommend finding a recipe for an existing object at the desired workbench. Duplicate it and change it accordingly.

Have a script on the created object that uses the OnContainerChanged event to see if the new container is the player and the old container is nothing. If that matches, either enable the single desired object or enable an xMarker that in turn enables everything you want to appear. Something like:

 

ScriptName SomeScript Extends ObjectReference
 
ObjectReference Property myEnableMarker Auto
GlobalVariable Property myStatusGV Auto
 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
  If akNewContainer == Game.GetPlayer() && akOldContainer == None
    myEnableMarker.Enable()
    myStatusGV.SetValue(1.0)
  EndIf
EndEvent

 

 

Set the item to be non-playable so that it will not appear in the player's inventory list.

To prevent multiple crafting of the object in question, you can set a global variable to a specific value when the object gets created and use that global variable as a condition on the recipe. Thus once crafted, it cannot be crafted again.

It may be necessary to remove the created object from the player at some point. Hearthfires does remove the created objects at some point, its just hard to follow as there are multiple jumps to different functions on different scripts. I'm just not sure when would be the best time to do this. Possibly a player alias could use the OnPlayerLoadGame event to remove the object from the inventory the next time the game is loaded provided the global variable is at the designated value that indicates the object has been crafted.

TL;DR

Set recipe to create table, table when added to player inventory runs script to enable table in the home. At a later point, remove the table from player inventory.

Link to comment
Share on other sites

IsharaMeradin approach makes the construction lighter and less complicated than from using the Hearthfires system, if you don't mind using a different approach.


In one of the "Possible Player's Home" of the mod i recently released, the player has the option to build an extra 'Bedroom' or a 'Forge' plus some other constructions along side with either one of the previous.


The biggest issue i had with the Hearthfires system was that 98% of the objects i have are all custom made, and making for each of them the 'Corresponding Misc Item' so that they can be display on the Hearthfires menu was i big pain in the a**, plus i was too lazy to do it since from my angle this was just a simple addition to the mod.


So i used a similar approach from what IsharaMeradin suggested.


1) The player after activating the 'Workbench' a 'Menu' will appear asking what to do.

The 'Menu' has 4 options.

a) Build Room

b) Build Forge

c) Add Material List

d) Exit


2) The player adds all the required materials to the 'Workbench's Container' and they are automatically removed, any left over / surplus materials are returned to the player when construction is finish.


3) When construction is finish the player is asked if she/he wants to keep the anvil and the container, if she/he doesn't, then those objects (anvil - container - workbench) will be returned to the player as 'Misc Resources', firewoods and iron ingots.


Here is my mod's script to get an idea how it was done.

* I have added explanations to all properties so that you can see what does what.




Scriptname aXMDbuildRoomForge01 extends ObjectReference
{Script to build either a Room or a Forge}

ObjectReference Property BCM Auto
{The container that holds all the building materials required to fire the construction}

Book Property MaterialList Auto
{The Journal to give to player with the Material List}

MiscObject Property Clay Auto
MiscObject Property DeerPelt Auto
MiscObject Property FireWood Auto
MiscObject Property Hinge Auto
MiscObject Property IronIngot Auto
MiscObject Property LeatherStrips Auto
MiscObject Property LinenWrap Auto
MiscObject Property Nails Auto
MiscObject Property QuarriedStone Auto
MiscObject Property SilverIngot Auto

ObjectReference Property DoorREF01 Auto
{Enables the xMarker handeling Door and Door Frame}

ObjectReference Property ForgeREFenable Auto
{xMarker that handles the ENABLE state of the FORGE items}

ObjectReference Property PortalREFenable Auto
{xMarker that handles the ENABLE state of the PORTAL items}

ObjectReference Property RoomREFenable Auto
{xMarker that handles the ENABLE state of the ROOM items}

ObjectReference Property AnvilREF01 Auto
{xMarker 'optional', that handles the DISABLE/DELETE state of the ANVIL}

ObjectReference Property AnvilREF02 Auto
{xMarker 'optional', that handles the DISABLE/DELETE state of the Anvil Candle}

ObjectReference Property AnvilREF03 Auto
{xMarker 'optional', that handles the DISABLE/DELETE state of the Anvil Light}

ObjectReference Property DraftingTableREF01 Auto
{Handles the DISABLE/DELETE state of the Drafting Table}

ObjectReference Property DraftingTableREF02 Auto
{Handles the DISABLE/DELETE state of the Drafting Table Candle}

ObjectReference Property DraftingTableREF03 Auto
{Handles the DISABLE/DELETE state of the Drafting Table Light}

ImageSpaceModifier property ImageModFX auto
{Image Space Modifier to apply when building Starts and Ends}

Message Property BuildRFMenu Auto
{Show the Building MENU to choose either Room or Forge}

Message Property NoBuildingMaterials auto
{Messsage to show if you don't have the building materials}

Message Property MaterialListGiven auto
{Messsage to show if the Material List has already been given}

Message Property PassedTimeBuildMSG auto
{Message to show to inform about the time Passed when ImageSpace and building of ROOM finish}

Message Property KeepAnvilMENU Auto
{Show the KeepAnvil MENU to choose either Keep or Remove the ANVIL}


Auto State Waiting
Event OnActivate(ObjectReference akActivator)
if (akActivator == Game.GetPlayer())
GoToState("Busy")

Int iButton = BuildRFMenu.Show()
If iButton == 0
If (BCM.GetItemCount(DeerPelt) >= 8) && (BCM.GetItemCount(FireWood) >= 210) && (BCM.GetItemCount(Hinge) >= 18) && (BCM.GetItemCount(IronIngot) >= 12)\
&& (BCM.GetItemCount(LeatherStrips) >= 8) && (BCM.GetItemCount(LinenWrap) >= 60) && (BCM.GetItemCount(Nails) >= 230) && (BCM.GetItemCount(QuarriedStone) >= 30) && (BCM.GetItemCount(SilverIngot) >= 5)
BCM.RemoveItem(DeerPelt, 8, True)
BCM.RemoveItem(FireWood, 210, True)
BCM.RemoveItem(Hinge, 18, True)
BCM.RemoveItem(IronIngot, 12, True)
BCM.RemoveItem(LeatherStrips, 8, True)
BCM.RemoveItem(LinenWrap, 60, True)
BCM.RemoveItem(Nails, 230, True)
BCM.RemoveItem(QuarriedStone, 30, True)
BCM.RemoveItem(SilverIngot, 5, True)
BuildRoom()
Utility.Wait(1.0)
BuildRoomReady(akActivator)
Else
NoBuildingMaterials.Show()
EndIf
EndIf

If iButton == 1
If (BCM.GetItemCount(Clay) >= 30) && (BCM.GetItemCount(DeerPelt) >= 5) && (BCM.GetItemCount(FireWood) >= 130) && (BCM.GetItemCount(Hinge) >= 16)\
&& (BCM.GetItemCount(IronIngot) >= 48) && (BCM.GetItemCount(LeatherStrips) >= 4) && (BCM.GetItemCount(LinenWrap) >= 10) && (BCM.GetItemCount(Nails) >= 110) && (BCM.GetItemCount(QuarriedStone) >= 120)
BCM.RemoveItem(Clay, 30, True)
BCM.RemoveItem(DeerPelt, 5, True)
BCM.RemoveItem(FireWood, 130, True)
BCM.RemoveItem(Hinge, 16, True)
BCM.RemoveItem(IronIngot, 48, True)
BCM.RemoveItem(LeatherStrips, 4, True)
BCM.RemoveItem(LinenWrap, 10, True)
BCM.RemoveItem(Nails, 110, True)
BCM.RemoveItem(QuarriedStone, 120, True)
BuildForge(akActivator)
Else
NoBuildingMaterials.Show()
EndIf
EndIf

If iButton == 2
If (akActivator.GetItemCount(MaterialList) == 0)
akActivator.AddItem(MaterialList, 1)
Else
MaterialListGiven.Show()
EndIf
EndIf

If iButton == 3
; Do Nothing
EndIf
EndIf
GoToState("Waiting")
EndEvent
ENDSTATE


State Busy
Event OnActivate(ObjectReference akActivator)
;Do nothing.
EndEvent
EndState


Function BuildRoom()
ImageModFX.applyCrossFade(2.0)
Utility.Wait(3.0)
PassedTimeBuildMSG.Show()
RoomREFenable.Enable()
DoorREF01.Enable()
PortalREFenable.Enable()
PassedTimeBuildMSG.Show()
Utility.Wait(4.0)
ImageSpaceModifier.RemoveCrossFade(2.0)
EndFunction


Function BuildRoomReady(ObjectReference akActivator)
Int iButton = KeepAnvilMENU.Show()
If iButton == 0
DraftingTableREF02.Disable()
DraftingTableREF03.Disable()
DraftingTableREF01.Disable(True)
akActivator.AddItem(FireWood, 5)
Utility.Wait(0.5)
DraftingTableREF01.Delete()
DraftingTableREF02.Delete()
DraftingTableREF03.Delete()
Self.Disable()
Utility.Wait(0.5)
Self.Delete()

ElseIf iButton == 1
BCM.RemoveAllItems(akTransferTo = akActivator)
Utility.Wait(1.0)
DraftingTableREF02.Disable()
DraftingTableREF03.Disable()
DraftingTableREF01.Disable(True)
BCM.Disable(True)
AnvilREF02.Disable()
AnvilREF03.Disable()
AnvilREF01.Disable(True)
akActivator.AddItem(FireWood, 10)
akActivator.AddItem(IronIngot, 10)
Utility.Wait(0.5)
DraftingTableREF01.Delete()
DraftingTableREF02.Delete()
DraftingTableREF03.Delete()
BCM.Delete()
AnvilREF01.Delete()
AnvilREF02.Delete()
AnvilREF03.Delete()
Self.Disable()
Utility.Wait(0.5)
Self.Delete()
EndIf
EndFunction


Function BuildForge(ObjectReference akActivator)
ImageModFX.applyCrossFade(2.0)
Utility.Wait(3.0)
BCM.RemoveAllItems(akTransferTo = akActivator)
DraftingTableREF01.Disable()
DraftingTableREF02.Disable()
DraftingTableREF03.Disable()
AnvilREF01.Disable()
AnvilREF02.Disable()
AnvilREF03.Disable()
PassedTimeBuildMSG.Show()
ForgeREFenable.Enable()
DoorREF01.Enable()
PortalREFenable.Enable()
PassedTimeBuildMSG.Show()
Utility.Wait(4.0)
BCM.Disable()
ImageSpaceModifier.RemoveCrossFade(2.0)
akActivator.AddItem(FireWood, 20)
akActivator.AddItem(IronIngot, 10)
Utility.Wait(1.5)
BCM.Delete()
DraftingTableREF01.Delete()
DraftingTableREF02.Delete()
DraftingTableREF03.Delete()
AnvilREF01.Delete()
AnvilREF02.Delete()
AnvilREF03.Delete()
Self.Disable()
Utility.Wait(0.5)
Self.Delete()
EndFunction




Feel free to use it or modify it if you want to use this approach.


I hope it helps, and have a happy modding.

Edited by maxarturo
Link to comment
Share on other sites

Thanks, Max, that's good food for thought.

 

And heya Ishara, great to see you!

 

No, I don't mind using a different but similar system to craft stuff -- that's not a problem at all, and it's a good idea!

What I wanted to do (for example) is build the house as usual. But in the Main Floor, I don't want a dining table and chairs, I want oh... say a bar and stools. And one thing I'd like to do is build the whole house, all at once -- Entryway, Main House, North Tower (again, for example). I figured what I'd do would be to duplicate the "main floor" thing from HF, but add the tower to the description -- increase the required items so you still need the total logs, nails, rabbit's feet, or whatever, but be able to construct it all at once. That part actually seems to be fairly easy (tho I haven't made a character and tested it yet.) It was the insides, the furnishings, that's messin' my little head up.

 

But thanks to both of you, I may be able to figure things out! Yay, much appreciated.

Edited by Allannaa
Link to comment
Share on other sites

One craft and it is all there? Hmm... Aside from the table and chairs that you do not want, locate the exact same items that Hearthfires uses as the created objects and put them all into a single formlist. Then you have a custom item that the player crafts. This item will be scripted to add the contents of the previously mentioned formlist to the player. So long as the player has started the Hearthfires quest the Hearthfires system should take over and "build" everything from the formlist. Tho you may want to cycle through the items rather than dump them all at once. Or have smaller lists broken down to the items dedicated to each workstation.

 

Its a thought that might be worth testing at the very least.

Link to comment
Share on other sites

 

@ Allannaa
"And one thing I'd like to do is build the whole house, all at once"
@ IsharaMeradin
"One craft and it is all there?"
This is exactly what this script does.

 

If you are referring to the script you posted earlier, that requires a custom menu system. I think Allannaa just wants to be able to use the workbench at the Hearthfires home site to craft it all in one go rather than running around like a crazy person doing it all piecemeal. Why completely reinvent when one can utilize what is already there for part of the process?

Link to comment
Share on other sites

 

 

@ Allannaa
"And one thing I'd like to do is build the whole house, all at once"
@ IsharaMeradin
"One craft and it is all there?"
This is exactly what this script does.

 

If you are referring to the script you posted earlier, that requires a custom menu system. I think Allannaa just wants to be able to use the workbench at the Hearthfires home site to craft it all in one go rather than running around like a crazy person doing it all piecemeal. Why completely reinvent when one can utilize what is already there for part of the process?

 

 

Aaa... I didn't get that part.
My bad !.
Link to comment
Share on other sites

Actually, kinda both!

 

I'd like to use the HF crafting system to do this:

 

Make the "Small House" blueprint

Build the "Small House"

Now, once you have the "Small House" built --

Back to the drafting table, and instead of just "Main Hall", you now see "Main Hall" and "Alla's Hall" (or whatever, you get the idea)

Back to the carpenter's bench -- you can either build build build the vanilla main hall and turn the "Small House" into the Entryway

OR

You can build "Alla's Hall" which builds the whole thing at once. (One build-click instead of the elventy-one you have to do for the vanilla main hall - but you would still have to do the "Turn house into Entry" separately.)

 

Inside, you can either click click click furniture vanilla style

OR

You can click "Alla's Ground Floor" and furnish the whole downstairs, then click "Alla's Upper Floor" and get all the beds, toy boxes, rusty tankards at once.

 

So, basically --

At the carpenter's bench, One click builds "Main Hall".... or Main Hall with 3 Towers or Main Hall with 3 Porches

 

At the work bench, One click furnished upstairs... or downstairs... or North Tower... or East Wing

 

Does this make sense to either of you? Or am I being overly ambitious and wanting to do the impossible?

Edited by Allannaa
Link to comment
Share on other sites

  • Recently Browsing   0 members

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