… | |
… | |
122 | continue; |
122 | continue; |
123 | |
123 | |
124 | if (*buf == '%') |
124 | if (*buf == '%') |
125 | { /* send one news */ |
125 | { /* send one news */ |
126 | if (size > 0) |
126 | if (size > 0) |
127 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", (char *)"%s\n%s", subject, news); /*send previously read news */ |
127 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
|
|
128 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, |
|
|
129 | "INFORMATION: %s\n%s", (char *)"%s\n%s", |
|
|
130 | subject, news); /*send previously read news */ |
128 | |
131 | |
129 | strcpy (subject, buf + 1); |
132 | strcpy (subject, buf + 1); |
130 | strip_endline (subject); |
133 | strip_endline (subject); |
131 | size = 0; |
134 | size = 0; |
132 | news[0] = '\0'; |
135 | news[0] = '\0'; |
… | |
… | |
216 | /* make sure he's a player -- needed because of class change. */ |
219 | /* make sure he's a player -- needed because of class change. */ |
217 | ob->type = PLAYER; // we are paranoid |
220 | ob->type = PLAYER; // we are paranoid |
218 | ob->race = ob->arch->race; |
221 | ob->race = ob->arch->race; |
219 | |
222 | |
220 | ob->update_weight (); |
223 | ob->update_weight (); |
221 | link_player_skills (ob); |
224 | link_skills (); |
222 | |
225 | |
223 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
226 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
224 | |
227 | |
225 | assign (title, ob->arch->object::name); |
228 | assign (title, ob->arch->object::name); |
226 | |
229 | |
… | |
… | |
291 | player::set_object (object *op) |
294 | player::set_object (object *op) |
292 | { |
295 | { |
293 | ob = observe = op; |
296 | ob = observe = op; |
294 | ob->contr = this; /* this aren't yet in archetype */ |
297 | ob->contr = this; /* this aren't yet in archetype */ |
295 | |
298 | |
296 | ob->speed = 1.0f; |
299 | ob->speed = 1.0f; |
297 | ob->speed_left = 0.5f; |
300 | ob->speed_left = 0.5f; |
298 | |
301 | |
299 | ob->direction = 5; /* So player faces south */ |
302 | ob->direction = 5; /* So player faces south */ |
300 | |
303 | |
301 | ob->flag [FLAG_READY_WEAPON] = false; |
304 | ob->flag [FLAG_READY_WEAPON] = false; |
302 | ob->flag [FLAG_READY_SKILL] = false; |
305 | ob->flag [FLAG_READY_SKILL] = false; |
303 | ob->flag [FLAG_READY_BOW] = false; |
306 | ob->flag [FLAG_READY_BOW] = false; |
304 | |
307 | |
… | |
… | |
321 | combat_ob = op; |
324 | combat_ob = op; |
322 | break; |
325 | break; |
323 | } |
326 | } |
324 | |
327 | |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
328 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
326 | ob->deactivate (); // change_Weapon activates, fix this better |
329 | ob->deactivate (); // change_weapon activates, fix this better |
327 | } |
330 | } |
328 | |
331 | |
329 | void |
332 | void |
330 | player::set_observe (object *op) |
333 | player::set_observe (object *op) |
331 | { |
334 | { |
… | |
… | |
345 | savebed_map = first_map_path; /* Init. respawn position */ |
348 | savebed_map = first_map_path; /* Init. respawn position */ |
346 | |
349 | |
347 | gen_sp_armour = 10; |
350 | gen_sp_armour = 10; |
348 | bowtype = bow_normal; |
351 | bowtype = bow_normal; |
349 | petmode = pet_normal; |
352 | petmode = pet_normal; |
350 | listening = 10; |
|
|
351 | usekeys = containers; |
353 | usekeys = containers; |
352 | peaceful = 1; /* default peaceful */ |
354 | peaceful = 1; /* default peaceful */ |
353 | do_los = 1; |
355 | do_los = 1; |
354 | |
356 | |
355 | weapon_sp = 1.0f; |
357 | weapon_sp = 1.0f; |
… | |
… | |
726 | else /* lock all 'normal items by default */ |
728 | else /* lock all 'normal items by default */ |
727 | SET_FLAG (op, FLAG_INV_LOCKED); |
729 | SET_FLAG (op, FLAG_INV_LOCKED); |
728 | } /* for loop of objects in player inv */ |
730 | } /* for loop of objects in player inv */ |
729 | |
731 | |
730 | /* Need to set up the skill pointers */ |
732 | /* Need to set up the skill pointers */ |
731 | link_player_skills (pl); |
733 | pl->contr->link_skills (); |
732 | } |
734 | } |
733 | |
735 | |
734 | void |
736 | void |
735 | get_party_password (object *op, partylist *party) |
737 | get_party_password (object *op, partylist *party) |
736 | { |
738 | { |
… | |
… | |
865 | ob->contr->ns->state = ST_PLAYING; |
867 | ob->contr->ns->state = ST_PLAYING; |
866 | |
868 | |
867 | if (ob->msg) |
869 | if (ob->msg) |
868 | ob->msg = 0; |
870 | ob->msg = 0; |
869 | |
871 | |
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); |
872 | start_info (ob); |
880 | CLEAR_FLAG (ob, FLAG_WIZ); |
873 | CLEAR_FLAG (ob, FLAG_WIZ); |
881 | give_initial_items (ob, ob->randomitems); |
874 | give_initial_items (ob, ob->randomitems); |
882 | link_player_skills (ob); |
|
|
883 | esrv_send_inventory (ob, ob); |
875 | esrv_send_inventory (ob, ob); |
884 | ob->update_stats (); |
876 | ob->update_stats (); |
885 | |
877 | |
886 | /* This moves the player to a different start map, if there |
878 | /* This moves the player to a different start map, if there |
887 | * is one for this race |
879 | * is one for this race |
888 | */ |
880 | */ |
889 | if (*first_map_ext_path) |
881 | if (*first_map_ext_path) |
890 | { |
882 | 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 |
883 | else |
905 | LOG (llevDebug, "first_map_ext_path not set\n"); |
884 | LOG (llevDebug, "first_map_ext_path not set\n"); |
906 | } |
885 | } |
907 | |
886 | |
908 | void |
887 | void |
… | |
… | |
1327 | if (op->contr->mode & PU_RATIO) |
1306 | if (op->contr->mode & PU_RATIO) |
1328 | { |
1307 | { |
1329 | /* use value density to decide what else to grab */ |
1308 | /* use value density to decide what else to grab */ |
1330 | /* >=7 was >= op->contr->mode */ |
1309 | /* >=7 was >= op->contr->mode */ |
1331 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1310 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1332 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1311 | */ |
1333 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
1312 | wvratio = op->contr->mode & PU_RATIO; |
1334 | if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) |
1313 | if (1000 * query_cost (tmp, op, F_TRUE) / tmp->total_weight () >= wvratio * 100) |
1335 | { |
1314 | { |
1336 | CHK_PICK_PICKUP; |
1315 | CHK_PICK_PICKUP; |
1337 | #if 0 |
1316 | #if 0 |
1338 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1317 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1339 | if (tmp->name != NULL) |
1318 | if (tmp->name != NULL) |
… | |
… | |
1405 | } |
1384 | } |
1406 | } |
1385 | } |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1386 | else if (arrow->type == ARROW && arrow->race == type) |
1408 | { |
1387 | { |
1409 | /* allways prefer assasination/slaying */ |
1388 | /* allways prefer assasination/slaying */ |
1410 | if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) |
1389 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1411 | { |
1390 | { |
1412 | if (arrow->attacktype & AT_DEATH) |
1391 | if (arrow->attacktype & AT_DEATH) |
1413 | { |
1392 | { |
1414 | *better = 100; |
1393 | *better = 100; |
1415 | return arrow; |
1394 | return arrow; |
… | |
… | |
1443 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1422 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1444 | } |
1423 | } |
1445 | } |
1424 | } |
1446 | } |
1425 | } |
1447 | } |
1426 | } |
|
|
1427 | |
1448 | if (tmp == NULL && arrow == NULL) |
1428 | if (tmp == NULL && arrow == NULL) |
1449 | return find_arrow (op, type); |
1429 | return find_arrow (op, type); |
1450 | |
1430 | |
1451 | *better = betterby; |
1431 | *better = betterby; |
1452 | return tmp; |
1432 | return tmp; |
… | |
… | |
1598 | } |
1578 | } |
1599 | |
1579 | |
1600 | /* this should not happen, but sometimes does */ |
1580 | /* this should not happen, but sometimes does */ |
1601 | if (arrow->nrof == 0) |
1581 | if (arrow->nrof == 0) |
1602 | { |
1582 | { |
|
|
1583 | LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ()); |
1603 | arrow->destroy (); |
1584 | arrow->destroy (); |
1604 | return 0; |
1585 | return 0; |
1605 | } |
1586 | } |
1606 | |
1587 | |
1607 | left = arrow; /* these are arrows left to the player */ |
1588 | left = arrow; /* these are arrows left to the player */ |
… | |
… | |
1763 | return; |
1744 | return; |
1764 | } |
1745 | } |
1765 | } |
1746 | } |
1766 | else if (item->type == ROD || item->type == HORN) |
1747 | else if (item->type == ROD || item->type == HORN) |
1767 | { |
1748 | { |
1768 | if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) |
1749 | sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); |
|
|
1750 | |
|
|
1751 | // using the maximum of the rods charge allows at least one spell cast |
|
|
1752 | // for a rod or horn, this fixes some broken rods. |
|
|
1753 | if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) |
1769 | { |
1754 | { |
1770 | op->contr->play_sound (sound_find ("wand_poof")); |
1755 | op->contr->play_sound (sound_find ("wand_poof")); |
1771 | |
1756 | |
1772 | if (item->type == ROD) |
1757 | if (item->type == ROD) |
1773 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
1758 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
… | |
… | |
1808 | bool |
1793 | bool |
1809 | fire (object *op, int dir) |
1794 | fire (object *op, int dir) |
1810 | { |
1795 | { |
1811 | int spellcost = 0; |
1796 | int spellcost = 0; |
1812 | |
1797 | |
1813 | /* check for loss of invisiblity/hide */ |
|
|
1814 | if (action_makes_visible (op)) |
|
|
1815 | make_visible (op); |
|
|
1816 | |
|
|
1817 | player *pl = op->contr; |
1798 | player *pl = op->contr; |
1818 | |
1799 | |
1819 | if (pl->golem) |
1800 | if (pl->golem) |
1820 | { |
1801 | { |
1821 | control_golem (op->contr->golem, dir); |
1802 | control_golem (op->contr->golem, dir); |
… | |
… | |
1823 | } |
1804 | } |
1824 | |
1805 | |
1825 | object *ob = pl->ranged_ob; |
1806 | object *ob = pl->ranged_ob; |
1826 | |
1807 | |
1827 | if (!ob) |
1808 | if (!ob) |
1828 | return false; |
|
|
1829 | |
|
|
1830 | if (!op->change_weapon (ob)) |
|
|
1831 | return false; |
1809 | return false; |
1832 | |
1810 | |
1833 | if (op->speed_left > 0.f) |
1811 | if (op->speed_left > 0.f) |
1834 | --op->speed_left; |
1812 | --op->speed_left; |
1835 | else |
1813 | else |
1836 | return false; |
1814 | return false; |
|
|
1815 | |
|
|
1816 | if (!op->change_weapon (ob)) |
|
|
1817 | return false; |
|
|
1818 | |
|
|
1819 | /* check for loss of invisiblity/hide */ |
|
|
1820 | if (action_makes_visible (op)) |
|
|
1821 | make_visible (op); |
1837 | |
1822 | |
1838 | switch (ob->type) |
1823 | switch (ob->type) |
1839 | { |
1824 | { |
1840 | case BOW: |
1825 | case BOW: |
1841 | player_fire_bow (op, dir); |
1826 | player_fire_bow (op, dir); |
… | |
… | |
2086 | --op->speed_left; |
2071 | --op->speed_left; |
2087 | |
2072 | |
2088 | op->play_sound (sound_find ("push_player")); |
2073 | op->play_sound (sound_find ("push_player")); |
2089 | push_ob (mon, dir, op); |
2074 | push_ob (mon, dir, op); |
2090 | |
2075 | |
2091 | if (op->contr->tmp_invis || op->hide) |
2076 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2092 | make_visible (op); |
2077 | make_visible (op); |
2093 | |
2078 | |
2094 | return true; |
2079 | return true; |
2095 | } |
2080 | } |
2096 | else |
2081 | else |
… | |
… | |
2118 | push_ob (mon, dir, op); |
2103 | push_ob (mon, dir, op); |
2119 | } |
2104 | } |
2120 | else |
2105 | else |
2121 | op->statusmsg ("You withhold your attack"); |
2106 | op->statusmsg ("You withhold your attack"); |
2122 | |
2107 | |
2123 | if (op->contr->tmp_invis || op->hide) |
2108 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2124 | make_visible (op); |
2109 | make_visible (op); |
2125 | |
2110 | |
2126 | return true; |
2111 | return true; |
2127 | } |
2112 | } |
2128 | } |
2113 | } |
… | |
… | |
2186 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2171 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2187 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2172 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2188 | |
2173 | |
2189 | op->facing = dir; |
2174 | op->facing = dir; |
2190 | |
2175 | |
2191 | if (op->hide) |
2176 | if (op->flag [FLAG_HIDDEN]) |
2192 | do_hidden_move (op); |
2177 | do_hidden_move (op); |
2193 | |
2178 | |
2194 | bool retval; |
2179 | bool retval; |
2195 | |
2180 | |
2196 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2181 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
… | |
… | |
2322 | * Moved from apply.c to player.c - player.c is what |
2307 | * Moved from apply.c to player.c - player.c is what |
2323 | * actually uses this function. player.c may not be quite the |
2308 | * actually uses this function. player.c may not be quite the |
2324 | * best, a misc file for object actions is probably better, |
2309 | * best, a misc file for object actions is probably better, |
2325 | * but there isn't one in the server directory. |
2310 | * but there isn't one in the server directory. |
2326 | */ |
2311 | */ |
2327 | char * |
2312 | const char * |
2328 | gravestone_text (object *op) |
2313 | gravestone_text (object *op) |
2329 | { |
2314 | { |
2330 | static char buf2[MAX_BUF]; |
2315 | static dynbuf_text buf; |
2331 | char buf[MAX_BUF]; |
|
|
2332 | time_t now = time (NULL); |
|
|
2333 | |
2316 | |
2334 | strcpy (buf2, " R.I.P.\n\n"); |
2317 | buf << "---- R.I.P. ----\n\n" |
|
|
2318 | << op->name; |
|
|
2319 | |
2335 | if (op->type == PLAYER) |
2320 | if (op->type == PLAYER) |
2336 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2321 | buf << " the " << op->contr->title; |
2337 | else |
|
|
2338 | sprintf (buf, "%s\n", &op->name); |
|
|
2339 | |
2322 | |
2340 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2323 | buf << "\n\n"; |
2341 | strcat (buf2, buf); |
2324 | |
|
|
2325 | buf << "who was level "; |
|
|
2326 | buf << (sint32)op->level << "\n\n" // OO breakdown |
|
|
2327 | << " when " << (op->contr ? "killed" : "died") << "\n\n"; |
|
|
2328 | |
2342 | if (op->type == PLAYER) |
2329 | if (op->type == PLAYER) |
2343 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2330 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
2344 | else |
|
|
2345 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2346 | |
2331 | |
2347 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
|
|
2348 | strcat (buf2, buf); |
|
|
2349 | if (op->type == PLAYER) |
|
|
2350 | { |
2332 | { |
2351 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2333 | static char buf2[128]; |
2352 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2334 | time_t now = time (NULL); |
2353 | strcat (buf2, buf); |
|
|
2354 | } |
|
|
2355 | |
|
|
2356 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2335 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
2357 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2336 | buf << buf2; |
2358 | strcat (buf2, buf); |
2337 | } |
2359 | |
2338 | |
2360 | return buf2; |
2339 | return buf; |
2361 | } |
2340 | } |
2362 | |
2341 | |
2363 | void |
2342 | void |
2364 | do_some_living (object *op) |
2343 | do_some_living (object *op) |
2365 | { |
2344 | { |
… | |
… | |
2546 | op->stats.food--; |
2525 | op->stats.food--; |
2547 | } |
2526 | } |
2548 | |
2527 | |
2549 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2528 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2550 | { |
2529 | { |
2551 | object *tmp, *flesh = 0; |
2530 | object *flesh = 0; |
2552 | |
2531 | |
2553 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2532 | for_inv_removable (op, tmp) |
2554 | { |
2533 | { |
2555 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2534 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
2535 | continue; |
|
|
2536 | |
|
|
2537 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2556 | { |
2538 | { |
2557 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2539 | op->statusmsg ("You blindly grab for a bite of food. " |
2558 | { |
2540 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2559 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
|
|
2560 | manual_apply (op, tmp, 0); |
2541 | manual_apply (op, tmp, 0); |
|
|
2542 | |
2561 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2543 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2562 | break; |
2544 | break; |
2563 | } |
2545 | } |
2564 | else if (tmp->type == FLESH) |
2546 | else if (tmp->type == FLESH) |
2565 | flesh = tmp; |
2547 | flesh = tmp; |
2566 | } /* End if paid for object */ |
2548 | } |
2567 | } /* end of for loop */ |
|
|
2568 | |
2549 | |
2569 | /* If player is still starving, it means they don't have any food, so |
2550 | /* If player is still starving, it means they don't have any food, so |
2570 | * eat flesh instead. |
2551 | * eat flesh instead. |
2571 | */ |
2552 | */ |
2572 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2553 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2573 | { |
2554 | { |
2574 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2555 | op->statusmsg ("You blindly grab for a bite of food. " |
|
|
2556 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2575 | manual_apply (op, flesh, 0); |
2557 | manual_apply (op, flesh, 0); |
2576 | } |
2558 | } |
|
|
2559 | |
|
|
2560 | // If player is still starving, alert him! |
|
|
2561 | if (op->stats.food < 0) |
|
|
2562 | op->failmsg ("You are starving! " |
|
|
2563 | "H<Eat some food to increase your food and prevent you from an untimely death.>"); |
2577 | } |
2564 | } |
2578 | |
2565 | |
2579 | if (op->stats.food < 0) |
2566 | if (op->stats.food < 0) |
2580 | { |
2567 | { |
2581 | op->stats.hp += op->stats.food; |
2568 | op->stats.hp += op->stats.food; |
2582 | op->stats.food = 0; |
2569 | op->stats.food = 0; |
|
|
2570 | |
|
|
2571 | if (op->stats.hp < 0) |
|
|
2572 | { |
|
|
2573 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2574 | op->contr->killer->destroy (); |
2583 | } |
2575 | } |
|
|
2576 | } |
2584 | |
2577 | |
|
|
2578 | /* killer should be set here already */ |
2585 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2579 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2586 | kill_player (op); |
2580 | kill_player (op); |
2587 | } |
2581 | } |
2588 | } |
2582 | } |
2589 | |
2583 | |
… | |
… | |
2639 | { |
2633 | { |
2640 | tmp->name = format ("%s's finger" , &op->name); |
2634 | tmp->name = format ("%s's finger" , &op->name); |
2641 | tmp->name_pl = format ("%s's fingers", &op->name); |
2635 | tmp->name_pl = format ("%s's fingers", &op->name); |
2642 | tmp->msg = format ( |
2636 | tmp->msg = format ( |
2643 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2637 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2644 | &op->name, op->contr->title, (int) (op->level), op->contr->killer |
2638 | &op->name, op->contr->title, |
|
|
2639 | (int)op->level, |
|
|
2640 | op->contr->killer_name () |
2645 | ); |
2641 | ); |
2646 | tmp->value = 0, tmp->type = 0; |
2642 | tmp->value = 0, tmp->type = 0; |
2647 | tmp->materialname = "organics"; |
2643 | tmp->materialname = "organics"; |
2648 | tmp->insert_at (op, tmp); |
2644 | tmp->insert_at (op, tmp); |
2649 | } |
2645 | } |
… | |
… | |
2655 | } |
2651 | } |
2656 | |
2652 | |
2657 | INVOKE_PLAYER (DEATH, op->contr); |
2653 | INVOKE_PLAYER (DEATH, op->contr); |
2658 | |
2654 | |
2659 | command_kill_pets (op, 0); |
2655 | command_kill_pets (op, 0); |
2660 | |
|
|
2661 | if (op->stats.food < 0) |
|
|
2662 | strcpy (op->contr->killer, "starvation"); |
|
|
2663 | |
2656 | |
2664 | op->contr->play_sound (sound_find ("player_dies")); |
2657 | op->contr->play_sound (sound_find ("player_dies")); |
2665 | |
2658 | |
2666 | /* save the map location for corpse, gravestone */ |
2659 | /* save the map location for corpse, gravestone */ |
2667 | x = op->x; |
2660 | x = op->x; |
… | |
… | |
2776 | lost_a_stat = 1; |
2769 | lost_a_stat = 1; |
2777 | } |
2770 | } |
2778 | } |
2771 | } |
2779 | } |
2772 | } |
2780 | } |
2773 | } |
|
|
2774 | |
2781 | /* If no stat lost, tell the player. */ |
2775 | /* If no stat lost, tell the player. */ |
2782 | if (!lost_a_stat) |
2776 | if (!lost_a_stat) |
2783 | { |
2777 | { |
2784 | /* determine_god() seems to not work sometimes... why is this? |
2778 | /* determine_god() seems to not work sometimes... why is this? |
2785 | Should I be using something else? GD */ |
2779 | Should I be using something else? GD */ |
… | |
… | |
2789 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2783 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2790 | else |
2784 | else |
2791 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2785 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2792 | } |
2786 | } |
2793 | #else |
2787 | #else |
2794 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
2788 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely."); |
2795 | #endif |
2789 | #endif |
2796 | |
2790 | |
2797 | /* Put a gravestone up where the character 'almost' died. List the |
2791 | /* Put a gravestone up where the character 'almost' died. List the |
2798 | * exp loss on the stone. |
2792 | * exp loss on the stone. |
2799 | */ |
2793 | */ |
2800 | tmp = arch_to_object (archetype::find ("gravestone")); |
2794 | tmp = arch_to_object (archetype::find ("gravestone")); |
2801 | sprintf (buf, "%s's gravestone", &op->name); |
2795 | tmp->name = format ("%s's gravestone", &op->name); |
2802 | tmp->name = buf; |
2796 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2803 | sprintf (buf, "%s's gravestones", &op->name); |
2797 | tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", |
2804 | tmp->name_pl = buf; |
2798 | &op->name, op->contr->title, op->contr->killer_name ()); |
2805 | sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); |
|
|
2806 | tmp->msg = buf; |
|
|
2807 | tmp->x = op->x, tmp->y = op->y; |
2799 | tmp->x = op->x, tmp->y = op->y; |
2808 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2800 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2809 | |
2801 | |
2810 | /**************************************/ |
2802 | /**************************************/ |
2811 | /* */ |
2803 | /* */ |
… | |
… | |
2834 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2826 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2835 | } |
2827 | } |
2836 | |
2828 | |
2837 | cure_disease (op, 0, 0); /* remove any disease */ |
2829 | cure_disease (op, 0, 0); /* remove any disease */ |
2838 | |
2830 | |
|
|
2831 | // remove all spell effects that are active |
|
|
2832 | // to avoid long-term effects such as word-of-recall |
|
|
2833 | for (object *item = op->inv; item; ) |
|
|
2834 | { |
|
|
2835 | object *next = item->below; |
|
|
2836 | |
|
|
2837 | if (item->type == SPELL_EFFECT && item->active) |
|
|
2838 | item->destroy (); |
|
|
2839 | |
|
|
2840 | item = next; |
|
|
2841 | } |
|
|
2842 | |
2839 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2843 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2840 | apply_death_exp_penalty (op); |
2844 | apply_death_exp_penalty (op); |
|
|
2845 | |
2841 | if (op->stats.food < 100) |
2846 | if (op->stats.food < 100) |
2842 | op->stats.food = 900; |
2847 | op->stats.food = 900; |
|
|
2848 | |
2843 | op->stats.hp = op->stats.maxhp; |
2849 | op->stats.hp = op->stats.maxhp; |
2844 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2850 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2845 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2851 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2846 | |
2852 | |
2847 | /* |
2853 | /* |
… | |
… | |
2885 | if (will_kill_again & (1 << at)) |
2891 | if (will_kill_again & (1 << at)) |
2886 | force->resist[at] = 100; |
2892 | force->resist[at] = 100; |
2887 | |
2893 | |
2888 | insert_ob_in_ob (force, op); |
2894 | insert_ob_in_ob (force, op); |
2889 | op->update_stats (); |
2895 | op->update_stats (); |
2890 | |
|
|
2891 | } |
2896 | } |
2892 | |
2897 | |
2893 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
2898 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
2894 | } |
2899 | } |
2895 | |
2900 | |
… | |
… | |
2996 | } |
3001 | } |
2997 | |
3002 | |
2998 | void |
3003 | void |
2999 | make_visible (object *op) |
3004 | make_visible (object *op) |
3000 | { |
3005 | { |
3001 | op->hide = 0; |
3006 | op->flag [FLAG_HIDDEN] = 0; |
3002 | op->invisible = 0; |
3007 | op->invisible = 0; |
3003 | |
3008 | |
3004 | if (op->type == PLAYER) |
3009 | if (op->type == PLAYER) |
3005 | { |
3010 | { |
3006 | op->contr->tmp_invis = 0; |
3011 | op->contr->tmp_invis = 0; |
… | |
… | |
3068 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3073 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3069 | */ |
3074 | */ |
3070 | void |
3075 | void |
3071 | do_hidden_move (object *op) |
3076 | do_hidden_move (object *op) |
3072 | { |
3077 | { |
3073 | int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); |
3078 | int hide = 0; |
3074 | object *skop; |
|
|
3075 | |
3079 | |
3076 | if (!op || !op->map) |
3080 | if (!op || !op->map) |
3077 | return; |
3081 | return; |
3078 | |
3082 | |
3079 | skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
3083 | object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
|
|
3084 | int num = random_roll (0, 19, op, PREFER_LOW); |
3080 | |
3085 | |
3081 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
3086 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
3082 | if (op->type == PLAYER && op->contr->run_on) |
3087 | if (op->type == PLAYER && op->contr->run_on) |
3083 | if (!skop || num >= skop->level) |
3088 | if (!skop || num >= skop->level) |
3084 | { |
3089 | { |
… | |
… | |
3094 | num -= hide; |
3099 | num -= hide; |
3095 | |
3100 | |
3096 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3101 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3097 | { |
3102 | { |
3098 | make_visible (op); |
3103 | make_visible (op); |
|
|
3104 | |
3099 | if (op->type == PLAYER) |
3105 | if (op->type == PLAYER) |
3100 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3106 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3101 | } |
3107 | } |
3102 | else if (op->type == PLAYER && skop) |
3108 | else if (op->type == PLAYER && skop) |
3103 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
3109 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
… | |
… | |
3226 | |
3232 | |
3227 | if (op->contr && op->contr->tmp_invis == 0) |
3233 | if (op->contr && op->contr->tmp_invis == 0) |
3228 | return 0; |
3234 | return 0; |
3229 | |
3235 | |
3230 | /* If monsters, they should become visible */ |
3236 | /* If monsters, they should become visible */ |
3231 | if (op->hide || !op->contr || (op->contr && op->contr->tmp_invis)) |
3237 | if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis)) |
3232 | { |
3238 | { |
3233 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); |
3239 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible"); |
3234 | return 1; |
3240 | return 1; |
3235 | } |
3241 | } |
3236 | } |
3242 | } |
3237 | |
3243 | |
3238 | return 0; |
3244 | return 0; |