Jump to content

[LE] Need script help with unequipping items


Recommended Posts

I'm very much a newb when it comes to scripts and as one of my first ventures into the field, I'm trying to edit the scripts that come with this mod (https://www.nexusmods.com/skyrim/mods/28515)

 

In the original mod, NPCs enter the pool or bath and unequip all items. I'm trying to edit the script so that they only unequip certain slots (e.g. 32 (body), 37 (feet)).

 

The mod only has three scripts:

 

1. uni_enabler

 

 

 

Scriptname UNI_enabler extends ObjectReference
;* Marker Enable/Disable * By: NexusComa * ; nexusmods.com
ObjectReference Property Marker Auto
;
Event OnInit()
If(Marker.IsDisabled())
GoToState("Disable")
Else
GoToState("Enable")
EndIf
EndEvent
;-----------------------
State Disable
Event OnBeginState()
Marker.Disable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
If(Marker.IsDisabled())
GoToState("Enable")
Else
GoToState("Disable")
EndIf
EndEvent
EndState
;-----------------------
State Enable
Event OnBeginState()
Marker.Enable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
If(Marker.IsDisabled())
GoToState("Enable")
Else
GoToState("Disable")
EndIf
EndEvent
EndState
;

2. uni_poolunequip

Scriptname UNI_PoolUnequip extends ObjectReference
Event OnTriggerEnter(ObjectReference akActionRef)
if(akActionRef != Game.GetPlayer())
actor who = akActionRef as actor
who.unequipall()
endif
EndEvent

3. un_reequipall

 

 

Scriptname UNI_ReEquipAll extends ObjectReference
Armor property DummyRing auto
Event OnTriggerEnter(ObjectReference akActionRef)
if(akActionRef != Game.GetPlayer())
actor who = akActionRef as actor
who.AddItem(DummyRing, abSilent = true)
who.EquipItem(DummyRing, abSilent = true)
who.UnEquipItem(DummyRing, abSilent = true)
who.RemoveItem(DummyRing, abSilent = true)
endif
EndEvent

My logic was that if I edited uni_poolunequip, that should achieve my desired result and the trigger of entering and exiting the pool, and requipping all items upon exiting the pool shouldn't change. My thought was to replace the "who.unequipall()" with commands like "who.UnequipItemSlot(32)", but that simply hasn't worked.
Can anyone advise what I'm doing wrong and suggest how I can achieve my desired outcome?
Link to comment
Share on other sites

according to CK`s page you should be able to use this function to unequip the item from specific slot

Function UnequipItemSlot(int aiSlot) native

 

Try the Slot Mask to see if its working

 

I tried replacing the who.unequipall() with who.UnequipItemSlot(32) and then who.UnequipItemSlot(0x00000004) but neither worked and the NPC's still continue to unequip everything.

 

Dull question - the mod in question uses a bsa file, but when using the edited scripts, I've left them in the loose folders. The loose folders take precedence over the bsa file, right?

Link to comment
Share on other sites

If the NPC is still unequipping everything, it means the UnEquipAll function is still being used. Did you compile the script? Loose files should take precedence over BSA but to be sure you can unpack the BSA and then delete it. UnequipItemSlot(32) does unequip your body armor clothes. I was curious so I tested it out on the player and it worked.

Link to comment
Share on other sites

  • 2 weeks later...

 

according to CK`s page you should be able to use this function to unequip the item from specific slot

Function UnequipItemSlot(int aiSlot) native

 

Try the Slot Mask to see if its working

 

I tried replacing the who.unequipall() with who.UnequipItemSlot(32) and then who.UnequipItemSlot(0x00000004) but neither worked and the NPC's still continue to unequip everything.

 

Dull question - the mod in question uses a bsa file, but when using the edited scripts, I've left them in the loose folders. The loose folders take precedence over the bsa file, right?

 

 

 

If the NPC is still unequipping everything, it means the UnEquipAll function is still being used. Did you compile the script? Loose files should take precedence over BSA but to be sure you can unpack the BSA and then delete it. UnequipItemSlot(32) does unequip your body armor clothes. I was curious so I tested it out on the player and it worked.

 

I'm such an idiot. I had edited the scripts correctly, but hadn't realised they weren't being activated properly because of a load order issue in MO2. *sigh*

 

One additional question - if I want the NPC to unequip their weapon, what slot number do I use? Or is a different command required?

Edited by TJHammersmith
Link to comment
Share on other sites

 

One additional question - if I want the NPC to unequip their weapon, what slot number do I use? Or is a different command required?

 

Does not require SKSE

 

Weapon NPCRightWeapon = NPC.GetEquippedWeapon()
Weapon NPCLeftWeapon = NPC.GetEquippedWeapon(true)
If NPCRightWeapon ; we got a valid object
  NPC.UnequipItem(NPCRightWeapon)
EndIf
IF NPCLeftWeapon ; we got a valid object
  NPC.UnequipItem(NPCLeftWeapon)
EndIf

These may be useful reading:

GetEquippedWeapon

GetEquippedShield

GetEquippedSpell

Link to comment
Share on other sites

Sorry for my intervencion TJHammersmith with my issue.


About a year ago i made a simple unequip - equip items script for one of my pools, mainly cause players like this kind of stuff....


But i came across a weird issue, i did only two tests with an 'Overpowered' character i had back then.


The issue:

- The 'Overpowered' character had gear, mainly weapons / swords (i can't remember if this issue also happened with the armors), with enchantments way over what the vanilla game can produce, if i remember correctly the swords had like over 550+ points of enchantment damage, each enchantment.


After the gear was removed and then added back and force equip, the enchantments instead of 550+ points had 76 points of damage !!??.


I only did two tests and since i'm not really interested in this kind of stuff, i just said F*** IT !!!, i didn't bother myself to look for the cause or for a solution, as a matter of fact i deleted everything right away.


Now i'm thinking to add this feature again to that particular pool, since players like a lot this kind of stuff, but this time i'll add an option to let the player decide if she/he wants to run this feature.


If anyone has an idea what might be causing something like this, or where to start looking it would save me some precious time.


I don't know if this is relevant, but the set up went like this:

Unequip 'Equpped gear' and equipped them in a mannequin > the rest of the player's stuff were transferred into a container > then unequip the gear from the mannequin and force equip on the player > then transfer the rest of the stuff from the container to the player's inventory.


Thanks a lot for reading this, and again sorry TJHammersmith.


Merry christmas.

Edited by maxarturo
Link to comment
Share on other sites

@Maxarturo

It is a known "bug" that the game does not apply player assigned enchantments when gear is equipped via script. This is why SKSE has the EquipItemEX function. It allows picking out a specific instance from a stack and equipping it.

 

The following may resolve the issue completely, however:

Equip Enchantment Fix (SSE version)

Equip Enchantment Fix (LE version)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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