… | |
… | |
20 | |
20 | |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #ifndef WIN32 /* ---win32 remove headers */ |
|
|
26 | # include <pwd.h> |
25 | #include <pwd.h> |
27 | #endif |
|
|
28 | #ifndef __CEXTRACT__ |
26 | #ifndef __CEXTRACT__ |
29 | # include <sproto.h> |
27 | # include <sproto.h> |
30 | #endif |
28 | #endif |
31 | #include <sounds.h> |
29 | #include <sounds.h> |
32 | #include <living.h> |
30 | #include <living.h> |
… | |
… | |
646 | (op->type == ARMOUR || op->type == BOOTS || |
644 | (op->type == ARMOUR || op->type == BOOTS || |
647 | op->type == CLOAK || op->type == HELMET || |
645 | op->type == CLOAK || op->type == HELMET || |
648 | op->type == SHIELD || op->type == GLOVES || |
646 | op->type == SHIELD || op->type == GLOVES || |
649 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
647 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
650 | { |
648 | { |
651 | remove_ob (op); |
649 | op->destroy (); |
652 | free_object (op); |
|
|
653 | continue; |
650 | continue; |
654 | } |
651 | } |
655 | } |
652 | } |
656 | |
653 | |
657 | /* This really needs to be better - we should really give |
654 | /* This really needs to be better - we should really give |
… | |
… | |
668 | if (tmp->type == op->type && tmp->name == op->name) |
665 | if (tmp->type == op->type && tmp->name == op->name) |
669 | break; |
666 | break; |
670 | |
667 | |
671 | if (tmp) |
668 | if (tmp) |
672 | { |
669 | { |
673 | remove_ob (op); |
670 | op->destroy (); |
674 | free_object (op); |
|
|
675 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
671 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
676 | continue; |
672 | continue; |
677 | } |
673 | } |
|
|
674 | |
678 | if (op->nrof > 1) |
675 | if (op->nrof > 1) |
679 | op->nrof = 1; |
676 | op->nrof = 1; |
680 | } |
677 | } |
681 | |
678 | |
682 | if (op->type == SPELLBOOK && op->inv) |
679 | if (op->type == SPELLBOOK && op->inv) |
… | |
… | |
694 | CLEAR_FLAG (op, FLAG_CURSED); |
691 | CLEAR_FLAG (op, FLAG_CURSED); |
695 | CLEAR_FLAG (op, FLAG_DAMNED); |
692 | CLEAR_FLAG (op, FLAG_DAMNED); |
696 | } |
693 | } |
697 | if (op->type == SPELL) |
694 | if (op->type == SPELL) |
698 | { |
695 | { |
699 | remove_ob (op); |
696 | op->destroy (); |
700 | free_object (op); |
|
|
701 | continue; |
697 | continue; |
702 | } |
698 | } |
703 | else if (op->type == SKILL) |
699 | else if (op->type == SKILL) |
704 | { |
700 | { |
705 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
701 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
… | |
… | |
744 | * removing the player - it probably makes more sense |
740 | * removing the player - it probably makes more sense |
745 | * to leave it to play_again to remove the object in all |
741 | * to leave it to play_again to remove the object in all |
746 | * cases. |
742 | * cases. |
747 | */ |
743 | */ |
748 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
744 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
749 | remove_ob (op); |
745 | op->remove (); |
750 | /* Need to set this to null - otherwise, it could point to garbage, |
746 | /* Need to set this to null - otherwise, it could point to garbage, |
751 | * and draw() doesn't check to see if the player is removed, only if |
747 | * and draw() doesn't check to see if the player is removed, only if |
752 | * the map is null or not swapped out. |
748 | * the map is null or not swapped out. |
753 | */ |
749 | */ |
754 | op->map = NULL; |
750 | op->map = NULL; |
… | |
… | |
1054 | { |
1050 | { |
1055 | int tmp_loop; |
1051 | int tmp_loop; |
1056 | |
1052 | |
1057 | if (key == 'q' || key == 'Q') |
1053 | if (key == 'q' || key == 'Q') |
1058 | { |
1054 | { |
1059 | remove_ob (op); |
1055 | op->remove (); |
1060 | play_again (op); |
1056 | play_again (op); |
1061 | return 0; |
1057 | return 0; |
1062 | } |
1058 | } |
1063 | if (key == 'd' || key == 'D') |
1059 | if (key == 'd' || key == 'D') |
1064 | { |
1060 | { |
… | |
… | |
1099 | { |
1095 | { |
1100 | object *tmp; |
1096 | object *tmp; |
1101 | char mapname[MAX_BUF]; |
1097 | char mapname[MAX_BUF]; |
1102 | |
1098 | |
1103 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1099 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1104 | tmp = get_object (); |
1100 | tmp = object::create (); |
1105 | EXIT_PATH (tmp) = mapname; |
1101 | EXIT_PATH (tmp) = mapname; |
1106 | EXIT_X (tmp) = op->x; |
1102 | EXIT_X (tmp) = op->x; |
1107 | EXIT_Y (tmp) = op->y; |
1103 | EXIT_Y (tmp) = op->y; |
1108 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1104 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1109 | * if the map isn't there, then stay on the |
1105 | * if the map isn't there, then stay on the |
1110 | * default initial map */ |
1106 | * default initial map */ |
1111 | free_object (tmp); |
1107 | tmp->destroy (); |
1112 | } |
1108 | } |
1113 | else |
1109 | else |
1114 | { |
1110 | { |
1115 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1111 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1116 | } |
1112 | } |
… | |
… | |
1126 | { |
1122 | { |
1127 | shstr name = op->name; |
1123 | shstr name = op->name; |
1128 | int x = op->x, y = op->y; |
1124 | int x = op->x, y = op->y; |
1129 | |
1125 | |
1130 | remove_statbonus (op); |
1126 | remove_statbonus (op); |
1131 | remove_ob (op); |
1127 | op->remove (); |
1132 | op->arch = get_player_archetype (op->arch); |
1128 | op->arch = get_player_archetype (op->arch); |
1133 | copy_object (&op->arch->clone, op); |
1129 | op->arch->clone.copy_to (op); |
1134 | op->instantiate (); |
1130 | op->instantiate (); |
1135 | op->stats = op->contr->orig_stats; |
1131 | op->stats = op->contr->orig_stats; |
1136 | op->name = op->name_pl = name; |
1132 | op->name = op->name_pl = name; |
1137 | op->x = x; |
1133 | op->x = x; |
1138 | op->y = y; |
1134 | op->y = y; |
… | |
… | |
1426 | /* question: don't pick up known-poisonous stuff? */ |
1422 | /* question: don't pick up known-poisonous stuff? */ |
1427 | if (op->contr->mode & PU_FOOD) |
1423 | if (op->contr->mode & PU_FOOD) |
1428 | if (tmp->type == FOOD) |
1424 | if (tmp->type == FOOD) |
1429 | { |
1425 | { |
1430 | pick_up (op, tmp); |
1426 | pick_up (op, tmp); |
1431 | if (0) |
|
|
1432 | fprintf (stderr, "FOOD\n"); |
|
|
1433 | continue; |
1427 | continue; |
1434 | } |
1428 | } |
|
|
1429 | |
1435 | if (op->contr->mode & PU_DRINK) |
1430 | if (op->contr->mode & PU_DRINK) |
1436 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1431 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1437 | { |
1432 | { |
1438 | pick_up (op, tmp); |
1433 | pick_up (op, tmp); |
1439 | if (0) |
|
|
1440 | fprintf (stderr, "DRINK\n"); |
|
|
1441 | continue; |
1434 | continue; |
1442 | } |
1435 | } |
1443 | |
1436 | |
1444 | if (op->contr->mode & PU_POTION) |
1437 | if (op->contr->mode & PU_POTION) |
1445 | if (tmp->type == POTION) |
1438 | if (tmp->type == POTION) |
1446 | { |
1439 | { |
1447 | pick_up (op, tmp); |
1440 | pick_up (op, tmp); |
1448 | if (0) |
|
|
1449 | fprintf (stderr, "POTION\n"); |
|
|
1450 | continue; |
1441 | continue; |
1451 | } |
1442 | } |
1452 | |
1443 | |
1453 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1444 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1454 | if (op->contr->mode & PU_SPELLBOOK) |
1445 | if (op->contr->mode & PU_SPELLBOOK) |
1455 | if (tmp->type == SPELLBOOK) |
1446 | if (tmp->type == SPELLBOOK) |
1456 | { |
1447 | { |
1457 | pick_up (op, tmp); |
1448 | pick_up (op, tmp); |
1458 | if (0) |
|
|
1459 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1460 | continue; |
1449 | continue; |
1461 | } |
1450 | } |
|
|
1451 | |
1462 | if (op->contr->mode & PU_SKILLSCROLL) |
1452 | if (op->contr->mode & PU_SKILLSCROLL) |
1463 | if (tmp->type == SKILLSCROLL) |
1453 | if (tmp->type == SKILLSCROLL) |
1464 | { |
1454 | { |
1465 | pick_up (op, tmp); |
1455 | pick_up (op, tmp); |
1466 | if (0) |
|
|
1467 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1468 | continue; |
1456 | continue; |
1469 | } |
1457 | } |
|
|
1458 | |
1470 | if (op->contr->mode & PU_READABLES) |
1459 | if (op->contr->mode & PU_READABLES) |
1471 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1460 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1472 | { |
1461 | { |
1473 | pick_up (op, tmp); |
1462 | pick_up (op, tmp); |
1474 | if (0) |
|
|
1475 | fprintf (stderr, "READABLES\n"); |
|
|
1476 | continue; |
1463 | continue; |
1477 | } |
1464 | } |
1478 | |
1465 | |
1479 | /* wands/staves/rods/horns */ |
1466 | /* wands/staves/rods/horns */ |
1480 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1467 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1481 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1468 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1482 | { |
1469 | { |
1483 | pick_up (op, tmp); |
1470 | pick_up (op, tmp); |
1484 | if (0) |
|
|
1485 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1486 | continue; |
1471 | continue; |
1487 | } |
1472 | } |
1488 | |
1473 | |
1489 | /* pick up all magical items */ |
1474 | /* pick up all magical items */ |
1490 | if (op->contr->mode & PU_MAGICAL) |
1475 | if (op->contr->mode & PU_MAGICAL) |
1491 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1476 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1492 | { |
1477 | { |
1493 | pick_up (op, tmp); |
1478 | pick_up (op, tmp); |
1494 | if (0) |
|
|
1495 | fprintf (stderr, "MAGICAL\n"); |
|
|
1496 | continue; |
1479 | continue; |
1497 | } |
1480 | } |
1498 | |
1481 | |
1499 | if (op->contr->mode & PU_VALUABLES) |
1482 | if (op->contr->mode & PU_VALUABLES) |
1500 | { |
1483 | { |
1501 | if (tmp->type == MONEY || tmp->type == GEM) |
1484 | if (tmp->type == MONEY || tmp->type == GEM) |
1502 | { |
1485 | { |
1503 | pick_up (op, tmp); |
1486 | pick_up (op, tmp); |
1504 | if (0) |
|
|
1505 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1506 | continue; |
1487 | continue; |
1507 | } |
1488 | } |
1508 | } |
1489 | } |
1509 | |
1490 | |
1510 | /* rings & amulets - talismans seems to be typed AMULET */ |
1491 | /* rings & amulets - talismans seems to be typed AMULET */ |
1511 | if (op->contr->mode & PU_JEWELS) |
1492 | if (op->contr->mode & PU_JEWELS) |
1512 | if (tmp->type == RING || tmp->type == AMULET) |
1493 | if (tmp->type == RING || tmp->type == AMULET) |
1513 | { |
1494 | { |
1514 | pick_up (op, tmp); |
1495 | pick_up (op, tmp); |
|
|
1496 | continue; |
1515 | if (0) |
1497 | } |
1516 | fprintf (stderr, "JEWELS\n"); |
1498 | |
|
|
1499 | /* we don't forget dragon food */ |
|
|
1500 | if (op->contr->mode & PU_FLESH) |
|
|
1501 | if (tmp->type == FLESH) |
|
|
1502 | { |
|
|
1503 | pick_up (op, tmp); |
1517 | continue; |
1504 | continue; |
1518 | } |
1505 | } |
1519 | |
1506 | |
1520 | /* bows and arrows. Bows are good for selling! */ |
1507 | /* bows and arrows. Bows are good for selling! */ |
1521 | if (op->contr->mode & PU_BOW) |
1508 | if (op->contr->mode & PU_BOW) |
1522 | if (tmp->type == BOW) |
1509 | if (tmp->type == BOW) |
1523 | { |
1510 | { |
1524 | pick_up (op, tmp); |
1511 | pick_up (op, tmp); |
1525 | if (0) |
|
|
1526 | fprintf (stderr, "BOW\n"); |
|
|
1527 | continue; |
1512 | continue; |
1528 | } |
1513 | } |
|
|
1514 | |
1529 | if (op->contr->mode & PU_ARROW) |
1515 | if (op->contr->mode & PU_ARROW) |
1530 | if (tmp->type == ARROW) |
1516 | if (tmp->type == ARROW) |
1531 | { |
1517 | { |
1532 | pick_up (op, tmp); |
1518 | pick_up (op, tmp); |
1533 | if (0) |
|
|
1534 | fprintf (stderr, "ARROW\n"); |
|
|
1535 | continue; |
1519 | continue; |
1536 | } |
1520 | } |
1537 | |
1521 | |
1538 | /* all kinds of armor etc. */ |
1522 | /* all kinds of armor etc. */ |
1539 | if (op->contr->mode & PU_ARMOUR) |
1523 | if (op->contr->mode & PU_ARMOUR) |
1540 | if (tmp->type == ARMOUR) |
1524 | if (tmp->type == ARMOUR) |
1541 | { |
1525 | { |
1542 | pick_up (op, tmp); |
1526 | pick_up (op, tmp); |
1543 | if (0) |
|
|
1544 | fprintf (stderr, "ARMOUR\n"); |
|
|
1545 | continue; |
1527 | continue; |
1546 | } |
1528 | } |
|
|
1529 | |
1547 | if (op->contr->mode & PU_HELMET) |
1530 | if (op->contr->mode & PU_HELMET) |
1548 | if (tmp->type == HELMET) |
1531 | if (tmp->type == HELMET) |
1549 | { |
1532 | { |
1550 | pick_up (op, tmp); |
1533 | pick_up (op, tmp); |
1551 | if (0) |
|
|
1552 | fprintf (stderr, "HELMET\n"); |
|
|
1553 | continue; |
1534 | continue; |
1554 | } |
1535 | } |
|
|
1536 | |
1555 | if (op->contr->mode & PU_SHIELD) |
1537 | if (op->contr->mode & PU_SHIELD) |
1556 | if (tmp->type == SHIELD) |
1538 | if (tmp->type == SHIELD) |
1557 | { |
1539 | { |
1558 | pick_up (op, tmp); |
1540 | pick_up (op, tmp); |
1559 | if (0) |
|
|
1560 | fprintf (stderr, "SHIELD\n"); |
|
|
1561 | continue; |
1541 | continue; |
1562 | } |
1542 | } |
|
|
1543 | |
1563 | if (op->contr->mode & PU_BOOTS) |
1544 | if (op->contr->mode & PU_BOOTS) |
1564 | if (tmp->type == BOOTS) |
1545 | if (tmp->type == BOOTS) |
1565 | { |
1546 | { |
1566 | pick_up (op, tmp); |
1547 | pick_up (op, tmp); |
1567 | if (0) |
|
|
1568 | fprintf (stderr, "BOOTS\n"); |
|
|
1569 | continue; |
1548 | continue; |
1570 | } |
1549 | } |
|
|
1550 | |
1571 | if (op->contr->mode & PU_GLOVES) |
1551 | if (op->contr->mode & PU_GLOVES) |
1572 | if (tmp->type == GLOVES) |
1552 | if (tmp->type == GLOVES) |
1573 | { |
1553 | { |
1574 | pick_up (op, tmp); |
1554 | pick_up (op, tmp); |
1575 | if (0) |
|
|
1576 | fprintf (stderr, "GLOVES\n"); |
|
|
1577 | continue; |
1555 | continue; |
1578 | } |
1556 | } |
|
|
1557 | |
1579 | if (op->contr->mode & PU_CLOAK) |
1558 | if (op->contr->mode & PU_CLOAK) |
1580 | if (tmp->type == CLOAK) |
1559 | if (tmp->type == CLOAK) |
1581 | { |
1560 | { |
1582 | pick_up (op, tmp); |
1561 | pick_up (op, tmp); |
1583 | if (0) |
|
|
1584 | fprintf (stderr, "GLOVES\n"); |
|
|
1585 | continue; |
1562 | continue; |
1586 | } |
1563 | } |
1587 | |
1564 | |
1588 | /* hoping to catch throwing daggers here */ |
1565 | /* hoping to catch throwing daggers here */ |
1589 | if (op->contr->mode & PU_MISSILEWEAPON) |
1566 | if (op->contr->mode & PU_MISSILEWEAPON) |
1590 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1567 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1591 | { |
1568 | { |
1592 | pick_up (op, tmp); |
1569 | pick_up (op, tmp); |
1593 | if (0) |
|
|
1594 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1595 | continue; |
1570 | continue; |
1596 | } |
1571 | } |
1597 | |
1572 | |
1598 | /* careful: chairs and tables are weapons! */ |
1573 | /* careful: chairs and tables are weapons! */ |
1599 | if (op->contr->mode & PU_ALLWEAPON) |
1574 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1602 | { |
1577 | { |
1603 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1578 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1604 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1579 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1605 | { |
1580 | { |
1606 | pick_up (op, tmp); |
1581 | pick_up (op, tmp); |
1607 | if (0) |
|
|
1608 | fprintf (stderr, "WEAPON\n"); |
|
|
1609 | continue; |
1582 | continue; |
1610 | } |
1583 | } |
1611 | } |
1584 | } |
|
|
1585 | |
1612 | if (tmp->type == WEAPON && tmp->name == NULL) |
1586 | if (tmp->type == WEAPON && tmp->name == NULL) |
1613 | { |
1587 | { |
1614 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1588 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1615 | { |
1589 | { |
1616 | pick_up (op, tmp); |
1590 | pick_up (op, tmp); |
1617 | if (0) |
|
|
1618 | fprintf (stderr, "WEAPON\n"); |
|
|
1619 | continue; |
1591 | continue; |
1620 | } |
1592 | } |
1621 | } |
1593 | } |
1622 | } |
1594 | } |
1623 | |
1595 | |
1624 | /* misc stuff that's useful */ |
1596 | /* misc stuff that's useful */ |
1625 | if (op->contr->mode & PU_KEY) |
1597 | if (op->contr->mode & PU_KEY) |
1626 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1598 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1627 | { |
1599 | { |
1628 | pick_up (op, tmp); |
1600 | pick_up (op, tmp); |
1629 | if (0) |
|
|
1630 | fprintf (stderr, "KEY\n"); |
|
|
1631 | continue; |
1601 | continue; |
1632 | } |
1602 | } |
1633 | |
1603 | |
1634 | /* any of the last 4 bits set means we use the ratio for value |
1604 | /* any of the last 4 bits set means we use the ratio for value |
1635 | * pickups */ |
1605 | * pickups */ |
… | |
… | |
1657 | continue; |
1627 | continue; |
1658 | } |
1628 | } |
1659 | } |
1629 | } |
1660 | } /* the new pickup model */ |
1630 | } /* the new pickup model */ |
1661 | } |
1631 | } |
|
|
1632 | |
1662 | return !stop; |
1633 | return !stop; |
1663 | } |
1634 | } |
1664 | |
1635 | |
1665 | /* |
1636 | /* |
1666 | * Find an arrow in the inventory and after that |
1637 | * Find an arrow in the inventory and after that |
… | |
… | |
1900 | } |
1871 | } |
1901 | |
1872 | |
1902 | /* this should not happen, but sometimes does */ |
1873 | /* this should not happen, but sometimes does */ |
1903 | if (arrow->nrof == 0) |
1874 | if (arrow->nrof == 0) |
1904 | { |
1875 | { |
1905 | remove_ob (arrow); |
1876 | arrow->destroy (); |
1906 | free_object (arrow); |
|
|
1907 | return 0; |
1877 | return 0; |
1908 | } |
1878 | } |
1909 | |
1879 | |
1910 | left = arrow; /* these are arrows left to the player */ |
1880 | left = arrow; /* these are arrows left to the player */ |
1911 | arrow = get_split_ob (arrow, 1); |
1881 | arrow = get_split_ob (arrow, 1); |
… | |
… | |
2130 | case range_misc: |
2100 | case range_misc: |
2131 | fire_misc_object (op, dir); |
2101 | fire_misc_object (op, dir); |
2132 | return; |
2102 | return; |
2133 | |
2103 | |
2134 | case range_golem: /* Control summoned monsters from scrolls */ |
2104 | case range_golem: /* Control summoned monsters from scrolls */ |
2135 | if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) |
2105 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2136 | { |
2106 | { |
2137 | op->contr->ranges[range_golem] = NULL; |
2107 | op->contr->ranges[range_golem] = 0; |
2138 | op->contr->shoottype = range_none; |
2108 | op->contr->shoottype = range_none; |
2139 | op->contr->golem_count = 0; |
|
|
2140 | } |
2109 | } |
2141 | else |
2110 | else |
2142 | control_golem (op->contr->ranges[range_golem], dir); |
2111 | control_golem (op->contr->ranges[range_golem], dir); |
2143 | return; |
2112 | return; |
2144 | |
2113 | |
… | |
… | |
2590 | /* I've been seeing crashes where the golem has been destroyed, but |
2559 | /* I've been seeing crashes where the golem has been destroyed, but |
2591 | * the player object still points to the defunct golem. The code that |
2560 | * the player object still points to the defunct golem. The code that |
2592 | * destroys the golem looks correct, and it doesn't always happen, so |
2561 | * destroys the golem looks correct, and it doesn't always happen, so |
2593 | * put this in a a workaround to clean up the golem pointer. |
2562 | * put this in a a workaround to clean up the golem pointer. |
2594 | */ |
2563 | */ |
2595 | if (op->contr->ranges[range_golem] && |
|
|
2596 | ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) |
2564 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2597 | { |
|
|
2598 | op->contr->ranges[range_golem] = NULL; |
2565 | op->contr->ranges[range_golem] = 0; |
2599 | op->contr->golem_count = 0; |
|
|
2600 | } |
|
|
2601 | |
2566 | |
2602 | /* call this here - we also will call this in do_ericserver, but |
2567 | /* call this here - we also will call this in do_ericserver, but |
2603 | * the players time has been increased when doericserver has been |
2568 | * the players time has been increased when doericserver has been |
2604 | * called, so we recheck it here. |
2569 | * called, so we recheck it here. |
2605 | */ |
2570 | */ |
… | |
… | |
2636 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2601 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2637 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2602 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2638 | { |
2603 | { |
2639 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2604 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2640 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2605 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
|
|
2606 | |
2641 | if (op->contr) |
2607 | if (op->contr) |
2642 | esrv_del_item (op->contr, tmp->count); |
2608 | esrv_del_item (op->contr, tmp->count); |
2643 | remove_ob (tmp); |
2609 | |
2644 | free_object (tmp); |
2610 | tmp->destroy (); |
2645 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2611 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
|
|
2612 | |
2646 | if (op->stats.hp < 0) |
2613 | if (op->stats.hp < 0) |
2647 | op->stats.hp = op->stats.maxhp; |
2614 | op->stats.hp = op->stats.maxhp; |
|
|
2615 | |
2648 | if (op->stats.food < 0) |
2616 | if (op->stats.food < 0) |
2649 | op->stats.food = 999; |
2617 | op->stats.food = 999; |
|
|
2618 | |
2650 | fix_player (op); |
2619 | fix_player (op); |
2651 | return 1; |
2620 | return 1; |
2652 | } |
2621 | } |
2653 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2622 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2654 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2623 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
… | |
… | |
2671 | next = op->below; /* Make sure we have a good value, in case |
2640 | next = op->below; /* Make sure we have a good value, in case |
2672 | * we remove object 'op' |
2641 | * we remove object 'op' |
2673 | */ |
2642 | */ |
2674 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2643 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2675 | { |
2644 | { |
2676 | remove_ob (op); |
2645 | op->remove (); |
2677 | op->x = env->x; |
2646 | op->x = env->x; |
2678 | op->y = env->y; |
2647 | op->y = env->y; |
2679 | if (env->type == PLAYER) |
2648 | if (env->type == PLAYER) |
2680 | esrv_del_item (env->contr, op->count); |
2649 | esrv_del_item (env->contr, op->count); |
2681 | insert_ob_in_map (op, env->map, NULL, 0); |
2650 | insert_ob_in_map (op, env->map, NULL, 0); |
… | |
… | |
2978 | /* restore player */ |
2947 | /* restore player */ |
2979 | at = archetype::find ("poisoning"); |
2948 | at = archetype::find ("poisoning"); |
2980 | tmp = present_arch_in_ob (at, op); |
2949 | tmp = present_arch_in_ob (at, op); |
2981 | if (tmp) |
2950 | if (tmp) |
2982 | { |
2951 | { |
2983 | remove_ob (tmp); |
2952 | tmp->destroy (); |
2984 | free_object (tmp); |
|
|
2985 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2953 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2986 | } |
2954 | } |
2987 | |
2955 | |
2988 | at = archetype::find ("confusion"); |
2956 | at = archetype::find ("confusion"); |
2989 | tmp = present_arch_in_ob (at, op); |
2957 | tmp = present_arch_in_ob (at, op); |
2990 | if (tmp) |
2958 | if (tmp) |
2991 | { |
2959 | { |
2992 | remove_ob (tmp); |
2960 | tmp->destroy (); |
2993 | free_object (tmp); |
|
|
2994 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2961 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2995 | } |
2962 | } |
2996 | |
2963 | |
2997 | cure_disease (op, 0); /* remove any disease */ |
2964 | cure_disease (op, 0); /* remove any disease */ |
2998 | op->stats.hp = op->stats.maxhp; |
2965 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
3175 | /* determine_god() seems to not work sometimes... why is this? |
3142 | /* determine_god() seems to not work sometimes... why is this? |
3176 | Should I be using something else? GD */ |
3143 | Should I be using something else? GD */ |
3177 | const char *god = determine_god (op); |
3144 | const char *god = determine_god (op); |
3178 | |
3145 | |
3179 | if (god && (strcmp (god, "none"))) |
3146 | if (god && (strcmp (god, "none"))) |
3180 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); |
3147 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3181 | else |
3148 | else |
3182 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); |
3149 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
3183 | } |
3150 | } |
|
|
3151 | #else |
|
|
3152 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3184 | #endif |
3153 | #endif |
3185 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3186 | |
3154 | |
3187 | /* Put a gravestone up where the character 'almost' died. List the |
3155 | /* Put a gravestone up where the character 'almost' died. List the |
3188 | * exp loss on the stone. |
3156 | * exp loss on the stone. |
3189 | */ |
3157 | */ |
3190 | tmp = arch_to_object (archetype::find ("gravestone")); |
3158 | tmp = arch_to_object (archetype::find ("gravestone")); |
… | |
… | |
3195 | 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); |
3163 | 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); |
3196 | tmp->msg = buf; |
3164 | tmp->msg = buf; |
3197 | tmp->x = op->x, tmp->y = op->y; |
3165 | tmp->x = op->x, tmp->y = op->y; |
3198 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3166 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3199 | |
3167 | |
3200 | /**************************************/ |
3168 | /**************************************/ |
3201 | /* */ |
3169 | /* */ |
3202 | /* Subtract the experience points, */ |
3170 | /* Subtract the experience points, */ |
3203 | /* if we died cause of food, give us */ |
3171 | /* if we died cause of food, give us */ |
3204 | /* food, and reset HP's... */ |
3172 | /* food, and reset HP's... */ |
3205 | /* */ |
3173 | /* */ |
3206 | |
|
|
3207 | /**************************************/ |
3174 | /**************************************/ |
3208 | |
3175 | |
3209 | /* remove any poisoning and confusion the character may be suffering. */ |
3176 | /* remove any poisoning and confusion the character may be suffering. */ |
3210 | /* restore player */ |
3177 | /* restore player */ |
3211 | at = archetype::find ("poisoning"); |
3178 | at = archetype::find ("poisoning"); |
3212 | tmp = present_arch_in_ob (at, op); |
3179 | tmp = present_arch_in_ob (at, op); |
|
|
3180 | |
3213 | if (tmp) |
3181 | if (tmp) |
3214 | { |
3182 | { |
3215 | remove_ob (tmp); |
3183 | tmp->destroy (); |
3216 | free_object (tmp); |
|
|
3217 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3184 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3218 | } |
3185 | } |
3219 | |
3186 | |
3220 | at = archetype::find ("confusion"); |
3187 | at = archetype::find ("confusion"); |
3221 | tmp = present_arch_in_ob (at, op); |
3188 | tmp = present_arch_in_ob (at, op); |
3222 | if (tmp) |
3189 | if (tmp) |
3223 | { |
3190 | { |
3224 | remove_ob (tmp); |
3191 | tmp->destroy (); |
3225 | free_object (tmp); |
|
|
3226 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3192 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3227 | } |
3193 | } |
|
|
3194 | |
3228 | cure_disease (op, 0); /* remove any disease */ |
3195 | cure_disease (op, 0); /* remove any disease */ |
3229 | |
3196 | |
3230 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3197 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3231 | apply_death_exp_penalty (op); |
3198 | apply_death_exp_penalty (op); |
3232 | if (op->stats.food < 100) |
3199 | if (op->stats.food < 100) |
… | |
… | |
3242 | */ |
3209 | */ |
3243 | |
3210 | |
3244 | if (is_in_shop (op)) |
3211 | if (is_in_shop (op)) |
3245 | remove_unpaid_objects (op->inv, op); |
3212 | remove_unpaid_objects (op->inv, op); |
3246 | |
3213 | |
3247 | /****************************************/ |
3214 | /****************************************/ |
3248 | /* */ |
3215 | /* */ |
3249 | /* Move player to his current respawn- */ |
3216 | /* Move player to his current respawn- */ |
3250 | /* position (usually last savebed) */ |
3217 | /* position (usually last savebed) */ |
3251 | /* */ |
3218 | /* */ |
3252 | |
|
|
3253 | /****************************************/ |
3219 | /****************************************/ |
3254 | |
3220 | |
3255 | enter_player_savebed (op); |
3221 | enter_player_savebed (op); |
3256 | |
3222 | |
3257 | /* Save the player before inserting the force to reduce |
3223 | /* Save the player before inserting the force to reduce |
3258 | * chance of abuse. |
3224 | * chance of abuse. |
… | |
… | |
3265 | * spell effects. So first see if there is a spell effect |
3231 | * spell effects. So first see if there is a spell effect |
3266 | * on the space that might harm the player. |
3232 | * on the space that might harm the player. |
3267 | */ |
3233 | */ |
3268 | will_kill_again = 0; |
3234 | will_kill_again = 0; |
3269 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3235 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3270 | { |
|
|
3271 | if (tmp->type == SPELL_EFFECT) |
3236 | if (tmp->type == SPELL_EFFECT) |
3272 | will_kill_again |= tmp->attacktype; |
3237 | will_kill_again |= tmp->attacktype; |
3273 | } |
3238 | |
3274 | if (will_kill_again) |
3239 | if (will_kill_again) |
3275 | { |
3240 | { |
3276 | object *force; |
3241 | object *force; |
3277 | int at; |
3242 | int at; |
3278 | |
3243 | |
… | |
… | |
3280 | /* 50 ticks should be enough time for the spell to abate */ |
3245 | /* 50 ticks should be enough time for the spell to abate */ |
3281 | force->speed = 0.1; |
3246 | force->speed = 0.1; |
3282 | force->speed_left = -5.0; |
3247 | force->speed_left = -5.0; |
3283 | SET_FLAG (force, FLAG_APPLIED); |
3248 | SET_FLAG (force, FLAG_APPLIED); |
3284 | for (at = 0; at < NROFATTACKS; at++) |
3249 | for (at = 0; at < NROFATTACKS; at++) |
3285 | { |
|
|
3286 | if (will_kill_again & (1 << at)) |
3250 | if (will_kill_again & (1 << at)) |
3287 | force->resist[at] = 100; |
3251 | force->resist[at] = 100; |
3288 | } |
3252 | |
3289 | insert_ob_in_ob (force, op); |
3253 | insert_ob_in_ob (force, op); |
3290 | fix_player (op); |
3254 | fix_player (op); |
3291 | |
3255 | |
3292 | } |
3256 | } |
3293 | |
3257 | |
… | |
… | |
3303 | op->contr->party = NULL; |
3267 | op->contr->party = NULL; |
3304 | if (settings.set_title == TRUE) |
3268 | if (settings.set_title == TRUE) |
3305 | op->contr->own_title[0] = '\0'; |
3269 | op->contr->own_title[0] = '\0'; |
3306 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3270 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3307 | check_score (op); |
3271 | check_score (op); |
|
|
3272 | |
3308 | if (op->contr->ranges[range_golem] != NULL) |
3273 | if (op->contr->ranges[range_golem]) |
3309 | { |
3274 | { |
3310 | remove_friendly_object (op->contr->ranges[range_golem]); |
3275 | remove_friendly_object (op->contr->ranges[range_golem]); |
3311 | remove_ob (op->contr->ranges[range_golem]); |
3276 | op->contr->ranges[range_golem]->destroy (); |
3312 | free_object (op->contr->ranges[range_golem]); |
|
|
3313 | op->contr->ranges[range_golem] = NULL; |
3277 | op->contr->ranges[range_golem] = 0; |
3314 | op->contr->golem_count = 0; |
|
|
3315 | } |
3278 | } |
|
|
3279 | |
3316 | loot_object (op); /* Remove some of the items for good */ |
3280 | loot_object (op); /* Remove some of the items for good */ |
3317 | remove_ob (op); |
3281 | op->remove (); |
3318 | op->direction = 0; |
3282 | op->direction = 0; |
3319 | |
3283 | |
3320 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3284 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3321 | { |
3285 | { |
3322 | delete_character (op->name, 0); |
3286 | delete_character (op->name, 0); |
… | |
… | |
3375 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3339 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3376 | { |
3340 | { |
3377 | next = tmp->below; |
3341 | next = tmp->below; |
3378 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3342 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3379 | continue; |
3343 | continue; |
3380 | remove_ob (tmp); |
3344 | tmp->remove (); |
3381 | tmp->x = op->x, tmp->y = op->y; |
3345 | tmp->x = op->x, tmp->y = op->y; |
3382 | if (tmp->type == CONTAINER) |
3346 | if (tmp->type == CONTAINER) |
3383 | { /* empty container to ground */ |
3347 | { /* empty container to ground */ |
3384 | loot_object (tmp); |
3348 | loot_object (tmp); |
3385 | } |
3349 | } |
3386 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3350 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3387 | { |
3351 | { |
3388 | if (tmp->nrof > 1) |
3352 | if (tmp->nrof > 1) |
3389 | { |
3353 | { |
3390 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3354 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3391 | free_object (tmp2); |
3355 | tmp2->destroy (); |
3392 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3356 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3393 | } |
3357 | } |
3394 | else |
3358 | else |
3395 | free_object (tmp); |
3359 | tmp->destroy (); |
3396 | } |
3360 | } |
3397 | else |
3361 | else |
3398 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3362 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3399 | } |
3363 | } |
3400 | } |
3364 | } |
… | |
… | |
3465 | if (op->type == PLAYER) |
3429 | if (op->type == PLAYER) |
3466 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3430 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3467 | |
3431 | |
3468 | cast_spell (op, throw_ob, dir, spob, NULL); |
3432 | cast_spell (op, throw_ob, dir, spob, NULL); |
3469 | |
3433 | |
3470 | if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) |
3434 | throw_ob->destroy (); |
3471 | remove_ob (throw_ob); |
|
|
3472 | free_object (throw_ob); |
|
|
3473 | } |
3435 | } |
3474 | |
3436 | |
3475 | void |
3437 | void |
3476 | make_visible (object *op) |
3438 | make_visible (object *op) |
3477 | { |
3439 | { |