Subject: Event-reaction model proposal
From: Jari P Saukkonen (jsaukkon@cs.Helsinki.FI)
Date: Thu Nov 18 1999 - 23:24:52 EET
In this document I propose a following model for handling actions in the world. It might get a bit technical at times (to explain implementation to other developers), but I'll try to keep this readable for others too :). First, some terminology: Event, is any action that some object (player, npc, monster, ...) does. For example movement, item handling, speaking and basically everything that includes action detectable by senses (sight, hearing, ...). A reaction is a piece of code that is performed when object receives an event. Object does not receive any events that it cannot react to. In practice, events are classes that have different attributes depending on the event. I'm not that good in explaining so let's start with an example. Plot: Yorkaturr is on a sunday-walk, and happens to walk through a small village. When he moves, 'movement' event is dispatched. In case Yorkaturr wasn't already in the vicinity (ie. villagers haven't yet noticed him), an 'arrive' event is generated. Villager's code has a reaction defined for the 'arrive' event. It checks the source of the event, Yorkaturr, and starts examining his outlook. It determines that Yorkaturr is a quite scaring sight, and thus the villagers starts to flee in panic. In case the villager would have been interactive (a PC) the code would have catched the 'arrive' event and sent a command to client to add Yorkaturr's object to the scene. Further movement events would cause the object to move in the client. For the implementation we will probably need a huge tree structure that divides the world in equally-spaced cells. Nodes of the tree contain references to objects. When object moves, it's position is updated in the tree structure accordingly, and it's very quick to determine the nearest objects (that an event needs to be dispatched to) by traversing the tree up a couple of levels (depending on the event sending range) and checking all nodes with the subtree. With this universal model, we can get over the problem of keeping the clients in sync, and provide a framework for building decent AI. If we start extrapolating, it could be possible to build a fighting AI that is based on reacting to opponent's movements and strikes. This is however purely theoretical, and would be quite cpu-intensive, but the framework would make it possible :). Hmm, maybe that's it, South Park is on TV :).. Ask if something is still unclear. ++ Dazzt --- | Jari Saukkonen + jari.saukkonen@cs.helsinki.fi : coral -. | programming music graphics | dolphin : | art keyboards web | nah-kolor | +------------------------------------------------+-----------' | Babylon5-inspired 'shadow function' 0 <= t <= 4*pi/3 : x(t) = (sin 8t)^2 * (5 + 3sin 8t) cos (t/2 + (sin 8t)^2) . y(t) = +-(sin 8t)^2 * (5 + 3cos 8t) sin (t/2 + (sin 8t)^2)
This archive was generated by hypermail 2b25 : Tue Feb 12 2002 - 00:03:25 EET