Need Trigger Script Help Unequip all on Enter Equip on Leave

Post » Mon Jun 30, 2014 3:24 am

Okay, So I'm trying to create a script which is going to be attached to a trigger box. When the trigger box is entered, all items will be unequipped from the actor. When the trigger box is left, those same items that were unequipped from the actor upon entering the trigger box will be requipped.

I'd assume it has something to do with the OnTriggerEnter and OntriggerLeave Events, but other than that I'm clueless. How would I go about doing this?

User avatar
REVLUTIN
 
Posts: 3498
Joined: Tue Dec 26, 2006 8:44 pm

Post » Mon Jun 30, 2014 5:47 am

Would this have to occur for any actor or only for a specific one like the player? The latter case is easier than the former, at least if several actors could enter the trigger box inside a short period of time.

User avatar
luis ortiz
 
Posts: 3355
Joined: Sun Oct 07, 2007 8:21 pm

Post » Mon Jun 30, 2014 1:25 am

Any Actor.

User avatar
Elisha KIng
 
Posts: 3285
Joined: Sat Aug 18, 2007 12:18 am

Post » Mon Jun 30, 2014 5:22 am

This is based on the example script in the http://www.creationkit.com/Slot_Masks_-_Armor. I'm not sure if this is a very good way to do it from a technical perspective (particularly threading), but I think it could work. An alternative method would be to have two FormLists: one for the actor and another for his/her container. Each actor spawns a container, which is used to store copies of the base forms of equipped pieces of armor as a form of bookkeeping instead of the event specific form array (kEquippedItems). The alternative method would remove the need for the loop that waits until the actor leaves the volume.

REQUIRES SKSE.

FormList Property kActorsInVolume AutoEvent OnTriggerEnter(ObjectReference akActionRef)	Actor kActor = akActionRef as Actor	If(kActor)		kActorsInVolume.AddForm(kActor)		Form[] kEquippedItems = New Form[31]		Int iSlotsChecked		iSlotsChecked += 0x00100000		iSlotsChecked += 0x00200000		iSlotsChecked += 0x80000000		Int iSlot = 0x01		Int i = 0		While(iSlot < 0x80000000)			If(Math.LogicalAnd(iSlotsChecked, iSlot) != iSlot)				Armor kArmor = kActor.GetWornForm(iSlot) as Armor				If(kArmor)					kEquippedItems[i] = kArmor					i += 1					iSlotsChecked += kArmor.GetSlotMask()				Else					iSlotsChecked += iSlot				EndIf			EndIf			iSlot *= 2		EndWhile		Weapon kRight = kActor.GetEquippedWeapon()		If(kRight)			kEquippedItems[i] = kRight			i += 1		EndIf		Weapon kLeft		If(kLeft)			kEquippedItems[i] = kLeft		EndIf		i = 0		While(i < kEquippedItems.Length)			If(kEquippedItems[i])				kActor.UnequipItem(kEquippedItems[i], False, True)			EndIf			i += 1		EndWhile		While(kActorsInVolume.Find(kActor) >= 0)			Utility.WaitMenuMode(5.0) ;Adjust according to size of trigger volume and average time spent inside.		EndWhile		i = 0		While(i < kEquippedItems.Length)			If(kEquippedItems[i])				kActor.EquipItem(kEquippedItems[i], False, True)			EndIf			i += 1		EndWhile	EndIfEndEventEvent OnTriggerLeave(ObjectReference akActionRef)	Actor kActor = akActionRef as Actor	If(kActor)		kActorsInVolume.RemoveAddedForm(kActor)	EndIfEndEvent

I haven't tried to compile it so I can't say whether it works or not.

User avatar
Leilene Nessel
 
Posts: 3428
Joined: Sun Apr 15, 2007 2:11 am

Post » Mon Jun 30, 2014 7:33 am

I had a thought... I know Bert's Breezehome Remodel does something to this effect... The Problem is, there's no source code, so all the scripts are .pex instead of the more readable .psc

Do you know if there's any way to, like, decompile the scripts or something?

User avatar
candice keenan
 
Posts: 3510
Joined: Tue Dec 05, 2006 10:43 pm

Post » Mon Jun 30, 2014 5:00 am

Yes. I use http://www.nexusmods.com/skyrim/mods/35307/?, though there may be other alternatives. Simply drag-and-drop the .pex file(s) on to the executable and the decompiled source files will be placed where the .pex files are.

User avatar
SamanthaLove
 
Posts: 3565
Joined: Mon Dec 11, 2006 3:54 am


Return to V - Skyrim