1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | 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 |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | 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, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | 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 |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <sproto.h> |
26 | #include <sproto.h> |
26 | #include <spells.h> |
27 | #include <spells.h> |
27 | |
28 | |
… | |
… | |
55 | |
56 | |
56 | nx = op->x + freearr_x[dir]; |
57 | nx = op->x + freearr_x[dir]; |
57 | ny = op->y + freearr_y[dir]; |
58 | ny = op->y + freearr_y[dir]; |
58 | m = op->map; |
59 | m = op->map; |
59 | |
60 | |
60 | if (get_map_flags (m, &m, nx, ny, &nx, &ny)) |
61 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & (P_OUT_OF_MAP | P_SAFE | P_NO_MAGIC | P_NO_CLERIC)) |
61 | { |
62 | { |
62 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
63 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
63 | return 0; |
64 | return 0; |
64 | } |
65 | } |
65 | |
66 | |
66 | for (tmp = GET_MAP_OB (m, nx, ny); tmp != NULL; tmp = tmp->above) |
67 | for (tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above) |
67 | if (tmp->type == RUNE) |
68 | if (tmp->type == RUNE) |
68 | break; |
69 | break; |
69 | |
70 | |
70 | if (tmp) |
71 | if (tmp) |
71 | { |
72 | { |
72 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune there."); |
73 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune on top of another rune."); |
73 | return 0; |
74 | return 0; |
74 | } |
75 | } |
75 | |
76 | |
76 | if (spell->other_arch) |
77 | if (spell->other_arch) |
77 | rune_spell = arch_to_object (spell->other_arch); |
78 | rune_spell = arch_to_object (spell->other_arch); |
… | |
… | |
89 | return 0; |
90 | return 0; |
90 | } |
91 | } |
91 | |
92 | |
92 | rune_spell = NULL; |
93 | rune_spell = NULL; |
93 | for (tmp = op->inv; tmp; tmp = tmp->below) |
94 | for (tmp = op->inv; tmp; tmp = tmp->below) |
94 | { |
|
|
95 | if (tmp->type == SPELL) |
95 | if (tmp->type == SPELL) |
96 | { |
96 | { |
97 | ms = item_matched_string (op, tmp, runename); |
97 | ms = item_matched_string (op, tmp, runename); |
98 | if (ms > bestmatch) |
98 | if (ms > bestmatch) |
99 | { |
99 | { |
100 | bestmatch = ms; |
100 | bestmatch = ms; |
101 | rune_spell = tmp; |
101 | rune_spell = tmp; |
102 | } |
102 | } |
103 | } |
103 | } |
104 | } |
|
|
105 | |
104 | |
106 | if (!rune_spell) |
105 | if (!rune_spell) |
107 | { |
106 | { |
108 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
107 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
109 | return 0; |
108 | return 0; |
… | |
… | |
113 | { |
112 | { |
114 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
113 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
115 | return 0; |
114 | return 0; |
116 | } |
115 | } |
117 | |
116 | |
118 | if (caster->path_denied & spell->path_attuned) |
117 | if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) |
119 | { |
118 | { |
120 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
119 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
121 | return 0; |
120 | return 0; |
122 | } |
121 | } |
123 | |
122 | |
124 | if (caster_level (caster, rune_spell) < rune_spell->level) |
123 | if (caster_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) |
125 | { |
124 | { |
126 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
125 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
127 | return 0; |
126 | return 0; |
128 | } |
127 | } |
129 | |
128 | |
… | |
… | |
180 | rune->maxhp : number of spells the rune casts |
179 | rune->maxhp : number of spells the rune casts |
181 | */ |
180 | */ |
182 | void |
181 | void |
183 | move_rune (object *op) |
182 | move_rune (object *op) |
184 | { |
183 | { |
185 | int det = 0; |
184 | /* runes of level zero cannot detonate. */ |
186 | |
|
|
187 | if (!op->level) |
185 | if (!op->level) |
188 | { |
|
|
189 | return; |
186 | return; |
190 | } /* runes of level zero cannot detonate. */ |
187 | |
191 | det = op->invisible; |
188 | int det = op->invisible; |
|
|
189 | |
192 | if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) |
190 | if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) |
193 | { |
191 | { |
194 | op->invisible = 0; |
192 | op->invisible = 0; |
195 | op->speed_left -= 1; |
193 | op->speed_left -= 1; |
196 | } |
194 | } |
197 | else |
195 | else |
198 | op->invisible = 1; |
196 | op->invisible = 1; |
|
|
197 | |
199 | if (op->invisible != det) |
198 | if (op->invisible != det) |
200 | update_object (op, UP_OBJ_FACE); |
199 | update_object (op, UP_OBJ_FACE); |
201 | } |
200 | } |
202 | |
201 | |
203 | |
202 | |