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.13 by root, Wed Dec 20 09:14:22 2006 UTC vs.
Revision 1.28 by root, Sun Jul 1 05:00:20 2007 UTC

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#ifndef __CEXTRACT__
26# include <sproto.h> 25#include <sproto.h>
27#endif
28#include <spells.h> 26#include <spells.h>
29
30 27
31#ifndef sqr 28#ifndef sqr
32# define sqr(x) ((x)*(x)) 29# define sqr(x) ((x)*(x))
33#endif 30#endif
34
35 31
36/* peterm: 32/* peterm:
37 * write_rune: 33 * write_rune:
38 * op: rune writer 34 * op: rune writer
39 * skop: skill object used for casting this rune 35 * skop: skill object used for casting this rune
59 55
60 nx = op->x + freearr_x[dir]; 56 nx = op->x + freearr_x[dir];
61 ny = op->y + freearr_y[dir]; 57 ny = op->y + freearr_y[dir];
62 m = op->map; 58 m = op->map;
63 59
64 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))
65 { 61 {
66 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!");
67 return 0; 63 return 0;
68 } 64 }
69 65
70 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)
71 if (tmp->type == RUNE) 67 if (tmp->type == RUNE)
72 break; 68 break;
73 69
74 if (tmp) 70 if (tmp)
75 { 71 {
76 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.");
77 return 0; 73 return 0;
78 } 74 }
79 75
80 if (spell->other_arch) 76 if (spell->other_arch)
81 rune_spell = arch_to_object (spell->other_arch); 77 rune_spell = arch_to_object (spell->other_arch);
93 return 0; 89 return 0;
94 } 90 }
95 91
96 rune_spell = NULL; 92 rune_spell = NULL;
97 for (tmp = op->inv; tmp; tmp = tmp->below) 93 for (tmp = op->inv; tmp; tmp = tmp->below)
98 {
99 if (tmp->type == SPELL) 94 if (tmp->type == SPELL)
100 { 95 {
101 ms = item_matched_string (op, tmp, runename); 96 ms = item_matched_string (op, tmp, runename);
102 if (ms > bestmatch) 97 if (ms > bestmatch)
103 { 98 {
104 bestmatch = ms; 99 bestmatch = ms;
105 rune_spell = tmp; 100 rune_spell = tmp;
106 } 101 }
107 } 102 }
108 }
109 103
110 if (!rune_spell) 104 if (!rune_spell)
111 { 105 {
112 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);
113 return 0; 107 return 0;
117 { 111 {
118 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);
119 return 0; 113 return 0;
120 } 114 }
121 115
122 if (caster->path_denied & spell->path_attuned) 116 if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST])
123 { 117 {
124 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);
125 return 0; 119 return 0;
126 } 120 }
127 121
128 if (caster_level (caster, rune_spell) < rune_spell->level) 122 if (caster_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST])
129 { 123 {
130 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);
131 return 0; 125 return 0;
132 } 126 }
133 127
147 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);
148 } 142 }
149 143
150 /* 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 */
151 if (rune_spell->type == RUNE) 145 if (rune_spell->type == RUNE)
152 {
153 rune = rune_spell; 146 rune = rune_spell;
154 }
155 else 147 else
156 { 148 {
157 rune = get_archetype (GENERIC_RUNE); 149 rune = get_archetype (GENERIC_RUNE);
158 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);
159 rune->msg = buf; 151 rune->msg = buf;
160 tmp = rune_spell->clone (); 152 rune->insert (rune_spell->clone ());
161 insert_ob_in_ob (tmp, rune);
162 153
163 if (spell->face != blank_face) 154 if (spell->face != blank_face)
164 rune->face = spell->face; 155 rune->face = spell->face;
165 } 156 }
166 157
167 rune->level = caster_level (caster, spell); 158 rune->level = caster_level (caster, spell);
168 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ 159 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 */ 160 rune->direction = dir; /* where any spell will go upon detonation */
173 rune->set_owner (op); /* runes without need no owner */ 161 rune->set_owner (op); /* runes without need no owner */
174 set_spell_skill (op, caster, spell, rune); 162 set_spell_skill (op, caster, spell, rune);
175 insert_ob_in_map (rune, m, op, 0); 163
164 m->insert (rune, nx, ny, op);
176 return 1; 165 return 1;
177
178} 166}
179
180
181 167
182/* move_rune: peterm 168/* move_rune: peterm
183 comments on runes: 169 comments on runes:
184 rune->level : level at which rune will cast its spell. 170 rune->level : level at which rune will cast its spell.
185 rune->hp : number of detonations before rune goes away 171 rune->hp : number of detonations before rune goes away
189 rune->attacktype: type of damage it does, if not casting spells 175 rune->attacktype: type of damage it does, if not casting spells
190 rune->other_arch: spell in the rune 176 rune->other_arch: spell in the rune
191 rune->Cha : how hidden the rune is 177 rune->Cha : how hidden the rune is
192 rune->maxhp : number of spells the rune casts 178 rune->maxhp : number of spells the rune casts
193*/ 179*/
194
195void 180void
196move_rune (object *op) 181move_rune (object *op)
197{ 182{
198 int det = 0; 183 /* runes of level zero cannot detonate. */
199
200 if (!op->level) 184 if (!op->level)
201 {
202 return; 185 return;
203 } /* runes of level zero cannot detonate. */ 186
204 det = op->invisible; 187 int det = op->invisible;
188
205 if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) 189 if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1)))
206 { 190 {
207 op->invisible = 0; 191 op->invisible = 0;
208 op->speed_left -= 1; 192 op->speed_left -= 1;
209 } 193 }
210 else 194 else
211 op->invisible = 1; 195 op->invisible = 1;
196
212 if (op->invisible != det) 197 if (op->invisible != det)
213 update_object (op, UP_OBJ_FACE); 198 update_object (op, UP_OBJ_CHANGE);
214} 199}
215
216 200
217/* peterm: rune_attack 201/* peterm: rune_attack
218 * function handles those runes which detonate but do not cast spells. 202 * function handles those runes which detonate but do not cast spells.
219 */ 203 */
220
221
222void 204void
223rune_attack (object *op, object *victim) 205rune_attack (object *op, object *victim)
224{ 206{
225 if (victim) 207 if (victim)
226 { 208 {
288 if (rv.distance > 1) 270 if (rv.distance > 1)
289 return; 271 return;
290 272
291 trap_show (trap, env); 273 trap_show (trap, env);
292 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
293 /* Only if it is a spell do we proceed here */ 279 /* Only if it is a spell do we proceed here */
294 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))
295 { 281 {
296 282
297 if (trap->destroyed ()) 283 if (trap->destroyed ())
298 return; 284 return;
299 285
366 352
367 /* we could put a probability chance here, but since nothing happens 353 /* we could put a probability chance here, but since nothing happens
368 * 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
369 * 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.
370 */ 356 */
371 if (tmp->type == SIGN && !strcmp (tmp->arch->name, "rune_mark")) 357 if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark"))
372 { 358 {
373 tmp->destroy (); 359 tmp->destroy ();
374 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!");
375 return 1; 361 return 1;
376 } 362 }
420} 406}
421 407
422int 408int
423trap_show (object *trap, object *where) 409trap_show (object *trap, object *where)
424{ 410{
425 object *tmp2;
426
427 if (where == NULL) 411 if (where == NULL)
428 return 0; 412 return 0;
413
429 tmp2 = get_archetype ("runedet"); 414 object *tmp = get_archetype ("runedet");
430 tmp2->face = &new_faces[GET_ANIMATION (trap, 0)]; 415 tmp->face = GET_ANIMATION (trap, 0);
431 tmp2->x = where->x; 416 tmp->insert_at (where, 0);
432 tmp2->y = where->y; 417
433 tmp2->map = where->map;
434 insert_ob_in_map (tmp2, where->map, NULL, 0);
435 return 1; 418 return 1;
436
437} 419}
438
439 420
440int 421int
441trap_disarm (object *disarmer, object *trap, int risk, object *skill) 422trap_disarm (object *disarmer, object *trap, int risk, object *skill)
442{ 423{
443 int trapworth; /* need to compute the experience worth of the trap 424 int trapworth; /* need to compute the experience worth of the trap

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines