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) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | 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 |
8 | 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 |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | 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, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | 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 |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | 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> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <living.h> |
26 | #include <living.h> |
26 | #include <spells.h> |
27 | #include <spells.h> |
27 | #include <skills.h> |
28 | #include <skills.h> |
… | |
… | |
978 | else |
979 | else |
979 | { |
980 | { |
980 | if (converter->other_arch == NULL) |
981 | if (converter->other_arch == NULL) |
981 | { |
982 | { |
982 | LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", |
983 | LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", |
983 | &converter->name, converter->map->path, converter->x, converter->y); |
984 | &converter->name, &converter->map->path, converter->x, converter->y); |
984 | return -1; |
985 | return -1; |
985 | } |
986 | } |
986 | |
987 | |
987 | item = object_create_arch (converter->other_arch); |
988 | item = object_create_arch (converter->other_arch); |
988 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
989 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
… | |
… | |
995 | if (is_in_shop (converter)) |
996 | if (is_in_shop (converter)) |
996 | SET_FLAG (item, FLAG_UNPAID); |
997 | SET_FLAG (item, FLAG_UNPAID); |
997 | else if (price_in < item->nrof * item->value) |
998 | else if (price_in < item->nrof * item->value) |
998 | { |
999 | { |
999 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1000 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1000 | &converter->name, converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1001 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1001 | |
1002 | |
1002 | /** |
1003 | /** |
1003 | * elmex: we are going to let the game continue, as the mapcreator |
1004 | * elmex: we are going to let the game continue, as the mapcreator |
1004 | * propably had something in mind when doing this |
1005 | * propably had something in mind when doing this |
1005 | */ |
1006 | */ |
… | |
… | |
1677 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1678 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1678 | { |
1679 | { |
1679 | /* Basically, don't show exits leading to random maps the |
1680 | /* Basically, don't show exits leading to random maps the |
1680 | * players output. |
1681 | * players output. |
1681 | */ |
1682 | */ |
1682 | if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2) && strncmp (EXIT_PATH (trap), "/random/", 8)) |
1683 | if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2)) |
1683 | new_draw_info (NDI_NAVY, 0, victim, trap->msg); |
1684 | new_draw_info (NDI_NAVY, 0, victim, trap->msg); |
|
|
1685 | |
1684 | enter_exit (victim, trap); |
1686 | victim->enter_exit (trap); |
1685 | } |
1687 | } |
1686 | goto leave; |
1688 | goto leave; |
1687 | |
1689 | |
1688 | case ENCOUNTER: |
1690 | case ENCOUNTER: |
1689 | /* may be some leftovers on this */ |
1691 | /* may be some leftovers on this */ |
… | |
… | |
2225 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2227 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2226 | return 0; |
2228 | return 0; |
2227 | |
2229 | |
2228 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2230 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2229 | from the player's inventory */ |
2231 | from the player's inventory */ |
|
|
2232 | shstr_cmp dragon_ability_force ("dragon_ability_force"); |
|
|
2233 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
|
|
2234 | |
2230 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2235 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2231 | { |
|
|
2232 | if (tmp->type == FORCE) |
2236 | if (tmp->type == FORCE) |
2233 | { |
|
|
2234 | if (strcmp (tmp->arch->name, "dragon_skin_force") == 0) |
2237 | if (tmp->arch->name == dragon_skin_force) |
2235 | skin = tmp; |
2238 | skin = tmp; |
2236 | else if (strcmp (tmp->arch->name, "dragon_ability_force") == 0) |
2239 | else if (tmp->arch->name == dragon_ability_force) |
2237 | abil = tmp; |
2240 | abil = tmp; |
2238 | } |
|
|
2239 | } |
|
|
2240 | |
2241 | |
2241 | /* if either skin or ability are missing, this is an old player |
2242 | /* if either skin or ability are missing, this is an old player |
2242 | which is not to be considered a dragon -> bail out */ |
2243 | which is not to be considered a dragon -> bail out */ |
2243 | if (skin == NULL || abil == NULL) |
2244 | if (skin == NULL || abil == NULL) |
2244 | return 0; |
2245 | return 0; |
… | |
… | |
2285 | /* doubled chance for resistance of ability-focus */ |
2286 | /* doubled chance for resistance of ability-focus */ |
2286 | if (i == abil->stats.exp) |
2287 | if (i == abil->stats.exp) |
2287 | chance = MIN (100., chance * 2.); |
2288 | chance = MIN (100., chance * 2.); |
2288 | |
2289 | |
2289 | /* now make the throw and save all winners (Don't insert luck bonus here!) */ |
2290 | /* now make the throw and save all winners (Don't insert luck bonus here!) */ |
2290 | if (RANDOM () % 10000 < (int) (chance * 100)) |
2291 | if (rndm (10000) < (int) (chance * 100)) |
2291 | { |
2292 | { |
2292 | atnr_winner[winners] = i; |
2293 | atnr_winner[winners] = i; |
2293 | winners++; |
2294 | winners++; |
2294 | } |
2295 | } |
2295 | |
2296 | |
… | |
… | |
2410 | handle_apply_yield (tmp); |
2411 | handle_apply_yield (tmp); |
2411 | decrease_ob (tmp); |
2412 | decrease_ob (tmp); |
2412 | } |
2413 | } |
2413 | |
2414 | |
2414 | /** |
2415 | /** |
2415 | * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2416 | * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2416 | * A valid 2 way exit means: |
2417 | * A valid 2 way exit means: |
2417 | * -You can come back (there is another exit at the other side) |
2418 | * -You can come back (there is another exit at the other side) |
2418 | * -You are |
2419 | * -You are |
2419 | * ° the owner of the exit |
2420 | * ° the owner of the exit |
2420 | * ° or in the same party as the owner |
2421 | * ° or in the same party as the owner |
… | |
… | |
2424 | * survive in the swapping (in fact the whole exit doesn't survive). |
2425 | * survive in the swapping (in fact the whole exit doesn't survive). |
2425 | */ |
2426 | */ |
2426 | int |
2427 | int |
2427 | is_legal_2ways_exit (object *op, object *exit) |
2428 | is_legal_2ways_exit (object *op, object *exit) |
2428 | { |
2429 | { |
2429 | object *tmp; |
|
|
2430 | object *exit_owner; |
|
|
2431 | player *pp; |
|
|
2432 | maptile *exitmap; |
|
|
2433 | |
|
|
2434 | if (exit->stats.exp != 1) |
2430 | if (exit->stats.exp != 1) |
2435 | return 1; /*This is not a 2 way, so it is legal */ |
2431 | return 1; /*This is not a 2 way, so it is legal */ |
|
|
2432 | |
|
|
2433 | #if 0 //TODO |
2436 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2434 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2437 | return 0; /* This is a reset town portal */ |
2435 | return 0; /* This is a reset town portal */ |
2438 | /* To know if an exit has a correspondant, we look at |
2436 | #endif |
2439 | * all the exits in destination and try to find one with same path as |
2437 | |
2440 | * the current exit's position */ |
2438 | maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map); |
2441 | if (!strncmp (EXIT_PATH (exit), settings.localdir, strlen (settings.localdir))) |
2439 | |
2442 | exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE); |
|
|
2443 | else |
|
|
2444 | exitmap = ready_map_name (EXIT_PATH (exit), 0); |
|
|
2445 | if (exitmap) |
2440 | if (exitmap) |
2446 | { |
2441 | { |
|
|
2442 | exitmap->load_sync (); |
|
|
2443 | |
2447 | tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit)); |
2444 | object *tmp = exitmap->at (EXIT_X (exit), EXIT_Y (exit)).bot; |
|
|
2445 | |
2448 | if (!tmp) |
2446 | if (!tmp) |
2449 | return 0; |
2447 | return 0; |
2450 | for ((tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above) |
2448 | |
|
|
2449 | for (; tmp; tmp = tmp->above) |
2451 | { |
2450 | { |
2452 | if (tmp->type != EXIT) |
2451 | if (tmp->type != EXIT) |
2453 | continue; /*Not an exit */ |
2452 | continue; /*Not an exit */ |
|
|
2453 | |
2454 | if (!EXIT_PATH (tmp)) |
2454 | if (!EXIT_PATH (tmp)) |
2455 | continue; /*Not a valid exit */ |
2455 | continue; /*Not a valid exit */ |
|
|
2456 | |
2456 | if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y)) |
2457 | if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y)) |
2457 | continue; /*Not in the same place */ |
2458 | continue; /*Not in the same place */ |
|
|
2459 | |
2458 | if (strcmp (exit->map->path, EXIT_PATH (tmp)) != 0) |
2460 | if (strcmp (exit->map->path, EXIT_PATH (tmp)) != 0) |
2459 | continue; /*Not in the same map */ |
2461 | continue; /*Not in the same map */ |
2460 | |
2462 | |
2461 | /* From here we have found the exit is valid. However we do |
2463 | /* From here we have found the exit is valid. However we do |
2462 | * here the check of the exit owner. It is important for the |
2464 | * here the check of the exit owner. It is important for the |
2463 | * town portals to prevent strangers from visiting your appartments |
2465 | * town portals to prevent strangers from visiting your appartments |
2464 | */ |
2466 | */ |
2465 | if (!exit->race) |
2467 | if (!exit->race) |
2466 | return 1; /*No owner, free for all! */ |
2468 | return 1; /*No owner, free for all! */ |
|
|
2469 | |
2467 | exit_owner = NULL; |
2470 | object *exit_owner = 0; |
2468 | for (pp = first_player; pp; pp = pp->next) |
2471 | |
|
|
2472 | for_all_players (pp) |
2469 | { |
2473 | { |
2470 | if (!pp->ob) |
2474 | if (!pp->ob) |
2471 | continue; |
2475 | continue; |
|
|
2476 | |
2472 | if (pp->ob->name != exit->race) |
2477 | if (pp->ob->name != exit->race) |
2473 | continue; |
2478 | continue; |
|
|
2479 | |
2474 | exit_owner = pp->ob; /*We found a player which correspond to the player name */ |
2480 | exit_owner = pp->ob; /*We found a player which correspond to the player name */ |
2475 | break; |
2481 | break; |
2476 | } |
2482 | } |
|
|
2483 | |
2477 | if (!exit_owner) |
2484 | if (!exit_owner) |
2478 | return 0; /* No more owner */ |
2485 | return 0; /* No more owner */ |
|
|
2486 | |
2479 | if (exit_owner->contr == op->contr) |
2487 | if (exit_owner->contr == op->contr) |
2480 | return 1; /*It is your exit */ |
2488 | return 1; /*It is your exit */ |
|
|
2489 | |
2481 | if (exit_owner && /*There is a owner */ |
2490 | if (exit_owner && /*There is a owner */ |
2482 | (op->contr) && /*A player tries to pass */ |
2491 | (op->contr) && /*A player tries to pass */ |
2483 | ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */ |
2492 | ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */ |
2484 | (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */ |
2493 | (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */ |
2485 | return 0; |
2494 | return 0; |
|
|
2495 | |
2486 | return 1; |
2496 | return 1; |
2487 | } |
2497 | } |
2488 | } |
2498 | } |
|
|
2499 | |
2489 | return 0; |
2500 | return 0; |
2490 | } |
2501 | } |
2491 | |
2502 | |
2492 | |
2503 | |
2493 | /** |
2504 | /** |
… | |
… | |
2543 | { |
2554 | { |
2544 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2555 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2545 | play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); |
2556 | play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); |
2546 | } |
2557 | } |
2547 | else |
2558 | else |
2548 | { |
|
|
2549 | new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); |
2559 | new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); |
2550 | } |
2560 | |
2551 | return 1; |
2561 | return 1; |
2552 | |
2562 | |
2553 | case EXIT: |
2563 | case EXIT: |
2554 | if (op->type != PLAYER) |
2564 | if (op->type != PLAYER) |
2555 | return 0; |
2565 | return 0; |
|
|
2566 | |
2556 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2567 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2557 | { |
2568 | { |
2558 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s is closed.", query_name (tmp)); |
2569 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s is closed.", query_name (tmp)); |
2559 | } |
2570 | } |
2560 | else |
2571 | else |
2561 | { |
2572 | { |
2562 | /* Don't display messages for random maps. */ |
2573 | /* Don't display messages for random maps. */ |
2563 | if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2) && strncmp (EXIT_PATH (tmp), "/random/", 8)) |
2574 | if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2)) |
2564 | new_draw_info (NDI_NAVY, 0, op, tmp->msg); |
2575 | new_draw_info (NDI_NAVY, 0, op, tmp->msg); |
|
|
2576 | |
2565 | enter_exit (op, tmp); |
2577 | op->enter_exit (tmp); |
2566 | } |
2578 | } |
2567 | return 1; |
2579 | return 1; |
2568 | |
2580 | |
2569 | case SIGN: |
2581 | case SIGN: |
2570 | apply_sign (op, tmp, 0); |
2582 | apply_sign (op, tmp, 0); |
… | |
… | |
3327 | } |
3339 | } |
3328 | else |
3340 | else |
3329 | { |
3341 | { |
3330 | if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) |
3342 | if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) |
3331 | { |
3343 | { |
3332 | new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some item(s):"); |
3344 | new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some of the following item(s) or change your applymode:"); |
3333 | unapply_for_ob (who, op, AP_PRINT); |
3345 | unapply_for_ob (who, op, AP_PRINT); |
3334 | return 1; |
3346 | return 1; |
3335 | } |
3347 | } |
3336 | else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) |
3348 | else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) |
3337 | { |
3349 | { |
… | |
… | |
3339 | if (i) |
3351 | if (i) |
3340 | return 1; |
3352 | return 1; |
3341 | } |
3353 | } |
3342 | } |
3354 | } |
3343 | } |
3355 | } |
|
|
3356 | |
3344 | if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) |
3357 | if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) |
3345 | { |
3358 | { |
3346 | skop = find_skill_by_name (who, op->skill); |
3359 | skop = find_skill_by_name (who, op->skill); |
3347 | if (!skop) |
3360 | if (!skop) |
3348 | { |
3361 | { |
… | |
… | |
3670 | * when an original map is loaded) and performs special actions for |
3683 | * when an original map is loaded) and performs special actions for |
3671 | * certain objects (most initialization of chests and creation of |
3684 | * certain objects (most initialization of chests and creation of |
3672 | * treasures and stuff). Calls auto_apply if appropriate. |
3685 | * treasures and stuff). Calls auto_apply if appropriate. |
3673 | */ |
3686 | */ |
3674 | void |
3687 | void |
3675 | fix_auto_apply (maptile *m) |
3688 | maptile::fix_auto_apply () |
3676 | { |
3689 | { |
3677 | object *tmp, *above = NULL; |
3690 | if (!spaces) |
3678 | int x, y; |
|
|
3679 | |
|
|
3680 | if (m == NULL) |
|
|
3681 | return; |
3691 | return; |
3682 | |
3692 | |
3683 | for (x = 0; x < MAP_WIDTH (m); x++) |
3693 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
3684 | for (y = 0; y < MAP_HEIGHT (m); y++) |
3694 | for (object *tmp = ms->bot; tmp; ) |
3685 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above) |
|
|
3686 | { |
3695 | { |
3687 | above = tmp->above; |
3696 | object *above = tmp->above; |
3688 | |
3697 | |
3689 | if (tmp->inv) |
3698 | if (tmp->inv) |
3690 | { |
3699 | { |
3691 | object *invtmp, *invnext; |
3700 | object *invtmp, *invnext; |
3692 | |
3701 | |
3693 | for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) |
3702 | for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) |
3694 | { |
3703 | { |
3695 | invnext = invtmp->below; |
3704 | invnext = invtmp->below; |
3696 | |
3705 | |
3697 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3706 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3698 | auto_apply (invtmp); |
3707 | auto_apply (invtmp); |
3699 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3708 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3700 | { |
3709 | { |
3701 | while ((invtmp->stats.hp--) > 0) |
3710 | while ((invtmp->stats.hp--) > 0) |
3702 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3711 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3703 | |
3712 | |
3704 | invtmp->randomitems = NULL; |
3713 | invtmp->randomitems = NULL; |
3705 | } |
3714 | } |
3706 | else if (invtmp && invtmp->arch |
3715 | else if (invtmp && invtmp->arch |
3707 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) |
3716 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) |
3708 | { |
3717 | { |
3709 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3718 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3710 | /* Need to clear this so that we never try to create |
3719 | /* Need to clear this so that we never try to create |
3711 | * treasure again for this object |
3720 | * treasure again for this object |
3712 | */ |
3721 | */ |
3713 | invtmp->randomitems = NULL; |
3722 | invtmp->randomitems = NULL; |
3714 | } |
3723 | } |
3715 | } |
3724 | } |
3716 | /* This is really temporary - the code at the bottom will |
3725 | /* This is really temporary - the code at the bottom will |
3717 | * also set randomitems to null. The problem is there are bunches |
3726 | * also set randomitems to null. The problem is there are bunches |
3718 | * of maps/players already out there with items that have spells |
3727 | * of maps/players already out there with items that have spells |
3719 | * which haven't had the randomitems set to null yet. |
3728 | * which haven't had the randomitems set to null yet. |
3720 | * MSW 2004-05-13 |
3729 | * MSW 2004-05-13 |
3721 | * |
3730 | * |
3722 | * And if it's a spellbook, it's better to set randomitems to NULL too, |
3731 | * And if it's a spellbook, it's better to set randomitems to NULL too, |
3723 | * else you get two spells in the book ^_- |
3732 | * else you get two spells in the book ^_- |
3724 | * Ryo 2004-08-16 |
3733 | * Ryo 2004-08-16 |
3725 | */ |
3734 | */ |
3726 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3735 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3727 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3736 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3728 | tmp->randomitems = NULL; |
|
|
3729 | |
|
|
3730 | } |
|
|
3731 | |
|
|
3732 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
|
|
3733 | auto_apply (tmp); |
|
|
3734 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
|
|
3735 | { |
|
|
3736 | while ((tmp->stats.hp--) > 0) |
|
|
3737 | create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
|
|
3738 | tmp->randomitems = NULL; |
3737 | tmp->randomitems = NULL; |
|
|
3738 | |
3739 | } |
3739 | } |
|
|
3740 | |
|
|
3741 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
|
|
3742 | auto_apply (tmp); |
|
|
3743 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
|
|
3744 | { |
|
|
3745 | while ((tmp->stats.hp--) > 0) |
|
|
3746 | create_treasure (tmp->randomitems, tmp, 0, difficulty, 0); |
|
|
3747 | tmp->randomitems = NULL; |
|
|
3748 | } |
3740 | else if (tmp->type == TIMED_GATE) |
3749 | else if (tmp->type == TIMED_GATE) |
3741 | { |
3750 | { |
3742 | object *head = tmp->head != NULL ? tmp->head : tmp; |
3751 | object *head = tmp->head != NULL ? tmp->head : tmp; |
3743 | |
3752 | |
3744 | if (QUERY_FLAG (head, FLAG_IS_LINKED)) |
3753 | if (QUERY_FLAG (head, FLAG_IS_LINKED)) |
3745 | { |
|
|
3746 | tmp->speed = 0; |
3754 | tmp->set_speed (0); |
3747 | update_ob_speed (tmp); |
|
|
3748 | } |
|
|
3749 | } |
3755 | } |
3750 | /* This function can be called everytime a map is loaded, even when |
3756 | /* This function can be called everytime a map is loaded, even when |
3751 | * swapping back in. As such, we don't want to create the treasure |
3757 | * swapping back in. As such, we don't want to create the treasure |
3752 | * over and ove again, so after we generate the treasure, blank out |
3758 | * over and ove again, so after we generate the treasure, blank out |
3753 | * randomitems so if it is swapped in again, it won't make anything. |
3759 | * randomitems so if it is swapped in again, it won't make anything. |
3754 | * This is a problem for the above objects, because they have counters |
3760 | * This is a problem for the above objects, because they have counters |
3755 | * which say how many times to make the treasure. |
3761 | * which say how many times to make the treasure. |
3756 | */ |
3762 | */ |
3757 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3763 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3758 | && tmp->type != TREASURE && tmp->type != SPELL |
3764 | && tmp->type != TREASURE && tmp->type != SPELL |
3759 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ()) |
3765 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ()) |
3760 | { |
3766 | { |
3761 | create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
3767 | create_treasure (tmp->randomitems, tmp, GT_APPLY, difficulty, 0); |
3762 | tmp->randomitems = NULL; |
3768 | tmp->randomitems = NULL; |
3763 | } |
3769 | } |
|
|
3770 | |
|
|
3771 | tmp = above; |
3764 | } |
3772 | } |
3765 | |
3773 | |
3766 | for (x = 0; x < MAP_WIDTH (m); x++) |
3774 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
3767 | for (y = 0; y < MAP_HEIGHT (m); y++) |
3775 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
3768 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
|
|
3769 | if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
3776 | if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
3770 | check_trigger (tmp, tmp->above); |
3777 | check_trigger (tmp, tmp->above); |
3771 | } |
3778 | } |
3772 | |
3779 | |
3773 | /** |
3780 | /** |
3774 | * Handles player eating food that temporarily changes status (resistances, stats). |
3781 | * Handles player eating food that temporarily changes status (resistances, stats). |
3775 | * This used to call cast_change_attr(), but |
3782 | * This used to call cast_change_attr(), but |
… | |
… | |
3806 | } |
3813 | } |
3807 | } |
3814 | } |
3808 | |
3815 | |
3809 | if (did_one) |
3816 | if (did_one) |
3810 | { |
3817 | { |
3811 | force->speed = 0.1; |
3818 | force->set_speed (0.1); |
3812 | update_ob_speed (force); |
|
|
3813 | /* bigger morsel of food = longer effect time */ |
3819 | /* bigger morsel of food = longer effect time */ |
3814 | force->duration = food->stats.food / 5; |
3820 | force->duration = food->stats.food / 5; |
3815 | SET_FLAG (force, FLAG_APPLIED); |
3821 | SET_FLAG (force, FLAG_APPLIED); |
3816 | change_abil (who, force); |
3822 | change_abil (who, force); |
3817 | insert_ob_in_ob (force, who); |
3823 | insert_ob_in_ob (force, who); |