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 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> |
… | |
… | |
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 | |
|
|
208 | void |
204 | void |
209 | rune_attack (object *op, object *victim) |
205 | rune_attack (object *op, object *victim) |
210 | { |
206 | { |
211 | if (victim) |
207 | if (victim) |
212 | { |
208 | { |
… | |
… | |
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 | |
284 | |
283 | if (trap->destroyed ()) |
285 | if (trap->destroyed ()) |
284 | return; |
286 | return; |
285 | |
287 | |
… | |
… | |
352 | |
354 | |
353 | /* we could put a probability chance here, but since nothing happens |
355 | /* 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 |
356 | * 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. |
357 | * comparison so low level players can't erase high level players runes. |
356 | */ |
358 | */ |
357 | if (tmp->type == SIGN && !strcmp (tmp->arch->name, "rune_mark")) |
359 | if (tmp->type == SIGN && !strcmp (tmp->arch->archname, "rune_mark")) |
358 | { |
360 | { |
359 | tmp->destroy (); |
361 | tmp->destroy (); |
360 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
362 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
361 | return 1; |
363 | return 1; |
362 | } |
364 | } |
… | |
… | |
381 | if (tmp == NULL) |
383 | if (tmp == NULL) |
382 | { |
384 | { |
383 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
385 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
384 | return 0; |
386 | return 0; |
385 | } |
387 | } |
|
|
388 | |
386 | trap_disarm (op, tmp, 0, skill); |
389 | trap_disarm (op, tmp, 0, skill); |
387 | return 1; |
390 | return 1; |
388 | |
|
|
389 | } |
391 | } |
390 | |
392 | |
391 | int |
393 | int |
392 | trap_see (object *op, object *trap) |
394 | trap_see (object *op, object *trap) |
393 | { |
395 | { |
… | |
… | |
400 | + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) |
402 | + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) |
401 | { |
403 | { |
402 | new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); |
404 | new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); |
403 | return 1; |
405 | return 1; |
404 | } |
406 | } |
|
|
407 | |
405 | return 0; |
408 | return 0; |
406 | } |
409 | } |
407 | |
410 | |
408 | int |
411 | int |
409 | trap_show (object *trap, object *where) |
412 | trap_show (object *trap, object *where) |
410 | { |
413 | { |
411 | if (where == NULL) |
414 | if (where == NULL) |
412 | return 0; |
415 | return 0; |
413 | |
416 | |
414 | object *tmp = get_archetype ("runedet"); |
417 | object *tmp = get_archetype ("runedet"); |
415 | tmp->face = &new_faces[GET_ANIMATION (trap, 0)]; |
418 | tmp->face = GET_ANIMATION (trap, 0); |
416 | tmp->insert_at (where, 0); |
419 | tmp->insert_at (where, 0); |
417 | |
420 | |
418 | return 1; |
421 | return 1; |
419 | } |
422 | } |
420 | |
423 | |
421 | int |
424 | int |
422 | trap_disarm (object *disarmer, object *trap, int risk, object *skill) |
425 | trap_disarm (object *disarmer, object *trap, int risk, object *skill) |
423 | { |
426 | { |
424 | int trapworth; /* need to compute the experience worth of the trap |
427 | int trapworth; /* need to compute the experience worth of the trap before we kill it */ |
425 | before we kill it */ |
|
|
426 | |
428 | |
427 | /* this formula awards a more reasonable amount of exp */ |
429 | /* this formula awards a more reasonable amount of exp */ |
428 | trapworth = MAX (1, trap->level) * disarmer->map->difficulty * |
430 | trapworth = MAX (1, trap->level) |
|
|
431 | * disarmer->map->difficulty |
429 | sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) / skill->level; |
432 | * sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) |
|
|
433 | / skill->level; |
430 | |
434 | |
431 | if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) |
435 | if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) |
432 | { |
436 | { |
433 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); |
437 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); |
434 | trap->destroy (1); |
438 | trap->destroy (1); |
… | |
… | |
451 | } |
455 | } |
452 | return 0; |
456 | return 0; |
453 | } |
457 | } |
454 | } |
458 | } |
455 | |
459 | |
456 | |
|
|
457 | /* traps need to be adjusted for the difficulty of the map. The |
460 | /* traps need to be adjusted for the difficulty of the map. The |
458 | * default traps are too strong for wimpy level 1 players, and |
461 | * default traps are too strong for wimpy level 1 players, and |
459 | * unthreatening to anyone of high level |
462 | * unthreatening to anyone of high level |
460 | */ |
463 | */ |
461 | |
|
|
462 | void |
464 | void |
463 | trap_adjust (object *trap, int difficulty) |
465 | trap_adjust (object *trap, int difficulty) |
464 | { |
466 | { |
465 | int i; |
467 | int i; |
466 | |
468 | |