IsharaMeradin Posted May 27, 2021 Share Posted May 27, 2021 You could try starting a quest and have the quest grab the closest ref to fill the alias. Then add that to the player. It would be a clunky workaround, however. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted May 27, 2021 Share Posted May 27, 2021 (edited) As I can see IsharaMeradin has given you a lot of help. Sometimes it's a good idea to take an advice. 1) If you have an issue with papyrus you should post here: https://forums.nexusmods.com/index.php?/forum/4070-skyrim-special-edition-creation-kit-and-modders/ 2) If you post papyrus code "mark the whole content" and use the icon <> in the mainbar above your posting text. 3) I wonder how do you get the OnAnimationEvent() to trigger? You never register for this inside your script. Scriptname ConvenientAxe extends ObjectReference ;Scriptname CLWATakeAxe extends ObjectReference {Grabs a required item from the surrounding area. Attach to the same object ResourceFurnitureScript is attached to.} ; https://forums.nexusmods.com/index.php?/topic/10050898-new-modder-new-papyrus-scripter-strange-bug/ ; GamingZacharyC wrote: "The script is only attached to one Wood Chopping Block", ; "a Wood Chopping Block in Ivarstead (IvarsteadExterior04)" Formlist PROPERTY preferredItemList auto {List of items that the script will prefer to take} Formlist PROPERTY requiredItemList auto ; use vanilla list of "woodChoppingAxes" {List of items for the attached ResourceFurnitureScript that the script will take, if needed} Message PROPERTY TookItemMessage auto {Message to say that a required item was grabbed from somewhere nearby} Message PROPERTY FailureMessage auto {Message to show when the script cannot find any required item. Make sure to use an empty message in ResourceFurnitureScript!} Float PROPERTY fSearchRadius = 100000.0 auto ; hundred thousand units as default {How far to search for a viable item?} ObjectReference ThatItem ; store itemRef here to make it persistent by scripting ; -- EVENTs -- 3 + "Busy" EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not player activated! ENDIF ;--------------------- IF (akActionRef.GetItemCount(requiredItemList) > 0) RETURN ; - STOP - player has (at least) one item from the itemlist in his inventory ENDIF ;--------------------- gotoState("Busy") ; ### STATE ### myF_Action(akActionRef) gotoState("") ; ### STATE ### ENDEVENT EVENT OnCellDetach() ; failsafe, player has left the parent cell of this object IF ( ThatItem ) myF_Remove( Game.GetPlayer() as ObjectReference ) ENDIF ENDEVENT ;======================= state Busy ; do not handle activation event for a while ;========= EVENT OnActivate(ObjectReference akActionRef) ENDEVENT ;======= endState EVENT OnAnimationEvent(ObjectReference akSource, string asEventName) IF ( ThatItem ) ;;; IF (asEventName == "IdleFurnitureExit") ; not really needed in this script, only one name has been registered myF_Remove(akSource) ; wood chopping has ended ;;; ENDIF ENDIF ENDEVENT ; -- FUNCTIONs -- 2 ;-------------------------------------------- FUNCTION myF_Remove(ObjectReference playeRef) ;-------------------------------------------- ; https://www.creationkit.com/index.php?title=UnregisterForAnimationEvent_-_Form ;;; Utility.Wait(0.25) ; maybe this wait is required here !? UnRegisterForAnimationEvent(playerRef, "IdleFurnitureExit") playerRef.RemoveItem(ThatItem.GetBaseObject(), 1, TRUE) ; remove the player given object to Nirvana ThatItem.EnableNoWait() ThatItem = None ; remove script persistent of Ref ENDFUNCTION ;--------------------------------------------- FUNCTION myF_Action(ObjectReference playerRef) ;--------------------------------------------- ; https://www.creationkit.com/index.php?title=FindClosestReferenceOfAnyTypeInListFromRef_-_Game ; https://www.creationkit.com/index.php?title=RegisterForAnimationEvent_-_Form IF ( preferredItemList ) ThatItem = Game.FindClosestReferenceOfAnyTypeInListFromRef(preferredItemList, playerRef, fSearchRadius) ELSE ThatItem = Game.FindClosestReferenceOfAnyTypeInListFromRef(requiredItemList, playerRef, fSearchRadius) ENDIF IF ( ThatItem ) playerRef.AddItem(ThatItem.GetBaseObject(), 1, TRUE) ; give player the item by creating a new object self.RegisterForAnimationEvent(playerRef, "IdleFurnitureExit") ; returns boolVar, register first to trigger OnAnimationEvent() ThatItem.Disable(TRUE) ; disable original item object TookItemMessage.Show() ; show msg of success self.Activate(playerRef, TRUE) ; initiate wood chopping by fake a player activation ELSE FailureMessage.Show() ; no object found in search radius ENDIF ENDFUNCTION Edited May 27, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
BellCube Posted May 30, 2021 Author Share Posted May 30, 2021 (edited) 3) I wonder how do you get the OnAnimationEvent() to trigger? You never register for this inside your script.That's taken care of in vanilla's ResourceFurnitureScript, which is present in all objects this script is attached to. Edited May 30, 2021 by GamingZacharyC Link to comment Share on other sites More sharing options...
Recommended Posts