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.43 by root, Mon Oct 12 14:00:59 2009 UTC vs.
Revision 1.55 by root, Mon Oct 29 23:55:55 2012 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,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2003 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * 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 Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <sproto.h> 26#include <sproto.h>
70 new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune on top of another rune."); 70 new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune on top of another rune.");
71 return 0; 71 return 0;
72 } 72 }
73 73
74 if (spell->other_arch) 74 if (spell->other_arch)
75 rune_spell = arch_to_object (spell->other_arch); 75 rune_spell = spell->other_arch->instance ();
76 else 76 else
77 { 77 {
78 /* Player specified spell. The player has to know the spell, so 78 /* Player specified spell. The player has to know the spell, so
79 * lets just look through the players inventory see if they know it 79 * lets just look through the players inventory see if they know it
80 * use the item_matched_string for our typical matching method. 80 * use the item_matched_string for our typical matching method.
142 /* already proper rune. Note this should only be the case if other_arch was set */ 142 /* already proper rune. Note this should only be the case if other_arch was set */
143 if (rune_spell->type == RUNE) 143 if (rune_spell->type == RUNE)
144 rune = rune_spell; 144 rune = rune_spell;
145 else 145 else
146 { 146 {
147 rune = get_archetype (GENERIC_RUNE); 147 rune = archetype::get (GENERIC_RUNE);
148 rune->msg = format ("You set off a rune of %s\n", &rune_spell->name); 148 rune->msg = format ("You set off a rune of %s\n", &rune_spell->name);
149 rune->insert (rune_spell->clone ()); 149 rune->insert (rune_spell->clone ());
150 150
151 if (spell->face != blank_face) 151 if (spell->face != blank_face)
152 rune->face = spell->face; 152 rune->face = spell->face;
181 if (!op->level) 181 if (!op->level)
182 return; 182 return;
183 183
184 int det = op->invisible; 184 int det = op->invisible;
185 185
186 if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) 186 if (!(rndm (0, max (0, op->stats.Cha - 1))))
187 { 187 {
188 op->invisible = 0; 188 op->invisible = 0;
189 op->speed_left -= 1; 189 op->speed_left -= 1;
190 } 190 }
191 else 191 else
196} 196}
197 197
198/* peterm: rune_attack 198/* peterm: rune_attack
199 * function handles those runes which detonate but do not cast spells. 199 * function handles those runes which detonate but do not cast spells.
200 */ 200 */
201void 201static void
202rune_attack (object *op, object *victim) 202rune_attack (object *op, object *victim)
203{ 203{
204 if (victim) 204 if (victim)
205 { 205 {
206 hit_player (victim, op->stats.dam, op, op->attacktype, 1); 206 hit_player (victim, op->stats.dam, op, op->attacktype, 1);
237 237
238 /* Prevent recursion */ 238 /* Prevent recursion */
239 if (trap->stats.hp <= 0) 239 if (trap->stats.hp <= 0)
240 return; 240 return;
241 241
242 if (QUERY_FLAG (trap, FLAG_IS_LINKED)) 242 if (trap->flag [FLAG_IS_LINKED])
243 use_trigger (trap, victim); 243 use_trigger (trap, victim);
244 244
245 /* Only living objects can trigger runes that don't cast spells, as 245 /* Only living objects can trigger runes that don't cast spells, as
246 * doing direct damage to a non-living object doesn't work anyway. 246 * doing direct damage to a non-living object doesn't work anyway.
247 * Typical example is an arrow attacking a door. 247 * Typical example is an arrow attacking a door.
248 */ 248 */
249 if (!QUERY_FLAG (victim, FLAG_ALIVE) && !trap->inv && !trap->other_arch) 249 if (!victim->flag [FLAG_ALIVE] && !trap->inv && !trap->other_arch)
250 return; 250 return;
251 251
252 trap->stats.hp--; /*decrement detcount */ 252 trap->stats.hp--; /*decrement detcount */
253 253
254 if (victim && victim->type == PLAYER) 254 if (victim && victim->type == PLAYER)
285 // do not work like summon golem spells at all but still require 285 // do not work like summon golem spells at all but still require
286 // direction "0" to work at all. 286 // direction "0" to work at all.
287 //if (trap->direction) 287 //if (trap->direction)
288 // rv.direction = trap->direction; 288 // rv.direction = trap->direction;
289 289
290 for (i = 0; i < MAX (1, trap->stats.maxhp); i++) 290 for (i = 0; i < max (1, trap->stats.maxhp); i++)
291 { 291 {
292 if (trap->inv) 292 if (trap->inv)
293 cast_spell (env, trap, trap->direction, trap->inv, NULL); 293 cast_spell (env, trap, trap->direction, trap->inv, NULL);
294 else 294 else
295 { 295 {
296 object *spell = arch_to_object (trap->other_arch); 296 object *spell = trap->other_arch->instance ();
297 297
298 cast_spell (env, trap, trap->direction, spell, NULL); 298 cast_spell (env, trap, trap->direction, spell, NULL);
299 spell->destroy (); 299 spell->destroy ();
300 } 300 }
301 } 301 }
309 309
310 if (trap->stats.hp <= 0) 310 if (trap->stats.hp <= 0)
311 { 311 {
312 trap->type = SIGN; /* make the trap impotent */ 312 trap->type = SIGN; /* make the trap impotent */
313 trap->stats.food = 20; /* make it stick around until its spells are gone */ 313 trap->stats.food = 20; /* make it stick around until its spells are gone */
314 SET_FLAG (trap, FLAG_IS_USED_UP); 314 trap->set_flag (FLAG_IS_USED_UP);
315 } 315 }
316} 316}
317 317
318/* dispel_rune: by peterm 318/* dispel_rune: by peterm
319 * dispels the target rune, depending on the level of the actor 319 * dispels the target rune, depending on the level of the actor
388} 388}
389 389
390int 390int
391trap_see (object *op, object *trap) 391trap_see (object *op, object *trap)
392{ 392{
393 int chance;
394
395 chance = random_roll (0, 99, op, PREFER_HIGH);; 393 int chance = random_roll (0, 99, op, PREFER_HIGH);
396 394
397 /* decide if we see the rune or not */ 395 /* decide if we see the rune or not */
398 if ((trap->stats.Cha == 1) || (chance > MIN (95, MAX (5, ((int) ((float) (op->map->difficulty 396 if ((trap->stats.Cha == 1) || (chance > min (95, max (5, ((int) ((float) (op->map->difficulty
399 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) 397 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0))))))
400 { 398 {
401 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); 399 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name);
402 return 1; 400 return 1;
403 } 401 }
409trap_show (object *trap, object *where) 407trap_show (object *trap, object *where)
410{ 408{
411 if (where == NULL) 409 if (where == NULL)
412 return 0; 410 return 0;
413 411
414 object *tmp = get_archetype ("runedet"); 412 object *tmp = archetype::get (shstr_runedet);
415 tmp->face = trap->get_anim_frame (0); 413 tmp->face = trap->get_anim_frame (0);
416 tmp->insert_at (where, 0); 414 tmp->insert_at (where, 0);
417 415
418 return 1; 416 return 1;
419} 417}
422trap_disarm (object *disarmer, object *trap, int risk, object *skill) 420trap_disarm (object *disarmer, object *trap, int risk, object *skill)
423{ 421{
424 int trapworth; /* need to compute the experience worth of the trap before we kill it */ 422 int trapworth; /* need to compute the experience worth of the trap before we kill it */
425 423
426 /* this formula awards a more reasonable amount of exp */ 424 /* this formula awards a more reasonable amount of exp */
427 trapworth = MAX (1, trap->level) 425 trapworth = max (1, trap->level)
428 * disarmer->map->difficulty 426 * disarmer->map->difficulty
429 * sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) 427 * sqr (max (trap->stats.dam, trap->inv ? trap->inv->level : 1))
430 / skill->level; 428 / skill->level;
431 429
432 if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) 430 if (!(random_roll (0, (max (2, min (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW)))
433 { 431 {
434 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); 432 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name);
435 trap->destroy (); 433 trap->destroy ();
436 434
437 /* If it is your own trap, (or any players trap), don't you don't 435 /* If it is your own trap, (or any players trap), don't you don't
443 return 1; /* give minimal exp and say success */ 441 return 1; /* give minimal exp and say success */
444 } 442 }
445 else 443 else
446 { 444 {
447 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You fail to disarm the %s.", &trap->name); 445 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You fail to disarm the %s.", &trap->name);
448 if (!(random_roll (0, (MAX (2, skill->level - trap->level + disarmer->stats.Dex / 2 - 6)) - 1, disarmer, PREFER_LOW)) && risk) 446 if (!(random_roll (0, (max (2, skill->level - trap->level + disarmer->stats.Dex / 2 - 6)) - 1, disarmer, PREFER_LOW)) && risk)
449 { 447 {
450 new_draw_info (NDI_UNIQUE, 0, disarmer, "In fact, you set it off!"); 448 new_draw_info (NDI_UNIQUE, 0, disarmer, "In fact, you set it off!");
451 spring_trap (trap, disarmer); 449 spring_trap (trap, disarmer);
452 } 450 }
453 return 0; 451 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines