Re: Modeling events that occur in a game world



On 21 Apr 2007 10:24:32 -0700, Aaron J. M. wrote:

I need a way of representing and tracking different events that occur in a game
I'm working on. I have a world composed of one or more Maps. Each Map location
(coordinate) may or may not have a Creature. A Creature is controlled by an AI,
which may also be the player's UI, though the Creatures themselves are not
necessarily aware of their AIs. Creatures may move to different coordinates or
attack other Creatures.

Right now the two events I know I'll want to keep track of is when a Creature
attacks another Creature and when a Creature dies, and I see myself coming up
with new events as my game grows more intricate. Different parts of my game
would be interested in different kinds of events. The graphical display would
be interested in all events so that it may display an appropriate animation.
More importantly, the different AIs would need to observe recent events to
modify their behaviour. If a Creature is attacked, the AI controlling it has a
vested interest in knowing about it.

I'm having trouble modeling this because the different kinds of events would
keep potentially arbitrary information, making it hard to generalize. An attack
event would know the attacking Creature, the target Creature, and the amount of
damage done. A death event would just know the Creature that died. I might
also implement Creatures grabbing and throwing other Creatures, so a throw event
would need to know the throwing Creature, the thrown Creature, and where the
thrown Creature landed. For this reason I can't really make them subclasses of
a single Event class, since they hold such different information.

Why are they events? I would say, that death, under attack, flight etc are
not events, they are states. If creatures are models of physical objects,
then the only event they need is a timer or scheduling event. The object
reads the sensors, changes its state and writes the actuators.

So how would I model these events and let my system handle and respond to them?

Multiple-dispatching operations, if your language can it. Otherwise you
have to emulate multiple dispatch.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: Fitting CR to a party of 6 PCs
    ... creature I'd use in such a situation is going to have, ... that can comphortably grapple at -20 without fear of retaliation. ... in order to attack one. ... enough grapple check to fight effectively this way... ...
    (rec.games.frp.dnd)
  • Re: Modeling events that occur in a game world
    ... cares what happened and has an appropriate response to it. ... For example, if a creature attacks another creature, any other ... who are friends with the target and are within range to see the attack ... how to encode any data packet and whoever receives the event will know ...
    (comp.object)
  • Re: Architecture OOD
    ... >> on every creature it hits. ... > actors to take special steps just to attack with that sword. ... selecting the <usage> when you invoke those actions. ... in the interface to allow non-obvious things, ...
    (rec.games.roguelike.development)
  • Re: Objectification of Roguelikes - how far to take it?
    ... The example given of a blind monster ... You can have a simgle Creature class ... If there was no dark area nearby, then the "attack ... each monster type has a 'Markov chain' of behaviours it ...
    (rec.games.roguelike.development)
  • Re: Refactoring all the time
    ... reconstructed using object composition. ... Each creature will be a composition of these objects: ... An Attack Navigator: From the same class as the navigator, ...
    (rec.games.roguelike.development)