Chapter 9
(WIP)
How to "install" [EVENTS]
A basic event looks like the following:
[EVENTS defname] code
Looks just like every other thing we've done so far doesn't it? Well events work the same way. They can be installed either in-game our through a script using the following:
EVENTS +defname EVENTS=defname EVENTS -defname
These are three very different commands. Some people tend to confuse them. Here is what they do:
EVENTS +DEFNAME
Adds the event to the character's list of events. Yes, a character can have more than one event. Both of the following will respond to triggers called on the character:
SRC.EVENTS +e_death_event SRC.EVENTS +e_ctf_event
EVENTS=DEFNAME
This method is should not be used. It will erase all other events on the character in place of this one.
EVENTS -DEFNAME
This will remove the specified event from the character.
THE DEFAULT OBJECT OF AN [EVENTS] SCRIPT IS THE CHARACTER ON WHICH THE SCRIPT IS INSTALLED.
The order of event handling
There are quite a few ways to add events to items or characters. These are:
EVENTS +DEFNAME
Can be set by a function, another event, a player action, or inside a trigger (for example, the @Create trigger).
TEVENTS=DEFNAME
In the body of the ITEMDEF or CHARDEF. There may be as many of TEVENTS lines as you wish.
TYPE=DEFNAME
(Items only) In the body of the ITEMDEF. There can only be ONE base type definition. TYPEs are not only events, they also determine some basic behaviour of the item, and it's capabilities (for example, if an item is not of an equippable type, it cannot be equipped).
DIRECT TRIGGERS
Poor man's events: As events are generally assortments of triggers what can be added to an item or character. You may also "hardcode" some trigger actions in the ITEMDEF/CHARDEF itself.
ORDER OF FIRING
Look at these simple code examples:
[ITEMDEF i_triggertester] ID=i_floor_wood TYPE = t_testtype NAME=TriggerTester TEVENTS=e_tev_test ON=@Create EVENTS +e_ev_test ON=@DClick SERV.LOG item dclick from direct trigger [TYPEDEF e_ev_test] ON=@DClick SERV.LOG dclick from event [TYPEDEF e_tev_test] ON=@DClick SERV.LOG item dclick from tevent [TYPEDEF t_testtype] ON=@DClick SERV.LOG item dclick from base typedef
This gives the following results:
item dclick from event
item dclick from tevent
item dclick from base typedef
item dclick from direct trigger
The same for characters:
[CHARDEF c_testorc] ID=c_orc NAME=TestOrc TEVENTS=e_tev_character ON=@Create STR = 100 ON=@NPCRestock EVENTS +e_ev_character ON=@DClick SERV.LOG char dclick from direct trigger [EVENTS e_tev_character] ON=@DClick SERV.LOG char dclick from tevent [EVENTS e_ev_character] ON=@DClick SERV.LOG char dclick from event
The results:
char dclick from event
char dclick from tevent
char dclick from direct trigger