00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #include <global.h>
00029 #include <ob_methods.h>
00030 #include <ob_types.h>
00031 #include <sounds.h>
00032 #include <sproto.h>
00033
00034 static method_ret trigger_type_apply(ob_methods *context, object *op, object *applier, int aflags);
00035 static method_ret trigger_type_process(ob_methods *context, object *op);
00036
00040 void init_type_trigger(void) {
00041 register_apply(TRIGGER, trigger_type_apply);
00042 register_process(TRIGGER, trigger_type_process);
00043 }
00044
00053 static method_ret trigger_type_apply(ob_methods *context, object *op, object *applier, int aflags) {
00054 if (check_trigger(op, applier)) {
00055 draw_ext_info(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
00056 "You turn the handle.", NULL);
00057 play_sound_map(SOUND_TYPE_GROUND, op, 0, "turn handle");
00058 } else {
00059 draw_ext_info(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE,
00060 "The handle doesn't move.", NULL);
00061 }
00062 return 1;
00063 }
00064
00071 static method_ret trigger_type_process(ob_methods *context, object *op) {
00072 if ((unsigned char)++op->stats.wc >= NUM_ANIMATIONS(op)) {
00073 op->stats.wc = 0;
00074 check_trigger(op, NULL);
00075 } else {
00076 SET_ANIMATION(op, op->stats.wc);
00077 update_object(op, UP_OBJ_FACE);
00078 }
00079 return METHOD_OK;
00080 }