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.20 by root, Sun Feb 18 18:30:28 2007 UTC vs.
Revision 1.35 by root, Mon Sep 29 10:20:49 2008 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (C) 2003 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program 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 2 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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 22 */
24 23
25#include <global.h> 24#include <global.h>
26#include <sproto.h> 25#include <sproto.h>
27#include <spells.h> 26#include <spells.h>
118 { 117 {
119 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);
120 return 0; 119 return 0;
121 } 120 }
122 121
123 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])
124 { 123 {
125 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);
126 return 0; 125 return 0;
127 } 126 }
128 127
154 153
155 if (spell->face != blank_face) 154 if (spell->face != blank_face)
156 rune->face = spell->face; 155 rune->face = spell->face;
157 } 156 }
158 157
159 rune->level = caster_level (caster, spell); 158 rune->level = casting_level (caster, spell);
160 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ 159 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */
161 rune->direction = dir; /* where any spell will go upon detonation */ 160 rune->direction = dir; /* where any spell will go upon detonation */
162 rune->set_owner (op); /* runes without need no owner */ 161 rune->set_owner (op); /* runes without need no owner */
163 set_spell_skill (op, caster, spell, rune); 162 set_spell_skill (op, caster, spell, rune);
164 163
194 } 193 }
195 else 194 else
196 op->invisible = 1; 195 op->invisible = 1;
197 196
198 if (op->invisible != det) 197 if (op->invisible != det)
199 update_object (op, UP_OBJ_FACE); 198 update_object (op, UP_OBJ_CHANGE);
200} 199}
201
202 200
203/* peterm: rune_attack 201/* peterm: rune_attack
204 * function handles those runes which detonate but do not cast spells. 202 * function handles those runes which detonate but do not cast spells.
205 */ 203 */
206
207
208void 204void
209rune_attack (object *op, object *victim) 205rune_attack (object *op, object *victim)
210{ 206{
211 if (victim) 207 if (victim)
212 { 208 {
222 if (op->inv && op->inv->type == DISEASE) 218 if (op->inv && op->inv->type == DISEASE)
223 { 219 {
224 object *disease = op->inv; 220 object *disease = op->inv;
225 221
226 infect_object (victim, disease, 1); 222 infect_object (victim, disease, 1);
227 disease->destroy (); 223 disease->destroy (true);
228 } 224 }
229 } 225 }
230 else 226 else
231 hit_map (op, 0, op->attacktype, 1); 227 hit_map (op, 0, op->attacktype, 1);
232} 228}
262 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); 258 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg);
263 259
264 /* 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
265 * knows what hit him. 261 * knows what hit him.
266 */ 262 */
267 env = object_get_env_recursive (trap); 263 env = trap->outer_env ();
268 264
269 /* 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.
270 * 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.
271 * At the same time, the trap will stick around until detonated 267 * At the same time, the trap will stick around until detonated
272 */ 268 */
273 get_rangevector (env, victim, &rv, 0); 269 get_rangevector (env, victim, &rv, 0);
274 if (rv.distance > 1) 270 if (rv.distance > 1)
275 return; 271 return;
276 272
273 env->play_sound (trap->sound ? trap->sound : sound_find ("trap_spring"));
274
277 trap_show (trap, env); 275 trap_show (trap, env);
278 276
277 if (victim->type == PLAYER) // only count players as enemies
278 trap->enemy = victim; // set the victim as the traps enemy, so that summoned
279 // creatures know who to attack.
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->clone.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
296 else 297 else
297 { 298 {
298 object *spell = arch_to_object (trap->other_arch); 299 object *spell = arch_to_object (trap->other_arch);
299 300
300 cast_spell (env, trap, trap->direction, spell, NULL); 301 cast_spell (env, trap, trap->direction, spell, NULL);
301 spell->destroy (); 302 spell->destroy (true);
302 } 303 }
303 } 304 }
304 } 305 }
305 else 306 else
306 { 307 {
352 353
353 /* we could put a probability chance here, but since nothing happens 354 /* we could put a probability chance here, but since nothing happens
354 * if you fail, no point on that. I suppose we could do a level 355 * if you fail, no point on that. I suppose we could do a level
355 * comparison so low level players can't erase high level players runes. 356 * comparison so low level players can't erase high level players runes.
356 */ 357 */
357 if (tmp->type == SIGN && !strcmp (tmp->arch->name, "rune_mark")) 358 if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark"))
358 { 359 {
359 tmp->destroy (); 360 tmp->destroy (true);
360 new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); 361 new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!");
361 return 1; 362 return 1;
362 } 363 }
363 364
364 /* now search tmp's inventory for traps 365 /* now search tmp's inventory for traps
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)
410{ 412{
411 if (where == NULL) 413 if (where == NULL)
412 return 0; 414 return 0;
413 415
414 object *tmp = get_archetype ("runedet"); 416 object *tmp = get_archetype ("runedet");
415 tmp->face = &new_faces[GET_ANIMATION (trap, 0)]; 417 tmp->face = GET_ANIMATION (trap, 0);
416 tmp->insert_at (where, 0); 418 tmp->insert_at (where, 0);
417 419
418 return 1; 420 return 1;
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 (true);
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