# \[New Wiki\] Quest Framework in C++

**URL:** <https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [February 25, 2016, 6:39pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468 "2016-02-25T18:39:59Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![smartyMARTY](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smartymarty/32/678332_2.png) [@smartyMARTY](https://forums.unrealengine.com/u/smartyMARTY)\
**Post date:** [February 25, 2016, 6:39pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/1 "2016-02-25T18:39:59Z")

</div>

Hey everyone! I haven’t seen much about it and I know there are several people who would like to learn it, so I made a new Wiki entry about creating a Quest/Objective Framework in C++ for UE4.

[Here is the link to the wiki (so you can mess it all up :P)](https://wiki.unrealengine.com/Quest_Framework)  
[Here is a link to the original content](http://enjoy-game-programming.blogspot.com/2016/02/unreal-engine-4-quest-framework-c-part-1.html)

If there is enough traction, I can continue on with a second part that shows how to design the current code to use nested sub-quests and nested sub-objectives.

---

<div class="post-metadata">

**Author:** ![HInoue](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HInoue](https://forums.unrealengine.com/u/HInoue)\
**Post date:** [February 26, 2016, 1:33am UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/2 "2016-02-26T01:33:29Z")

</div>

Quick question; as-is, the code doesn’t compile out of the box because Quest’s declaration tries to call some method GetCompletion() in Objective. Did you possibly mean to call GetProgress() there?

---

<div class="post-metadata">

**Author:** ![smartyMARTY](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smartymarty/32/678332_2.png) [@smartyMARTY](https://forums.unrealengine.com/u/smartyMARTY)\
**Post date:** [February 26, 2016, 1:03pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/3 "2016-02-26T13:03:46Z")

</div>

> [@HInoue;481585](#):
>
> Quick question; as-is, the code doesn’t compile out of the box because Quest’s declaration tries to call some method GetCompletion() in Objective. Did you possibly mean to call GetProgress() there?

Yes I did. Thank you for that. I am sure that happened after I re factored it for the tutorial.

---

<div class="post-metadata">

**Author:** ![smartyMARTY](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smartymarty/32/678332_2.png) [@smartyMARTY](https://forums.unrealengine.com/u/smartyMARTY)\
**Post date:** [February 26, 2016, 1:53pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/4 "2016-02-26T13:53:33Z")

</div>

It is fixed now

---

<div class="post-metadata">

**Author:** ![MatzeOGH](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MatzeOGH](https://forums.unrealengine.com/u/MatzeOGH)\
**Post date:** [February 26, 2016, 6:05pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/5 "2016-02-26T18:05:58Z")

</div>

Any reason why you inherited from AInfo

---

<div class="post-metadata">

**Author:** ![smartyMARTY](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smartymarty/32/678332_2.png) [@smartyMARTY](https://forums.unrealengine.com/u/smartyMARTY)\
**Post date:** [February 26, 2016, 8:44pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/6 "2016-02-26T20:44:35Z")

</div>

> [@MatzeOGH;481964](#):
>
> Any reason why you inherited from AInfo

Standards. I originally had it inherited from AActor. However, AInfo is a more appropriate class to inherit from in this case.

> [@](#):
>
> Info, the root of all information holding classes. Doesn’t have any movement / collision related code. Info is the base class of an Actor that isn’t meant to have a physical representation in the world, used primarily for “manager” type classes that hold settings data about the world, but might need to be an Actor for replication purposes.

[Quoted from the Remarks section of the API]  
([AInfo | Unreal Engine 5.2 Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AInfo/index.html))

I figured that since it was a class with some management code, metadata, and had no purpose having collision or movement without getting into game implementation, it was appropriate. In fact, if I remember, there may be a section in the Wiki explaining why I chose AInfo.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [February 26, 2016, 8:44pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/7 "2016-02-26T20:44:37Z")

</div>

> [@MatzeOGH;481964](#):
>
> Any reason why you inherited from AInfo

Yeah, good question. Why don’t you inherit from UObjects? Is there a need for the questions and objectives to be spawned in the world?  
Otherwise, for just plain data, you could/should use UObject children.

---

<div class="post-metadata">

**Author:** ![MatzeOGH](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MatzeOGH](https://forums.unrealengine.com/u/MatzeOGH)\
**Post date:** [February 26, 2016, 9:10pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/8 "2016-02-26T21:10:14Z")

</div>

I would have chosen UObject too, I don’t see any reason to pay the overhead of an actor.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [February 26, 2016, 10:36pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/9 "2016-02-26T22:36:42Z")

</div>

Also, if it’s really plain data that doesn’t change or needs to be unique per instance, you could have a look at “UDataAsset”.  
It’s similar to, for example, texture, where you reference them and then you can use the data you saved.

I use that for recipes in a crafting system for example.

---

<div class="post-metadata">

**Author:** ![smartyMARTY](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smartymarty/32/678332_2.png) [@smartyMARTY](https://forums.unrealengine.com/u/smartyMARTY)\
**Post date:** [February 27, 2016, 5:15am UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/10 "2016-02-27T05:15:49Z")

</div>

> [@eXi;482161](#):
>
> Also, if it’s really plain data that doesn’t change or needs to be unique per instance, you could have a look at “UDataAsset”.  
> It’s similar to, for example, texture, where you reference them and then you can use the data you saved.
> 
> I use that for recipes in a crafting system for example.

I agree, pure data would justify using UDataAsset, or even a FTableRowBase parent. However, mentioned in the tutorial, this offers the option in the framework to add quest specific game play code that effects the level. This would be similar to something like AGameMode.

---

<div class="post-metadata">

**Author:** ![MatzeOGH](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MatzeOGH](https://forums.unrealengine.com/u/MatzeOGH)\
**Post date:** [February 27, 2016, 1:21pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/11 "2016-02-27T13:21:56Z")

</div>

I personally would have chosen an UObject and implemented the GetWorld() method to get a valid UWorld.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [February 27, 2016, 1:56pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/12 "2016-02-27T13:56:34Z")

</div>

> [@smartyMARTY;482327](#):
>
> I agree, pure data would justify using UDataAsset, or even a FTableRowBase parent. However, mentioned in the tutorial, this offers the option in the framework to add quest specific game play code that effects the level. This would be similar to something like AGameMode.

Yo, that was more a general information 😃 sorry. I tend to always give out some extra information for people reading this.

---

<div class="post-metadata">

**Author:** ![smartyMARTY](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smartymarty/32/678332_2.png) [@smartyMARTY](https://forums.unrealengine.com/u/smartyMARTY)\
**Post date:** [February 29, 2016, 3:14pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/13 "2016-02-29T15:14:53Z")

</div>

> [@eXi;482454](#):
>
> Yo, that was more a general information 😃 sorry. I tend to always give out some extra information for people reading this.

Hey, ya - information is always good. I figured using something simple would be good for a beginner tutorial. Thank you for the input 😃

---

<div class="post-metadata">

**Author:** ![smartyMARTY](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smartymarty/32/678332_2.png) [@smartyMARTY](https://forums.unrealengine.com/u/smartyMARTY)\
**Post date:** [February 29, 2016, 3:29pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/14 "2016-02-29T15:29:40Z")

</div>

> [@MatzeOGH;482449](#):
>
> I personally would have chosen an UObject and implemented the GetWorld() method to get a valid UWorld.

Can you explain that a little more? I am a bit confused as to what you are referencing in regards to that. Are you saying you would have overridden the GetWorld() method? Because in the API docs, [UObject](https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UObject/UObject/index.html) does not define GetWorld(). It is defined in [AActor](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/index.html).

---

<div class="post-metadata">

**Author:** ![MatzeOGH](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MatzeOGH](https://forums.unrealengine.com/u/MatzeOGH)\
**Post date:** [February 29, 2016, 6:32pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/15 "2016-02-29T18:32:15Z")

</div>

I was thinking of making UObjective blueprintable so you can implement the logic with blueprints. But for that to work the blueprint needs a way of getting UWorld;  
something like:

return OwningQuest-\>GetWorld();  
or  
return Outer-\>GetWorld(); //this only works if outer implements GetWorld()

In the end it is completly irrelevant if you are using Actos for everything. It’s probably even better if you like to network your quest system

---

<div class="post-metadata">

**Author:** ![HInoue](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HInoue](https://forums.unrealengine.com/u/HInoue)\
**Post date:** [March 14, 2016, 11:49pm UTC](https://forums.unrealengine.com/t/new-wiki-quest-framework-in-c/56468/16 "2016-03-14T23:49:45Z")

</div>

I’ve had a lot of success doing something similiar with UDataAsset. I originally tried to accomplish this with structs, since it felt silly to bring something from UObject in just to store a couple of logical rules (e.g. “resolve to finished if you’ve killed _n_ monsters”), but I simply couldn’t find a way to make this logic work without overridable functions and casting. Can you guys think of any reason _not_ to do it that way? I keep worrying that I’ve somehow created a behemoth that will quietly eat all of my memory, then rear out of the water when I’ve written the rest of the system and require me to refactor everything.
