Jump to content

[LE] GetEquippedArmorInSlot


TyburnKetch

Recommended Posts

 

Scriptname THBathDressScript extends ObjectReference

Actor Property PlayerRef Auto
ObjectReference Property Wardrobe Auto
Armor Armor1

Event OnTriggerEnter(ObjectReference akActionRef)

Int aiSlot = 30
Armor1 = Game.GetPlayer().GetEquippedArmorInSlot(30) as Armor
If Armor1
Wardrobe.AddItem(Armor1)
EndIf
EndEvent

Event OnTriggerLeave(ObjectReference akActionRef)
PlayerRef.UnEquipAll()
EndEvent



I can literally find nothing on this SE exclusive. I am using SE. Sorry if this is the wrong place to post this.

What am i missing?

Very new to scripting and have got this to compile ... but nothing is happening. It's basically butchered together using info from skse GetWornForm - as it is the closest I have to work with.

I know I am missing something obvious ... or maybe it just can not happen without skse. I am unsure of how to use (or how it works) int aislot, and how to make getequippedarmorinslot function properly.

As you can see I want to move equpped items to a wardrobe on trigger enter.

The event on trigger leave is there as a test. I am also just looking for Head(30) at the moment as a test.

Thanks for any help.

 

 

UPDATE*

 

Helmets(30) Are an issue! Having tested with (32) body I can grab the equipped item using GetequippedArmorInSlot. Worked out what Int aislot is (lol), and changed it around so that the item is removed from player rather than being added to wardrobe - and it works.

 

Need to test more but it seems that slot 30 is a problem. Maybe more are. I need to test. But I can grab and move the equipped body armor (32) ... like so:

 

 

Scriptname THBathDressScript extends ObjectReference

Actor Property PlayerRef Auto
ObjectReference Property Wardrobe Auto
Armor Body

Event OnTriggerEnter(ObjectReference akActionRef)

Body = Game.GetPlayer().GetEquippedArmorInSlot(32) as Armor
Game.GetPlayer().GetEquippedArmorInSlot(32)
PlayerRef.RemoveItem(Body,1,True,Wardrobe)

EndEvent

 

 

It is literally the first script that works. Will be tidying it up and adding/testing other body slots.

Edited by TyburnKetch
Link to comment
Share on other sites

Armor GetEquippedArmorInSlot(Int aiSlot)
; Obtain the armor currently equipped in the specified slot.

probably this is what you are looking for: https://www.creationkit.com/index.php?title=Slot_Masks_-_Armor

 

You should have a bit knowledge of mathematics.

Hexadeciamal Decimal

( HEX ) ( DEC )

0Ah 10

10h 16

 

1Eh 30

20h 32

100h 256

 

THBathDressScript

 

Scriptname THBathDressScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/7223611-getequippedarmorinslot/

  ObjectReference PROPERTY Wardrobe auto            ; the target container you like to remove to
  Armor Body

; -- EVENT --

EVENT OnTriggerEnter(ObjectReference akActionRef)
IF (akActionRef as Actor)
ELSE
    RETURN    ; - STOP -    triggered by object, not by an actor
ENDIF
;---------------------
    myF_Action(akActionRef as Actor)
ENDEVENT


; -- FUNCTION --

;------------------------------
FUNCTION myF_Action(Actor aRef)
;------------------------------
IF (aRef == Game.GetPlayer())
ELSE
    RETURN    ; - STOP -    not triggered by the player
ENDIF
;---------------------
    int i = 32
    armor AR = aRef.GetEquippedArmorInSlot(i)        ; native function, (Special Edition exclusive)

; see link slot_masks above, but keep in mind it is SKSE specific
;;;    int Property kSlotMask35 = 0x00000020 = 32 AutoReadOnly ; Amulet

IF ( AR )
    Debug.Notification("Armor removed..")
    aRef.RemoveItem(AR as Form, 1, TRUE, Wardrobe)    ; moving "AR" from player inventory (after unequip) to wardrobe inventory
ELSE
    Debug.Notification("Armor not found in slot " +i)
ENDIF
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Slotmasks and slots are different things. Slotmasks are an SKSE convenience property added to allow you to do binary math to easily work out all the slots a given piece of armour uses. The SE function Tyburn is using will be looking for slots proper, since that's what non-SKSE stuff uses.

 

There is a distinction, Tyburn, between your original script and your modified one, other than the change in slot: In your original you just call an AddItem; in the second, you call a RemoveItem on the player. The original script will only add a copy of what was on the player's head to the wardrobe, not remove it from them.

 

When you say 'nothing happens', what precisely do you mean? Did you test that the trigger fires via a notification? Did you check the wardrobe to see if the item was added? Did you see if the If Armor1 branch fires with a notification?

 

(also, be aware, your script will clone the player's gear whenever *anything* enters the trigger volume, as you have no check for what akActionRef is. The usual triggerbox settings will mean this fires whenever any NPC wanders into the area)

Link to comment
Share on other sites

 

Scriptname THBathDressScript extends ObjectReference

Actor Property PlayerRef Auto
ObjectReference Property Wardrobe Auto
ObjectReference Property Dresser Auto

Armor Head
Armor Hair
Armor Body
Armor Hands
Armor Forearms
Armor Amulet
Armor Ring
Armor Feet
Armor Calves
Armor Shield
Armor Tail
Armor Longhair
Armor Circlet
Armor Ears
Armor Fx01
Armor FullHelmet
Armor OpenHelmet
Armor HairGeo
Armor Circlets2
Armor EarGeo
Armor Neck
Armor Face
Armor Neck2
Armor ChestOuter
Armor Back
Armor Jewelry
Armor ChestUnder
Armor Shoulder
Armor Misc
Armor Misc1
Weapon Left
Weapon Right

Event OnTriggerEnter(ObjectReference akActionRef)

 

If (akActionRef == PlayerRef)

Head = Game.GetPlayer().GetEquippedArmorInSlot(30) as Armor
Hair = Game.GetPlayer().GetEquippedArmorInSlot(31) as Armor
Body = Game.GetPlayer().GetEquippedArmorInSlot(32) as Armor
Hands = Game.GetPlayer().GetEquippedArmorInSlot(33) as Armor
Forearms = Game.GetPlayer().GetEquippedArmorInSlot(34) as Armor
Amulet = Game.GetPlayer().GetEquippedArmorInSlot(35) as Armor
Ring = Game.GetPlayer().GetEquippedArmorInSlot(36) as Armor
Feet = Game.GetPlayer().GetEquippedArmorInSlot(37) as Armor
Calves = Game.GetPlayer().GetEquippedArmorInSlot(38) as Armor
Shield = Game.GetPlayer().GetEquippedArmorInSlot(39) as Armor
Tail = Game.GetPlayer().GetEquippedArmorInSlot(40) as Armor
Longhair = Game.GetPlayer().GetEquippedArmorInSlot(41) as Armor
Circlet = Game.GetPlayer().GetEquippedArmorInSlot(42) as Armor
Ears = Game.GetPlayer().GetEquippedArmorInSlot(43) as Armor
Fx01 = Game.GetPlayer().GetEquippedArmorInSlot(61) as Armor
FullHelmet = Game.GetPlayer().GetEquippedArmorInSlot(130) as Armor
OpenHelmet = Game.GetPlayer().GetEquippedArmorInSlot(131) as Armor
HairGeo = Game.GetPlayer().GetEquippedArmorInSlot(141) as Armor
Circlets2 = Game.GetPlayer().GetEquippedArmorInSlot(142) as Armor
EarGeo = Game.GetPlayer().GetEquippedArmorInSlot(143) as Armor
Neck = Game.GetPlayer().GetEquippedArmorInSlot(230) as Armor
Face = Game.GetPlayer().GetEquippedArmorInSlot(44) as Armor
Neck2 = Game.GetPlayer().GetEquippedArmorInSlot(45) as Armor
ChestOuter = Game.GetPlayer().GetEquippedArmorInSlot(46) as Armor
Back = Game.GetPlayer().GetEquippedArmorInSlot(47) as Armor
Jewelry = Game.GetPlayer().GetEquippedArmorInSlot(55) as Armor
ChestUnder = Game.GetPlayer().GetEquippedArmorInSlot(56) as Armor
Shoulder = Game.GetPlayer().GetEquippedArmorInSlot(57) as Armor
Misc = Game.GetPlayer().GetEquippedArmorInSlot(48) as Armor
Misc1 = Game.GetPlayer().GetEquippedArmorInSlot(60) as Armor

Left = Game.GetPlayer().GetEquippedWeapon(True) as Weapon
Right = Game.GetPlayer().GetEquippedWeapon() as Weapon

Game.GetPlayer().GetEquippedArmorInSlot(30)
Game.GetPlayer().GetEquippedArmorInSlot(31)
Game.GetPlayer().GetEquippedArmorInSlot(32)
Game.GetPlayer().GetEquippedArmorInSlot(33)
Game.GetPlayer().GetEquippedArmorInSlot(34)
Game.GetPlayer().GetEquippedArmorInSlot(35)
Game.GetPlayer().GetEquippedArmorInSlot(36)
Game.GetPlayer().GetEquippedArmorInSlot(37)
Game.GetPlayer().GetEquippedArmorInSlot(38)
Game.GetPlayer().GetEquippedArmorInSlot(39)
Game.GetPlayer().GetEquippedArmorInSlot(40)
Game.GetPlayer().GetEquippedArmorInSlot(41)
Game.GetPlayer().GetEquippedArmorInSlot(42)
Game.GetPlayer().GetEquippedArmorInSlot(43)
Game.GetPlayer().GetEquippedArmorInSlot(61)
Game.GetPlayer().GetEquippedArmorInSlot(130)
Game.GetPlayer().GetEquippedArmorInSlot(131)
Game.GetPlayer().GetEquippedArmorInSlot(141)
Game.GetPlayer().GetEquippedArmorInSlot(142)
Game.GetPlayer().GetEquippedArmorInSlot(143)
Game.GetPlayer().GetEquippedArmorInSlot(230)
Game.GetPlayer().GetEquippedArmorInSlot(44)
Game.GetPlayer().GetEquippedArmorInSlot(45)
Game.GetPlayer().GetEquippedArmorInSlot(46)
Game.GetPlayer().GetEquippedArmorInSlot(47)
Game.GetPlayer().GetEquippedArmorInSlot(55)
Game.GetPlayer().GetEquippedArmorInSlot(56)
Game.GetPlayer().GetEquippedArmorInSlot(57)
Game.GetPlayer().GetEquippedArmorInSlot(48)
Game.GetPlayer().GetEquippedArmorInSlot(60)

Game.GetPlayer().GetEquippedWeapon(True)
Game.GetPlayer().GetEquippedWeapon()

PlayerRef.RemoveItem(Head,1,True,Wardrobe)
PlayerRef.RemoveItem(Hair,1,True,Wardrobe)
PlayerRef.RemoveItem(Body,1,True,Wardrobe)
PlayerRef.RemoveItem(Hands,1,True,Wardrobe)
PlayerRef.RemoveItem(Forearms,1,True,Wardrobe)
PlayerRef.RemoveItem(Amulet,1,True,Wardrobe)
PlayerRef.RemoveItem(Ring,1,True,Wardrobe)
PlayerRef.RemoveItem(Feet,1,True,Wardrobe)
PlayerRef.RemoveItem(Calves,1,True,Wardrobe)
PlayerRef.RemoveItem(Shield,1,True,Wardrobe)
PlayerRef.RemoveItem(Tail,1,True,Wardrobe)
PlayerRef.RemoveItem(Longhair,1,True,Wardrobe)
PlayerRef.RemoveItem(Circlet,1,True,Wardrobe)
PlayerRef.RemoveItem(Ears,1,True,Wardrobe)
PlayerRef.RemoveItem(Fx01,1,True,Wardrobe)
PlayerRef.RemoveItem(Fullhelmet,1,True,Wardrobe)
PlayerRef.RemoveItem(OpenHelmet,1,True,Wardrobe)
PlayerRef.RemoveItem(HairGeo,1,True,Wardrobe)
PlayerRef.RemoveItem(Circlets2,1,True,Wardrobe)
PlayerRef.RemoveItem(EarGeo,1,True,Wardrobe)
PlayerRef.RemoveItem(Neck,1,True,Wardrobe)
PlayerRef.RemoveItem(Face,1,True,Wardrobe)
PlayerRef.RemoveItem(Neck2,1,True,Wardrobe)
PlayerRef.RemoveItem(ChestOuter,1,True,Wardrobe)
PlayerRef.RemoveItem(Back,1,True,Wardrobe)
PlayerRef.RemoveItem(Jewelry,1,True,Wardrobe)
PlayerRef.RemoveItem(ChestUnder,1,True,Wardrobe)
PlayerRef.RemoveItem(Shoulder,1,True,Wardrobe)
PlayerRef.RemoveItem(Misc,1,True,Wardrobe)
PlayerRef.RemoveItem(Misc1,1,True,Wardrobe)

PlayerRef.RemoveItem(Left,1,True,Wardrobe)
PlayerRef.RemoveItem(Right,1,True,Wardrobe)

PlayerRef.UnEquipAll()
PlayerRef.RemoveAllItems(Dresser, True)

 

Else

Return

EndIf
EndEvent

 

 

This is my current working script in all it's ... um ... glory.

 

I am indeed calling on slots ... not slotmasks. I can set up a definition for akactionref ... but have not at the moment while I test and tbh I am not sure if any npcs will get anywhere near this atm.

 

*EDIT - Have added akActionRef definition.

 

I have added a removeall function to combat my lack of being able to call on equipped ammo (and also to navigate past the next weapon in line being equipped from the inventory after unequipping).

 

It works ... I quite like it .... but i would like it to be a little more refined and I am sure it is wonky ... but it works. Would very much welcome some thoughts on it.

Edited by TyburnKetch
Link to comment
Share on other sites

Okay, using your current approach: 1, You should be using arrays; 2, the entire middle section where you call Game.GetPlayer().foo() without assigning it to anything is doing nothing (except slowing the script down); 3, You don't need to make all the armour and weapon variables global, they can be declared locally in the event and assigned a value via the Get() functions at that time; and 4, you don't need to call Game.GetPlayer() every time, you could just use akActionRef after confirming it is in fact the player.

 

If you want to do a full scan of a player's equipped gear that's what slotmasks were designed to do, though they will introduce a SKSE dependency if your mod doesn't already have it. Absent that, you can put every check from 30 to 61 into a loop that feeds an array, and then do some one-offs for 130, 131, 141, 142, 143, 230, and the weapons. Since you're not doing anything specific you can leave it as a Form array and will accept armour, weapons, etc.

 

You should also put a check in to avoid duplications. The slotmask system SKSE adds is excellent for this, but if you're storing the found forms in an array you need to simply search the array to see if the current form already exists in it, and, if so, you don't need to add it again. If you only have one copy of each item on you you won't notice any difference, but as it currently stands if you have a multi-slot item (which many pieces of gear are!) it will generate a separate removeitem call for each slot, so if you had more than one in inventory they'll all move into the wardrobe, equipped or not.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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