… | |
… | |
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> |
… | |
… | |
322 | * All we can really get in this is some settings like host and display |
320 | * All we can really get in this is some settings like host and display |
323 | * mode. |
321 | * mode. |
324 | */ |
322 | */ |
325 | |
323 | |
326 | int |
324 | int |
327 | add_player (NewSocket * ns) |
325 | add_player (client_socket * ns) |
328 | { |
326 | { |
329 | player *p; |
327 | player *p; |
330 | |
328 | |
331 | p = get_player (NULL); |
329 | p = get_player (NULL); |
332 | p->socket = *ns; |
330 | p->socket = *ns; |
333 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
331 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
|
|
332 | |
334 | if (p->socket.faces_sent == NULL) |
333 | if (p->socket.faces_sent == NULL) |
335 | fatal (OUT_OF_MEMORY); |
334 | fatal (OUT_OF_MEMORY); |
|
|
335 | |
336 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
336 | 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. |
337 | /* 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 |
338 | * Note that this can result in a client reset if there is partial data |
339 | * on the uncoming socket. |
339 | * on the uncoming socket. |
340 | */ |
340 | */ |
|
|
341 | //TODO socket copying is EVIL, do not do this |
341 | p->socket.inbuf.len = 0; |
342 | p->socket.inbuf_len = 0; |
342 | set_first_map (p->ob); |
343 | set_first_map (p->ob); |
343 | |
344 | |
344 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
345 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
345 | add_friendly_object (p->ob); |
346 | add_friendly_object (p->ob); |
346 | send_rules (p->ob); |
347 | send_rules (p->ob); |
347 | send_news (p->ob); |
348 | send_news (p->ob); |
348 | display_motd (p->ob); |
349 | display_motd (p->ob); |
349 | get_name (p->ob); |
350 | get_name (p->ob); |
|
|
351 | |
350 | return 0; |
352 | return 0; |
351 | } |
353 | } |
352 | |
354 | |
353 | /* |
355 | /* |
354 | * get_player_archetype() return next player archetype from archetype |
356 | * get_player_archetype() return next player archetype from archetype |
… | |
… | |
489 | path_to_player (object *mon, object *pl, unsigned mindiff) |
491 | path_to_player (object *mon, object *pl, unsigned mindiff) |
490 | { |
492 | { |
491 | rv_vector rv; |
493 | rv_vector rv; |
492 | sint16 x, y; |
494 | sint16 x, y; |
493 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
495 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
494 | mapstruct *m, *lastmap; |
496 | maptile *m, *lastmap; |
495 | |
497 | |
496 | get_rangevector (mon, pl, &rv, 0); |
498 | get_rangevector (mon, pl, &rv, 0); |
497 | |
499 | |
498 | if (rv.distance < mindiff) |
500 | if (rv.distance < mindiff) |
499 | return 0; |
501 | return 0; |
… | |
… | |
643 | (op->type == ARMOUR || op->type == BOOTS || |
645 | (op->type == ARMOUR || op->type == BOOTS || |
644 | op->type == CLOAK || op->type == HELMET || |
646 | op->type == CLOAK || op->type == HELMET || |
645 | op->type == SHIELD || op->type == GLOVES || |
647 | op->type == SHIELD || op->type == GLOVES || |
646 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
648 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
647 | { |
649 | { |
648 | remove_ob (op); |
650 | op->destroy (); |
649 | free_object (op); |
|
|
650 | continue; |
651 | continue; |
651 | } |
652 | } |
652 | } |
653 | } |
653 | |
654 | |
654 | /* This really needs to be better - we should really give |
655 | /* This really needs to be better - we should really give |
… | |
… | |
665 | if (tmp->type == op->type && tmp->name == op->name) |
666 | if (tmp->type == op->type && tmp->name == op->name) |
666 | break; |
667 | break; |
667 | |
668 | |
668 | if (tmp) |
669 | if (tmp) |
669 | { |
670 | { |
670 | remove_ob (op); |
671 | op->destroy (); |
671 | free_object (op); |
|
|
672 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
672 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
673 | continue; |
673 | continue; |
674 | } |
674 | } |
|
|
675 | |
675 | if (op->nrof > 1) |
676 | if (op->nrof > 1) |
676 | op->nrof = 1; |
677 | op->nrof = 1; |
677 | } |
678 | } |
678 | |
679 | |
679 | if (op->type == SPELLBOOK && op->inv) |
680 | if (op->type == SPELLBOOK && op->inv) |
… | |
… | |
691 | CLEAR_FLAG (op, FLAG_CURSED); |
692 | CLEAR_FLAG (op, FLAG_CURSED); |
692 | CLEAR_FLAG (op, FLAG_DAMNED); |
693 | CLEAR_FLAG (op, FLAG_DAMNED); |
693 | } |
694 | } |
694 | if (op->type == SPELL) |
695 | if (op->type == SPELL) |
695 | { |
696 | { |
696 | remove_ob (op); |
697 | op->destroy (); |
697 | free_object (op); |
|
|
698 | continue; |
698 | continue; |
699 | } |
699 | } |
700 | else if (op->type == SKILL) |
700 | else if (op->type == SKILL) |
701 | { |
701 | { |
702 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
702 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
… | |
… | |
741 | * removing the player - it probably makes more sense |
741 | * removing the player - it probably makes more sense |
742 | * to leave it to play_again to remove the object in all |
742 | * to leave it to play_again to remove the object in all |
743 | * cases. |
743 | * cases. |
744 | */ |
744 | */ |
745 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
745 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
746 | remove_ob (op); |
746 | op->remove (); |
747 | /* Need to set this to null - otherwise, it could point to garbage, |
747 | /* Need to set this to null - otherwise, it could point to garbage, |
748 | * and draw() doesn't check to see if the player is removed, only if |
748 | * and draw() doesn't check to see if the player is removed, only if |
749 | * the map is null or not swapped out. |
749 | * the map is null or not swapped out. |
750 | */ |
750 | */ |
751 | op->map = NULL; |
751 | op->map = NULL; |
… | |
… | |
765 | player *pl = op->contr; |
765 | player *pl = op->contr; |
766 | shstr name = op->name; |
766 | shstr name = op->name; |
767 | |
767 | |
768 | op->contr = 0; |
768 | op->contr = 0; |
769 | op->type = 0; |
769 | op->type = 0; |
770 | op->free (1); |
770 | op->destroy (1); |
771 | pl = get_player (pl); |
771 | pl = get_player (pl); |
772 | op = pl->ob; |
772 | op = pl->ob; |
773 | add_friendly_object (op); |
773 | add_friendly_object (op); |
774 | op->contr->password[0] = '~'; |
774 | op->contr->password[0] = '~'; |
775 | op->name = op->name_pl = 0; |
775 | op->name = op->name_pl = 0; |
… | |
… | |
1051 | { |
1051 | { |
1052 | int tmp_loop; |
1052 | int tmp_loop; |
1053 | |
1053 | |
1054 | if (key == 'q' || key == 'Q') |
1054 | if (key == 'q' || key == 'Q') |
1055 | { |
1055 | { |
1056 | remove_ob (op); |
1056 | op->remove (); |
1057 | play_again (op); |
1057 | play_again (op); |
1058 | return 0; |
1058 | return 0; |
1059 | } |
1059 | } |
1060 | if (key == 'd' || key == 'D') |
1060 | if (key == 'd' || key == 'D') |
1061 | { |
1061 | { |
1062 | char buf[MAX_BUF]; |
1062 | char buf[MAX_BUF]; |
1063 | |
1063 | |
1064 | /* this must before then initial items are given */ |
1064 | /* this must before then initial items are given */ |
1065 | esrv_new_player (op->contr, op->weight + op->carrying); |
1065 | esrv_new_player (op->contr, op->weight + op->carrying); |
|
|
1066 | |
1066 | create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); |
1067 | treasurelist *tl = find_treasurelist ("starting_wealth"); |
|
|
1068 | if (tl) |
|
|
1069 | create_treasure (tl, op, 0, 0, 0); |
1067 | |
1070 | |
1068 | INVOKE_PLAYER (BIRTH, op->contr); |
1071 | INVOKE_PLAYER (BIRTH, op->contr); |
1069 | INVOKE_PLAYER (LOGIN, op->contr); |
1072 | INVOKE_PLAYER (LOGIN, op->contr); |
1070 | |
1073 | |
1071 | op->contr->state = ST_PLAYING; |
1074 | op->contr->state = ST_PLAYING; |
… | |
… | |
1096 | { |
1099 | { |
1097 | object *tmp; |
1100 | object *tmp; |
1098 | char mapname[MAX_BUF]; |
1101 | char mapname[MAX_BUF]; |
1099 | |
1102 | |
1100 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1103 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1101 | tmp = get_object (); |
1104 | tmp = object::create (); |
1102 | EXIT_PATH (tmp) = mapname; |
1105 | EXIT_PATH (tmp) = mapname; |
1103 | EXIT_X (tmp) = op->x; |
1106 | EXIT_X (tmp) = op->x; |
1104 | EXIT_Y (tmp) = op->y; |
1107 | EXIT_Y (tmp) = op->y; |
1105 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1108 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1106 | * if the map isn't there, then stay on the |
1109 | * if the map isn't there, then stay on the |
1107 | * default initial map */ |
1110 | * default initial map */ |
1108 | free_object (tmp); |
1111 | tmp->destroy (); |
1109 | } |
1112 | } |
1110 | else |
1113 | else |
1111 | { |
1114 | { |
1112 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1115 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1113 | } |
1116 | } |
… | |
… | |
1123 | { |
1126 | { |
1124 | shstr name = op->name; |
1127 | shstr name = op->name; |
1125 | int x = op->x, y = op->y; |
1128 | int x = op->x, y = op->y; |
1126 | |
1129 | |
1127 | remove_statbonus (op); |
1130 | remove_statbonus (op); |
1128 | remove_ob (op); |
1131 | op->remove (); |
1129 | op->arch = get_player_archetype (op->arch); |
1132 | op->arch = get_player_archetype (op->arch); |
1130 | copy_object (&op->arch->clone, op); |
1133 | op->arch->clone.copy_to (op); |
1131 | op->instantiate (); |
1134 | op->instantiate (); |
1132 | op->stats = op->contr->orig_stats; |
1135 | op->stats = op->contr->orig_stats; |
1133 | op->name = op->name_pl = name; |
1136 | op->name = op->name_pl = name; |
1134 | op->x = x; |
1137 | op->x = x; |
1135 | op->y = y; |
1138 | op->y = y; |
… | |
… | |
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 | */ |
… | |
… | |
1423 | /* question: don't pick up known-poisonous stuff? */ |
1426 | /* question: don't pick up known-poisonous stuff? */ |
1424 | if (op->contr->mode & PU_FOOD) |
1427 | if (op->contr->mode & PU_FOOD) |
1425 | if (tmp->type == FOOD) |
1428 | if (tmp->type == FOOD) |
1426 | { |
1429 | { |
1427 | pick_up (op, tmp); |
1430 | pick_up (op, tmp); |
1428 | if (0) |
|
|
1429 | fprintf (stderr, "FOOD\n"); |
|
|
1430 | continue; |
1431 | continue; |
1431 | } |
1432 | } |
|
|
1433 | |
1432 | if (op->contr->mode & PU_DRINK) |
1434 | if (op->contr->mode & PU_DRINK) |
1433 | 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))) |
1434 | { |
1436 | { |
1435 | pick_up (op, tmp); |
1437 | pick_up (op, tmp); |
1436 | if (0) |
|
|
1437 | fprintf (stderr, "DRINK\n"); |
|
|
1438 | continue; |
1438 | continue; |
1439 | } |
1439 | } |
1440 | |
1440 | |
1441 | if (op->contr->mode & PU_POTION) |
1441 | if (op->contr->mode & PU_POTION) |
1442 | if (tmp->type == POTION) |
1442 | if (tmp->type == POTION) |
1443 | { |
1443 | { |
1444 | pick_up (op, tmp); |
1444 | pick_up (op, tmp); |
1445 | if (0) |
|
|
1446 | fprintf (stderr, "POTION\n"); |
|
|
1447 | continue; |
1445 | continue; |
1448 | } |
1446 | } |
1449 | |
1447 | |
1450 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1448 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1451 | if (op->contr->mode & PU_SPELLBOOK) |
1449 | if (op->contr->mode & PU_SPELLBOOK) |
1452 | if (tmp->type == SPELLBOOK) |
1450 | if (tmp->type == SPELLBOOK) |
1453 | { |
1451 | { |
1454 | pick_up (op, tmp); |
1452 | pick_up (op, tmp); |
1455 | if (0) |
|
|
1456 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1457 | continue; |
1453 | continue; |
1458 | } |
1454 | } |
|
|
1455 | |
1459 | if (op->contr->mode & PU_SKILLSCROLL) |
1456 | if (op->contr->mode & PU_SKILLSCROLL) |
1460 | if (tmp->type == SKILLSCROLL) |
1457 | if (tmp->type == SKILLSCROLL) |
1461 | { |
1458 | { |
1462 | pick_up (op, tmp); |
1459 | pick_up (op, tmp); |
1463 | if (0) |
|
|
1464 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1465 | continue; |
1460 | continue; |
1466 | } |
1461 | } |
|
|
1462 | |
1467 | if (op->contr->mode & PU_READABLES) |
1463 | if (op->contr->mode & PU_READABLES) |
1468 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1464 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1469 | { |
1465 | { |
1470 | pick_up (op, tmp); |
1466 | pick_up (op, tmp); |
1471 | if (0) |
|
|
1472 | fprintf (stderr, "READABLES\n"); |
|
|
1473 | continue; |
1467 | continue; |
1474 | } |
1468 | } |
1475 | |
1469 | |
1476 | /* wands/staves/rods/horns */ |
1470 | /* wands/staves/rods/horns */ |
1477 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1471 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1478 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1472 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1479 | { |
1473 | { |
1480 | pick_up (op, tmp); |
1474 | pick_up (op, tmp); |
1481 | if (0) |
|
|
1482 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1483 | continue; |
1475 | continue; |
1484 | } |
1476 | } |
1485 | |
1477 | |
1486 | /* pick up all magical items */ |
1478 | /* pick up all magical items */ |
1487 | if (op->contr->mode & PU_MAGICAL) |
1479 | if (op->contr->mode & PU_MAGICAL) |
1488 | 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)) |
1489 | { |
1481 | { |
1490 | pick_up (op, tmp); |
1482 | pick_up (op, tmp); |
1491 | if (0) |
|
|
1492 | fprintf (stderr, "MAGICAL\n"); |
|
|
1493 | continue; |
1483 | continue; |
1494 | } |
1484 | } |
1495 | |
1485 | |
1496 | if (op->contr->mode & PU_VALUABLES) |
1486 | if (op->contr->mode & PU_VALUABLES) |
1497 | { |
1487 | { |
1498 | if (tmp->type == MONEY || tmp->type == GEM) |
1488 | if (tmp->type == MONEY || tmp->type == GEM) |
1499 | { |
1489 | { |
1500 | pick_up (op, tmp); |
1490 | pick_up (op, tmp); |
1501 | if (0) |
|
|
1502 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1503 | continue; |
1491 | continue; |
1504 | } |
1492 | } |
1505 | } |
1493 | } |
1506 | |
1494 | |
1507 | /* rings & amulets - talismans seems to be typed AMULET */ |
1495 | /* rings & amulets - talismans seems to be typed AMULET */ |
1508 | if (op->contr->mode & PU_JEWELS) |
1496 | if (op->contr->mode & PU_JEWELS) |
1509 | if (tmp->type == RING || tmp->type == AMULET) |
1497 | if (tmp->type == RING || tmp->type == AMULET) |
1510 | { |
1498 | { |
1511 | pick_up (op, tmp); |
1499 | pick_up (op, tmp); |
|
|
1500 | continue; |
1512 | if (0) |
1501 | } |
1513 | 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); |
1514 | continue; |
1508 | continue; |
1515 | } |
1509 | } |
1516 | |
1510 | |
1517 | /* bows and arrows. Bows are good for selling! */ |
1511 | /* bows and arrows. Bows are good for selling! */ |
1518 | if (op->contr->mode & PU_BOW) |
1512 | if (op->contr->mode & PU_BOW) |
1519 | if (tmp->type == BOW) |
1513 | if (tmp->type == BOW) |
1520 | { |
1514 | { |
1521 | pick_up (op, tmp); |
1515 | pick_up (op, tmp); |
1522 | if (0) |
|
|
1523 | fprintf (stderr, "BOW\n"); |
|
|
1524 | continue; |
1516 | continue; |
1525 | } |
1517 | } |
|
|
1518 | |
1526 | if (op->contr->mode & PU_ARROW) |
1519 | if (op->contr->mode & PU_ARROW) |
1527 | if (tmp->type == ARROW) |
1520 | if (tmp->type == ARROW) |
1528 | { |
1521 | { |
1529 | pick_up (op, tmp); |
1522 | pick_up (op, tmp); |
1530 | if (0) |
|
|
1531 | fprintf (stderr, "ARROW\n"); |
|
|
1532 | continue; |
1523 | continue; |
1533 | } |
1524 | } |
1534 | |
1525 | |
1535 | /* all kinds of armor etc. */ |
1526 | /* all kinds of armor etc. */ |
1536 | if (op->contr->mode & PU_ARMOUR) |
1527 | if (op->contr->mode & PU_ARMOUR) |
1537 | if (tmp->type == ARMOUR) |
1528 | if (tmp->type == ARMOUR) |
1538 | { |
1529 | { |
1539 | pick_up (op, tmp); |
1530 | pick_up (op, tmp); |
1540 | if (0) |
|
|
1541 | fprintf (stderr, "ARMOUR\n"); |
|
|
1542 | continue; |
1531 | continue; |
1543 | } |
1532 | } |
|
|
1533 | |
1544 | if (op->contr->mode & PU_HELMET) |
1534 | if (op->contr->mode & PU_HELMET) |
1545 | if (tmp->type == HELMET) |
1535 | if (tmp->type == HELMET) |
1546 | { |
1536 | { |
1547 | pick_up (op, tmp); |
1537 | pick_up (op, tmp); |
1548 | if (0) |
|
|
1549 | fprintf (stderr, "HELMET\n"); |
|
|
1550 | continue; |
1538 | continue; |
1551 | } |
1539 | } |
|
|
1540 | |
1552 | if (op->contr->mode & PU_SHIELD) |
1541 | if (op->contr->mode & PU_SHIELD) |
1553 | if (tmp->type == SHIELD) |
1542 | if (tmp->type == SHIELD) |
1554 | { |
1543 | { |
1555 | pick_up (op, tmp); |
1544 | pick_up (op, tmp); |
1556 | if (0) |
|
|
1557 | fprintf (stderr, "SHIELD\n"); |
|
|
1558 | continue; |
1545 | continue; |
1559 | } |
1546 | } |
|
|
1547 | |
1560 | if (op->contr->mode & PU_BOOTS) |
1548 | if (op->contr->mode & PU_BOOTS) |
1561 | if (tmp->type == BOOTS) |
1549 | if (tmp->type == BOOTS) |
1562 | { |
1550 | { |
1563 | pick_up (op, tmp); |
1551 | pick_up (op, tmp); |
1564 | if (0) |
|
|
1565 | fprintf (stderr, "BOOTS\n"); |
|
|
1566 | continue; |
1552 | continue; |
1567 | } |
1553 | } |
|
|
1554 | |
1568 | if (op->contr->mode & PU_GLOVES) |
1555 | if (op->contr->mode & PU_GLOVES) |
1569 | if (tmp->type == GLOVES) |
1556 | if (tmp->type == GLOVES) |
1570 | { |
1557 | { |
1571 | pick_up (op, tmp); |
1558 | pick_up (op, tmp); |
1572 | if (0) |
|
|
1573 | fprintf (stderr, "GLOVES\n"); |
|
|
1574 | continue; |
1559 | continue; |
1575 | } |
1560 | } |
|
|
1561 | |
1576 | if (op->contr->mode & PU_CLOAK) |
1562 | if (op->contr->mode & PU_CLOAK) |
1577 | if (tmp->type == CLOAK) |
1563 | if (tmp->type == CLOAK) |
1578 | { |
1564 | { |
1579 | pick_up (op, tmp); |
1565 | pick_up (op, tmp); |
1580 | if (0) |
|
|
1581 | fprintf (stderr, "GLOVES\n"); |
|
|
1582 | continue; |
1566 | continue; |
1583 | } |
1567 | } |
1584 | |
1568 | |
1585 | /* hoping to catch throwing daggers here */ |
1569 | /* hoping to catch throwing daggers here */ |
1586 | if (op->contr->mode & PU_MISSILEWEAPON) |
1570 | if (op->contr->mode & PU_MISSILEWEAPON) |
1587 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1571 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1588 | { |
1572 | { |
1589 | pick_up (op, tmp); |
1573 | pick_up (op, tmp); |
1590 | if (0) |
|
|
1591 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1592 | continue; |
1574 | continue; |
1593 | } |
1575 | } |
1594 | |
1576 | |
1595 | /* careful: chairs and tables are weapons! */ |
1577 | /* careful: chairs and tables are weapons! */ |
1596 | if (op->contr->mode & PU_ALLWEAPON) |
1578 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1599 | { |
1581 | { |
1600 | 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 && |
1601 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1583 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1602 | { |
1584 | { |
1603 | pick_up (op, tmp); |
1585 | pick_up (op, tmp); |
1604 | if (0) |
|
|
1605 | fprintf (stderr, "WEAPON\n"); |
|
|
1606 | continue; |
1586 | continue; |
1607 | } |
1587 | } |
1608 | } |
1588 | } |
|
|
1589 | |
1609 | if (tmp->type == WEAPON && tmp->name == NULL) |
1590 | if (tmp->type == WEAPON && tmp->name == NULL) |
1610 | { |
1591 | { |
1611 | 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) |
1612 | { |
1593 | { |
1613 | pick_up (op, tmp); |
1594 | pick_up (op, tmp); |
1614 | if (0) |
|
|
1615 | fprintf (stderr, "WEAPON\n"); |
|
|
1616 | continue; |
1595 | continue; |
1617 | } |
1596 | } |
1618 | } |
1597 | } |
1619 | } |
1598 | } |
1620 | |
1599 | |
1621 | /* misc stuff that's useful */ |
1600 | /* misc stuff that's useful */ |
1622 | if (op->contr->mode & PU_KEY) |
1601 | if (op->contr->mode & PU_KEY) |
1623 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1602 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1624 | { |
1603 | { |
1625 | pick_up (op, tmp); |
1604 | pick_up (op, tmp); |
1626 | if (0) |
|
|
1627 | fprintf (stderr, "KEY\n"); |
|
|
1628 | continue; |
1605 | continue; |
1629 | } |
1606 | } |
1630 | |
1607 | |
1631 | /* 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 |
1632 | * pickups */ |
1609 | * pickups */ |
… | |
… | |
1654 | continue; |
1631 | continue; |
1655 | } |
1632 | } |
1656 | } |
1633 | } |
1657 | } /* the new pickup model */ |
1634 | } /* the new pickup model */ |
1658 | } |
1635 | } |
|
|
1636 | |
1659 | return !stop; |
1637 | return !stop; |
1660 | } |
1638 | } |
1661 | |
1639 | |
1662 | /* |
1640 | /* |
1663 | * Find an arrow in the inventory and after that |
1641 | * Find an arrow in the inventory and after that |
… | |
… | |
1762 | |
1740 | |
1763 | object * |
1741 | object * |
1764 | pick_arrow_target (object *op, const char *type, int dir) |
1742 | pick_arrow_target (object *op, const char *type, int dir) |
1765 | { |
1743 | { |
1766 | object *tmp = NULL; |
1744 | object *tmp = NULL; |
1767 | mapstruct *m; |
1745 | maptile *m; |
1768 | int i, mflags, found, number; |
1746 | int i, mflags, found, number; |
1769 | sint16 x, y; |
1747 | sint16 x, y; |
1770 | |
1748 | |
1771 | if (op->map == NULL) |
1749 | if (op->map == NULL) |
1772 | return find_arrow (op, type); |
1750 | return find_arrow (op, type); |
… | |
… | |
1833 | int |
1811 | int |
1834 | 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) |
1835 | { |
1813 | { |
1836 | object *left, *bow; |
1814 | object *left, *bow; |
1837 | int bowspeed, mflags; |
1815 | int bowspeed, mflags; |
1838 | mapstruct *m; |
1816 | maptile *m; |
1839 | |
1817 | |
1840 | if (!dir) |
1818 | if (!dir) |
1841 | { |
1819 | { |
1842 | 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!"); |
1843 | return 0; |
1821 | return 0; |
… | |
… | |
1897 | } |
1875 | } |
1898 | |
1876 | |
1899 | /* this should not happen, but sometimes does */ |
1877 | /* this should not happen, but sometimes does */ |
1900 | if (arrow->nrof == 0) |
1878 | if (arrow->nrof == 0) |
1901 | { |
1879 | { |
1902 | remove_ob (arrow); |
1880 | arrow->destroy (); |
1903 | free_object (arrow); |
|
|
1904 | return 0; |
1881 | return 0; |
1905 | } |
1882 | } |
1906 | |
1883 | |
1907 | left = arrow; /* these are arrows left to the player */ |
1884 | left = arrow; /* these are arrows left to the player */ |
1908 | arrow = get_split_ob (arrow, 1); |
1885 | arrow = get_split_ob (arrow, 1); |
1909 | if (arrow == NULL) |
1886 | if (arrow == NULL) |
1910 | { |
1887 | { |
1911 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1888 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1912 | return 0; |
1889 | return 0; |
1913 | } |
1890 | } |
1914 | set_owner (arrow, op); |
1891 | arrow->set_owner (op); |
1915 | arrow->skill = bow->skill; |
1892 | arrow->skill = bow->skill; |
1916 | |
1893 | |
1917 | arrow->direction = dir; |
1894 | arrow->direction = dir; |
1918 | arrow->x = sx; |
1895 | arrow->x = sx; |
1919 | arrow->y = sy; |
1896 | arrow->y = sy; |
… | |
… | |
2127 | case range_misc: |
2104 | case range_misc: |
2128 | fire_misc_object (op, dir); |
2105 | fire_misc_object (op, dir); |
2129 | return; |
2106 | return; |
2130 | |
2107 | |
2131 | case range_golem: /* Control summoned monsters from scrolls */ |
2108 | case range_golem: /* Control summoned monsters from scrolls */ |
2132 | if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) |
2109 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2133 | { |
2110 | { |
2134 | op->contr->ranges[range_golem] = NULL; |
2111 | op->contr->ranges[range_golem] = 0; |
2135 | op->contr->shoottype = range_none; |
2112 | op->contr->shoottype = range_none; |
2136 | op->contr->golem_count = 0; |
|
|
2137 | } |
2113 | } |
2138 | else |
2114 | else |
2139 | control_golem (op->contr->ranges[range_golem], dir); |
2115 | control_golem (op->contr->ranges[range_golem], dir); |
2140 | return; |
2116 | return; |
2141 | |
2117 | |
… | |
… | |
2303 | move_player_attack (object *op, int dir) |
2279 | move_player_attack (object *op, int dir) |
2304 | { |
2280 | { |
2305 | object *tmp, *mon; |
2281 | object *tmp, *mon; |
2306 | sint16 nx, ny; |
2282 | sint16 nx, ny; |
2307 | int on_battleground; |
2283 | int on_battleground; |
2308 | mapstruct *m; |
2284 | maptile *m; |
2309 | |
2285 | |
2310 | nx = freearr_x[dir] + op->x; |
2286 | nx = freearr_x[dir] + op->x; |
2311 | ny = freearr_y[dir] + op->y; |
2287 | ny = freearr_y[dir] + op->y; |
2312 | |
2288 | |
2313 | on_battleground = op_on_battleground (op, NULL, NULL); |
2289 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2349 | if (tmp == op) |
2325 | if (tmp == op) |
2350 | { |
2326 | { |
2351 | tmp = tmp->above; |
2327 | tmp = tmp->above; |
2352 | continue; |
2328 | continue; |
2353 | } |
2329 | } |
|
|
2330 | |
2354 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2331 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2355 | { |
2332 | { |
2356 | mon = tmp; |
2333 | mon = tmp; |
2357 | break; |
2334 | break; |
2358 | } |
2335 | } |
|
|
2336 | |
2359 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2337 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2360 | mon = tmp; |
2338 | mon = tmp; |
|
|
2339 | |
2361 | tmp = tmp->above; |
2340 | tmp = tmp->above; |
2362 | } |
2341 | } |
2363 | |
2342 | |
2364 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2343 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2365 | return; /* into a wall */ |
2344 | return; /* into a wall */ |
… | |
… | |
2384 | * player owns it and it is either friendly or unagressive. |
2363 | * player owns it and it is either friendly or unagressive. |
2385 | */ |
2364 | */ |
2386 | if ((op->type == PLAYER) |
2365 | if ((op->type == PLAYER) |
2387 | #if COZY_SERVER |
2366 | #if COZY_SERVER |
2388 | && |
2367 | && |
2389 | ((get_owner (mon) && get_owner (mon)->contr |
2368 | ((mon->owner && mon->owner->contr |
2390 | && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) |
2369 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2391 | #else |
2370 | #else |
2392 | && get_owner (mon) == op |
2371 | && mon->owner == op |
2393 | #endif |
2372 | #endif |
2394 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2373 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2395 | { |
2374 | { |
2396 | /* If we're braced, we don't want to switch places with it */ |
2375 | /* If we're braced, we don't want to switch places with it */ |
2397 | if (op->contr->braced) |
2376 | if (op->contr->braced) |
… | |
… | |
2584 | /* I've been seeing crashes where the golem has been destroyed, but |
2563 | /* I've been seeing crashes where the golem has been destroyed, but |
2585 | * the player object still points to the defunct golem. The code that |
2564 | * the player object still points to the defunct golem. The code that |
2586 | * destroys the golem looks correct, and it doesn't always happen, so |
2565 | * destroys the golem looks correct, and it doesn't always happen, so |
2587 | * put this in a a workaround to clean up the golem pointer. |
2566 | * put this in a a workaround to clean up the golem pointer. |
2588 | */ |
2567 | */ |
2589 | if (op->contr->ranges[range_golem] && |
|
|
2590 | ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) |
2568 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2591 | { |
|
|
2592 | op->contr->ranges[range_golem] = NULL; |
2569 | op->contr->ranges[range_golem] = 0; |
2593 | op->contr->golem_count = 0; |
|
|
2594 | } |
|
|
2595 | |
2570 | |
2596 | /* call this here - we also will call this in do_ericserver, but |
2571 | /* call this here - we also will call this in do_ericserver, but |
2597 | * the players time has been increased when doericserver has been |
2572 | * the players time has been increased when doericserver has been |
2598 | * called, so we recheck it here. |
2573 | * called, so we recheck it here. |
2599 | */ |
2574 | */ |
… | |
… | |
2630 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2605 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2631 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2606 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2632 | { |
2607 | { |
2633 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2608 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2634 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2609 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
|
|
2610 | |
2635 | if (op->contr) |
2611 | if (op->contr) |
2636 | esrv_del_item (op->contr, tmp->count); |
2612 | esrv_del_item (op->contr, tmp->count); |
2637 | remove_ob (tmp); |
2613 | |
2638 | free_object (tmp); |
2614 | tmp->destroy (); |
2639 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2615 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
|
|
2616 | |
2640 | if (op->stats.hp < 0) |
2617 | if (op->stats.hp < 0) |
2641 | op->stats.hp = op->stats.maxhp; |
2618 | op->stats.hp = op->stats.maxhp; |
|
|
2619 | |
2642 | if (op->stats.food < 0) |
2620 | if (op->stats.food < 0) |
2643 | op->stats.food = 999; |
2621 | op->stats.food = 999; |
|
|
2622 | |
2644 | fix_player (op); |
2623 | fix_player (op); |
2645 | return 1; |
2624 | return 1; |
2646 | } |
2625 | } |
2647 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2626 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2648 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2627 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
… | |
… | |
2665 | next = op->below; /* Make sure we have a good value, in case |
2644 | next = op->below; /* Make sure we have a good value, in case |
2666 | * we remove object 'op' |
2645 | * we remove object 'op' |
2667 | */ |
2646 | */ |
2668 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2647 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2669 | { |
2648 | { |
2670 | remove_ob (op); |
2649 | op->remove (); |
2671 | op->x = env->x; |
2650 | op->x = env->x; |
2672 | op->y = env->y; |
2651 | op->y = env->y; |
2673 | if (env->type == PLAYER) |
2652 | if (env->type == PLAYER) |
2674 | esrv_del_item (env->contr, op->count); |
2653 | esrv_del_item (env->contr, op->count); |
2675 | insert_ob_in_map (op, env->map, NULL, 0); |
2654 | insert_ob_in_map (op, env->map, NULL, 0); |
… | |
… | |
2943 | { |
2922 | { |
2944 | char buf[MAX_BUF]; |
2923 | char buf[MAX_BUF]; |
2945 | int x, y; |
2924 | int x, y; |
2946 | |
2925 | |
2947 | //int i; |
2926 | //int i; |
2948 | mapstruct *map; /* this is for resurrection */ |
2927 | maptile *map; /* this is for resurrection */ |
2949 | |
2928 | |
2950 | /* int z; |
2929 | /* int z; |
2951 | int num_stats_lose; |
2930 | int num_stats_lose; |
2952 | int lost_a_stat; |
2931 | int lost_a_stat; |
2953 | int lose_this_stat; |
2932 | int lose_this_stat; |
… | |
… | |
2972 | /* restore player */ |
2951 | /* restore player */ |
2973 | at = archetype::find ("poisoning"); |
2952 | at = archetype::find ("poisoning"); |
2974 | tmp = present_arch_in_ob (at, op); |
2953 | tmp = present_arch_in_ob (at, op); |
2975 | if (tmp) |
2954 | if (tmp) |
2976 | { |
2955 | { |
2977 | remove_ob (tmp); |
2956 | tmp->destroy (); |
2978 | free_object (tmp); |
|
|
2979 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2957 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2980 | } |
2958 | } |
2981 | |
2959 | |
2982 | at = archetype::find ("confusion"); |
2960 | at = archetype::find ("confusion"); |
2983 | tmp = present_arch_in_ob (at, op); |
2961 | tmp = present_arch_in_ob (at, op); |
2984 | if (tmp) |
2962 | if (tmp) |
2985 | { |
2963 | { |
2986 | remove_ob (tmp); |
2964 | tmp->destroy (); |
2987 | free_object (tmp); |
|
|
2988 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2965 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2989 | } |
2966 | } |
2990 | |
2967 | |
2991 | cure_disease (op, 0); /* remove any disease */ |
2968 | cure_disease (op, 0); /* remove any disease */ |
2992 | op->stats.hp = op->stats.maxhp; |
2969 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
3169 | /* determine_god() seems to not work sometimes... why is this? |
3146 | /* determine_god() seems to not work sometimes... why is this? |
3170 | Should I be using something else? GD */ |
3147 | Should I be using something else? GD */ |
3171 | const char *god = determine_god (op); |
3148 | const char *god = determine_god (op); |
3172 | |
3149 | |
3173 | if (god && (strcmp (god, "none"))) |
3150 | if (god && (strcmp (god, "none"))) |
3174 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); |
3151 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3175 | else |
3152 | else |
3176 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); |
3153 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
3177 | } |
3154 | } |
|
|
3155 | #else |
|
|
3156 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3178 | #endif |
3157 | #endif |
3179 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3180 | |
3158 | |
3181 | /* Put a gravestone up where the character 'almost' died. List the |
3159 | /* Put a gravestone up where the character 'almost' died. List the |
3182 | * exp loss on the stone. |
3160 | * exp loss on the stone. |
3183 | */ |
3161 | */ |
3184 | tmp = arch_to_object (archetype::find ("gravestone")); |
3162 | tmp = arch_to_object (archetype::find ("gravestone")); |
… | |
… | |
3189 | 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); |
3167 | 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); |
3190 | tmp->msg = buf; |
3168 | tmp->msg = buf; |
3191 | tmp->x = op->x, tmp->y = op->y; |
3169 | tmp->x = op->x, tmp->y = op->y; |
3192 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3170 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3193 | |
3171 | |
3194 | /**************************************/ |
3172 | /**************************************/ |
3195 | /* */ |
3173 | /* */ |
3196 | /* Subtract the experience points, */ |
3174 | /* Subtract the experience points, */ |
3197 | /* if we died cause of food, give us */ |
3175 | /* if we died cause of food, give us */ |
3198 | /* food, and reset HP's... */ |
3176 | /* food, and reset HP's... */ |
3199 | /* */ |
3177 | /* */ |
3200 | |
|
|
3201 | /**************************************/ |
3178 | /**************************************/ |
3202 | |
3179 | |
3203 | /* remove any poisoning and confusion the character may be suffering. */ |
3180 | /* remove any poisoning and confusion the character may be suffering. */ |
3204 | /* restore player */ |
3181 | /* restore player */ |
3205 | at = archetype::find ("poisoning"); |
3182 | at = archetype::find ("poisoning"); |
3206 | tmp = present_arch_in_ob (at, op); |
3183 | tmp = present_arch_in_ob (at, op); |
|
|
3184 | |
3207 | if (tmp) |
3185 | if (tmp) |
3208 | { |
3186 | { |
3209 | remove_ob (tmp); |
3187 | tmp->destroy (); |
3210 | free_object (tmp); |
|
|
3211 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3188 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3212 | } |
3189 | } |
3213 | |
3190 | |
3214 | at = archetype::find ("confusion"); |
3191 | at = archetype::find ("confusion"); |
3215 | tmp = present_arch_in_ob (at, op); |
3192 | tmp = present_arch_in_ob (at, op); |
3216 | if (tmp) |
3193 | if (tmp) |
3217 | { |
3194 | { |
3218 | remove_ob (tmp); |
3195 | tmp->destroy (); |
3219 | free_object (tmp); |
|
|
3220 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3196 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3221 | } |
3197 | } |
|
|
3198 | |
3222 | cure_disease (op, 0); /* remove any disease */ |
3199 | cure_disease (op, 0); /* remove any disease */ |
3223 | |
3200 | |
3224 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3201 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3225 | apply_death_exp_penalty (op); |
3202 | apply_death_exp_penalty (op); |
3226 | if (op->stats.food < 100) |
3203 | if (op->stats.food < 100) |
… | |
… | |
3236 | */ |
3213 | */ |
3237 | |
3214 | |
3238 | if (is_in_shop (op)) |
3215 | if (is_in_shop (op)) |
3239 | remove_unpaid_objects (op->inv, op); |
3216 | remove_unpaid_objects (op->inv, op); |
3240 | |
3217 | |
3241 | /****************************************/ |
3218 | /****************************************/ |
3242 | /* */ |
3219 | /* */ |
3243 | /* Move player to his current respawn- */ |
3220 | /* Move player to his current respawn- */ |
3244 | /* position (usually last savebed) */ |
3221 | /* position (usually last savebed) */ |
3245 | /* */ |
3222 | /* */ |
3246 | |
|
|
3247 | /****************************************/ |
3223 | /****************************************/ |
3248 | |
3224 | |
3249 | enter_player_savebed (op); |
3225 | enter_player_savebed (op); |
3250 | |
3226 | |
3251 | /* Save the player before inserting the force to reduce |
3227 | /* Save the player before inserting the force to reduce |
3252 | * chance of abuse. |
3228 | * chance of abuse. |
… | |
… | |
3259 | * spell effects. So first see if there is a spell effect |
3235 | * spell effects. So first see if there is a spell effect |
3260 | * on the space that might harm the player. |
3236 | * on the space that might harm the player. |
3261 | */ |
3237 | */ |
3262 | will_kill_again = 0; |
3238 | will_kill_again = 0; |
3263 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3239 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3264 | { |
|
|
3265 | if (tmp->type == SPELL_EFFECT) |
3240 | if (tmp->type == SPELL_EFFECT) |
3266 | will_kill_again |= tmp->attacktype; |
3241 | will_kill_again |= tmp->attacktype; |
3267 | } |
3242 | |
3268 | if (will_kill_again) |
3243 | if (will_kill_again) |
3269 | { |
3244 | { |
3270 | object *force; |
3245 | object *force; |
3271 | int at; |
3246 | int at; |
3272 | |
3247 | |
… | |
… | |
3274 | /* 50 ticks should be enough time for the spell to abate */ |
3249 | /* 50 ticks should be enough time for the spell to abate */ |
3275 | force->speed = 0.1; |
3250 | force->speed = 0.1; |
3276 | force->speed_left = -5.0; |
3251 | force->speed_left = -5.0; |
3277 | SET_FLAG (force, FLAG_APPLIED); |
3252 | SET_FLAG (force, FLAG_APPLIED); |
3278 | for (at = 0; at < NROFATTACKS; at++) |
3253 | for (at = 0; at < NROFATTACKS; at++) |
3279 | { |
|
|
3280 | if (will_kill_again & (1 << at)) |
3254 | if (will_kill_again & (1 << at)) |
3281 | force->resist[at] = 100; |
3255 | force->resist[at] = 100; |
3282 | } |
3256 | |
3283 | insert_ob_in_ob (force, op); |
3257 | insert_ob_in_ob (force, op); |
3284 | fix_player (op); |
3258 | fix_player (op); |
3285 | |
3259 | |
3286 | } |
3260 | } |
3287 | |
3261 | |
… | |
… | |
3297 | op->contr->party = NULL; |
3271 | op->contr->party = NULL; |
3298 | if (settings.set_title == TRUE) |
3272 | if (settings.set_title == TRUE) |
3299 | op->contr->own_title[0] = '\0'; |
3273 | op->contr->own_title[0] = '\0'; |
3300 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3274 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3301 | check_score (op); |
3275 | check_score (op); |
|
|
3276 | |
3302 | if (op->contr->ranges[range_golem] != NULL) |
3277 | if (op->contr->ranges[range_golem]) |
3303 | { |
3278 | { |
3304 | remove_friendly_object (op->contr->ranges[range_golem]); |
3279 | remove_friendly_object (op->contr->ranges[range_golem]); |
3305 | remove_ob (op->contr->ranges[range_golem]); |
3280 | op->contr->ranges[range_golem]->destroy (); |
3306 | free_object (op->contr->ranges[range_golem]); |
|
|
3307 | op->contr->ranges[range_golem] = NULL; |
3281 | op->contr->ranges[range_golem] = 0; |
3308 | op->contr->golem_count = 0; |
|
|
3309 | } |
3282 | } |
|
|
3283 | |
3310 | loot_object (op); /* Remove some of the items for good */ |
3284 | loot_object (op); /* Remove some of the items for good */ |
3311 | remove_ob (op); |
3285 | op->remove (); |
3312 | op->direction = 0; |
3286 | op->direction = 0; |
3313 | |
3287 | |
3314 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3288 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3315 | { |
3289 | { |
3316 | delete_character (op->name, 0); |
3290 | delete_character (op->name, 0); |
… | |
… | |
3369 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3343 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3370 | { |
3344 | { |
3371 | next = tmp->below; |
3345 | next = tmp->below; |
3372 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3346 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3373 | continue; |
3347 | continue; |
3374 | remove_ob (tmp); |
3348 | tmp->remove (); |
3375 | tmp->x = op->x, tmp->y = op->y; |
3349 | tmp->x = op->x, tmp->y = op->y; |
3376 | if (tmp->type == CONTAINER) |
3350 | if (tmp->type == CONTAINER) |
3377 | { /* empty container to ground */ |
3351 | { /* empty container to ground */ |
3378 | loot_object (tmp); |
3352 | loot_object (tmp); |
3379 | } |
3353 | } |
3380 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3354 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3381 | { |
3355 | { |
3382 | if (tmp->nrof > 1) |
3356 | if (tmp->nrof > 1) |
3383 | { |
3357 | { |
3384 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3358 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3385 | free_object (tmp2); |
3359 | tmp2->destroy (); |
3386 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3360 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3387 | } |
3361 | } |
3388 | else |
3362 | else |
3389 | free_object (tmp); |
3363 | tmp->destroy (); |
3390 | } |
3364 | } |
3391 | else |
3365 | else |
3392 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3366 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3393 | } |
3367 | } |
3394 | } |
3368 | } |
… | |
… | |
3459 | if (op->type == PLAYER) |
3433 | if (op->type == PLAYER) |
3460 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3434 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3461 | |
3435 | |
3462 | cast_spell (op, throw_ob, dir, spob, NULL); |
3436 | cast_spell (op, throw_ob, dir, spob, NULL); |
3463 | |
3437 | |
3464 | if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) |
3438 | throw_ob->destroy (); |
3465 | remove_ob (throw_ob); |
|
|
3466 | free_object (throw_ob); |
|
|
3467 | } |
3439 | } |
3468 | |
3440 | |
3469 | void |
3441 | void |
3470 | make_visible (object *op) |
3442 | make_visible (object *op) |
3471 | { |
3443 | { |
… | |
… | |
3587 | int |
3559 | int |
3588 | stand_near_hostile (object *who) |
3560 | stand_near_hostile (object *who) |
3589 | { |
3561 | { |
3590 | object *tmp = NULL; |
3562 | object *tmp = NULL; |
3591 | int i, friendly = 0, player = 0, mflags; |
3563 | int i, friendly = 0, player = 0, mflags; |
3592 | mapstruct *m; |
3564 | maptile *m; |
3593 | sint16 x, y; |
3565 | sint16 x, y; |
3594 | |
3566 | |
3595 | if (!who) |
3567 | if (!who) |
3596 | return 0; |
3568 | return 0; |
3597 | |
3569 | |