| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#include <global.h> |
| 28 |
#include <ob_methods.h> |
| 29 |
#include <ob_types.h> |
| 30 |
#include <sounds.h> |
| 31 |
#include <sproto.h> |
| 32 |
|
| 33 |
static method_ret identify_altar_type_move_on(ob_methods *context, object *altar, object *money, object *originator); |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
void init_type_identify_altar(void) { |
| 39 |
register_move_on(IDENTIFY_ALTAR, identify_altar_type_move_on); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
static method_ret identify_altar_type_move_on(ob_methods *context, object *altar, object *money, object *originator) { |
| 51 |
object *marked; |
| 52 |
int success = 0; |
| 53 |
char desc[MAX_BUF]; |
| 54 |
|
| 55 |
if (common_pre_ob_move_on(altar, money, originator) == METHOD_ERROR) |
| 56 |
return METHOD_OK; |
| 57 |
|
| 58 |
if (originator == NULL || originator->type != PLAYER) { |
| 59 |
common_post_ob_move_on(altar, money, originator); |
| 60 |
return METHOD_OK; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
if (money->type != MONEY || !check_altar_sacrifice(altar, money, 0, NULL)) { |
| 66 |
common_post_ob_move_on(altar, money, originator); |
| 67 |
return METHOD_OK; |
| 68 |
} |
| 69 |
marked = find_marked_object(originator); |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
if (marked && !is_identified(marked)) { |
| 74 |
if (operate_altar(altar, &money)) { |
| 75 |
marked = identify(marked); |
| 76 |
draw_ext_info_format(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 77 |
"You have %s.", |
| 78 |
ob_describe(marked, originator, 1, desc, sizeof(desc))); |
| 79 |
|
| 80 |
if (marked->msg) { |
| 81 |
draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 82 |
"The item has a story:"); |
| 83 |
draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 84 |
marked->msg); |
| 85 |
} |
| 86 |
common_post_ob_move_on(altar, money, originator); |
| 87 |
return METHOD_OK; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
FOR_INV_PREPARE(originator, id) { |
| 92 |
if (!id->invisible && !is_identified(id)) { |
| 93 |
if (operate_altar(altar, &money)) { |
| 94 |
id = identify(id); |
| 95 |
draw_ext_info_format(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 96 |
"You have %s.", ob_describe(id, originator, 1, desc, sizeof(desc))); |
| 97 |
if (id->msg) { |
| 98 |
draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 99 |
"The item has a story:"); |
| 100 |
draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 101 |
id->msg); |
| 102 |
} |
| 103 |
success = 1; |
| 104 |
|
| 105 |
if (money == NULL || !check_altar_sacrifice(altar, money, 0, NULL)) |
| 106 |
break; |
| 107 |
} else { |
| 108 |
LOG(llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n"); |
| 109 |
break; |
| 110 |
} |
| 111 |
} |
| 112 |
} FOR_INV_FINISH(); |
| 113 |
if (!success) |
| 114 |
draw_ext_info(NDI_UNIQUE, 0, originator, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, |
| 115 |
"You have nothing that needs identifying"); |
| 116 |
common_post_ob_move_on(altar, money, originator); |
| 117 |
return METHOD_OK; |
| 118 |
} |