Custom Quest Actions
-
- Posts: 178
- Joined: Fri Sep 21, 2018 8:38 pm
Custom Quest Actions
Hi,
I'm coding my own Quest Actions and Conditions to communicate with my scripts. I've done 4 so far and work great.
But one thing that I want to do also on those Quest Action is to write into the Dialogue Text, Journal and HUD, so I can do it populating data from the code.
How do I call them from the Quest Action? I don't find how to do it and what classes to use it (there are son many
Thanks,
I'm coding my own Quest Actions and Conditions to communicate with my scripts. I've done 4 so far and work great.
But one thing that I want to do also on those Quest Action is to write into the Dialogue Text, Journal and HUD, so I can do it populating data from the code.
How do I call them from the Quest Action? I don't find how to do it and what classes to use it (there are son many
Thanks,
Re: Custom Quest Actions
Can you give me an example of data and how you want it to appear in the UIs?
-
- Posts: 178
- Joined: Fri Sep 21, 2018 8:38 pm
Re: Custom Quest Actions
Yes sure,
What I want is the following:
In Active State Node I use my own Custom Quest Action, for instance to communicate with my chest and send "Active" state so the chest shows up in scene with the HUD activated and the trigger activated so the player can open it.
What I want it's try to avoid to write on every node as less as possible, so I'd love to have on this custom Quest Action access to the HUD and Journal and show for example: "Now go to find the chest". What I want is to be able to write this from my custom Quest Action script instead than from the Quest Machine Node Editor (I don't want to fill all info manually in the active state for Hud, Journal, Notifications, etc... as it's quite time consuming for long quests....
Same for my own Custom Quest Condition, where I'd love to have on this custom Quest Condition access to the HUD and Journal and show for example: "Chest Opened!... "
I have tried to access from code to Hud and Journal and I don't find how to do it...
Thanks
What I want is the following:
In Active State Node I use my own Custom Quest Action, for instance to communicate with my chest and send "Active" state so the chest shows up in scene with the HUD activated and the trigger activated so the player can open it.
What I want it's try to avoid to write on every node as less as possible, so I'd love to have on this custom Quest Action access to the HUD and Journal and show for example: "Now go to find the chest". What I want is to be able to write this from my custom Quest Action script instead than from the Quest Machine Node Editor (I don't want to fill all info manually in the active state for Hud, Journal, Notifications, etc... as it's quite time consuming for long quests....
Same for my own Custom Quest Condition, where I'd love to have on this custom Quest Condition access to the HUD and Journal and show for example: "Chest Opened!... "
I have tried to access from code to Hud and Journal and I don't find how to do it...
Thanks
Re: Custom Quest Actions
That's not the way Quest Machine is designed. You can do this for alerts, but not for the HUD or Journal.
When Quest Machine updates the HUD or Journal, it collects all of the UI content for the current state. And that's all it shows.
You could make a subclass of UnityUIQuestHUD and override the RefreshNow() or AddContent() method to add more to the UIs, but it would be complicated.
It might be better if I make it easier to fill in UI content. What features would make it easier for you to fill in the UI content?
When Quest Machine updates the HUD or Journal, it collects all of the UI content for the current state. And that's all it shows.
You could make a subclass of UnityUIQuestHUD and override the RefreshNow() or AddContent() method to add more to the UIs, but it would be complicated.
It might be better if I make it easier to fill in UI content. What features would make it easier for you to fill in the UI content?
-
- Posts: 178
- Joined: Fri Sep 21, 2018 8:38 pm
Re: Custom Quest Actions
Ok, and is there any chance to update the UI content from code? Just in the state where the action and Condition Chest script is located?
Re: Custom Quest Actions
Yes. You can do that. You will need to find the right instance of the quest. If it's on the player and you have a reference to the player's QuestJournal, use QuestJournal.FindQuest(). For example:GorkaGames wrote: ↑Tue Feb 19, 2019 11:48 am Ok, and is there any chance to update the UI content from code? Just in the state where the action and Condition Chest script is located?
Code: Select all
var quest = questJournal.FindQuest("Chest Quest");
If you need to add UI content to a specific node, call Quest.GetNode():
Code: Select all
var node = quest.GetNode("Find Chest");
Code: Select all
var stateInfo = node.GetStateInfo(QuestNodeState.Active);
Code: Select all
var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD);
Code: Select all
var content = BodyTextQuestContent.CreateInstance<BodyTextQuestContent>();
content.bodyText = new StringField("Now go find the chest.);
hudContentList.Add(content);
Code: Select all
QuestMachineMessages.RefreshUIs(this);
-
- Posts: 178
- Joined: Fri Sep 21, 2018 8:38 pm
Re: Custom Quest Actions
This looks great and I'm going to check it out right now.
But for being 100% automatic and not relaying on quest and node's names, is there a way to know on which Quest and Node am I located when I write the code from the Action or Condition Quest Script?
I mean if the Action or Condition Quest Script is called from Quest (x) and Node (x), I guess the Action or Condition Quest Script can know witch Quest and Node is the actual...
But for being 100% automatic and not relaying on quest and node's names, is there a way to know on which Quest and Node am I located when I write the code from the Action or Condition Quest Script?
I mean if the Action or Condition Quest Script is called from Quest (x) and Node (x), I guess the Action or Condition Quest Script can know witch Quest and Node is the actual...
Re: Custom Quest Actions
Yes. Every QuestAction has quest and questNode properties.
-
- Posts: 178
- Joined: Fri Sep 21, 2018 8:38 pm
Re: Custom Quest Actions
This is great, testing now.
Is it any way to access the also the counters? Actual and Max values?
Is it any way to access the also the counters? Actual and Max values?
Re: Custom Quest Actions
Yes, use Quest.GetCounter(). Example:
Code: Select all
var carrotsCounter = quest.GetCounter("carrots");