Jump to content

Scripted insert of weapon into cell


Recommended Posts

I am looking for an example of placing an item (weapon in this case) in a cell on the first run of a mod using scripting.

 

Inserting it in to the plugin cell or worldspace works but then there are potential conflicts if a master or compact master has updated the cell definition.

 

Example: I want to place the weapon in the Sanctuary Root Cellar but I have a master that makes the Root Cellar buildable hence changing the record. The weapon mod would then change it back to the original cell record unless I copied the record from the master plugin making the master a requirement for the unrelated weapon mod.

 

Thanks,

Mason

 

P.S. I have spent 2 days looking for any hints about this and have come up dry. I apologize if this has been answered and I have missed it.

 

Link to comment
Share on other sites

If there is a common base game object that is in the worldspace regardless of the mod state you can use that ObjectReference as the anchor to place at (or place in if its a container).

 

Simple script example based on the Yellow wood explosives box in the base game root cellar that would be attacjhed to a start game enabled quest:

Weapon Property pMyWeaponName Auto Const Mandatory
ObjectReference Property pLoot_Prewar_WoodCrate Auto Const Mandatory; Link to SanctuaryBasementJahani 000a327c

Event OnInit()
   ObjectReference ThisWeapon = pLoot_Prewar_WoodCrate.PlaceAtMe(pMyWeaponName, aiCount = 1, abForcePersist = true, abInitiallyDisabled = false, abDeleteWhenAble = false ) ;place next to box, OR
   pLoot_Prewar_WoodCrate.AddItem(pMyWeaponName, aiCount = 1, absilent = true) ; place in the box
EndEvent

Or you could do this with a quest and zero script. Create new quest, Give it a name unique to you + this mod, make start game enabled ...

Add a Quest Alias - Location Alias = ThisLocation Specific Location = SanctuaryRootCellarLocation

add a Quest alias - Reference Alias = ThisContainer

Find matching reference = match conditions GetInCurrentLocationAlias ThisLocation

GetIsId = Container Loot_Prewar_WoodCrate

Alias Inventory = MyWeapon

 

Ideally the container alias would have a script to shutdown the quest when the weapon is taken from the box, but I'm out of energy.

Link to comment
Share on other sites

Forgot to say the script example shows two options placeat the box and placein the box. Placeat never lands well without some fine xyz position adjustment so placein is preferred.

Link to comment
Share on other sites

LOL! I was wondering about that. Had already been looking at the methods for moving things (and rotating if necessary). I should be able to look at the coordinates for the manually placed version to know where to move it.

 

I may try to make an FO4Edit script to generate the papyrus script based on 2 selected items when I get it all working.

Link to comment
Share on other sites

  • 2 weeks later...

I finally got it to work. It took a lot of playing with and experimenting. I finally got to the point that it said it was working but could not find the weapon. I went into the console and started deleting thing to see if it was hidden. After I deleted all of the objects I started deleting dirt and just before I started falling to forever there was the gun. I added code to move and rotate and it worked.

 

Thanks for all of your help!

Link to comment
Share on other sites

When you link the crate object to the quest. The crate becomes persistent. Which is bad, because this means its written into the save file. If you do that with a lot of objects, you bloat the save file with unnecessary data.

If we now let the quest finish after doing its job, the persistent flag should be cleared? And the data is removed from the save file? Is this correct?

 

How can you align an item with placeatme? Probably not? There are no xyz cords as it seems.

 

I'm looking into creating a new mod and for best practices for adding items into the existing world, like notes etc.

For example, placing a note onto a desk with a script. Table.placeatme(Note01) will probably make it spawn under the table in the middle.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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