ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/apply.C
(Generate patch)

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.161 by elmex, Thu Jul 3 09:16:41 2008 UTC vs.
Revision 1.172 by root, Mon Sep 29 10:32:50 2008 UTC

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 }
703 weapon->last_eat++; 703 weapon->last_eat++;
704 weapon->item_power++; 704 weapon->item_power++;
705 improver->decrease (); 705 improver->decrease ();
706 return 1; 706 return 1;
707 } 707 }
708
708 if (improver->stats.sp == IMPROVE_ENCHANT) 709 if (improver->stats.sp == IMPROVE_ENCHANT)
709 { 710 {
710 weapon->magic++; 711 weapon->magic++;
711 weapon->last_eat++; 712 weapon->last_eat++;
712 op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); 713 op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic));
767 op->failmsg ("Something blocks the magic of the scroll!"); 768 op->failmsg ("Something blocks the magic of the scroll!");
768 return 0; 769 return 0;
769 } 770 }
770 771
771 otmp = find_marked_object (op); 772 otmp = find_marked_object (op);
773
772 if (!otmp) 774 if (!otmp)
773 { 775 {
774 op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); 776 op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>");
775 return 0; 777 return 0;
776 } 778 }
1258 * Handles applying a sign. 1260 * Handles applying a sign.
1259 */ 1261 */
1260static void 1262static void
1261apply_sign (object *op, object *sign, int autoapply) 1263apply_sign (object *op, object *sign, int autoapply)
1262{ 1264{
1263 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 }
1264 1270
1265 if (!sign->msg) 1271 if (!sign->msg)
1266 { 1272 {
1267 op->statusmsg ("Nothing is written on it."); 1273 op->statusmsg ("Nothing is written on it.");
1268 return; 1274 return;
1300 ns->play_sound (sign->sound); 1306 ns->play_sound (sign->sound);
1301 else if (autoapply) 1307 else if (autoapply)
1302 ns->play_sound (sound_find ("msg_voice")); 1308 ns->play_sound (sound_find ("msg_voice"));
1303 1309
1304 if (ns->can_msg) 1310 if (ns->can_msg)
1305 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));
1306 else 1312 else
1307 { 1313 {
1308 msgType = get_readable_message_type (sign); 1314 readable_message_type *msgType = get_readable_message_type (sign);
1309 const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); 1315 const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg);
1310 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);
1311 } 1317 }
1312 } 1318 }
1319}
1320
1321static void
1322move_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);
1313} 1351}
1314 1352
1315/** 1353/**
1316 * 'victim' moves onto 'trap' 1354 * 'victim' moves onto 'trap'
1317 * 'victim' leaves 'trap' 1355 * 'victim' leaves 'trap'
1486 case CHECK_INV: 1524 case CHECK_INV:
1487 check_inv (victim, trap); 1525 check_inv (victim, trap);
1488 goto leave; 1526 goto leave;
1489 1527
1490 case HOLE: 1528 case HOLE:
1491 /* Hole not open? */ 1529 move_apply_hole (trap, victim);
1492 if (trap->stats.wc > 0)
1493 goto leave;
1494
1495 /* Is this a multipart monster and not the head? If so, return.
1496 * Processing will happen if the head runs into the pit
1497 */
1498 if (victim->head)
1499 goto leave;
1500
1501 victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole"));
1502 victim->statusmsg ("You fall through the hole!", NDI_RED);
1503 transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim);
1504 goto leave; 1530 goto leave;
1505 1531
1506 case EXIT: 1532 case EXIT:
1507 if (victim->type == PLAYER && EXIT_PATH (trap)) 1533 if (victim->type == PLAYER && EXIT_PATH (trap))
1508 { 1534 {
1601 readable_message_type *msgType = get_readable_message_type (tmp); 1627 readable_message_type *msgType = get_readable_message_type (tmp);
1602 1628
1603 if (player *pl = op->contr) 1629 if (player *pl = op->contr)
1604 if (client *ns = pl->ns) 1630 if (client *ns = pl->ns)
1605 if (ns->can_msg) 1631 if (ns->can_msg)
1606 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));
1607 else 1633 else
1608 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, 1634 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op,
1609 msgType->message_type, msgType->message_subtype, 1635 msgType->message_type, msgType->message_subtype,
1610 "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",
1611 long_desc (tmp, op), &tmp->msg); 1637 long_desc (tmp, op), &tmp->msg);
1939 if (op->destroyed () || tmp->destroyed ()) 1965 if (op->destroyed () || tmp->destroyed ())
1940 break; 1966 break;
1941 } 1967 }
1942 1968
1943 if (!tmp->destroyed () && !tmp->inv) 1969 if (!tmp->destroyed () && !tmp->inv)
1944 tmp->decrease (); 1970 tmp->decrease (true);
1945} 1971}
1946 1972
1947/** 1973/**
1948 * op eats food. 1974 * op eats food.
1949 * If player, takes care of messages and dragon special food. 1975 * If player, takes care of messages and dragon special food.
3498auto_apply (object *op) 3524auto_apply (object *op)
3499{ 3525{
3500 object *tmp = NULL, *tmp2; 3526 object *tmp = NULL, *tmp2;
3501 int i; 3527 int i;
3502 3528
3529 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3530
3503 switch (op->type) 3531 switch (op->type)
3504 { 3532 {
3505 case SHOP_FLOOR: 3533 case SHOP_FLOOR:
3506 if (!op->has_random_items ()) 3534 if (!op->has_random_items ())
3507 return 0; 3535 return 0;
3508 3536
3509 do 3537 do
3510 { 3538 {
3511 i = 10; /* let's give it 10 tries */ 3539 i = 10; /* let's give it 10 tries */
3512 while ((tmp = generate_treasure (op->randomitems, 3540 while ((tmp = generate_treasure (op->randomitems,
3513 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
3514 if (tmp == NULL) 3546 if (tmp == NULL)
3515 return 0; 3547 return 0;
3548
3516 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 3549 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
3517 { 3550 {
3518 tmp->destroy (); 3551 tmp->destroy ();
3519 tmp = NULL; 3552 tmp = NULL;
3520 } 3553 }
3523 3556
3524 tmp->x = op->x; 3557 tmp->x = op->x;
3525 tmp->y = op->y; 3558 tmp->y = op->y;
3526 SET_FLAG (tmp, FLAG_UNPAID); 3559 SET_FLAG (tmp, FLAG_UNPAID);
3527 insert_ob_in_map (tmp, op->map, NULL, 0); 3560 insert_ob_in_map (tmp, op->map, NULL, 0);
3528 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3529 identify (tmp); 3561 identify (tmp);
3530 break; 3562 break;
3531 3563
3532 case TREASURE: 3564 case TREASURE:
3533 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 3565 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))
3540 /* 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,
3541 * 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
3542 * to disappear. An example of this item is the random_* stuff 3574 * to disappear. An example of this item is the random_* stuff
3543 * that is put inside other objects. 3575 * that is put inside other objects.
3544 */ 3576 */
3545 for (tmp = op->inv; tmp; tmp = tmp2)
3546 {
3547 tmp2 = tmp->below;
3548 tmp->remove ();
3549
3550 if (op->env) 3577 if (op->env)
3551 insert_ob_in_ob (tmp, op->env); 3578 while (op->inv)
3552 else 3579 op->env->insert (op->inv);
3553 tmp->destroy ();
3554 }
3555 3580
3556 op->destroy (); 3581 op->destroy ();
3557 break; 3582 break;
3558 } 3583 }
3559 return tmp ? 1 : 0; 3584
3585 return !!tmp;
3560} 3586}
3561 3587
3562/** 3588/**
3563 * 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
3564 * is loaded or swapped in and performs special actions for 3590 * is loaded or swapped in and performs special actions for
3578 3604
3579 if (tmp->inv) 3605 if (tmp->inv)
3580 { 3606 {
3581 object *invtmp, *invnext; 3607 object *invtmp, *invnext;
3582 3608
3583 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) 3609 for (invtmp = tmp->inv; invtmp; invtmp = invnext)
3584 { 3610 {
3585 invnext = invtmp->below; 3611 invnext = invtmp->below;
3586 3612
3587 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) 3613 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY))
3588 auto_apply (invtmp); 3614 auto_apply (invtmp);
3589 else if (invtmp->type == TREASURE && invtmp->has_random_items ()) 3615 else if (invtmp->type == TREASURE && invtmp->has_random_items ())
3590 { 3616 {
3591 while ((invtmp->stats.hp--) > 0) 3617 while (invtmp->stats.hp-- > 0)
3592 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); 3618 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3593 3619
3594 invtmp->randomitems = NULL; 3620 invtmp->randomitems = NULL;
3595 } 3621 }
3596 else if (invtmp && invtmp->arch 3622 else if (invtmp && invtmp->arch

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines