… | |
… | |
329 | player *p; |
329 | player *p; |
330 | |
330 | |
331 | p = get_player (NULL); |
331 | p = get_player (NULL); |
332 | p->socket = *ns; |
332 | p->socket = *ns; |
333 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
333 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
|
|
334 | |
334 | if (p->socket.faces_sent == NULL) |
335 | if (p->socket.faces_sent == NULL) |
335 | fatal (OUT_OF_MEMORY); |
336 | fatal (OUT_OF_MEMORY); |
|
|
337 | |
336 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
338 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
337 | /* Needed because the socket we just copied over needs to be cleared. |
339 | /* Needed because the socket we just copied over needs to be cleared. |
338 | * Note that this can result in a client reset if there is partial data |
340 | * Note that this can result in a client reset if there is partial data |
339 | * on the uncoming socket. |
341 | * on the uncoming socket. |
340 | */ |
342 | */ |
… | |
… | |
345 | add_friendly_object (p->ob); |
347 | add_friendly_object (p->ob); |
346 | send_rules (p->ob); |
348 | send_rules (p->ob); |
347 | send_news (p->ob); |
349 | send_news (p->ob); |
348 | display_motd (p->ob); |
350 | display_motd (p->ob); |
349 | get_name (p->ob); |
351 | get_name (p->ob); |
|
|
352 | |
350 | return 0; |
353 | return 0; |
351 | } |
354 | } |
352 | |
355 | |
353 | /* |
356 | /* |
354 | * get_player_archetype() return next player archetype from archetype |
357 | * get_player_archetype() return next player archetype from archetype |
… | |
… | |
489 | path_to_player (object *mon, object *pl, unsigned mindiff) |
492 | path_to_player (object *mon, object *pl, unsigned mindiff) |
490 | { |
493 | { |
491 | rv_vector rv; |
494 | rv_vector rv; |
492 | sint16 x, y; |
495 | sint16 x, y; |
493 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
496 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
494 | mapstruct *m, *lastmap; |
497 | maptile *m, *lastmap; |
495 | |
498 | |
496 | get_rangevector (mon, pl, &rv, 0); |
499 | get_rangevector (mon, pl, &rv, 0); |
497 | |
500 | |
498 | if (rv.distance < mindiff) |
501 | if (rv.distance < mindiff) |
499 | return 0; |
502 | return 0; |
… | |
… | |
765 | player *pl = op->contr; |
768 | player *pl = op->contr; |
766 | shstr name = op->name; |
769 | shstr name = op->name; |
767 | |
770 | |
768 | op->contr = 0; |
771 | op->contr = 0; |
769 | op->type = 0; |
772 | op->type = 0; |
770 | op->free (1); |
773 | op->destroy (1); |
771 | pl = get_player (pl); |
774 | pl = get_player (pl); |
772 | op = pl->ob; |
775 | op = pl->ob; |
773 | add_friendly_object (op); |
776 | add_friendly_object (op); |
774 | op->contr->password[0] = '~'; |
777 | op->contr->password[0] = '~'; |
775 | op->name = op->name_pl = 0; |
778 | op->name = op->name_pl = 0; |
… | |
… | |
1180 | if (settings.set_title == TRUE) |
1183 | if (settings.set_title == TRUE) |
1181 | op->contr->own_title[0] = '\0'; |
1184 | op->contr->own_title[0] = '\0'; |
1182 | |
1185 | |
1183 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1186 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1184 | { |
1187 | { |
1185 | mapstruct *mp, *next; |
1188 | maptile *mp, *next; |
1186 | |
1189 | |
1187 | /* We need to hunt for any per player unique maps in memory and |
1190 | /* We need to hunt for any per player unique maps in memory and |
1188 | * get rid of them. The trailing slash in the path is intentional, |
1191 | * get rid of them. The trailing slash in the path is intentional, |
1189 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1192 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1190 | */ |
1193 | */ |
… | |
… | |
1264 | */ |
1267 | */ |
1265 | int |
1268 | int |
1266 | check_pick (object *op) |
1269 | check_pick (object *op) |
1267 | { |
1270 | { |
1268 | object *tmp, *next; |
1271 | object *tmp, *next; |
1269 | tag_t next_tag = 0, op_tag; |
|
|
1270 | int stop = 0; |
1272 | int stop = 0; |
1271 | int j, k, wvratio; |
1273 | int j, k, wvratio; |
1272 | char putstring[128], tmpstr[16]; |
1274 | char putstring[128], tmpstr[16]; |
1273 | |
1275 | |
1274 | |
|
|
1275 | /* if you're flying, you cna't pick up anything */ |
1276 | /* if you're flying, you cna't pick up anything */ |
1276 | if (op->move_type & MOVE_FLYING) |
1277 | if (op->move_type & MOVE_FLYING) |
1277 | return 1; |
1278 | return 1; |
1278 | |
1279 | |
1279 | op_tag = op->count; |
|
|
1280 | |
|
|
1281 | next = op->below; |
1280 | next = op->below; |
1282 | if (next) |
|
|
1283 | next_tag = next->count; |
|
|
1284 | |
1281 | |
1285 | /* loop while there are items on the floor that are not marked as |
1282 | /* loop while there are items on the floor that are not marked as |
1286 | * destroyed */ |
1283 | * destroyed */ |
1287 | while (next && !was_destroyed (next, next_tag)) |
1284 | while (next && !next->destroyed ()) |
1288 | { |
1285 | { |
1289 | tmp = next; |
1286 | tmp = next; |
1290 | next = tmp->below; |
1287 | next = tmp->below; |
1291 | if (next) |
|
|
1292 | next_tag = next->count; |
|
|
1293 | |
1288 | |
1294 | if (was_destroyed (op, op_tag)) |
1289 | if (op->destroyed ()) |
1295 | return 0; |
1290 | return 0; |
1296 | |
1291 | |
1297 | if (!can_pick (op, tmp)) |
1292 | if (!can_pick (op, tmp)) |
1298 | continue; |
1293 | continue; |
1299 | |
1294 | |
… | |
… | |
1431 | /* question: don't pick up known-poisonous stuff? */ |
1426 | /* question: don't pick up known-poisonous stuff? */ |
1432 | if (op->contr->mode & PU_FOOD) |
1427 | if (op->contr->mode & PU_FOOD) |
1433 | if (tmp->type == FOOD) |
1428 | if (tmp->type == FOOD) |
1434 | { |
1429 | { |
1435 | pick_up (op, tmp); |
1430 | pick_up (op, tmp); |
1436 | if (0) |
|
|
1437 | fprintf (stderr, "FOOD\n"); |
|
|
1438 | continue; |
1431 | continue; |
1439 | } |
1432 | } |
|
|
1433 | |
1440 | if (op->contr->mode & PU_DRINK) |
1434 | if (op->contr->mode & PU_DRINK) |
1441 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1435 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1442 | { |
1436 | { |
1443 | pick_up (op, tmp); |
1437 | pick_up (op, tmp); |
1444 | if (0) |
|
|
1445 | fprintf (stderr, "DRINK\n"); |
|
|
1446 | continue; |
1438 | continue; |
1447 | } |
1439 | } |
1448 | |
1440 | |
1449 | if (op->contr->mode & PU_POTION) |
1441 | if (op->contr->mode & PU_POTION) |
1450 | if (tmp->type == POTION) |
1442 | if (tmp->type == POTION) |
1451 | { |
1443 | { |
1452 | pick_up (op, tmp); |
1444 | pick_up (op, tmp); |
1453 | if (0) |
|
|
1454 | fprintf (stderr, "POTION\n"); |
|
|
1455 | continue; |
1445 | continue; |
1456 | } |
1446 | } |
1457 | |
1447 | |
1458 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1448 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1459 | if (op->contr->mode & PU_SPELLBOOK) |
1449 | if (op->contr->mode & PU_SPELLBOOK) |
1460 | if (tmp->type == SPELLBOOK) |
1450 | if (tmp->type == SPELLBOOK) |
1461 | { |
1451 | { |
1462 | pick_up (op, tmp); |
1452 | pick_up (op, tmp); |
1463 | if (0) |
|
|
1464 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1465 | continue; |
1453 | continue; |
1466 | } |
1454 | } |
|
|
1455 | |
1467 | if (op->contr->mode & PU_SKILLSCROLL) |
1456 | if (op->contr->mode & PU_SKILLSCROLL) |
1468 | if (tmp->type == SKILLSCROLL) |
1457 | if (tmp->type == SKILLSCROLL) |
1469 | { |
1458 | { |
1470 | pick_up (op, tmp); |
1459 | pick_up (op, tmp); |
1471 | if (0) |
|
|
1472 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1473 | continue; |
1460 | continue; |
1474 | } |
1461 | } |
|
|
1462 | |
1475 | if (op->contr->mode & PU_READABLES) |
1463 | if (op->contr->mode & PU_READABLES) |
1476 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1464 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1477 | { |
1465 | { |
1478 | pick_up (op, tmp); |
1466 | pick_up (op, tmp); |
1479 | if (0) |
|
|
1480 | fprintf (stderr, "READABLES\n"); |
|
|
1481 | continue; |
1467 | continue; |
1482 | } |
1468 | } |
1483 | |
1469 | |
1484 | /* wands/staves/rods/horns */ |
1470 | /* wands/staves/rods/horns */ |
1485 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1471 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1486 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1472 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1487 | { |
1473 | { |
1488 | pick_up (op, tmp); |
1474 | pick_up (op, tmp); |
1489 | if (0) |
|
|
1490 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1491 | continue; |
1475 | continue; |
1492 | } |
1476 | } |
1493 | |
1477 | |
1494 | /* pick up all magical items */ |
1478 | /* pick up all magical items */ |
1495 | if (op->contr->mode & PU_MAGICAL) |
1479 | if (op->contr->mode & PU_MAGICAL) |
1496 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1480 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1497 | { |
1481 | { |
1498 | pick_up (op, tmp); |
1482 | pick_up (op, tmp); |
1499 | if (0) |
|
|
1500 | fprintf (stderr, "MAGICAL\n"); |
|
|
1501 | continue; |
1483 | continue; |
1502 | } |
1484 | } |
1503 | |
1485 | |
1504 | if (op->contr->mode & PU_VALUABLES) |
1486 | if (op->contr->mode & PU_VALUABLES) |
1505 | { |
1487 | { |
1506 | if (tmp->type == MONEY || tmp->type == GEM) |
1488 | if (tmp->type == MONEY || tmp->type == GEM) |
1507 | { |
1489 | { |
1508 | pick_up (op, tmp); |
1490 | pick_up (op, tmp); |
1509 | if (0) |
|
|
1510 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1511 | continue; |
1491 | continue; |
1512 | } |
1492 | } |
1513 | } |
1493 | } |
1514 | |
1494 | |
1515 | /* rings & amulets - talismans seems to be typed AMULET */ |
1495 | /* rings & amulets - talismans seems to be typed AMULET */ |
1516 | if (op->contr->mode & PU_JEWELS) |
1496 | if (op->contr->mode & PU_JEWELS) |
1517 | if (tmp->type == RING || tmp->type == AMULET) |
1497 | if (tmp->type == RING || tmp->type == AMULET) |
1518 | { |
1498 | { |
1519 | pick_up (op, tmp); |
1499 | pick_up (op, tmp); |
|
|
1500 | continue; |
1520 | if (0) |
1501 | } |
1521 | fprintf (stderr, "JEWELS\n"); |
1502 | |
|
|
1503 | /* we don't forget dragon food */ |
|
|
1504 | if (op->contr->mode & PU_FLESH) |
|
|
1505 | if (tmp->type == FLESH) |
|
|
1506 | { |
|
|
1507 | pick_up (op, tmp); |
1522 | continue; |
1508 | continue; |
1523 | } |
1509 | } |
1524 | |
1510 | |
1525 | /* bows and arrows. Bows are good for selling! */ |
1511 | /* bows and arrows. Bows are good for selling! */ |
1526 | if (op->contr->mode & PU_BOW) |
1512 | if (op->contr->mode & PU_BOW) |
1527 | if (tmp->type == BOW) |
1513 | if (tmp->type == BOW) |
1528 | { |
1514 | { |
1529 | pick_up (op, tmp); |
1515 | pick_up (op, tmp); |
1530 | if (0) |
|
|
1531 | fprintf (stderr, "BOW\n"); |
|
|
1532 | continue; |
1516 | continue; |
1533 | } |
1517 | } |
|
|
1518 | |
1534 | if (op->contr->mode & PU_ARROW) |
1519 | if (op->contr->mode & PU_ARROW) |
1535 | if (tmp->type == ARROW) |
1520 | if (tmp->type == ARROW) |
1536 | { |
1521 | { |
1537 | pick_up (op, tmp); |
1522 | pick_up (op, tmp); |
1538 | if (0) |
|
|
1539 | fprintf (stderr, "ARROW\n"); |
|
|
1540 | continue; |
1523 | continue; |
1541 | } |
1524 | } |
1542 | |
1525 | |
1543 | /* all kinds of armor etc. */ |
1526 | /* all kinds of armor etc. */ |
1544 | if (op->contr->mode & PU_ARMOUR) |
1527 | if (op->contr->mode & PU_ARMOUR) |
1545 | if (tmp->type == ARMOUR) |
1528 | if (tmp->type == ARMOUR) |
1546 | { |
1529 | { |
1547 | pick_up (op, tmp); |
1530 | pick_up (op, tmp); |
1548 | if (0) |
|
|
1549 | fprintf (stderr, "ARMOUR\n"); |
|
|
1550 | continue; |
1531 | continue; |
1551 | } |
1532 | } |
|
|
1533 | |
1552 | if (op->contr->mode & PU_HELMET) |
1534 | if (op->contr->mode & PU_HELMET) |
1553 | if (tmp->type == HELMET) |
1535 | if (tmp->type == HELMET) |
1554 | { |
1536 | { |
1555 | pick_up (op, tmp); |
1537 | pick_up (op, tmp); |
1556 | if (0) |
|
|
1557 | fprintf (stderr, "HELMET\n"); |
|
|
1558 | continue; |
1538 | continue; |
1559 | } |
1539 | } |
|
|
1540 | |
1560 | if (op->contr->mode & PU_SHIELD) |
1541 | if (op->contr->mode & PU_SHIELD) |
1561 | if (tmp->type == SHIELD) |
1542 | if (tmp->type == SHIELD) |
1562 | { |
1543 | { |
1563 | pick_up (op, tmp); |
1544 | pick_up (op, tmp); |
1564 | if (0) |
|
|
1565 | fprintf (stderr, "SHIELD\n"); |
|
|
1566 | continue; |
1545 | continue; |
1567 | } |
1546 | } |
|
|
1547 | |
1568 | if (op->contr->mode & PU_BOOTS) |
1548 | if (op->contr->mode & PU_BOOTS) |
1569 | if (tmp->type == BOOTS) |
1549 | if (tmp->type == BOOTS) |
1570 | { |
1550 | { |
1571 | pick_up (op, tmp); |
1551 | pick_up (op, tmp); |
1572 | if (0) |
|
|
1573 | fprintf (stderr, "BOOTS\n"); |
|
|
1574 | continue; |
1552 | continue; |
1575 | } |
1553 | } |
|
|
1554 | |
1576 | if (op->contr->mode & PU_GLOVES) |
1555 | if (op->contr->mode & PU_GLOVES) |
1577 | if (tmp->type == GLOVES) |
1556 | if (tmp->type == GLOVES) |
1578 | { |
1557 | { |
1579 | pick_up (op, tmp); |
1558 | pick_up (op, tmp); |
1580 | if (0) |
|
|
1581 | fprintf (stderr, "GLOVES\n"); |
|
|
1582 | continue; |
1559 | continue; |
1583 | } |
1560 | } |
|
|
1561 | |
1584 | if (op->contr->mode & PU_CLOAK) |
1562 | if (op->contr->mode & PU_CLOAK) |
1585 | if (tmp->type == CLOAK) |
1563 | if (tmp->type == CLOAK) |
1586 | { |
1564 | { |
1587 | pick_up (op, tmp); |
1565 | pick_up (op, tmp); |
1588 | if (0) |
|
|
1589 | fprintf (stderr, "GLOVES\n"); |
|
|
1590 | continue; |
1566 | continue; |
1591 | } |
1567 | } |
1592 | |
1568 | |
1593 | /* hoping to catch throwing daggers here */ |
1569 | /* hoping to catch throwing daggers here */ |
1594 | if (op->contr->mode & PU_MISSILEWEAPON) |
1570 | if (op->contr->mode & PU_MISSILEWEAPON) |
1595 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1571 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1596 | { |
1572 | { |
1597 | pick_up (op, tmp); |
1573 | pick_up (op, tmp); |
1598 | if (0) |
|
|
1599 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1600 | continue; |
1574 | continue; |
1601 | } |
1575 | } |
1602 | |
1576 | |
1603 | /* careful: chairs and tables are weapons! */ |
1577 | /* careful: chairs and tables are weapons! */ |
1604 | if (op->contr->mode & PU_ALLWEAPON) |
1578 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1607 | { |
1581 | { |
1608 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1582 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1609 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1583 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1610 | { |
1584 | { |
1611 | pick_up (op, tmp); |
1585 | pick_up (op, tmp); |
1612 | if (0) |
|
|
1613 | fprintf (stderr, "WEAPON\n"); |
|
|
1614 | continue; |
1586 | continue; |
1615 | } |
1587 | } |
1616 | } |
1588 | } |
|
|
1589 | |
1617 | if (tmp->type == WEAPON && tmp->name == NULL) |
1590 | if (tmp->type == WEAPON && tmp->name == NULL) |
1618 | { |
1591 | { |
1619 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1592 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1620 | { |
1593 | { |
1621 | pick_up (op, tmp); |
1594 | pick_up (op, tmp); |
1622 | if (0) |
|
|
1623 | fprintf (stderr, "WEAPON\n"); |
|
|
1624 | continue; |
1595 | continue; |
1625 | } |
1596 | } |
1626 | } |
1597 | } |
1627 | } |
1598 | } |
1628 | |
1599 | |
1629 | /* misc stuff that's useful */ |
1600 | /* misc stuff that's useful */ |
1630 | if (op->contr->mode & PU_KEY) |
1601 | if (op->contr->mode & PU_KEY) |
1631 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1602 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1632 | { |
1603 | { |
1633 | pick_up (op, tmp); |
1604 | pick_up (op, tmp); |
1634 | if (0) |
|
|
1635 | fprintf (stderr, "KEY\n"); |
|
|
1636 | continue; |
1605 | continue; |
1637 | } |
1606 | } |
1638 | |
1607 | |
1639 | /* any of the last 4 bits set means we use the ratio for value |
1608 | /* any of the last 4 bits set means we use the ratio for value |
1640 | * pickups */ |
1609 | * pickups */ |
… | |
… | |
1662 | continue; |
1631 | continue; |
1663 | } |
1632 | } |
1664 | } |
1633 | } |
1665 | } /* the new pickup model */ |
1634 | } /* the new pickup model */ |
1666 | } |
1635 | } |
|
|
1636 | |
1667 | return !stop; |
1637 | return !stop; |
1668 | } |
1638 | } |
1669 | |
1639 | |
1670 | /* |
1640 | /* |
1671 | * Find an arrow in the inventory and after that |
1641 | * Find an arrow in the inventory and after that |
… | |
… | |
1770 | |
1740 | |
1771 | object * |
1741 | object * |
1772 | pick_arrow_target (object *op, const char *type, int dir) |
1742 | pick_arrow_target (object *op, const char *type, int dir) |
1773 | { |
1743 | { |
1774 | object *tmp = NULL; |
1744 | object *tmp = NULL; |
1775 | mapstruct *m; |
1745 | maptile *m; |
1776 | int i, mflags, found, number; |
1746 | int i, mflags, found, number; |
1777 | sint16 x, y; |
1747 | sint16 x, y; |
1778 | |
1748 | |
1779 | if (op->map == NULL) |
1749 | if (op->map == NULL) |
1780 | return find_arrow (op, type); |
1750 | return find_arrow (op, type); |
… | |
… | |
1840 | */ |
1810 | */ |
1841 | int |
1811 | int |
1842 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1812 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1843 | { |
1813 | { |
1844 | object *left, *bow; |
1814 | object *left, *bow; |
1845 | tag_t left_tag, tag; |
|
|
1846 | int bowspeed, mflags; |
1815 | int bowspeed, mflags; |
1847 | mapstruct *m; |
1816 | maptile *m; |
1848 | |
1817 | |
1849 | if (!dir) |
1818 | if (!dir) |
1850 | { |
1819 | { |
1851 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1820 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1852 | return 0; |
1821 | return 0; |
… | |
… | |
1912 | free_object (arrow); |
1881 | free_object (arrow); |
1913 | return 0; |
1882 | return 0; |
1914 | } |
1883 | } |
1915 | |
1884 | |
1916 | left = arrow; /* these are arrows left to the player */ |
1885 | left = arrow; /* these are arrows left to the player */ |
1917 | left_tag = left->count; |
|
|
1918 | arrow = get_split_ob (arrow, 1); |
1886 | arrow = get_split_ob (arrow, 1); |
1919 | if (arrow == NULL) |
1887 | if (arrow == NULL) |
1920 | { |
1888 | { |
1921 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1889 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1922 | return 0; |
1890 | return 0; |
… | |
… | |
1965 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1933 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1966 | } |
1934 | } |
1967 | else |
1935 | else |
1968 | { |
1936 | { |
1969 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1937 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1970 | |
|
|
1971 | arrow->level = op->level; |
1938 | arrow->level = op->level; |
1972 | } |
1939 | } |
|
|
1940 | |
1973 | if (arrow->attacktype == AT_PHYSICAL) |
1941 | if (arrow->attacktype == AT_PHYSICAL) |
1974 | arrow->attacktype |= bow->attacktype; |
1942 | arrow->attacktype |= bow->attacktype; |
|
|
1943 | |
1975 | if (bow->slaying != NULL) |
1944 | if (bow->slaying != NULL) |
1976 | arrow->slaying = bow->slaying; |
1945 | arrow->slaying = bow->slaying; |
1977 | |
1946 | |
1978 | arrow->map = m; |
1947 | arrow->map = m; |
1979 | arrow->move_type = MOVE_FLY_LOW; |
1948 | arrow->move_type = MOVE_FLY_LOW; |
1980 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1949 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1981 | |
1950 | |
1982 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1951 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1983 | tag = arrow->count; |
|
|
1984 | insert_ob_in_map (arrow, m, op, 0); |
1952 | insert_ob_in_map (arrow, m, op, 0); |
1985 | |
1953 | |
1986 | if (!was_destroyed (arrow, tag)) |
1954 | if (!arrow->destroyed ()) |
1987 | move_arrow (arrow); |
1955 | move_arrow (arrow); |
1988 | |
1956 | |
1989 | if (op->type == PLAYER) |
1957 | if (op->type == PLAYER) |
1990 | { |
1958 | { |
1991 | if (was_destroyed (left, left_tag)) |
1959 | if (left->destroyed ()) |
1992 | esrv_del_item (op->contr, left_tag); |
1960 | esrv_del_item (op->contr, left->count); |
1993 | else |
1961 | else |
1994 | esrv_send_item (op, left); |
1962 | esrv_send_item (op, left); |
1995 | } |
1963 | } |
|
|
1964 | |
1996 | return 1; |
1965 | return 1; |
1997 | } |
1966 | } |
1998 | |
1967 | |
1999 | /* Special fire code for players - this takes into |
1968 | /* Special fire code for players - this takes into |
2000 | * account the special fire modes players can have |
1969 | * account the special fire modes players can have |
… | |
… | |
2312 | move_player_attack (object *op, int dir) |
2281 | move_player_attack (object *op, int dir) |
2313 | { |
2282 | { |
2314 | object *tmp, *mon; |
2283 | object *tmp, *mon; |
2315 | sint16 nx, ny; |
2284 | sint16 nx, ny; |
2316 | int on_battleground; |
2285 | int on_battleground; |
2317 | mapstruct *m; |
2286 | maptile *m; |
2318 | |
2287 | |
2319 | nx = freearr_x[dir] + op->x; |
2288 | nx = freearr_x[dir] + op->x; |
2320 | ny = freearr_y[dir] + op->y; |
2289 | ny = freearr_y[dir] + op->y; |
2321 | |
2290 | |
2322 | on_battleground = op_on_battleground (op, NULL, NULL); |
2291 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2358 | if (tmp == op) |
2327 | if (tmp == op) |
2359 | { |
2328 | { |
2360 | tmp = tmp->above; |
2329 | tmp = tmp->above; |
2361 | continue; |
2330 | continue; |
2362 | } |
2331 | } |
|
|
2332 | |
2363 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2333 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2364 | { |
2334 | { |
2365 | mon = tmp; |
2335 | mon = tmp; |
2366 | break; |
2336 | break; |
2367 | } |
2337 | } |
|
|
2338 | |
2368 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2339 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2369 | mon = tmp; |
2340 | mon = tmp; |
|
|
2341 | |
2370 | tmp = tmp->above; |
2342 | tmp = tmp->above; |
2371 | } |
2343 | } |
2372 | |
2344 | |
2373 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2345 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2374 | return; /* into a wall */ |
2346 | return; /* into a wall */ |
… | |
… | |
2952 | { |
2924 | { |
2953 | char buf[MAX_BUF]; |
2925 | char buf[MAX_BUF]; |
2954 | int x, y; |
2926 | int x, y; |
2955 | |
2927 | |
2956 | //int i; |
2928 | //int i; |
2957 | mapstruct *map; /* this is for resurrection */ |
2929 | maptile *map; /* this is for resurrection */ |
2958 | |
2930 | |
2959 | /* int z; |
2931 | /* int z; |
2960 | int num_stats_lose; |
2932 | int num_stats_lose; |
2961 | int lost_a_stat; |
2933 | int lost_a_stat; |
2962 | int lose_this_stat; |
2934 | int lose_this_stat; |
… | |
… | |
3178 | /* determine_god() seems to not work sometimes... why is this? |
3150 | /* determine_god() seems to not work sometimes... why is this? |
3179 | Should I be using something else? GD */ |
3151 | Should I be using something else? GD */ |
3180 | const char *god = determine_god (op); |
3152 | const char *god = determine_god (op); |
3181 | |
3153 | |
3182 | if (god && (strcmp (god, "none"))) |
3154 | if (god && (strcmp (god, "none"))) |
3183 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); |
3155 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3184 | else |
3156 | else |
3185 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); |
3157 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
3186 | } |
3158 | } |
|
|
3159 | #else |
|
|
3160 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3187 | #endif |
3161 | #endif |
3188 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3189 | |
3162 | |
3190 | /* Put a gravestone up where the character 'almost' died. List the |
3163 | /* Put a gravestone up where the character 'almost' died. List the |
3191 | * exp loss on the stone. |
3164 | * exp loss on the stone. |
3192 | */ |
3165 | */ |
3193 | tmp = arch_to_object (archetype::find ("gravestone")); |
3166 | tmp = arch_to_object (archetype::find ("gravestone")); |
… | |
… | |
3198 | 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); |
3171 | 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); |
3199 | tmp->msg = buf; |
3172 | tmp->msg = buf; |
3200 | tmp->x = op->x, tmp->y = op->y; |
3173 | tmp->x = op->x, tmp->y = op->y; |
3201 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3174 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3202 | |
3175 | |
3203 | /**************************************/ |
3176 | /**************************************/ |
3204 | /* */ |
3177 | /* */ |
3205 | /* Subtract the experience points, */ |
3178 | /* Subtract the experience points, */ |
3206 | /* if we died cause of food, give us */ |
3179 | /* if we died cause of food, give us */ |
3207 | /* food, and reset HP's... */ |
3180 | /* food, and reset HP's... */ |
3208 | /* */ |
3181 | /* */ |
3209 | |
|
|
3210 | /**************************************/ |
3182 | /**************************************/ |
3211 | |
3183 | |
3212 | /* remove any poisoning and confusion the character may be suffering. */ |
3184 | /* remove any poisoning and confusion the character may be suffering. */ |
3213 | /* restore player */ |
3185 | /* restore player */ |
3214 | at = archetype::find ("poisoning"); |
3186 | at = archetype::find ("poisoning"); |
3215 | tmp = present_arch_in_ob (at, op); |
3187 | tmp = present_arch_in_ob (at, op); |
… | |
… | |
3226 | { |
3198 | { |
3227 | remove_ob (tmp); |
3199 | remove_ob (tmp); |
3228 | free_object (tmp); |
3200 | free_object (tmp); |
3229 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3201 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3230 | } |
3202 | } |
|
|
3203 | |
3231 | cure_disease (op, 0); /* remove any disease */ |
3204 | cure_disease (op, 0); /* remove any disease */ |
3232 | |
3205 | |
3233 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3206 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3234 | apply_death_exp_penalty (op); |
3207 | apply_death_exp_penalty (op); |
3235 | if (op->stats.food < 100) |
3208 | if (op->stats.food < 100) |
… | |
… | |
3245 | */ |
3218 | */ |
3246 | |
3219 | |
3247 | if (is_in_shop (op)) |
3220 | if (is_in_shop (op)) |
3248 | remove_unpaid_objects (op->inv, op); |
3221 | remove_unpaid_objects (op->inv, op); |
3249 | |
3222 | |
3250 | /****************************************/ |
3223 | /****************************************/ |
3251 | /* */ |
3224 | /* */ |
3252 | /* Move player to his current respawn- */ |
3225 | /* Move player to his current respawn- */ |
3253 | /* position (usually last savebed) */ |
3226 | /* position (usually last savebed) */ |
3254 | /* */ |
3227 | /* */ |
3255 | |
|
|
3256 | /****************************************/ |
3228 | /****************************************/ |
3257 | |
3229 | |
3258 | enter_player_savebed (op); |
3230 | enter_player_savebed (op); |
3259 | |
3231 | |
3260 | /* Save the player before inserting the force to reduce |
3232 | /* Save the player before inserting the force to reduce |
3261 | * chance of abuse. |
3233 | * chance of abuse. |
… | |
… | |
3268 | * spell effects. So first see if there is a spell effect |
3240 | * spell effects. So first see if there is a spell effect |
3269 | * on the space that might harm the player. |
3241 | * on the space that might harm the player. |
3270 | */ |
3242 | */ |
3271 | will_kill_again = 0; |
3243 | will_kill_again = 0; |
3272 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3244 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3273 | { |
|
|
3274 | if (tmp->type == SPELL_EFFECT) |
3245 | if (tmp->type == SPELL_EFFECT) |
3275 | will_kill_again |= tmp->attacktype; |
3246 | will_kill_again |= tmp->attacktype; |
3276 | } |
3247 | |
3277 | if (will_kill_again) |
3248 | if (will_kill_again) |
3278 | { |
3249 | { |
3279 | object *force; |
3250 | object *force; |
3280 | int at; |
3251 | int at; |
3281 | |
3252 | |
… | |
… | |
3283 | /* 50 ticks should be enough time for the spell to abate */ |
3254 | /* 50 ticks should be enough time for the spell to abate */ |
3284 | force->speed = 0.1; |
3255 | force->speed = 0.1; |
3285 | force->speed_left = -5.0; |
3256 | force->speed_left = -5.0; |
3286 | SET_FLAG (force, FLAG_APPLIED); |
3257 | SET_FLAG (force, FLAG_APPLIED); |
3287 | for (at = 0; at < NROFATTACKS; at++) |
3258 | for (at = 0; at < NROFATTACKS; at++) |
3288 | { |
|
|
3289 | if (will_kill_again & (1 << at)) |
3259 | if (will_kill_again & (1 << at)) |
3290 | force->resist[at] = 100; |
3260 | force->resist[at] = 100; |
3291 | } |
3261 | |
3292 | insert_ob_in_ob (force, op); |
3262 | insert_ob_in_ob (force, op); |
3293 | fix_player (op); |
3263 | fix_player (op); |
3294 | |
3264 | |
3295 | } |
3265 | } |
3296 | |
3266 | |
… | |
… | |
3596 | int |
3566 | int |
3597 | stand_near_hostile (object *who) |
3567 | stand_near_hostile (object *who) |
3598 | { |
3568 | { |
3599 | object *tmp = NULL; |
3569 | object *tmp = NULL; |
3600 | int i, friendly = 0, player = 0, mflags; |
3570 | int i, friendly = 0, player = 0, mflags; |
3601 | mapstruct *m; |
3571 | maptile *m; |
3602 | sint16 x, y; |
3572 | sint16 x, y; |
3603 | |
3573 | |
3604 | if (!who) |
3574 | if (!who) |
3605 | return 0; |
3575 | return 0; |
3606 | |
3576 | |