How can I make something equip all the time?

Post » Thu Aug 25, 2011 7:37 pm

I'm trying to write a simple script for staff objects and need a little help! I have two versions of each staff, one as a torch and the other as a regular staff for casting.

I want NPCs who have the staff in their inventory to equip the torch version of the staff regardless of what time it is, as long as they are awake. The reason is because
the torch animation animates beautifully for staves (making them look like true walking staves). However, if the staff version of the item is in the NPC's inventory, it wont equip.

However, once battle starts, if there is a magical staff in the NPC's inventory they will equip it. Once battle is over, they will reequip the torch version of the staff and the "magical staff"
version will be unequipped.

Last aspect of the script should be...if there's no magical staff in the inventory they will just fight without it going to their normal battle packages.


I know a bit of coding from my old programming days but I know little to nothing about programming code in the CS/OBSE...

I know the pseudocode would be something like...

Placing the script on the staff IF the Container holding this item = An Npc ANDIF the (time >= 0:00) OR (time <= 24:00) AND (Npc.Holding This Item Is Sleeping = False) AND (Npc.Holding this item is not in battle = True)ANDItem is UnequippedThenEquip the item


Can anyone help me make this pseudocode into real code? xD
User avatar
Cccurly
 
Posts: 3381
Joined: Mon Apr 09, 2007 8:18 pm

Post » Thu Aug 25, 2011 11:24 am

Might take some finagling, but...
ScriptName NonPlayableArmorTokenSCPTRef rContainerInt iCountInt bEquipWeaponBegin OnAdd	Set rContainer to GetContainer	Set iCount to rContainer.GetItemCount WeaponID	If iCount		If (iCount > 1)			Set iCount to (iCount - 1)			rContainer.RemoveItem WeaponID iCount		EndIf	Else		rContainer.AddItem WeaponID 1	EndIf	Set iCount to rContainer.GetItemCount LightID	If iCount		If (iCount > 1)			Set iCount to (iCount - 1)			rContainer.RemoveItem LightID iCount		EndIf	Else		rContainer.AddItem LightID 1	EndIfEnd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Begin GameMode	If rContainer.IsSleeping		Return ; They should automatically unequip either item while sleeping	ElseIf rContainer.GetDead		rContainer.RemoveItem LightID 1 ; So the player never sees both versions of what is to apparently be a single item	ElseIf (rContainer.IsInCombat != rContainer.GetEquipped WeaponID)		Set bEquipWeapon to (bEquipWeapon == 0) ; Set boolean to whatever it's not		If bEquipWeapon			rContainer.UnequipItem LightID			rContainer.EquipItem WeaponID		Else			rContainer.UnequipItem WeaponID			rContainer.EquipItem LightID		EndIf	EndIfEnd
...should be a good start. Rather than attaching a script to either the LIGH or WEAP record or both, this would be on a Non-Playable token. You'd have to add the token to them elsweyr and in doing so they'd acquire both versions of the stave.
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm


Return to IV - Oblivion