ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/apply.C
(Generate patch)

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.59 by pippijn, Sat Jan 6 14:42:30 2007 UTC vs.
Revision 1.67 by root, Thu Feb 8 03:09:32 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team
6 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 7 *
8 This program is free software; you can redistribute it and/or modify 8 * This program 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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The authors can be reached via e-mail to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23*/ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <living.h> 26#include <living.h>
27#include <spells.h> 27#include <spells.h>
28#include <skills.h> 28#include <skills.h>
65 { 65 {
66 arch_flag = 1; 66 arch_flag = 1;
67 name_flag = 1; 67 name_flag = 1;
68 race_flag = 1; 68 race_flag = 1;
69 } 69 }
70
70 /* If the director has race set, only affect objects with a arch, 71 /* If the director has race set, only affect objects with a arch,
71 * name or race that matches. 72 * name or race that matches.
72 */ 73 */
73 if ((op->race) && 74 if ((op->race) &&
74 ((!(victim->arch && arch_flag && victim->arch->name) || strcmp (op->race, victim->arch->name))) && 75 ((!(victim->arch && arch_flag && victim->arch->name) || op->race != victim->arch->name)) &&
75 ((!(victim->name && name_flag) || strcmp (op->race, victim->name))) && 76 ((!(victim->name && name_flag) || op->race != victim->name)) &&
76 ((!(victim->race && race_flag) || strcmp (op->race, victim->race)))) 77 ((!(victim->race && race_flag) || op->race != victim->race)))
77 {
78 return 1; 78 return 1;
79 } 79
80 /* If the director has slaying set, only affect objects where none 80 /* If the director has slaying set, only affect objects where none
81 * of arch, name, or race match. 81 * of arch, name, or race match.
82 */ 82 */
83 if ((op->slaying) && (((victim->arch && arch_flag && victim->arch->name && !strcmp (op->slaying, victim->arch->name))) || 83 if ((op->slaying) && (((victim->arch && arch_flag && victim->arch->name && op->slaying == victim->arch->name))) ||
84 ((victim->name && name_flag && !strcmp (op->slaying, victim->name))) || 84 ((victim->name && name_flag && op->slaying == victim->name)) ||
85 ((victim->race && race_flag && !strcmp (op->slaying, victim->race))))) 85 ((victim->race && race_flag && op->slaying == victim->race)))
86 {
87 return 1; 86 return 1;
88 } 87
89 return 0; 88 return 0;
90} 89}
91 90
92/** 91/**
93 * This handles a player dropping money on an altar to identify stuff. 92 * This handles a player dropping money on an altar to identify stuff.
422 int count = 0; 421 int count = 0;
423 422
424 423
425 if (item == NULL) 424 if (item == NULL)
426 return 0; 425 return 0;
426
427 op = op->below; 427 op = op->below;
428 while (op != NULL) 428 while (op != NULL)
429 { 429 {
430 if (strcmp (op->arch->name, item) == 0) 430 if (strcmp (op->arch->name, item) == 0)
431 { 431 {
436 count++; 436 count++;
437 else 437 else
438 count += op->nrof; 438 count += op->nrof;
439 } 439 }
440 } 440 }
441
441 op = op->below; 442 op = op->below;
442 } 443 }
444
443 return count; 445 return count;
444} 446}
445 447
446/** 448/**
447 * This removes 'nrof' of what item->slaying says to remove. 449 * This removes 'nrof' of what item->slaying says to remove.
1628 1630
1629 1631
1630 case CONVERTER: 1632 case CONVERTER:
1631 if (convert_item (victim, trap) < 0) 1633 if (convert_item (victim, trap) < 0)
1632 { 1634 {
1633 object *op;
1634
1635 new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap)); 1635 new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap));
1636 1636 get_archetype ("burnout")->insert_at (trap, trap);
1637 op = get_archetype ("burnout");
1638 if (op != NULL)
1639 {
1640 op->x = trap->x;
1641 op->y = trap->y;
1642 insert_ob_in_map (op, trap->map, trap, 0);
1643 } 1637 }
1644 } 1638
1645 goto leave; 1639 goto leave;
1646 1640
1647 case TRIGGER_BUTTON: 1641 case TRIGGER_BUTTON:
1648 case TRIGGER_PEDESTAL: 1642 case TRIGGER_PEDESTAL:
1649 case TRIGGER_ALTAR: 1643 case TRIGGER_ALTAR:
2227 if (meal->type != FLESH || !is_dragon_pl (op)) 2221 if (meal->type != FLESH || !is_dragon_pl (op))
2228 return 0; 2222 return 0;
2229 2223
2230 /* now grab the 'dragon_skin'- and 'dragon_ability'-forces 2224 /* now grab the 'dragon_skin'- and 'dragon_ability'-forces
2231 from the player's inventory */ 2225 from the player's inventory */
2226 shstr_cmp dragon_ability_force ("dragon_ability_force");
2227 shstr_cmp dragon_skin_force ("dragon_skin_force");
2228
2232 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2229 for (tmp = op->inv; tmp; tmp = tmp->below)
2233 {
2234 if (tmp->type == FORCE) 2230 if (tmp->type == FORCE)
2235 {
2236 if (strcmp (tmp->arch->name, "dragon_skin_force") == 0) 2231 if (tmp->arch->name == dragon_skin_force)
2237 skin = tmp; 2232 skin = tmp;
2238 else if (strcmp (tmp->arch->name, "dragon_ability_force") == 0) 2233 else if (tmp->arch->name == dragon_ability_force)
2239 abil = tmp; 2234 abil = tmp;
2240 }
2241 }
2242 2235
2243 /* if either skin or ability are missing, this is an old player 2236 /* if either skin or ability are missing, this is an old player
2244 which is not to be considered a dragon -> bail out */ 2237 which is not to be considered a dragon -> bail out */
2245 if (skin == NULL || abil == NULL) 2238 if (skin == NULL || abil == NULL)
2246 return 0; 2239 return 0;
2287 /* doubled chance for resistance of ability-focus */ 2280 /* doubled chance for resistance of ability-focus */
2288 if (i == abil->stats.exp) 2281 if (i == abil->stats.exp)
2289 chance = MIN (100., chance * 2.); 2282 chance = MIN (100., chance * 2.);
2290 2283
2291 /* now make the throw and save all winners (Don't insert luck bonus here!) */ 2284 /* now make the throw and save all winners (Don't insert luck bonus here!) */
2292 if (RANDOM () % 10000 < (int) (chance * 100)) 2285 if (rndm (10000) < (int) (chance * 100))
2293 { 2286 {
2294 atnr_winner[winners] = i; 2287 atnr_winner[winners] = i;
2295 winners++; 2288 winners++;
2296 } 2289 }
2297 2290
2456 continue; /*Not a valid exit */ 2449 continue; /*Not a valid exit */
2457 2450
2458 if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y)) 2451 if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y))
2459 continue; /*Not in the same place */ 2452 continue; /*Not in the same place */
2460 2453
2461 if (strcmp (exit->map->path, EXIT_PATH (tmp)) != 0) 2454 if (exit->map->path != EXIT_PATH (tmp))
2462 continue; /*Not in the same map */ 2455 continue; /*Not in the same map */
2463 2456
2464 /* From here we have found the exit is valid. However we do 2457 /* From here we have found the exit is valid. However we do
2465 * here the check of the exit owner. It is important for the 2458 * here the check of the exit owner. It is important for the
2466 * town portals to prevent strangers from visiting your appartments 2459 * town portals to prevent strangers from visiting your appartments
3402 new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); 3395 new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!.");
3403 if (tmp != NULL) 3396 if (tmp != NULL)
3404 (void) insert_ob_in_ob (tmp, who); 3397 (void) insert_ob_in_ob (tmp, who);
3405 return 1; 3398 return 1;
3406 } 3399 }
3400
3401 //TODO: this obviously fails for players using a shiorter prefix
3402 // i.e. "R" can use Ragnarok's swors.
3407 if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) 3403 if (op->level && (strncmp (op->name, who->name, strlen (who->name))))
3408 { 3404 {
3409 /* if the weapon does not have the name as the character, can't use it. */ 3405 /* if the weapon does not have the name as the character, can't use it. */
3410 /* (Ragnarok's sword attempted to be used by Foo: won't work) */ 3406 /* (Ragnarok's sword attempted to be used by Foo: won't work) */
3411 new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); 3407 new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner.");
3408
3412 if (tmp != NULL) 3409 if (tmp)
3413 (void) insert_ob_in_ob (tmp, who); 3410 insert_ob_in_ob (tmp, who);
3411
3414 return 1; 3412 return 1;
3415 } 3413 }
3414
3416 SET_FLAG (op, FLAG_APPLIED); 3415 SET_FLAG (op, FLAG_APPLIED);
3417 3416
3418 if (skop) 3417 if (skop)
3419 change_skill (who, skop, 1); 3418 change_skill (who, skop, 1);
3420 if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) 3419 if (!QUERY_FLAG (who, FLAG_READY_WEAPON))
3651 3650
3652 case TREASURE: 3651 case TREASURE:
3653 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 3652 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))
3654 return 0; 3653 return 0;
3655 3654
3656 while ((op->stats.hp--) > 0) 3655 while (op->stats.hp-- > 0)
3657 create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, 3656 create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0,
3658 op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); 3657 op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
3659 3658
3660 /* If we generated an object and put it in this object inventory, 3659 /* If we generated an object and put it in this object inventory,
3661 * move it to the parent object as the current object is about 3660 * move it to the parent object as the current object is about
3829 /* check for hp, sp change */ 3828 /* check for hp, sp change */
3830 if (food->stats.hp != 0) 3829 if (food->stats.hp != 0)
3831 { 3830 {
3832 if (QUERY_FLAG (food, FLAG_CURSED)) 3831 if (QUERY_FLAG (food, FLAG_CURSED))
3833 { 3832 {
3834 strcpy (who->contr->killer, food->name); 3833 assign (who->contr->killer, food->name);
3835 hit_player (who, food->stats.hp, food, AT_POISON, 1); 3834 hit_player (who, food->stats.hp, food, AT_POISON, 1);
3836 new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!"); 3835 new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!");
3837 } 3836 }
3838 else 3837 else
3839 { 3838 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines