Jump to content

[LE] New to scripting - Need a short Equip Slot 49 Script


Recommended Posts

Hi everyone! Still learning scripting and doing poorly. I'll try to make this short and to the point by describing my issue.

 

First off, I'm using Cubic Hairs Renewal for CBBE and UUNP for SSE - https://www.nexusmods.com/skyrimspecialedition/mods/18650 which uses slot 49 (primary pelvis slot)

Second, I have a number of player homes I've downloaded that share one thing in common that I love and that's the Undress script that runs on entering a pool area. Awesome!

Third, this creates an issue for my followers as they are all robbed as these scripts remove their bush darn it ( :ohmy: ), lol.

 

Now I've finally created my own custom race and custom followers using that race and I'm in the middle of creating their home place with a pool and I'm using another persons Undress script which is working fine, but back to the issue of my ladies being robbed! :/

 

Is there a way for me to create a small script to run after these Undress scripts to simply re-add slot 49 which still sits in their inventory? I'd really love it if these Undress scripts didn't include Slot 49 but unfortunately I think they all use the UnequipAll function and I'm afraid to alter or mess with their working scripts. Knowing my luck I'd render them useless.

 

Any help ideas or thoughts on the matter would be greatly appreciated, thanks and Cheers!

Link to comment
Share on other sites

To only unequip certain things, you can use UnEquipItemSlot: https://www.creationkit.com/index.php?title=Biped_Object

 

Or if you want to use skse you can use GetWornForm. How I would do it, is to add an ability to the npc when you get in the pool, with a trigger box. Remove the ability when they leave the pool with OnTriggerLeave. Then in your ability, put a script like this on the magic effect:

 

Scriptname PoolUndressScript extends ActiveMagicEffect 

Form Head 
Form Body

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    Undress(akTarget)
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster) 
    Dress(akTarget)
EndEvent

Function Undress(Actor akActor) 
    Head = akActor.GetWornForm(0x00000001)
    Body = akActor.GetWornForm(0x00000004)
    
    akActor.UnEquipItem(Head) 
    akActor.UnEquipItem(Body)
EndFunction
    
Function Dress(Actor akActor)
    akActor.EquipItem(Head)
    akActor.EquipItem(Body)
EndFunction

You can add more slots to unequip if you want. They're listed here: https://www.creationkit.com/index.php?title=Slot_Masks_-_Armor

Link to comment
Share on other sites

If you want to do it without SKSE you can do something like this on the ability script.

 

Scriptname PoolUndressScript extends ActiveMagicEffect 

Form[] EquippedItems 

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    EquippedItems = New Form[128]
    Undress(akTarget)
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster) 
    Dress(akTarget)
EndEvent

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) 
    Int EmptySlot = EquippedItems.Find(None) 
    EquippedItems[EmptySlot] = akBaseObject 
EndEvent

Function Undress(Actor akActor) 
    akActor.UnEquipItemSlot(30) ;Head
    akActor.UnEquipItemSlot(32) ;Body
EndFunction
    
Function Dress(Actor akActor)
    Int M = EquippedItems.Find(None) 
    While M > 0
        M -= 1
        akActor.EquipItem(EquippedItems[M])
    EndWhile
EndFunction

Edit. Here's the list of biped objects you can use: https://www.creationkit.com/index.php?title=Biped_Object

Edited by dylbill
Link to comment
Share on other sites

Appreciate the feedback Dylbill. But I'm really trying to focus on "re-equipping" Slot 49 (which is removed by other author's Undress scripts that use the UnequipAll function) I suspect. I'm looking for something I can add after their script has run. Otherwise I'd be looking at re-writing or editing all of those individual scripts. I'm hoping I can make a small script to simply add to the same trigger box they use to re-equip slot 49 instead.

 

Honestly, I don't know enough about scripting to write my own from scratch and have resorted to piece-parting others together in the past with some luck. If I could write my own script I would think it makes sense to go ahead and use the UnequipAll function first to remove everything as desired then have a portion of the script at the end re-equip slot 49 if it was unequipped to begin with?

Link to comment
Share on other sites

If you just want to prevent unequip of the slot 49 you can add an ability with a script like this to your npc:

 

Form Slot49Form
Actor Target

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    Target = akTarget
    Slot49Form = akTarget.GetWornForm(0x00080000)
EndEvent 

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) 
    If akBaseObject == Slot49Form 
        Target.EquipItem(Slot49Form)
    Endif 
EndEvent

That way you don't have to edit the triggerbox script at all. Note, that does require skse

Edited by dylbill
Link to comment
Share on other sites

Ok, I like that idea a lot. Now how do I add it to my NPCs ?

 

edit: Ok the only thing I can find while editing an NPC actor is the Traits tab which has a block for adding Papyrus Scripts, so I'm thinking this has to be it. Correct me if I'm wrong. Tried adding your script but it wont compile. Also, CK threw in "extends ObjectReference" to the name if that matters? Took that out and tried again, samething notta.

 

This was the compiler output:

Starting 1 compile threads for 1 files...
Compiling "Slot49Form"...
C:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Slot49Form.psc(2,5): cannot name a variable or property the same as a known type or script
C:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Slot49Form.psc(7,26): GetWornForm is not a function or does not exist
C:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Slot49Form.psc(11,23): Slot49Form is not a variable
C:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Slot49Form.psc(11,20): cannot compare a form to a slot49form (cast missing or types unrelated)
C:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Slot49Form.psc(12,25): Slot49Form is not a variable
C:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Slot49Form.psc(12,15): type mismatch on parameter 1 (did you forget a cast?)
No output generated for Slot49Form, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on Slot49Form
Link to comment
Share on other sites

Ah, if you're going to put the script directly on the actor, it should extend actor, and it would look something like this:

 

Scriptname TM_PreventSlot49UnEquip extends Actor 

Form My49Form

Event OnInit()
    Utility.Wait(1)
    My49Form = GetWornForm(0x00080000)
EndEvent

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) 
    If akBaseObject == My49Form 
        EquipItem(My49Form)
    Endif 
EndEvent 

If you're getting the GetWornForm is not a function or does not exist error, it means SKSE isn't installed. Make sure the source .psc files from SKSE are in Data/Scripts/Source for Skyrim LE or Data/Source/Scripts for SSE.

Edited by dylbill
Link to comment
Share on other sites

  • Recently Browsing   0 members

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