Jump to content

Put a weapon with mod into a container


Zorkaz

Recommended Posts

Here's a thing I never understood.

 

How can I put a weapon with mod attached into a container or even the world?

There's something going on with levelled lists but apart from there I don't have a clue

Link to comment
Share on other sites

I had that problem before ...

Every time I placed a weapon in the world, it would "spawn" with random modifications attatched to it.

I wanted to place a unique weapon in a kind of display case and with things like a longer barrel it wouldn't fit properly inside the display case and it would clip through is ...

It almost made me go insane!

So I just left this problem alone ...

Hopefully somebody knows an answer to this, because like I said, I was wondering the same thing ...

Link to comment
Share on other sites

Hello Zorkaz,

 

This is achieved using Object Templates and instantiation filter keywords (which is used in leveled list as "if_tmp_.....").

 

Open the weapon editor, and click on "Object Template" button which is located next to the weapon name. This is the window that'll pop up :

 

 

 

34555-1585586525-479451331.png

 

 

 

I'm selecting a template "Simple Pistol" in this screen shot. In the Keyword section you see "if_tmp_SimplePistol" - this is the keyword you use in the leveled list to call up the object mods in this particular template (which you see listed in "Object Modifiers" section in the above screenshot.).

 

Would this make sense?

Link to comment
Share on other sites

  • 2 years later...

My apologies for necro-ing this topic. However, I've been trying to create a non-unique weapon (the test weapon that I've been using is a laser pistol that is ordinary except for a scope) and I can not create it.

 

I've performed the following actions:

 

Created a new "LaserGun" weapon (so as to not spoil the normal base one).

Created a Keyword (made certain that I used type "Instantation Filter")

Created a leveled list to include all of the object mods I wanted on that weapon (everything is stock except for the scope).

Attached the keyword to the leveled list.

Attached the keyword to the object template.

Unchecked the "default" checkbox in the object template.

 

And... nothing. I attempt to spawn the weapon inside of the game (player.additem etcetera so forth) and I still get a laser weapon with random mods attached to it.

 

I am once again humbled by my lack of Creation Kit skills. What am I doing wrong? Thank you.

Link to comment
Share on other sites

My apologies for necro-ing this topic. However, I've been trying to create a non-unique weapon (the test weapon that I've been using is a laser pistol that is ordinary except for a scope) and I can not create it.

 

I've performed the following actions:

 

Created a new "LaserGun" weapon (so as to not spoil the normal base one).

Created a Keyword (made certain that I used type "Instantation Filter")

Created a leveled list to include all of the object mods I wanted on that weapon (everything is stock except for the scope).

Attached the keyword to the leveled list.

Attached the keyword to the object template.

Unchecked the "default" checkbox in the object template.

 

And... nothing. I attempt to spawn the weapon inside of the game (player.additem etcetera so forth) and I still get a laser weapon with random mods attached to it.

 

I am once again humbled by my lack of Creation Kit skills. What am I doing wrong? Thank you.

 

To make a custom laser pistol with specific object modifications (OMODs),

 

- Duplicate the vanilla Weapon form "LaserGun", name it "MyMod_LaserGun"

 

- Open MyMod_LaserGun, then click Object Template

 

- In the Object Template window, remove the object templates you don't need. Practically, you can remove anything under "[D] (0-0) Default" (Default object template).

 

- After you remove everything except the Default object template, select the OMODs you want MyMod_LaserGun to have under "Object Modifiers" (e.g., replace "mod-LaserGun_LaserReceiver_Standard" with another receiver OMOD)

Link to comment
Share on other sites

 

To make a custom laser pistol with specific object modifications (OMODs),

 

- Duplicate the vanilla Weapon form "LaserGun", name it "MyMod_LaserGun"

 

- Open MyMod_LaserGun, then click Object Template

 

- In the Object Template window, remove the object templates you don't need. Practically, you can remove anything under "[D] (0-0) Default" (Default object template).

 

- After you remove everything except the Default object template, select the OMODs you want MyMod_LaserGun to have under "Object Modifiers" (e.g., replace "mod-LaserGun_LaserReceiver_Standard" with another receiver OMOD)

 

 

Hi Larannkiar and thanks for the reply.

 

Yes, I eventually figured out what you've described above and I should have replied sooner as such.

 

Of note, though, is an important detail - You need to generate a new instance of the weapon in question; It seemingly doesn't work in modifying a weapon that is already being used by the player. That delayed my understanding of this procedure for a little while.

 

Again, thank you for the reply.

Link to comment
Share on other sites

I know the above instructions are correct but I think I'd personally cheat using Papyrus at runtime, so here's another way if all else fails or if one should need a convenience function, for proper use, debugging or fun. Any feedback welcome. The global flag can of course be removed. Execution time is about 0.4 seconds.

; A FormList or Form Array with full kit, starting with the weapon at index 0, must be provided. The weapon will be persistent.
Bool Function AddModdedWeapon(ObjectReference ContainerToPlaceIn, FormList KitList = None, Form[] KitArray = None) Global
ObjectMod[] Mods = new ObjectMod[0]
Weapon Weap
Int i = 1
If (KitList != None && KitArray == None)
Weap = KitList.GetAt(0) as Weapon
While (i < KitList.GetSize())
Mods.Add(KitList.GetAt(i) as ObjectMod)
i += 1
EndWhile
ElseIf (KitList == None && KitArray != None)
Weap = KitArray[0] as Weapon
While (i < KitArray.Length)
Mods.Add(KitArray as ObjectMod)
i += 1
EndWhile
ElseIf (KitList == None && KitArray == None)
Debug.Trace("A FormList or Form Array with full kit, starting with the weapon at index 0, must be provided")
Return False
Else
Debug.Trace("Function can only accept one FormList or one Form Array")
Return False
EndIf
ObjectReference WeapRef = ContainerToPlaceIn.PlaceAtMe(Weap, 1, true, true, false)
i = 0
While (i < Mods.Length)
WeapRef.AttachMod(Mods)
i += 1
EndWhile
ContainerToPlaceIn.AddItem(WeapRef, 1, true)
WeapRef.Enable()
If (ContainerToPlaceIn.GetItemCount(WeapRef as Form) == 1)
Debug.Trace(WeapRef + " was added to " + ContainerToPlaceIn)
Return True
Else
Debug.Trace("ERROR: " + WeapRef.GetFormID() + " was not added to " + ContainerToPlaceIn)
Return False
EndIf
EndFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

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