At the end of October, I released v0.8 of Rez, a game authoring system I built for myself to replace my use of Twine. Today I have published v0.9.
Originally meant to be a “quick & dirty” replacement for Twine, over a year, it has become a complete system for building HTML games. It has built-in support for things I wanted, like flexible items & inventories, NPC actors, and a scene & card based rendering system. Rez is declarative, with Javascript callbacks providing dynamic behaviour.
However, for my own use, it was missing a key component: behaviour trees. I hate trying to implement behaviour in a programming language (esp. one like Javascript). I have used behaviour trees before, so I ported a behaviour tree library I wrote for Clojure and here we are.
Rez now natively supports behaviour trees as an attribute type and provides a helpful selection of tasks in the standard library (composites & decorators) and a @task
element to define custom condition tasks & action tasks yourself (see stdlib source for how the core tasks are implemented).
The result: you can write something like:
@actor sam_spade begin
...
behaviours: ^[SELECT [
[SEQUENCE [
[ACTOR_IN location=sams_office]
[ACTOR_SEES item=booze]
[MAYBE p=20 [ACTOR_DRINKS]]]
[SEQUENCE [
[ACTOR_SEES actor=wilmer]
[ACTOR_RELATIONSHIP actor=wilmer rel=antagonist]
[ACTOR_HAS item=handgun]
[SELECT [
[SEQUENCE [
[ACTOR_HAS tag=drunk]
[ACTOR_SHOOTS_AND_MISSES]]]
[MAYBE p=20 [
[ACTOR_SHOOTS target=wilmer item=handgun]]
[SEQUENCE [
[ACTOR_SEES tagged=dame]
[RANDOM_EACH [
[ACTOR_SAYS line="You know, that's good, because if you actually were as innocent as you pretend to be, we'd never get anywhere"]
[ACTOR_SAYS line="We didn't exactly believe your story, Miss. We believed your 200 dollars"]
[ACTOR_SAYS line="You won't need much of anybody's help. You're good. Chiefly your eyes, I think, and that throb you get in your voice when you say things like "Be generous, Mr. Spade"]]]]]
@end
Okay, very simple and silly example, but hopefully illustrative of what is possible. SEQUENCE
, SELECT
, MAYBE
, and RANDOM_EACH
are core tasks from the standard library. The author of this game would implement condition tasks like ACTOR_IN
and ACTOR_SEES
and action tasks such as ACTOR_DRINKS
, ACTOR_SAYS
, and so on.
With the addition of behaviour trees, Rez is now conceptually complete, although there are still a lot of holes in my implementation of some of those concepts. I plan to fill those in as I switch my focus from tooling to game development.
I realise there are already a lot of authoring systems out there, but if anyone fancies trying Rez drop me a line. The source is all available, but I guess it might require my help to set it up.