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 (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | |
7 | * |
7 | 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 |
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 3 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, see <http://www.gnu.org/licenses/>. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * |
20 | |
|
|
21 | 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> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <sproto.h> |
25 | #include <sproto.h> |
26 | #include <spells.h> |
26 | #include <spells.h> |
27 | |
27 | |
… | |
… | |
55 | |
55 | |
56 | nx = op->x + freearr_x[dir]; |
56 | nx = op->x + freearr_x[dir]; |
57 | ny = op->y + freearr_y[dir]; |
57 | ny = op->y + freearr_y[dir]; |
58 | m = op->map; |
58 | m = op->map; |
59 | |
59 | |
60 | 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)) |
61 | { |
61 | { |
62 | 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!"); |
63 | return 0; |
63 | return 0; |
64 | } |
64 | } |
65 | |
65 | |
66 | 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) |
67 | if (tmp->type == RUNE) |
67 | if (tmp->type == RUNE) |
68 | break; |
68 | break; |
69 | |
69 | |
70 | if (tmp) |
70 | if (tmp) |
71 | { |
71 | { |
72 | 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."); |
73 | return 0; |
73 | return 0; |
74 | } |
74 | } |
75 | |
75 | |
76 | if (spell->other_arch) |
76 | if (spell->other_arch) |
77 | rune_spell = arch_to_object (spell->other_arch); |
77 | rune_spell = arch_to_object (spell->other_arch); |
… | |
… | |
89 | return 0; |
89 | return 0; |
90 | } |
90 | } |
91 | |
91 | |
92 | rune_spell = NULL; |
92 | rune_spell = NULL; |
93 | for (tmp = op->inv; tmp; tmp = tmp->below) |
93 | for (tmp = op->inv; tmp; tmp = tmp->below) |
94 | { |
|
|
95 | if (tmp->type == SPELL) |
94 | if (tmp->type == SPELL) |
96 | { |
95 | { |
97 | ms = item_matched_string (op, tmp, runename); |
96 | ms = item_matched_string (op, tmp, runename); |
98 | if (ms > bestmatch) |
97 | if (ms > bestmatch) |
99 | { |
98 | { |
100 | bestmatch = ms; |
99 | bestmatch = ms; |
101 | rune_spell = tmp; |
100 | rune_spell = tmp; |
102 | } |
101 | } |
103 | } |
102 | } |
104 | } |
|
|
105 | |
103 | |
106 | if (!rune_spell) |
104 | if (!rune_spell) |
107 | { |
105 | { |
108 | 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); |
109 | return 0; |
107 | return 0; |
… | |
… | |
113 | { |
111 | { |
114 | 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); |
115 | return 0; |
113 | return 0; |
116 | } |
114 | } |
117 | |
115 | |
118 | if (caster->path_denied & spell->path_attuned) |
116 | if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) |
119 | { |
117 | { |
120 | 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); |
121 | return 0; |
119 | return 0; |
122 | } |
120 | } |
123 | |
121 | |
124 | if (caster_level (caster, rune_spell) < rune_spell->level) |
122 | if (caster_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) |
125 | { |
123 | { |
126 | 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); |
127 | return 0; |
125 | return 0; |
128 | } |
126 | } |
129 | |
127 | |
… | |
… | |
143 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
141 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
144 | } |
142 | } |
145 | |
143 | |
146 | /* already proper rune. Note this should only be the case if other_arch was set */ |
144 | /* already proper rune. Note this should only be the case if other_arch was set */ |
147 | if (rune_spell->type == RUNE) |
145 | if (rune_spell->type == RUNE) |
148 | { |
|
|
149 | rune = rune_spell; |
146 | rune = rune_spell; |
150 | } |
|
|
151 | else |
147 | else |
152 | { |
148 | { |
153 | rune = get_archetype (GENERIC_RUNE); |
149 | rune = get_archetype (GENERIC_RUNE); |
154 | sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); |
150 | sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); |
155 | rune->msg = buf; |
151 | rune->msg = buf; |
156 | tmp = rune_spell->clone (); |
152 | rune->insert (rune_spell->clone ()); |
157 | insert_ob_in_ob (tmp, rune); |
|
|
158 | |
153 | |
159 | if (spell->face != blank_face) |
154 | if (spell->face != blank_face) |
160 | rune->face = spell->face; |
155 | rune->face = spell->face; |
161 | } |
156 | } |
162 | |
157 | |
163 | rune->level = caster_level (caster, spell); |
158 | rune->level = caster_level (caster, spell); |
164 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
159 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
165 | rune->x = nx; |
|
|
166 | rune->y = ny; |
|
|
167 | rune->map = m; |
|
|
168 | rune->direction = dir; /* where any spell will go upon detonation */ |
160 | rune->direction = dir; /* where any spell will go upon detonation */ |
169 | rune->set_owner (op); /* runes without need no owner */ |
161 | rune->set_owner (op); /* runes without need no owner */ |
170 | set_spell_skill (op, caster, spell, rune); |
162 | set_spell_skill (op, caster, spell, rune); |
171 | insert_ob_in_map (rune, m, op, 0); |
163 | |
|
|
164 | m->insert (rune, nx, ny, op); |
172 | return 1; |
165 | return 1; |
173 | |
|
|
174 | } |
166 | } |
175 | |
|
|
176 | |
|
|
177 | |
167 | |
178 | /* move_rune: peterm |
168 | /* move_rune: peterm |
179 | comments on runes: |
169 | comments on runes: |
180 | rune->level : level at which rune will cast its spell. |
170 | rune->level : level at which rune will cast its spell. |
181 | rune->hp : number of detonations before rune goes away |
171 | rune->hp : number of detonations before rune goes away |
… | |
… | |
185 | rune->attacktype: type of damage it does, if not casting spells |
175 | rune->attacktype: type of damage it does, if not casting spells |
186 | rune->other_arch: spell in the rune |
176 | rune->other_arch: spell in the rune |
187 | rune->Cha : how hidden the rune is |
177 | rune->Cha : how hidden the rune is |
188 | rune->maxhp : number of spells the rune casts |
178 | rune->maxhp : number of spells the rune casts |
189 | */ |
179 | */ |
190 | |
|
|
191 | void |
180 | void |
192 | move_rune (object *op) |
181 | move_rune (object *op) |
193 | { |
182 | { |
194 | int det = 0; |
183 | /* runes of level zero cannot detonate. */ |
195 | |
|
|
196 | if (!op->level) |
184 | if (!op->level) |
197 | { |
|
|
198 | return; |
185 | return; |
199 | } /* runes of level zero cannot detonate. */ |
186 | |
200 | det = op->invisible; |
187 | int det = op->invisible; |
|
|
188 | |
201 | if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) |
189 | if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) |
202 | { |
190 | { |
203 | op->invisible = 0; |
191 | op->invisible = 0; |
204 | op->speed_left -= 1; |
192 | op->speed_left -= 1; |
205 | } |
193 | } |
206 | else |
194 | else |
207 | op->invisible = 1; |
195 | op->invisible = 1; |
|
|
196 | |
208 | if (op->invisible != det) |
197 | if (op->invisible != det) |
209 | update_object (op, UP_OBJ_FACE); |
198 | update_object (op, UP_OBJ_CHANGE); |
210 | } |
199 | } |
211 | |
|
|
212 | |
200 | |
213 | /* peterm: rune_attack |
201 | /* peterm: rune_attack |
214 | * function handles those runes which detonate but do not cast spells. |
202 | * function handles those runes which detonate but do not cast spells. |
215 | */ |
203 | */ |
216 | |
|
|
217 | |
|
|
218 | void |
204 | void |
219 | rune_attack (object *op, object *victim) |
205 | rune_attack (object *op, object *victim) |
220 | { |
206 | { |
221 | if (victim) |
207 | if (victim) |
222 | { |
208 | { |
… | |
… | |
284 | if (rv.distance > 1) |
270 | if (rv.distance > 1) |
285 | return; |
271 | return; |
286 | |
272 | |
287 | trap_show (trap, env); |
273 | trap_show (trap, env); |
288 | |
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 | |
289 | /* Only if it is a spell do we proceed here */ |
279 | /* Only if it is a spell do we proceed here */ |
290 | 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)) |
291 | { |
281 | { |
292 | |
282 | |
293 | if (trap->destroyed ()) |
283 | if (trap->destroyed ()) |
294 | return; |
284 | return; |
295 | |
285 | |
… | |
… | |
362 | |
352 | |
363 | /* we could put a probability chance here, but since nothing happens |
353 | /* we could put a probability chance here, but since nothing happens |
364 | * 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 |
365 | * 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. |
366 | */ |
356 | */ |
367 | if (tmp->type == SIGN && !strcmp (tmp->arch->name, "rune_mark")) |
357 | if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark")) |
368 | { |
358 | { |
369 | tmp->destroy (); |
359 | tmp->destroy (); |
370 | 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!"); |
371 | return 1; |
361 | return 1; |
372 | } |
362 | } |
… | |
… | |
416 | } |
406 | } |
417 | |
407 | |
418 | int |
408 | int |
419 | trap_show (object *trap, object *where) |
409 | trap_show (object *trap, object *where) |
420 | { |
410 | { |
421 | object *tmp2; |
|
|
422 | |
|
|
423 | if (where == NULL) |
411 | if (where == NULL) |
424 | return 0; |
412 | return 0; |
|
|
413 | |
425 | tmp2 = get_archetype ("runedet"); |
414 | object *tmp = get_archetype ("runedet"); |
426 | tmp2->face = &new_faces[GET_ANIMATION (trap, 0)]; |
415 | tmp->face = GET_ANIMATION (trap, 0); |
427 | tmp2->x = where->x; |
416 | tmp->insert_at (where, 0); |
428 | tmp2->y = where->y; |
417 | |
429 | tmp2->map = where->map; |
|
|
430 | insert_ob_in_map (tmp2, where->map, NULL, 0); |
|
|
431 | return 1; |
418 | return 1; |
432 | |
|
|
433 | } |
419 | } |
434 | |
|
|
435 | |
420 | |
436 | int |
421 | int |
437 | trap_disarm (object *disarmer, object *trap, int risk, object *skill) |
422 | trap_disarm (object *disarmer, object *trap, int risk, object *skill) |
438 | { |
423 | { |
439 | int trapworth; /* need to compute the experience worth of the trap |
424 | int trapworth; /* need to compute the experience worth of the trap |