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.188 by elmex, Sun Feb 22 16:42:55 2009 UTC vs.
Revision 1.189 by elmex, Sun Feb 22 17:10:06 2009 UTC

396/**************************************************************************** 396/****************************************************************************
397 * Weapon improvement code follows 397 * Weapon improvement code follows
398 ****************************************************************************/ 398 ****************************************************************************/
399 399
400/** 400/**
401 * This function just checks whether who can handle equipping an item
402 * with item_power.
403 */
404
405bool
406check_item_power (object *who, int item_power)
407{
408 if (who->type == PLAYER
409 && item_power
410 && item_power + who->contr->item_power > settings.item_power_factor * who->level)
411 return false;
412 else
413 return true;
414}
415
416/**
401 * This returns the sum of nrof of item (arch name). 417 * This returns the sum of nrof of item (arch name).
402 */ 418 */
403static int 419static int
404check_item (object *op, shstr_cmp item) 420check_item (object *op, shstr_cmp item)
405{ 421{
450 } 466 }
451 467
452 prev = op; 468 prev = op;
453 op = op->below; 469 op = op->below;
454 } 470 }
455}
456
457/**
458 * This checks to see of the player (who) is sufficient level to use a weapon
459 * with improvs improvements (typically last_eat). We take an int here
460 * instead of the object so that the improvement code can pass along the
461 * increased value to see if the object is usuable.
462 * we return 1 (true) if the player can use the weapon.
463 */
464static int
465check_weapon_power (const object *who, int improvs)
466{
467/* Old code is below (commented out). Basically, since weapons are the only
468 * object players really have any control to improve, it's a bit harsh to
469 * require high level in some combat skill, so we just use overall level.
470 */
471#if 1
472 if (((who->level / 5) + 5) >= improvs)
473 return 1;
474 else
475 return 0;
476
477#else
478 int level = 0;
479
480 /* The skill system hands out wc and dam bonuses to fighters
481 * more generously than the old system (see fix_player). Thus
482 * we need to curtail the power of player enchanted weapons.
483 * I changed this to 1 improvement per "fighter" level/5 -b.t.
484 * Note: Nothing should break by allowing this ratio to be different or
485 * using normal level - it is just a matter of play balance.
486 */
487 if (who->type == PLAYER)
488 {
489 object *wc_obj = NULL;
490
491 for (wc_obj = who->inv; wc_obj; wc_obj = wc_obj->below)
492 if (wc_obj->type == SKILL && IS_COMBAT_SKILL (wc_obj->subtype) && wc_obj->level > level)
493 level = wc_obj->level;
494
495 if (!level)
496 {
497 LOG (llevError, "Error: Player: %s lacks wc experience object\n", who->name);
498 level = who->level;
499 }
500 }
501 else
502 level = who->level;
503
504 return (improvs <= ((level / 5) + 5));
505#endif
506} 471}
507 472
508/** 473/**
509 * Returns how many items of type improver->slaying there are under op. 474 * Returns how many items of type improver->slaying there are under op.
510 * Will display a message if none found, and 1 if improver->slaying is NULL. 475 * Will display a message if none found, and 1 if improver->slaying is NULL.
639 if (improver->stats.sp == IMPROVE_PREPARE) 604 if (improver->stats.sp == IMPROVE_PREPARE)
640 return prepare_weapon (op, improver, weapon); 605 return prepare_weapon (op, improver, weapon);
641 606
642 if (weapon->level == 0) 607 if (weapon->level == 0)
643 { 608 {
644 op->failmsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>"); 609 op->failmsg (
610 "This weapon has not been prepared."
611 " H<You first have to prepare a weapon with a prepare weapon scroll.>");
645 return 0; 612 return 0;
646 } 613 }
647 614
648 if (weapon->level == weapon->last_eat && weapon->item_power >= 100) 615 if (weapon->last_eat >= weapon->level // improvements used up
616 || weapon->item_power >= 100) // or item_power >= arbitrary limit of 100
649 { 617 {
650 op->failmsg ("This weapon cannot be improved any more."); 618 op->failmsg ("This weapon cannot be improved any more.");
651 return 0; 619 return 0;
652 } 620 }
653 621
654 if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1)) 622 if (QUERY_FLAG (weapon, FLAG_APPLIED)
623 && !check_item_power (op, weapon->item_power + 1))
655 { 624 {
656 op->failmsg ("Improving the weapon will make it too " 625 op->failmsg ("Improving the weapon will make it too "
657 "powerful for you to use. Unready it if you " 626 "powerful for you to use. Unready it if you "
658 "really want to improve it."); 627 "really want to improve it.");
659 return 0; 628 return 0;
3390 * skill so that the dam and wc get updated 3359 * skill so that the dam and wc get updated
3391 */ 3360 */
3392 who->change_skill (skop); 3361 who->change_skill (skop);
3393 } 3362 }
3394 3363
3395 if (who->type == PLAYER 3364 if (!check_item_power (who, op->item_power))
3396 && op->item_power
3397 && op->item_power + who->contr->item_power > settings.item_power_factor * who->level)
3398 { 3365 {
3399 who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); 3366 who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER);
3400 return 1; 3367 return 1;
3401 } 3368 }
3402 3369
3410 return RESULT_INT (0); 3377 return RESULT_INT (0);
3411 3378
3412 switch (op->type) 3379 switch (op->type)
3413 { 3380 {
3414 case WEAPON: 3381 case WEAPON:
3415 if (!check_weapon_power (who, op->last_eat))
3416 {
3417 who->failmsg ("This weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER);
3418
3419 if (tmp)
3420 insert_ob_in_ob (tmp, who);
3421
3422 return 1;
3423 }
3424
3425 //TODO: this obviously fails for players using a shorter prefix 3382 //TODO: this obviously fails for players using a shorter prefix
3426 // i.e. "R" can use Ragnarok's sword. 3383 // i.e. "R" can use Ragnarok's sword.
3427 if (op->level && !op->name.starts_with (who->name)) 3384 if (op->level && !op->name.starts_with (who->name))
3428 { 3385 {
3429 /* if the weapon does not have the name as the character, can't use it. */ 3386 /* if the weapon does not have the name as the character, can't use it. */
3555 } 3512 }
3556 3513
3557 break; 3514 break;
3558 3515
3559 case BOW: 3516 case BOW:
3560 if (!check_weapon_power (who, op->last_eat))
3561 {
3562 who->failmsg ("That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER);
3563
3564 if (tmp)
3565 insert_ob_in_ob (tmp, who);
3566
3567 return 1;
3568 }
3569
3570 if (op->level && !op->name.starts_with (who->name)) 3517 if (op->level && !op->name.starts_with (who->name))
3571 { 3518 {
3572 who->failmsg ("The weapon does not recognize you as its owner. " 3519 who->failmsg ("The weapon does not recognize you as its owner. "
3573 "H<Its name indicates that it belongs to somebody else.>"); 3520 "H<Its name indicates that it belongs to somebody else.>");
3574 if (tmp) 3521 if (tmp)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines