ahab5920 Posted June 22, 2021 Posted June 22, 2021 Hello, I'm having some trouble with a mod I'm creating. The issue is Quest/Array/Property related but here's some background first: I'm trying to create a system for handling approaches (similar to AAF Sexual Harassment) but I'm trying to implement a system that uses Quests to handle approach scenarios. Effectively the system would process like this: Approach is initiated - This could be a combat surrender, friendly NPC approach, etc. Approachers are identified - Actors are identified based on the approach type (Combatants/Lovers/Citizens/etc.) *Random Quest is selected - Based on the actor selection and the approach type, a quest would be randomly selected from an array. Quest is run - The quest runs with any dialog/scripts/scenes/etc that is coded into it. So my problem is with the array of quests in step 3. The array doesn't seem to be functioning as I'd expect it. In my papyrus I have 4 properties that align with the different approach scenarios that will be available: Group ApproachQuests Quest[] Property VM_CitizenApproaches auto Quest[] Property VM_GuardApproaches auto Quest[] Property VM_CombatApproaches auto Quest[] Property VM_LoverApporaches auto EndGroup These properties are filled with pre-constructed quests (I only have one right now) in Creation Kit: The papyrus script then loops through the list of Quests based on the type set when the approach was initiated (VM_ApproachType): Function StartQuest() VM_Debug("Starting Quest Scene") If VM_ApproachType == "Lover" ElseIf VM_ApproachType == "Citizen" ; Get Quest Int QuestIndex = Utility.RandomInt(0, VM_CitizenApproaches.Length-1) VM_Debug("Quest Index: " + QuestIndex) Quest ActiveQuest = VM_CitizenApproaches[QuestIndex] If !ActiveQuest.IsRunning() ActiveQuest.Start() EndIf ActiveQuest.Reset() ActiveQuest.SetStage(10) ElseIf VM_ApproachType == "Guard" ElseIf VM_ApproachType == "Combat" EndIf EndFunction When trying to debug the approach it gives this response: error: Cannot access an element of a None array stack: [VM_Main (1D004C50)].VM:VM_Approaches.StartQuest() - "<unknown file>" Line ? [VM_Main (1D004C50)].VM:VM_Approaches.StartApproach() - "<unknown file>" Line ? [VM_Main (1D004C50)].vm:vm_scenes.DebugApproachStart() - "<unknown file>" Line ? [VM_Main (1D004C50)].vm:vm_scenes.OnKeyUp() - "<unknown file>" Line ? Based on this response, it leads me to believe it's an issue with the array being filled. as the Quest Index is returning -1. I have no clue what I'm doing wrong here so any insight on this would be greatly appreciated! Also, let me know if more information would be useful and I can provide it. Thanks!
EgoBallistic Posted June 22, 2021 Posted June 22, 2021 Your Quest[] properties are defined as auto and not auto const. Once the value of a non-const property is set in your save, the value in the save overrides any changes you make to that property's value in the editor. I suspect what happened is you defined those properties, started the game just to test, then went back into the CK and filled that property. But, the value of VM_CitizenApproaches was set to None and now it won't change unless you set it explicitly in the script. Change those to auto const properties, then stop and start the quest, and it should work as expected. You'll need to recompile the script, then open the quest's properties again in the CK so that everything is in synch.
ahab5920 Posted June 22, 2021 Author Posted June 22, 2021 Thanks! That fixed the Array issue. Seems its staying filled now. I'm now struggling to get the quest to start/stop/reset. I'm not sure I completely understand how quests work despite reading the documentation and following a few online video guides. Here's the basic data for the approach quest in Creation Kit: Quest Data Quest Stages I have a script attached to the quest that looks like this: Event OnStageSet(int auiStageID, int auiItemID) VM_Main.VM_Debug("Stage: " + auiStageID) If auiStageID == 10 Host = VM_Approaches.VM_Host Partners = VM_Approaches.VM_Partners ActiveActors = New Actor[0] ActiveActors.Add(Host) Int i = 0 While i < Partners.Length Actor Partner = Partners[i] ActiveActors.Add(Partner) i += 1 EndWhile VM_Scenes.StartScene(ActiveActors,false) RegisterForCustomEvent(AAF_API, "OnAnimationStop") ElseIf auiStageID == 100 ; Stop() ; Reset() EndIf EndEvent Event AAF:AAF_API.OnAnimationStop(AAF:AAF_API akSender, Var[] akArgs) SetStage(100) EndEvent My understanding is that the quest is initiated when the game is loaded (regardless of if the quest is active). The quest then can be started (Quest.Start()) which sets the quest to stage 0. You can then run SetStage(int) to set stages. Any ideas on what I'm doing wrong here? Thanks!
EgoBallistic Posted June 22, 2021 Posted June 22, 2021 2 hours ago, ahab5920 said: My understanding is that the quest is initiated when the game is loaded (regardless of if the quest is active). The quest then can be started (Quest.Start()) which sets the quest to stage 0. You can then run SetStage(int) to set stages. You can't Reset() a quest that isn't running. You have to Reset() first, then call Stop(). You should also check "Allow Repeated Stages", otherwise SetStage() won't do anything after the first time it is called for a particular stage number.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.