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.234 by root, Sat Apr 3 02:27:24 2010 UTC vs.
Revision 1.240 by root, Mon Apr 5 20:33:13 2010 UTC

948 item->nrof *= nr; 948 item->nrof *= nr;
949 949
950 if (converter->flag [FLAG_PRECIOUS]) 950 if (converter->flag [FLAG_PRECIOUS])
951 SET_FLAG (item, FLAG_UNPAID); 951 SET_FLAG (item, FLAG_UNPAID);
952 952
953 if (is_in_shop (converter)) 953 if (converter->is_in_shop ())
954 { 954 {
955 // converters on shop floors don't work anymore, bug lets check for it 955 // converters on shop floors don't work anymore, bug lets check for it
956 // and report in case someone still does it. 956 // and report in case someone still does it.
957 LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", 957 LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n",
958 converter->debug_desc ()); 958 converter->debug_desc ());
1161 /* this is only used for players */ 1161 /* this is only used for players */
1162 rv = teleport (shop_mat, SHOP_MAT, op); 1162 rv = teleport (shop_mat, SHOP_MAT, op);
1163 1163
1164 if (has_unpaid) 1164 if (has_unpaid)
1165 op->contr->play_sound (sound_find ("shop_buy")); 1165 op->contr->play_sound (sound_find ("shop_buy"));
1166 else if (is_in_shop (op)) 1166 else if (op->is_in_shop ())
1167 op->contr->play_sound (sound_find ("shop_enter")); 1167 op->contr->play_sound (sound_find ("shop_enter"));
1168 else 1168 else
1169 op->contr->play_sound (sound_find ("shop_leave")); 1169 op->contr->play_sound (sound_find ("shop_leave"));
1170 1170
1171 if (shop_mat->msg) 1171 if (shop_mat->msg)
1172 op->statusmsg (shop_mat->msg); 1172 op->statusmsg (shop_mat->msg);
1173 /* This check below is a bit simplistic - generally it should be correct, 1173 /* This check below is a bit simplistic - generally it should be correct,
1174 * but there is never a guarantee that the bottom space on the map is 1174 * but there is never a guarantee that the bottom space on the map is
1175 * actually the shop floor. 1175 * actually the shop floor.
1176 */ 1176 */
1177 else if (!rv && !is_in_shop (op)) 1177 else if (!rv && !op->is_in_shop ())
1178 { 1178 {
1179 opinion = shopkeeper_approval (op->map, op); 1179 opinion = shopkeeper_approval (op->map, op);
1180 1180
1181 op->statusmsg ( 1181 op->statusmsg (
1182 opinion >= 0.90 ? "The shopkeeper gives you a friendly wave." 1182 opinion >= 0.90 ? "The shopkeeper gives you a friendly wave."
1805 op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low, it must be at least %d.>", 1805 op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low, it must be at least %d.>",
1806 &tmp->skill, learn_level)); 1806 &tmp->skill, learn_level));
1807 return; 1807 return;
1808 } 1808 }
1809 1809
1810 op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); 1810 op->statusmsg (format ("The spellbook contains the %s level spell %s.", ordinal (spell->level), &spell->name));
1811 1811
1812 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1812 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1813 identify (tmp); 1813 identify (tmp);
1814 1814
1815 /* I removed the check for special_prayer_mark here - it didn't make 1815 /* I removed the check for special_prayer_mark here - it didn't make
2626 * being applied. 2626 * being applied.
2627 * 2627 *
2628 * aflag is special (always apply/unapply) flags. Nothing is done with 2628 * aflag is special (always apply/unapply) flags. Nothing is done with
2629 * them in this function - they are passed to apply_special 2629 * them in this function - they are passed to apply_special
2630 */ 2630 */
2631int 2631static int
2632manual_apply (object *who, object *op, int aflag) 2632manual_apply (object *who, object *op, int aflag)
2633{ 2633{
2634 op = op->head_ (); 2634 op = op->head_ ();
2635 2635
2636 if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) 2636 if (op->flag [FLAG_UNPAID] && !op->flag [FLAG_APPLIED])
2637 { 2637 {
2638 if (who->type == PLAYER) 2638 if (who->type == PLAYER)
2639 { 2639 {
2640 examine (who, op); 2640 examine (who, op);
2641 //who->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>");//TODO remove 2641 //who->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>");//TODO remove
2936 switch (op->type) 2936 switch (op->type)
2937 { 2937 {
2938 case SKILL: 2938 case SKILL:
2939 if (player *pl = who->contr) 2939 if (player *pl = who->contr)
2940 if (op->invisible) 2940 if (op->invisible)
2941 pl->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); 2941 pl->statusmsg (format ("You can no longer use the %s skill.", &op->skill));
2942 else 2942 else
2943 pl->statusmsg (format ("You stop using the %s.", query_name (op))); 2943 pl->statusmsg (format ("You stop using the %s.", query_name (op)));
2944 2944
2945 change_abil (who, op); 2945 change_abil (who, op);
2946 who->flag [FLAG_READY_SKILL] = false; 2946 who->flag [FLAG_READY_SKILL] = false;
3269 object_ptr *slot = 0; 3269 object_ptr *slot = 0;
3270 3270
3271 // detect the slot, if this is a player 3271 // detect the slot, if this is a player
3272 if (contr && !(aflags & AP_NO_SLOT)) 3272 if (contr && !(aflags & AP_NO_SLOT))
3273 { 3273 {
3274 object *oslot;
3275
3274 switch (ob->type) 3276 switch (ob->type)
3275 { 3277 {
3276 case WEAPON: 3278 case WEAPON:
3277 slot = &contr->combat_ob; 3279 slot = &contr->combat_ob;
3280 oslot = contr->ranged_ob;
3278 break; 3281 break;
3279 3282
3280 case BOW: 3283 case BOW:
3281 case RANGED: 3284 case RANGED:
3282 case SPELL: 3285 case SPELL:
3283 case WAND: 3286 case WAND:
3284 case ROD: 3287 case ROD:
3285 case HORN: 3288 case HORN:
3286 case BUILDER: 3289 case BUILDER:
3287 slot = &contr->ranged_ob; 3290 slot = &contr->ranged_ob;
3291 oslot = contr->combat_ob;
3288 break; 3292 break;
3289 3293
3290 // oh, the humanity 3294 // oh, the humanity
3291 case SKILL: 3295 case SKILL:
3292 if (aflags & AP_NO_SLOT) 3296 if (aflags & AP_NO_SLOT)
3294 3298
3295 if (skill_flags [ob->subtype] & SF_NEED_ITEM) 3299 if (skill_flags [ob->subtype] & SF_NEED_ITEM)
3296 break; 3300 break;
3297 3301
3298 if (skill_flags [ob->subtype] & SF_COMBAT) 3302 if (skill_flags [ob->subtype] & SF_COMBAT)
3303 {
3299 slot = &contr->combat_ob; 3304 slot = &contr->combat_ob;
3305 oslot = contr->ranged_ob;
3306 }
3300 else if (skill_flags [ob->subtype] & SF_RANGED) 3307 else if (skill_flags [ob->subtype] & SF_RANGED)
3308 {
3301 slot = &contr->ranged_ob; 3309 slot = &contr->ranged_ob;
3310 oslot = contr->combat_ob;
3311 }
3302 3312
3303 break; 3313 break;
3304 } 3314 }
3305 3315
3316 // now handle slot exclusions
3317 if (slot)
3318 {
3319 // only one slot can be active
3320 if (want_apply)
3321 apply (oslot, AP_UNAPPLY);
3322
3306 // clear item from slot if applied 3323 // clear item from slot if applied
3307 if (slot && *slot == ob && !want_apply) 3324 if (!want_apply && *slot == ob)
3308 { 3325 {
3309 *slot = 0; 3326 *slot = 0;
3310 3327
3311 if (current_weapon == ob) 3328 if (current_weapon == ob)
3312 current_weapon = 0; 3329 current_weapon = 0;
3330 }
3313 } 3331 }
3314 } 3332 }
3315 3333
3316 if (ob->flag [FLAG_APPLIED] != want_apply) 3334 if (ob->flag [FLAG_APPLIED] != want_apply)
3317 manual_apply (this, ob, aflags); 3335 manual_apply (this, ob, aflags);
3506 //TODO: unapplying should unapply the skill, though 3524 //TODO: unapplying should unapply the skill, though
3507 SET_FLAG (op, FLAG_APPLIED); 3525 SET_FLAG (op, FLAG_APPLIED);
3508 break; 3526 break;
3509 3527
3510 case SKILL: 3528 case SKILL:
3511 if (skill_flags [op->subtype] & SF_NEED_ITEM && !(aflags & AP_NO_SLOT)) 3529 if (!(aflags & AP_NO_SLOT))
3512 { 3530 {
3531 // skill is used on it's own, as opposed to being a chosen_skill
3532
3533 if (skill_flags [op->subtype] & (SF_NEED_ITEM | SF_MANA))
3534 {
3513 who->failmsg (format ( 3535 who->failmsg (format (
3514 "You feel as if you wanted to do something funny, but you can't remember what. " 3536 "You feel as if you wanted to do something funny, but you can't remember what. "
3515 "H<The %s skill needs an item to function, it cannot be used on its own.>", 3537 "H<The %s skill needs something else to function, for example a tool, weapon, rod, or spell. "
3538 "It cannot be used on its own.>",
3516 &op->skill 3539 &op->skill
3517 )); 3540 ));
3518 if (tmp) who->insert (tmp); 3541 if (tmp) who->insert (tmp);
3519 return 1; 3542 return 1;
3520 } 3543 }
3521 3544
3522 if (player *pl = who->contr) 3545 if (skill_flags [op->subtype] & SF_AUTARK
3546 || !(skill_flags [op->subtype] & (SF_COMBAT | SF_RANGED)))
3523 { 3547 {
3524 if (op->invisible) 3548 if (skill_flags [op->subtype] & SF_USE)
3525 who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name)); 3549 who->failmsg (format (
3550 "You feel as if you wanted to do something funny, but you can't remember what. "
3551 "H<The %s skill cannot be readied, instead, try C<use_skill %s>.>",
3552 &op->skill, &op->skill
3553 ));
3526 else 3554 else
3555 who->failmsg (format (
3556 "You feel as if you wanted to do something funny, but you can't remember what. "
3557 "H<The %s skill cannot be readied or used, it is always active.>",
3558 &op->skill, &op->skill
3559 ));
3560
3561 if (tmp) who->insert (tmp);
3562 return 1;
3563 }
3564
3565 if (who->contr)
3527 who->statusmsg (format ( 3566 who->statusmsg (format (
3528 "You ready %s." 3567 op->invisible ? "You can now use the %s skill." : "You ready %s.",
3529 "You can now use the skill: %s.",
3530 query_name (op), 3568 query_name (op),
3531 &op->skill 3569 &op->skill
3532 )); 3570 ));
3533 } 3571 }
3534 3572

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines