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.28 by root, Sun Jul 1 05:00:20 2007 UTC vs.
Revision 1.37 by root, Sat Dec 20 01:46:46 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra 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 3 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,
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, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
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>
101 } 101 }
102 } 102 }
103 103
104 if (!rune_spell) 104 if (!rune_spell)
105 { 105 {
106 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);
107 return 0; 107 return 0;
108 } 108 }
109 109
110 if (rune_spell->skill != spell->skill) 110 if (rune_spell->skill != spell->skill)
111 { 111 {
112 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. H<The spell must be of the %s spell school.>", &rune_spell->name, &spell->name, &spell->skill);
113 return 0; 113 return 0;
114 } 114 }
115 115
116 if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) 116 if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST])
117 { 117 {
118 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);
119 return 0; 119 return 0;
120 } 120 }
121 121
122 if (caster_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) 122 if (casting_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST])
123 { 123 {
124 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! H<Your effetcive casting level is too low.>", &rune_spell->name);
125 return 0; 125 return 0;
126 } 126 }
127 127
128 if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) 128 if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp)
129 { 129 {
153 153
154 if (spell->face != blank_face) 154 if (spell->face != blank_face)
155 rune->face = spell->face; 155 rune->face = spell->face;
156 } 156 }
157 157
158 rune->level = caster_level (caster, spell); 158 rune->level = casting_level (caster, spell);
159 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ 159 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */
160 rune->direction = dir; /* where any spell will go upon detonation */ 160 rune->direction = dir; /* where any spell will go upon detonation */
161 rune->set_owner (op); /* runes without need no owner */ 161 rune->set_owner (op); /* runes without need no owner */
162 set_spell_skill (op, caster, spell, rune); 162 set_spell_skill (op, caster, spell, rune);
163 163
258 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); 258 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg);
259 259
260 /* Flash an image of the trap on the map so the poor sod 260 /* Flash an image of the trap on the map so the poor sod
261 * knows what hit him. 261 * knows what hit him.
262 */ 262 */
263 env = object_get_env_recursive (trap); 263 env = trap->outer_env ();
264 264
265 /* If the victim is not next to this trap, don't set it off. 265 /* If the victim is not next to this trap, don't set it off.
266 * players shouldn't get hit by firing arrows at a door for example. 266 * players shouldn't get hit by firing arrows at a door for example.
267 * At the same time, the trap will stick around until detonated 267 * At the same time, the trap will stick around until detonated
268 */ 268 */
269 get_rangevector (env, victim, &rv, 0); 269 get_rangevector (env, victim, &rv, 0);
270 if (rv.distance > 1) 270 if (rv.distance > 1)
271 return; 271 return;
272 272
273 env->play_sound (trap->sound ? trap->sound : sound_find ("trap_spring"));
274
273 trap_show (trap, env); 275 trap_show (trap, env);
274 276
275 if (victim->type == PLAYER) // only count players as enemies 277 if (victim->type == PLAYER) // only count players as enemies
276 trap->enemy = victim; // set the victim as the traps enemy, so that summoned 278 trap->enemy = victim; // set the victim as the traps enemy, so that summoned
277 // creatures know who to attack. 279 // creatures know who to attack.
278 280
279 /* Only if it is a spell do we proceed here */ 281 /* Only if it is a spell do we proceed here */
280 if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL)) 282 if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL))
281 { 283 {
282
283 if (trap->destroyed ()) 284 if (trap->destroyed ())
284 return; 285 return;
285 286
286 // breaks summon golem spells, which, for inexplicable reasons, 287 // breaks summon golem spells, which, for inexplicable reasons,
287 // do not work like summon golem spells at all but still require 288 // do not work like summon golem spells at all but still require
381 if (tmp == NULL) 382 if (tmp == NULL)
382 { 383 {
383 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); 384 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!");
384 return 0; 385 return 0;
385 } 386 }
387
386 trap_disarm (op, tmp, 0, skill); 388 trap_disarm (op, tmp, 0, skill);
387 return 1; 389 return 1;
388
389} 390}
390 391
391int 392int
392trap_see (object *op, object *trap) 393trap_see (object *op, object *trap)
393{ 394{
400 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) 401 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0))))))
401 { 402 {
402 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); 403 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name);
403 return 1; 404 return 1;
404 } 405 }
406
405 return 0; 407 return 0;
406} 408}
407 409
408int 410int
409trap_show (object *trap, object *where) 411trap_show (object *trap, object *where)
419} 421}
420 422
421int 423int
422trap_disarm (object *disarmer, object *trap, int risk, object *skill) 424trap_disarm (object *disarmer, object *trap, int risk, object *skill)
423{ 425{
424 int trapworth; /* need to compute the experience worth of the trap 426 int trapworth; /* need to compute the experience worth of the trap before we kill it */
425 before we kill it */
426 427
427 /* this formula awards a more reasonable amount of exp */ 428 /* this formula awards a more reasonable amount of exp */
428 trapworth = MAX (1, trap->level) * disarmer->map->difficulty * 429 trapworth = MAX (1, trap->level)
430 * disarmer->map->difficulty
429 sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) / skill->level; 431 * sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1))
432 / skill->level;
430 433
431 if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) 434 if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW)))
432 { 435 {
433 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); 436 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name);
434 trap->destroy (1); 437 trap->destroy ();
435 438
436 /* If it is your own trap, (or any players trap), don't you don't 439 /* If it is your own trap, (or any players trap), don't you don't
437 * get exp for it. 440 * get exp for it.
438 */ 441 */
439 if (trap->owner && trap->owner->type != PLAYER && risk) 442 if (trap->owner && trap->owner->type != PLAYER && risk)
451 } 454 }
452 return 0; 455 return 0;
453 } 456 }
454} 457}
455 458
456
457/* traps need to be adjusted for the difficulty of the map. The 459/* traps need to be adjusted for the difficulty of the map. The
458 * default traps are too strong for wimpy level 1 players, and 460 * default traps are too strong for wimpy level 1 players, and
459 * unthreatening to anyone of high level 461 * unthreatening to anyone of high level
460 */ 462 */
461
462void 463void
463trap_adjust (object *trap, int difficulty) 464trap_adjust (object *trap, int difficulty)
464{ 465{
465 int i; 466 int i;
466 467

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines