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.232 by root, Sun Mar 28 02:53:46 2010 UTC vs.
Revision 1.233 by root, Fri Apr 2 03:41:24 2010 UTC

1742 LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); 1742 LOG (llevError, "BUG: do_forget_spell(): spell not known\n");
1743 return; 1743 return;
1744 } 1744 }
1745 1745
1746 op->failmsg (format ("You lose knowledge of %s.", spell)); 1746 op->failmsg (format ("You lose knowledge of %s.", spell));
1747 player_unready_range_ob (op->contr, spob);
1748 esrv_remove_spell (op->contr, spob); 1747 esrv_remove_spell (op->contr, spob);
1749 spob->destroy (); 1748 spob->destroy ();
1750} 1749}
1751 1750
1752/** 1751/**
2019 which is not to be considered a dragon -> bail out */ 2018 which is not to be considered a dragon -> bail out */
2020 if (skin == NULL || abil == NULL) 2019 if (skin == NULL || abil == NULL)
2021 return 0; 2020 return 0;
2022 2021
2023 /* now start by filling stomache and health, according to food-value */ 2022 /* now start by filling stomache and health, according to food-value */
2024 if ((999 - op->stats.food) < meal->stats.food) 2023 if ((MAX_FOOD - op->stats.food) < meal->stats.food)
2025 op->stats.hp += (999 - op->stats.food) / 50; 2024 op->stats.hp += (MAX_FOOD - op->stats.food) / 50;
2026 else 2025 else
2027 op->stats.hp += meal->stats.food / 50; 2026 op->stats.hp += meal->stats.food / 50;
2028 2027
2029 if (op->stats.hp > op->stats.maxhp) 2028 min_it (op->stats.hp, op->stats.maxhp);
2030 op->stats.hp = op->stats.maxhp;
2031
2032 op->stats.food = min (999, op->stats.food + meal->stats.food); 2029 op->stats.food = min (MAX_FOOD, op->stats.food + meal->stats.food);
2033 2030
2034 /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */ 2031 /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */
2035 2032
2036 /* on to the interesting part: chances for adding resistance */ 2033 /* on to the interesting part: chances for adding resistance */
2037 for (i = 0; i < NROFATTACKS; i++) 2034 for (i = 0; i < NROFATTACKS; i++)
2154 if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp)) 2151 if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp))
2155 ; 2152 ;
2156 else 2153 else
2157 { 2154 {
2158 /* usual case - no dragon meal: */ 2155 /* usual case - no dragon meal: */
2159 if (op->stats.food + tmp->stats.food > 999) 2156 if (op->stats.food + tmp->stats.food > MAX_FOOD)
2160 { 2157 {
2161 if (tmp->type == FOOD || tmp->type == FLESH) 2158 if (tmp->type == FOOD || tmp->type == FLESH)
2162 op->failmsg ("You feel full, but what a waste of food!"); 2159 op->failmsg ("You feel full, but what a waste of food!");
2163 else 2160 else
2164 op->statusmsg ("Most of the drink goes down your face not your throat!"); 2161 op->statusmsg ("Most of the drink goes down your face not your throat!");
2188 /* eating message for dragon players */ 2185 /* eating message for dragon players */
2189 buf = format ("The %s tasted terrible!", &tmp->name); 2186 buf = format ("The %s tasted terrible!", &tmp->name);
2190 2187
2191 op->statusmsg (buf); 2188 op->statusmsg (buf);
2192 2189
2193 capacity_remaining = 999 - op->stats.food; 2190 capacity_remaining = MAX_FOOD - op->stats.food;
2194 op->stats.food += tmp->stats.food; 2191 op->stats.food += tmp->stats.food;
2195 if (capacity_remaining < tmp->stats.food) 2192 if (capacity_remaining < tmp->stats.food)
2196 op->stats.hp += capacity_remaining / 50; 2193 op->stats.hp += capacity_remaining / 50;
2197 else 2194 else
2198 op->stats.hp += tmp->stats.food / 50; 2195 op->stats.hp += tmp->stats.food / 50;
2199 2196
2200 if (op->stats.hp > op->stats.maxhp) 2197 min_it (op->stats.hp, op->stats.maxhp);
2201 op->stats.hp = op->stats.maxhp; 2198 min_it (op->stats.food, MAX_FOOD);
2202 if (op->stats.food > 999)
2203 op->stats.food = 999;
2204 } 2199 }
2205 2200
2206 /* special food hack -b.t. */ 2201 /* special food hack -b.t. */
2207 if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) 2202 if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED))
2208 eat_special_food (op, tmp); 2203 eat_special_food (op, tmp);
2776 case CLOAK: 2771 case CLOAK:
2777 case WAND: 2772 case WAND:
2778 case ROD: 2773 case ROD:
2779 case HORN: 2774 case HORN:
2780 case SKILL: 2775 case SKILL:
2776 case SPELL:
2781 case BOW: 2777 case BOW:
2778 case RANGED:
2782 case BUILDER: 2779 case BUILDER:
2783 case SKILL_TOOL: 2780 case SKILL_TOOL:
2784 if (op->env != who) 2781 if (op->env != who)
2785 return 2; /* not in inventory */ 2782 return 2; /* not in inventory */
2786 2783
2950{ 2947{
2951 if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) 2948 if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags))
2952 || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) 2949 || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags)))
2953 return RESULT_INT (0); 2950 return RESULT_INT (0);
2954 2951
2955 CLEAR_FLAG (op, FLAG_APPLIED); 2952 if (who->current_weapon == op)
2953 who->current_weapon = 0;
2954
2955 op->flag [FLAG_APPLIED] = false;
2956 2956
2957 switch (op->type) 2957 switch (op->type)
2958 { 2958 {
2959 case SKILL_TOOL: 2959 case SKILL:
2960 if (player *pl = who->contr)
2961 if (op->invisible)
2962 pl->statusmsg (format ("You can no longer use the skill: %s.", &op->skill));
2963 else
2964 pl->statusmsg (format ("You stop using the %s.", query_name (op)));
2965
2966 change_abil (who, op);
2967 who->flag [FLAG_READY_SKILL] = false;
2968 break;
2969
2960 case WEAPON: 2970 case WEAPON:
2971 who->statusmsg (format ("You unwield %s.", query_name (op)));
2972 change_abil (who, op);
2973 who->flag [FLAG_READY_WEAPON] = false;
2974
2961 // unapplying a weapon or skill tool should also unapply the skill it governs 2975 // unapplying a weapon or skill tool should also unapply the skill it governs
2962 // but this is hard, as it shouldn't do so when the skill can 2976 // but this is hard, as it shouldn't do so when the skill can
2963 // be used for other reasons 2977 // be used for other reasons
2964 for (object *tmp = who->inv; tmp; tmp = tmp->below) 2978 if (who->chosen_skill)
2965 if (tmp->skill == op->skill 2979 if (!who->chosen_skill->flag [FLAG_CAN_USE_SKILL])
2966 && tmp->type == SKILL
2967 && tmp->flag [FLAG_APPLIED]
2968 && !tmp->flag [FLAG_CAN_USE_SKILL])
2969 unapply_special (who, tmp, 0); 2980 unapply_special (who, op, 0);
2970 2981
2982 break;
2983
2984 case BOW:
2985 case WAND:
2986 case ROD:
2987 case HORN:
2988 case RANGED:
2971 if (player *pl = who->contr) 2989 if (player *pl = who->contr)
2972 if (op == pl->combat_ob)
2973 {
2974 pl->combat_ob = 0;
2975 who->change_weapon (pl->ranged_ob);
2976 }
2977
2978 change_abil (who, op);
2979
2980 if (op->type == WEAPON)
2981 { 2990 {
2982 who->flag [FLAG_READY_WEAPON] = false;
2983 who->statusmsg (format ("You unwield %s.", query_name (op))); 2991 who->statusmsg (format ("You unready %s.", query_name (op)));
2992 change_abil (who, op);
2984 } 2993 }
2985 else 2994 else
2986 who->flag [FLAG_READY_SKILL] = false;
2987
2988 break;
2989
2990 case SKILL:
2991 if (who->contr)
2992 { 2995 {
2993 if (op == who->contr->combat_ob) 2996 who->change_skill (0);
2994 {
2995 who->contr->combat_ob = 0;
2996 who->change_weapon (who->contr->ranged_ob);
2997 }
2998 2997
2999 if (op == who->contr->ranged_ob) 2998 if (op->type == BOW)
3000 { 2999 op->flag [FLAG_READY_BOW ] = false;
3001 who->contr->ranged_ob = 0;
3002 who->change_weapon (who->contr->combat_ob);
3003 }
3004
3005 if (op->invisible)
3006 who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill));
3007 else 3000 else
3008 who->statusmsg (format ("You stop using the %s.", query_name (op))); 3001 op->flag [FLAG_READY_RANGE] = false;
3009 } 3002 }
3010 3003
3011 change_abil (who, op);
3012 CLEAR_FLAG (who, FLAG_READY_SKILL);
3013 break; 3004 break;
3014 3005
3015 case ARMOUR: 3006 case ARMOUR:
3016 case HELMET: 3007 case HELMET:
3017 case SHIELD: 3008 case SHIELD:
3024 case CLOAK: 3015 case CLOAK:
3025 who->statusmsg (format ("You unwear %s.", query_name (op))); 3016 who->statusmsg (format ("You unwear %s.", query_name (op)));
3026 change_abil (who, op); 3017 change_abil (who, op);
3027 break; 3018 break;
3028 3019
3020 case SPELL:
3029 case BOW: 3021 case BUILDER:
3030 case WAND:
3031 case ROD:
3032 case HORN:
3033 if (player *pl = who->contr)
3034 {
3035 if (op == pl->ranged_ob)
3036 {
3037 pl->ranged_ob = 0;
3038 who->change_weapon (pl->combat_ob);
3039 }
3040
3041 who->statusmsg (format ("You unready %s.", query_name (op))); 3022 who->statusmsg (format ("You unready %s.", query_name (op)));
3042 }
3043 else
3044 {
3045 who->change_skill (0);
3046
3047 if (op->type == BOW)
3048 op->flag [FLAG_READY_BOW ] = false;
3049 else
3050 op->flag [FLAG_READY_RANGE] = false;
3051 }
3052
3053 break; 3023 break;
3054 3024
3055 case BUILDER: 3025 //case SKILL_TOOL://TODO
3056 if (who->contr)
3057 who->statusmsg (format ("You unready %s.", query_name (op)));
3058 break;
3059
3060 default: 3026 default:
3061 who->statusmsg (format ("You unapply %s.", query_name (op))); 3027 who->statusmsg (format ("You unapply %s.", query_name (op)));
3062 break; 3028 break;
3063 } 3029 }
3064 3030
3313 if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) 3279 if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW))
3314 retval |= CAN_APPLY_RESTRICTION; 3280 retval |= CAN_APPLY_RESTRICTION;
3315 } 3281 }
3316 3282
3317 return retval; 3283 return retval;
3284}
3285
3286// saner interface, returns successful status
3287bool
3288object::apply (object *ob, int aflags)
3289{
3290 bool want_apply = aflags & AP_APPLY;
3291
3292 if (ob->flag [FLAG_APPLIED] == want_apply)
3293 return true;
3294
3295 manual_apply (this, ob, aflags);
3296
3297 return ob->flag [FLAG_APPLIED] == want_apply;
3318} 3298}
3319 3299
3320/** 3300/**
3321 * who is the object using the object. It can be a monster. 3301 * who is the object using the object. It can be a monster.
3322 * op is the object they are using. op is an equipment type item, 3302 * op is the object they are using. op is an equipment type item,
3375 return unapply_special (who, op, aflags); 3355 return unapply_special (who, op, aflags);
3376 } 3356 }
3377 else if (basic_flag == AP_UNAPPLY) 3357 else if (basic_flag == AP_UNAPPLY)
3378 return 0; 3358 return 0;
3379 3359
3380 // if the item is combat/ranged, wield the relevant slot first
3381 // to resolve conflicts.
3382 if (player *pl = who->contr)
3383 switch (op->slottype ())
3384 {
3385 case slot_combat: who->change_weapon (pl->combat_ob); break;
3386 case slot_ranged: who->change_weapon (pl->ranged_ob); break;
3387 }
3388
3389 splay (op); 3360 splay (op);
3390 3361
3391 /* Can't just apply this object. Lets see what not and what to do */ 3362 /* Can't just apply this object. Lets see what not and what to do */
3392 if (int i = can_apply_object (who, op)) 3363 if (int i = can_apply_object (who, op))
3393 { 3364 {
3426 } 3397 }
3427 } 3398 }
3428 3399
3429 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) 3400 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL)
3430 { 3401 {
3402 // try to ready attached skill first
3431 skop = find_skill_by_name (who, op->skill); 3403 skop = find_skill_by_name (who, op->skill);
3432 3404
3433 if (!skop) 3405 if (!skop)
3434 { 3406 {
3435 who->failmsg (format ("You need the %s skill to use this item!", &op->skill)); 3407 who->failmsg (format ("You need the %s skill to use this item!", &op->skill));
3436 return 1; 3408 return 1;
3437 } 3409 }
3438 else 3410 else if (!who->apply (skop, AP_APPLY | AP_HAVE_WEAPON))
3439 /* While experience will be credited properly, we want to change the
3440 * skill so that the dam and wc get updated
3441 */ 3411 {
3442 who->change_skill (skop); 3412 who->failmsg (format ("You can't use the required %s skill!", &op->skill));
3413 return 1;
3414 }
3443 } 3415 }
3444 3416
3445 if (!check_item_power (who, op->item_power)) 3417 if (!check_item_power (who, op->item_power))
3446 { 3418 {
3447 who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); 3419 who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER);
3450 3422
3451 /* Ok. We are now at the state where we can apply the new object. 3423 /* Ok. We are now at the state where we can apply the new object.
3452 * Note that we don't have the checks for can_use_... 3424 * Note that we don't have the checks for can_use_...
3453 * below - that is already taken care of by can_apply_object. 3425 * below - that is already taken care of by can_apply_object.
3454 */ 3426 */
3427
3428 // split away all the other items from the stack, so only one item is left
3455 tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0; 3429 tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0;
3456 3430
3457 if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) 3431 if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op)))
3458 return RESULT_INT (0); 3432 return RESULT_INT (0);
3459 3433
3460 switch (op->type) 3434 switch (op->type)
3461 { 3435 {
3462 case WEAPON: 3436 case WEAPON:
3463 //TODO: this obviously fails for players using a shorter prefix 3437 if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\''))
3464 // i.e. "R" can use Ragnarok's sword.
3465 if (op->level && !op->name.starts_with (who->name))
3466 { 3438 {
3467 /* if the weapon does not have the name as the character, can't use it. */ 3439 /* if the weapon does not have the name as the character, can't use it. */
3468 /* (Ragnarok's sword attempted to be used by Foo: won't work) */ 3440 /* (Ragnarok's sword attempted to be used by Foo: won't work) */
3469 who->failmsg ("The weapon does not recognize you as its owner. H<Its name indicates that it belongs to somebody else.>"); 3441 who->failmsg ("The weapon does not recognize you as its owner. "
3470 3442 "H<Its name indicates that it belongs to somebody else.>");
3471 if (tmp) 3443 if (tmp) who->insert (tmp);
3472 insert_ob_in_ob (tmp, who);
3473
3474 return 1; 3444 return 1;
3475 } 3445 }
3476 3446
3477 if (!skop) 3447 op->flag [FLAG_APPLIED] = true;
3448
3449 if (player *pl = who->contr)
3478 { 3450 {
3479 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO 3451 who->current_weapon = pl->combat_ob = op;
3480 return 1; 3452 who->statusmsg (format ("You wield %s.", query_name (op)));
3453 change_abil (who, op);
3481 } 3454 }
3482
3483 op->flag [FLAG_APPLIED] = true;
3484
3485 if (who->contr)
3486 who->change_weapon (who->contr->combat_ob = op);
3487 else 3455 else
3488 who->change_skill (skop); 3456 who->change_skill (skop);
3489 3457
3490 who->statusmsg (format ("You wield %s.", query_name (op)));
3491
3492 op->flag [FLAG_READY_WEAPON] = true; 3458 op->flag [FLAG_READY_WEAPON] = true;
3493 change_abil (who, op);
3494 break; 3459 break;
3495 3460
3496 case ARMOUR: 3461 case ARMOUR:
3497 case HELMET: 3462 case HELMET:
3498 case SHIELD: 3463 case SHIELD:
3507 who->statusmsg (format ("You wear %s.", query_name (op))); 3472 who->statusmsg (format ("You wear %s.", query_name (op)));
3508 change_abil (who, op); 3473 change_abil (who, op);
3509 break; 3474 break;
3510 3475
3511 case SKILL_TOOL: 3476 case SKILL_TOOL:
3512 // applying a skill tool also readies the skill 3477 // applying a skill tool does not ready the skill
3478 // if something needs the skill, it has to ready it itself
3479 //TODO: unapplying should unapply the skill, though
3513 SET_FLAG (op, FLAG_APPLIED); 3480 SET_FLAG (op, FLAG_APPLIED);
3481 break;
3514 3482
3515 if (!(aflags & AP_NO_READY)) 3483 case SKILL:
3484 if (skill_flags [op->subtype] & SF_NEED_ITEM && !(aflags & AP_HAVE_WEAPON))
3516 { 3485 {
3517 skop = find_skill_by_name (who, op->skill); 3486 who->failmsg (format (
3518 if (!skop->flag [FLAG_APPLIED]) 3487 "You feel as if you wanted to do something funny, but you can't remember what. "
3519 apply_special (who, skop, AP_APPLY); 3488 "H<The skill %s needs an item to function, it cannot be used on its own.>",
3489 &op->skill
3490 ));
3491 if (tmp) who->insert (tmp);
3492 return 1;
3520 } 3493 }
3521 break;
3522 3494
3523 case SKILL:
3524 if (player *pl = who->contr) 3495 if (player *pl = who->contr)
3525 { 3496 {
3526 if (IS_COMBAT_SKILL (op->subtype)) 3497 if (skill_flags [op->subtype] & SF_COMBAT)
3527 { 3498 who->current_weapon = pl->combat_ob = op;
3499
3528 if (skill_flags [op->subtype] & SF_NEED_ITEM) 3500 if (skill_flags [op->subtype] & SF_RANGED)
3529 {
3530 // try to find the weapon, and apply it instead
3531 for (object *item = who->inv; item; item = item->below)
3532 if (item->type == op->weapontype && item->flag [FLAG_APPLIED])
3533 {
3534 if (item->skill == op->skill)
3535 {
3536 who->change_weapon (pl->combat_ob = item);
3537 goto found_weapon;
3538 }
3539 }
3540
3541 who->failmsg (format (
3542 "You need to apply a '%s' melee weapon before readying this skill. "
3543 "H<Some skills need an item, in this case a melee weapon, to function.>",
3544 &op->skill
3545 ));
3546 return 1;
3547
3548 found_weapon:;
3549 }
3550 else
3551 who->change_weapon (pl->combat_ob = op);
3552 }
3553 else if (IS_RANGED_SKILL (op->subtype))
3554 {
3555 if (skill_flags [op->subtype] & SF_NEED_ITEM)
3556 {
3557 for (object *item = who->inv; item; item = item->below)
3558 if (item->type == op->weapontype && item->flag [FLAG_APPLIED])
3559 {
3560 //TODO: bows should/must all have skill missile weapon right now
3561 who->change_weapon (pl->ranged_ob = item);
3562 goto found_bow;
3563 }
3564
3565 who->failmsg (
3566 "You need to apply a missile weapon before readying this skill. "
3567 "H<Some skills need an item, in this case a missile weapon, to function.>"
3568 );
3569 return 1;
3570
3571 found_bow:;
3572 }
3573 else
3574 who->change_weapon (pl->ranged_ob = op); 3501 who->current_weapon = pl->ranged_ob = op;
3575 }
3576 3502
3577 if (!op->invisible) 3503 if (op->invisible)
3578 { 3504 who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name));
3579 who->statusmsg (format (
3580 "You ready %s."
3581 "You can now use the skill: %s.",
3582 query_name (op),
3583 &op->skill
3584 ));
3585 }
3586 else 3505 else
3587 who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name)); 3506 who->statusmsg (format (
3507 "You ready %s."
3508 "You can now use the skill: %s.",
3509 query_name (op),
3510 &op->skill
3511 ));
3588 } 3512 }
3589 else 3513
3590 {
3591 SET_FLAG (op, FLAG_APPLIED);
3592 change_abil (who, op);
3593 who->chosen_skill = op;
3594 SET_FLAG (who, FLAG_READY_SKILL); 3514 SET_FLAG (who, FLAG_READY_SKILL);
3595 } 3515 SET_FLAG (op, FLAG_APPLIED);
3596 3516 change_abil (who, op);
3597 break; 3517 break;
3598 3518
3599 case BOW: 3519 case BOW:
3600 if (op->level && !op->name.starts_with (who->name)) 3520 if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\''))
3601 { 3521 {
3602 who->failmsg ("The weapon does not recognize you as its owner. " 3522 who->failmsg ("The weapon does not recognize you as its owner. "
3603 "H<Its name indicates that it belongs to somebody else.>"); 3523 "H<Its name indicates that it belongs to somebody else.>");
3604 if (tmp) 3524 if (tmp) who->insert (tmp);
3605 insert_ob_in_ob (tmp, who);
3606
3607 return 1; 3525 return 1;
3608 } 3526 }
3527
3528 if (player *pl = who->contr)
3529 {
3530 op->flag [FLAG_APPLIED] = true;
3531 who->current_weapon = pl->ranged_ob = op;
3532 who->statusmsg (format ("You wield the %s.", query_name (op)));
3533 change_abil (who, op);
3534 }
3535 break;
3536
3537 case RANGED:
3538 if (player *pl = who->contr)
3539 {
3540 op->flag [FLAG_APPLIED] = true;
3541 who->current_weapon = pl->ranged_ob = op;
3542 who->statusmsg (format ("You applied the %s.", query_name (op)));
3543 }
3544 break;
3545
3546 case SPELL:
3547 if (player *pl = who->contr)
3548 {
3549 op->flag [FLAG_APPLIED] = true;
3550 who->current_weapon = pl->ranged_ob = op;
3551 who->statusmsg (format ("You ready the spell %s.", query_name (op)));
3552 }
3553 break;
3609 3554
3610 /*FALLTHROUGH*/ 3555 /*FALLTHROUGH*/
3611 case WAND: 3556 case WAND:
3612 case ROD: 3557 case ROD:
3613 case HORN: 3558 case HORN:
3614 /* check for skill, alter player status */ 3559 /* check for skill, alter player status */
3615 3560
3616 if (!skop) 3561 if (!skop)
3617 { 3562 {
3618 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO 3563 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO
3564 if (tmp) who->insert (tmp);
3619 return 1; 3565 return 1;
3620 } 3566 }
3621 3567
3622 op->flag [FLAG_APPLIED] = true; 3568 op->flag [FLAG_APPLIED] = true;
3623 3569
3624 if (who->contr) 3570 if (player *pl = who->contr)
3625 { 3571 {
3626 who->statusmsg (format ("You ready %s.", query_name (op))); 3572 who->statusmsg (format ("You ready %s.", query_name (op)));
3627 who->change_weapon (who->contr->ranged_ob = op); 3573 who->current_weapon = pl->ranged_ob = op;
3628 3574
3629 if (op->type == BOW) 3575 if (op->type == BOW)
3630 who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op))); 3576 who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op)));
3577
3578 change_abil (who, op);
3631 } 3579 }
3632 else 3580 else
3633 { 3581 {
3634 who->change_skill (skop); 3582 who->change_skill (skop);
3635 3583
3640 } 3588 }
3641 3589
3642 break; 3590 break;
3643 3591
3644 case BUILDER: 3592 case BUILDER:
3645 if (who->type == PLAYER) 3593 if (player *pl = who->contr)
3646 { 3594 {
3647 //TODO: wtf does this do? shouldn't this be managed automatically (slots?) 3595 who->current_weapon = pl->ranged_ob = op;
3648 if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER)
3649 unapply_special (who, who->contr->ranged_ob, 0);
3650
3651 who->statusmsg (format ("You ready your %s.", query_name (op))); 3596 who->statusmsg (format ("You ready your %s.", query_name (op)));
3652 who->change_weapon (who->contr->ranged_ob = op); 3597 //TODO: change_abil?
3653 } 3598 }
3654 break; 3599 break;
3655 3600
3656 default: 3601 default:
3657 who->statusmsg (format ("You apply %s.", query_name (op))); 3602 who->statusmsg (format ("You apply %s.", query_name (op)));
3658 } 3603 }
3659 3604
3660 SET_FLAG (op, FLAG_APPLIED); 3605 SET_FLAG (op, FLAG_APPLIED);
3661 3606
3662 if (tmp)
3663 who->insert (tmp); 3607 if (tmp) who->insert (tmp);
3664 3608
3665 who->update_stats (); 3609 who->update_stats ();
3666 3610
3667 /* We exclude spell casting objects. The fire code will set the 3611 /* We exclude spell casting objects. The fire code will set the
3668 * been applied flag when they are used - until that point, 3612 * been applied flag when they are used - until that point,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines