Conditional bonuses
This post is in response to Open Source d20 API/Engine thread on ENWorld, where I was asked to give an example.
Here’s an example of how I would model the “+1 vs goblinoids” so it can be resolved by an engine. This is off the top of my head and probably won’t withstand closer analysis.
First, we’ll need to define a goblinoid. Note that this could actually be an anonymous class defined as part of the bonus rather than a named class as in the example.
If something has creature subtype goblin and is a humanoid, we’re calling it a goblinoid. A more accurate definition would use oneOf to enumerate the full list of subtypes IIRC.
<owl:Class rdf:ID="http://example.org/srd#goblinoid"> <owl:intersectionOf rdf:parseType="Collection"> <owl:Class rdf:about="http://example.org/srd#humanoid"> <owl:Restriction> <owl:onProperty rdf:resource="http://example.org/core#creatureSubtype" /> <owl:hasValue rdf:resource="http://example.org/srd#goblin" /> </owl:Restriction> </owl:intersectionOf> </owl:Class>
Now, let’s define the bonus. It’s anonymous as it will typically be defined as part of some other rule, such as a racial trait.
<core:Bonus> <core:appliesTo resource="http://example.org/core#attack" /> <core:type resource="http://example.org/srd#racial" /> <core:Condition> <rdfs:label>vs goblinoids</rdfs:label> <core:conditionType rdf:resource="http://example.org/core#runtime" /> <srd:goblinoid> <runtime:Role rdf:about="http://example.org/core#target" /> </srd:goblinoid> </core:Condition> <core:formula>1</core:formula> </core:Bonus>
So, at runtime, when a creature of subtype goblinoid is assigned the “target” role relative to the character, the formula is evaulated and applied to the attack roll subject to stacking rules for bonus types.
Here, I’m telling the processor this condition can be checked at runtime. If, at that time, there is a goblinoid with the ‘target’ role, apply this bonus.
Some conditions can realistically only be evaluated by a DM (see the preqs for assassins, for example). For those I would stick with a simple text description like my original example.
Now, this is a lot of work, so I’m sticking to a small, well-defined ontology to begin with (stuff in the “core” namespace, above), and building tools to extend the ontologies on top of that. So all the stuff in the SRD namespace would be the result of using my BookBuilder application. Definitions like goblinoid can be built by example rather than typed out (I haven’t even thought about the book builder UI yet).