special.h
pdirt/drv/include/special.h · 5.2 KB
From the archive pDirt-1_tar.gz
Download the archive « Back to the archive contents
/*************************************************************************
** Headerfile : special.h
** Description: Give a certain mobile/object/room a special function
** Definitions, macros and prototypes used by special.c
** Author : Peter Eussen (Marty)
** Version : 0.2
** Date : 30 June 1996
** Notes : See special.c for documentation.
*************************************************************************/
#ifndef _SPECIAL_H_
#define _SPECIAL_H_
/*************************************************************************
** First some conditions on when this function can be called
*************************************************************************/
#define E_ONTIMER 1 /* Special event on every alarm */
#define E_ONEXAMINE 2 /* On examine call */
#define E_ONKILL 3 /* On kill call */
#define E_ONREST 4 /* On sleep/sit/trance */
#define E_ONMOVE 5 /* On players movement */
#define E_ONENTRY 6 /* On players entry */
#define E_ONTHROW 7 /* Throwing an object */
#define E_ONGIVE 8 /* Giving an object */
#define E_ONGET 9 /* Acquiring object */
#define E_ONCOMM 10 /* When someone talks */
#define E_ONOPEN 11 /* When the object is opened */
#define E_ONCLOSE 12 /* WHen an object is closed */
#define E_ONLOCK 13 /* When an object is locked */
#define E_ONUNLOCK 14 /* When an object is unlocked */
#define E_ONDROP 15 /* When object is dropped */
#define E_ONLIGHT 16 /* When an object is lighted */
#define E_ONUSE 17 /* Wear/Wield etc */
#define E_ONPUT 18 /* On placement of an artifact */
#define E_ONCONSUME 19 /* Eat Drink */
#define E_ONJUMP 20 /* On a jump */
#define E_ONLOOK 21 /* General look, same as Examine? */
#define E_ONPUSH 22 /* Push/Pull/Move etc */
#define E_WHILEFIGHT 23 /* While fighting */
#define E_ONKILLED 24 /* Need one for a killed mobile as well :( */
#define E_ONDIG 25 /* When a player digs */
#define E_ONINIT 29 /* Initialise data */
#define E_ONTIE 30 /* Tie */
#define E_ONUNTIE 31 /* Untie */
#define E_AFTERENTRY 32 /* After Entry */
#define E_SPECIALEXIT 33 /* For invisible exits */
#define E_ONWIELD 34 /* Wield Commando */
#define E_ONSAY 35 /* Say commando */
#define E_ONACTION 36 /* On an action (kiss , hug)*/
# define ACT_RET_GOOD 0
# define ACT_RET_BAD (-1)
#define E_AFTERPUT 37
#define E_STORE 38
#define E_ONSPELL 39 /* New spell casting event */
#define E_ONMISC 100 /* Misc. events */
#define E_USER 200 /* User specified code */
#define E_EXIT 201 /* User specified code */
#define E_PLAYCOM 66 /* A player special event ? */
#define D_NORMAL 0 /* Normal drop */
#define D_INPIT 1 /* In pit drop */
#define D_DONATE 2 /* In donations room drop */
#define BEFORE_GET 0 /* Events before get */
#define DURING_GET 1 /* During get */
#define AFTER_GET 2 /* After object is picked up */
typedef struct _intmapping
{ int id;
void (*func)(int);
} intmapping;
typedef struct _charmapping
{ char *id;
void (*func)(int);
} charmapping;
#define MAPPING(n) static intmapping n[]
#define MAPSIZE(n) (sizeof(n) / sizeof(intmapping))
#define CHARMAPPING(n) static charmapping n[]
#define CHMAPSIZE(n) (sizeof(n) / sizeof(charmapping))
#define EVENT_HANDLER(x) void (x)(int event)
/**************************************************************************
** Some macros used internaly..
**************************************************************************/
#define clear_obj_fun(O) (objects[O].spec_case = NULL)
#define clear_mob_fun(M) (ublock[M].spec_case = NULL)
#define clear_rom_fun(R) (room_data[R].spec_case = NULL)
#define set_obj_fun(O,F) (objects[O].spec_case = (F))
#define set_mob_fun(M,F) (ublock[M].spec_case = (F))
#define set_rom_fun(R,F) (room_data[R].spec_case = (F))
#define rom_fun(R) (room_data[convroom(R)].spec_case)
#define obj_fun(O) (objects[O].spec_case)
#define mob_fun(M) (ublock[M].spec_case)
int setfunctions(void); /* Set functions on reboot/reset */
void on_timer_events(void); /* Do on timer events rooms */
void check_obj_in_room(int player,int event);/* Check obj in room for actions */
void check_pl_in_room(int player,int event); /* Same now for mobiles */
void check_obj_on_plx(int player,int event);
void clearfunctions(void); /* Remove events */
void init_all(void); /* Initialise functions with E_ONINIT); */
void setplayerfunc(int plx); /* Some special code for players */
void init_zone(int zone); /* Initialise functions with E_ONINIT; */
int get_rand_start(void);
Boolean is_start_loc(int loc);
void specials_on_timer(void);
Boolean in_table(int value, const int *table);
#endif