maxarturo Posted January 28, 2019 Share Posted January 28, 2019 (edited) Hi everyone !. I've encountered a small issue in which i can't make an activator to return the key (Skyrim). I'm using the sarcophagus lock and a skull key, the script is working just fine but i can't remove the skull key, I try all weekend to make it work but... for the love of god... what am i missing ? is the first activator i've encounter this issue, every other activator i've scripted works fine. My script without the remove function (works as intended): Scriptname aXMDSkullLockSCRIPT01 extends ObjectReference {Script for the Skull Lock setup} Quest Property myQuest auto {The quest we will be setting stages on} Int Property stageSetOnTriggered auto {The stage that will be set when the player Triggered this slot, or activates the slot without the required item} ObjectReference Property SecretDoor auto {Activates door or activator} MiscObject Property myKey01 auto ObjectReference Property BarrierSound auto {Disable link Ref} Message Property emptySlotMessage auto {Message that shows when the player Triggers this slot without the required keys.} bool Property isTriggered = false auto hidden Event onActivate(ObjectReference akActionRef) if (isTriggered != TRUE && akactionref.getitemcount(myKey01) >= 1) if (myQuest.GetStageDone(stageSetOnTriggered) == FALSE) myQuest.SetStage(stageSetOnTriggered) endif akactionref.removeitem(myKey01, 1) ;debug.messagebox("Removing KEY 01 From PLAYERS INVENTORY") PlayAnimationAndWait("Insert", "Done") isTriggered = true SecretDoor.activate(self) BarrierSound.disable() else if (isTriggered != TRUE && akactionref.getitemcount(myKey01) >= 0) emptySlotMessage.Show() endif endif endEvent This is one of my scripts with the remove key (skull) function (NOT WORKING - Does not play the animation and does not adds skull key to inventory): Scriptname aXMDSkullLockSCRIPT01 extends ObjectReference {Script for the Skull Lock setup} Quest Property myQuest auto {The quest we will be setting stages on} Int Property stageSetOnTriggered auto {The stage that will be set when the player Triggered this slot, or activates the slot without the required item} ObjectReference Property SecretDoor auto {Activates door or activator} MiscObject Property myKey01 auto ObjectReference Property BarrierSound auto {Disable link Ref} Message Property emptySlotMessage auto {Message that shows when the player Triggers this slot without the required keys.} bool Property isTriggered = false auto hidden Event onActivate(ObjectReference akActionRef) if (isTriggered != TRUE && akactionref.getitemcount(myKey01) >= 1) if (myQuest.GetStageDone(stageSetOnTriggered) == FALSE) myQuest.SetStage(stageSetOnTriggered) endif akactionref.removeitem(myKey01, 1) ;debug.messagebox("Removing KEY 01 From PLAYERS INVENTORY") PlayAnimationAndWait("Insert", "Done") isTriggered = true SecretDoor.activate(self) BarrierSound.disable() else if (isTriggered != TRUE && akactionref.getitemcount(myKey01) >= 0) emptySlotMessage.Show() endif endif endEvent STATE ReadyToTake Event onActivate(ObjectReference akActionRef) if (isTriggered != FALSE && akactionref.getitemcount(myKey01) >= 0) PlayAnimationAndWait("Remove", "Done") isTriggered = false akactionref.Additem(myKey01, 1) ;debug.messagebox("Adding KEY 01 To PLAYERS INVENTORY") GoToState("AllDone") endif EndEVENT EndSTATE Thanks a lot to anyone who takes a look at this !!. Edited January 28, 2019 by maxarturo Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 28, 2019 Share Posted January 28, 2019 You have the state "ReadyToTake" but no where in your code do you go to that state. You also have an "AllDone" state being activated but no such corresponding state. Is this the entire script? If so, I'm not even sure how it would compile. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted January 28, 2019 Share Posted January 28, 2019 If the sceond script is the whole you have, there is a missing of gotoState() here. aXMDSkullLockSCRIPT01 Scriptname aXMDSkullLockSCRIPT01 extends ObjectReference {Script for the Skull Lock setup} ; https://forums.nexusmods.com/index.php?/topic/7351716-can-somebody-help-with-a-little-script/ ; script without the remove function (works as intended) Quest PROPERTY myQuest auto ; {The quest we will be setting stages on} Int PROPERTY stageSetOnTriggered auto ; {The stage that will be set when the player Triggered this slot, or activates the slot without the required item} Message PROPERTY emptySlotMessage auto {Message that shows when the player Triggers this slot without the required keys.} MiscObject PROPERTY myKey01 auto ObjectReference PROPERTY BarrierSound auto ; {Disable link Ref} ObjectReference PROPERTY SecretDoor auto ; {Activates door or activator} Bool PROPERTY isTriggered = False auto Hidden ; -- EVENT -- EVENT OnActivate(ObjectReference akActionRef) IF ( isTriggered ) RETURN ; - STOP - already done! ENDIF ;--------------------- IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not the player, do nothing! ENDIF ;--------------------- IF (akActionRef.GetItemCount(myKey01) == 0) emptySlotMessage.Show() RETURN ; - STOP - player does not have the key01! ENDIF ;--------------------- IF myQuest.IsStageDone(stageSetOnTriggered) ; if not set ELSE myQuest.setStage(stageSetOnTriggered) ; set the quest stage ENDIF isTriggered = TRUE akActionRef.RemoveItem(myKey01, 1) ;; debug.messagebox("Removing KEY 01 From PLAYERS INVENTORY") self.PlayAnimationAndWait("Insert", "Done") SecretDoor.Activate(self) BarrierSound.Disable() ENDEVENT ;if (isTriggered != TRUE && akActionRef.GetItemCount(myKey01) >= 1) ; ; if (myQuest.GetStageDone(stageSetOnTriggered) == FALSE) ; myQuest.SetStage(stageSetOnTriggered) ; endif ; ; akActionRef.RemoveItem(myKey01, 1) ;;; debug.messagebox("Removing KEY 01 From PLAYERS INVENTORY") ; ; self.PlayAnimationAndWait("Insert", "Done") ; isTriggered = TRUE ; ; SecretDoor.activate(self) ; BarrierSound.disable() ; ;elseif (isTriggered != TRUE && akActionRef.GetItemCount(myKey01) >= 0) ; emptySlotMessage.Show() ;endif Keep in mind I renamed the second script!aXMDSkullLockSCRIPT02 Scriptname aXMDSkullLockSCRIPT02 extends ObjectReference {Script for the Skull Lock setup} ; https://forums.nexusmods.com/index.php?/topic/7351716-can-somebody-help-with-a-little-script/ ; scripts with the remove key function (NOT WORKING - Does not play the animation and does not adds skull key to inventory): ; "i can't remove the skull key" Quest PROPERTY myQuest auto ; {The quest we will be setting stages on} Int PROPERTY stageSetOnTriggered auto ; {The stage that will be set when the player Triggered this slot, or activates the slot without the required item} Message PROPERTY emptySlotMessage auto {Message that shows when the player Triggers this slot without the required keys.} MiscObject PROPERTY myKey01 auto ObjectReference PROPERTY BarrierSound auto ; {Disable link Ref} ObjectReference PROPERTY SecretDoor auto ; {Activates door or activator} Bool PROPERTY isTriggered auto Hidden ; [default=False] ; -- EVENTs -- 1 + "ReadyToTake" + "AllDone" EVENT OnActivate(ObjectReference akActionRef) ; script triggeres this event at first, because no "auto state" here IF ( isTriggered ) RETURN ; - STOP - already done! ENDIF ;--------------------- myF_Action(akActionRef, 1) ENDEVENT ;=================================== STATE ReadyToTake ;================ EVENT OnActivate(ObjectReference akActionRef) ; after gotoState() this will be triggered IF ( isTriggered ) ELSE RETURN ; - STOP - already done! ENDIF ;--------------------- myF_Action(akActionRef, 2) ENDEVENT ;======= endState ;=================================== STATE AllDone ; do not trigger this event anymore ;============ EVENT OnActivate(ObjectReference akActionRef) ENDEVENT ;======= endState ; -- FUNCTION -- ;------------------------------------------------------ FUNCTION myF_Action(ObjectReference akActionRef, Int i) ;------------------------------------------------------ IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not the player, do nothing! ENDIF ;--------------------- in state("") IF (i == 1) IF (akActionRef.GetItemCount(myKey01) == 0) emptySlotMessage.Show() RETURN ; - STOP - player does not have the key01! ENDIF ; ---------------------- IF myQuest.IsStageDone(stageSetOnTriggered) ; if not set ELSE myQuest.setStage(stageSetOnTriggered) ; set the quest stage ENDIF akActionRef.RemoveItem(myKey01 as Form, 1) ;; debug.messagebox("Removing KEY 01 From PLAYERS INVENTORY") isTriggered = TRUE self.PlayAnimationAndWait("Insert", "Done") SecretDoor.Activate(self) BarrierSound.Disable() gotoState("ReadyToTake") ; ### STATE ### RETURN ; - STOP - ENDIF ;--------------------- in state("ReadyToTake") IF (i == 2) isTriggered = False self.PlayAnimationAndWait("Remove", "Done") akActionRef.AddItem(myKey01 as Form, 1) ;; debug.messagebox("Adding KEY 01 To PLAYERS INVENTORY") gotoState("AllDone") ; ### STATE ### ;;; RETURN ; - STOP - ENDIF Link to comment Share on other sites More sharing options...
maxarturo Posted January 29, 2019 Author Share Posted January 29, 2019 (edited) Thanks IsharaMeradin & ReDragon2013 for replying. ReDragon2013 i try your script version but i still have problem, now it adds the skull key to the inventory but it won't play the remove key animation. And if i don't manage to make it work i'll have to change my whole mod because the main quest it's based on the player finding along his journey 5 skulls in which he will use each skull in different cells and all 5 of them in the final cell. IsharaMeradin this was one of my scripts that i made in my attempt to make it work, but i actually wanted to post an other one but cause of been too tired i messed up the scripts that i wanted to post - i'm refering to the second script. Further info on vanilla items: Activator name = SarcophagusSkullLock01 Skull key name = dunRagnTorstensKey Vanilla script attach to it (the vanilla script does not serves my purpose): Scriptname SarcophagusSkullLock01SCRIPT extends ObjectReference {Script for the Sarcophagus Skull Lock setup} Keyword Property LinkCustom01 auto ObjectReference Property myLock auto hidden {Link ref to the lock this slot controls} ObjectReference Property myPartnerSlot auto hidden {LinkCustom01 pointing to my partner lock.} ObjectReference Property myKey01 auto {Point this property to the key/skull that belongs to this slot} ObjectReference Property myKey02 auto {Point this property to the second key/skull that belongs to this slot} Quest Property myQuest auto {The quest we will be setting stages on} Int Property stageSetOnFirstActivate auto {The stage that will be set when the player first activates this slot, or activates the slot without the required item} Message Property emptySlotMessage auto {Message that shows when the player activates this slot without the required keys.} Int Property stageSetOnUnlock auto {The stage that will be set when this is unlocked} Bool Property alreadyLoaded = FALSE auto hidden Int Property itemThatUnlockedMe auto hidden Bool Property lastUnlocked = FALSE auto hidden EVENT OnLoad() ; Unless this has been loaded set up the linked refs if (alreadyLoaded == FALSE) myLock = GetLinkedRef() myPartnerSlot = GetLinkedRef(LinkCustom01) as SarcophagusSkullLock01SCRIPT alreadyLoaded = TRUE endif EndEVENT auto STATE WaitingForKey EVENT OnActivate(ObjectReference ActivateRef) ; Removed the correct key from the player when he activates me and go to state Unlocked ; ...if player doesn't have a key then set the stage, and show the message about the slots if (Game.GetPlayer().GetItemCount(myKey01) == 1) GoToState("Unlocked") ; debug.Trace("DARYL - Player has " + Game.GetPlayer().GetItemCount(mykey01) + " Key01: " + myKey01 + " in his inventory") if (myQuest.GetStageDone(stageSetOnFirstActivate) == FALSE) myQuest.SetStage(stageSetOnFirstActivate) endif Game.GetPlayer().RemoveItem(myKey01) ; debug.Trace("DARYL - Removing Key01 from player. Player now has " + Game.GetPlayer().GetItemCount(mykey01) + " of " + myKey01) ;debug.messagebox("Removing KEY 01 From PLAYERS INVENTORY") itemThatUnlockedMe = 1 PlayAnimationAndWait("Insert", "Done") myLock.PlayAnimationAndWait("Unlock01", "Done") elseif (Game.GetPlayer().GetItemCount(myKey02) == 1) GoToState("Unlocked") ; debug.Trace("DARYL - Player has " + Game.GetPlayer().GetItemCount(mykey02) + " Key02: " + myKey02 + " in his inventory") if (myQuest.GetStageDone(stageSetOnFirstActivate) == FALSE) myQuest.SetStage(stageSetOnFirstActivate) endif Game.GetPlayer().RemoveItem(myKey02) ; debug.Trace("DARYL - Removing Key02 from player. Player now has " + Game.GetPlayer().GetItemCount(mykey02) + " of " + myKey02) ;debug.messagebox("Removing KEY 02 From PLAYERS INVENTORY") itemThatUnlockedMe = 2 PlayAnimationAndWait("Insert", "Done") myLock.PlayAnimationAndWait("Unlock01", "Done") else ; debug.Trace("DARYL - Player doesn't have either key") if (myQuest.GetStageDone(stageSetOnFirstActivate) == FALSE) myQuest.SetStage(stageSetOnFirstActivate) endif emptySlotMessage.Show() endif EndEVENT endSTATE STATE Unlocked EVENT OnBeginState() ; If myPartnerSlot is also in state Unlocked then run the UnlockSequence() function if (myPartnerSlot.GetState() == "Unlocked") ; debug.Trace("DARYL - My Partner slot is also unlocked, running UnlockSequence()") lastUnlocked = TRUE UnlockSequence() endif EndEVENT EVENT OnAnimationEvent(ObjectReference akSource, string asEventName) if (akSource == self) && (asEventName == "Done") utility.Wait(1) playAnimationAndWait("Unlock", "Done") myLock.PlayAnimation("Unlock02") if (lastUnlocked == TRUE) myQuest.SetStage(stageSetOnUnlock) endif utility.wait(2) PlayAnimationAndWait("Release", "Done") UnregisterForAnimationEvent(self, "Done") GoToState("ReadyToTake") endIf EndEvent EndSTATE STATE ReadyToTake ; Make sure that the player takes back the correct key after activating me. EVENT OnActivate(ObjectReference ActivateRef) if (itemThatUnlockedMe == 1) PlayAnimationAndWait("Remove", "Done") Form Key01Form = myKey01.GetBaseObject() Game.GetPlayer().AddItem(Key01Form) ;debug.messagebox("ADDING KEY 01 TO PLAYERS INVENTORY") GoToState("AllDone") itemThatUnlockedMe = 0 elseif (itemThatUnlockedMe == 2) PlayAnimationAndWait("Remove", "Done") Form Key02Form = myKey02.GetBaseObject() Game.GetPlayer().AddItem(Key02Form) ;debug.messagebox("ADDING KEY 02 TO PLAYERS INVENTORY") GoToState("AllDone") ItemThatUnlockedMe = 0 endif EndEVENT EndSTATE STATE AllDone ;Do Nothing EndSTATE Function UnlockSequence() ; Unlock both this and the partner slot and go to ReadyToTake state if (lastUnlocked == TRUE) (myPartnerSlot as SarcophagusSkullLock01SCRIPT).UnlockSequence() endif RegisterForAnimationEvent(self, "Done") PlayAnimation("Unlock") ;myPartnerSlot.PlayAnimation("Unlock") ;playAnimationAndWait("Unlock", "Done") ;utility.Wait(1) ;(myPartnerSlot.myLock).PlayAnimation("Unlock2") ;myLock.PlayAnimationAndWait("Unlock02", "Done") ;utility.Wait(1) ;myQuest.SetStage(stageSetOnUnlock) ;myPartnerSlot.GoToState("ReadyToTake") ;GoToState("ReadyToTake") EndFunction Again thanks both of you very much for your help !!. Edited January 29, 2019 by maxarturo Link to comment Share on other sites More sharing options...
ReDragon2013 Posted January 30, 2019 Share Posted January 30, 2019 (edited) You posted the vanilla skyrim script, which was certainly the base to your own script. As you can see we had a debug with "Daryl" inside. All Skyrim scripts with such info in debug trace are far away to be nice coded.I do not play Skyrim so often (my time is limited), that is the reason I cannot confirm what is happen during animation. SarcophagusSkullLock01SCRIPT I rewrote the script years ago. Scriptname SarcophagusSkullLock01SCRIPT extends ObjectReference {v1.4 ReDragon 2014} ; for the Sarcophagus Skull Lock setup Quest PROPERTY myQuest auto ; The quest we will be setting stages on ; The stage that will be set when, ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Int PROPERTY stageSetOnFirstActivate auto ; player first activates this slot, or activates the slot without the required item Int PROPERTY stageSetOnUnlock auto ; this is unlocked Keyword PROPERTY LinkCustom01 auto Message PROPERTY emptySlotMessage auto ; Message that shows when the player activates this slot without the required keys. ObjectReference PROPERTY myKey01 auto ; the key/skull that belongs to this slot ObjectReference PROPERTY myKey02 auto ; the second key/skull that belongs to this slot ObjectReference PROPERTY myLock auto Hidden ; LinkedRef to the lock this slot controls ObjectReference PROPERTY myPartnerSlot auto Hidden ; LinkCustom01 pointing to my partner lock. Int PROPERTY itemThatUnlockedMe auto Hidden Bool PROPERTY alreadyLoaded = False auto Hidden Bool PROPERTY lastUnlocked = False auto Hidden ; -- FUNCTIONs -- 2 FUNCTION UnlockSequence() ;------------------------ ; Unlock both this and the partner slot and go to ReadyToTake state IF ( lastUnlocked ) (myPartnerSlot as SarcophagusSkullLock01SCRIPT).UnlockSequence() ENDIF RegisterForAnimationEvent(self, "Done") self.PlayAnimation("Unlock") ENDFUNCTION FUNCTION myF_Done(ObjectReference sRef) ;-------------------------------------- IF (sRef == self) ELSE RETURN ; - STOP - ENDIF ;--------------------- UnregisterForAnimationEvent(self, "Done") Utility.Wait(1.0) self.PlayAnimationAndWait("Unlock", "Done") myLock.PlayAnimation("Unlock02") IF ( lastUnlocked ) myQuest.setStage(stageSetOnUnlock) ENDIF Utility.Wait(2.0) self.PlayAnimationAndWait("Release", "Done") gotoState("ReadyToTake") ; ### STATE ### ENDFUNCTION ; -- EVENTs -- "WaitingForKey" + "Unlocked" + "ReadyToTake" + "AllDone" EVENT OnLoad() ; Unless this has been loaded set up the linked refs IF ( alreadyLoaded ) RETURN ; - STOP - ENDIF ;--------------------- alreadyLoaded = TRUE myLock = self.GetLinkedRef() myPartnerSlot = self.GetLinkedRef(LinkCustom01) as SarcophagusSkullLock01SCRIPT EndEVENT ;====================================== auto STATE WaitingForKey ;======================= EVENT OnActivate(ObjectReference actionRef) ; Removed the correct key from the player when he activates me and go to state Unlocked ; ...if player does not have a key then set the stage, and show the message about the slots int i IF (Game.GetPlayer().GetItemCount(myKey01) > 0) i = 1 Game.GetPlayer().RemoveItem(myKey01) ELSEIF (Game.GetPlayer().GetItemCount(myKey02) > 0) i = 2 Game.GetPlayer().RemoveItem(myKey02) ELSE i = 0 emptySlotMessage.Show() ;; Debug.Trace(self+" OnActivate() - Player doesn't have either key!") ENDIF ;--------------------- IF !myQuest.IsStageDone(stageSetOnFirstActivate) myQuest.setStage(stageSetOnFirstActivate) ENDIF IF (i == 0) RETURN ; - STOP - no key (0 of 2) ENDIF ;--------------------- gotoState("Unlocked") ; ### STATE ### itemThatUnlockedMe = i self.PlayAnimationAndWait("Insert", "Done") myLock.PlayAnimationAndWait("Unlock01", "Done") ENDEVENT ;======= endState ;====================================== state Unlocked ;============= EVENT OnBeginState() ; If myPartnerSlot is also in state Unlocked then run the UnlockSequence() function IF (myPartnerSlot.GetState() == "Unlocked") lastUnlocked = TRUE UnlockSequence() ENDIF ENDEVENT EVENT OnAnimationEvent(ObjectReference akSource, String asEventName) IF (asEventName == "Done") myF_Done(akSource) ENDIF ENDEVENT ;======= endState ;====================================== state ReadyToTake ;================ EVENT OnActivate(ObjectReference actionRef) ; Make sure that the player takes back the correct key after activating me. form fm IF (itemThatUnlockedMe == 1) fm = myKey01.GetBaseObject() ELSEIF (itemThatUnlockedMe == 2) fm = myKey02.GetBaseObject() ELSE RETURN ; - STOP - ENDIF ;--------------------- IF ( fm ) gotoState("AllDone") ; ### STATE ### self.PlayAnimationAndWait("Remove", "Done") Game.GetPlayer().AddItem(fm) ItemThatUnlockedMe = 0 ENDIF ENDEVENT ;======= endState ;====================================== state AllDone ;============ endState Now the same script rewritten caused by your posting here, maybe something is not as intended.SarcophagusSkullLock01SCRIPT Scriptname SarcophagusSkullLock01SCRIPT extends ObjectReference {v1.4a ReDragon 2019} ; Script for the Sarcophagus Skull Lock setup ; https://forums.nexusmods.com/index.php?/topic/7351716-can-somebody-help-with-a-little-script/ Quest PROPERTY myQuest auto {The quest we will be setting stages on} Int PROPERTY stageSetOnFirstActivate auto {The stage that will be set when the player first activates this slot, or activates the slot without the required item} Int PROPERTY stageSetOnUnlock auto {The stage that will be set when this is unlocked} Keyword PROPERTY LinkCustom01 auto ; use autofill Message PROPERTY emptySlotMessage auto {Message that shows when the player activates this slot without the required keys.} ObjectReference PROPERTY myKey01 auto ; {Point this PROPERTY to the key/skull that belongs to this slot} ObjectReference PROPERTY myKey02 auto ; {Point this PROPERTY to the second key/skull that belongs to this slot} ;ObjectReference PROPERTY myLock auto Hidden ; {Link ref to the lock this slot controls} ;ObjectReference PROPERTY myPartnerSlot auto Hidden ; {LinkCustom01 pointing to my partner lock.} Int PROPERTY itemThatUnlockedMe auto Hidden ; [default=0] Bool PROPERTY alreadyLoaded auto Hidden ; [default=False] Bool PROPERTY lastUnlocked auto Hidden ; [default=False] ; -- EVENTs -- "WaitingForKey" + "Unlocked" + "ReadyToTake" + "AllDone" EVENT OnReset() Debug.Trace(self+" OnReset() - has been reached..") ; debug.info ENDEVENT EVENT OnLoad() ; maybe OnCellLoad() will be better here alreadyLoaded = TRUE Debug.Trace(self+" OnLoad() - has been reached..") ; debug info EndEVENT EVENT OnUnload() alreadyLoaded = False Debug.Trace(self+" OnUnload() - has been reached..") ; debug info ENDEVENT ;================================== auto STATE WaitingForKey ;======================= ; Removed the correct key from the player when he activates me and goto state Unlocked ; ...if player does not have a key then set the stage, and show the message about the slots EVENT OnActivate(ObjectReference akActionRef) ; this is the activation event we start at first IF (akActionRef == Game.GetPlayer() as ObjectReference) myF_Action(akActionRef) ; do it for player activation only ENDIF ENDEVENT ;======= endState ;================================== STATE Unlocked ;============= EVENT OnAnimationEvent(ObjectReference akSource, String asEventName) IF (akSource == self) IF (asEventName == "Done") myF_Anim() ENDIF ENDIF ENDEVENT ;======= endState ;================================== STATE ReadyToTake ;================ ; Make sure that the player takes back the correct key after activating me. EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not the player, do nothing ENDIF ;--------------------- player activated IF (itemThatUnlockedMe == 1) myF_UnLock(akActionRef, myKey01) RETURN ; - STOP - ENDIF ;--------------------- IF (itemThatUnlockedMe == 2) myF_UnLock(akActionRef, myKey02) ENDIF EndEVENT ;======= endState ;================================== STATE AllDone ; do nothing ;======= endState ; -- FUNCTIONs -- 5 ;------------------------- FUNCTION myF_SetStage_FA() ; internal helper ;------------------------- IF myQuest.IsStageDone(stageSetOnFirstActivate) RETURN ; - STOP - quest stage already set ENDIF ;--------------------- myQuest.setStage(stageSetOnFirstActivate) ENDFUNCTION ;----------------------------------------------- FUNCTION myF_Action(ObjectReference akActionRef) ;----------------------------------------------- IF (akActionRef.GetItemCount(myKey01) > 0) ; firstly look at key01 itemThatUnlockedMe = 1 ELSEIF (akActionRef.GetItemCount(myKey02) > 0) ; if not found, try key02 itemThatUnlockedMe = 2 ELSE ;; debug.Trace("DARYL - Player doesn't have either key") myF_SetStage_FA() emptySlotMessage.Show() RETURN ; - STOP - ENDIF ;--------------------- gotoState("Unlocked") ; ### STATE ### myF_SetStage_FA() ; If myPartnerSlot is also in state Unlocked then run the UnlockSequence() function SarcophagusSkullLock01SCRIPT ps = self.GetLinkedRef(LinkCustom01) as SarcophagusSkullLock01SCRIPT IF (ps) && (ps.GetState() == "Unlocked") ;; debug.Trace("DARYL - My Partner slot is also unlocked, running UnlockSequence()") lastUnlocked = TRUE ps.UnlockSequence() RegisterForAnimationEvent(self, "Done") self.PlayAnimation("Unlock") ENDIF IF (itemThatUnlockedMe == 1) akActionRef.RemoveItem(myKey01) ;; debug.messagebox("Removing KEY01 From PLAYERS INVENTORY") ELSE akActionRef.RemoveItem(myKey02) ;; debug.messagebox("Removing KEY02 From PLAYERS INVENTORY") ENDIF self.PlayAnimationAndWait("Insert", "Done") self.GetLinkedRef().PlayAnimationAndWait("Unlock01", "Done") ENDFUNCTION ;------------------ FUNCTION myF_Anim() ;------------------ UnRegisterForAnimationEvent(self, "Done") ; just in case, do it inside a function body NOT inside event body objectReference linkRef = self.GetLinkedRef() Utility.Wait(1.0) self.PlayAnimationAndWait("Unlock", "Done") linkRef.PlayAnimation("Unlock02") IF ( lastUnlocked ) ; == TRUE myQuest.setStage(stageSetOnUnlock) ENDIF Utility.Wait(2.0) self.PlayAnimationAndWait("Release", "Done") gotoState("ReadyToTake") ; ### STATE ### ENDFUNCTION ;--------------------------------------------------------------------- FUNCTION myF_UnLock(ObjectReference akActionRef, ObjectReference oRef) ;--------------------------------------------------------------------- self.PlayAnimationAndWait("Remove", "Done") akActionRef.AddItem( oRef.GetBaseObject() ) ; Key01Form or Key02Form ;; debug.messagebox("ADDING KEY TO PLAYERS INVENTORY") gotoState("AllDone") ; ### STATE ### itemThatUnlockedMe = 0 ENDFUNCTION ;------------------------ FUNCTION UnlockSequence() ; Unlock both this and the partner slot (and goto "ReadyToTake" state) ;------------------------ IF ( lastUnlocked ) SarcophagusSkullLock01SCRIPT ps = self.GetLinkedRef(LinkCustom01) as SarcophagusSkullLock01SCRIPT IF ( ps ) ps.UnlockSequence() ENDIF ENDIF RegisterForAnimationEvent(self, "Done") self.PlayAnimation("Unlock") ENDFUNCTION ;myPartnerSlot.PlayAnimation("Unlock") ;playAnimationAndWait("Unlock", "Done") ;utility.Wait(1) ;(myPartnerSlot.myLock).PlayAnimation("Unlock2") ;myLock.PlayAnimationAndWait("Unlock02", "Done") ;utility.Wait(1) ;myQuest.SetStage(stageSetOnUnlock) ;myPartnerSlot.GoToState("ReadyToTake") ;GoToState("ReadyToTake") Edited January 30, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
maxarturo Posted January 31, 2019 Author Share Posted January 31, 2019 (edited) ReDragon2013 thanks for your help till now !! But as the VANILLA script this does not serves my purpose because : A) It works only with 2 linked pedestals and it won't allow me to use only 1 or a combination of 3 - 5 pedestals linked to a common XMarker activator with a counter - plus this script activates the counter attached to the XMarker activator by just displaying the "emptySlotMessage.Show()" and not with the placed in pedestal skull key (activator triggered only, as is supposed to be done). B) I still haven't been able to trigger the remove key animation. I think it's controled by the quest but i didn't check it for the reason expleined above (i didn't do an in depth testing). C) Only 2 pedestal out of 10 will have a quest attach to it. D) I'm not using only 1 single skull key - pedestal model, every pedestal has it's own skull key model & pedestal model, so the check "mykey 02" it's an issue here (i've re-texture 5 different skull keys and pedestals). * I'll have to find an other way to make this work or i'll have to change my whole mod... BUMMER... Thank you very much for spending your precious time in trying to help me !! I'll for sure credit you in my mod's page when ever i manage to finish it (i'm at 750mb & 80% of its completion). A thousands thanks !! Edited January 31, 2019 by maxarturo Link to comment Share on other sites More sharing options...
ReDragon2013 Posted February 4, 2019 Share Posted February 4, 2019 (edited) Just an idea, instead of using one keyword "LinkCustom01", use for each pedestal a new keyword.Next code is a bit experimental, probably not working as intended, but maybe useful to realize your mod. maoSkullKey_UnLockSCRIPT Scriptname maoSkullKey_UnLockSCRIPT extends ObjectReference {Script for specific Sarcophagus Skull key to activate a pedestal} ; https://forums.nexusmods.com/index.php?/topic/7351716-can-somebody-help-with-a-little-script/ ; maxarturo wrote: ; "every pedestal has it's own skull key model & pedestal model" Quest PROPERTY myQuest auto {The quest we will be setting stages on} Int PROPERTY stageSetOnFirstActivate auto {The stage that will be set when the player first activates this slot, or activates the slot without the required item} Int PROPERTY stageSetOnUnlock auto {The stage that will be set when this is unlocked} ;; pedestal 1 is linked to pedestal 2 ; Keyword PROPERTY LinkCustom01 auto ; use autofill 1 is linked with 2 ; Keyword PROPERTY LinkCustom02 auto ; use autofill 2 is linked with 3 ; Keyword PROPERTY LinkCustom03 auto ; use autofill ; Keyword PROPERTY LinkCustom04 auto ; use autofill ; Keyword PROPERTY LinkCustom05 auto ; use autofill ; Keyword PROPERTY LinkCustom06 auto ; use autofill ; Keyword PROPERTY LinkCustom07 auto ; use autofill ; Keyword PROPERTY LinkCustom08 auto ; use autofill ; Keyword PROPERTY LinkCustom09 auto ; use autofill 9 is linked with 10 ; Keyword PROPERTY LinkCustom10 auto ; use autofill pedestal 10 is linked with pedestal 1 ; if linked skull is using keyword LinkCustom01 take this here Keyword PROPERTY LinkCustom auto ; use one of the 10 keywords above Keyword PROPERTY LinkCustomFinal auto ; the last pedestal has this keyword as same as LinkCustom Message PROPERTY emptySlotMessage auto {Message that shows when the player activates this slot without the required keys.} Message PROPERTY RightKeyMessage auto ; if you need it! {Message that show when the player activates this slot with the right key} Message PROPERTY WrongKeyMessage auto ; if you need it! {Message that show when the player activates this slot with the wrong key} FormList PROPERTY myKeyList auto ; put in each key you need for activating the pedestals ObjectReference PROPERTY myKey auto ; {Point this PROPERTY to the key/skull that belongs to this slot} ;ObjectReference PROPERTY myKey02 auto ; {Point this PROPERTY to the second key/skull that belongs to this slot} ;ObjectReference PROPERTY myLock auto Hidden ; {Link ref to the lock this slot controls} ;ObjectReference PROPERTY myPartnerSlot auto Hidden ; {LinkCustom01 pointing to my partner lock.} Bool PROPERTY alreadyLoaded auto Hidden ; [default=False] Bool PROPERTY lastUnlocked auto Hidden ; [default=False] ;Int PROPERTY itemThatUnlockedMe auto Hidden ; replaced by the next Bool PROPERTY bUnLocked auto Hidden ; [default=False] ; -- EVENTs -- "WaitingForKey" + "Unlocked" + "ReadyToTake" + "AllDone" EVENT OnReset() Debug.Trace(self+" OnReset() - has been reached..") ; debug.info ENDEVENT EVENT OnLoad() alreadyLoaded = TRUE Debug.Trace(" OnLoad() - has been reached.. " +self) ; debug info EndEVENT EVENT OnUnload() alreadyLoaded = False Debug.Trace(" OnUnload() - has been reached.. " +self) ; debug info ENDEVENT ;================================== auto STATE WaitingForKey ;======================= ; Removed the correct key from the player when he activates me and goto state Unlocked ; ...if player does not have a key then set the stage, and show the message about the slots EVENT OnActivate(ObjectReference akActionRef) ; this is the activation event we start at first IF (akActionRef == Game.GetPlayer() as ObjectReference) myF_Action(akActionRef as Actor) ; do it for player activation only ENDIF ENDEVENT ;======= endState ;================================== STATE Unlocked ;============= EVENT OnAnimationEvent(ObjectReference akSource, String asEventName) IF (akSource == self) && (asEventName == "Done") myF_Anim() ENDIF ENDEVENT ;======= endState ;================================== STATE ReadyToTake ; Make sure that the player takes back the correct key after activating me. ;================ EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not the player, do nothing ENDIF ;--------------------- IF ( bUnLocked ) gotoState("AllDone") ; ### STATE ### self.PlayAnimationAndWait("Remove", "Done") akActionRef.AddItem( myKey.GetBaseObject() ) ; Key01Form ;; debug.messagebox("Give the KEY back TO PLAYERS INVENTORY") ENDIF EndEVENT ;======= endState ;================================== STATE AllDone ; do nothing ;======= endState ; -- FUNCTIONs -- 6 ;------------------------- FUNCTION myF_SetStage_FA() ; internal helper ;------------------------- IF myQuest.IsStageDone(stageSetOnFirstActivate) RETURN ; - STOP - quest stage already set ENDIF ;--------------------- myQuest.setStage(stageSetOnFirstActivate) ENDFUNCTION ;------------------------------ FUNCTION myF_Show(Actor player) ;------------------------------ IF ( WrongKeyMessage ) int iMax = myKeyList.GetSize() int i = 0 WHILE (i < iMax) objectReference oRef = myKeyList.GetAt(i) as ObjectReference IF (oRef) && player.GetItemCount(oRef) WrongKeyMessage.Show() RETURN ; - STOP - at least one key has been found in the inventory ENDIF ; ---------------------- i = i + 1 ENDWHILE ELSE emptySlotMessage.Show() ; no special key in players inventory ENDIF ENDFUNCTION ;-------------------------------- FUNCTION myF_Action(Actor player) ;-------------------------------- IF ( bUnLocked ) RETURN ; - STOP - already unlocked ENDIF ;--------------------- myF_SetStage_FA() ; if not needed, removed it !! int i = player.GetItemCount(myKey) ; adjust the property 'myKey01' for each pedestal IF (i == 0) myF_Show(player) RETURN ; - STOP - ENDIF ;===================== TRUE, player has the right key gotoState("Unlocked") ; ### STATE ### bUnLocked = TRUE IF ( RightKeyMessage ) RightKeyMessage.Show() ENDIF player.RemoveItem(myKey) ;; debug.messagebox("Removing the KEY From PLAYERS INVENTORY") myF_Test() self.PlayAnimationAndWait("Insert", "Done") ; the key self.GetLinkedRef().PlayAnimationAndWait("Unlock01", "Done") ; the door ENDFUNCTION ;------------------ FUNCTION myF_Anim() ;------------------ UnRegisterForAnimationEvent(self, "Done") ; just in case, do it inside a function body NOT inside the event body Utility.Wait(1.0) self.PlayAnimationAndWait("Unlock", "Done") ; the key self.GetLinkedRef().PlayAnimation("Unlock02") ; the door IF ( lastUnlocked ) ; == TRUE myQuest.setStage(stageSetOnUnlock) ENDIF Utility.Wait(2.0) self.PlayAnimationAndWait("Release", "Done") gotoState("ReadyToTake") ; ### STATE ### ENDFUNCTION ;---------------------------------- FUNCTION UnlockSequence(Keyword kw) ; Unlock both this and the partner slot (and goto "ReadyToTake" state) ;---------------------------------- maoSkullKey_UnLockSCRIPT ps = self.GetLinkedRef(kw) as maoSkullKey_UnLockSCRIPT ; NEXT function call could lead to an infinte call, if break condition is wrong here !!! KEEP that in MIND. IF (ps.LinkCustom != ps.LinkCustomFinal) ; test only debug.Trace("DARYL - All my partner slots are also unlocked, running UnlockSequence() for " +ps) ps.UnlockSequence( ps.LinkCustom ) ;* and now call it for the other pedestals ENDIF RegisterForAnimationEvent(self, "Done") self.PlayAnimation("Unlock") ENDFUNCTION ;------------------ FUNCTION myF_Test() ;------------------ IF ( !LinkCustom ) Debug.Trace(" myF_Test() - bail out because of missing keyword!") RETURN ; - STOP - /1 ENDIF ;--------- ; If myPartnerSlot is also in state Unlocked then run the UnlockSequence() function maoSkullKey_UnLockSCRIPT ps = self.GetLinkedRef(LinkCustom) as maoSkullKey_UnLockSCRIPT IF (ps) && (ps.GetState() == "Unlocked") IF (LinkCustom == LinkCustomFinal) debug.Trace("DARYL - All my partner slots are also unlocked, starting UnlockSequence() with " +ps) lastUnlocked = TRUE ps.UnLockSequence( ps.LinkCustom ) ;* this is the beginner RegisterForAnimationEvent(self, "Done") self.PlayAnimation("Unlock") ENDIF RETURN ; - STOP - /2 ENDIF ;--------- Debug.Trace(" myF_Test() - still locked for keyword " +LinkCustom) ENDFUNCTION ;;------------------ ;FUNCTION myF_Test() ;;------------------ ; keyword[] a = new Keyword[11] ; temp array for easier access to the linked partners ; a[0] = LinkCustom ; current linked partner, same keyword as one of the next 10 ; a[1] = LinkCustom01 ; a[2] = LinkCustom02 ; a[3] = LinkCustom03 ; a[4] = LinkCustom04 ; a[5] = LinkCustom05 ; a[6] = LinkCustom06 ; a[7] = LinkCustom07 ; a[8] = LinkCustom08 ; a[9] = LinkCustom09 ; a[10]= LinkCustom10 ; ; keyword kw = a[0] ; bool bOK = False ; ;int i = 1 ; WHILE (i < a.Length) && (!bOK) ; IF (kw == a[i]) ; bOK = TRUE ; ENDIF ; i = i + 1 ; ENDWHILE ; ;IF ( !bOK ) ; Debug.Trace(" myF_Test() - bail out because of missing keyword!") ; RETURN ; - STOP - /1 ;ENDIF ;;--------- ;; If myPartnerSlot is also in state Unlocked then run the UnlockSequence() function ; ; maoSkullKey_UnLockSCRIPT ps = self.GetLinkedRef(kw) as maoSkullKey_UnLockSCRIPT ; ;IF (ps) && (ps.GetState() == "Unlocked") ; IF (kw == LinkCustom10) ;;; debug.Trace("DARYL - All my partner slots are also unlocked, running UnlockSequence()") ; lastUnlocked = TRUE ; ENDIF ; UnLockSequence(kw) ; RETURN ; - STOP - /2 ;ENDIF ;;--------- ; Debug.Trace(" myF_Test() - still locked for keyword " +kw) ;ENDFUNCTION Edited February 4, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
maxarturo Posted February 5, 2019 Author Share Posted February 5, 2019 (edited) Woooh... I didn't expect that !, thank you very much for your trouble !!!... I'll for sure check this "maoSkullKey_UnLockSCRIPT" just for the seek of knowledge and learning. But i found a workaround to my issue, i used as a base your script "aXMDSkullLockSCRIPT02" and instead of "unlock" i set it to upon "adding the skull key to player's inventory to self disable", and this actually help me to prevent players from "closing activators and disableing links Ref" + "reseting the counter" (if they panic) upon removing the keys in two crucials points of the quest. Is not the most beautiful or elegance solution, but it fits well with the mod's dark and mystical atmosphere, plus i want them to be used only once, and it works as a fail safe. Again thank you so much for your help !!... Edited February 5, 2019 by maxarturo Link to comment Share on other sites More sharing options...
Recommended Posts