… | |
… | |
321 | combat_ob = op; |
321 | combat_ob = op; |
322 | break; |
322 | break; |
323 | } |
323 | } |
324 | |
324 | |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
326 | ob->deactivate (); // change_Weapon activates, fix this better |
326 | ob->deactivate (); // change_weapon activates, fix this better |
327 | } |
327 | } |
328 | |
328 | |
329 | void |
329 | void |
330 | player::set_observe (object *op) |
330 | player::set_observe (object *op) |
331 | { |
331 | { |
… | |
… | |
865 | ob->contr->ns->state = ST_PLAYING; |
865 | ob->contr->ns->state = ST_PLAYING; |
866 | |
866 | |
867 | if (ob->msg) |
867 | if (ob->msg) |
868 | ob->msg = 0; |
868 | ob->msg = 0; |
869 | |
869 | |
870 | /* We create this now because some of the unique maps will need it |
|
|
871 | * to save here. |
|
|
872 | */ |
|
|
873 | { |
|
|
874 | char buf[MAX_BUF]; |
|
|
875 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &ob->name); |
|
|
876 | make_path_to_file (buf); |
|
|
877 | } |
|
|
878 | |
|
|
879 | start_info (ob); |
870 | start_info (ob); |
880 | CLEAR_FLAG (ob, FLAG_WIZ); |
871 | CLEAR_FLAG (ob, FLAG_WIZ); |
881 | give_initial_items (ob, ob->randomitems); |
872 | give_initial_items (ob, ob->randomitems); |
882 | link_player_skills (ob); |
873 | link_player_skills (ob); |
883 | esrv_send_inventory (ob, ob); |
874 | esrv_send_inventory (ob, ob); |
… | |
… | |
885 | |
876 | |
886 | /* This moves the player to a different start map, if there |
877 | /* This moves the player to a different start map, if there |
887 | * is one for this race |
878 | * is one for this race |
888 | */ |
879 | */ |
889 | if (*first_map_ext_path) |
880 | if (*first_map_ext_path) |
890 | { |
881 | ob->player_goto (format ("%s/%s", &first_map_ext_path, &ob->arch->archname), ob->x, ob->y); |
891 | object *tmp; |
|
|
892 | char mapname[MAX_BUF]; |
|
|
893 | |
|
|
894 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname); |
|
|
895 | tmp = object::create (); |
|
|
896 | EXIT_PATH (tmp) = mapname; |
|
|
897 | EXIT_X (tmp) = ob->x; |
|
|
898 | EXIT_Y (tmp) = ob->y; |
|
|
899 | ob->enter_exit (tmp); /* we don't really care if it succeeded; |
|
|
900 | * if the map isn't there, then stay on the |
|
|
901 | * default initial map */ |
|
|
902 | tmp->destroy (); |
|
|
903 | } |
|
|
904 | else |
882 | else |
905 | LOG (llevDebug, "first_map_ext_path not set\n"); |
883 | LOG (llevDebug, "first_map_ext_path not set\n"); |
906 | } |
884 | } |
907 | |
885 | |
908 | void |
886 | void |
… | |
… | |
2545 | op->stats.food--; |
2523 | op->stats.food--; |
2546 | } |
2524 | } |
2547 | |
2525 | |
2548 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2526 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2549 | { |
2527 | { |
2550 | object *tmp, *flesh = 0; |
2528 | object *flesh = 0; |
2551 | |
2529 | |
2552 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2530 | for_inv_removable (op, tmp) |
2553 | { |
2531 | { |
2554 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2532 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
2533 | continue; |
|
|
2534 | |
|
|
2535 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2555 | { |
2536 | { |
2556 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2537 | op->statusmsg ("You blindly grab for a bite of food. " |
2557 | { |
2538 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2558 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
|
|
2559 | manual_apply (op, tmp, 0); |
2539 | manual_apply (op, tmp, 0); |
|
|
2540 | |
2560 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2541 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2561 | break; |
2542 | break; |
2562 | } |
2543 | } |
2563 | else if (tmp->type == FLESH) |
2544 | else if (tmp->type == FLESH) |
2564 | flesh = tmp; |
2545 | flesh = tmp; |
2565 | } /* End if paid for object */ |
2546 | } |
2566 | } /* end of for loop */ |
|
|
2567 | |
2547 | |
2568 | /* If player is still starving, it means they don't have any food, so |
2548 | /* If player is still starving, it means they don't have any food, so |
2569 | * eat flesh instead. |
2549 | * eat flesh instead. |
2570 | */ |
2550 | */ |
2571 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2551 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2572 | { |
2552 | { |
2573 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2553 | op->statusmsg ("You blindly grab for a bite of food. " |
|
|
2554 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2574 | manual_apply (op, flesh, 0); |
2555 | manual_apply (op, flesh, 0); |
2575 | } |
2556 | } |
2576 | } |
|
|
2577 | |
2557 | |
2578 | if (op->stats.food < 0 && op->stats.hp >= -op->stats.food) |
2558 | // If player is still starving, alert him! |
|
|
2559 | if (op->stats.food < 0) |
|
|
2560 | op->failmsg ("You are starving! " |
|
|
2561 | "H<Eat some food to increase your food and prevent you from an untimely death.>"); |
2579 | { |
2562 | } |
|
|
2563 | |
|
|
2564 | if (op->stats.food < 0) |
|
|
2565 | { |
2580 | op->stats.hp += op->stats.food; |
2566 | op->stats.hp += op->stats.food; |
2581 | op->stats.food = 0; |
2567 | op->stats.food = 0; |
2582 | } |
2568 | } |
2583 | |
2569 | |
2584 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2570 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2585 | kill_player (op); |
2571 | kill_player (op); |