… | |
… | |
33 | * write_rune: |
33 | * write_rune: |
34 | * op: rune writer |
34 | * op: rune writer |
35 | * skop: skill object used for casting this rune |
35 | * skop: skill object used for casting this rune |
36 | * dir: orientation of rune, direction rune's contained spell will |
36 | * dir: orientation of rune, direction rune's contained spell will |
37 | * be cast in, if applicable |
37 | * be cast in, if applicable |
38 | * inspell: spell object to put into the rune, can be null if doing |
38 | * spell: spell object to put into the rune |
39 | * a marking rune. |
|
|
40 | * level: level of casting of the rune |
39 | * level: level of casting of the rune |
41 | * runename: name of the rune or message displayed by the rune for |
40 | * runename: name of the rune or message displayed by the rune for |
42 | * a rune of marking |
41 | * a rune of marking |
43 | */ |
42 | */ |
44 | |
|
|
45 | int |
43 | int |
46 | write_rune (object *op, object *caster, object *spell, int dir, const char *runename) |
44 | write_rune (object *op, object *caster, object *spell, int dir, const char *runename) |
47 | { |
45 | { |
48 | object *tmp, *rune_spell, *rune; |
46 | object *tmp, *rune_spell, *rune; |
49 | char buf[MAX_BUF]; |
|
|
50 | maptile *m; |
47 | maptile *m; |
51 | sint16 nx, ny; |
48 | sint16 nx, ny; |
52 | |
49 | |
53 | if (!dir) |
50 | if (!dir) |
54 | dir = 1; |
51 | dir = 1; |
… | |
… | |
101 | } |
98 | } |
102 | } |
99 | } |
103 | |
100 | |
104 | if (!rune_spell) |
101 | if (!rune_spell) |
105 | { |
102 | { |
106 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
103 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s.", runename); |
107 | return 0; |
104 | return 0; |
108 | } |
105 | } |
109 | |
106 | |
110 | if (rune_spell->skill != spell->skill) |
107 | if (rune_spell->skill != spell->skill) |
111 | { |
108 | { |
112 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
109 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s. H<The spell must be of the %s spell school.>", &rune_spell->name, &spell->name, &spell->skill); |
113 | return 0; |
110 | return 0; |
114 | } |
111 | } |
115 | |
112 | |
116 | if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) |
113 | if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) |
117 | { |
114 | { |
… | |
… | |
119 | return 0; |
116 | return 0; |
120 | } |
117 | } |
121 | |
118 | |
122 | if (casting_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) |
119 | if (casting_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) |
123 | { |
120 | { |
124 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
121 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast! H<Your effetcive casting level is too low.>", &rune_spell->name); |
125 | return 0; |
122 | return 0; |
126 | } |
123 | } |
127 | |
124 | |
128 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) |
125 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) |
129 | { |
126 | { |
… | |
… | |
136 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); |
133 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); |
137 | return 0; |
134 | return 0; |
138 | } |
135 | } |
139 | |
136 | |
140 | op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); |
137 | op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); |
141 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
138 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
142 | } |
139 | } |
143 | |
140 | |
144 | /* already proper rune. Note this should only be the case if other_arch was set */ |
141 | /* already proper rune. Note this should only be the case if other_arch was set */ |
145 | if (rune_spell->type == RUNE) |
142 | if (rune_spell->type == RUNE) |
146 | rune = rune_spell; |
143 | rune = rune_spell; |
147 | else |
144 | else |
148 | { |
145 | { |
149 | rune = get_archetype (GENERIC_RUNE); |
146 | rune = get_archetype (GENERIC_RUNE); |
150 | sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); |
147 | rune->msg = format ("You set off a rune of %s\n", &rune_spell->name); |
151 | rune->msg = buf; |
|
|
152 | rune->insert (rune_spell->clone ()); |
148 | rune->insert (rune_spell->clone ()); |
153 | |
149 | |
154 | if (spell->face != blank_face) |
150 | if (spell->face != blank_face) |
155 | rune->face = spell->face; |
151 | rune->face = spell->face; |
156 | } |
152 | } |
… | |
… | |
218 | if (op->inv && op->inv->type == DISEASE) |
214 | if (op->inv && op->inv->type == DISEASE) |
219 | { |
215 | { |
220 | object *disease = op->inv; |
216 | object *disease = op->inv; |
221 | |
217 | |
222 | infect_object (victim, disease, 1); |
218 | infect_object (victim, disease, 1); |
223 | disease->destroy (true); |
219 | disease->destroy (); |
224 | } |
220 | } |
225 | } |
221 | } |
226 | else |
222 | else |
227 | hit_map (op, 0, op->attacktype, 1); |
223 | hit_map (op, 0, op->attacktype, 1); |
228 | } |
224 | } |
… | |
… | |
297 | else |
293 | else |
298 | { |
294 | { |
299 | object *spell = arch_to_object (trap->other_arch); |
295 | object *spell = arch_to_object (trap->other_arch); |
300 | |
296 | |
301 | cast_spell (env, trap, trap->direction, spell, NULL); |
297 | cast_spell (env, trap, trap->direction, spell, NULL); |
302 | spell->destroy (true); |
298 | spell->destroy (); |
303 | } |
299 | } |
304 | } |
300 | } |
305 | } |
301 | } |
306 | else |
302 | else |
307 | { |
303 | { |
… | |
… | |
344 | { |
340 | { |
345 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
341 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
346 | return 0; |
342 | return 0; |
347 | } |
343 | } |
348 | |
344 | |
349 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
345 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
350 | { |
346 | { |
351 | if (tmp->type == RUNE || tmp->type == TRAP) |
347 | if (tmp->type == RUNE || tmp->type == TRAP) |
352 | break; |
348 | break; |
353 | |
349 | |
354 | /* we could put a probability chance here, but since nothing happens |
350 | /* we could put a probability chance here, but since nothing happens |
355 | * if you fail, no point on that. I suppose we could do a level |
351 | * if you fail, no point on that. I suppose we could do a level |
356 | * comparison so low level players can't erase high level players runes. |
352 | * comparison so low level players can't erase high level players runes. |
357 | */ |
353 | */ |
358 | if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark")) |
354 | if (tmp->type == SIGN && tmp->arch->archname == shstr_rune_mark) |
359 | { |
355 | { |
360 | tmp->destroy (true); |
356 | tmp->destroy (); |
361 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
357 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
362 | return 1; |
358 | return 1; |
363 | } |
359 | } |
364 | |
360 | |
365 | /* now search tmp's inventory for traps |
361 | /* now search tmp's inventory for traps |
366 | * This is for chests, where the rune is in the chests inventory. |
362 | * This is for chests, where the rune is in the chests inventory. |
367 | */ |
363 | */ |
368 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
364 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
369 | { |
365 | { |
370 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
366 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
371 | { |
367 | { |
372 | tmp = tmp2; |
368 | tmp = tmp2; |
373 | searchflag = 0; |
369 | searchflag = 0; |
374 | break; |
370 | break; |
375 | } |
371 | } |
376 | } |
372 | } |
|
|
373 | |
377 | if (!searchflag) |
374 | if (!searchflag) |
378 | break; |
375 | break; |
379 | } |
376 | } |
380 | |
377 | |
381 | /* no rune there. */ |
378 | /* no rune there. */ |
… | |
… | |
432 | / skill->level; |
429 | / skill->level; |
433 | |
430 | |
434 | if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) |
431 | if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) |
435 | { |
432 | { |
436 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); |
433 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); |
437 | trap->destroy (true); |
434 | trap->destroy (); |
438 | |
435 | |
439 | /* If it is your own trap, (or any players trap), don't you don't |
436 | /* If it is your own trap, (or any players trap), don't you don't |
440 | * get exp for it. |
437 | * get exp for it. |
441 | */ |
438 | */ |
442 | if (trap->owner && trap->owner->type != PLAYER && risk) |
439 | if (trap->owner && trap->owner->type != PLAYER && risk) |