21 December 2015

Treasure

As I mentioned in the last post, I am trying to make as much of the game data-driven as possible. Treasures are a good case in point.

King of Dragon Pass has 133 treasures in the latest version. The exact number matters for saved games (in other words, adding treasures changes the file format). Each treasure has specific code somewhere in the code to implement it — sometimes more than once, to handle battle treasures, source, or reference. This is of course a lot of code to write and test, and it makes it difficult to add treasures. We can do better.

Six Ages has the advantage of being the second time we’ve done this. The treasures are fairly similar in behavior to KoDP, with effects like

.mood+=3 on any Hunting win
+1 on tests vs Skepticism
characters gain +1 on Magic and Diplomacy tests where the player chose them as testee
increase q by 1 on any win vs. Duel
heal d4 sickened each Earth Season

The first four are patterns that are repeat frequently (with different skills or oppositions). The fifth is unique, but is best handled by a script that runs each Earth Season checking for the specific treasure (rather than KoDP’s approach of putting this in C++).

Here's how the first two can be specified:

{key = 1037, name = "Happy Hunting Ground",
summary = "Dirt that improves mood when hunting goes well",
onWin = {"Hunting", "mood", 3},
pool = TRADE},

{key = 1041, name = "Golden Drinking Cup",
summary = "Helps overcome skeptical minds",
modifiers = { Skepticism = 1 },
pool = EXPLORATION},

Obviously there needs to be code that checks for the onWin slot when a test is won, and the modifiers slot when a test is made. But that code then handles a wide variety of treasures.

Treasures now have unique keys, so it’s easy to add new ones. And the pool slot makes it simple to specify that a player might obtain the treasure by trading with another clan, or by exploring.

Combined with scene tagging, it’s also much easier to implement a treasure like KoDP’s Iron Spike, which included the effect

gain +1 to all tests made during Scenes R137, R163, R166, R181 and R200

If this treasure were in Six Ages, the effect would be specified

modifiers = {["@troll"] = 1 },

which means it would work for any new troll scenes, not just those created at the time the treasure was created.

Of course, nothing about this approach precludes custom code. But it massively reduces it, so only unusual treasures will need it.

2 comments: