Skip to main content

Quests

Quests manage anything concerning a players quest progress. Besides the logic-handling & UI scripts, Quest objects function similarly to Skill objects - objects that live throughout a players session with pre-defined methods inherited from QuestBase. Quest objects are also replicated to the client for QuestFX - which allows for easy, modular two-way communication between the client and server.

Relevant Files​

Client​

  • Quest UI - src\StarterPlayer\StarterCharacterScripts\HUD\UI\Quests.lua
  • Quest FX - src\StarterPlayer\StarterPlayerScripts\VFX\QuestFXHandler.client.lua
  • Quest FX folder - src\ReplicatedStorage\Modules\Quests\QuestFX
  • Quest FX template - src\ReplicatedStorage\Modules\Quests\QuestFX\Client_QuestTemplate.lua

Server​

  • Server quest main logic - src\ServerStorage\Modules\Quests\QuestModule.lua
    • Quest utils - src\ServerStorage\Modules\Quests\QuestUtils.lua
    • Quest folder - src\ServerStorage\Modules\Quests\QuestHandlers
    • Quest template - src\ServerStorage\Modules\Quests\QuestHandlers\Server_QuestTemplate.lua
  • Quest replication - src\ServerStorage\Modules\Replication\QuestFXModule.lua

Shared​

  • Base for Quest objects - src\ReplicatedStorage\Modules\DataStructures\QuestBase.lua

Data​

  • API data - src\ReplicatedStorage\Modules\Quests\QuestAPI

Minimum Requirements for Adding a Quest​

  • A Server_QuestName file in the src\ServerStorage\Modules\Quests\QuestHandlers folder, copied from the server Server_QuestTemplate file.
  • A Client_QuestName file in the src\ReplicatedStorage\Modules\Quests\QuestFX folder, copied from the client Client_QuestTemplate file.
  • (If there are any methods with non-zero parameters) An API_QuestName file in the src\ReplicatedStorage\Modules\Quests\QuestAPI folder.

Quest API​

To minimize the data size for replicating quest data to the client & reduce ping, every Quest:Fire[...] method call must have API data. This data is stored in the src\ReplicatedStorage\Modules\Quests\QuestAPI folder, and lets the client know what the parameters are for each method call. The t module is used to set each parameter's type, and each method table has a dictionary & array of the parameters. The dictionary is used to check if the parameters are valid, and the array determines the order of the parameters. Example:

return {
ExampleMethod = {
Origin = t.Vector3,
HitCharacter = t.Model,
"Origin",
"HitCharacter",
}
}

Quest Status Replication​

In addition to manual replication through the Quest object Fire[...] methods, automatic replication occurs when a quest's goal is updated. The server fires the QuestStatus remote to the client with the new goal data. The client then updates the UI accordingly.

Quest FX​

Like Skills, QuestFX objects are automatically created along with the server. The non-yieldable QuestFX:Start method is called, erroring upon yield.

Since the server-side Quest:Destroy method is meant to handle the internal cleanup of the Quest objects data, when the server replicates a Quest:Destroy method call to the client, the client will call QuestFX:Cancel instead. This method is meant to add additional cleanup logic for the client-side QuestFX object, and must also call QuestFX:Destroy thereafter.