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.39 by root, Sun Jan 4 22:39:59 2009 UTC vs.
Revision 1.46 by root, Sun Nov 29 17:41:08 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,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009 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 it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your 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 GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * 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>
22 */ 23 */
23 24
24#include <global.h> 25#include <global.h>
69 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.");
70 return 0; 71 return 0;
71 } 72 }
72 73
73 if (spell->other_arch) 74 if (spell->other_arch)
74 rune_spell = arch_to_object (spell->other_arch); 75 rune_spell = spell->other_arch->instance ();
75 else 76 else
76 { 77 {
77 /* Player specified spell. The player has to know the spell, so 78 /* Player specified spell. The player has to know the spell, so
78 * 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
79 * use the item_matched_string for our typical matching method. 80 * use the item_matched_string for our typical matching method.
180 if (!op->level) 181 if (!op->level)
181 return; 182 return;
182 183
183 int det = op->invisible; 184 int det = op->invisible;
184 185
185 if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) 186 if (!(rndm (0, max (1, (op->stats.Cha)) - 1)))
186 { 187 {
187 op->invisible = 0; 188 op->invisible = 0;
188 op->speed_left -= 1; 189 op->speed_left -= 1;
189 } 190 }
190 else 191 else
195} 196}
196 197
197/* peterm: rune_attack 198/* peterm: rune_attack
198 * function handles those runes which detonate but do not cast spells. 199 * function handles those runes which detonate but do not cast spells.
199 */ 200 */
200void 201static void
201rune_attack (object *op, object *victim) 202rune_attack (object *op, object *victim)
202{ 203{
203 if (victim) 204 if (victim)
204 { 205 {
205 hit_player (victim, op->stats.dam, op, op->attacktype, 1); 206 hit_player (victim, op->stats.dam, op, op->attacktype, 1);
237 /* Prevent recursion */ 238 /* Prevent recursion */
238 if (trap->stats.hp <= 0) 239 if (trap->stats.hp <= 0)
239 return; 240 return;
240 241
241 if (QUERY_FLAG (trap, FLAG_IS_LINKED)) 242 if (QUERY_FLAG (trap, FLAG_IS_LINKED))
242 use_trigger (trap); 243 use_trigger (trap, victim);
243 244
244 /* 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
245 * 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.
246 * Typical example is an arrow attacking a door. 247 * Typical example is an arrow attacking a door.
247 */ 248 */
254 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); 255 new_draw_info (NDI_UNIQUE, 0, victim, trap->msg);
255 256
256 /* 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
257 * knows what hit him. 258 * knows what hit him.
258 */ 259 */
259 env = trap->outer_env (); 260 env = trap->outer_env_or_self ();
260 261
261 /* 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.
262 * 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.
263 * At the same time, the trap will stick around until detonated 264 * At the same time, the trap will stick around until detonated
264 */ 265 */
284 // 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
285 // direction "0" to work at all. 286 // direction "0" to work at all.
286 //if (trap->direction) 287 //if (trap->direction)
287 // rv.direction = trap->direction; 288 // rv.direction = trap->direction;
288 289
289 for (i = 0; i < MAX (1, trap->stats.maxhp); i++) 290 for (i = 0; i < max (1, trap->stats.maxhp); i++)
290 { 291 {
291 if (trap->inv) 292 if (trap->inv)
292 cast_spell (env, trap, trap->direction, trap->inv, NULL); 293 cast_spell (env, trap, trap->direction, trap->inv, NULL);
293 else 294 else
294 { 295 {
295 object *spell = arch_to_object (trap->other_arch); 296 object *spell = trap->other_arch->instance ();
296 297
297 cast_spell (env, trap, trap->direction, spell, NULL); 298 cast_spell (env, trap, trap->direction, spell, NULL);
298 spell->destroy (); 299 spell->destroy ();
299 } 300 }
300 } 301 }
392 int chance; 393 int chance;
393 394
394 chance = random_roll (0, 99, op, PREFER_HIGH);; 395 chance = random_roll (0, 99, op, PREFER_HIGH);;
395 396
396 /* decide if we see the rune or not */ 397 /* decide if we see the rune or not */
397 if ((trap->stats.Cha == 1) || (chance > MIN (95, MAX (5, ((int) ((float) (op->map->difficulty 398 if ((trap->stats.Cha == 1) || (chance > min (95, max (5, ((int) ((float) (op->map->difficulty
398 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) 399 + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0))))))
399 { 400 {
400 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); 401 new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name);
401 return 1; 402 return 1;
402 } 403 }
408trap_show (object *trap, object *where) 409trap_show (object *trap, object *where)
409{ 410{
410 if (where == NULL) 411 if (where == NULL)
411 return 0; 412 return 0;
412 413
413 object *tmp = get_archetype ("runedet"); 414 object *tmp = get_archetype (shstr_runedet);
414 tmp->face = GET_ANIMATION (trap, 0); 415 tmp->face = trap->get_anim_frame (0);
415 tmp->insert_at (where, 0); 416 tmp->insert_at (where, 0);
416 417
417 return 1; 418 return 1;
418} 419}
419 420
421trap_disarm (object *disarmer, object *trap, int risk, object *skill) 422trap_disarm (object *disarmer, object *trap, int risk, object *skill)
422{ 423{
423 int trapworth; /* need to compute the experience worth of the trap before we kill it */ 424 int trapworth; /* need to compute the experience worth of the trap before we kill it */
424 425
425 /* this formula awards a more reasonable amount of exp */ 426 /* this formula awards a more reasonable amount of exp */
426 trapworth = MAX (1, trap->level) 427 trapworth = max (1, trap->level)
427 * disarmer->map->difficulty 428 * disarmer->map->difficulty
428 * sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) 429 * sqr (max (trap->stats.dam, trap->inv ? trap->inv->level : 1))
429 / skill->level; 430 / skill->level;
430 431
431 if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) 432 if (!(random_roll (0, (max (2, min (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW)))
432 { 433 {
433 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); 434 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name);
434 trap->destroy (); 435 trap->destroy ();
435 436
436 /* If it is your own trap, (or any players trap), don't you don't 437 /* If it is your own trap, (or any players trap), don't you don't
442 return 1; /* give minimal exp and say success */ 443 return 1; /* give minimal exp and say success */
443 } 444 }
444 else 445 else
445 { 446 {
446 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You fail to disarm the %s.", &trap->name); 447 new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You fail to disarm the %s.", &trap->name);
447 if (!(random_roll (0, (MAX (2, skill->level - trap->level + disarmer->stats.Dex / 2 - 6)) - 1, disarmer, PREFER_LOW)) && risk) 448 if (!(random_roll (0, (max (2, skill->level - trap->level + disarmer->stats.Dex / 2 - 6)) - 1, disarmer, PREFER_LOW)) && risk)
448 { 449 {
449 new_draw_info (NDI_UNIQUE, 0, disarmer, "In fact, you set it off!"); 450 new_draw_info (NDI_UNIQUE, 0, disarmer, "In fact, you set it off!");
450 spring_trap (trap, disarmer); 451 spring_trap (trap, disarmer);
451 } 452 }
452 return 0; 453 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines