Adventures In Modding

As I am wont to do, I relieve stress with gaming.

The current fixation is a revisitation with Skyrim.

Found myself raiding and looting some old Dwarven ruins for metal with which to level my smithing skill. Unfortunately, the stuff is very heavy and I need a lot of it. Putting it in piles to come back to later would be wonderful

I am the Dragonborn. I can bend space and time, wield the elements and rend opponents to grape jelly with the power of my voice alone. However, the simple mechanics of a sack elude me. Bethesda calls this a “gameplay mechanic”. I call it bullshit.

So, I go to look for a mod.

Most were just not right for me. Spells to conjure a dimensional storage chest (hokey). Craftable items that are linked to one central, hidden chest (Think Cloud Storage).

I just wanted a damned sack.

So, I made one.

  • Go into the creation kit.
  • Duplicate a large sack container.
  • Toggle it to not respawn, thus replace stuff I put into it with random leveled items.
  • Named it “Placed Sack”

All well and good but this is a static item that cannot be picked up and put into your inventory. It has to be placed either by code or in the creation kit.

  • Go back into creation kit
  • Duplicate a random item I can pick up (Gold Ore in this case)
  • Named it “Empty Sack”. It would be the item I carry in my inventory.
  • Made a recipe so it could be crafted with (2) Linen Wrap and (1) Leather Strip at any tanning rack.
  • Used an external tool to replace the mesh and texture with that of a large sack so it looked like a sack and not a lump of gold ore in the inventory screen

Now all the remained was tying those things together.

Attached the following script to the “Empty Sack” object.

Scriptname EmptySack extends ObjectReference  

Container Property PlacedSack Auto
Actor Property PlayerRef Auto

Event OnContainerChanged(ObjectReference NewContainer, ObjectReference OldContainer)
	If NewContainer == None
		ObjectReference SackRef = PlayerRef.PlaceAtMe(PlacedSack, 1, true, false)
		PlaceInFrontOfPlayer(SackRef, 80,0,0)
		Debug.Notification("Placed a sack on the ground")
		Delete()
	EndIf
EndEvent

Function PlaceInFrontOfPlayer(ObjectReference targetItem,float distanceOffset, float heightOffset,  float angleOffset)
	float playerAngleZ = PlayerRef.GetAngleZ()
	float angZ = playerAngleZ + angleOffset
	float posX = PlayerRef.GetPositionX() + distanceOffset * Math.Sin(playerAngleZ)
	float posY = PlayerRef.GetPositionY() + distanceOffset * Math.Cos(playerAngleZ)
	float posZ = PlayerRef.GetPositionZ() + heightOffset
	targetItem.TranslateTo(posX, posY, posZ, 0.0, 0.0, angZ, 99999)
EndFunction

In plain english, If this item is taken out of inventory and dropped on the ground, it spawns the “Placed Sack” container I previously mentioned then deletes itself.

This is wonderful! A sack! On the ground! In front of me! I can put things in it and take them out again. If I go to another area and wait 31 in-game days then come back, it is still there with my stuff!

Now, I need to figure out how to pick the damned thing up when I am done with it.

Attached the following script to the “Placed Sack” object.

Scriptname PlacedSack extends ObjectReference  

MiscObject Property EmptySack auto 
Actor Property PlayerRef auto

Event OnActivate(ObjectReference akActionRef)
	If PlayerRef.IsSneaking()
		PickUpSack()
	EndIf
endEvent

Function PickUpSack()
	Debug.Notification("Picked up sack")
	RemoveAllItems(PlayerRef, false, false)
	PlayerRef.AddItem(EmptySack)
      Delete()
EndFunction

In plain english, if the sack is “opened” while I am in sneak mode (crouching), it will empty anything it still contains into my personal inventory, give me a new “Empty Sack” object, then delete itself.

I have managed to replicate one of mankind's simplest inventions in Skyrim.

Keeps me off the streets.