… | |
… | |
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 | { |
118 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
115 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
119 | return 0; |
116 | return 0; |
120 | } |
117 | } |
121 | |
118 | |
122 | if (caster_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 | } |
157 | |
153 | |
158 | rune->level = caster_level (caster, spell); |
154 | rune->level = casting_level (caster, spell); |
159 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
155 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
160 | rune->direction = dir; /* where any spell will go upon detonation */ |
156 | rune->direction = dir; /* where any spell will go upon detonation */ |
161 | rune->set_owner (op); /* runes without need no owner */ |
157 | rune->set_owner (op); /* runes without need no owner */ |
162 | set_spell_skill (op, caster, spell, rune); |
158 | set_spell_skill (op, caster, spell, rune); |
163 | |
159 | |
… | |
… | |
279 | // creatures know who to attack. |
275 | // creatures know who to attack. |
280 | |
276 | |
281 | /* Only if it is a spell do we proceed here */ |
277 | /* Only if it is a spell do we proceed here */ |
282 | if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL)) |
278 | if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL)) |
283 | { |
279 | { |
284 | |
|
|
285 | if (trap->destroyed ()) |
280 | if (trap->destroyed ()) |
286 | return; |
281 | return; |
287 | |
282 | |
288 | // breaks summon golem spells, which, for inexplicable reasons, |
283 | // breaks summon golem spells, which, for inexplicable reasons, |
289 | // do not work like summon golem spells at all but still require |
284 | // do not work like summon golem spells at all but still require |
… | |
… | |
345 | { |
340 | { |
346 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
341 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
347 | return 0; |
342 | return 0; |
348 | } |
343 | } |
349 | |
344 | |
350 | 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) |
351 | { |
346 | { |
352 | if (tmp->type == RUNE || tmp->type == TRAP) |
347 | if (tmp->type == RUNE || tmp->type == TRAP) |
353 | break; |
348 | break; |
354 | |
349 | |
355 | /* we could put a probability chance here, but since nothing happens |
350 | /* we could put a probability chance here, but since nothing happens |
356 | * 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 |
357 | * 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. |
358 | */ |
353 | */ |
359 | if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark")) |
354 | if (tmp->type == SIGN && tmp->arch->archname == shstr_rune_mark) |
360 | { |
355 | { |
361 | tmp->destroy (); |
356 | tmp->destroy (); |
362 | 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!"); |
363 | return 1; |
358 | return 1; |
364 | } |
359 | } |
365 | |
360 | |
366 | /* now search tmp's inventory for traps |
361 | /* now search tmp's inventory for traps |
367 | * 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. |
368 | */ |
363 | */ |
369 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
364 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
370 | { |
365 | { |
371 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
366 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
372 | { |
367 | { |
373 | tmp = tmp2; |
368 | tmp = tmp2; |
374 | searchflag = 0; |
369 | searchflag = 0; |
375 | break; |
370 | break; |
376 | } |
371 | } |
377 | } |
372 | } |
|
|
373 | |
378 | if (!searchflag) |
374 | if (!searchflag) |
379 | break; |
375 | break; |
380 | } |
376 | } |
381 | |
377 | |
382 | /* no rune there. */ |
378 | /* no rune there. */ |
… | |
… | |
433 | / skill->level; |
429 | / skill->level; |
434 | |
430 | |
435 | 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))) |
436 | { |
432 | { |
437 | 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); |
438 | trap->destroy (1); |
434 | trap->destroy (); |
439 | |
435 | |
440 | /* 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 |
441 | * get exp for it. |
437 | * get exp for it. |
442 | */ |
438 | */ |
443 | if (trap->owner && trap->owner->type != PLAYER && risk) |
439 | if (trap->owner && trap->owner->type != PLAYER && risk) |