Smirkyguy Posted May 27, 2020 Share Posted May 27, 2020 basically wanting to attach this script to a miscobject. SCRIPTING IS HARD! SKSE code is allowed. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 27, 2020 Share Posted May 27, 2020 You want some code to trigger when two separate objects are unequippepd? Not possible for a misc object. You'll need more that one script to achieve this. It could be done with one script on an actor alias but if you specifically want a misc object to run specific code, then you will need two scripts at minimum. Quest record with an alias pointing to the actor (could be player or desired NPC)Attach script to the alias record, would be something like this: Scriptname MultiObjectUnequipAliasScript Extends ReferenceAlias FormList Property myObjectList Auto ;this list contains all objects to be checked GlobalVariable Property myObjectsUnequipped Auto ;this global keeps track of how many equipped / unequipped ;start value should match the total number of items in the formlist Int Property TotalNumPieces Auto ;this value must match total number of items in formlist myMiscObjectScript Property myObjectScript Auto ;this will point to the object holding the target script ;the object type name (far left) must be identical to the target script name. Variable name can be anything. Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) Int index = myObjectList.GetSize() - 1 While index >= 0 Form Entry = myObjectList.GetAt(index) If Entry == akBaseObject myObjectsUnequipped.Mod(1) ;add one for each unequipped EndIf index -= 1 EndWhile EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) Int index = myObjectList.GetSize() - 1 While index >= 0 Form Entry = myObjectList.GetAt(index) If Entry == akBaseObject myObjectsUnequipped.Mod(-1) ;remove one for each equipped EndIf index -= 1 EndWhile EndEvent Function GetIfAllUnequipped(GlobalVariable myGV) If (myGV.GetValue() as Int) == TotalNumPieces ;Tell the other script to run a specific function myObjectScript.TargetItemsUnequipped() ElseIf (myGV.GetValue() as Int) < TotalNumPieces ;statement in the log indicating not enough have been removed -- can be removed after testing Debug.Trace("Not enough pieces unequipped yet.") ElseIf (myGV.GetValue() as Int) > TotalNumPieces ;statement in the log indicating too many have been removed -- can be removed after testing Debug.Trace("Something went wrong too many") EndIf EndFunction Create the form list and global variable records to fill those properties. The form list must have each item that needs to be unequipped. The global needs to start off with a non-constant value of zero.Finally attach a script to the misc object that you want to actually run the code.Something like: Scriptname myMiscObjectScript Extends ObjectReference Function TargetItemsUnequipped() ;do something EndFunction Ensure that all properties are properly filled before testing in-game. Please note, neither script has been tested for compilation or function. It should also be noted that this was written to be able to handle more than just two items. If one wanted to track whether five different items were all unequipped after having been equipped, they could. Link to comment Share on other sites More sharing options...
Smirkyguy Posted May 27, 2020 Author Share Posted May 27, 2020 slight misunderstanding. i want to make it so, when the miscitem is picked up, it forcefully unequips two pieces of armor. and when the item is removed, it also re equips the two pieces of armor. preferably make it so it can only activate on a specific actor Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 27, 2020 Share Posted May 27, 2020 Then state clearly what you want the first time... ScriptName myObjectScript Extends ObjectReference FormList Property myGearList Auto ;formlist containing all get intended to be equipped / unequipped Actor Property TargetActor Auto ;the target actor Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer && akNewContainer as Actor == TargetActor Int index = myGearList.GetSize() - 1 While index >= 0 Form Entry = myGearList.GetAt(index) If TargetActor.GetItemCount(Entry) > 0 ;actually have the item If TargetActor.IsEquipped(Entry) TargetActor.UnEquipItem(Entry) EndIf EndIf index -= 1 EndWhile ElseIf akOldContainer && akOldContainer as Actor == TargetActor Int index = myGearList.GetSize() - 1 While index >= 0 Form Entry = myGearList.GetAt(index) If TargetActor.GetItemCount(Entry) > 0 ;actually have the item If !(TargetActor.IsEquipped(Entry)) TargetActor.EquipItem(Entry) EndIf EndIf index -= 1 EndWhile EndIf EndEvent Not tested for function or compilation. Unequips items in list if present and equipped when moved into the target actor's inventory. Equips the items in the list if present when removed from the target actor's inventory. Note that any player added enchantments will not take affect. Enchantments attached to the base record via the CK will take affect. You can explicitly define the items to be equipped / unequipped. Using a formlist, however, gives room for growth without rewriting the code if at some point you wish to include more than the initial two items. Link to comment Share on other sites More sharing options...
Smirkyguy Posted May 27, 2020 Author Share Posted May 27, 2020 and i paste this into an alias script? or the miscitem script? Link to comment Share on other sites More sharing options...
Smirkyguy Posted May 27, 2020 Author Share Posted May 27, 2020 okay it mostly works, but the follower keeps re equipping the armor later. can it be modified to delete the armor from her inventory, then re add it? Link to comment Share on other sites More sharing options...
Smirkyguy Posted May 27, 2020 Author Share Posted May 27, 2020 NVM got it! thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts