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.30 by root, Thu Nov 8 19:43:28 2007 UTC vs.
Revision 1.39 by root, Sun Jan 4 22:39:59 2009 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra 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 * Deliantra 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
33 * write_rune: 33 * write_rune:
34 * op: rune writer 34 * op: rune writer
35 * skop: skill object used for casting this rune 35 * skop: skill object used for casting this rune
36 * dir: orientation of rune, direction rune's contained spell will 36 * dir: orientation of rune, direction rune's contained spell will
37 * be cast in, if applicable 37 * be cast in, if applicable
38 * inspell: spell object to put into the rune, can be null if doing 38 * spell: spell object to put into the rune
39 * a marking rune.
40 * level: level of casting of the rune 39 * level: level of casting of the rune
41 * runename: name of the rune or message displayed by the rune for 40 * runename: name of the rune or message displayed by the rune for
42 * a rune of marking 41 * a rune of marking
43 */ 42 */
44
45int 43int
46write_rune (object *op, object *caster, object *spell, int dir, const char *runename) 44write_rune (object *op, object *caster, object *spell, int dir, const char *runename)
47{ 45{
48 object *tmp, *rune_spell, *rune; 46 object *tmp, *rune_spell, *rune;
49 char buf[MAX_BUF];
50 maptile *m; 47 maptile *m;
51 sint16 nx, ny; 48 sint16 nx, ny;
52 49
53 if (!dir) 50 if (!dir)
54 dir = 1; 51 dir = 1;
101 } 98 }
102 } 99 }
103 100
104 if (!rune_spell) 101 if (!rune_spell)
105 { 102 {
106 new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); 103 new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s.", runename);
107 return 0; 104 return 0;
108 } 105 }
109 106
110 if (rune_spell->skill != spell->skill) 107 if (rune_spell->skill != spell->skill)
111 { 108 {
112 new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); 109 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; 110 return 0;
114 } 111 }
115 112
116 if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) 113 if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST])
117 { 114 {
118 new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); 115 new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name);
119 return 0; 116 return 0;
120 } 117 }
121 118
122 if (caster_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) 119 if (casting_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST])
123 { 120 {
124 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); 121 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; 122 return 0;
126 } 123 }
127 124
128 if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) 125 if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp)
129 { 126 {
136 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); 133 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace.");
137 return 0; 134 return 0;
138 } 135 }
139 136
140 op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); 137 op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE);
141 op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); 138 op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA);
142 } 139 }
143 140
144 /* already proper rune. Note this should only be the case if other_arch was set */ 141 /* already proper rune. Note this should only be the case if other_arch was set */
145 if (rune_spell->type == RUNE) 142 if (rune_spell->type == RUNE)
146 rune = rune_spell; 143 rune = rune_spell;
147 else 144 else
148 { 145 {
149 rune = get_archetype (GENERIC_RUNE); 146 rune = get_archetype (GENERIC_RUNE);
150 sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); 147 rune->msg = format ("You set off a rune of %s\n", &rune_spell->name);
151 rune->msg = buf;
152 rune->insert (rune_spell->clone ()); 148 rune->insert (rune_spell->clone ());
153 149
154 if (spell->face != blank_face) 150 if (spell->face != blank_face)
155 rune->face = spell->face; 151 rune->face = spell->face;
156 } 152 }
157 153
158 rune->level = caster_level (caster, spell); 154 rune->level = casting_level (caster, spell);
159 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ 155 rune->stats.Cha = rune->level / 2; /* the invisibility parameter */
160 rune->direction = dir; /* where any spell will go upon detonation */ 156 rune->direction = dir; /* where any spell will go upon detonation */
161 rune->set_owner (op); /* runes without need no owner */ 157 rune->set_owner (op); /* runes without need no owner */
162 set_spell_skill (op, caster, spell, rune); 158 set_spell_skill (op, caster, spell, rune);
163 159
258 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); 254 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg);
259 255
260 /* Flash an image of the trap on the map so the poor sod 256 /* Flash an image of the trap on the map so the poor sod
261 * knows what hit him. 257 * knows what hit him.
262 */ 258 */
263 env = object_get_env_recursive (trap); 259 env = trap->outer_env ();
264 260
265 /* If the victim is not next to this trap, don't set it off. 261 /* 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. 262 * 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 263 * At the same time, the trap will stick around until detonated
268 */ 264 */
279 // creatures know who to attack. 275 // creatures know who to attack.
280 276
281 /* Only if it is a spell do we proceed here */ 277 /* Only if it is a spell do we proceed here */
282 if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL)) 278 if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL))
283 { 279 {
284
285 if (trap->destroyed ()) 280 if (trap->destroyed ())
286 return; 281 return;
287 282
288 // breaks summon golem spells, which, for inexplicable reasons, 283 // breaks summon golem spells, which, for inexplicable reasons,
289 // do not work like summon golem spells at all but still require 284 // do not work like summon golem spells at all but still require
345 { 340 {
346 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); 341 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!");
347 return 0; 342 return 0;
348 } 343 }
349 344
350 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 345 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
351 { 346 {
352 if (tmp->type == RUNE || tmp->type == TRAP) 347 if (tmp->type == RUNE || tmp->type == TRAP)
353 break; 348 break;
354 349
355 /* we could put a probability chance here, but since nothing happens 350 /* we could put a probability chance here, but since nothing happens
356 * if you fail, no point on that. I suppose we could do a level 351 * if you fail, no point on that. I suppose we could do a level
357 * comparison so low level players can't erase high level players runes. 352 * comparison so low level players can't erase high level players runes.
358 */ 353 */
359 if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark")) 354 if (tmp->type == SIGN && tmp->arch->archname == shstr_rune_mark)
360 { 355 {
361 tmp->destroy (); 356 tmp->destroy ();
362 new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); 357 new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!");
363 return 1; 358 return 1;
364 } 359 }
365 360
366 /* now search tmp's inventory for traps 361 /* now search tmp's inventory for traps
367 * This is for chests, where the rune is in the chests inventory. 362 * This is for chests, where the rune is in the chests inventory.
368 */ 363 */
369 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) 364 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below)
370 { 365 {
371 if (tmp2->type == RUNE || tmp2->type == TRAP) 366 if (tmp2->type == RUNE || tmp2->type == TRAP)
372 { 367 {
373 tmp = tmp2; 368 tmp = tmp2;
374 searchflag = 0; 369 searchflag = 0;
375 break; 370 break;
376 } 371 }
377 } 372 }
373
378 if (!searchflag) 374 if (!searchflag)
379 break; 375 break;
380 } 376 }
381 377
382 /* no rune there. */ 378 /* no rune there. */
383 if (tmp == NULL) 379 if (tmp == NULL)
384 { 380 {
385 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); 381 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!");
386 return 0; 382 return 0;
387 } 383 }
384
388 trap_disarm (op, tmp, 0, skill); 385 trap_disarm (op, tmp, 0, skill);
389 return 1; 386 return 1;
390
391} 387}
392 388
393int 389int
394trap_see (object *op, object *trap) 390trap_see (object *op, object *trap)
395{ 391{
402 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) 398 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0))))))
403 { 399 {
404 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); 400 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name);
405 return 1; 401 return 1;
406 } 402 }
403
407 return 0; 404 return 0;
408} 405}
409 406
410int 407int
411trap_show (object *trap, object *where) 408trap_show (object *trap, object *where)
421} 418}
422 419
423int 420int
424trap_disarm (object *disarmer, object *trap, int risk, object *skill) 421trap_disarm (object *disarmer, object *trap, int risk, object *skill)
425{ 422{
426 int trapworth; /* need to compute the experience worth of the trap 423 int trapworth; /* need to compute the experience worth of the trap before we kill it */
427 before we kill it */
428 424
429 /* this formula awards a more reasonable amount of exp */ 425 /* this formula awards a more reasonable amount of exp */
430 trapworth = MAX (1, trap->level) * disarmer->map->difficulty * 426 trapworth = MAX (1, trap->level)
427 * disarmer->map->difficulty
431 sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) / skill->level; 428 * sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1))
429 / skill->level;
432 430
433 if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) 431 if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW)))
434 { 432 {
435 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); 433 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name);
436 trap->destroy (1); 434 trap->destroy ();
437 435
438 /* If it is your own trap, (or any players trap), don't you don't 436 /* If it is your own trap, (or any players trap), don't you don't
439 * get exp for it. 437 * get exp for it.
440 */ 438 */
441 if (trap->owner && trap->owner->type != PLAYER && risk) 439 if (trap->owner && trap->owner->type != PLAYER && risk)
453 } 451 }
454 return 0; 452 return 0;
455 } 453 }
456} 454}
457 455
458
459/* traps need to be adjusted for the difficulty of the map. The 456/* traps need to be adjusted for the difficulty of the map. The
460 * default traps are too strong for wimpy level 1 players, and 457 * default traps are too strong for wimpy level 1 players, and
461 * unthreatening to anyone of high level 458 * unthreatening to anyone of high level
462 */ 459 */
463
464void 460void
465trap_adjust (object *trap, int difficulty) 461trap_adjust (object *trap, int difficulty)
466{ 462{
467 int i; 463 int i;
468 464

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines