ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/rune.C
(Generate patch)

Comparing deliantra/server/server/rune.C (file contents):
Revision 1.12 by root, Mon Dec 18 03:00:02 2006 UTC vs.
Revision 1.19 by root, Fri Feb 2 22:49:11 2007 UTC

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#ifndef __CEXTRACT__
26# include <sproto.h> 26#include <sproto.h>
27#endif
28#include <spells.h> 27#include <spells.h>
29
30 28
31#ifndef sqr 29#ifndef sqr
32# define sqr(x) ((x)*(x)) 30# define sqr(x) ((x)*(x))
33#endif 31#endif
34
35 32
36/* peterm: 33/* peterm:
37 * write_rune: 34 * write_rune:
38 * op: rune writer 35 * op: rune writer
39 * skop: skill object used for casting this rune 36 * skop: skill object used for casting this rune
59 56
60 nx = op->x + freearr_x[dir]; 57 nx = op->x + freearr_x[dir];
61 ny = op->y + freearr_y[dir]; 58 ny = op->y + freearr_y[dir];
62 m = op->map; 59 m = op->map;
63 60
64 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))
65 { 62 {
66 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!");
67 return 0; 64 return 0;
68 } 65 }
69 66
70 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)
71 if (tmp->type == RUNE) 68 if (tmp->type == RUNE)
72 break; 69 break;
73 70
74 if (tmp) 71 if (tmp)
75 { 72 {
147 op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); 144 op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA);
148 } 145 }
149 146
150 /* already proper rune. Note this should only be the case if other_arch was set */ 147 /* already proper rune. Note this should only be the case if other_arch was set */
151 if (rune_spell->type == RUNE) 148 if (rune_spell->type == RUNE)
152 {
153 rune = rune_spell; 149 rune = rune_spell;
154 }
155 else 150 else
156 { 151 {
157 rune = get_archetype (GENERIC_RUNE); 152 rune = get_archetype (GENERIC_RUNE);
158 sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); 153 sprintf (buf, "You set off a rune of %s\n", &rune_spell->name);
159 rune->msg = buf; 154 rune->msg = buf;
160 tmp = rune_spell->clone (); 155 rune->insert (rune_spell->clone ());
161 insert_ob_in_ob (tmp, rune);
162 156
163 if (spell->face != blank_face) 157 if (spell->face != blank_face)
164 rune->face = spell->face; 158 rune->face = spell->face;
165 } 159 }
166 160
167 rune->level = caster_level (caster, spell); 161 rune->level = caster_level (caster, spell);
168 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ 162 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */
169 rune->x = nx;
170 rune->y = ny;
171 rune->map = m;
172 rune->direction = dir; /* where any spell will go upon detonation */ 163 rune->direction = dir; /* where any spell will go upon detonation */
173 rune->set_owner (op); /* runes without need no owner */ 164 rune->set_owner (op); /* runes without need no owner */
174 set_spell_skill (op, caster, spell, rune); 165 set_spell_skill (op, caster, spell, rune);
175 insert_ob_in_map (rune, m, op, 0); 166
167 m->insert (rune, nx, ny, op);
176 return 1; 168 return 1;
177
178} 169}
179
180
181 170
182/* move_rune: peterm 171/* move_rune: peterm
183 comments on runes: 172 comments on runes:
184 rune->level : level at which rune will cast its spell. 173 rune->level : level at which rune will cast its spell.
185 rune->hp : number of detonations before rune goes away 174 rune->hp : number of detonations before rune goes away
189 rune->attacktype: type of damage it does, if not casting spells 178 rune->attacktype: type of damage it does, if not casting spells
190 rune->other_arch: spell in the rune 179 rune->other_arch: spell in the rune
191 rune->Cha : how hidden the rune is 180 rune->Cha : how hidden the rune is
192 rune->maxhp : number of spells the rune casts 181 rune->maxhp : number of spells the rune casts
193*/ 182*/
194
195void 183void
196move_rune (object *op) 184move_rune (object *op)
197{ 185{
198 int det = 0; 186 /* runes of level zero cannot detonate. */
199
200 if (!op->level) 187 if (!op->level)
201 {
202 return; 188 return;
203 } /* runes of level zero cannot detonate. */ 189
204 det = op->invisible; 190 int det = op->invisible;
191
205 if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) 192 if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1)))
206 { 193 {
207 op->invisible = 0; 194 op->invisible = 0;
208 op->speed_left -= 1; 195 op->speed_left -= 1;
209 } 196 }
210 else 197 else
211 op->invisible = 1; 198 op->invisible = 1;
199
212 if (op->invisible != det) 200 if (op->invisible != det)
213 update_object (op, UP_OBJ_FACE); 201 update_object (op, UP_OBJ_FACE);
214} 202}
215 203
216 204
357 { 345 {
358 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); 346 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!");
359 return 0; 347 return 0;
360 } 348 }
361 349
362 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 350 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
363 { 351 {
364 if (tmp->type == RUNE || tmp->type == TRAP) 352 if (tmp->type == RUNE || tmp->type == TRAP)
365 break; 353 break;
366 354
367 /* we could put a probability chance here, but since nothing happens 355 /* we could put a probability chance here, but since nothing happens
420} 408}
421 409
422int 410int
423trap_show (object *trap, object *where) 411trap_show (object *trap, object *where)
424{ 412{
425 object *tmp2;
426
427 if (where == NULL) 413 if (where == NULL)
428 return 0; 414 return 0;
415
429 tmp2 = get_archetype ("runedet"); 416 object *tmp = get_archetype ("runedet");
430 tmp2->face = &new_faces[GET_ANIMATION (trap, 0)]; 417 tmp->face = &new_faces[GET_ANIMATION (trap, 0)];
431 tmp2->x = where->x; 418 tmp->insert_at (where, 0);
432 tmp2->y = where->y; 419
433 tmp2->map = where->map;
434 insert_ob_in_map (tmp2, where->map, NULL, 0);
435 return 1; 420 return 1;
436
437} 421}
438
439 422
440int 423int
441trap_disarm (object *disarmer, object *trap, int risk, object *skill) 424trap_disarm (object *disarmer, object *trap, int risk, object *skill)
442{ 425{
443 int trapworth; /* need to compute the experience worth of the trap 426 int trapworth; /* need to compute the experience worth of the trap

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines