Jump to content

Place my items all over commonwealth


Recommended Posts

I have a few items (chems) I have created. I have already put them in leveled list to make them appear as loot in containers. It works. I also want to physically place items in the world without having to go and edit each cell. Is there an easy way (script) ?

Link to comment
Share on other sites

Not EZ but if you fire up a finder quest with a RefCollectionAlias conditional fill on known persistent objects or containers you can get ~ 200 to script placing in or at. Examples:

ObjectType Container & LocRefType BOSSChest = 200 boss chests 

ObjectType Container & Haskeyword WorkshopKeyword = 30 workshops

ObjectType Container & Haskeyword WorkbenchGeneral = 90 assorted workbenches.

The difficulty is knowing what placed object types or classes are persistent and their conditional attributes to query.

Since most base game placed objects are non persistent, they are not findable without being in the loaded uGrids around the player. 

Link to comment
Share on other sites

It depends on what you mean. Are you trying to place the object as a physical item in the world without using the creation kit's cell view to place them? Or are you trying to avoid making edits in cells to avoid adding cell records to your mod? The first is much more difficult because the game doesn't really have any established systems for that sort of thing. The closest I can think of offhand is that certain random encounter types (camp encounters and assault encounters, specifically) have markers intended for placing notes and other small objects.

If you mean the latter and want to avoid having cell records in your mod, it's doable but it's also a hassle. You have to start by actually placing the items where you want them to be, so that you can get their coordinates and angle. I recommend doing this in a second mod that uses your main mod as a master, so you don't need to clean up afterward. Once you have that, you need to find a persistent reference from the same cell (for interiors) or the same worldspace (for exteriors) and then use a specific combination of papyrus functions to spawn the item, move it, and then angle it as desired:

  1. ObjectReference.PlaceAtMe(Form akFormToPlace, int aiCount, bool abForcePersist, bool abInitiallyDisabled, bool abDeleteWhenAble)
  2. ObjectReference.SetPosition(float afX, float afY, float afZ)
  3. ObjectReference.SetAngle(float afXAngle, float afYAngle, float afZAngle)
Link to comment
Share on other sites

You could attach a script to the base object of vanilla chems of your choice, so that it drops one of your chems right next to it.

Scriptname MyChemSpawn extends ObjectReference

FormList Property MyChemList Auto Mandatory

int chancePerCent = 20
bool doOnce = False

; Do this once the parent cell loads, so you make sure it is attached to a cell, not thrown from the inventory
Event OnCellLoad()
	; Make sure to take the chance only once
	If(!doOnce)
		int chanceRoll = utility.RandomInt(0, 100)
		; Randomly select a number between 0 and 100, 
		; if this number is under chancePerCent it will spawn some random chem from the list.
		if(chanceRoll < chancePerCent)
			int lastIndex = MyChemList.GetSize() - 1
			int randomIndex = utility.RandomInt(0, lastIndex) ; Select a ramdom index from the list
			Potion randomChem = MyChemList.GetAt(randomIndex) As Potion
			PlaceAtMe(randomChem)
		endIf
		doOnce = True
	endIf
EndEvent

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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