Is there a way to unequip weapons and helmet?

Post » Thu Jun 21, 2012 10:09 am

I'm working on the see you sleep mod and would like an option that unequips helmets and weapons.

Am I going to have to write a huge if statement that checks to see if every helmet in the game is equipped? This leaves modded armor out which isn't good. I know I can do it with SKSE using the slot masks, but I don't really want to use SKSE.
User avatar
Schel[Anne]FTL
 
Posts: 3384
Joined: Thu Nov 16, 2006 6:53 pm

Post » Thu Jun 21, 2012 4:59 pm

I'm working on the see you sleep mod and would like an option that unequips helmets and weapons.

Am I going to have to write a huge if statement that checks to see if every helmet in the game is equipped? This leaves modded armor out which isn't good. I know I can do it with SKSE using the slot masks, but I don't really want to use SKSE.

Looks like getting the weapon with http://www.creationkit.com/GetEquippedItemType_-_Actor and then calling http://www.creationkit.com/UnequipItem_-_Actor would be easy but not seeing a way to get the helmet.
User avatar
nath
 
Posts: 3463
Joined: Mon Jan 22, 2007 5:34 am

Post » Thu Jun 21, 2012 6:31 pm

You might be able to catch the helm by equipping an invisible helm and grabbing akBaseObject OnObjectUnequipped style.

Something like:
Spoiler
Bool bGrabHelmetBool bSleepingForm kLeftHandWeaponForm kRightHandWeaponForm kHelmetActor Property PlayerREF AutoEvent SomeEvent()	...	If bSleeping		kRightHandWeapon = Game.GetPlayer().GetEquippedWeapon() ; Right Hand Weapon		If kRightHandWeapon			PlayerREF.UnequipItem(kRightHandWeapon, False, True)		EndIf		kLeftHandWeapon = Game.GetPlayer().GetEquippedWeapon(True) ; Left Hand Weapon		If kRightHandWeapon			PlayerREF.UnequipItem(kLeftHandWeapon, False, True)		EndIf		bGrabHemlet = True		PlayerREF.EquipItem(InvisiHelmARMO, False, True)	Else		PlayerREF.RemoveItem(InvisiHelmARMO, 1, True)		If kRightHandWeapon			PlayerREF.EquipItem(kRightHandWeapon, False, True)			EndIf		If kLeftHandWeapon			PlayerREF.EquipItem(kLeftHandWeapon, False, True)		EndIf		If kHelmet			PlayerREF.EquipItem(kHelmet, False, True)		EndIf	EndIf	...EndEventEvent OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)	If bGrabHemlet		bGrabHemlet = False		kHelmet = akBaseObject	EndIfEndEvent
User avatar
Taylah Illies
 
Posts: 3369
Joined: Fri Feb 09, 2007 7:13 am

Post » Thu Jun 21, 2012 7:19 pm

The OnUnequipped event will discover the helmet, as suggested.

However, that event needs to be in a script attached to the player (as a quest alias or whatever).

Since the event will fire every time the player unequips something, you could use HasKeyword(ArmorHelmet) to determine whether a helmet is being removed.

You could record the current helmet throughout the game (as a quest property, for example).

Alternatively, the OnUnquipped event could be scripted to record the helmet only in the unique situation of equipping the invisible helmet. That has the advantage of not depending on keywords or adding overhead throughout the game. The potential downside is that you must disable the player's ability to unequip items - otherwise, there's no way of knowing which action has triggered the OnUnquipped script.

P.S. The DummyHelmet item might serve as an invisible helmet, but I haven't tested it in game.
User avatar
Janine Rose
 
Posts: 3428
Joined: Wed Feb 14, 2007 6:59 pm

Post » Thu Jun 21, 2012 1:47 pm

The engine already automatically shealths your weapon when you activate furniture. I was wanting to unequip the sheathed sword or bow. For the helmet couldn't I just add a weightless invisible unplayable helmet to the inventory when the mod is started and equip it, then remove it?
User avatar
Danial Zachery
 
Posts: 3451
Joined: Fri Aug 24, 2007 5:41 am

Post » Thu Jun 21, 2012 8:01 am

However, that event needs to be in a script attached to the player (as a quest alias or whatever).
Precisely.
Since the event will fire every time the player unequips something, you could use HasKeyword(ArmorHelmet) to determine whether a helmet is being removed.
That's what the bGrabHelmet var is for. That'll be true when and only when it's unequipped via equipping the InvisiHelm.
Alternatively, the OnUnquipped event could be scripted to record the helmet only in the unique situation of equipping the invisible helmet.
It would be too late in that case to catch the form in the OnObjectUnequipped event, thus bGrabHelmet has to get flipped before equipping the dummy helm.
P.S. The DummyHelmet item might serve as an invisible helmet, but I haven't tested it in game.
You can make invisible apparel items, at least you could in Oblivion/Fallouts. A model with 0 scale should do it with the appropriate biped slots of course.


The engine already automatically shealths your weapon when you activate furniture. I was wanting to unequip the sheathed sword or bow. For the helmet couldn't I just add a weightless invisible unplayable helmet to the inventory when the mod is started and equip it, then remove it?
That should work just as well, but you risk losing it if depending on a single item instance unless it's scripted to go back to the player when removed. You could probably add it as a quest alias in the player alias, then mark said alias as a "Quest Object".

Note: In my example code, EquipItem will give the player an InvisiHelm if they've not already got one. If it's "Unplayable", you could just change the RemoveItem to UnequipItem and it will always work.
User avatar
Karine laverre
 
Posts: 3439
Joined: Tue Mar 20, 2007 7:50 am

Post » Thu Jun 21, 2012 2:40 pm

If you use SKSE, for the helmet you could do :

Armor Helmet = PlayerRef.GetWornForm(2) as ArmorPlayerRef.UnequipItem(Helmet)

Edit : sorry, as you don't want to use SKSE.
User avatar
Phoenix Draven
 
Posts: 3443
Joined: Thu Jun 29, 2006 3:50 am

Post » Thu Jun 21, 2012 9:03 am

Precisely... That's what the bGrabHelmet var is for. That'll be true when and only when it's unequipped via equipping the InvisiHelm...
It would be too late in that case to catch the form in the OnObjectUnequipped event, thus bGrabHelmet has to get flipped before equipping the dummy helm...
Sorry, it wasn't clear that your script was intended to be attached to the player. Since you have the player as a property, one might be forgiven for assuming the opposite, perhaps?

At any rate, since we don't know which object the OP's main script is attached to, it's entirely possible that the OnObjectUnequipped event is in a separate player script.

When I said "only in the unique situation of equipping the invisible helmet", that indeed implies that the situation must be identified before the event fires. If the player script is external, we can't use a local boolean. I guess a quest script property or global variable would suffice, but that's only reliable if the player's ability to unequip other stuff is locked down.
User avatar
Naomi Ward
 
Posts: 3450
Joined: Fri Jul 14, 2006 8:37 pm

Post » Thu Jun 21, 2012 7:15 pm

Sorry, it wasn't clear that your script was intended to be attached to the player. Since you have the player as a property, one might be forgiven for assuming the opposite, perhaps?

At any rate, since we don't know which object the OP's main script is attached to, it's entirely possible that the OnObjectUnequipped event is in a separate player script.

When I said "only in the unique situation of equipping the invisible helmet", that indeed implies that the situation must be identified before the event fires. If the player script is external, we can't use a local boolean. I guess a quest script property or global variable would suffice, but that's only reliable if the player's ability to unequip other stuff is locked down.
You're right as that wasn't evident. I've been working with aliases so much lately, specifying where it was to be attached slipped my mind. Sorry if I came off like a turd :) With all that stuff set up on a player alias though, it ought to work out well (at least that's how I'd go about it).
User avatar
SWagg KId
 
Posts: 3488
Joined: Sat Nov 17, 2007 8:26 am

Post » Thu Jun 21, 2012 5:10 pm

...
User avatar
Killer McCracken
 
Posts: 3456
Joined: Wed Feb 14, 2007 9:57 pm


Return to V - Skyrim