… | |
… | |
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 | |
… | |
… | |
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) |
… | |
… | |
1599 | } |
1578 | } |
1600 | |
1579 | |
1601 | /* this should not happen, but sometimes does */ |
1580 | /* this should not happen, but sometimes does */ |
1602 | if (arrow->nrof == 0) |
1581 | if (arrow->nrof == 0) |
1603 | { |
1582 | { |
|
|
1583 | LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ()); |
1604 | arrow->destroy (); |
1584 | arrow->destroy (); |
1605 | return 0; |
1585 | return 0; |
1606 | } |
1586 | } |
1607 | |
1587 | |
1608 | left = arrow; /* these are arrows left to the player */ |
1588 | left = arrow; /* these are arrows left to the player */ |
… | |
… | |
1813 | bool |
1793 | bool |
1814 | fire (object *op, int dir) |
1794 | fire (object *op, int dir) |
1815 | { |
1795 | { |
1816 | int spellcost = 0; |
1796 | int spellcost = 0; |
1817 | |
1797 | |
1818 | /* check for loss of invisiblity/hide */ |
|
|
1819 | if (action_makes_visible (op)) |
|
|
1820 | make_visible (op); |
|
|
1821 | |
|
|
1822 | player *pl = op->contr; |
1798 | player *pl = op->contr; |
1823 | |
1799 | |
1824 | if (pl->golem) |
1800 | if (pl->golem) |
1825 | { |
1801 | { |
1826 | control_golem (op->contr->golem, dir); |
1802 | control_golem (op->contr->golem, dir); |
… | |
… | |
1828 | } |
1804 | } |
1829 | |
1805 | |
1830 | object *ob = pl->ranged_ob; |
1806 | object *ob = pl->ranged_ob; |
1831 | |
1807 | |
1832 | if (!ob) |
1808 | if (!ob) |
1833 | return false; |
|
|
1834 | |
|
|
1835 | if (!op->change_weapon (ob)) |
|
|
1836 | return false; |
1809 | return false; |
1837 | |
1810 | |
1838 | if (op->speed_left > 0.f) |
1811 | if (op->speed_left > 0.f) |
1839 | --op->speed_left; |
1812 | --op->speed_left; |
1840 | else |
1813 | else |
1841 | 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); |
1842 | |
1822 | |
1843 | switch (ob->type) |
1823 | switch (ob->type) |
1844 | { |
1824 | { |
1845 | case BOW: |
1825 | case BOW: |
1846 | player_fire_bow (op, dir); |
1826 | player_fire_bow (op, dir); |
… | |
… | |
2091 | --op->speed_left; |
2071 | --op->speed_left; |
2092 | |
2072 | |
2093 | op->play_sound (sound_find ("push_player")); |
2073 | op->play_sound (sound_find ("push_player")); |
2094 | push_ob (mon, dir, op); |
2074 | push_ob (mon, dir, op); |
2095 | |
2075 | |
2096 | if (op->contr->tmp_invis || op->hide) |
2076 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2097 | make_visible (op); |
2077 | make_visible (op); |
2098 | |
2078 | |
2099 | return true; |
2079 | return true; |
2100 | } |
2080 | } |
2101 | else |
2081 | else |
… | |
… | |
2123 | push_ob (mon, dir, op); |
2103 | push_ob (mon, dir, op); |
2124 | } |
2104 | } |
2125 | else |
2105 | else |
2126 | op->statusmsg ("You withhold your attack"); |
2106 | op->statusmsg ("You withhold your attack"); |
2127 | |
2107 | |
2128 | if (op->contr->tmp_invis || op->hide) |
2108 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2129 | make_visible (op); |
2109 | make_visible (op); |
2130 | |
2110 | |
2131 | return true; |
2111 | return true; |
2132 | } |
2112 | } |
2133 | } |
2113 | } |
… | |
… | |
2191 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2171 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2192 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2172 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2193 | |
2173 | |
2194 | op->facing = dir; |
2174 | op->facing = dir; |
2195 | |
2175 | |
2196 | if (op->hide) |
2176 | if (op->flag [FLAG_HIDDEN]) |
2197 | do_hidden_move (op); |
2177 | do_hidden_move (op); |
2198 | |
2178 | |
2199 | bool retval; |
2179 | bool retval; |
2200 | |
2180 | |
2201 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2181 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
… | |
… | |
2332 | const char * |
2312 | const char * |
2333 | gravestone_text (object *op) |
2313 | gravestone_text (object *op) |
2334 | { |
2314 | { |
2335 | static dynbuf_text buf; |
2315 | static dynbuf_text buf; |
2336 | |
2316 | |
2337 | buf << "---- R.I.P. ----\n\n"; |
2317 | buf << "---- R.I.P. ----\n\n" |
2338 | op->name; |
2318 | << op->name; |
2339 | |
2319 | |
2340 | if (op->type == PLAYER) |
2320 | if (op->type == PLAYER) |
2341 | buf << " the " << op->contr->title; |
2321 | buf << " the " << op->contr->title; |
2342 | |
2322 | |
2343 | buf << "\n\n"; |
2323 | buf << "\n\n"; |
… | |
… | |
2585 | |
2565 | |
2586 | if (op->stats.food < 0) |
2566 | if (op->stats.food < 0) |
2587 | { |
2567 | { |
2588 | op->stats.hp += op->stats.food; |
2568 | op->stats.hp += op->stats.food; |
2589 | 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 (); |
2590 | } |
2575 | } |
|
|
2576 | } |
2591 | |
2577 | |
|
|
2578 | /* killer should be set here already */ |
2592 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2579 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2593 | kill_player (op); |
2580 | kill_player (op); |
2594 | } |
2581 | } |
2595 | } |
2582 | } |
2596 | |
2583 | |
… | |
… | |
2664 | } |
2651 | } |
2665 | |
2652 | |
2666 | INVOKE_PLAYER (DEATH, op->contr); |
2653 | INVOKE_PLAYER (DEATH, op->contr); |
2667 | |
2654 | |
2668 | command_kill_pets (op, 0); |
2655 | command_kill_pets (op, 0); |
2669 | |
|
|
2670 | if (op->stats.food < 0) |
|
|
2671 | { |
|
|
2672 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2673 | op->contr->killer->destroy (); |
|
|
2674 | } |
|
|
2675 | |
2656 | |
2676 | op->contr->play_sound (sound_find ("player_dies")); |
2657 | op->contr->play_sound (sound_find ("player_dies")); |
2677 | |
2658 | |
2678 | /* save the map location for corpse, gravestone */ |
2659 | /* save the map location for corpse, gravestone */ |
2679 | x = op->x; |
2660 | x = op->x; |
… | |
… | |
2811 | * exp loss on the stone. |
2792 | * exp loss on the stone. |
2812 | */ |
2793 | */ |
2813 | tmp = arch_to_object (archetype::find ("gravestone")); |
2794 | tmp = arch_to_object (archetype::find ("gravestone")); |
2814 | tmp->name = format ("%s's gravestone", &op->name); |
2795 | tmp->name = format ("%s's gravestone", &op->name); |
2815 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2796 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2816 | 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 ()); |
2797 | tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", |
|
|
2798 | &op->name, op->contr->title, op->contr->killer_name ()); |
2817 | tmp->x = op->x, tmp->y = op->y; |
2799 | tmp->x = op->x, tmp->y = op->y; |
2818 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2800 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2819 | |
2801 | |
2820 | /**************************************/ |
2802 | /**************************************/ |
2821 | /* */ |
2803 | /* */ |
… | |
… | |
2909 | if (will_kill_again & (1 << at)) |
2891 | if (will_kill_again & (1 << at)) |
2910 | force->resist[at] = 100; |
2892 | force->resist[at] = 100; |
2911 | |
2893 | |
2912 | insert_ob_in_ob (force, op); |
2894 | insert_ob_in_ob (force, op); |
2913 | op->update_stats (); |
2895 | op->update_stats (); |
2914 | |
|
|
2915 | } |
2896 | } |
2916 | |
2897 | |
2917 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
2898 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
2918 | } |
2899 | } |
2919 | |
2900 | |
… | |
… | |
3020 | } |
3001 | } |
3021 | |
3002 | |
3022 | void |
3003 | void |
3023 | make_visible (object *op) |
3004 | make_visible (object *op) |
3024 | { |
3005 | { |
3025 | op->hide = 0; |
3006 | op->flag [FLAG_HIDDEN] = 0; |
3026 | op->invisible = 0; |
3007 | op->invisible = 0; |
3027 | |
3008 | |
3028 | if (op->type == PLAYER) |
3009 | if (op->type == PLAYER) |
3029 | { |
3010 | { |
3030 | op->contr->tmp_invis = 0; |
3011 | op->contr->tmp_invis = 0; |
… | |
… | |
3251 | |
3232 | |
3252 | if (op->contr && op->contr->tmp_invis == 0) |
3233 | if (op->contr && op->contr->tmp_invis == 0) |
3253 | return 0; |
3234 | return 0; |
3254 | |
3235 | |
3255 | /* If monsters, they should become visible */ |
3236 | /* If monsters, they should become visible */ |
3256 | 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)) |
3257 | { |
3238 | { |
3258 | 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"); |
3259 | return 1; |
3240 | return 1; |
3260 | } |
3241 | } |
3261 | } |
3242 | } |
3262 | |
3243 | |
3263 | return 0; |
3244 | return 0; |