Procedural generator - Generating more than one quest
Procedural generator - Generating more than one quest
Hello,
As my project might've been a bit different(and maybe more complex) I finally set everything up and everything is working except for the procedural generator generating more than one quest. Now the main idea of my procedural quests are that you can undermine or help opposing or friendly factions. As you are part of just one faction the generator successfully generates a quest to i.e. attack some members of an opposing factions(faction in this scenario are both faction and entity type, where each action you can take for that faction is done on that faction entity type). And that's it. No more quests after that. What I would want is to have the same quest(action) after some time but in the meantime I would like the generator to generate more quests to be done to the same faction and other actions which can be done to other factions. Is this somehow doable out of the box or I would have to change some code, and which one?
P.S. I have a custom urgency function which calculates urgency based on the absolute value of the relationship between factions, don't know if that's important or not.
As my project might've been a bit different(and maybe more complex) I finally set everything up and everything is working except for the procedural generator generating more than one quest. Now the main idea of my procedural quests are that you can undermine or help opposing or friendly factions. As you are part of just one faction the generator successfully generates a quest to i.e. attack some members of an opposing factions(faction in this scenario are both faction and entity type, where each action you can take for that faction is done on that faction entity type). And that's it. No more quests after that. What I would want is to have the same quest(action) after some time but in the meantime I would like the generator to generate more quests to be done to the same faction and other actions which can be done to other factions. Is this somehow doable out of the box or I would have to change some code, and which one?
P.S. I have a custom urgency function which calculates urgency based on the absolute value of the relationship between factions, don't know if that's important or not.
Re: Procedural generator - Generating more than one quest
Hi,
Sure, that's no problem. Set the Quest Generator Entity's Max Quests To Generate to a higher value. Then call QuestGeneratorEntity.GenerateQuest(). You can hook this up in a UnityEvent; you don't have to write any code. If the quest giver has fewer than Max Quests To Generate, it will generate a new quest.
To see an example, play the Demo scene. Inspect the Knight. Set Max Quests To Generate to 3. Then click the Generate Quest button a few times. You will see that the Knight adds new quests to its Quest Giver's Quests list.
Sure, that's no problem. Set the Quest Generator Entity's Max Quests To Generate to a higher value. Then call QuestGeneratorEntity.GenerateQuest(). You can hook this up in a UnityEvent; you don't have to write any code. If the quest giver has fewer than Max Quests To Generate, it will generate a new quest.
To see an example, play the Demo scene. Inspect the Knight. Set Max Quests To Generate to 3. Then click the Generate Quest button a few times. You will see that the Knight adds new quests to its Quest Giver's Quests list.
Re: Procedural generator - Generating more than one quest
Thank you, that works.
Just a bit of feedback I think you can make it clearer, since I though the quest generation would periodically generate new quests based on the number of max quests. Just my two cents .
Just a bit of feedback I think you can make it clearer, since I though the quest generation would periodically generate new quests based on the number of max quests. Just my two cents .
Re: Procedural generator - Generating more than one quest
Thanks for pointing that out. I'll clarify that in the manual and the Quest Generator Entity inspector. To keep CPU utilization to a minimum, it only generates one quest at start, and only if the Generate At Start checkbox is ticked. If the player talks to the quest giver and the quest giver doesn't have a quest, it will try to generate one before starting the dialogue. Other than that, it only generates additional quests on demand, such as by calling QuestGeneratorEntity.GenerateQuest.
Re: Procedural generator - Generating more than one quest
Hey,
Yeah, I understand your reasoning, I just had a different idea.
Anyways, after I made changes to my code, and added a code to generate max possible quests on button click(basically my game has no 2d/3d characters, all characters are buttons on a menu ). And one big problem started showing up, although the generation works fine, on quest state change gets called numerous times for the same state, i.e. currently on active I add some interactable objects/enemies to my custom object pools and like 12 objects are added when 4 where spawned before(the value needed to be spawn). And I think the times state change gets called is based on the number of quests available(and I've added some code to add some random value to the motive choosing, aka the choose goal method so to have multiple options not just the same quest different entity). I think that on quest generated listener somehow adds multiple state change listeners but not sure what to do to prevent that. Tested with checking whether the quest isn't in journal and some other checks too, didn't help, tested it with nothing changed from your packages still the same.. Is there something I misunderstand again or the error is on my part of the code?
Thank you in advance.
Yeah, I understand your reasoning, I just had a different idea.
Anyways, after I made changes to my code, and added a code to generate max possible quests on button click(basically my game has no 2d/3d characters, all characters are buttons on a menu ). And one big problem started showing up, although the generation works fine, on quest state change gets called numerous times for the same state, i.e. currently on active I add some interactable objects/enemies to my custom object pools and like 12 objects are added when 4 where spawned before(the value needed to be spawn). And I think the times state change gets called is based on the number of quests available(and I've added some code to add some random value to the motive choosing, aka the choose goal method so to have multiple options not just the same quest different entity). I think that on quest generated listener somehow adds multiple state change listeners but not sure what to do to prevent that. Tested with checking whether the quest isn't in journal and some other checks too, didn't help, tested it with nothing changed from your packages still the same.. Is there something I misunderstand again or the error is on my part of the code?
Thank you in advance.
Re: Procedural generator - Generating more than one quest
Hi,
The "Quest State Changed" message is sent whenever a quest or one of its nodes changes its state. (Or when it first sets its initial state.) If you have a quest with 3 nodes, then it may send up to 4 messages: 1 for the quest and 3 for the nodes.
When you receive the message, you can check the MessageArgs.
The "Quest State Changed" message is sent whenever a quest or one of its nodes changes its state. (Or when it first sets its initial state.) If you have a quest with 3 nodes, then it may send up to 4 messages: 1 for the quest and 3 for the nodes.
When you receive the message, you can check the MessageArgs.
- MessageArgs.parameter is the quest ID.
- values[0] is the quest node ID (a StringField type), or blank for the main quest.
- values[1] is the new state (a QuestState or QuestNodeState type).
Re: Procedural generator - Generating more than one quest
Sorry, I should've been more clear, I am not talking about the message, I am talking about the stateChanged delegate on the Quest class. Knowing that there is another delegate for a quest node idk if the problem is that.
Re: Procedural generator - Generating more than one quest
It may help to temporarily tick the Quest Machine GameObject's Debug checkbox. This will log info like:
Quest Machine: quest.SetState(newState)
which will give you information about what quests it's setting, and to what states.
If you get stuck, feel free to send a reproduction project to tony (at) pixelcrushers.com.
Quest Machine: quest.SetState(newState)
which will give you information about what quests it's setting, and to what states.
If you get stuck, feel free to send a reproduction project to tony (at) pixelcrushers.com.
Re: Procedural generator - Generating more than one quest
Yeah, I understand, I too thought sending you a project was the best way, but as I am going on a vacation the next week, I really wont have time to make it as a separate project. I just don't understand nothing else gets called numerous times for the same quest neither in the debug the setstate call neither questGenerated delegate, just the state changed one, and no there are no loops anywhere I checked . Thank you anyways, I might send you a project in the future if I don't manage to fix it.
Re: Procedural generator - Generating more than one quest
Okay, I'll be here to help when you get back. Have a nice vacation!