Gudulba Posted June 21, 2024 Posted June 21, 2024 There ist this great mod ZAP Helper Addon 8.0+ Extension, which allows to tie up to 50 NPCs to ZAZ furniture with the help of spells. As the original mod author doesn't seem to be active anymore on LL (last login in 2022), I have taken the liberty to expand this mod and I have tried to add additional 50 slots (I edited the scripts in Notepad++, compiled them with PCA and edited the ESP in Creation Kit). However I always get the error "ERROR WITH LOCK 51" when trying to tie up the 51st NPC. Obviously I am missing something regarding my changes. Would it be possible for somone to take a look at my changes? I could upload the files somewhere.
traison Posted June 21, 2024 Posted June 21, 2024 "ERROR WITH LOCK 51" is not a Papyrus error, so I'd search for that (or a part of it) in the code. It would point directly at where the problem is.
Gudulba Posted June 21, 2024 Author Posted June 21, 2024 1 hour ago, traison said: "ERROR WITH LOCK 51" is not a Papyrus error, so I'd search for that (or a part of it) in the code. It would point directly at where the problem is. Yes indeed, it's part of the scripts, namely ZFPFurnitureLockScript.psc and ZFPLockControlScript.psc. Slot 51 is the first slot I added myself (see code snippet in spoiler section). I have double-checked the three scripts I edited (ZFPFurnitureLockScript.psc and ZFPLockControlScript.psc and ZFPSelectLockNPCScript.psc) and the changes I made in Creation Kit. But as I more or less only copied what was already there without really understanding its mechanisms, I could have overlooked something. Attached is the edited mod in case someone finds the time to have a look at it 🙂 Spoiler If ZFPLockAliasFurn50.GetReference() == None ZFPLockAliasFurn50.ForceRefTo(BDSMFurnitureAlias1.GetReference()) ZFPLockAliasNPC50.ForceRefTo(BDSM_NPCAlias1.GetActorRef()) If ZFPLockAliasNPC50.GetReference() != None Debug.Notification("NPC 50/100 LOCKED!") If ZFPLockAliasNPC50.GetActorRef().IsInFaction(ZFPBoundFaction) ZFPLockAliasNPC50.GetActorRef().RemoveFromFaction(ZFPBoundFaction) EndIf If !ZFPLockAliasNPC50.GetActorRef().IsInFaction(ZFPLockedFaction) ZFPLockAliasNPC50.GetActorRef().AddToFaction(ZFPLockedFaction) EndIf BDSM_NPCAlias1.Clear() BDSMFurnitureAlias1.Clear() ZFPFurnitureUsed.SetValueInt(0) ZFPAlias1Filled.SetValueInt(0) ZFPFurnitureFilled1.SetValueInt(0) ZFPAliasGreeted.SetValueInt(0) ElseIf ZFPLockAliasNPC50.GetReference() == None Debug.Notification("ERROR WITH LOCK 50!") EndIf Return EndIf If ZFPLockAliasFurn51.GetReference() == None ZFPLockAliasFurn51.ForceRefTo(BDSMFurnitureAlias1.GetReference()) ZFPLockAliasNPC51.ForceRefTo(BDSM_NPCAlias1.GetActorRef()) If ZFPLockAliasNPC51.GetReference() != None Debug.Notification("NPC 51/100 LOCKED!") If ZFPLockAliasNPC51.GetActorRef().IsInFaction(ZFPBoundFaction) ZFPLockAliasNPC51.GetActorRef().RemoveFromFaction(ZFPBoundFaction) EndIf If !ZFPLockAliasNPC51.GetActorRef().IsInFaction(ZFPLockedFaction) ZFPLockAliasNPC51.GetActorRef().AddToFaction(ZFPLockedFaction) EndIf BDSM_NPCAlias1.Clear() BDSMFurnitureAlias1.Clear() ZFPFurnitureUsed.SetValueInt(0) ZFPAlias1Filled.SetValueInt(0) ZFPFurnitureFilled1.SetValueInt(0) ZFPAliasGreeted.SetValueInt(0) ElseIf ZFPLockAliasNPC51.GetReference() == None Debug.Notification("ERROR WITH LOCK 51!") EndIf Return ZAP_8.0_Helper_Addon.rar
traison Posted June 21, 2024 Posted June 21, 2024 (edited) BDSM_NPCAlias1.GetActorRef() is None when passed to ZFPLockAliasNPC51.ForceRefTo(). Edit: Lots to clean up in this code in general, but it should still work. Wasteful perhaps, would be appropriate. Edited June 21, 2024 by traison
Gudulba Posted June 22, 2024 Author Posted June 22, 2024 I reset the mod with the according spells in-game, made a clean save and installed my edited version. Now I get a "ERROR WITH LOCK" already at NPC 6... Sigh... The "ERROR WITH LOCK 51" I got when I just installed my edited version over the original version. Double- and triple-checked the mod scripts and in SSEEdit and Creation Kit again, but I just don't see what's amiss...
traison Posted June 22, 2024 Posted June 22, 2024 (edited) 52 minutes ago, Gudulba said: I just don't see what's amiss... Whatever is supposed to set BDSM_NPCAlias1, is not doing it. Edit: Actually, looking at the original file. There's 11 THOUSAND lines in it that could probably be written in less than 100. I wouldn't build anything upon this file/mod. Switch over to using reference arrays and this all becomes a lot easier to do. As a bonus, it then probably won't choke your Papyrus engine performance either. Edit again: Also, looking at your modifications. You haven't assigned an alias to the new script properties. Edited June 22, 2024 by traison
traison Posted June 22, 2024 Posted June 22, 2024 (edited) Not compiled, not tested, not checked. Here's a more compact, easier to edit and manage ZFPFurnitureLockScript. Spoiler Scriptname ZFPFurnitureLockScript extends activemagiceffect Actor Property PlayerRef Auto KeyWord Property zbfFurniture Auto KeyWord Property ActorTypeNPC Auto Quest Property ZFPAliases Auto Faction Property ZFPLockedFaction Auto Faction Property ZFPBoundFaction Auto ReferenceAlias Property BDSM_NPCAlias1 Auto ReferenceAlias Property BDSM_NPCAlias2 Auto ReferenceAlias Property BDSM_NPCAlias3 Auto ReferenceAlias Property BDSM_NPCAlias4 Auto ReferenceAlias Property BDSM_NPCAlias5 Auto ReferenceAlias Property BDSM_NPCAlias6 Auto ReferenceAlias Property BDSM_NPCAlias7 Auto ReferenceAlias Property BDSM_NPCAlias8 Auto ReferenceAlias Property BDSM_NPCAlias9 Auto ReferenceAlias Property BDSM_NPCAlias10 Auto ReferenceAlias Property BDSMFurnitureAlias1 Auto ReferenceAlias Property BDSMFurnitureAlias2 Auto ReferenceAlias Property BDSMFurnitureAlias3 Auto ReferenceAlias Property BDSMFurnitureAlias4 Auto ReferenceAlias Property BDSMFurnitureAlias5 Auto ReferenceAlias Property BDSMFurnitureAlias6 Auto ReferenceAlias Property BDSMFurnitureAlias7 Auto ReferenceAlias Property BDSMFurnitureAlias8 Auto ReferenceAlias Property BDSMFurnitureAlias9 Auto ReferenceAlias Property BDSMFurnitureAlias10 Auto GlobalVariable Property ZFPFurnitureFilled10 Auto GlobalVariable Property ZFPFurnitureFilled9 Auto GlobalVariable Property ZFPFurnitureFilled8 Auto GlobalVariable Property ZFPFurnitureFilled7 Auto GlobalVariable Property ZFPFurnitureFilled6 Auto GlobalVariable Property ZFPFurnitureFilled5 Auto GlobalVariable Property ZFPFurnitureFilled4 Auto GlobalVariable Property ZFPFurnitureFilled3 Auto GlobalVariable Property ZFPFurnitureFilled2 Auto GlobalVariable Property ZFPFurnitureFilled1 Auto GlobalVariable Property ZFPAlias1Filled Auto GlobalVariable Property ZFPAlias2Filled Auto GlobalVariable Property ZFPAlias3Filled Auto GlobalVariable Property ZFPAlias4Filled Auto GlobalVariable Property ZFPAlias5Filled Auto GlobalVariable Property ZFPAlias6Filled Auto GlobalVariable Property ZFPAlias7Filled Auto GlobalVariable Property ZFPAlias8Filled Auto GlobalVariable Property ZFPAlias9Filled Auto GlobalVariable Property ZFPAlias10Filled Auto GlobalVariable Property ZFPFurnitureUsed Auto GlobalVariable Property ZFPFurnitureUsed2 Auto GlobalVariable Property ZFPFurnitureUsed3 Auto GlobalVariable Property ZFPFurnitureUsed4 Auto GlobalVariable Property ZFPFurnitureUsed5 Auto GlobalVariable Property ZFPFurnitureUsed6 Auto GlobalVariable Property ZFPFurnitureUsed7 Auto GlobalVariable Property ZFPFurnitureUsed8 Auto GlobalVariable Property ZFPFurnitureUsed9 Auto GlobalVariable Property ZFPFurnitureUsed10 Auto GlobalVariable Property ZFPAliasGreeted Auto Quest Property ZFPLock Auto ReferenceAlias[] Property ZFPLockAliasFurns Auto ReferenceAlias[] Property ZFPLockAliasNPCs Auto bool Function HasFreeLockSlot() int i = 0 While (i < ZFPLockAliasFurns.Length) If (ZFPLockAliasFurns[i].GetReference() == None) Return true EndIf If (ZFPLockAliasNPCs[i].GetReference() == None) Return true EndIf i += 1 EndWhile Return false EndFunction bool Function AllocateLock(ReferenceAlias npcRefAlias, ReferenceAlias furnRefAlias) int aliasMax = ZFPLockAliasFurns.Length int i = 0 Actor who = npcRefAlias.GetActorRef() If (who == None) Return false EndIf While (i < aliasMax) If (ZFPLockAliasFurns[i].GetReference() == None) ZFPLockAliasFurns[i].ForceRefTo(furnRefAlias.GetReference()) ZFPLockAliasNPCs[i].ForceRefTo(who) Debug.Notification("NPC " + i + "/" + aliasMax + " LOCKED!") If (who.IsInFaction(ZFPBoundFaction)) who.RemoveFromFaction(ZFPBoundFaction) EndIf If (!who.IsInFaction(ZFPLockedFaction)) who.AddToFaction(ZFPLockedFaction) EndIf npcRefAlias.Clear() furnRefAlias.Clear() ZFPFurnitureUsed.SetValueInt(0) ZFPAliasGreeted.SetValueInt(0) Return true EndIf i += 1 EndWhile Debug.Notification("ERROR AllocateLock failed for " + who + "!") Return false EndFunction Event OnEffectStart(Actor akTarget, Actor akCaster) If akCaster == PlayerRef If (!HasFreeLockSlot()) Debug.Notification("Error: All Locking Slots Full!") Return EndIf If (BDSM_NPCAlias1 == None) Return EndIf ObjectReference crosshairRef = Game.GetCurrentCrosshairRef() If (crosshairRef == None) Return EndIf If (crosshairRef.HasKeyword(ActorTypeNPC)) Debug.Notification("Locking Selection 1") If !ZFPLock.IsRunning() ZFPLock.SetStage(10) EndIf If (crosshairRef == BDSM_NPCAlias1.GetActorRef()) If (AllocateLock(BDSM_NPCAlias1, BDSMFurnitureAlias1)) ZFPAlias1Filled.SetValueInt(0) ZFPFurnitureFilled1.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias2.GetActorRef()) If (AllocateLock(BDSM_NPCAlias2, BDSMFurnitureAlias2)) ZFPAlias2Filled.SetValueInt(0) ZFPFurnitureFilled2.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias3.GetActorRef()) If (AllocateLock(BDSM_NPCAlias3, BDSMFurnitureAlias3)) ZFPAlias3Filled.SetValueInt(0) ZFPFurnitureFilled3.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias4.GetActorRef()) If (AllocateLock(BDSM_NPCAlias4, BDSMFurnitureAlias4)) ZFPAlias4Filled.SetValueInt(0) ZFPFurnitureFilled4.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias5.GetActorRef()) If (AllocateLock(BDSM_NPCAlias5, BDSMFurnitureAlias5)) ZFPAlias5Filled.SetValueInt(0) ZFPFurnitureFilled5.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias6.GetActorRef()) If (AllocateLock(BDSM_NPCAlias6, BDSMFurnitureAlias6)) ZFPAlias6Filled.SetValueInt(0) ZFPFurnitureFilled6.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias7.GetActorRef()) If (AllocateLock(BDSM_NPCAlias7, BDSMFurnitureAlias7)) ZFPAlias7Filled.SetValueInt(0) ZFPFurnitureFilled7.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias8.GetActorRef()) If (AllocateLock(BDSM_NPCAlias8, BDSMFurnitureAlias8)) ZFPAlias8Filled.SetValueInt(0) ZFPFurnitureFilled8.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias9.GetActorRef()) If (AllocateLock(BDSM_NPCAlias9, BDSMFurnitureAlias9)) ZFPAlias9Filled.SetValueInt(0) ZFPFurnitureFilled9.SetValueInt(0) EndIf ElseIf (crosshairRef == BDSM_NPCAlias10.GetActorRef()) If (AllocateLock(BDSM_NPCAlias10, BDSMFurnitureAlias10)) ZFPAlias10Filled.SetValueInt(0) ZFPFurnitureFilled10.SetValueInt(0) EndIf EndIf EndIf ;Debug.Notification("Error: Target must be an NPC restrained by ZFP!") EndIf EndEvent Add all quest aliases to the new alias arrays: ReferenceAlias[] Property ZFPLockAliasFurns Auto ReferenceAlias[] Property ZFPLockAliasNPCs Auto Edit: Fixed script, it compiles now. Edited June 22, 2024 by traison
Gudulba Posted June 22, 2024 Author Posted June 22, 2024 (edited) Awesome to work with someone who knows what he's doing! Honestly! I myself only copy, I don't really know what I am doing here... 🙂 From what I saw, of all the scripts, those three address the slots: ZFPFurnitureLockScript.psc and ZFPLockControlScript.psc and ZFPSelectLockNPCScript.psc. I guess your code would also have to be adapted to the other two scripts as well, I guess? Funny regarding the missing aliases on the script properties. I checked again in Creation Kit and they seem to be there. Unless I am looking at the wrong place. I have attached my edited mod again. Maybe in the first upload, it was an older version of mine. ZAP_8.0_Helper_Addon - Edited.rar Edited June 22, 2024 by Gudulba
traison Posted June 22, 2024 Posted June 22, 2024 2 hours ago, Gudulba said: I guess your code would also have to be adapted to the other two scripts as well, I guess? Have to? No. Could be? Yes. I definitely would rewrite those. When your Papyrus scripts start to rival simple x86 Operating Systems in number of lines you know you got a problem; especially when all those 11,000 lines do is assign 2 variables to another 2 variables depending on a few simple if statements. That is truly some unbelieveable code bloat.
Gudulba Posted June 26, 2024 Author Posted June 26, 2024 I have taken some time to study the ZFPFurnitureLockScript.psc code. It looks definitely nice and clean 🙂 However unfortunately, I am way over my head to adapt this structure to the other two scripts ZFPLockControlScript.psc and ZFPSelectLockNPCScript.psc. Also, I fail to understand what changes I have to make in Creation Kit to the Packages and Quest in regards to the new script. I have tried to understand what this would mean, but haven't found out yet...: Add all quest aliases to the new alias arrays: ReferenceAlias[] Property ZFPLockAliasFurns Auto ReferenceAlias[] Property ZFPLockAliasNPCs Auto
traison Posted June 26, 2024 Posted June 26, 2024 2 hours ago, Gudulba said: I have tried to understand what this would mean, but haven't found out yet...: The same way you add quest aliases to properties, you add quest aliases to property arrays. The difference is instead of having to check each property (in your case 10 times 100 checks per file) you can simply loop through them in a while loop: array[0 ... 100]. Its really no different looking on the CK side of things.
Gudulba Posted June 27, 2024 Author Posted June 27, 2024 (edited) I went to Quest / ZFPLock / Script Properties, but my screen looks different than yours: "Add Property" is greyed out, and the right side also looks different. Am I looking at the wrong place? I always only find the ZFPLockControlScript, while your screenshot shows the ZFPFurnitureLockScript. Spoiler Edited June 27, 2024 by Gudulba
traison Posted June 27, 2024 Posted June 27, 2024 The window title reveals where this is: Quote Properties for script ZFPFurnitureLockScript attached to ZFPNPCLock (03017D8A) ZFPNPCLock is a Magic Effect, attached to 03017D88 <ZFPFurnitureNPCLockSpell>. Also if you're using my script, the window contents will look different because I already removed the hundereds of properties that are no longer needed. Searching through the entire plugin, this is where your problematic scripts are used: ZFPFurnitureLockScript ------------------------------------------------------------ \ [03] ZAPFurniturePlacer.esp \ [3] GRUP Top "MGEF" \ [0] ZFPNPCLock "Locks the Targeted NPC (Must be restrained) and clears the ZFP Selection" [MGEF:03017D8A] ZFPLockControlScript ------------------------------------------------------------ \ [03] ZAPFurniturePlacer.esp \ [6] GRUP Top "QUST" \ [2] ZFPLock "Container for ZFP Locked NPC Slots" [QUST:03019893] ZFPSelectLockNPCScript ------------------------------------------------------------ \ [03] ZAPFurniturePlacer.esp \ [3] GRUP Top "MGEF" \ [9] ZFPNPCSelectLock "Cast at zbfFurniture and then an NPC to instantly lock them to that Furniture" [MGEF:0301A8F6]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now