[HOWTO] How To: Generate Quests About Entities Not In Current Scene

Announcements, support questions, and discussion for Quest Machine.
Post Reply
User avatar
Tony Li
Posts: 22098
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Generate Quests About Entities Not In Current Scene

Post by Tony Li »

Someone on discord asked how to procedurally generate quests about entities that aren't in the current scene. For example, say the NPC is in a space station scene, but he wants the player to mine ore from an asteroid belt scene. This is a brief summary of how to set it up:

When the quest generator generates a quest, it creates a "world model," which is its understanding of what's in the world. To create the world model, it first checks all of its quest domains. In this case, the space station scene won't have a quest domain for the asteroid belt since it's in a separate scene. After checking quest domains, it calls a custom QuestGeneratorEntity.updateWorldModel method if assigned. You can use this method to add more info to the world model that isn't represented by the current scene's quest domains. Try this:
  • I assume from your description that the quest generator NPC is not in the asteroid belt scene. Remove the quest domain from the NPC's scene.
  • Add a script to the NPC that has these methods:

    Code: Select all

    public DomainType asteroidBelt; // <-- ASSIGN THESE IN INSPECTOR
    public EntityType ore;
    
    void Start()
    {
        GetComponent<QuestGeneratorEntity>().updateWorldModel += UpdateWorldModel;
    }
    
    void UpdateWorldModel(WorldModel worldModel)
    {
        // Add a fact to the world model that says the AsteroidBelt domain contains 300 ore:
        worldModel.AddFact(new Fact(asteroidBelt, ore, 300));
    }
Post Reply