| 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 |
#include <global.h> |
| 27 |
#include <ob_methods.h> |
| 28 |
#include <ob_types.h> |
| 29 |
#include <sounds.h> |
| 30 |
#include <sproto.h> |
| 31 |
|
| 32 |
static method_ret scroll_type_apply(ob_methods *context, object *op, object *applier, int aflags); |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
void init_type_scroll(void) { |
| 38 |
register_apply(SCROLL, scroll_type_apply); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
static method_ret scroll_type_apply(ob_methods *context, object *scroll, |
| 58 |
object *applier, int aflags) { |
| 59 |
object *skapplier; |
| 60 |
object *head; |
| 61 |
sstring name; |
| 62 |
|
| 63 |
head = HEAD(applier); |
| 64 |
|
| 65 |
if (QUERY_FLAG(applier, FLAG_BLIND) && !QUERY_FLAG(applier, FLAG_WIZ)) { |
| 66 |
draw_ext_info(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, |
| 67 |
"You are unable to read while blind."); |
| 68 |
return METHOD_OK; |
| 69 |
} |
| 70 |
|
| 71 |
if (!scroll->inv || scroll->inv->type != SPELL) { |
| 72 |
draw_ext_info(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, |
| 73 |
"The scroll just doesn't make sense!"); |
| 74 |
return METHOD_OK; |
| 75 |
} |
| 76 |
|
| 77 |
if (applier->type == PLAYER) { |
| 78 |
|
| 79 |
int exp_gain; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
skapplier = find_skill_by_number(applier, SK_LITERACY); |
| 85 |
|
| 86 |
if (!skapplier) { |
| 87 |
draw_ext_info(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, |
| 88 |
"You are unable to decipher the strange symbols."); |
| 89 |
return METHOD_OK; |
| 90 |
} |
| 91 |
|
| 92 |
if (!QUERY_FLAG(scroll, FLAG_IDENTIFIED)) |
| 93 |
scroll = identify(scroll); |
| 94 |
|
| 95 |
if (QUERY_FLAG(scroll, FLAG_CURSED) || QUERY_FLAG(scroll, FLAG_DAMNED)) { |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
int failure = -35; |
| 103 |
|
| 104 |
if (settings.spell_failure_effects == TRUE) |
| 105 |
failure = -rndm(35, 100); |
| 106 |
scroll_failure(applier, failure, MAX(20, (scroll->level-skapplier->level)*5)); |
| 107 |
object_decrease_nrof_by_one(scroll); |
| 108 |
return METHOD_OK; |
| 109 |
} |
| 110 |
|
| 111 |
if ((exp_gain = calc_skill_exp(applier, scroll, skapplier))) |
| 112 |
change_exp(applier, exp_gain, skapplier->skill, 0); |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
name = scroll->inv->name; |
| 117 |
cast_spell(applier, scroll, head->facing, scroll->inv, NULL); |
| 118 |
|
| 119 |
if (QUERY_FLAG(scroll, FLAG_BLESSED) && die_roll(1, 100, applier, 1) < 10) { |
| 120 |
draw_ext_info_format(NDI_BLACK, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 121 |
"Your scroll of %s glows for a second!", |
| 122 |
name); |
| 123 |
} else { |
| 124 |
draw_ext_info_format(NDI_BLACK, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, |
| 125 |
"The scroll of %s turns to dust.", |
| 126 |
name); |
| 127 |
|
| 128 |
object_decrease_nrof_by_one(scroll); |
| 129 |
} |
| 130 |
return METHOD_OK; |
| 131 |
} |