00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027 #include <global.h>
00028 #include <ob_methods.h>
00029 #include <ob_types.h>
00030 #include <sounds.h>
00031 #include <sproto.h>
00032
00033 static method_ret identify_altar_type_move_on(ob_methods *context, object *altar, object *money, object *originator);
00034
00038 void init_type_identify_altar(void) {
00039 register_move_on(IDENTIFY_ALTAR, identify_altar_type_move_on);
00040 }
00041
00050 static method_ret identify_altar_type_move_on(ob_methods *context, object *altar, object *money, object *originator) {
00051 object *id;
00052 object *marked;
00053 int success = 0;
00054 char desc[MAX_BUF];
00055
00056 if (common_pre_ob_move_on(altar, money, originator) == METHOD_ERROR)
00057 return METHOD_OK;
00058
00059 if (originator == NULL || originator->type != PLAYER) {
00060 common_post_ob_move_on(altar, money, originator);
00061 return METHOD_OK;
00062 }
00063
00064
00065
00066 if (money->type != MONEY || !check_altar_sacrifice(altar, money, 0, NULL)) {
00067 common_post_ob_move_on(altar, money, originator);
00068 return METHOD_OK;
00069 }
00070 marked = find_marked_object(originator);
00071
00072
00073
00074 if (marked
00075 && !QUERY_FLAG(marked, FLAG_IDENTIFIED)
00076 && need_identify(marked)) {
00077 if (operate_altar(altar, &money)) {
00078 identify(marked);
00079 draw_ext_info_format(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
00080 "You have %s.",
00081 NULL,
00082 ob_describe(marked, originator, desc, sizeof(desc)));
00083
00084 if (marked->msg) {
00085 draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
00086 "The item has a story:", NULL);
00087 draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
00088 marked->msg, NULL);
00089 }
00090 common_post_ob_move_on(altar, money, originator);
00091 return METHOD_OK;
00092 }
00093 }
00094
00095 for (id = originator->inv; id; id = id->below) {
00096 if (!QUERY_FLAG(id, FLAG_IDENTIFIED)
00097 && !id->invisible
00098 && need_identify(id)) {
00099 if (operate_altar(altar, &money)) {
00100 identify(id);
00101 draw_ext_info_format(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
00102 "You have %s.", "You have %s.", ob_describe(id, originator, desc, sizeof(desc)));
00103 if (id->msg) {
00104 draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
00105 "The item has a story:", NULL);
00106 draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
00107 id->msg, NULL);
00108 }
00109 success = 1;
00110
00111 if (money == NULL || !check_altar_sacrifice(altar, money, 0, NULL))
00112 break;
00113 } else {
00114 LOG(llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n");
00115 break;
00116 }
00117 }
00118 }
00119 if (!success)
00120 draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE,
00121 "You have nothing that needs identifying", NULL);
00122 common_post_ob_move_on(altar, money, originator);
00123 return METHOD_OK;
00124 }