I felt like telling someone about my new random quest engine, and I chose you because – who else might be interested?
About 13 years ago, CoffeeMud got a questing engine, and a Quest Maker to allow builders to fill out a few gui fields and create new quests based on one of several dozen templates. Two years later, CoffeeMud also got a random areas generator. Nothing beats real builder-designed area, of course, but the ability to generate random areas based on some trivial criteria was extremely useful in filling game gaps while awaiting real builder attention.
Since then, aside from adding a few more themes to each, both features have sat fairly dormant.
Lately, however, I've felt like the grind needed a bit more color, and that's where random quests come in. Instead of simply exploring and killing, why not have a reason to explore and kill, with some prize for completing the goals? –Especially in random areas or areas lacking builder attention!
For the implementation, I started with the random area generator (RAG). After all, it has the ability to generate strings to serve as room descriptions, and a Quest script isn't too far from that. Then I decided to merge the idea with the templates used by the Quest Maker. Now the RAG doesn't even have to generate the whole quest script, it can just fill in those empty boxes just like a builder would! The boxes are things like the name of the Area to use, the mob who would act as quest giver, the dialog said by the quest giver, etc.
This plan works great for randomly generated areas, since the RAG engine can create its own quest givers, create its own target items or mobs, then choose the activity/template to use, and proceed. However, that still left one gap: what about random quests for existing world areas? For that, the RAG engine fell short: it's great for creating new mobs and items and rooms, but has absolutely no capacity for interacting with the existing world. For that, I extended the engine to allow a Query of the world to substitute, when necessary, for creating new things.
If the random quest needs a quest giver, the RAG can make you one of course, but if the template can handle it, the RAG should be able to query for an existing one that meets the needed criteria. The RAG already knows how to build on top of previous choices very well e.g. if an Area was already chosen, the quest giver will come from that area, but if a quest giver was already chosen, the Area will be the his area, and so forth.
The RAG uses XML as a basis for generating new things, where XML tag names and parameters stand in for properties you want to define on different objects being created. However, this language is ill suited for queries. For those, I allowed an XML tag to set its value based on a query string I call MQL, which looks a lot like SQL. For example, the XML tag that queries for an appropriate area looks like this:
<OBJECT define="source_area"> SELECT: ANY\. FROM areas WHERE (SELECT: count\. from area\mobs WHERE name\count =1 and intelligence>8) > 0 AND (SELECT:count\. from area\mobs WHERE name\count >$num_targets) > 0 </OBJECT>
This query is for a Capture template quest, where a mob wants X other mobs captured. The query makes sure that the area it chooses as at least one mob with a unique name to be a quest giver, and at least X mobs with the same names to serve as the capturables.
So! Once all this was put together, I generated my first random world quest, set it to expire after an hour, and ran through it to make sure it works. I think stuff like this will not only make randomly generated areas more interesting, but the existing world areas as well. And since the dialog and rationales are also random, I'm sure it will provide lots of absurdity and humor as well.