1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra 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 |
… | |
… | |
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'; |
… | |
… | |
215 | |
218 | |
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->carrying = sum_weight (ob); |
223 | ob->update_weight (); |
221 | link_player_skills (ob); |
224 | link_player_skills (ob); |
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); |
… | |
… | |
239 | set_dragon_name (ob, abil, skin); |
242 | set_dragon_name (ob, abil, skin); |
240 | } |
243 | } |
241 | |
244 | |
242 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
245 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
243 | |
246 | |
244 | esrv_new_player (this, ob->weight + ob->carrying); |
247 | esrv_new_player (this); |
245 | |
248 | |
246 | ob->update_stats (); |
249 | ob->update_stats (); |
247 | |
250 | |
248 | ns->floorbox_update (); |
251 | ns->floorbox_update (); |
249 | esrv_send_inventory (ob, ob); |
252 | esrv_send_inventory (ob, ob); |
… | |
… | |
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); |
|
|
329 | ob->deactivate (); // change_weapon activates, fix this better |
326 | } |
330 | } |
327 | |
331 | |
328 | void |
332 | void |
329 | player::set_observe (object *op) |
333 | player::set_observe (object *op) |
330 | { |
334 | { |
… | |
… | |
344 | savebed_map = first_map_path; /* Init. respawn position */ |
348 | savebed_map = first_map_path; /* Init. respawn position */ |
345 | |
349 | |
346 | gen_sp_armour = 10; |
350 | gen_sp_armour = 10; |
347 | bowtype = bow_normal; |
351 | bowtype = bow_normal; |
348 | petmode = pet_normal; |
352 | petmode = pet_normal; |
349 | listening = 10; |
|
|
350 | usekeys = containers; |
353 | usekeys = containers; |
351 | peaceful = 1; /* default peaceful */ |
354 | peaceful = 1; /* default peaceful */ |
352 | do_los = 1; |
355 | do_los = 1; |
353 | |
356 | |
354 | weapon_sp = 1.0f; |
357 | weapon_sp = 1.0f; |
… | |
… | |
403 | * Note: there MUST be at least one player archetype! |
406 | * Note: there MUST be at least one player archetype! |
404 | */ |
407 | */ |
405 | archetype * |
408 | archetype * |
406 | get_player_archetype (archetype *at) |
409 | get_player_archetype (archetype *at) |
407 | { |
410 | { |
|
|
411 | // archetypes could have been reloaded |
|
|
412 | archetype *nat = at ? archetype::find (at->archname) : archetypes [0]; |
|
|
413 | |
|
|
414 | if (!nat) |
|
|
415 | return at; |
|
|
416 | |
408 | archvec::iterator i = at ? archetypes.find (at) : archetypes.begin (); |
417 | archvec::iterator i = archetypes.find (nat); |
409 | |
418 | |
410 | for (;;) |
419 | for (;;) |
411 | { |
420 | { |
412 | if (++i == archetypes.end ()) |
421 | if (++i == archetypes.end ()) |
413 | i = archetypes.begin (); |
422 | i = archetypes.begin (); |
… | |
… | |
631 | |
640 | |
632 | return firstdir; |
641 | return firstdir; |
633 | } |
642 | } |
634 | |
643 | |
635 | void |
644 | void |
636 | give_initial_items (object *pl, treasurelist * items) |
645 | give_initial_items (object *pl, treasurelist *items) |
637 | { |
646 | { |
638 | if (pl->randomitems) |
647 | if (pl->randomitems) |
639 | create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); |
648 | create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); |
640 | |
649 | |
641 | for (object *next, *op = pl->inv; op; op = next) |
650 | for (object *next, *op = pl->inv; op; op = next) |
… | |
… | |
651 | /* we never give weapons/armour if these cannot be used |
660 | /* we never give weapons/armour if these cannot be used |
652 | * by this player due to race restrictions |
661 | * by this player due to race restrictions |
653 | */ |
662 | */ |
654 | if (pl->type == PLAYER) |
663 | if (pl->type == PLAYER) |
655 | { |
664 | { |
656 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) && |
665 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) |
|
|
666 | && |
657 | (op->type == ARMOUR || op->type == BOOTS || |
667 | (op->type == ARMOUR || op->type == BOOTS |
658 | op->type == CLOAK || op->type == HELMET || |
668 | || op->type == CLOAK || op->type == HELMET |
659 | op->type == SHIELD || op->type == GLOVES || |
669 | || op->type == SHIELD || op->type == GLOVES |
|
|
670 | || op->type == BRACERS || op->type == GIRDLE)) |
660 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
671 | || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
661 | { |
672 | { |
662 | op->destroy (); |
673 | op->destroy (); |
663 | continue; |
674 | continue; |
664 | } |
675 | } |
665 | } |
676 | } |
… | |
… | |
691 | |
702 | |
692 | if (op->type == SPELLBOOK && op->inv) |
703 | if (op->type == SPELLBOOK && op->inv) |
693 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
704 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
694 | |
705 | |
695 | /* Give starting characters identified, uncursed, and undamned |
706 | /* Give starting characters identified, uncursed, and undamned |
696 | * items. Just don't identify gold or silver, or it won't be |
707 | * items. Just don't identify gold or silver, or it won't be |
697 | * merged properly. |
708 | * merged properly. |
698 | */ |
709 | */ |
699 | if (need_identify (op)) |
710 | if (need_identify (op)) |
700 | { |
711 | { |
701 | SET_FLAG (op, FLAG_IDENTIFIED); |
712 | SET_FLAG (op, FLAG_IDENTIFIED); |
702 | CLEAR_FLAG (op, FLAG_CURSED); |
713 | CLEAR_FLAG (op, FLAG_CURSED); |
703 | CLEAR_FLAG (op, FLAG_DAMNED); |
714 | CLEAR_FLAG (op, FLAG_DAMNED); |
704 | } |
715 | } |
|
|
716 | |
705 | if (op->type == SPELL) |
717 | if (op->type == SPELL) |
706 | { |
718 | { |
707 | op->destroy (); |
719 | op->destroy (); |
708 | continue; |
720 | continue; |
709 | } |
721 | } |
… | |
… | |
711 | { |
723 | { |
712 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
724 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
713 | op->stats.exp = 0; |
725 | op->stats.exp = 0; |
714 | op->level = 1; |
726 | op->level = 1; |
715 | } |
727 | } |
716 | /* lock all 'normal items by default */ |
728 | else /* lock all 'normal items by default */ |
717 | else |
|
|
718 | SET_FLAG (op, FLAG_INV_LOCKED); |
729 | SET_FLAG (op, FLAG_INV_LOCKED); |
719 | } /* for loop of objects in player inv */ |
730 | } /* for loop of objects in player inv */ |
720 | |
731 | |
721 | /* Need to set up the skill pointers */ |
732 | /* Need to set up the skill pointers */ |
722 | link_player_skills (pl); |
733 | link_player_skills (pl); |
… | |
… | |
842 | */ |
853 | */ |
843 | void |
854 | void |
844 | player::chargen_race_done () |
855 | player::chargen_race_done () |
845 | { |
856 | { |
846 | /* this must before then initial items are given */ |
857 | /* this must before then initial items are given */ |
847 | esrv_new_player (ob->contr, ob->weight + ob->carrying); |
858 | esrv_new_player (ob->contr); |
848 | |
859 | |
849 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
860 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
850 | if (tl) |
861 | if (tl) |
851 | create_treasure (tl, ob, 0, 0, 0); |
862 | create_treasure (tl, ob, 0, 0, 0); |
852 | |
863 | |
… | |
… | |
855 | |
866 | |
856 | ob->contr->ns->state = ST_PLAYING; |
867 | ob->contr->ns->state = ST_PLAYING; |
857 | |
868 | |
858 | if (ob->msg) |
869 | if (ob->msg) |
859 | ob->msg = 0; |
870 | ob->msg = 0; |
860 | |
|
|
861 | /* We create this now because some of the unique maps will need it |
|
|
862 | * to save here. |
|
|
863 | */ |
|
|
864 | { |
|
|
865 | char buf[MAX_BUF]; |
|
|
866 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &ob->name); |
|
|
867 | make_path_to_file (buf); |
|
|
868 | } |
|
|
869 | |
871 | |
870 | start_info (ob); |
872 | start_info (ob); |
871 | CLEAR_FLAG (ob, FLAG_WIZ); |
873 | CLEAR_FLAG (ob, FLAG_WIZ); |
872 | give_initial_items (ob, ob->randomitems); |
874 | give_initial_items (ob, ob->randomitems); |
873 | link_player_skills (ob); |
875 | link_player_skills (ob); |
… | |
… | |
876 | |
878 | |
877 | /* This moves the player to a different start map, if there |
879 | /* This moves the player to a different start map, if there |
878 | * is one for this race |
880 | * is one for this race |
879 | */ |
881 | */ |
880 | if (*first_map_ext_path) |
882 | if (*first_map_ext_path) |
881 | { |
883 | ob->player_goto (format ("%s/%s", &first_map_ext_path, &ob->arch->archname), ob->x, ob->y); |
882 | object *tmp; |
|
|
883 | char mapname[MAX_BUF]; |
|
|
884 | |
|
|
885 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname); |
|
|
886 | tmp = object::create (); |
|
|
887 | EXIT_PATH (tmp) = mapname; |
|
|
888 | EXIT_X (tmp) = ob->x; |
|
|
889 | EXIT_Y (tmp) = ob->y; |
|
|
890 | ob->enter_exit (tmp); /* we don't really care if it succeeded; |
|
|
891 | * if the map isn't there, then stay on the |
|
|
892 | * default initial map */ |
|
|
893 | tmp->destroy (); |
|
|
894 | } |
|
|
895 | else |
884 | else |
896 | LOG (llevDebug, "first_map_ext_path not set\n"); |
885 | LOG (llevDebug, "first_map_ext_path not set\n"); |
897 | } |
886 | } |
898 | |
887 | |
899 | void |
888 | void |
… | |
… | |
1318 | if (op->contr->mode & PU_RATIO) |
1307 | if (op->contr->mode & PU_RATIO) |
1319 | { |
1308 | { |
1320 | /* use value density to decide what else to grab */ |
1309 | /* use value density to decide what else to grab */ |
1321 | /* >=7 was >= op->contr->mode */ |
1310 | /* >=7 was >= op->contr->mode */ |
1322 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1311 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1323 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1312 | */ |
1324 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
1313 | wvratio = op->contr->mode & PU_RATIO; |
1325 | if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) |
1314 | if (1000 * query_cost (tmp, op, F_TRUE) / tmp->total_weight () >= wvratio * 100) |
1326 | { |
1315 | { |
1327 | CHK_PICK_PICKUP; |
1316 | CHK_PICK_PICKUP; |
1328 | #if 0 |
1317 | #if 0 |
1329 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1318 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1330 | if (tmp->name != NULL) |
1319 | if (tmp->name != NULL) |
… | |
… | |
1351 | * found object is returned. |
1340 | * found object is returned. |
1352 | */ |
1341 | */ |
1353 | object * |
1342 | object * |
1354 | find_arrow (object *op, const char *type) |
1343 | find_arrow (object *op, const char *type) |
1355 | { |
1344 | { |
1356 | object *tmp = 0; |
|
|
1357 | |
|
|
1358 | for (op = op->inv; op; op = op->below) |
1345 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1359 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
|
|
1360 | tmp = find_arrow (splay (op), type); |
|
|
1361 | else if (op->type == ARROW && op->race == type) |
1346 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1362 | return splay (op); |
1347 | return splay (tmp); |
1363 | |
1348 | |
|
|
1349 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
|
|
1350 | if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && !strcmp (&tmp->race, type)) |
|
|
1351 | if (object *arrow = find_arrow (tmp, type)) |
|
|
1352 | { |
|
|
1353 | splay (tmp); |
|
|
1354 | return arrow; |
|
|
1355 | } |
|
|
1356 | |
1364 | return tmp; |
1357 | return 0; |
1365 | } |
1358 | } |
1366 | |
1359 | |
1367 | /* |
1360 | /* |
1368 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1361 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1369 | * against the target. A full test is not performed, simply a basic test |
1362 | * against the target. A full test is not performed, simply a basic test |
… | |
… | |
1392 | } |
1385 | } |
1393 | } |
1386 | } |
1394 | else if (arrow->type == ARROW && arrow->race == type) |
1387 | else if (arrow->type == ARROW && arrow->race == type) |
1395 | { |
1388 | { |
1396 | /* allways prefer assasination/slaying */ |
1389 | /* allways prefer assasination/slaying */ |
1397 | if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) |
1390 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1398 | { |
1391 | { |
1399 | if (arrow->attacktype & AT_DEATH) |
1392 | if (arrow->attacktype & AT_DEATH) |
1400 | { |
1393 | { |
1401 | *better = 100; |
1394 | *better = 100; |
1402 | return arrow; |
1395 | return arrow; |
… | |
… | |
1430 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1423 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1431 | } |
1424 | } |
1432 | } |
1425 | } |
1433 | } |
1426 | } |
1434 | } |
1427 | } |
|
|
1428 | |
1435 | if (tmp == NULL && arrow == NULL) |
1429 | if (tmp == NULL && arrow == NULL) |
1436 | return find_arrow (op, type); |
1430 | return find_arrow (op, type); |
1437 | |
1431 | |
1438 | *better = betterby; |
1432 | *better = betterby; |
1439 | return tmp; |
1433 | return tmp; |
… | |
… | |
1590 | arrow->destroy (); |
1584 | arrow->destroy (); |
1591 | return 0; |
1585 | return 0; |
1592 | } |
1586 | } |
1593 | |
1587 | |
1594 | left = arrow; /* these are arrows left to the player */ |
1588 | left = arrow; /* these are arrows left to the player */ |
1595 | arrow = get_split_ob (arrow, 1); |
1589 | arrow = arrow->split (); |
1596 | if (!arrow) |
1590 | if (!arrow) |
1597 | { |
1591 | { |
1598 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1592 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1599 | return 0; |
1593 | return 0; |
1600 | } |
1594 | } |
… | |
… | |
1667 | op->play_sound (sound_find ("fire_arrow")); |
1661 | op->play_sound (sound_find ("fire_arrow")); |
1668 | m->insert (arrow, sx, sy, op); |
1662 | m->insert (arrow, sx, sy, op); |
1669 | |
1663 | |
1670 | if (!arrow->destroyed ()) |
1664 | if (!arrow->destroyed ()) |
1671 | move_arrow (arrow); |
1665 | move_arrow (arrow); |
1672 | |
|
|
1673 | if (op->type == PLAYER) |
|
|
1674 | { |
|
|
1675 | if (left->destroyed ()) |
|
|
1676 | esrv_del_item (op->contr, left->count); |
|
|
1677 | else |
|
|
1678 | esrv_send_item (op, left); |
|
|
1679 | } |
|
|
1680 | |
1666 | |
1681 | return 1; |
1667 | return 1; |
1682 | } |
1668 | } |
1683 | |
1669 | |
1684 | /* Special fire code for players - this takes into |
1670 | /* Special fire code for players - this takes into |
… | |
… | |
1758 | return; |
1744 | return; |
1759 | } |
1745 | } |
1760 | } |
1746 | } |
1761 | else if (item->type == ROD || item->type == HORN) |
1747 | else if (item->type == ROD || item->type == HORN) |
1762 | { |
1748 | { |
1763 | 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)) |
1764 | { |
1754 | { |
1765 | op->contr->play_sound (sound_find ("wand_poof")); |
1755 | op->contr->play_sound (sound_find ("wand_poof")); |
1766 | |
1756 | |
1767 | if (item->type == ROD) |
1757 | if (item->type == ROD) |
1768 | 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)); |
… | |
… | |
1787 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1777 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1788 | item->face = item->arch->face; |
1778 | item->face = item->arch->face; |
1789 | item->set_speed (0); |
1779 | item->set_speed (0); |
1790 | } |
1780 | } |
1791 | |
1781 | |
1792 | if ((tmp = item->in_player ())) |
1782 | if (object *pl = item->visible_to ()) |
1793 | esrv_update_item (UPD_ANIM, tmp, item); |
1783 | esrv_update_item (UPD_ANIM, pl, item); |
1794 | } |
1784 | } |
1795 | } |
1785 | } |
1796 | else if (item->type == ROD || item->type == HORN) |
1786 | else if (item->type == ROD || item->type == HORN) |
1797 | drain_rod_charge (item); |
1787 | drain_rod_charge (item); |
1798 | } |
1788 | } |
… | |
… | |
1974 | op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); |
1964 | op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); |
1975 | remove_door2 (door); /* remove door without violence ;-) */ |
1965 | remove_door2 (door); /* remove door without violence ;-) */ |
1976 | } |
1966 | } |
1977 | |
1967 | |
1978 | /* Do this after we print the message */ |
1968 | /* Do this after we print the message */ |
1979 | decrease_ob (key); /* Use up one of the keys */ |
1969 | key->decrease (); /* Use up one of the keys */ |
1980 | /* Need to update the weight the container the key was in */ |
|
|
1981 | if (container != op) |
|
|
1982 | esrv_update_item (UPD_WEIGHT, op, container); |
|
|
1983 | |
1970 | |
1984 | return 1; /* Nothing more to do below */ |
1971 | return 1; /* Nothing more to do below */ |
1985 | } |
1972 | } |
1986 | else if (door->type == LOCKED_DOOR) |
1973 | else if (door->type == LOCKED_DOOR) |
1987 | { |
1974 | { |
… | |
… | |
2168 | bool |
2155 | bool |
2169 | move_player (object *op, int dir) |
2156 | move_player (object *op, int dir) |
2170 | { |
2157 | { |
2171 | int pick; |
2158 | int pick; |
2172 | |
2159 | |
2173 | if (!op->map || op->map->in_memory != MAP_IN_MEMORY) |
2160 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2174 | return 0; |
2161 | return 0; |
2175 | |
2162 | |
2176 | /* Sanity check: make sure dir is valid */ |
2163 | /* Sanity check: make sure dir is valid */ |
2177 | if ((dir < 0) || (dir >= 9)) |
2164 | if ((dir < 0) || (dir >= 9)) |
2178 | { |
2165 | { |
… | |
… | |
2266 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2253 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2267 | { |
2254 | { |
2268 | op->play_sound (sound_find ("ob_evaporate")); |
2255 | op->play_sound (sound_find ("ob_evaporate")); |
2269 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2256 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2270 | |
2257 | |
2271 | if (op->contr) |
|
|
2272 | esrv_del_item (op->contr, tmp->count); |
|
|
2273 | |
|
|
2274 | tmp->destroy (); |
2258 | tmp->destroy (); |
2275 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2259 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2276 | |
2260 | |
2277 | if (op->stats.hp < 0) |
2261 | if (op->stats.hp < 0) |
2278 | op->stats.hp = op->stats.maxhp; |
2262 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
2290 | return 0; |
2274 | return 0; |
2291 | } |
2275 | } |
2292 | |
2276 | |
2293 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2277 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2294 | * back in the map (location and map determined by values of env). This |
2278 | * back in the map (location and map determined by values of env). This |
2295 | * function will descend into containers. op is the object to start the search |
2279 | * function will descend into containers. op is the object to start the search |
2296 | * from. |
2280 | * from. |
2297 | */ |
2281 | */ |
2298 | static void |
2282 | static void |
2299 | drop_unpaid_items (object *op, object *env) |
2283 | drop_unpaid_items (object *op, object *env) |
2300 | { |
2284 | { |
2301 | while (op) |
2285 | while (op) |
2302 | { |
2286 | { |
2303 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2287 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2304 | |
2288 | |
2305 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2289 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2306 | { |
|
|
2307 | if (env->type == PLAYER) |
|
|
2308 | esrv_del_item (env->contr, op->count); |
|
|
2309 | |
|
|
2310 | op->insert_at (env); |
2290 | op->insert_at (env); |
2311 | } |
|
|
2312 | else if (op->inv) |
2291 | else if (op->inv) |
2313 | drop_unpaid_items (op->inv, env); |
2292 | drop_unpaid_items (op->inv, env); |
2314 | |
2293 | |
2315 | op = next; |
2294 | op = next; |
2316 | } |
2295 | } |
… | |
… | |
2328 | * Moved from apply.c to player.c - player.c is what |
2307 | * Moved from apply.c to player.c - player.c is what |
2329 | * actually uses this function. player.c may not be quite the |
2308 | * actually uses this function. player.c may not be quite the |
2330 | * best, a misc file for object actions is probably better, |
2309 | * best, a misc file for object actions is probably better, |
2331 | * but there isn't one in the server directory. |
2310 | * but there isn't one in the server directory. |
2332 | */ |
2311 | */ |
2333 | char * |
2312 | const char * |
2334 | gravestone_text (object *op) |
2313 | gravestone_text (object *op) |
2335 | { |
2314 | { |
2336 | static char buf2[MAX_BUF]; |
2315 | static dynbuf_text buf; |
2337 | char buf[MAX_BUF]; |
|
|
2338 | time_t now = time (NULL); |
|
|
2339 | |
2316 | |
2340 | strcpy (buf2, " R.I.P.\n\n"); |
2317 | buf << "---- R.I.P. ----\n\n"; |
|
|
2318 | op->name; |
|
|
2319 | |
2341 | if (op->type == PLAYER) |
2320 | if (op->type == PLAYER) |
2342 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2321 | buf << " the " << op->contr->title; |
2343 | else |
|
|
2344 | sprintf (buf, "%s\n", &op->name); |
|
|
2345 | |
2322 | |
2346 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2323 | buf << "\n\n"; |
2347 | 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 | |
2348 | if (op->type == PLAYER) |
2329 | if (op->type == PLAYER) |
2349 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2330 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
2350 | else |
|
|
2351 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2352 | |
2331 | |
2353 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
|
|
2354 | strcat (buf2, buf); |
|
|
2355 | if (op->type == PLAYER) |
|
|
2356 | { |
2332 | { |
2357 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2333 | static char buf2[128]; |
2358 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2334 | time_t now = time (NULL); |
2359 | strcat (buf2, buf); |
|
|
2360 | } |
|
|
2361 | |
|
|
2362 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2335 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
2363 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2336 | buf << buf2; |
2364 | strcat (buf2, buf); |
2337 | } |
2365 | |
2338 | |
2366 | return buf2; |
2339 | return buf; |
2367 | } |
2340 | } |
2368 | |
2341 | |
2369 | void |
2342 | void |
2370 | do_some_living (object *op) |
2343 | do_some_living (object *op) |
2371 | { |
2344 | { |
… | |
… | |
2552 | op->stats.food--; |
2525 | op->stats.food--; |
2553 | } |
2526 | } |
2554 | |
2527 | |
2555 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2528 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2556 | { |
2529 | { |
2557 | object *tmp, *flesh = 0; |
2530 | object *flesh = 0; |
2558 | |
2531 | |
2559 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2532 | for_inv_removable (op, tmp) |
2560 | { |
2533 | { |
2561 | 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) |
2562 | { |
2538 | { |
2563 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2539 | op->statusmsg ("You blindly grab for a bite of food. " |
2564 | { |
2540 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2565 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
|
|
2566 | manual_apply (op, tmp, 0); |
2541 | manual_apply (op, tmp, 0); |
|
|
2542 | |
2567 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2543 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2568 | break; |
2544 | break; |
2569 | } |
2545 | } |
2570 | else if (tmp->type == FLESH) |
2546 | else if (tmp->type == FLESH) |
2571 | flesh = tmp; |
2547 | flesh = tmp; |
2572 | } /* End if paid for object */ |
2548 | } |
2573 | } /* end of for loop */ |
|
|
2574 | |
2549 | |
2575 | /* 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 |
2576 | * eat flesh instead. |
2551 | * eat flesh instead. |
2577 | */ |
2552 | */ |
2578 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2553 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2579 | { |
2554 | { |
2580 | 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.>"); |
2581 | manual_apply (op, flesh, 0); |
2557 | manual_apply (op, flesh, 0); |
2582 | } |
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.>"); |
2583 | } |
2564 | } |
2584 | |
2565 | |
2585 | if (op->stats.food < 0) |
2566 | if (op->stats.food < 0) |
2586 | { |
2567 | { |
2587 | op->stats.hp += op->stats.food; |
2568 | op->stats.hp += op->stats.food; |
2588 | 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 (); |
2589 | } |
2575 | } |
|
|
2576 | } |
2590 | |
2577 | |
|
|
2578 | /* killer should be set here already */ |
2591 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2579 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2592 | kill_player (op); |
2580 | kill_player (op); |
2593 | } |
2581 | } |
2594 | } |
2582 | } |
2595 | |
2583 | |
… | |
… | |
2645 | { |
2633 | { |
2646 | tmp->name = format ("%s's finger" , &op->name); |
2634 | tmp->name = format ("%s's finger" , &op->name); |
2647 | tmp->name_pl = format ("%s's fingers", &op->name); |
2635 | tmp->name_pl = format ("%s's fingers", &op->name); |
2648 | tmp->msg = format ( |
2636 | tmp->msg = format ( |
2649 | "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", |
2650 | &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 () |
2651 | ); |
2641 | ); |
2652 | tmp->value = 0, tmp->type = 0; |
2642 | tmp->value = 0, tmp->type = 0; |
2653 | tmp->materialname = "organics"; |
2643 | tmp->materialname = "organics"; |
2654 | tmp->insert_at (op, tmp); |
2644 | tmp->insert_at (op, tmp); |
2655 | } |
2645 | } |
… | |
… | |
2661 | } |
2651 | } |
2662 | |
2652 | |
2663 | INVOKE_PLAYER (DEATH, op->contr); |
2653 | INVOKE_PLAYER (DEATH, op->contr); |
2664 | |
2654 | |
2665 | command_kill_pets (op, 0); |
2655 | command_kill_pets (op, 0); |
2666 | |
|
|
2667 | if (op->stats.food < 0) |
|
|
2668 | strcpy (op->contr->killer, "starvation"); |
|
|
2669 | |
2656 | |
2670 | op->contr->play_sound (sound_find ("player_dies")); |
2657 | op->contr->play_sound (sound_find ("player_dies")); |
2671 | |
2658 | |
2672 | /* save the map location for corpse, gravestone */ |
2659 | /* save the map location for corpse, gravestone */ |
2673 | x = op->x; |
2660 | x = op->x; |
… | |
… | |
2782 | lost_a_stat = 1; |
2769 | lost_a_stat = 1; |
2783 | } |
2770 | } |
2784 | } |
2771 | } |
2785 | } |
2772 | } |
2786 | } |
2773 | } |
|
|
2774 | |
2787 | /* If no stat lost, tell the player. */ |
2775 | /* If no stat lost, tell the player. */ |
2788 | if (!lost_a_stat) |
2776 | if (!lost_a_stat) |
2789 | { |
2777 | { |
2790 | /* determine_god() seems to not work sometimes... why is this? |
2778 | /* determine_god() seems to not work sometimes... why is this? |
2791 | Should I be using something else? GD */ |
2779 | Should I be using something else? GD */ |
… | |
… | |
2795 | 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); |
2796 | else |
2784 | else |
2797 | 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."); |
2798 | } |
2786 | } |
2799 | #else |
2787 | #else |
2800 | 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."); |
2801 | #endif |
2789 | #endif |
2802 | |
2790 | |
2803 | /* Put a gravestone up where the character 'almost' died. List the |
2791 | /* Put a gravestone up where the character 'almost' died. List the |
2804 | * exp loss on the stone. |
2792 | * exp loss on the stone. |
2805 | */ |
2793 | */ |
2806 | tmp = arch_to_object (archetype::find ("gravestone")); |
2794 | tmp = arch_to_object (archetype::find ("gravestone")); |
2807 | sprintf (buf, "%s's gravestone", &op->name); |
2795 | tmp->name = format ("%s's gravestone", &op->name); |
2808 | tmp->name = buf; |
2796 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2809 | sprintf (buf, "%s's gravestones", &op->name); |
|
|
2810 | tmp->name_pl = buf; |
|
|
2811 | 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); |
2797 | tmp->msg = format ("RIP\nHere rests the hero %s the %s,\nwho was killed\nby %s.\n", &op->name, op->contr->title, op->contr->killer_name ()); |
2812 | tmp->msg = buf; |
|
|
2813 | tmp->x = op->x, tmp->y = op->y; |
2798 | tmp->x = op->x, tmp->y = op->y; |
2814 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2799 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2815 | |
2800 | |
2816 | /**************************************/ |
2801 | /**************************************/ |
2817 | /* */ |
2802 | /* */ |
… | |
… | |
2840 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2825 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2841 | } |
2826 | } |
2842 | |
2827 | |
2843 | cure_disease (op, 0, 0); /* remove any disease */ |
2828 | cure_disease (op, 0, 0); /* remove any disease */ |
2844 | |
2829 | |
|
|
2830 | // remove all spell effects that are active |
|
|
2831 | // to avoid long-term effects such as word-of-recall |
|
|
2832 | for (object *item = op->inv; item; ) |
|
|
2833 | { |
|
|
2834 | object *next = item->below; |
|
|
2835 | |
|
|
2836 | if (item->type == SPELL_EFFECT && item->active) |
|
|
2837 | item->destroy (); |
|
|
2838 | |
|
|
2839 | item = next; |
|
|
2840 | } |
|
|
2841 | |
2845 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2842 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2846 | apply_death_exp_penalty (op); |
2843 | apply_death_exp_penalty (op); |
|
|
2844 | |
2847 | if (op->stats.food < 100) |
2845 | if (op->stats.food < 100) |
2848 | op->stats.food = 900; |
2846 | op->stats.food = 900; |
|
|
2847 | |
2849 | op->stats.hp = op->stats.maxhp; |
2848 | op->stats.hp = op->stats.maxhp; |
2850 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2849 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2851 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2850 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2852 | |
2851 | |
2853 | /* |
2852 | /* |
… | |
… | |
2921 | |
2920 | |
2922 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2921 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2923 | { |
2922 | { |
2924 | if (tmp->nrof > 1) |
2923 | if (tmp->nrof > 1) |
2925 | { |
2924 | { |
2926 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2925 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2927 | tmp2->destroy (); |
|
|
2928 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2926 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2929 | } |
2927 | } |
2930 | else |
2928 | else |
2931 | tmp->destroy (); |
2929 | tmp->destroy (); |
2932 | } |
2930 | } |
… | |
… | |
2943 | void |
2941 | void |
2944 | fix_weight (void) |
2942 | fix_weight (void) |
2945 | { |
2943 | { |
2946 | for_all_players (pl) |
2944 | for_all_players (pl) |
2947 | { |
2945 | { |
2948 | int old = pl->ob->carrying, sum = sum_weight (pl->ob); |
2946 | sint32 old = pl->ob->carrying; |
2949 | |
2947 | |
2950 | if (old == sum) |
2948 | pl->ob->update_weight (); |
2951 | continue; |
2949 | |
|
|
2950 | if (old != pl->ob->carrying) |
|
|
2951 | { |
2952 | pl->ob->update_stats (); |
2952 | pl->ob->update_stats (); |
2953 | LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, old, sum); |
2953 | LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, (int)old, (int)pl->ob->carrying); |
|
|
2954 | } |
2954 | } |
2955 | } |
2955 | } |
2956 | } |
2956 | |
2957 | |
2957 | void |
2958 | void |
2958 | fix_luck (void) |
2959 | fix_luck (void) |
… | |
… | |
3044 | * as bad as carrying a light on a pitch dark map */ |
3045 | * as bad as carrying a light on a pitch dark map */ |
3045 | if (has_carried_lights (ob)) |
3046 | if (has_carried_lights (ob)) |
3046 | level = -(10 + (2 * ob->map->darkness)); |
3047 | level = -(10 + (2 * ob->map->darkness)); |
3047 | |
3048 | |
3048 | /* scan through all nearby squares for terrain to hide in */ |
3049 | /* scan through all nearby squares for terrain to hide in */ |
3049 | for (i = 0, x = ob->x, y = ob->y; i < 9; i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
3050 | for (i = 0, x = ob->x, y = ob->y; |
|
|
3051 | i <= SIZEOFFREE1; |
|
|
3052 | i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
3050 | { |
3053 | { |
3051 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3054 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3052 | if (mflag & P_OUT_OF_MAP) |
3055 | if (mflag & P_OUT_OF_MAP) |
3053 | { |
|
|
3054 | continue; |
3056 | continue; |
3055 | } |
3057 | |
3056 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3058 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3057 | level += 2; |
3059 | level += 2; |
3058 | else /* open terrain! */ |
3060 | else /* open terrain! */ |
3059 | level -= 1; |
3061 | level -= 1; |
3060 | } |
3062 | } |
… | |
… | |
3071 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3073 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3072 | */ |
3074 | */ |
3073 | void |
3075 | void |
3074 | do_hidden_move (object *op) |
3076 | do_hidden_move (object *op) |
3075 | { |
3077 | { |
3076 | int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); |
3078 | int hide = 0; |
3077 | object *skop; |
|
|
3078 | |
3079 | |
3079 | if (!op || !op->map) |
3080 | if (!op || !op->map) |
3080 | return; |
3081 | return; |
3081 | |
3082 | |
3082 | 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); |
3083 | |
3085 | |
3084 | /* 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! */ |
3085 | if (op->type == PLAYER && op->contr->run_on) |
3087 | if (op->type == PLAYER && op->contr->run_on) |
3086 | if (!skop || num >= skop->level) |
3088 | if (!skop || num >= skop->level) |
3087 | { |
3089 | { |
… | |
… | |
3097 | num -= hide; |
3099 | num -= hide; |
3098 | |
3100 | |
3099 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3101 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3100 | { |
3102 | { |
3101 | make_visible (op); |
3103 | make_visible (op); |
|
|
3104 | |
3102 | if (op->type == PLAYER) |
3105 | if (op->type == PLAYER) |
3103 | 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!"); |
3104 | } |
3107 | } |
3105 | else if (op->type == PLAYER && skop) |
3108 | else if (op->type == PLAYER && skop) |
3106 | 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); |
… | |
… | |
3447 | else |
3450 | else |
3448 | { |
3451 | { |
3449 | /* generate misc. treasure */ |
3452 | /* generate misc. treasure */ |
3450 | tmp = arch_to_object (tr->item); |
3453 | tmp = arch_to_object (tr->item); |
3451 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3454 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3452 | tmp = insert_ob_in_ob (tmp, who); |
3455 | who->insert (tmp); |
3453 | if (who->type == PLAYER) |
|
|
3454 | esrv_send_item (who, tmp); |
|
|
3455 | } |
3456 | } |
3456 | } |
3457 | } |
3457 | |
3458 | |
3458 | /** |
3459 | /** |
3459 | * Unready an object for a player. This function does nothing if the object was |
3460 | * Unready an object for a player. This function does nothing if the object was |