1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | #include <global.h> |
24 | #include <global.h> |
26 | #include <sproto.h> |
25 | #include <sproto.h> |
27 | #include <spells.h> |
26 | #include <spells.h> |
… | |
… | |
56 | |
55 | |
57 | nx = op->x + freearr_x[dir]; |
56 | nx = op->x + freearr_x[dir]; |
58 | ny = op->y + freearr_y[dir]; |
57 | ny = op->y + freearr_y[dir]; |
59 | m = op->map; |
58 | m = op->map; |
60 | |
59 | |
61 | if (get_map_flags (m, &m, nx, ny, &nx, &ny)) |
60 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & (P_OUT_OF_MAP | P_SAFE | P_NO_MAGIC | P_NO_CLERIC)) |
62 | { |
61 | { |
63 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
62 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
64 | return 0; |
63 | return 0; |
65 | } |
64 | } |
66 | |
65 | |
67 | for (tmp = GET_MAP_OB (m, nx, ny); tmp != NULL; tmp = tmp->above) |
66 | for (tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above) |
68 | if (tmp->type == RUNE) |
67 | if (tmp->type == RUNE) |
69 | break; |
68 | break; |
70 | |
69 | |
71 | if (tmp) |
70 | if (tmp) |
72 | { |
71 | { |
73 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune there."); |
72 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune on top of another rune."); |
74 | return 0; |
73 | return 0; |
75 | } |
74 | } |
76 | |
75 | |
77 | if (spell->other_arch) |
76 | if (spell->other_arch) |
78 | rune_spell = arch_to_object (spell->other_arch); |
77 | rune_spell = arch_to_object (spell->other_arch); |
… | |
… | |
90 | return 0; |
89 | return 0; |
91 | } |
90 | } |
92 | |
91 | |
93 | rune_spell = NULL; |
92 | rune_spell = NULL; |
94 | for (tmp = op->inv; tmp; tmp = tmp->below) |
93 | for (tmp = op->inv; tmp; tmp = tmp->below) |
95 | { |
|
|
96 | if (tmp->type == SPELL) |
94 | if (tmp->type == SPELL) |
97 | { |
95 | { |
98 | ms = item_matched_string (op, tmp, runename); |
96 | ms = item_matched_string (op, tmp, runename); |
99 | if (ms > bestmatch) |
97 | if (ms > bestmatch) |
100 | { |
98 | { |
101 | bestmatch = ms; |
99 | bestmatch = ms; |
102 | rune_spell = tmp; |
100 | rune_spell = tmp; |
103 | } |
101 | } |
104 | } |
102 | } |
105 | } |
|
|
106 | |
103 | |
107 | if (!rune_spell) |
104 | if (!rune_spell) |
108 | { |
105 | { |
109 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
106 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
110 | return 0; |
107 | return 0; |
… | |
… | |
114 | { |
111 | { |
115 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
112 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
116 | return 0; |
113 | return 0; |
117 | } |
114 | } |
118 | |
115 | |
119 | if (caster->path_denied & spell->path_attuned) |
116 | if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) |
120 | { |
117 | { |
121 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
118 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
122 | return 0; |
119 | return 0; |
123 | } |
120 | } |
124 | |
121 | |
125 | if (caster_level (caster, rune_spell) < rune_spell->level) |
122 | if (caster_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) |
126 | { |
123 | { |
127 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
124 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
128 | return 0; |
125 | return 0; |
129 | } |
126 | } |
130 | |
127 | |
… | |
… | |
196 | } |
193 | } |
197 | else |
194 | else |
198 | op->invisible = 1; |
195 | op->invisible = 1; |
199 | |
196 | |
200 | if (op->invisible != det) |
197 | if (op->invisible != det) |
201 | update_object (op, UP_OBJ_FACE); |
198 | update_object (op, UP_OBJ_CHANGE); |
202 | } |
199 | } |
203 | |
|
|
204 | |
200 | |
205 | /* peterm: rune_attack |
201 | /* peterm: rune_attack |
206 | * function handles those runes which detonate but do not cast spells. |
202 | * function handles those runes which detonate but do not cast spells. |
207 | */ |
203 | */ |
208 | |
|
|
209 | |
|
|
210 | void |
204 | void |
211 | rune_attack (object *op, object *victim) |
205 | rune_attack (object *op, object *victim) |
212 | { |
206 | { |
213 | if (victim) |
207 | if (victim) |
214 | { |
208 | { |
… | |
… | |
276 | if (rv.distance > 1) |
270 | if (rv.distance > 1) |
277 | return; |
271 | return; |
278 | |
272 | |
279 | trap_show (trap, env); |
273 | trap_show (trap, env); |
280 | |
274 | |
|
|
275 | if (victim->type == PLAYER) // only count players as enemies |
|
|
276 | trap->enemy = victim; // set the victim as the traps enemy, so that summoned |
|
|
277 | // creatures know who to attack. |
|
|
278 | |
281 | /* Only if it is a spell do we proceed here */ |
279 | /* Only if it is a spell do we proceed here */ |
282 | if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->clone.type == SPELL)) |
280 | if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL)) |
283 | { |
281 | { |
284 | |
282 | |
285 | if (trap->destroyed ()) |
283 | if (trap->destroyed ()) |
286 | return; |
284 | return; |
287 | |
285 | |
… | |
… | |
354 | |
352 | |
355 | /* we could put a probability chance here, but since nothing happens |
353 | /* 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 |
354 | * 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. |
355 | * comparison so low level players can't erase high level players runes. |
358 | */ |
356 | */ |
359 | if (tmp->type == SIGN && !strcmp (tmp->arch->name, "rune_mark")) |
357 | if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark")) |
360 | { |
358 | { |
361 | tmp->destroy (); |
359 | tmp->destroy (); |
362 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
360 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
363 | return 1; |
361 | return 1; |
364 | } |
362 | } |
… | |
… | |
412 | { |
410 | { |
413 | if (where == NULL) |
411 | if (where == NULL) |
414 | return 0; |
412 | return 0; |
415 | |
413 | |
416 | object *tmp = get_archetype ("runedet"); |
414 | object *tmp = get_archetype ("runedet"); |
417 | tmp->face = &new_faces[GET_ANIMATION (trap, 0)]; |
415 | tmp->face = GET_ANIMATION (trap, 0); |
418 | tmp->insert_at (where, 0); |
416 | tmp->insert_at (where, 0); |
419 | |
417 | |
420 | return 1; |
418 | return 1; |
421 | } |
419 | } |
422 | |
420 | |