TyburnKetch Posted December 12, 2018 Share Posted December 12, 2018 (edited) Scriptname THBathDressScript extends ObjectReferenceActor Property PlayerRef AutoObjectReference Property Wardrobe AutoArmor Armor1Event OnTriggerEnter(ObjectReference akActionRef)Int aiSlot = 30Armor1 = Game.GetPlayer().GetEquippedArmorInSlot(30) as ArmorIf Armor1Wardrobe.AddItem(Armor1)EndIfEndEventEvent OnTriggerLeave(ObjectReference akActionRef)PlayerRef.UnEquipAll()EndEventI 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 ObjectReferenceActor Property PlayerRef AutoObjectReference Property Wardrobe AutoArmor BodyEvent OnTriggerEnter(ObjectReference akActionRef)Body = Game.GetPlayer().GetEquippedArmorInSlot(32) as ArmorGame.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 December 12, 2018 by TyburnKetch Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 12, 2018 Share Posted December 12, 2018 (edited) 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 December 12, 2018 by ReDragon2013 Link to comment Share on other sites More sharing options...
TyburnKetch Posted December 12, 2018 Author Share Posted December 12, 2018 This is great. Thank you. Any idea how to grab Ammo? Also ran in to a slight issue with unequipping weapons. For some reason using .removeitem will then equip my next available weapon in the inventory. Anyway to stop that? Link to comment Share on other sites More sharing options...
foamyesque Posted December 12, 2018 Share Posted December 12, 2018 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 More sharing options...
TyburnKetch Posted December 13, 2018 Author Share Posted December 13, 2018 (edited) Scriptname THBathDressScript extends ObjectReferenceActor Property PlayerRef AutoObjectReference Property Wardrobe AutoObjectReference Property Dresser AutoArmor HeadArmor HairArmor BodyArmor HandsArmor ForearmsArmor AmuletArmor RingArmor FeetArmor CalvesArmor ShieldArmor TailArmor LonghairArmor CircletArmor EarsArmor Fx01Armor FullHelmetArmor OpenHelmetArmor HairGeoArmor Circlets2Armor EarGeoArmor NeckArmor FaceArmor Neck2Armor ChestOuterArmor BackArmor JewelryArmor ChestUnderArmor ShoulderArmor MiscArmor Misc1Weapon LeftWeapon RightEvent OnTriggerEnter(ObjectReference akActionRef) If (akActionRef == PlayerRef)Head = Game.GetPlayer().GetEquippedArmorInSlot(30) as ArmorHair = Game.GetPlayer().GetEquippedArmorInSlot(31) as ArmorBody = Game.GetPlayer().GetEquippedArmorInSlot(32) as ArmorHands = Game.GetPlayer().GetEquippedArmorInSlot(33) as ArmorForearms = Game.GetPlayer().GetEquippedArmorInSlot(34) as ArmorAmulet = Game.GetPlayer().GetEquippedArmorInSlot(35) as ArmorRing = Game.GetPlayer().GetEquippedArmorInSlot(36) as ArmorFeet = Game.GetPlayer().GetEquippedArmorInSlot(37) as ArmorCalves = Game.GetPlayer().GetEquippedArmorInSlot(38) as ArmorShield = Game.GetPlayer().GetEquippedArmorInSlot(39) as ArmorTail = Game.GetPlayer().GetEquippedArmorInSlot(40) as ArmorLonghair = Game.GetPlayer().GetEquippedArmorInSlot(41) as ArmorCirclet = Game.GetPlayer().GetEquippedArmorInSlot(42) as ArmorEars = Game.GetPlayer().GetEquippedArmorInSlot(43) as ArmorFx01 = Game.GetPlayer().GetEquippedArmorInSlot(61) as ArmorFullHelmet = Game.GetPlayer().GetEquippedArmorInSlot(130) as ArmorOpenHelmet = Game.GetPlayer().GetEquippedArmorInSlot(131) as ArmorHairGeo = Game.GetPlayer().GetEquippedArmorInSlot(141) as ArmorCirclets2 = Game.GetPlayer().GetEquippedArmorInSlot(142) as ArmorEarGeo = Game.GetPlayer().GetEquippedArmorInSlot(143) as ArmorNeck = Game.GetPlayer().GetEquippedArmorInSlot(230) as ArmorFace = Game.GetPlayer().GetEquippedArmorInSlot(44) as ArmorNeck2 = Game.GetPlayer().GetEquippedArmorInSlot(45) as ArmorChestOuter = Game.GetPlayer().GetEquippedArmorInSlot(46) as ArmorBack = Game.GetPlayer().GetEquippedArmorInSlot(47) as ArmorJewelry = Game.GetPlayer().GetEquippedArmorInSlot(55) as ArmorChestUnder = Game.GetPlayer().GetEquippedArmorInSlot(56) as ArmorShoulder = Game.GetPlayer().GetEquippedArmorInSlot(57) as ArmorMisc = Game.GetPlayer().GetEquippedArmorInSlot(48) as ArmorMisc1 = Game.GetPlayer().GetEquippedArmorInSlot(60) as ArmorLeft = Game.GetPlayer().GetEquippedWeapon(True) as WeaponRight = Game.GetPlayer().GetEquippedWeapon() as WeaponGame.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) ElseReturnEndIfEndEvent 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 December 13, 2018 by TyburnKetch Link to comment Share on other sites More sharing options...
foamyesque Posted December 13, 2018 Share Posted December 13, 2018 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 More sharing options...
TyburnKetch Posted December 13, 2018 Author Share Posted December 13, 2018 (edited) Thank you very much! Great information. Lots here I am unfamiliar with. I need to learn Arrays. I will try to work it all out but I will undoubtedly be back. Point 2: Thank you for confirming my thoughts. Edited December 13, 2018 by TyburnKetch Link to comment Share on other sites More sharing options...
Recommended Posts