Jump to content

[Scripting] GetEquippedObject when the equipped object is a modified weapon.


Nephelus

Recommended Posts

So, I've got this simple script on a container where activating the container takes the players currently equipped weapon and places it in the container.

 

Problem is, if the weapon is modified, the weapon that gets placed in the container is the unmodified version of the weapon. For example, I tried it on a Hunting Rifle that had a scope and extended clip. The weapon that ended up in the container was just the base rifle with no mods. I've tried this on multiple different weapons and get the same result. What am I missing?

 

Here's my script as it stands.

scn GetWeaponSCRIPT

ref playerWpn

Begin OnActivate

	; Get the weapon currently equipped by the player
	set playerWpn to Player.getEquippedObject 5

	; If player is unarmed, inform player that he must be armed
	if playerWpn == 0
		ShowMessage UnarmedMsg

	; Otherwise, take the weapon from the player and add it to the container
	else
		AddItem playerWpn 1
	endif
End
Link to comment
Share on other sites

GetEquippedObject returns BaseObject of that weapon.

So when you add that item you add a simple copy of that weapon without attachments

 

 

You need to use some other commans (Removeitem or something else, look through GECK wiki)

Link to comment
Share on other sites

Weapons with and without mods are the same base form, just have different models and adjusted stats.

 

AddItem creates an entirely new copy of whatever item you add, just as RemoveItem destroys whatever item you remove. You need a function that transfers items from one container to another while preserving the item itself.

 

RemoveAllITypedtems can do that and allows you to specify an exemption list with items that won't get transferred.

 

The best option though is RemoveItemTarget, a function added by the JIP NVSE Plugin. It works the same as RemoveItem, except doesn't destroy the item and transfers it to the container you specify instead.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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