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.280 by root, Wed Nov 23 06:11:47 2016 UTC vs.
Revision 1.281 by root, Sun Jan 29 02:47:05 2017 UTC

305 * Returns 0 if it was not able to work for some reason. 305 * Returns 0 if it was not able to work for some reason.
306 * 306 *
307 * Checks if weapon was prepared, if enough potions on the floor, ... 307 * Checks if weapon was prepared, if enough potions on the floor, ...
308 * 308 *
309 * We are hiding extra information about the weapon in the level and 309 * We are hiding extra information about the weapon in the level and
310 * last_eat numbers for an object. Hopefully this won't break anything ?? 310 * last_eat numbers for an object. Hopefully this won't break anything ??
311 * level == max improve last_eat == current improve 311 * level == max improve last_eat == current improve
312 */ 312 */
313static int 313static int
314improve_weapon (object *op, object *improver, object *weapon) 314improve_weapon (object *op, object *improver, object *weapon)
315{ 315{
667 item->nrof *= nr; 667 item->nrof *= nr;
668 668
669 if (converter->flag [FLAG_PRECIOUS]) 669 if (converter->flag [FLAG_PRECIOUS])
670 item->set_flag (FLAG_UNPAID); 670 item->set_flag (FLAG_UNPAID);
671 671
672 if (converter->is_in_shop ()) 672 if (converter->is_in_shop ())
673 { 673 {
674 // converters on shop floors don't work anymore, bug lets check for it 674 // converters on shop floors don't work anymore, bug lets check for it
675 // and report in case someone still does it. 675 // and report in case someone still does it.
676 LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", 676 LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n",
677 converter->debug_desc ()); 677 converter->debug_desc ());
680 else if (price_in < sint64 (item->nrof) * item->value) 680 else if (price_in < sint64 (item->nrof) * item->value)
681 { 681 {
682 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", 682 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n",
683 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); 683 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name);
684 /** 684 /**
685 * elmex: we are going to let the game continue, as the mapcreator 685 * elmex: we are going to let the game continue, as the mapcreator
686 * hopefully had something in mind when doing this. 686 * hopefully had something in mind when doing this.
687 */ 687 */
688 } 688 }
689 689
690 // elmex: only identify if we need to, for example so that generated money doesn't 690 // elmex: only identify if we need to, for example so that generated money doesn't
696 696
697 return 1; 697 return 1;
698} 698}
699 699
700/** 700/**
701 * Handle apply on containers. 701 * Handle apply on containers.
702 * By Eneq(@csd.uu.se). 702 * By Eneq(@csd.uu.se).
703 * Moved to own function and added many features [Tero.Haatanen@lut.fi] 703 * Moved to own function and added many features [Tero.Haatanen@lut.fi]
704 * added the alchemical cauldron to the code -b.t. 704 * added the alchemical cauldron to the code -b.t.
705 */ 705 */
706static int 706static int
972 } 972 }
973 973
974 /* Sign or magic mouth? Do we need to see it, or does it talk to us? 974 /* Sign or magic mouth? Do we need to see it, or does it talk to us?
975 * No way to know for sure. The presumption is basically that if 975 * No way to know for sure. The presumption is basically that if
976 * move_on is zero, it needs to be manually applied (doesn't talk 976 * move_on is zero, it needs to be manually applied (doesn't talk
977 * to us). 977 * to us).
978 */ 978 */
979 if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ] && !sign->move_on) 979 if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ] && !sign->move_on)
980 { 980 {
981 op->failmsg ("You are unable to read while blind!"); 981 op->failmsg ("You are unable to read while blind!");
982 return; 982 return;
1286 1286
1287 /* if we have an applied weapon/shield, and unapply it would free 1287 /* if we have an applied weapon/shield, and unapply it would free
1288 * enough slots to equip the new item, then just set "can 1288 * enough slots to equip the new item, then just set "can
1289 * apply unapply". We don't care about the logic below - if you have a 1289 * apply unapply". We don't care about the logic below - if you have a
1290 * shield equipped and try to equip another shield, there is only 1290 * shield equipped and try to equip another shield, there is only
1291 * one choice. However, the check for the number of body locations 1291 * one choice. However, the check for the number of body locations
1292 * does take into the account cases where what is being applied 1292 * does take into the account cases where what is being applied
1293 * may be two handed for example. 1293 * may be two handed for example.
1294 */ 1294 */
1295 if (ws) 1295 if (ws)
1296 if ((who->slot[i].used - ws->slot[i].info + op->slot[i].info) >= 0) 1296 if ((who->slot[i].used - ws->slot[i].info + op->slot[i].info) >= 0)
1315 else if (tmp != tmp1) 1315 else if (tmp != tmp1)
1316 retval |= CAN_APPLY_UNAPPLY_MULT; 1316 retval |= CAN_APPLY_UNAPPLY_MULT;
1317 1317
1318 /* This object isn't using up all the slots, so there must 1318 /* This object isn't using up all the slots, so there must
1319 * be another. If so, and it the new item doesn't need all 1319 * be another. If so, and it the new item doesn't need all
1320 * the slots, the player then has a choice. 1320 * the slots, the player then has a choice.
1321 */ 1321 */
1322 if ((who->slot[i].used - tmp1->slot[i].info != who->slot[i].info) 1322 if ((who->slot[i].used - tmp1->slot[i].info != who->slot[i].info)
1323 && abs (op->slot[i].info) < who->slot[i].info) 1323 && abs (op->slot[i].info) < who->slot[i].info)
1324 retval |= CAN_APPLY_UNAPPLY_CHOICE; 1324 retval |= CAN_APPLY_UNAPPLY_CHOICE;
1325 1325
1472 return 1; 1472 return 1;
1473 } 1473 }
1474 1474
1475 /* Ok. We are now at the state where we can apply the new object. 1475 /* Ok. We are now at the state where we can apply the new object.
1476 * Note that we don't have the checks for can_use_... 1476 * Note that we don't have the checks for can_use_...
1477 * below - that is already taken care of by can_apply_object. 1477 * below - that is already taken care of by can_apply_object.
1478 */ 1478 */
1479 1479
1480 // split away all the other items from the stack, so only one item is left 1480 // split away all the other items from the stack, so only one item is left
1481 tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0; 1481 tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0;
1482 1482
1670 arch_flag = 1; 1670 arch_flag = 1;
1671 name_flag = 1; 1671 name_flag = 1;
1672 race_flag = 1; 1672 race_flag = 1;
1673 } 1673 }
1674 1674
1675 /* If the director has race set, only affect objects with a arch, 1675 /* If the director has race set, only affect objects with a arch,
1676 * name or race that matches. 1676 * name or race that matches.
1677 */ 1677 */
1678 if ((op->race) && 1678 if ((op->race) &&
1679 ((!(victim->arch && arch_flag && victim->arch->archname) || op->race != victim->arch->archname)) && 1679 ((!(victim->arch && arch_flag && victim->arch->archname) || op->race != victim->arch->archname)) &&
1680 ((!(victim->name && name_flag) || op->race != victim->name)) && 1680 ((!(victim->name && name_flag) || op->race != victim->name)) &&
2016 /* Only exits affect DMs. */ 2016 /* Only exits affect DMs. */
2017 if (victim->flag [FLAG_WIZPASS] && trap->type != EXIT && trap->type != SIGN) 2017 if (victim->flag [FLAG_WIZPASS] && trap->type != EXIT && trap->type != SIGN)
2018 return; 2018 return;
2019 2019
2020 /* move_apply() is the most likely candidate for causing unwanted and 2020 /* move_apply() is the most likely candidate for causing unwanted and
2021 * possibly unlimited recursion. 2021 * possibly unlimited recursion.
2022 */ 2022 */
2023 2023
2024 /* The following was changed because it was causing perfectly correct 2024 /* The following was changed because it was causing perfectly correct
2025 * maps to fail. 1) it's not an error to recurse: 2025 * maps to fail. 1) it's not an error to recurse:
2026 * rune detonates, summoning monster. monster lands on nearby rune. 2026 * rune detonates, summoning monster. monster lands on nearby rune.
2027 * nearby rune detonates. This sort of recursion is expected and 2027 * nearby rune detonates. This sort of recursion is expected and
2028 * proper. This code was causing needless crashes. 2028 * proper. This code was causing needless crashes.
2029 */ 2029 */
2030 if (recursion_depth >= 500) 2030 if (recursion_depth >= 500)
2031 { 2031 {
2032 LOG (llevDebug, "WARNING: move_apply(): aborting recursion " 2032 LOG (llevDebug, "WARNING: move_apply(): aborting recursion "
2033 "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->archname, &trap->name, &victim->arch->archname, &victim->name); 2033 "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->archname, &trap->name, &victim->arch->archname, &victim->name);
2128 } 2128 }
2129 2129
2130 for (ab = trap->above, max = 100, sound_was_played = 0; --max && ab; ab = ab_next) 2130 for (ab = trap->above, max = 100, sound_was_played = 0; --max && ab; ab = ab_next)
2131 { 2131 {
2132 /* need to set this up, since if we do transfer the object, 2132 /* need to set this up, since if we do transfer the object,
2133 * ab->above would be bogus 2133 * ab->above would be bogus
2134 */ 2134 */
2135 ab_next = ab->above; 2135 ab_next = ab->above;
2136 2136
2137 if ((ab->move_type && trap->move_on) || ab->move_type == 0) 2137 if ((ab->move_type && trap->move_on) || ab->move_type == 0)
2138 { 2138 {
2541 * 2541 *
2542 * 2- The learner's skill level in literacy adjusts the chance to learn 2542 * 2- The learner's skill level in literacy adjusts the chance to learn
2543 * a spell. 2543 * a spell.
2544 * 2544 *
2545 * 3 -Automatically fail to learn if you read while confused 2545 * 3 -Automatically fail to learn if you read while confused
2546 * 2546 *
2547 * Overall, chances are the same but a player will find having a high 2547 * Overall, chances are the same but a player will find having a high
2548 * literacy rate very useful! -b.t. 2548 * literacy rate very useful! -b.t.
2549 */ 2549 */
2550 if (op->flag [FLAG_CONFUSED]) 2550 if (op->flag [FLAG_CONFUSED])
2551 { 2551 {
2552 op->failmsg ("In your confused state you flub the wording of the text!"); 2552 op->failmsg ("In your confused state you flub the wording of the text!");
2553 scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace)); 2553 scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace));
3821 else if (invtmp->arch 3821 else if (invtmp->arch
3822 && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS 3822 && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS
3823 && invtmp->has_random_items ()) 3823 && invtmp->has_random_items ())
3824 { 3824 {
3825 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); 3825 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3826 /* Need to clear this so that we never try to create 3826 /* Need to clear this so that we never try to create
3827 * treasure again for this object 3827 * treasure again for this object
3828 */ 3828 */
3829 invtmp->randomitems = NULL; 3829 invtmp->randomitems = NULL;
3830 } 3830 }
3831 } 3831 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines