… | |
… | |
366 | attachable::do_destroy (); |
366 | attachable::do_destroy (); |
367 | |
367 | |
368 | if (ob) |
368 | if (ob) |
369 | { |
369 | { |
370 | ob->destroy_inv (false); |
370 | ob->destroy_inv (false); |
371 | ob->destroy (true); |
371 | ob->destroy (); |
372 | } |
372 | } |
373 | |
373 | |
374 | ob = observe = 0; |
374 | ob = observe = 0; |
375 | } |
375 | } |
376 | |
376 | |
… | |
… | |
668 | || op->type == CLOAK || op->type == HELMET |
668 | || op->type == CLOAK || op->type == HELMET |
669 | || op->type == SHIELD || op->type == GLOVES |
669 | || op->type == SHIELD || op->type == GLOVES |
670 | || op->type == BRACERS || op->type == GIRDLE)) |
670 | || op->type == BRACERS || op->type == GIRDLE)) |
671 | || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
671 | || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
672 | { |
672 | { |
673 | op->destroy (true); |
673 | op->destroy (); |
674 | continue; |
674 | continue; |
675 | } |
675 | } |
676 | } |
676 | } |
677 | |
677 | |
678 | /* This really needs to be better - we should really give |
678 | /* This really needs to be better - we should really give |
… | |
… | |
689 | if (tmp->type == op->type && tmp->name == op->name) |
689 | if (tmp->type == op->type && tmp->name == op->name) |
690 | break; |
690 | break; |
691 | |
691 | |
692 | if (tmp) |
692 | if (tmp) |
693 | { |
693 | { |
694 | op->destroy (true); |
694 | op->destroy (); |
695 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
695 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
696 | continue; |
696 | continue; |
697 | } |
697 | } |
698 | |
698 | |
699 | if (op->nrof > 1) |
699 | if (op->nrof > 1) |
… | |
… | |
714 | CLEAR_FLAG (op, FLAG_DAMNED); |
714 | CLEAR_FLAG (op, FLAG_DAMNED); |
715 | } |
715 | } |
716 | |
716 | |
717 | if (op->type == SPELL) |
717 | if (op->type == SPELL) |
718 | { |
718 | { |
719 | op->destroy (true); |
719 | op->destroy (); |
720 | continue; |
720 | continue; |
721 | } |
721 | } |
722 | else if (op->type == SKILL) |
722 | else if (op->type == SKILL) |
723 | { |
723 | { |
724 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
724 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
… | |
… | |
1579 | |
1579 | |
1580 | /* this should not happen, but sometimes does */ |
1580 | /* this should not happen, but sometimes does */ |
1581 | if (arrow->nrof == 0) |
1581 | if (arrow->nrof == 0) |
1582 | { |
1582 | { |
1583 | LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ()); |
1583 | LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ()); |
1584 | arrow->destroy (true); |
1584 | arrow->destroy (); |
1585 | return 0; |
1585 | return 0; |
1586 | } |
1586 | } |
1587 | |
1587 | |
1588 | left = arrow; /* these are arrows left to the player */ |
1588 | left = arrow; /* these are arrows left to the player */ |
1589 | arrow = arrow->split (); |
1589 | arrow = arrow->split (); |
… | |
… | |
1793 | bool |
1793 | bool |
1794 | fire (object *op, int dir) |
1794 | fire (object *op, int dir) |
1795 | { |
1795 | { |
1796 | int spellcost = 0; |
1796 | int spellcost = 0; |
1797 | |
1797 | |
1798 | /* check for loss of invisiblity/hide */ |
|
|
1799 | if (action_makes_visible (op)) |
|
|
1800 | make_visible (op); |
|
|
1801 | |
|
|
1802 | player *pl = op->contr; |
1798 | player *pl = op->contr; |
1803 | |
1799 | |
1804 | if (pl->golem) |
1800 | if (pl->golem) |
1805 | { |
1801 | { |
1806 | control_golem (op->contr->golem, dir); |
1802 | control_golem (op->contr->golem, dir); |
… | |
… | |
1808 | } |
1804 | } |
1809 | |
1805 | |
1810 | object *ob = pl->ranged_ob; |
1806 | object *ob = pl->ranged_ob; |
1811 | |
1807 | |
1812 | if (!ob) |
1808 | if (!ob) |
1813 | return false; |
|
|
1814 | |
|
|
1815 | if (!op->change_weapon (ob)) |
|
|
1816 | return false; |
1809 | return false; |
1817 | |
1810 | |
1818 | if (op->speed_left > 0.f) |
1811 | if (op->speed_left > 0.f) |
1819 | --op->speed_left; |
1812 | --op->speed_left; |
1820 | else |
1813 | else |
1821 | 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); |
1822 | |
1822 | |
1823 | switch (ob->type) |
1823 | switch (ob->type) |
1824 | { |
1824 | { |
1825 | case BOW: |
1825 | case BOW: |
1826 | player_fire_bow (op, dir); |
1826 | player_fire_bow (op, dir); |
… | |
… | |
2071 | --op->speed_left; |
2071 | --op->speed_left; |
2072 | |
2072 | |
2073 | op->play_sound (sound_find ("push_player")); |
2073 | op->play_sound (sound_find ("push_player")); |
2074 | push_ob (mon, dir, op); |
2074 | push_ob (mon, dir, op); |
2075 | |
2075 | |
2076 | if (op->contr->tmp_invis || op->hide) |
2076 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2077 | make_visible (op); |
2077 | make_visible (op); |
2078 | |
2078 | |
2079 | return true; |
2079 | return true; |
2080 | } |
2080 | } |
2081 | else |
2081 | else |
… | |
… | |
2103 | push_ob (mon, dir, op); |
2103 | push_ob (mon, dir, op); |
2104 | } |
2104 | } |
2105 | else |
2105 | else |
2106 | op->statusmsg ("You withhold your attack"); |
2106 | op->statusmsg ("You withhold your attack"); |
2107 | |
2107 | |
2108 | if (op->contr->tmp_invis || op->hide) |
2108 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2109 | make_visible (op); |
2109 | make_visible (op); |
2110 | |
2110 | |
2111 | return true; |
2111 | return true; |
2112 | } |
2112 | } |
2113 | } |
2113 | } |
… | |
… | |
2171 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2171 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2172 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2172 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2173 | |
2173 | |
2174 | op->facing = dir; |
2174 | op->facing = dir; |
2175 | |
2175 | |
2176 | if (op->hide) |
2176 | if (op->flag [FLAG_HIDDEN]) |
2177 | do_hidden_move (op); |
2177 | do_hidden_move (op); |
2178 | |
2178 | |
2179 | bool retval; |
2179 | bool retval; |
2180 | |
2180 | |
2181 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2181 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
… | |
… | |
2253 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2253 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2254 | { |
2254 | { |
2255 | op->play_sound (sound_find ("ob_evaporate")); |
2255 | op->play_sound (sound_find ("ob_evaporate")); |
2256 | 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)); |
2257 | |
2257 | |
2258 | tmp->destroy (true); |
2258 | tmp->destroy (); |
2259 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2259 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2260 | |
2260 | |
2261 | if (op->stats.hp < 0) |
2261 | if (op->stats.hp < 0) |
2262 | op->stats.hp = op->stats.maxhp; |
2262 | op->stats.hp = op->stats.maxhp; |
2263 | |
2263 | |
… | |
… | |
2569 | op->stats.food = 0; |
2569 | op->stats.food = 0; |
2570 | |
2570 | |
2571 | if (op->stats.hp < 0) |
2571 | if (op->stats.hp < 0) |
2572 | { |
2572 | { |
2573 | op->contr->killer = archetype::get ("killer_starvation"); |
2573 | op->contr->killer = archetype::get ("killer_starvation"); |
2574 | op->contr->killer->destroy (true); |
2574 | op->contr->killer->destroy (); |
2575 | } |
2575 | } |
2576 | } |
2576 | } |
2577 | |
2577 | |
2578 | /* killer should be set here already */ |
2578 | /* killer should be set here already */ |
2579 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2579 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
… | |
… | |
2610 | |
2610 | |
2611 | /* restore player */ |
2611 | /* restore player */ |
2612 | at = archetype::find ("poisoning"); |
2612 | at = archetype::find ("poisoning"); |
2613 | if (object *tmp = present_arch_in_ob (at, op)) |
2613 | if (object *tmp = present_arch_in_ob (at, op)) |
2614 | { |
2614 | { |
2615 | tmp->destroy (true); |
2615 | tmp->destroy (); |
2616 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2616 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2617 | } |
2617 | } |
2618 | |
2618 | |
2619 | at = archetype::find ("confusion"); |
2619 | at = archetype::find ("confusion"); |
2620 | if (object *tmp = present_arch_in_ob (at, op)) |
2620 | if (object *tmp = present_arch_in_ob (at, op)) |
2621 | { |
2621 | { |
2622 | tmp->destroy (true); |
2622 | tmp->destroy (); |
2623 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2623 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2624 | } |
2624 | } |
2625 | |
2625 | |
2626 | cure_disease (op, 0, 0); /* remove any disease */ |
2626 | cure_disease (op, 0, 0); /* remove any disease */ |
2627 | op->stats.hp = op->stats.maxhp; |
2627 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
2812 | at = archetype::find ("poisoning"); |
2812 | at = archetype::find ("poisoning"); |
2813 | tmp = present_arch_in_ob (at, op); |
2813 | tmp = present_arch_in_ob (at, op); |
2814 | |
2814 | |
2815 | if (tmp) |
2815 | if (tmp) |
2816 | { |
2816 | { |
2817 | tmp->destroy (true); |
2817 | tmp->destroy (); |
2818 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2818 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2819 | } |
2819 | } |
2820 | |
2820 | |
2821 | at = archetype::find ("confusion"); |
2821 | at = archetype::find ("confusion"); |
2822 | tmp = present_arch_in_ob (at, op); |
2822 | tmp = present_arch_in_ob (at, op); |
2823 | if (tmp) |
2823 | if (tmp) |
2824 | { |
2824 | { |
2825 | tmp->destroy (true); |
2825 | tmp->destroy (); |
2826 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2826 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2827 | } |
2827 | } |
2828 | |
2828 | |
2829 | cure_disease (op, 0, 0); /* remove any disease */ |
2829 | cure_disease (op, 0, 0); /* remove any disease */ |
2830 | |
2830 | |
… | |
… | |
2833 | for (object *item = op->inv; item; ) |
2833 | for (object *item = op->inv; item; ) |
2834 | { |
2834 | { |
2835 | object *next = item->below; |
2835 | object *next = item->below; |
2836 | |
2836 | |
2837 | if (item->type == SPELL_EFFECT && item->active) |
2837 | if (item->type == SPELL_EFFECT && item->active) |
2838 | item->destroy (true); |
2838 | item->destroy (); |
2839 | |
2839 | |
2840 | item = next; |
2840 | item = next; |
2841 | } |
2841 | } |
2842 | |
2842 | |
2843 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2843 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
… | |
… | |
2924 | { |
2924 | { |
2925 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2925 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2926 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2926 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2927 | } |
2927 | } |
2928 | else |
2928 | else |
2929 | tmp->destroy (true); |
2929 | tmp->destroy (); |
2930 | } |
2930 | } |
2931 | else |
2931 | else |
2932 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2932 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2933 | } |
2933 | } |
2934 | } |
2934 | } |
… | |
… | |
2995 | if (op->type == PLAYER) |
2995 | if (op->type == PLAYER) |
2996 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
2996 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
2997 | |
2997 | |
2998 | cast_spell (op, throw_ob, dir, spob, NULL); |
2998 | cast_spell (op, throw_ob, dir, spob, NULL); |
2999 | |
2999 | |
3000 | throw_ob->destroy (true); |
3000 | throw_ob->destroy (); |
3001 | } |
3001 | } |
3002 | |
3002 | |
3003 | void |
3003 | void |
3004 | make_visible (object *op) |
3004 | make_visible (object *op) |
3005 | { |
3005 | { |
3006 | op->hide = 0; |
3006 | op->flag [FLAG_HIDDEN] = 0; |
3007 | op->invisible = 0; |
3007 | op->invisible = 0; |
3008 | |
3008 | |
3009 | if (op->type == PLAYER) |
3009 | if (op->type == PLAYER) |
3010 | { |
3010 | { |
3011 | op->contr->tmp_invis = 0; |
3011 | op->contr->tmp_invis = 0; |
… | |
… | |
3203 | |
3203 | |
3204 | /* only the viewable area the player sees is updated by LOS |
3204 | /* only the viewable area the player sees is updated by LOS |
3205 | * code, so we need to restrict ourselves to that range of values |
3205 | * code, so we need to restrict ourselves to that range of values |
3206 | * for any meaningful values. |
3206 | * for any meaningful values. |
3207 | */ |
3207 | */ |
3208 | if (abs (dx) <= (pl->contr->ns->mapx / 2) && |
3208 | if (pl->contr->blocked_los (dx, dy) != LOS_BLOCKED) |
3209 | abs (dy) <= (pl->contr->ns->mapy / 2) && |
|
|
3210 | !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)]) |
|
|
3211 | return 1; |
3209 | return 1; |
3212 | |
3210 | |
3213 | op = op->more; |
3211 | op = op->more; |
3214 | } |
3212 | } |
3215 | |
3213 | |
… | |
… | |
3232 | |
3230 | |
3233 | if (op->contr && op->contr->tmp_invis == 0) |
3231 | if (op->contr && op->contr->tmp_invis == 0) |
3234 | return 0; |
3232 | return 0; |
3235 | |
3233 | |
3236 | /* If monsters, they should become visible */ |
3234 | /* If monsters, they should become visible */ |
3237 | if (op->hide || !op->contr || (op->contr && op->contr->tmp_invis)) |
3235 | if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis)) |
3238 | { |
3236 | { |
3239 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); |
3237 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible"); |
3240 | return 1; |
3238 | return 1; |
3241 | } |
3239 | } |
3242 | } |
3240 | } |
3243 | |
3241 | |
3244 | return 0; |
3242 | return 0; |
… | |
… | |
3481 | |
3479 | |
3482 | int dx, dy; |
3480 | int dx, dy; |
3483 | if (!adjacent_map (map, ns->current_map, &dx, &dy)) |
3481 | if (!adjacent_map (map, ns->current_map, &dx, &dy)) |
3484 | return 0; |
3482 | return 0; |
3485 | |
3483 | |
3486 | x += dx - ns->current_x + ns->mapx / 2; |
3484 | x += dx - ns->current_x; |
3487 | y += dy - ns->current_y + ns->mapy / 2; |
3485 | y += dy - ns->current_y; |
3488 | |
3486 | |
3489 | if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy)) |
|
|
3490 | return 0; |
|
|
3491 | |
|
|
3492 | return 100 - blocked_los [x][y]; |
3487 | return 100 - blocked_los (x, y); |
3493 | } |
3488 | } |
3494 | |
3489 | |
3495 | void |
3490 | void |
3496 | player::infobox (const char *title, const char *msg, int color) |
3491 | player::infobox (const char *title, const char *msg, int color) |
3497 | { |
3492 | { |