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.152 by root, Fri May 2 20:16:24 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 }
160 * matching item. 160 * matching item.
161 **/ 161 **/
162void 162void
163handle_apply_yield (object *tmp) 163handle_apply_yield (object *tmp)
164{ 164{
165 if (const char *yield = get_ob_key_value (tmp, "on_use_yield")) 165 if (shstr yield = tmp->kv (shstr_on_use_yield))
166 archetype::get (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR); 166 archetype::get (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR);
167} 167}
168 168
169/** 169/**
170 * Handles applying a potion. 170 * Handles applying a potion.
608 weapon->stats.exp || /* speed */ 608 weapon->stats.exp || /* speed */
609 weapon->stats.ac) /* AC - only taifu's I think */ 609 weapon->stats.ac) /* AC - only taifu's I think */
610 { 610 {
611 op->failmsg ("You cannot prepare magic weapons. " 611 op->failmsg ("You cannot prepare magic weapons. "
612 "H<A weapon is considered magical if it changes regeneration, " 612 "H<A weapon is considered magical if it changes regeneration, "
613 "speed or ac.>"); 613 "speed or ac, or has other protections.>");
614 return 0; 614 return 0;
615 } 615 }
616 616
617 sacrifice_count = check_sacrifice (op, improver); 617 sacrifice_count = check_sacrifice (op, improver);
618 if (sacrifice_count <= 0) 618 if (sacrifice_count <= 0)
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 }
970 ob_to_copy = converter->inv; 972 ob_to_copy = converter->inv;
971 for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) 973 for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++)
972 if (rndm (0, i) == 0) 974 if (rndm (0, i) == 0)
973 ob_to_copy = ob; 975 ob_to_copy = ob;
974 976
975 item = object_create_clone (ob_to_copy); 977 item = ob_to_copy->deep_clone ();
976 CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); 978 CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE);
977 unflag_inv (item, FLAG_IS_A_TEMPLATE); 979 unflag_inv (item, FLAG_IS_A_TEMPLATE);
978 } 980 }
979 else 981 else
980 { 982 {
1005 * elmex: we are going to let the game continue, as the mapcreator 1007 * elmex: we are going to let the game continue, as the mapcreator
1006 * hopefully had something in mind when doing this. 1008 * hopefully had something in mind when doing this.
1007 */ 1009 */
1008 } 1010 }
1009 1011
1010 SET_FLAG (item, FLAG_IDENTIFIED); 1012 // elmex: only identify if we need to, for example so that generated money doesn't
1013 // get an 'identified' flag so easily.
1014 if (need_identify (item))
1015 identify (item);
1016
1011 insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); 1017 insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y);
1012 return 1; 1018 return 1;
1013} 1019}
1014 1020
1015/** 1021/**
1254 * Handles applying a sign. 1260 * Handles applying a sign.
1255 */ 1261 */
1256static void 1262static void
1257apply_sign (object *op, object *sign, int autoapply) 1263apply_sign (object *op, object *sign, int autoapply)
1258{ 1264{
1259 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 }
1260 1270
1261 if (!sign->msg) 1271 if (!sign->msg)
1262 { 1272 {
1263 op->statusmsg ("Nothing is written on it."); 1273 op->statusmsg ("Nothing is written on it.");
1264 return; 1274 return;
1296 ns->play_sound (sign->sound); 1306 ns->play_sound (sign->sound);
1297 else if (autoapply) 1307 else if (autoapply)
1298 ns->play_sound (sound_find ("msg_voice")); 1308 ns->play_sound (sound_find ("msg_voice"));
1299 1309
1300 if (ns->can_msg) 1310 if (ns->can_msg)
1301 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));
1302 else 1312 else
1303 { 1313 {
1304 msgType = get_readable_message_type (sign); 1314 readable_message_type *msgType = get_readable_message_type (sign);
1305 const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); 1315 const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg);
1306 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);
1307 } 1317 }
1308 } 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);
1309} 1351}
1310 1352
1311/** 1353/**
1312 * 'victim' moves onto 'trap' 1354 * 'victim' moves onto 'trap'
1313 * 'victim' leaves 'trap' 1355 * 'victim' leaves 'trap'
1462 1504
1463 case CONVERTER: 1505 case CONVERTER:
1464 if (convert_item (victim, trap) < 0) 1506 if (convert_item (victim, trap) < 0)
1465 { 1507 {
1466 originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); 1508 originator->failmsg (format ("The %s seems to be broken!", query_name (trap)));
1467 get_archetype ("burnout")->insert_at (trap, trap); 1509 archetype::get (shstr_burnout)->insert_at (trap, trap);
1468 } 1510 }
1469 1511
1470 goto leave; 1512 goto leave;
1471 1513
1472 case TRIGGER_BUTTON: 1514 case TRIGGER_BUTTON:
1482 case CHECK_INV: 1524 case CHECK_INV:
1483 check_inv (victim, trap); 1525 check_inv (victim, trap);
1484 goto leave; 1526 goto leave;
1485 1527
1486 case HOLE: 1528 case HOLE:
1487 /* Hole not open? */ 1529 move_apply_hole (trap, victim);
1488 if (trap->stats.wc > 0)
1489 goto leave;
1490
1491 /* Is this a multipart monster and not the head? If so, return.
1492 * Processing will happen if the head runs into the pit
1493 */
1494 if (victim->head)
1495 goto leave;
1496
1497 victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole"));
1498 victim->statusmsg ("You fall through the hole!", NDI_RED);
1499 transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim);
1500 goto leave; 1530 goto leave;
1501 1531
1502 case EXIT: 1532 case EXIT:
1503 if (victim->type == PLAYER && EXIT_PATH (trap)) 1533 if (victim->type == PLAYER && EXIT_PATH (trap))
1504 { 1534 {
1597 readable_message_type *msgType = get_readable_message_type (tmp); 1627 readable_message_type *msgType = get_readable_message_type (tmp);
1598 1628
1599 if (player *pl = op->contr) 1629 if (player *pl = op->contr)
1600 if (client *ns = pl->ns) 1630 if (client *ns = pl->ns)
1601 if (ns->can_msg) 1631 if (ns->can_msg)
1602 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));
1603 else 1633 else
1604 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, 1634 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op,
1605 msgType->message_type, msgType->message_subtype, 1635 msgType->message_type, msgType->message_subtype,
1606 "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",
1607 long_desc (tmp, op), &tmp->msg); 1637 long_desc (tmp, op), &tmp->msg);
1935 if (op->destroyed () || tmp->destroyed ()) 1965 if (op->destroyed () || tmp->destroyed ())
1936 break; 1966 break;
1937 } 1967 }
1938 1968
1939 if (!tmp->destroyed () && !tmp->inv) 1969 if (!tmp->destroyed () && !tmp->inv)
1940 tmp->decrease (); 1970 tmp->decrease (true);
1941} 1971}
1942 1972
1943/** 1973/**
1944 * op eats food. 1974 * op eats food.
1945 * If player, takes care of messages and dragon special food. 1975 * If player, takes care of messages and dragon special food.
2212} 2242}
2213 2243
2214void 2244void
2215apply_poison (object *op, object *tmp) 2245apply_poison (object *op, object *tmp)
2216{ 2246{
2247 // need to do it now when it is still on the map
2248 handle_apply_yield (tmp);
2249
2217 object *poison = tmp->split (1); 2250 object *poison = tmp->split (1);
2218 2251
2219 if (op->type == PLAYER) 2252 if (op->type == PLAYER)
2220 { 2253 {
2221 op->contr->play_sound (sound_find ("drink_poison")); 2254 op->contr->play_sound (sound_find ("drink_poison"));
2228 LOG (llevDebug, "Trying to poison player/monster for %d hp\n", poison->stats.hp); 2261 LOG (llevDebug, "Trying to poison player/monster for %d hp\n", poison->stats.hp);
2229 hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); 2262 hit_player (op, poison->stats.hp, tmp, AT_POISON, 1);
2230 } 2263 }
2231 2264
2232 op->stats.food -= op->stats.food / 4; 2265 op->stats.food -= op->stats.food / 4;
2233 handle_apply_yield (poison);
2234 poison->destroy (); 2266 poison->destroy ();
2235} 2267}
2236 2268
2237/** 2269/**
2238 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. 2270 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit.
2341 * them in this function - they are passed to apply_special 2373 * them in this function - they are passed to apply_special
2342 */ 2374 */
2343int 2375int
2344manual_apply (object *op, object *tmp, int aflag) 2376manual_apply (object *op, object *tmp, int aflag)
2345{ 2377{
2346 if (tmp->head)
2347 tmp = tmp->head; 2378 tmp = tmp->head_ ();
2348 2379
2349 if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) 2380 if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED))
2350 { 2381 {
2351 if (op->type == PLAYER) 2382 if (op->type == PLAYER)
2352 { 2383 {
2560 default: 2591 default:
2561 return 0; 2592 return 0;
2562 } 2593 }
2563} 2594}
2564 2595
2565
2566/* quiet suppresses the "don't know how to apply" and "you must get it first" 2596/* quiet suppresses the "don't know how to apply" and "you must get it first"
2567 * messages as needed by player_apply_below(). But there can still be 2597 * messages as needed by player_apply_below(). But there can still be
2568 * "but you are floating high above the ground" messages. 2598 * "but you are floating high above the ground" messages.
2569 * 2599 *
2570 * Same return value as apply() function. 2600 * Same return value as apply() function.
2571 */ 2601 */
2572int 2602int
2573player_apply (object *pl, object *op, int aflag, int quiet) 2603player_apply (object *pl, object *op, int aflag, int quiet)
2574{ 2604{
2575 int tmp;
2576
2577 if (op->env && (pl->move_type & MOVE_FLYING)) 2605 if (!op->env && (pl->move_type & MOVE_FLYING))
2578 { 2606 {
2579 /* player is flying and applying object not in inventory */ 2607 /* player is flying and applying object not in inventory */
2580 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) 2608 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING))
2581 { 2609 {
2582 pl->failmsg ("But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); 2610 pl->failmsg ("But you are floating high above the ground! "
2611 "H<You have to stop levitating first, if you can, either by using your levitation skill, "
2612 "or waiting till the levitation effect wears off.>");
2583 return 0; 2613 return 0;
2584 } 2614 }
2585 } 2615 }
2586 2616
2587 pl->contr->last_used = op; 2617 pl->contr->last_used = op;
2588 2618
2589 tmp = manual_apply (pl, op, aflag); 2619 int tmp = manual_apply (pl, op, aflag);
2620
2590 if (!quiet) 2621 if (!quiet)
2591 { 2622 {
2592 if (tmp == 0) 2623 if (tmp == 0)
2593 pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); 2624 pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op)));
2594 else if (tmp == 2) 2625 else if (tmp == 2)
2686 break; 2717 break;
2687 2718
2688 case SKILL: 2719 case SKILL:
2689 if (who->contr) 2720 if (who->contr)
2690 { 2721 {
2722 if (IS_COMBAT_SKILL (op->subtype))
2723 who->change_weapon (who->contr->combat_ob = 0);
2724 else if (IS_RANGED_SKILL (op->subtype))
2725 who->change_weapon (who->contr->ranged_ob = 0);
2726
2691 if (!op->invisible) 2727 if (op->invisible)
2728 who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill));
2729 else
2692 who->statusmsg (format ("You stop using the %s.", query_name (op))); 2730 who->statusmsg (format ("You stop using the %s.", query_name (op)));
2693 else
2694 who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill));
2695 } 2731 }
2696 2732
2697 change_abil (who, op); 2733 change_abil (who, op);
2698 CLEAR_FLAG (who, FLAG_READY_SKILL); 2734 CLEAR_FLAG (who, FLAG_READY_SKILL);
2699 break; 2735 break;
3090 return 1; 3126 return 1;
3091 } 3127 }
3092 3128
3093 return unapply_special (who, op, aflags); 3129 return unapply_special (who, op, aflags);
3094 } 3130 }
3095
3096 if (basic_flag == AP_UNAPPLY) 3131 else if (basic_flag == AP_UNAPPLY)
3097 return 0; 3132 return 0;
3098 3133
3099 // if the item is combat/ranged, wield the relevant slot first 3134 // if the item is combat/ranged, wield the relevant slot first
3100 // to resolve conflicts. 3135 // to resolve conflicts.
3101 if (player *pl = who->contr) 3136 if (player *pl = who->contr)
3181 switch (op->type) 3216 switch (op->type)
3182 { 3217 {
3183 case WEAPON: 3218 case WEAPON:
3184 if (!check_weapon_power (who, op->last_eat)) 3219 if (!check_weapon_power (who, op->last_eat))
3185 { 3220 {
3186 op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!." LACK_ITEM_POWER); 3221 op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER);
3187 3222
3188 if (tmp) 3223 if (tmp)
3189 insert_ob_in_ob (tmp, who); 3224 insert_ob_in_ob (tmp, who);
3190 3225
3191 return 1; 3226 return 1;
3489auto_apply (object *op) 3524auto_apply (object *op)
3490{ 3525{
3491 object *tmp = NULL, *tmp2; 3526 object *tmp = NULL, *tmp2;
3492 int i; 3527 int i;
3493 3528
3529 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3530
3494 switch (op->type) 3531 switch (op->type)
3495 { 3532 {
3496 case SHOP_FLOOR: 3533 case SHOP_FLOOR:
3497 if (!op->has_random_items ()) 3534 if (!op->has_random_items ())
3498 return 0; 3535 return 0;
3499 3536
3500 do 3537 do
3501 { 3538 {
3502 i = 10; /* let's give it 10 tries */ 3539 i = 10; /* let's give it 10 tries */
3503 while ((tmp = generate_treasure (op->randomitems, 3540 while ((tmp = generate_treasure (op->randomitems,
3504 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
3505 if (tmp == NULL) 3546 if (tmp == NULL)
3506 return 0; 3547 return 0;
3548
3507 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 3549 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
3508 { 3550 {
3509 tmp->destroy (); 3551 tmp->destroy ();
3510 tmp = NULL; 3552 tmp = NULL;
3511 } 3553 }
3514 3556
3515 tmp->x = op->x; 3557 tmp->x = op->x;
3516 tmp->y = op->y; 3558 tmp->y = op->y;
3517 SET_FLAG (tmp, FLAG_UNPAID); 3559 SET_FLAG (tmp, FLAG_UNPAID);
3518 insert_ob_in_map (tmp, op->map, NULL, 0); 3560 insert_ob_in_map (tmp, op->map, NULL, 0);
3519 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3520 identify (tmp); 3561 identify (tmp);
3521 break; 3562 break;
3522 3563
3523 case TREASURE: 3564 case TREASURE:
3524 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 3565 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))
3531 /* 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,
3532 * 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
3533 * to disappear. An example of this item is the random_* stuff 3574 * to disappear. An example of this item is the random_* stuff
3534 * that is put inside other objects. 3575 * that is put inside other objects.
3535 */ 3576 */
3536 for (tmp = op->inv; tmp; tmp = tmp2)
3537 {
3538 tmp2 = tmp->below;
3539 tmp->remove ();
3540
3541 if (op->env) 3577 if (op->env)
3542 insert_ob_in_ob (tmp, op->env); 3578 while (op->inv)
3543 else 3579 op->env->insert (op->inv);
3544 tmp->destroy ();
3545 }
3546 3580
3547 op->destroy (); 3581 op->destroy ();
3548 break; 3582 break;
3549 } 3583 }
3550 return tmp ? 1 : 0; 3584
3585 return !!tmp;
3551} 3586}
3552 3587
3553/** 3588/**
3554 * 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
3555 * is loaded or swapped in and performs special actions for 3590 * is loaded or swapped in and performs special actions for
3569 3604
3570 if (tmp->inv) 3605 if (tmp->inv)
3571 { 3606 {
3572 object *invtmp, *invnext; 3607 object *invtmp, *invnext;
3573 3608
3574 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) 3609 for (invtmp = tmp->inv; invtmp; invtmp = invnext)
3575 { 3610 {
3576 invnext = invtmp->below; 3611 invnext = invtmp->below;
3577 3612
3578 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) 3613 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY))
3579 auto_apply (invtmp); 3614 auto_apply (invtmp);
3580 else if (invtmp->type == TREASURE && invtmp->has_random_items ()) 3615 else if (invtmp->type == TREASURE && invtmp->has_random_items ())
3581 { 3616 {
3582 while ((invtmp->stats.hp--) > 0) 3617 while (invtmp->stats.hp-- > 0)
3583 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); 3618 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3584 3619
3585 invtmp->randomitems = NULL; 3620 invtmp->randomitems = NULL;
3586 } 3621 }
3587 else if (invtmp && invtmp->arch 3622 else if (invtmp && invtmp->arch
3909 if (!strcmp (walk->name, "NOCLASSFACECHANGE")) 3944 if (!strcmp (walk->name, "NOCLASSFACECHANGE"))
3910 flag_change_face = 0; 3945 flag_change_face = 0;
3911 3946
3912 if (flag_change_face) 3947 if (flag_change_face)
3913 { 3948 {
3914 pl->animation_id = GET_ANIM_ID (change);
3915 pl->face = change->face; 3949 pl->face = change->face;
3916 3950 pl->animation_id = change->animation_id;
3917 if (QUERY_FLAG (change, FLAG_ANIMATE)) 3951 pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE];
3918 SET_FLAG (pl, FLAG_ANIMATE);
3919 else
3920 CLEAR_FLAG (pl, FLAG_ANIMATE);
3921 } 3952 }
3922 3953
3923 /* check the special case of can't use weapons */ 3954 /* check the special case of can't use weapons */
3924 /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ 3955 /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */
3925 if (!strcmp (change->name, "monk")) 3956 if (!strcmp (change->name, "monk"))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines