Skip to content
arendjr edited this page Jan 28, 2013 · 4 revisions

Game Events are used to propagate information about events to characters in a room, as well as nearby rooms. Examples of events that may be propagated through Game Events are people talking, people walking, fighting, as well as arbitrary sounds or visual effects.

Event Type Derives from Description
AreaEvent GameEvent Simply propagates the event to all rooms belonging to a certain area.
MovementSoundEvent SoundEvent Used for propagating the sound of footsteps when someone walks from one room to another.
MovementVisualEvent VisualEvent Used for propagating movements of people from one room to another to anyway able to see it.
GameEvent GameEvent is the basic type that all game events derive from. It implements the basic propagation framework.
SoundEvent GameEvent Generic event type for propagating sounds. This event type implements sound propagation rules.
SpeechEvent SoundEvent Used for propagating the sound of speech.
VisualEvent GameEvent Generic event type for propagating visuals. This event type implements line of sight.

Firing an event

Here's an example of how to fire a speech event:

var origin = character.currentRoom;
var event = Realm.createEvent("Speech", origin, 1.0);
event.speaker = character;
event.message = "Hi, there!";
event.fire();

For more examples I would suggest looking at the methods in character.js.

Creating New Game Event Types

Creating new types of game events is currently only possible using C++. To do this, you will have to create a class that derives from GameEvent, possibly via SoundEvent or VisualEvent. You may want to take the source of one of the existing types as template to create your own type.

Once you've created your own class, you have to add it to the GameEventType enum defined in gameevent.h, and add a new case for your type in createByEventType() in gameevent.cpp.

You will have to recompile PlainText after adding your own game event type.

Further Reading

Read how you can create triggers, how you can implement your own commands, or how you can customize game objects.

You may want to take a look at the Frequently Asked Questions.