Darklocq Posted August 22, 2021 Share Posted August 22, 2021 So, here's the basic script I have for "you've fetched this quest item". It is one that will next be taken from player inventory and put into follower inventory, to close out the quest: Scriptname DrqMgGearQstGetCuir extends ObjectReference Quest Property DrqMgGearQstGetCuirProp Auto Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer) If (newContainer == Game.GetPlayer()) DrqMgGearQstGetCuirProp.SetObjectiveDisplayed(30) DrqMgGearQstGetCuirProp.SetStage(30) EndIf EndEvent But it may re-enter player inventory, e.g. to temper it and give it back to the follower, at any time thereafter. Do I need to do anything in here to test for that, or is it all going to be irrelevant because the quest is already closed as soon as you hand the cuirass (for the first time) to the follower who had you go fetch it? I'm concerned about the SetObjectiveDisplayed and whether that would spam the player with on-screen notices about an already-closed quest. My suspicion is that I have to declare a variable of some sort, then set it to DrqMgGearQstGetCuirProp.GetStage(), then test whether that is < 30. But I don't want to have to do that if it'll just be wasted code. Maybe an alternative is having two versions of the gear, and removing the quest one from the player and putting the non-quest one in the follower inventory, so the quest one disappears from the game after initial delivery. There's probably a "best practices" way to handle this sort of thing, but I'm new to this corner of modding. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted August 22, 2021 Share Posted August 22, 2021 Scriptname DrqMgGearQstGetCuir extends ObjectReference Quest Property DrqMgGearQstGetCuirProp Auto Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer) ;do nothing EndEvent Auto State Waiting Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer) If (newContainer == Game.GetPlayer()) DrqMgGearQstGetCuirProp.SetObjectiveDisplayed(30) DrqMgGearQstGetCuirProp.SetStage(30) GoToState("") EndIf EndEvent EndState The switching from the auto state to the empty state where the event is empty will allow later transfers to the player inventory to avoid running the quest related stuff again. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted August 22, 2021 Share Posted August 22, 2021 (edited) According to your script description, I think your condition is not right. I also changed the scriptname and the name of quest property.If you want to be sure a specific follower should get the scripted item only, you have to add a new actor property filled with the follower for comparing in this script. Drq30ContainerChangeScript Scriptname Drq30ContainerChangeScript extends ObjectReference ; old scriptname "DrqMgGearQstGetCuir" ; https://forums.nexusmods.com/index.php?/topic/10402203-fetch-quest-item-script-for-item-that-may-go-in-and-out-of-player-inventory-later/ Quest PROPERTY myQuest auto ; fill with your own quest "DrqMgGearQstGetCuirProp" ;;Actor PROPERTY myFollower aut ; specific follower pre-filled by CK Bool bOnceOnly ; [default=False] ; -- EVENT -- EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) IF ( bOnceOnly ) RETURN ; - STOP - already given ENDIF ;--------------------- myF_Action(akNewContainer, akOldContainer) ENDEVENT ; -- FUNCTIONs -- 2 ; Darklocq wrote: "It is one that will next be taken from player inventory and ; put into follower inventory, to close out the quest:" ;-------------------------------------------------- FUNCTION myF_Action(ObjectReference akNewContainer) ; outsourced code for better overview ;-------------------------------------------------- ; https://www.creationkit.com/index.php?title=OnContainerChanged_-_ObjectReference IF (akOldContainer == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - (scripted item) does not come from players inventory ENDIF ;--------------------- IF myF_IsFollower(akNewContainer as Actor) ELSE RETURN ; - STOP - (scripted item) is not recieved by a follower ENDIF ;--------------------- bOnceOnly = TRUE ; Item transfer from player to follower was successfully! myQuest.SetObjectiveDisplayed(30) myQuest.setStage(30) ;;; myQuest.Stop() ; you could stop your quest here, if required! ENDEVENT ;--------------------------------------- Bool FUNCTION myF_IsFollower(Actor aRef) ; helper ;--------------------------------------- IF ( aRef ) ELSE Return False ; /1 * no actor ENDIF ;--------- ;IF (aRef == myFollower) ; * by using actor property ; Return TRUE ; * use this condition ;ENDIF ; * as short circuit ;;--------- ; * ; Return False ; * actor player = Game.GetPlayer() ;IF (aRef == player) ; Return TRUE ; /2 its the player (whole function was used in other context, avoid check here!) ;ENDIF ;--------- ;IF (aRef.GetFactionReaction(player) == 1) ; Return False ; /3 * its hostile to player (avoid check here!) ;ENDIF ;--------- IF aRef.IsPlayerTeammate() Return TRUE ; /4 its a teammate, as good as follower ENDIF ;--------- IF (aRef.GetRelationshipRank(player) > 0) Return TRUE ; /5 good relationship ENDIF ;--------- IF aRef.IsInFaction(CurrentFollowerFaction) Return TRUE ; /6 its follower by faction ENDIF ;--------- IF (aRef.GetCurrentPackage().GetTemplate() == Follow) Return TRUE ; /7 its follower typ1 ENDIF ;--------- IF (aRef.GetCurrentPackage().GetTemplate() == FollowerPackageTemplate) Return TRUE ; /8 its follower typ2 ENDIF ;--------- ;IF aRef.IsCommandedActor() ; RETURN !aRef.IsHostileToActor(player) ; /9 avoid hostile summons (avoid check here!) ;ENDIF ;--------- Return False ; /10 * ENDFUNCTION Edited August 22, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted August 22, 2021 Share Posted August 22, 2021 For what it is worth, your condition is fine if this is an item that the player has been tasked with finding, picking up and then giving to the designated NPC / follower to end the quest. Assuming of course that this pre-placed object reference only spawns once the quest governing it starts. Perhaps more information on intended steps is needed to ensure no unnecessary rabbit holes are taken. Link to comment Share on other sites More sharing options...
Recommended Posts