… | |
… | |
53 | * subtype 5: arch or race |
53 | * subtype 5: arch or race |
54 | * subtype 7: all three |
54 | * subtype 7: all three |
55 | */ |
55 | */ |
56 | if (op->subtype) |
56 | if (op->subtype) |
57 | { |
57 | { |
58 | arch_flag = (op->subtype & 1); |
58 | arch_flag = op->subtype & 1; |
59 | name_flag = (op->subtype & 2); |
59 | name_flag = op->subtype & 2; |
60 | race_flag = (op->subtype & 4); |
60 | race_flag = op->subtype & 4; |
61 | } |
61 | } |
62 | else |
62 | else |
63 | { |
63 | { |
64 | arch_flag = 1; |
64 | arch_flag = 1; |
65 | name_flag = 1; |
65 | name_flag = 1; |
… | |
… | |
113 | { |
113 | { |
114 | if (operate_altar (altar, &money)) |
114 | if (operate_altar (altar, &money)) |
115 | { |
115 | { |
116 | identify (marked); |
116 | identify (marked); |
117 | |
117 | |
118 | buf.printf ("You have %s.\n\n", long_desc (marked, pl)); |
118 | buf.printf ("You have %s.\r", long_desc (marked, pl)); |
119 | if (marked->msg) |
119 | if (marked->msg) |
120 | buf << "The item has a story:\n\n" << marked->msg << "\n\n"; |
120 | buf << "The item has a story:\r" << marked->msg << "\n\n"; |
121 | |
121 | |
122 | return !money; |
122 | return !money; |
123 | } |
123 | } |
124 | } |
124 | } |
125 | |
125 | |
… | |
… | |
129 | { |
129 | { |
130 | if (operate_altar (altar, &money)) |
130 | if (operate_altar (altar, &money)) |
131 | { |
131 | { |
132 | identify (id); |
132 | identify (id); |
133 | |
133 | |
134 | buf.printf ("You have %s.\n\n", long_desc (id, pl)); |
134 | buf.printf ("You have %s.\r", long_desc (id, pl)); |
135 | if (id->msg) |
135 | if (id->msg) |
136 | buf << "The item has a story:\n\n" << id->msg << "\n\n"; |
136 | buf << "The item has a story:\r" << id->msg << "\n\n"; |
137 | |
137 | |
138 | /* If no more money, might as well quit now */ |
138 | /* If no more money, might as well quit now */ |
139 | if (!money || !check_altar_sacrifice (altar, money)) |
139 | if (!money || !check_altar_sacrifice (altar, money)) |
140 | break; |
140 | break; |
141 | } |
141 | } |
… | |
… | |
1260 | * Handles applying a sign. |
1260 | * Handles applying a sign. |
1261 | */ |
1261 | */ |
1262 | static void |
1262 | static void |
1263 | apply_sign (object *op, object *sign, int autoapply) |
1263 | apply_sign (object *op, object *sign, int autoapply) |
1264 | { |
1264 | { |
1265 | readable_message_type *msgType; |
1265 | if (sign->has_dialogue ()) |
|
|
1266 | { |
|
|
1267 | op->statusmsg (form ("Maybe you should I<talk> to the %s instead?", &sign->name)); |
|
|
1268 | return; |
|
|
1269 | } |
1266 | |
1270 | |
1267 | if (!sign->msg) |
1271 | if (!sign->msg) |
1268 | { |
1272 | { |
1269 | op->statusmsg ("Nothing is written on it."); |
1273 | op->statusmsg ("Nothing is written on it."); |
1270 | return; |
1274 | return; |
… | |
… | |
1302 | ns->play_sound (sign->sound); |
1306 | ns->play_sound (sign->sound); |
1303 | else if (autoapply) |
1307 | else if (autoapply) |
1304 | ns->play_sound (sound_find ("msg_voice")); |
1308 | ns->play_sound (sound_find ("msg_voice")); |
1305 | |
1309 | |
1306 | if (ns->can_msg) |
1310 | if (ns->can_msg) |
1307 | op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n\n\n%s", &sign->name, &sign->msg)); |
1311 | op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n%s", &sign->name, &sign->msg)); |
1308 | else |
1312 | else |
1309 | { |
1313 | { |
1310 | msgType = get_readable_message_type (sign); |
1314 | readable_message_type *msgType = get_readable_message_type (sign); |
1311 | const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); |
1315 | const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); |
1312 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, somemsg, &sign->msg); |
1316 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, somemsg, &sign->msg); |
1313 | } |
1317 | } |
1314 | } |
1318 | } |
|
|
1319 | } |
|
|
1320 | |
|
|
1321 | static void |
|
|
1322 | move_apply_hole (object *trap, object *victim) |
|
|
1323 | { |
|
|
1324 | /* Hole not open? */ |
|
|
1325 | if (trap->stats.wc > 0) |
|
|
1326 | return; |
|
|
1327 | |
|
|
1328 | /* Is this a multipart monster and not the head? If so, return. |
|
|
1329 | * Processing will happen if the head runs into the pit |
|
|
1330 | */ |
|
|
1331 | if (victim->head) |
|
|
1332 | return; |
|
|
1333 | |
|
|
1334 | // now find all possible locations and randomly pick one |
|
|
1335 | int dir = find_free_spot (victim, trap->map, EXIT_X (trap), EXIT_Y (trap), 0, |
|
|
1336 | trap->range >= 3 ? SIZEOFFREE3 + 1 |
|
|
1337 | : trap->range >= 2 ? SIZEOFFREE2 + 1 |
|
|
1338 | : trap->range >= 1 ? SIZEOFFREE1 + 1 |
|
|
1339 | : SIZEOFFREE0 + 1); |
|
|
1340 | |
|
|
1341 | if (dir < 0) |
|
|
1342 | return; |
|
|
1343 | |
|
|
1344 | victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1345 | victim->statusmsg ("You fall through the hole!", NDI_RED); |
|
|
1346 | |
|
|
1347 | transfer_ob (victim, |
|
|
1348 | EXIT_X (trap) + freearr_x[dir], |
|
|
1349 | EXIT_Y (trap) + freearr_y[dir], |
|
|
1350 | 0, victim); |
1315 | } |
1351 | } |
1316 | |
1352 | |
1317 | /** |
1353 | /** |
1318 | * 'victim' moves onto 'trap' |
1354 | * 'victim' moves onto 'trap' |
1319 | * 'victim' leaves 'trap' |
1355 | * 'victim' leaves 'trap' |
… | |
… | |
1488 | case CHECK_INV: |
1524 | case CHECK_INV: |
1489 | check_inv (victim, trap); |
1525 | check_inv (victim, trap); |
1490 | goto leave; |
1526 | goto leave; |
1491 | |
1527 | |
1492 | case HOLE: |
1528 | case HOLE: |
1493 | /* Hole not open? */ |
1529 | move_apply_hole (trap, victim); |
1494 | if (trap->stats.wc > 0) |
|
|
1495 | goto leave; |
|
|
1496 | |
|
|
1497 | /* Is this a multipart monster and not the head? If so, return. |
|
|
1498 | * Processing will happen if the head runs into the pit |
|
|
1499 | */ |
|
|
1500 | if (victim->head) |
|
|
1501 | goto leave; |
|
|
1502 | |
|
|
1503 | victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1504 | victim->statusmsg ("You fall through the hole!", NDI_RED); |
|
|
1505 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
|
|
1506 | goto leave; |
1530 | goto leave; |
1507 | |
1531 | |
1508 | case EXIT: |
1532 | case EXIT: |
1509 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1533 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1510 | { |
1534 | { |
… | |
… | |
1603 | readable_message_type *msgType = get_readable_message_type (tmp); |
1627 | readable_message_type *msgType = get_readable_message_type (tmp); |
1604 | |
1628 | |
1605 | if (player *pl = op->contr) |
1629 | if (player *pl = op->contr) |
1606 | if (client *ns = pl->ns) |
1630 | if (client *ns = pl->ns) |
1607 | if (ns->can_msg) |
1631 | if (ns->can_msg) |
1608 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1632 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1609 | else |
1633 | else |
1610 | draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, |
1634 | draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, |
1611 | msgType->message_type, msgType->message_subtype, |
1635 | msgType->message_type, msgType->message_subtype, |
1612 | "You open the %s and start reading.\n%s", (char *)"%s\n%s", |
1636 | "You open the %s and start reading.\n%s", (char *)"%s\n%s", |
1613 | long_desc (tmp, op), &tmp->msg); |
1637 | long_desc (tmp, op), &tmp->msg); |
… | |
… | |
1941 | if (op->destroyed () || tmp->destroyed ()) |
1965 | if (op->destroyed () || tmp->destroyed ()) |
1942 | break; |
1966 | break; |
1943 | } |
1967 | } |
1944 | |
1968 | |
1945 | if (!tmp->destroyed () && !tmp->inv) |
1969 | if (!tmp->destroyed () && !tmp->inv) |
1946 | tmp->decrease (); |
1970 | tmp->decrease (true); |
1947 | } |
1971 | } |
1948 | |
1972 | |
1949 | /** |
1973 | /** |
1950 | * op eats food. |
1974 | * op eats food. |
1951 | * If player, takes care of messages and dragon special food. |
1975 | * If player, takes care of messages and dragon special food. |
… | |
… | |
3500 | auto_apply (object *op) |
3524 | auto_apply (object *op) |
3501 | { |
3525 | { |
3502 | object *tmp = NULL, *tmp2; |
3526 | object *tmp = NULL, *tmp2; |
3503 | int i; |
3527 | int i; |
3504 | |
3528 | |
|
|
3529 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
|
|
3530 | |
3505 | switch (op->type) |
3531 | switch (op->type) |
3506 | { |
3532 | { |
3507 | case SHOP_FLOOR: |
3533 | case SHOP_FLOOR: |
3508 | if (!op->has_random_items ()) |
3534 | if (!op->has_random_items ()) |
3509 | return 0; |
3535 | return 0; |
3510 | |
3536 | |
3511 | do |
3537 | do |
3512 | { |
3538 | { |
3513 | i = 10; /* let's give it 10 tries */ |
3539 | i = 10; /* let's give it 10 tries */ |
3514 | while ((tmp = generate_treasure (op->randomitems, |
3540 | while ((tmp = generate_treasure (op->randomitems, |
3515 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3541 | op->stats.exp |
|
|
3542 | ? (int) op->stats.exp |
|
|
3543 | : max (op->map->difficulty, 5))) |
|
|
3544 | == NULL && --i); |
|
|
3545 | |
3516 | if (tmp == NULL) |
3546 | if (tmp == NULL) |
3517 | return 0; |
3547 | return 0; |
|
|
3548 | |
3518 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3549 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3519 | { |
3550 | { |
3520 | tmp->destroy (); |
3551 | tmp->destroy (); |
3521 | tmp = NULL; |
3552 | tmp = NULL; |
3522 | } |
3553 | } |
… | |
… | |
3525 | |
3556 | |
3526 | tmp->x = op->x; |
3557 | tmp->x = op->x; |
3527 | tmp->y = op->y; |
3558 | tmp->y = op->y; |
3528 | SET_FLAG (tmp, FLAG_UNPAID); |
3559 | SET_FLAG (tmp, FLAG_UNPAID); |
3529 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3560 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3530 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
|
|
3531 | identify (tmp); |
3561 | identify (tmp); |
3532 | break; |
3562 | break; |
3533 | |
3563 | |
3534 | case TREASURE: |
3564 | case TREASURE: |
3535 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3565 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
… | |
… | |
3542 | /* If we generated an object and put it in this object inventory, |
3572 | /* If we generated an object and put it in this object inventory, |
3543 | * move it to the parent object as the current object is about |
3573 | * move it to the parent object as the current object is about |
3544 | * to disappear. An example of this item is the random_* stuff |
3574 | * to disappear. An example of this item is the random_* stuff |
3545 | * that is put inside other objects. |
3575 | * that is put inside other objects. |
3546 | */ |
3576 | */ |
3547 | for (tmp = op->inv; tmp; tmp = tmp2) |
|
|
3548 | { |
|
|
3549 | tmp2 = tmp->below; |
|
|
3550 | tmp->remove (); |
|
|
3551 | |
|
|
3552 | if (op->env) |
3577 | if (op->env) |
3553 | insert_ob_in_ob (tmp, op->env); |
3578 | while (op->inv) |
3554 | else |
3579 | op->env->insert (op->inv); |
3555 | tmp->destroy (); |
|
|
3556 | } |
|
|
3557 | |
3580 | |
3558 | op->destroy (); |
3581 | op->destroy (); |
3559 | break; |
3582 | break; |
3560 | } |
3583 | } |
3561 | return tmp ? 1 : 0; |
3584 | |
|
|
3585 | return !!tmp; |
3562 | } |
3586 | } |
3563 | |
3587 | |
3564 | /** |
3588 | /** |
3565 | * fix_auto_apply goes through the entire map every time a map |
3589 | * fix_auto_apply goes through the entire map every time a map |
3566 | * is loaded or swapped in and performs special actions for |
3590 | * is loaded or swapped in and performs special actions for |
… | |
… | |
3580 | |
3604 | |
3581 | if (tmp->inv) |
3605 | if (tmp->inv) |
3582 | { |
3606 | { |
3583 | object *invtmp, *invnext; |
3607 | object *invtmp, *invnext; |
3584 | |
3608 | |
3585 | for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) |
3609 | for (invtmp = tmp->inv; invtmp; invtmp = invnext) |
3586 | { |
3610 | { |
3587 | invnext = invtmp->below; |
3611 | invnext = invtmp->below; |
3588 | |
3612 | |
3589 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3613 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3590 | auto_apply (invtmp); |
3614 | auto_apply (invtmp); |
3591 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3615 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3592 | { |
3616 | { |
3593 | while ((invtmp->stats.hp--) > 0) |
3617 | while (invtmp->stats.hp-- > 0) |
3594 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3618 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3595 | |
3619 | |
3596 | invtmp->randomitems = NULL; |
3620 | invtmp->randomitems = NULL; |
3597 | } |
3621 | } |
3598 | else if (invtmp && invtmp->arch |
3622 | else if (invtmp && invtmp->arch |