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.55 by root, Mon Oct 29 23:55:55 2012 UTC vs.
Revision 1.58 by root, Sat Sep 16 22:17:42 2017 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,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2003 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2003 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 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
28 28
29#ifndef sqr 29#ifndef sqr
30# define sqr(x) ((x)*(x)) 30# define sqr(x) ((x)*(x))
31#endif 31#endif
32 32
33/* peterm: 33/* peterm:
34 * write_rune: 34 * write_rune:
35 * op: rune writer 35 * op: rune writer
36 * skop: skill object used for casting this rune 36 * skop: skill object used for casting this rune
37 * dir: orientation of rune, direction rune's contained spell will 37 * dir: orientation of rune, direction rune's contained spell will
38 * be cast in, if applicable 38 * be cast in, if applicable
39 * spell: spell object to put into the rune 39 * spell: spell object to put into the rune
40 * level: level of casting of the rune 40 * level: level of casting of the rune
41 * runename: name of the rune or message displayed by the rune for 41 * runename: name of the rune or message displayed by the rune for
42 * a rune of marking 42 * a rune of marking
43 */ 43 */
44int 44int
45write_rune (object *op, object *caster, object *spell, int dir, const char *runename) 45write_rune (object *op, object *caster, object *spell, int dir, const char *runename)
46{ 46{
47 object *tmp, *rune_spell, *rune; 47 object *tmp, *rune_spell, *rune;
49 sint16 nx, ny; 49 sint16 nx, ny;
50 50
51 if (!dir) 51 if (!dir)
52 dir = 1; 52 dir = 1;
53 53
54 nx = op->x + freearr_x[dir]; 54 nx = op->x + DIRX (dir);
55 ny = op->y + freearr_y[dir]; 55 ny = op->y + DIRY (dir);
56 m = op->map; 56 m = op->map;
57 57
58 if (get_map_flags (m, &m, nx, ny, &nx, &ny) & (P_OUT_OF_MAP | P_SAFE | P_NO_MAGIC | P_NO_CLERIC)) 58 if (get_map_flags (m, &m, nx, ny, &nx, &ny) & (P_OUT_OF_MAP | P_SAFE | P_NO_MAGIC | P_NO_CLERIC))
59 { 59 {
60 new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); 60 new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!");
194 if (op->invisible != det) 194 if (op->invisible != det)
195 update_object (op, UP_OBJ_CHANGE); 195 update_object (op, UP_OBJ_CHANGE);
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 */
201static void 201static void
202rune_attack (object *op, object *victim) 202rune_attack (object *op, object *victim)
203{ 203{
204 if (victim) 204 if (victim)
223 else 223 else
224 hit_map (op, 0, op->attacktype, 1); 224 hit_map (op, 0, op->attacktype, 1);
225} 225}
226 226
227/* This function generalizes attacks by runes/traps. This ought to make 227/* This function generalizes attacks by runes/traps. This ought to make
228 * it possible for runes to attack from the inventory, 228 * it possible for runes to attack from the inventory,
229 * it'll spring the trap on the victim. 229 * it'll spring the trap on the victim.
230 */ 230 */
231void 231void
232spring_trap (object *trap, object *victim) 232spring_trap (object *trap, object *victim)
233{ 233{
253 253
254 if (victim && victim->type == PLAYER) 254 if (victim && victim->type == PLAYER)
255 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); 255 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg);
256 256
257 /* Flash an image of the trap on the map so the poor sod 257 /* Flash an image of the trap on the map so the poor sod
258 * knows what hit him. 258 * knows what hit him.
259 */ 259 */
260 env = trap->outer_env_or_self (); 260 env = trap->outer_env_or_self ();
261 261
262 /* If the victim is not next to this trap, don't set it off. 262 /* If the victim is not next to this trap, don't set it off.
263 * players shouldn't get hit by firing arrows at a door for example. 263 * players shouldn't get hit by firing arrows at a door for example.
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 trap->set_flag (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
320 * and the level of the rune risk flag, if true, means that there is 320 * and the level of the rune risk flag, if true, means that there is
321 * a chance that the trap/rune will detonate 321 * a chance that the trap/rune will detonate
322 */ 322 */
323int 323int
324dispel_rune (object *op, object *caster, object *spell, object *skill, int dir) 324dispel_rune (object *op, object *caster, object *spell, object *skill, int dir)
325{ 325{
326 object *tmp, *tmp2; 326 object *tmp, *tmp2;
327 int searchflag = 1, mflags; 327 int searchflag = 1, mflags;
328 sint16 x, y; 328 sint16 x, y;
329 maptile *m; 329 maptile *m;
330 330
331 x = op->x + freearr_x[dir]; 331 x = op->x + DIRX (dir);
332 y = op->y + freearr_y[dir]; 332 y = op->y + DIRY (dir);
333 m = op->map; 333 m = op->map;
334 334
335 mflags = get_map_flags (m, &m, x, y, &x, &y); 335 mflags = get_map_flags (m, &m, x, y, &x, &y);
336 336
337 /* Should we perhaps not allow player to disable traps if a monster/ 337 /* Should we perhaps not allow player to disable traps if a monster/
338 * player is standing on top? 338 * player is standing on top?
339 */ 339 */
340 if (mflags & P_OUT_OF_MAP) 340 if (mflags & P_OUT_OF_MAP)
341 { 341 {
342 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); 342 new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!");
343 return 0; 343 return 0;
451 return 0; 451 return 0;
452 } 452 }
453} 453}
454 454
455/* traps need to be adjusted for the difficulty of the map. The 455/* traps need to be adjusted for the difficulty of the map. The
456 * default traps are too strong for wimpy level 1 players, and 456 * default traps are too strong for wimpy level 1 players, and
457 * unthreatening to anyone of high level 457 * unthreatening to anyone of high level
458 */ 458 */
459void 459void
460trap_adjust (object *trap, int difficulty) 460trap_adjust (object *trap, int difficulty)
461{ 461{
462 int i; 462 int i;
463 463
464 /* now we set the trap level to match the difficulty of the level 464 /* now we set the trap level to match the difficulty of the level
465 * the formula below will give a level from 1 to (2*difficulty) with 465 * the formula below will give a level from 1 to (2*difficulty) with
466 * a peak probability at difficulty 466 * a peak probability at difficulty
467 */ 467 */
468 468
469 trap->level = rndm (0, difficulty - 1) + rndm (0, difficulty - 1); 469 trap->level = rndm (0, difficulty - 1) + rndm (0, difficulty - 1);
470 if (trap->level < 1) 470 if (trap->level < 1)
471 trap->level = 1; 471 trap->level = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines