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.198 by root, Sat May 17 00:17:02 2008 UTC vs.
Revision 1.217 by root, Sun Dec 28 08:56:44 2008 UTC

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';
207 ob->close_container (); //TODO: client-specific 210 ob->close_container (); //TODO: client-specific
208 211
209 ns->update_look = 0; 212 ns->update_look = 0;
210 ns->look_position = 0; 213 ns->look_position = 0;
211 214
212 clear_los (this); 215 clear_los ();
213 216
214 ns->reset_stats (); 217 ns->reset_stats ();
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->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
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
734void 736void
735get_party_password (object *op, partylist *party) 737get_party_password (object *op, partylist *party)
736{ 738{
868 ob->msg = 0; 870 ob->msg = 0;
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);
874 esrv_send_inventory (ob, ob); 875 esrv_send_inventory (ob, ob);
875 ob->update_stats (); 876 ob->update_stats ();
876 877
877 /* This moves the player to a different start map, if there 878 /* This moves the player to a different start map, if there
878 * is one for this race 879 * is one for this race
930 LOG (llevDebug, "Fleeing player is dead.\n"); 931 LOG (llevDebug, "Fleeing player is dead.\n");
931 CLEAR_FLAG (op, FLAG_SCARED); 932 CLEAR_FLAG (op, FLAG_SCARED);
932 return; 933 return;
933 } 934 }
934 935
935 if (op->enemy == NULL) 936 if (!op->enemy)
936 { 937 {
937 LOG (llevDebug, "Fleeing player had no enemy.\n"); 938 LOG (llevDebug, "Fleeing player had no enemy.\n");
938 CLEAR_FLAG (op, FLAG_SCARED); 939 CLEAR_FLAG (op, FLAG_SCARED);
939 return; 940 return;
940 } 941 }
941 942
942 /* Seen some crashes here. Since we don't store an
943 * op->enemy_count, it is possible that something destroys the
944 * actual enemy, and the object is recycled.
945 */
946 if (op->enemy->map == NULL)
947 {
948 CLEAR_FLAG (op, FLAG_SCARED);
949 op->enemy = NULL;
950 return;
951 }
952
953 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))
954 { 944 {
955 op->enemy = NULL; 945 op->enemy = NULL;
956 CLEAR_FLAG (op, FLAG_SCARED); 946 CLEAR_FLAG (op, FLAG_SCARED);
957 return; 947 return;
960 get_rangevector (op, op->enemy, &rv, 0); 950 get_rangevector (op, op->enemy, &rv, 0);
961 951
962 dir = absdir (4 + rv.direction); 952 dir = absdir (4 + rv.direction);
963 for (diff = 0; diff < 3; diff++) 953 for (diff = 0; diff < 3; diff++)
964 { 954 {
965 int m = 1 - (RANDOM () & 2); 955 int m = 1 - rndm (2) * 2;
966 956
967 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)))
968 return; 958 return;
969 } 959 }
970 960
1015 1005
1016 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) 1006 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE)
1017 { 1007 {
1018 if (item_matched_string (op, tmp, op->contr->search_str)) 1008 if (item_matched_string (op, tmp, op->contr->search_str))
1019 CHK_PICK_PICKUP; 1009 CHK_PICK_PICKUP;
1010
1020 continue; 1011 continue;
1021 } 1012 }
1022 1013
1023 /* high not bit set? We're using the old autopickup model */ 1014 /* high not bit set? We're using the old autopickup model */
1024 if (!(op->contr->mode & PU_NEWMODE)) 1015 if (!(op->contr->mode & PU_NEWMODE))
1305 if (op->contr->mode & PU_RATIO) 1296 if (op->contr->mode & PU_RATIO)
1306 { 1297 {
1307 /* use value density to decide what else to grab */ 1298 /* use value density to decide what else to grab */
1308 /* >=7 was >= op->contr->mode */ 1299 /* >=7 was >= op->contr->mode */
1309 /* >=7 is the old standard setting. Now we take the last 4 bits 1300 /* >=7 is the old standard setting. Now we take the last 4 bits
1310 * and multiply them by 5, giving 0..15*5== 5..75 */ 1301 */
1311 wvratio = (op->contr->mode & PU_RATIO) * 5; 1302 wvratio = op->contr->mode & PU_RATIO;
1312 if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) 1303 if (1000 * query_cost (tmp, op, F_TRUE) / tmp->total_weight () >= wvratio * 100)
1313 { 1304 {
1314 CHK_PICK_PICKUP; 1305 CHK_PICK_PICKUP;
1315#if 0 1306#if 0
1316 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1307 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1317 if (tmp->name != NULL) 1308 if (tmp->name != NULL)
1461 for (i = 0, found = 0; i < 20; i++) 1452 for (i = 0, found = 0; i < 20; i++)
1462 { 1453 {
1463 x += freearr_x[dir]; 1454 x += freearr_x[dir];
1464 y += freearr_y[dir]; 1455 y += freearr_y[dir];
1465 mflags = get_map_flags (m, &m, x, y, &x, &y); 1456 mflags = get_map_flags (m, &m, x, y, &x, &y);
1457
1466 if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW) 1458 if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW)
1467 { 1459 {
1468 tmp = NULL; 1460 tmp = 0;
1469 break; 1461 break;
1470 } 1462 }
1471 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)
1472 { 1464 {
1473 /* This block presumes arrows and the like are MOVE_FLY_SLOW - 1465 /* This block presumes arrows and the like are MOVE_FLY_SLOW -
1474 * perhaps a bad assumption. 1466 * perhaps a bad assumption.
1475 */ 1467 */
1476 tmp = NULL; 1468 tmp = 0;
1477 break; 1469 break;
1478 } 1470 }
1471
1479 if (mflags & P_IS_ALIVE) 1472 if (mflags & P_IS_ALIVE)
1480 {
1481 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)
1482 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 1474 if (QUERY_FLAG (tmp, FLAG_ALIVE))
1483 {
1484 found++;
1485 break;
1486 }
1487 if (found)
1488 break; 1475 break;
1489 }
1490 } 1476 }
1491 if (tmp == NULL) 1477
1478 if (!tmp)
1492 return find_arrow (op, type); 1479 return find_arrow (op, type);
1493 1480
1494 if (tmp->head) 1481 if (tmp->head)
1495 tmp = tmp->head; 1482 tmp = tmp->head;
1496 1483
1541 if (bow->below) 1528 if (bow->below)
1542 { 1529 {
1543 bow->remove (); 1530 bow->remove ();
1544 op->insert (bow); 1531 op->insert (bow);
1545 } 1532 }
1546
1547 } 1533 }
1548 1534
1549 if (!bow->race || !bow->skill) 1535 if (!bow->race || !bow->skill)
1550 { 1536 {
1551 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);
1577 } 1563 }
1578 1564
1579 /* this should not happen, but sometimes does */ 1565 /* this should not happen, but sometimes does */
1580 if (arrow->nrof == 0) 1566 if (arrow->nrof == 0)
1581 { 1567 {
1568 LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ());
1582 arrow->destroy (); 1569 arrow->destroy ();
1583 return 0; 1570 return 0;
1584 } 1571 }
1585 1572
1586 left = arrow; /* these are arrows left to the player */ 1573 left = arrow; /* these are arrows left to the player */
1673 * hence the function name. 1660 * hence the function name.
1674 */ 1661 */
1675int 1662int
1676player_fire_bow (object *op, int dir) 1663player_fire_bow (object *op, int dir)
1677{ 1664{
1678 int ret = 0, wcmod = 0; 1665 int ret;
1679 1666
1680 if (op->contr->bowtype == bow_bestarrow) 1667 if (op->contr->bowtype == bow_bestarrow)
1681 { 1668 {
1682 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);
1683 } 1670 }
1684 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)
1685 { 1672 {
1686 if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) 1673 int wcmod = similar_direction (dir, op->contr->bowtype - bow_n + 1) ? 0 : -1;
1687 wcmod = -1;
1688
1689 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);
1690 } 1675 }
1691 else if (op->contr->bowtype == bow_threewide) 1676 else if (op->contr->bowtype == bow_threewide)
1692 { 1677 {
1693 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);
1694 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)]);
1695 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)]);
1696 } 1681 }
1697 else if (op->contr->bowtype == bow_spreadshot) 1682 else if (op->contr->bowtype == bow_spreadshot)
1698 { 1683 {
1699 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);
1700 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);
1701 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);
1702 } 1687 }
1703 else 1688 else
1704 { 1689 {
1761 } 1746 }
1762 } 1747 }
1763 1748
1764 if (cast_spell (op, item, dir, item->inv, NULL)) 1749 if (cast_spell (op, item, dir, item->inv, NULL))
1765 { 1750 {
1766 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
1767 if (item->type == WAND) 1753 if (item->type == WAND)
1768 { 1754 {
1769 if (!(--item->stats.food)) 1755 if (!(--item->stats.food))
1770 { 1756 {
1771 object *tmp; 1757 object *tmp;
1791bool 1777bool
1792fire (object *op, int dir) 1778fire (object *op, int dir)
1793{ 1779{
1794 int spellcost = 0; 1780 int spellcost = 0;
1795 1781
1796 /* check for loss of invisiblity/hide */
1797 if (action_makes_visible (op))
1798 make_visible (op);
1799
1800 player *pl = op->contr; 1782 player *pl = op->contr;
1801 1783
1802 if (pl->golem) 1784 if (pl->golem)
1803 { 1785 {
1804 control_golem (op->contr->golem, dir); 1786 control_golem (op->contr->golem, dir);
1806 } 1788 }
1807 1789
1808 object *ob = pl->ranged_ob; 1790 object *ob = pl->ranged_ob;
1809 1791
1810 if (!ob) 1792 if (!ob)
1811 return false;
1812
1813 if (!op->change_weapon (ob))
1814 return false; 1793 return false;
1815 1794
1816 if (op->speed_left > 0.f) 1795 if (op->speed_left > 0.f)
1817 --op->speed_left; 1796 --op->speed_left;
1818 else 1797 else
1819 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);
1820 1806
1821 switch (ob->type) 1807 switch (ob->type)
1822 { 1808 {
1823 case BOW: 1809 case BOW:
1824 player_fire_bow (op, dir); 1810 player_fire_bow (op, dir);
2069 --op->speed_left; 2055 --op->speed_left;
2070 2056
2071 op->play_sound (sound_find ("push_player")); 2057 op->play_sound (sound_find ("push_player"));
2072 push_ob (mon, dir, op); 2058 push_ob (mon, dir, op);
2073 2059
2074 if (op->contr->tmp_invis || op->hide) 2060 if (action_makes_visible (op))
2075 make_visible (op); 2061 make_visible (op);
2076 2062
2077 return true; 2063 return true;
2078 } 2064 }
2079 else 2065 else
2101 push_ob (mon, dir, op); 2087 push_ob (mon, dir, op);
2102 } 2088 }
2103 else 2089 else
2104 op->statusmsg ("You withhold your attack"); 2090 op->statusmsg ("You withhold your attack");
2105 2091
2106 if (op->contr->tmp_invis || op->hide) 2092 if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN])
2107 make_visible (op); 2093 make_visible (op);
2108 2094
2109 return true; 2095 return true;
2110 } 2096 }
2111 } 2097 }
2169 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2155 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2170 dir = absdir (dir + rndm (3) + rndm (3) - 2); 2156 dir = absdir (dir + rndm (3) + rndm (3) - 2);
2171 2157
2172 op->facing = dir; 2158 op->facing = dir;
2173 2159
2174 if (op->hide) 2160 if (op->flag [FLAG_HIDDEN])
2175 do_hidden_move (op); 2161 do_hidden_move (op);
2176 2162
2177 bool retval; 2163 bool retval;
2178 2164
2179 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) 2165 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir)))
2310const char * 2296const char *
2311gravestone_text (object *op) 2297gravestone_text (object *op)
2312{ 2298{
2313 static dynbuf_text buf; 2299 static dynbuf_text buf;
2314 2300
2315 buf << "---- R.I.P. ----\n\n"; 2301 buf << "---- R.I.P. ----\n\n"
2316 op->name; 2302 << op->name;
2317 2303
2318 if (op->type == PLAYER) 2304 if (op->type == PLAYER)
2319 buf << " the " << op->contr->title; 2305 buf << " the " << op->contr->title;
2320 2306
2321 buf << "\n\n"; 2307 buf << "\n\n";
2497 { 2483 {
2498 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; 2484 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp;
2499 2485
2500 if (over_hp > 0) 2486 if (over_hp > 0)
2501 { 2487 {
2502 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;
2503 op->last_heal = 0; 2489 op->last_heal = 0;
2504 } 2490 }
2505 else 2491 else
2506 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);
2507 } 2493 }
2563 2549
2564 if (op->stats.food < 0) 2550 if (op->stats.food < 0)
2565 { 2551 {
2566 op->stats.hp += op->stats.food; 2552 op->stats.hp += op->stats.food;
2567 op->stats.food = 0; 2553 op->stats.food = 0;
2554
2555 if (op->stats.hp < 0)
2556 {
2557 op->contr->killer = archetype::get ("killer_starvation");
2558 op->contr->killer->destroy ();
2568 } 2559 }
2560 }
2569 2561
2562 /* killer should be set here already */
2570 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2563 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2571 kill_player (op); 2564 kill_player (op);
2572 } 2565 }
2573} 2566}
2574 2567
2643 2636
2644 INVOKE_PLAYER (DEATH, op->contr); 2637 INVOKE_PLAYER (DEATH, op->contr);
2645 2638
2646 command_kill_pets (op, 0); 2639 command_kill_pets (op, 0);
2647 2640
2648 if (op->stats.food < 0)
2649 {
2650 op->contr->killer = archetype::get ("killer_starvation");
2651 op->contr->killer->destroy ();
2652 }
2653
2654 op->contr->play_sound (sound_find ("player_dies")); 2641 op->contr->play_sound (sound_find ("player_dies"));
2655 2642
2656 /* save the map location for corpse, gravestone */ 2643 /* save the map location for corpse, gravestone */
2657 x = op->x; 2644 x = op->x;
2658 y = op->y; 2645 y = op->y;
2687 2674
2688 lost_a_stat = 0; 2675 lost_a_stat = 0;
2689 2676
2690 for (z = 0; z < num_stats_lose; z++) 2677 for (z = 0; z < num_stats_lose; z++)
2691 { 2678 {
2692 i = RANDOM () % NUM_STATS; 2679 i = rndm (NUM_STATS);
2693 2680
2694 if (settings.stat_loss_on_death) 2681 if (settings.stat_loss_on_death)
2695 { 2682 {
2696 /* 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
2697 * what he lost. 2684 * what he lost.
2789 * exp loss on the stone. 2776 * exp loss on the stone.
2790 */ 2777 */
2791 tmp = arch_to_object (archetype::find ("gravestone")); 2778 tmp = arch_to_object (archetype::find ("gravestone"));
2792 tmp->name = format ("%s's gravestone", &op->name); 2779 tmp->name = format ("%s's gravestone", &op->name);
2793 tmp->name_pl = format ("%s's gravestones", &op->name); 2780 tmp->name_pl = format ("%s's gravestones", &op->name);
2794 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 ());
2795 tmp->x = op->x, tmp->y = op->y; 2783 tmp->x = op->x, tmp->y = op->y;
2796 insert_ob_in_map (tmp, op->map, NULL, 0); 2784 insert_ob_in_map (tmp, op->map, NULL, 0);
2797 2785
2798 /**************************************/ 2786 /**************************************/
2799 /* */ 2787 /* */
2887 if (will_kill_again & (1 << at)) 2875 if (will_kill_again & (1 << at))
2888 force->resist[at] = 100; 2876 force->resist[at] = 100;
2889 2877
2890 insert_ob_in_ob (force, op); 2878 insert_ob_in_ob (force, op);
2891 op->update_stats (); 2879 op->update_stats ();
2892
2893 } 2880 }
2894 2881
2895 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); 2882 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED.");
2896} 2883}
2897 2884
2998} 2985}
2999 2986
3000void 2987void
3001make_visible (object *op) 2988make_visible (object *op)
3002{ 2989{
3003 op->hide = 0; 2990 op->flag [FLAG_HIDDEN] = 0;
3004 op->invisible = 0; 2991 op->invisible = 0;
3005 2992
3006 if (op->type == PLAYER) 2993 if (op->type == PLAYER)
3007 { 2994 {
3008 op->contr->tmp_invis = 0; 2995 op->contr->tmp_invis = 0;
3033 3020
3034 if (!ob || !ob->map) 3021 if (!ob || !ob->map)
3035 return 0; 3022 return 0;
3036 3023
3037 /* so, on normal lighted maps, its hard to hide */ 3024 /* so, on normal lighted maps, its hard to hide */
3038 level = ob->map->darkness - 2; 3025 level = ob->map->darklevel () - 2;
3039 3026
3040 /* this also picks up whether the object is glowing. 3027 /* this also picks up whether the object is glowing.
3041 * 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
3042 * as bad as carrying a light on a pitch dark map */ 3029 * as bad as carrying a light on a pitch dark map */
3043 if (has_carried_lights (ob)) 3030 if (has_carried_lights (ob))
3044 level = -(10 + (2 * ob->map->darkness)); 3031 level = -(10 + (2 * ob->map->darklevel ()));
3045 3032
3046 /* scan through all nearby squares for terrain to hide in */ 3033 /* scan through all nearby squares for terrain to hide in */
3047 for (i = 0, x = ob->x, y = ob->y; 3034 for (i = 0, x = ob->x, y = ob->y;
3048 i <= SIZEOFFREE1; 3035 i <= SIZEOFFREE1;
3049 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])
3196 while (op) 3183 while (op)
3197 { 3184 {
3198 dx = rv.distance_x + op->arch->x; 3185 dx = rv.distance_x + op->arch->x;
3199 dy = rv.distance_y + op->arch->y; 3186 dy = rv.distance_y + op->arch->y;
3200 3187
3201 /* only the viewable area the player sees is updated by LOS 3188 if (pl->contr->blocked_los (dx, dy) != LOS_BLOCKED)
3202 * code, so we need to restrict ourselves to that range of values
3203 * for any meaningful values.
3204 */
3205 if (abs (dx) <= (pl->contr->ns->mapx / 2) &&
3206 abs (dy) <= (pl->contr->ns->mapy / 2) &&
3207 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3208 return 1; 3189 return 1;
3209 3190
3210 op = op->more; 3191 op = op->more;
3211 } 3192 }
3212 3193
3213 return 0; 3194 return 0;
3214} 3195}
3215 3196
3216/* routine for both players and monsters. We call this when 3197/* routine for both players and monsters. We call this when
3217 * there is a possibility for our action distrubing our hiding 3198 * there is a possibility for our action distrubing our hiding
3218 * place or invisiblity spell. Artefact invisiblity is not 3199 * place or invisiblity spell. Artefact invisiblity causes
3219 * effected by this. If we arent invisible to begin with, we 3200 * "noise" instead. If we arent invisible to begin with, we
3220 * return 0. 3201 * return 0.
3221 */ 3202 */
3222int 3203int
3223action_makes_visible (object *op) 3204action_makes_visible (object *op)
3224{ 3205{
3225 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) 3206 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE))
3226 { 3207 {
3227 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
3228 return 0; 3215 return 0;
3216 }
3229 3217
3230 if (op->contr && op->contr->tmp_invis == 0) 3218 if (op->contr && op->contr->tmp_invis == 0)
3231 return 0; 3219 return 0;
3232 3220
3233 /* If monsters, they should become visible */ 3221 /* If monsters, they should become visible */
3234 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))
3235 { 3223 {
3236 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");
3237 return 1; 3225 return 1;
3238 } 3226 }
3239 } 3227 }
3240 3228
3241 return 0; 3229 return 0;
3469 if (pl->ranged_ob == ob) 3457 if (pl->ranged_ob == ob)
3470 pl->ranged_ob = 0; 3458 pl->ranged_ob = 0;
3471} 3459}
3472 3460
3473sint8 3461sint8
3474player::visibility_at (maptile *map, int x, int y) const 3462player::darkness_at (maptile *map, int x, int y) const
3475{ 3463{
3476 if (!ns) 3464 if (!ns)
3477 return 0; 3465 return LOS_BLOCKED;
3478 3466
3479 int dx, dy; 3467 int dx, dy;
3480 if (!adjacent_map (map, ns->current_map, &dx, &dy)) 3468 if (!adjacent_map (map, ns->current_map, &dx, &dy))
3481 return 0; 3469 return LOS_BLOCKED;
3482 3470
3483 x += dx - ns->current_x + ns->mapx / 2; 3471 x += dx - ns->current_x;
3484 y += dy - ns->current_y + ns->mapy / 2; 3472 y += dy - ns->current_y;
3485 3473
3486 if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy))
3487 return 0;
3488
3489 return 100 - blocked_los [x][y]; 3474 return blocked_los (x, y);
3490} 3475}
3491 3476
3492void 3477void
3493player::infobox (const char *title, const char *msg, int color) 3478player::infobox (const char *title, const char *msg, int color)
3494{ 3479{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines