| 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 void apply_sign(object *sign, object *op, int autoapply); |
| 34 |
static method_ret sign_type_apply(ob_methods *context, object *op, object *applier, int aflags); |
| 35 |
static method_ret sign_type_move_on(ob_methods *context, object *trap, object *victim, object *originator); |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
void init_type_sign(void) { |
| 41 |
register_move_on(SIGN, sign_type_move_on); |
| 42 |
register_apply(SIGN, sign_type_apply); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
static void apply_sign(object *sign, object *op, int autoapply) { |
| 52 |
const readable_message_type *msgType; |
| 53 |
|
| 54 |
if (sign->msg == NULL) { |
| 55 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, |
| 56 |
"Nothing is written on it."); |
| 57 |
return; |
| 58 |
} |
| 59 |
|
| 60 |
if (sign->stats.food) { |
| 61 |
if (sign->last_eat >= sign->stats.food) { |
| 62 |
if (!sign->move_on) |
| 63 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, |
| 64 |
"You cannot read it anymore."); |
| 65 |
return; |
| 66 |
} |
| 67 |
|
| 68 |
if (!QUERY_FLAG(op, FLAG_WIZPASS)) |
| 69 |
sign->last_eat++; |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
if (QUERY_FLAG(op, FLAG_BLIND) |
| 78 |
&& !QUERY_FLAG(op, FLAG_WIZ) |
| 79 |
&& !sign->move_on) { |
| 80 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, |
| 81 |
"You are unable to read while blind."); |
| 82 |
return; |
| 83 |
} |
| 84 |
msgType = get_readable_message_type(sign); |
| 85 |
draw_ext_info(NDI_UNIQUE|NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, |
| 86 |
sign->msg); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
static method_ret sign_type_apply(ob_methods *context, object *op, object *applier, int aflags) { |
| 98 |
apply_sign(op, applier, 0); |
| 99 |
return METHOD_OK; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
static method_ret sign_type_move_on(ob_methods *context, object *trap, object *victim, object *originator) { |
| 111 |
if (common_pre_ob_move_on(trap, victim, originator) == METHOD_ERROR) |
| 112 |
return METHOD_OK; |
| 113 |
if (victim->type != PLAYER && trap->stats.food > 0) { |
| 114 |
common_post_ob_move_on(trap, victim, originator); |
| 115 |
return METHOD_OK; |
| 116 |
} |
| 117 |
apply_sign(trap, victim, 1); |
| 118 |
common_post_ob_move_on(trap, victim, originator); |
| 119 |
return METHOD_OK; |
| 120 |
} |