… | |
… | |
744 | player::chargen_race_done () |
744 | player::chargen_race_done () |
745 | { |
745 | { |
746 | /* this must before then initial items are given */ |
746 | /* this must before then initial items are given */ |
747 | esrv_new_player (ob->contr); |
747 | esrv_new_player (ob->contr); |
748 | |
748 | |
749 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
749 | treasurelist *tl = treasurelist::find (shstr_starting_wealth); |
750 | if (tl) |
750 | if (tl) |
751 | create_treasure (tl, ob, 0, 0, 0); |
751 | create_treasure (tl, ob, 0, 0, 0); |
752 | |
752 | |
753 | INVOKE_PLAYER (BIRTH, ob->contr); |
753 | INVOKE_PLAYER (BIRTH, ob->contr); |
754 | INVOKE_PLAYER (LOGIN, ob->contr); |
754 | INVOKE_PLAYER (LOGIN, ob->contr); |
… | |
… | |
903 | if (op->contr->mode & PU_DEBUG) |
903 | if (op->contr->mode & PU_DEBUG) |
904 | { |
904 | { |
905 | /* some debugging code to figure out item information */ |
905 | /* some debugging code to figure out item information */ |
906 | const char *str = tmp->name |
906 | const char *str = tmp->name |
907 | ? format ("item name: %s item type: %d weight/value: %d", |
907 | ? format ("item name: %s item type: %d weight/value: %d", |
908 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))) |
908 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1)))) |
909 | : format ("item name: %s item type: %d weight/value: %d", |
909 | : format ("item name: %s item type: %d weight/value: %d", |
910 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
910 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1)))); |
911 | |
911 | |
912 | new_draw_info (NDI_UNIQUE, 0, op, str); |
912 | new_draw_info (NDI_UNIQUE, 0, op, str); |
913 | } |
913 | } |
914 | |
914 | |
915 | if (op->contr->mode & PU_INHIBIT) |
915 | if (op->contr->mode & PU_INHIBIT) |
… | |
… | |
1146 | fprintf (stderr, "%s", tmp->name); |
1146 | fprintf (stderr, "%s", tmp->name); |
1147 | } |
1147 | } |
1148 | else |
1148 | else |
1149 | fprintf (stderr, "%s", tmp->arch->archname); |
1149 | fprintf (stderr, "%s", tmp->arch->archname); |
1150 | fprintf (stderr, ",%d] = ", tmp->type); |
1150 | fprintf (stderr, ",%d] = ", tmp->type); |
1151 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1151 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1)))); |
1152 | #endif |
1152 | #endif |
1153 | CHK_PICK_PICKUP; |
1153 | CHK_PICK_PICKUP; |
1154 | continue; |
1154 | continue; |
1155 | } |
1155 | } |
1156 | } /* the new pickup model */ |
1156 | } /* the new pickup model */ |
… | |
… | |
1595 | return; |
1595 | return; |
1596 | } |
1596 | } |
1597 | } |
1597 | } |
1598 | else if (item->type == ROD || item->type == HORN) |
1598 | else if (item->type == ROD || item->type == HORN) |
1599 | { |
1599 | { |
1600 | sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); |
1600 | sint16 spell_sp = max (item->inv->stats.sp, item->inv->stats.grace); |
1601 | |
1601 | |
1602 | // using the maximum of the rods charge allows at least one spell cast |
1602 | // using the maximum of the rods charge allows at least one spell cast |
1603 | // for a rod or horn, this fixes some broken rods. |
1603 | // for a rod or horn, this fixes some broken rods. |
1604 | if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) |
1604 | if (item->stats.hp < min (spell_sp, item->stats.maxhp)) |
1605 | { |
1605 | { |
1606 | op->contr->play_sound (sound_find ("wand_poof")); |
1606 | op->contr->play_sound (sound_find ("wand_poof")); |
1607 | |
1607 | |
1608 | if (item->type == ROD) |
1608 | if (item->type == ROD) |
1609 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
1609 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
… | |
… | |
2018 | } |
2018 | } |
2019 | |
2019 | |
2020 | bool |
2020 | bool |
2021 | move_player (object *op, int dir) |
2021 | move_player (object *op, int dir) |
2022 | { |
2022 | { |
2023 | int pick; |
|
|
2024 | |
|
|
2025 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2023 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2026 | return 0; |
2024 | return 0; |
2027 | |
2025 | |
2028 | /* Sanity check: make sure dir is valid */ |
2026 | /* Sanity check: make sure dir is valid */ |
2029 | if ((dir < 0) || (dir >= 9)) |
2027 | if ((dir < 0) || (dir >= 9)) |
… | |
… | |
2040 | |
2038 | |
2041 | if (op->flag [FLAG_HIDDEN]) |
2039 | if (op->flag [FLAG_HIDDEN]) |
2042 | do_hidden_move (op); |
2040 | do_hidden_move (op); |
2043 | |
2041 | |
2044 | bool retval; |
2042 | bool retval; |
|
|
2043 | int pick = 0; |
2045 | |
2044 | |
2046 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2045 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2047 | retval = RESULT_INT (0); |
2046 | retval = RESULT_INT (0); |
2048 | else if (op->contr->fire_on) |
2047 | else if (op->contr->fire_on) |
2049 | retval = fire (op, dir); |
2048 | retval = fire (op, dir); |
… | |
… | |
2163 | void |
2162 | void |
2164 | object::drop_unpaid_items () |
2163 | object::drop_unpaid_items () |
2165 | { |
2164 | { |
2166 | if (!flag [FLAG_REMOVED]) |
2165 | if (!flag [FLAG_REMOVED]) |
2167 | ::drop_unpaid_items (inv, this); |
2166 | ::drop_unpaid_items (inv, this); |
2168 | } |
|
|
2169 | |
|
|
2170 | /* |
|
|
2171 | * Returns pointer a static string containing gravestone text |
|
|
2172 | * Moved from apply.c to player.c - player.c is what |
|
|
2173 | * actually uses this function. player.c may not be quite the |
|
|
2174 | * best, a misc file for object actions is probably better, |
|
|
2175 | * but there isn't one in the server directory. |
|
|
2176 | */ |
|
|
2177 | static const char * |
|
|
2178 | gravestone_text (object *op) |
|
|
2179 | { |
|
|
2180 | static dynbuf_text buf; |
|
|
2181 | |
|
|
2182 | buf << "---- R.I.P. ----\n\n" |
|
|
2183 | << op->name; |
|
|
2184 | |
|
|
2185 | if (op->type == PLAYER) |
|
|
2186 | buf << " the " << op->contr->title; |
|
|
2187 | |
|
|
2188 | buf << "\n\n"; |
|
|
2189 | |
|
|
2190 | buf << "who was level "; |
|
|
2191 | buf << (sint32)op->level << "\n\n" // OO breakdown |
|
|
2192 | << " when " << (op->contr ? "killed" : "died") << "\n\n"; |
|
|
2193 | |
|
|
2194 | if (op->type == PLAYER) |
|
|
2195 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
|
|
2196 | |
|
|
2197 | { |
|
|
2198 | static char buf2[128]; |
|
|
2199 | time_t now = time (NULL); |
|
|
2200 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
|
|
2201 | buf << buf2; |
|
|
2202 | } |
|
|
2203 | |
|
|
2204 | return buf; |
|
|
2205 | } |
2167 | } |
2206 | |
2168 | |
2207 | void |
2169 | void |
2208 | do_some_living (object *op) |
2170 | do_some_living (object *op) |
2209 | { |
2171 | { |
… | |
… | |
2464 | return; |
2426 | return; |
2465 | |
2427 | |
2466 | dynbuf_text deathtab; |
2428 | dynbuf_text deathtab; |
2467 | |
2429 | |
2468 | /* restore player */ |
2430 | /* restore player */ |
2469 | at = archetype::find ("poisoning"); |
2431 | at = archetype::find (shstr_poisoning); |
2470 | if (object *tmp = present_arch_in_ob (at, op)) |
2432 | if (object *tmp = present_arch_in_ob (at, op)) |
2471 | { |
2433 | { |
2472 | tmp->destroy (); |
2434 | tmp->destroy (); |
2473 | deathtab << "Your body feels cleansed...\r"; |
2435 | deathtab << "Your body feels cleansed...\r"; |
2474 | } |
2436 | } |
2475 | |
2437 | |
2476 | at = archetype::find ("confusion"); |
2438 | at = archetype::find (shstr_confusion); |
2477 | if (object *tmp = present_arch_in_ob (at, op)) |
2439 | if (object *tmp = present_arch_in_ob (at, op)) |
2478 | { |
2440 | { |
2479 | tmp->destroy (); |
2441 | tmp->destroy (); |
2480 | deathtab << "Your mind feels clearer...\r"; |
2442 | deathtab << "Your mind feels clearer...\r"; |
2481 | } |
2443 | } |
… | |
… | |
2508 | if (op_on_battleground (op, &x, &y)) |
2470 | if (op_on_battleground (op, &x, &y)) |
2509 | { |
2471 | { |
2510 | deathtab << "You almost died in combat, but local medics have saved your life...\r"; |
2472 | deathtab << "You almost died in combat, but local medics have saved your life...\r"; |
2511 | |
2473 | |
2512 | /* create a bodypart-trophy to make the winner happy */ |
2474 | /* create a bodypart-trophy to make the winner happy */ |
2513 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2475 | if (object *tmp = arch_to_object (archetype::find (shstr_finger))) |
2514 | { |
2476 | { |
2515 | tmp->name = format ("%s's finger" , &op->name); |
2477 | tmp->name = format ("%s's finger" , &op->name); |
2516 | tmp->name_pl = format ("%s's fingers", &op->name); |
2478 | tmp->name_pl = format ("%s's fingers", &op->name); |
2517 | tmp->msg = format ( |
2479 | tmp->msg = format ( |
2518 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2480 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
… | |
… | |
2593 | lost_a_stat = 1; |
2555 | lost_a_stat = 1; |
2594 | } |
2556 | } |
2595 | else |
2557 | else |
2596 | { |
2558 | { |
2597 | /* deplete a stat */ |
2559 | /* deplete a stat */ |
2598 | archetype *deparch = archetype::find ("depletion"); |
2560 | archetype *deparch = archetype::find (shstr_depletion); |
2599 | object *dep; |
2561 | object *dep; |
2600 | |
2562 | |
2601 | dep = present_arch_in_ob (deparch, op); |
2563 | dep = present_arch_in_ob (deparch, op); |
2602 | if (!dep) |
2564 | if (!dep) |
2603 | { |
2565 | { |
… | |
… | |
2675 | #endif |
2637 | #endif |
2676 | |
2638 | |
2677 | /* Put a gravestone up where the character 'almost' died. List the |
2639 | /* Put a gravestone up where the character 'almost' died. List the |
2678 | * exp loss on the stone. |
2640 | * exp loss on the stone. |
2679 | */ |
2641 | */ |
2680 | tmp = arch_to_object (archetype::find ("gravestone")); |
2642 | tmp = arch_to_object (archetype::find (shstr_gravestone)); |
2681 | tmp->name = format ("%s's gravestone", &op->name); |
2643 | tmp->name = format ("%s's gravestone", &op->name); |
2682 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2644 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2683 | tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", |
2645 | tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", |
2684 | &op->name, op->contr->title, op->contr->killer_name ()); |
2646 | &op->name, op->contr->title, op->contr->killer_name ()); |
2685 | tmp->x = op->x, tmp->y = op->y; |
2647 | tmp->x = op->x, tmp->y = op->y; |