Jump to content

Recommended Posts

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:

 

  1. Approach is initiated - This could be a combat surrender, friendly NPC approach, etc.
  2. Approachers are identified - Actors are identified based on the approach type (Combatants/Lovers/Citizens/etc.)
  3. *Random Quest is selected - Based on the actor selection and the approach type, a quest would be randomly selected from an array.
  4. 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:

 

image.png.5019429038c52cc6f0ad62529b454cf0.png

 

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!

Link to comment

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.

Link to comment

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

image.png.bc72122b110ff63dee6b8d5583a739b3.png

Quest Stages

image.png.e3ff5ac3764fe32997e5cf51cfa44ccd.png

 

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!

Link to comment
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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use