ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.202 by root, Fri Aug 29 02:07:09 2008 UTC vs.
Revision 1.217 by root, Sun Dec 28 08:56:44 2008 UTC

210 ob->close_container (); //TODO: client-specific 210 ob->close_container (); //TODO: client-specific
211 211
212 ns->update_look = 0; 212 ns->update_look = 0;
213 ns->look_position = 0; 213 ns->look_position = 0;
214 214
215 clear_los (this); 215 clear_los ();
216 216
217 ns->reset_stats (); 217 ns->reset_stats ();
218 218
219 /* make sure he's a player -- needed because of class change. */ 219 /* make sure he's a player -- needed because of class change. */
220 ob->type = PLAYER; // we are paranoid 220 ob->type = PLAYER; // we are paranoid
221 ob->race = ob->arch->race; 221 ob->race = ob->arch->race;
222 222
223 ob->update_weight (); 223 ob->update_weight ();
224 link_player_skills (ob); 224 link_skills ();
225 225
226 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); 226 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER);
227 227
228 assign (title, ob->arch->object::name); 228 assign (title, ob->arch->object::name);
229 229
728 else /* lock all 'normal items by default */ 728 else /* lock all 'normal items by default */
729 SET_FLAG (op, FLAG_INV_LOCKED); 729 SET_FLAG (op, FLAG_INV_LOCKED);
730 } /* for loop of objects in player inv */ 730 } /* for loop of objects in player inv */
731 731
732 /* Need to set up the skill pointers */ 732 /* Need to set up the skill pointers */
733 link_player_skills (pl); 733 pl->contr->link_skills ();
734} 734}
735 735
736void 736void
737get_party_password (object *op, partylist *party) 737get_party_password (object *op, partylist *party)
738{ 738{
870 ob->msg = 0; 870 ob->msg = 0;
871 871
872 start_info (ob); 872 start_info (ob);
873 CLEAR_FLAG (ob, FLAG_WIZ); 873 CLEAR_FLAG (ob, FLAG_WIZ);
874 give_initial_items (ob, ob->randomitems); 874 give_initial_items (ob, ob->randomitems);
875 link_player_skills (ob);
876 esrv_send_inventory (ob, ob); 875 esrv_send_inventory (ob, ob);
877 ob->update_stats (); 876 ob->update_stats ();
878 877
879 /* This moves the player to a different start map, if there 878 /* This moves the player to a different start map, if there
880 * is one for this race 879 * is one for this race
932 LOG (llevDebug, "Fleeing player is dead.\n"); 931 LOG (llevDebug, "Fleeing player is dead.\n");
933 CLEAR_FLAG (op, FLAG_SCARED); 932 CLEAR_FLAG (op, FLAG_SCARED);
934 return; 933 return;
935 } 934 }
936 935
937 if (op->enemy == NULL) 936 if (!op->enemy)
938 { 937 {
939 LOG (llevDebug, "Fleeing player had no enemy.\n"); 938 LOG (llevDebug, "Fleeing player had no enemy.\n");
940 CLEAR_FLAG (op, FLAG_SCARED); 939 CLEAR_FLAG (op, FLAG_SCARED);
941 return; 940 return;
942 } 941 }
943 942
944 /* Seen some crashes here. Since we don't store an
945 * op->enemy_count, it is possible that something destroys the
946 * actual enemy, and the object is recycled.
947 */
948 if (op->enemy->map == NULL)
949 {
950 CLEAR_FLAG (op, FLAG_SCARED);
951 op->enemy = NULL;
952 return;
953 }
954
955 if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) 943 if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0))
956 { 944 {
957 op->enemy = NULL; 945 op->enemy = NULL;
958 CLEAR_FLAG (op, FLAG_SCARED); 946 CLEAR_FLAG (op, FLAG_SCARED);
959 return; 947 return;
962 get_rangevector (op, op->enemy, &rv, 0); 950 get_rangevector (op, op->enemy, &rv, 0);
963 951
964 dir = absdir (4 + rv.direction); 952 dir = absdir (4 + rv.direction);
965 for (diff = 0; diff < 3; diff++) 953 for (diff = 0; diff < 3; diff++)
966 { 954 {
967 int m = 1 - (RANDOM () & 2); 955 int m = 1 - rndm (2) * 2;
968 956
969 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) 957 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op)))
970 return; 958 return;
971 } 959 }
972 960
1017 1005
1018 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) 1006 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE)
1019 { 1007 {
1020 if (item_matched_string (op, tmp, op->contr->search_str)) 1008 if (item_matched_string (op, tmp, op->contr->search_str))
1021 CHK_PICK_PICKUP; 1009 CHK_PICK_PICKUP;
1010
1022 continue; 1011 continue;
1023 } 1012 }
1024 1013
1025 /* high not bit set? We're using the old autopickup model */ 1014 /* high not bit set? We're using the old autopickup model */
1026 if (!(op->contr->mode & PU_NEWMODE)) 1015 if (!(op->contr->mode & PU_NEWMODE))
1463 for (i = 0, found = 0; i < 20; i++) 1452 for (i = 0, found = 0; i < 20; i++)
1464 { 1453 {
1465 x += freearr_x[dir]; 1454 x += freearr_x[dir];
1466 y += freearr_y[dir]; 1455 y += freearr_y[dir];
1467 mflags = get_map_flags (m, &m, x, y, &x, &y); 1456 mflags = get_map_flags (m, &m, x, y, &x, &y);
1457
1468 if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW) 1458 if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW)
1469 { 1459 {
1470 tmp = NULL; 1460 tmp = 0;
1471 break; 1461 break;
1472 } 1462 }
1473 else if (GET_MAP_MOVE_BLOCK (m, x, y) == MOVE_FLY_LOW) 1463 else if (GET_MAP_MOVE_BLOCK (m, x, y) == MOVE_FLY_LOW)
1474 { 1464 {
1475 /* This block presumes arrows and the like are MOVE_FLY_SLOW - 1465 /* This block presumes arrows and the like are MOVE_FLY_SLOW -
1476 * perhaps a bad assumption. 1466 * perhaps a bad assumption.
1477 */ 1467 */
1478 tmp = NULL; 1468 tmp = 0;
1479 break; 1469 break;
1480 } 1470 }
1471
1481 if (mflags & P_IS_ALIVE) 1472 if (mflags & P_IS_ALIVE)
1482 {
1483 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) 1473 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
1484 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 1474 if (QUERY_FLAG (tmp, FLAG_ALIVE))
1485 {
1486 found++;
1487 break;
1488 }
1489 if (found)
1490 break; 1475 break;
1491 }
1492 } 1476 }
1493 if (tmp == NULL) 1477
1478 if (!tmp)
1494 return find_arrow (op, type); 1479 return find_arrow (op, type);
1495 1480
1496 if (tmp->head) 1481 if (tmp->head)
1497 tmp = tmp->head; 1482 tmp = tmp->head;
1498 1483
1543 if (bow->below) 1528 if (bow->below)
1544 { 1529 {
1545 bow->remove (); 1530 bow->remove ();
1546 op->insert (bow); 1531 op->insert (bow);
1547 } 1532 }
1548
1549 } 1533 }
1550 1534
1551 if (!bow->race || !bow->skill) 1535 if (!bow->race || !bow->skill)
1552 { 1536 {
1553 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); 1537 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name);
1579 } 1563 }
1580 1564
1581 /* this should not happen, but sometimes does */ 1565 /* this should not happen, but sometimes does */
1582 if (arrow->nrof == 0) 1566 if (arrow->nrof == 0)
1583 { 1567 {
1568 LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ());
1584 arrow->destroy (); 1569 arrow->destroy ();
1585 return 0; 1570 return 0;
1586 } 1571 }
1587 1572
1588 left = arrow; /* these are arrows left to the player */ 1573 left = arrow; /* these are arrows left to the player */
1675 * hence the function name. 1660 * hence the function name.
1676 */ 1661 */
1677int 1662int
1678player_fire_bow (object *op, int dir) 1663player_fire_bow (object *op, int dir)
1679{ 1664{
1680 int ret = 0, wcmod = 0; 1665 int ret;
1681 1666
1682 if (op->contr->bowtype == bow_bestarrow) 1667 if (op->contr->bowtype == bow_bestarrow)
1683 { 1668 {
1684 ret = fire_bow (op, op, pick_arrow_target (op, op->contr->ranged_ob->race, dir), dir, 0, op->x, op->y); 1669 ret = fire_bow (op, op, pick_arrow_target (op, op->contr->ranged_ob->race, dir), dir, 0, op->x, op->y);
1685 } 1670 }
1686 else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) 1671 else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw)
1687 { 1672 {
1688 if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) 1673 int wcmod = similar_direction (dir, op->contr->bowtype - bow_n + 1) ? 0 : -1;
1689 wcmod = -1;
1690
1691 ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); 1674 ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y);
1692 } 1675 }
1693 else if (op->contr->bowtype == bow_threewide) 1676 else if (op->contr->bowtype == bow_threewide)
1694 { 1677 {
1695 ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); 1678 ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y);
1696 ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir + 2)], op->y + freearr_y[absdir (dir + 2)]); 1679 ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir + 2)], op->y + freearr_y[absdir (dir + 2)]);
1697 ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir - 2)], op->y + freearr_y[absdir (dir - 2)]); 1680 ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir - 2)], op->y + freearr_y[absdir (dir - 2)]);
1698 } 1681 }
1699 else if (op->contr->bowtype == bow_spreadshot) 1682 else if (op->contr->bowtype == bow_spreadshot)
1700 { 1683 {
1701 ret |= fire_bow (op, op, NULL, dir, 0, op->x, op->y); 1684 ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y);
1702 ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y); 1685 ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y);
1703 ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y); 1686 ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y);
1704 } 1687 }
1705 else 1688 else
1706 { 1689 {
1763 } 1746 }
1764 } 1747 }
1765 1748
1766 if (cast_spell (op, item, dir, item->inv, NULL)) 1749 if (cast_spell (op, item, dir, item->inv, NULL))
1767 { 1750 {
1768 SET_FLAG (op, FLAG_BEEN_APPLIED); /* You now know something about it */ 1751 item->flag [FLAG_BEEN_APPLIED] = true; /* You now know something about it */
1752
1769 if (item->type == WAND) 1753 if (item->type == WAND)
1770 { 1754 {
1771 if (!(--item->stats.food)) 1755 if (!(--item->stats.food))
1772 { 1756 {
1773 object *tmp; 1757 object *tmp;
1793bool 1777bool
1794fire (object *op, int dir) 1778fire (object *op, int dir)
1795{ 1779{
1796 int spellcost = 0; 1780 int spellcost = 0;
1797 1781
1798 /* check for loss of invisiblity/hide */
1799 if (action_makes_visible (op))
1800 make_visible (op);
1801
1802 player *pl = op->contr; 1782 player *pl = op->contr;
1803 1783
1804 if (pl->golem) 1784 if (pl->golem)
1805 { 1785 {
1806 control_golem (op->contr->golem, dir); 1786 control_golem (op->contr->golem, dir);
1808 } 1788 }
1809 1789
1810 object *ob = pl->ranged_ob; 1790 object *ob = pl->ranged_ob;
1811 1791
1812 if (!ob) 1792 if (!ob)
1813 return false;
1814
1815 if (!op->change_weapon (ob))
1816 return false; 1793 return false;
1817 1794
1818 if (op->speed_left > 0.f) 1795 if (op->speed_left > 0.f)
1819 --op->speed_left; 1796 --op->speed_left;
1820 else 1797 else
1821 return false; 1798 return false;
1799
1800 if (!op->change_weapon (ob))
1801 return false;
1802
1803 /* check for loss of invisiblity/hide */
1804 if (action_makes_visible (op))
1805 make_visible (op);
1822 1806
1823 switch (ob->type) 1807 switch (ob->type)
1824 { 1808 {
1825 case BOW: 1809 case BOW:
1826 player_fire_bow (op, dir); 1810 player_fire_bow (op, dir);
2071 --op->speed_left; 2055 --op->speed_left;
2072 2056
2073 op->play_sound (sound_find ("push_player")); 2057 op->play_sound (sound_find ("push_player"));
2074 push_ob (mon, dir, op); 2058 push_ob (mon, dir, op);
2075 2059
2076 if (op->contr->tmp_invis || op->hide) 2060 if (action_makes_visible (op))
2077 make_visible (op); 2061 make_visible (op);
2078 2062
2079 return true; 2063 return true;
2080 } 2064 }
2081 else 2065 else
2103 push_ob (mon, dir, op); 2087 push_ob (mon, dir, op);
2104 } 2088 }
2105 else 2089 else
2106 op->statusmsg ("You withhold your attack"); 2090 op->statusmsg ("You withhold your attack");
2107 2091
2108 if (op->contr->tmp_invis || op->hide) 2092 if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN])
2109 make_visible (op); 2093 make_visible (op);
2110 2094
2111 return true; 2095 return true;
2112 } 2096 }
2113 } 2097 }
2171 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2155 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2172 dir = absdir (dir + rndm (3) + rndm (3) - 2); 2156 dir = absdir (dir + rndm (3) + rndm (3) - 2);
2173 2157
2174 op->facing = dir; 2158 op->facing = dir;
2175 2159
2176 if (op->hide) 2160 if (op->flag [FLAG_HIDDEN])
2177 do_hidden_move (op); 2161 do_hidden_move (op);
2178 2162
2179 bool retval; 2163 bool retval;
2180 2164
2181 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) 2165 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir)))
2312const char * 2296const char *
2313gravestone_text (object *op) 2297gravestone_text (object *op)
2314{ 2298{
2315 static dynbuf_text buf; 2299 static dynbuf_text buf;
2316 2300
2317 buf << "---- R.I.P. ----\n\n"; 2301 buf << "---- R.I.P. ----\n\n"
2318 op->name; 2302 << op->name;
2319 2303
2320 if (op->type == PLAYER) 2304 if (op->type == PLAYER)
2321 buf << " the " << op->contr->title; 2305 buf << " the " << op->contr->title;
2322 2306
2323 buf << "\n\n"; 2307 buf << "\n\n";
2499 { 2483 {
2500 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; 2484 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp;
2501 2485
2502 if (over_hp > 0) 2486 if (over_hp > 0)
2503 { 2487 {
2504 op->stats.sp += over_hp + (RANDOM () % rate_hp > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0; 2488 op->stats.sp += over_hp + (rndm (rate_hp) > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0;
2505 op->last_heal = 0; 2489 op->last_heal = 0;
2506 } 2490 }
2507 else 2491 else
2508 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10); 2492 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10);
2509 } 2493 }
2690 2674
2691 lost_a_stat = 0; 2675 lost_a_stat = 0;
2692 2676
2693 for (z = 0; z < num_stats_lose; z++) 2677 for (z = 0; z < num_stats_lose; z++)
2694 { 2678 {
2695 i = RANDOM () % NUM_STATS; 2679 i = rndm (NUM_STATS);
2696 2680
2697 if (settings.stat_loss_on_death) 2681 if (settings.stat_loss_on_death)
2698 { 2682 {
2699 /* Pick a random stat and take a point off it. Tell the player 2683 /* Pick a random stat and take a point off it. Tell the player
2700 * what he lost. 2684 * what he lost.
2792 * exp loss on the stone. 2776 * exp loss on the stone.
2793 */ 2777 */
2794 tmp = arch_to_object (archetype::find ("gravestone")); 2778 tmp = arch_to_object (archetype::find ("gravestone"));
2795 tmp->name = format ("%s's gravestone", &op->name); 2779 tmp->name = format ("%s's gravestone", &op->name);
2796 tmp->name_pl = format ("%s's gravestones", &op->name); 2780 tmp->name_pl = format ("%s's gravestones", &op->name);
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 ()); 2781 tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n",
2782 &op->name, op->contr->title, op->contr->killer_name ());
2798 tmp->x = op->x, tmp->y = op->y; 2783 tmp->x = op->x, tmp->y = op->y;
2799 insert_ob_in_map (tmp, op->map, NULL, 0); 2784 insert_ob_in_map (tmp, op->map, NULL, 0);
2800 2785
2801 /**************************************/ 2786 /**************************************/
2802 /* */ 2787 /* */
2890 if (will_kill_again & (1 << at)) 2875 if (will_kill_again & (1 << at))
2891 force->resist[at] = 100; 2876 force->resist[at] = 100;
2892 2877
2893 insert_ob_in_ob (force, op); 2878 insert_ob_in_ob (force, op);
2894 op->update_stats (); 2879 op->update_stats ();
2895
2896 } 2880 }
2897 2881
2898 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); 2882 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED.");
2899} 2883}
2900 2884
3001} 2985}
3002 2986
3003void 2987void
3004make_visible (object *op) 2988make_visible (object *op)
3005{ 2989{
3006 op->hide = 0; 2990 op->flag [FLAG_HIDDEN] = 0;
3007 op->invisible = 0; 2991 op->invisible = 0;
3008 2992
3009 if (op->type == PLAYER) 2993 if (op->type == PLAYER)
3010 { 2994 {
3011 op->contr->tmp_invis = 0; 2995 op->contr->tmp_invis = 0;
3036 3020
3037 if (!ob || !ob->map) 3021 if (!ob || !ob->map)
3038 return 0; 3022 return 0;
3039 3023
3040 /* so, on normal lighted maps, its hard to hide */ 3024 /* so, on normal lighted maps, its hard to hide */
3041 level = ob->map->darkness - 2; 3025 level = ob->map->darklevel () - 2;
3042 3026
3043 /* this also picks up whether the object is glowing. 3027 /* this also picks up whether the object is glowing.
3044 * If you carry a light on a non-dark map, its not 3028 * If you carry a light on a non-dark map, its not
3045 * as bad as carrying a light on a pitch dark map */ 3029 * as bad as carrying a light on a pitch dark map */
3046 if (has_carried_lights (ob)) 3030 if (has_carried_lights (ob))
3047 level = -(10 + (2 * ob->map->darkness)); 3031 level = -(10 + (2 * ob->map->darklevel ()));
3048 3032
3049 /* scan through all nearby squares for terrain to hide in */ 3033 /* scan through all nearby squares for terrain to hide in */
3050 for (i = 0, x = ob->x, y = ob->y; 3034 for (i = 0, x = ob->x, y = ob->y;
3051 i <= SIZEOFFREE1; 3035 i <= SIZEOFFREE1;
3052 i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) 3036 i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i])
3199 while (op) 3183 while (op)
3200 { 3184 {
3201 dx = rv.distance_x + op->arch->x; 3185 dx = rv.distance_x + op->arch->x;
3202 dy = rv.distance_y + op->arch->y; 3186 dy = rv.distance_y + op->arch->y;
3203 3187
3204 /* only the viewable area the player sees is updated by LOS 3188 if (pl->contr->blocked_los (dx, dy) != LOS_BLOCKED)
3205 * code, so we need to restrict ourselves to that range of values
3206 * for any meaningful values.
3207 */
3208 if (abs (dx) <= (pl->contr->ns->mapx / 2) &&
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; 3189 return 1;
3212 3190
3213 op = op->more; 3191 op = op->more;
3214 } 3192 }
3215 3193
3216 return 0; 3194 return 0;
3217} 3195}
3218 3196
3219/* routine for both players and monsters. We call this when 3197/* routine for both players and monsters. We call this when
3220 * there is a possibility for our action distrubing our hiding 3198 * there is a possibility for our action distrubing our hiding
3221 * place or invisiblity spell. Artefact invisiblity is not 3199 * place or invisiblity spell. Artefact invisiblity causes
3222 * effected by this. If we arent invisible to begin with, we 3200 * "noise" instead. If we arent invisible to begin with, we
3223 * return 0. 3201 * return 0.
3224 */ 3202 */
3225int 3203int
3226action_makes_visible (object *op) 3204action_makes_visible (object *op)
3227{ 3205{
3228 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) 3206 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE))
3229 { 3207 {
3230 if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) 3208 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
3209 {
3210 // artefact invisibility is permanent, but we still make noise
3211 // this is important for game-balance.
3212 if (op->contr)
3213 op->make_noise ();
3214
3231 return 0; 3215 return 0;
3216 }
3232 3217
3233 if (op->contr && op->contr->tmp_invis == 0) 3218 if (op->contr && op->contr->tmp_invis == 0)
3234 return 0; 3219 return 0;
3235 3220
3236 /* If monsters, they should become visible */ 3221 /* If monsters, they should become visible */
3237 if (op->hide || !op->contr || (op->contr && op->contr->tmp_invis)) 3222 if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis))
3238 { 3223 {
3239 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); 3224 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible");
3240 return 1; 3225 return 1;
3241 } 3226 }
3242 } 3227 }
3243 3228
3244 return 0; 3229 return 0;
3472 if (pl->ranged_ob == ob) 3457 if (pl->ranged_ob == ob)
3473 pl->ranged_ob = 0; 3458 pl->ranged_ob = 0;
3474} 3459}
3475 3460
3476sint8 3461sint8
3477player::visibility_at (maptile *map, int x, int y) const 3462player::darkness_at (maptile *map, int x, int y) const
3478{ 3463{
3479 if (!ns) 3464 if (!ns)
3480 return 0; 3465 return LOS_BLOCKED;
3481 3466
3482 int dx, dy; 3467 int dx, dy;
3483 if (!adjacent_map (map, ns->current_map, &dx, &dy)) 3468 if (!adjacent_map (map, ns->current_map, &dx, &dy))
3484 return 0; 3469 return LOS_BLOCKED;
3485 3470
3486 x += dx - ns->current_x + ns->mapx / 2; 3471 x += dx - ns->current_x;
3487 y += dy - ns->current_y + ns->mapy / 2; 3472 y += dy - ns->current_y;
3488 3473
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]; 3474 return blocked_los (x, y);
3493} 3475}
3494 3476
3495void 3477void
3496player::infobox (const char *title, const char *msg, int color) 3478player::infobox (const char *title, const char *msg, int color)
3497{ 3479{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines