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.87 by root, Fri May 11 21:07:14 2007 UTC vs.
Revision 1.92 by root, Sat May 12 18:23:51 2007 UTC

232 depl = present_arch_in_ob (at, op); 232 depl = present_arch_in_ob (at, op);
233 233
234 if (depl) 234 if (depl)
235 { 235 {
236 for (i = 0; i < NUM_STATS; i++) 236 for (i = 0; i < NUM_STATS; i++)
237 if (get_attr_value (&depl->stats, i)) 237 if (depl->stats.stat (i))
238 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 238 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
239 239
240 depl->destroy (); 240 depl->destroy ();
241 op->update_stats (); 241 op->update_stats ();
242 } 242 }
374 force->stats.food *= 10; 374 force->stats.food *= 10;
375 for (i = 0; i < NROFATTACKS; i++) 375 for (i = 0; i < NROFATTACKS; i++)
376 if (force->resist[i] > 0) 376 if (force->resist[i] > 0)
377 force->resist[i] = -force->resist[i]; /* prot => vuln */ 377 force->resist[i] = -force->resist[i]; /* prot => vuln */
378 } 378 }
379
379 force->speed_left = -1; 380 force->speed_left = -1;
380 force = insert_ob_in_ob (force, op); 381 force = insert_ob_in_ob (force, op);
381 CLEAR_FLAG (tmp, FLAG_APPLIED); 382 CLEAR_FLAG (tmp, FLAG_APPLIED);
382 SET_FLAG (force, FLAG_APPLIED); 383 SET_FLAG (force, FLAG_APPLIED);
383 change_abil (op, force); 384 change_abil (op, force);
2579/** 2580/**
2580 * player_apply_below attempts to apply the object 'below' the player. 2581 * player_apply_below attempts to apply the object 'below' the player.
2581 * If the player has an open container, we use that for below, otherwise 2582 * If the player has an open container, we use that for below, otherwise
2582 * we use the ground. 2583 * we use the ground.
2583 */ 2584 */
2584
2585void 2585void
2586player_apply_below (object *pl) 2586player_apply_below (object *pl)
2587{ 2587{
2588 int floors = 0; 2588 int floors = 0;
2589 2589
2943 * one choice. However, the check for the number of body locations 2943 * one choice. However, the check for the number of body locations
2944 * does take into the account cases where what is being applied 2944 * does take into the account cases where what is being applied
2945 * may be two handed for example. 2945 * may be two handed for example.
2946 */ 2946 */
2947 if (ws) 2947 if (ws)
2948 {
2949 if ((who->slot[i].used - ws->slot[i].info + op->slot[i].info) >= 0) 2948 if ((who->slot[i].used - ws->slot[i].info + op->slot[i].info) >= 0)
2950 { 2949 {
2951 retval |= CAN_APPLY_UNAPPLY; 2950 retval |= CAN_APPLY_UNAPPLY;
2952 continue; 2951 continue;
2953 } 2952 }
2954 }
2955 2953
2956 object *tmp1 = get_item_from_body_location (i, who->inv); 2954 object *tmp1 = get_item_from_body_location (i, who->inv);
2957 if (!tmp1) 2955 if (!tmp1)
2958 { 2956 {
2959#if 0 2957#if 0
3069 if (basic_flag == AP_APPLY) 3067 if (basic_flag == AP_APPLY)
3070 return 0; 3068 return 0;
3071 3069
3072 if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) 3070 if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)))
3073 { 3071 {
3074 new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't\nremove %s.", query_name (op)); 3072 new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove %s.", query_name (op));
3075 return 1; 3073 return 1;
3076 } 3074 }
3077 3075
3078 return unapply_special (who, op, aflags); 3076 return unapply_special (who, op, aflags);
3079 } 3077 }
3080 3078
3081 if (basic_flag == AP_UNAPPLY) 3079 if (basic_flag == AP_UNAPPLY)
3082 return 0; 3080 return 0;
3081
3082 // if the item is combat/ranged, wield the relevant slot first
3083 // to resolve conflicts.
3084 if (player *pl = who->contr)
3085 switch (op->type)
3086 {
3087 case WEAPON:
3088 who->change_weapon (pl->combat_ob);
3089 break;
3090
3091 case BOW:
3092 case ROD:
3093 case WAND:
3094 case HORN:
3095 case SKILL_TOOL:
3096 who->change_weapon (pl->ranged_ob);
3097 break;
3098
3099 case SKILL:
3100 if (IS_COMBAT_SKILL (op->subtype))
3101 who->change_weapon (pl->combat_ob);
3102 else if (IS_RANGED_SKILL (op->subtype))
3103 who->change_weapon (pl->ranged_ob);
3104 break;
3105 }
3083 3106
3084 /* Can't just apply this object. Lets see what not and what to do */ 3107 /* Can't just apply this object. Lets see what not and what to do */
3085 if (int i = can_apply_object (who, op)) 3108 if (int i = can_apply_object (who, op))
3086 { 3109 {
3087 if (i & CAN_APPLY_NEVER) 3110 if (i & CAN_APPLY_NEVER)
3189 3212
3190 SET_FLAG (op, FLAG_APPLIED); 3213 SET_FLAG (op, FLAG_APPLIED);
3191 change_skill (who, skop, 1); 3214 change_skill (who, skop, 1);
3192 3215
3193 if (who->contr) 3216 if (who->contr)
3194 who->set_weapon (who->contr->combat_ob = op); 3217 who->change_weapon (who->contr->combat_ob = op);
3195 3218
3196 if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) 3219 if (!QUERY_FLAG (who, FLAG_READY_WEAPON))
3197 SET_FLAG (who, FLAG_READY_WEAPON); 3220 SET_FLAG (who, FLAG_READY_WEAPON);
3198 3221
3199 new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); 3222 new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op));
3277 if (skill_flags [op->subtype] & SF_NEED_WEAPON) 3300 if (skill_flags [op->subtype] & SF_NEED_WEAPON)
3278 { 3301 {
3279 for (object *item = who->inv; item; item = item->below) 3302 for (object *item = who->inv; item; item = item->below)
3280 if (item->type == WEAPON && item->flag [FLAG_APPLIED]) 3303 if (item->type == WEAPON && item->flag [FLAG_APPLIED])
3281 { 3304 {
3282 who->set_weapon (pl->combat_ob = item); 3305 who->change_weapon (pl->combat_ob = item);
3283 goto found_weapon; 3306 goto found_weapon;
3284 } 3307 }
3285 3308
3286 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill"); 3309 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill");
3287 return 1; 3310 return 1;
3288 3311
3289 found_weapon:; 3312 found_weapon:;
3290 } 3313 }
3291 else 3314 else
3292 who->set_weapon (pl->combat_ob = op); 3315 who->change_weapon (pl->combat_ob = op);
3293 } 3316 }
3294 else if (IS_RANGED_SKILL (op->subtype)) 3317 else if (IS_RANGED_SKILL (op->subtype))
3295 { 3318 {
3296 if (skill_flags [op->subtype] & SF_NEED_BOW) 3319 if (skill_flags [op->subtype] & SF_NEED_BOW)
3297 { 3320 {
3298 for (object *item = who->inv; item; item = item->below) 3321 for (object *item = who->inv; item; item = item->below)
3299 if (item->type == BOW && item->flag [FLAG_APPLIED]) 3322 if (item->type == BOW && item->flag [FLAG_APPLIED])
3300 { 3323 {
3301 who->set_weapon (pl->ranged_ob = item); 3324 who->change_weapon (pl->ranged_ob = item);
3302 goto found_bow; 3325 goto found_bow;
3303 } 3326 }
3304 3327
3305 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); 3328 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill");
3306 return 1; 3329 return 1;
3311 { 3334 {
3312 for (object *item = who->inv; item; item = item->below) 3335 for (object *item = who->inv; item; item = item->below)
3313 if (item->flag [FLAG_APPLIED] 3336 if (item->flag [FLAG_APPLIED]
3314 && (item->type == WAND || item->type == ROD || item->type == HORN)) 3337 && (item->type == WAND || item->type == ROD || item->type == HORN))
3315 { 3338 {
3316 who->set_weapon (pl->ranged_ob = item); 3339 who->change_weapon (pl->ranged_ob = item);
3317 goto found_item; 3340 goto found_item;
3318 } 3341 }
3319 3342
3320 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill"); 3343 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill");
3321 return 1; 3344 return 1;
3322 3345
3323 found_item:; 3346 found_item:;
3324 } 3347 }
3325 else 3348 else
3326 who->set_weapon (pl->ranged_ob = op); 3349 who->change_weapon (pl->ranged_ob = op);
3327 } 3350 }
3328 3351
3329 if (!op->invisible) 3352 if (!op->invisible)
3330 { 3353 {
3331 new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); 3354 new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op));
3637 * Handles player eating food that temporarily changes status (resistances, stats). 3660 * Handles player eating food that temporarily changes status (resistances, stats).
3638 * This used to call cast_change_attr(), but 3661 * This used to call cast_change_attr(), but
3639 * that doesn't work with the new spell code. Since we know what 3662 * that doesn't work with the new spell code. Since we know what
3640 * the food changes, just grab a force and use that instead. 3663 * the food changes, just grab a force and use that instead.
3641 */ 3664 */
3642
3643void 3665void
3644eat_special_food (object *who, object *food) 3666eat_special_food (object *who, object *food)
3645{ 3667{
3646 object *force; 3668 object *force;
3647 int i, did_one = 0; 3669 int i, did_one = 0;
3648 sint8 k;
3649 3670
3650 force = get_archetype (FORCE_NAME); 3671 force = get_archetype (FORCE_NAME);
3651 3672
3652 for (i = 0; i < NUM_STATS; i++) 3673 for (i = 0; i < NUM_STATS; i++)
3653 { 3674 if (sint8 k = food->stats.stat (i))
3654 k = get_attr_value (&food->stats, i);
3655 if (k)
3656 { 3675 {
3657 set_attr_value (&force->stats, i, k); 3676 force->stats.stat (i) = k;
3658 did_one = 1; 3677 did_one = 1;
3659 } 3678 }
3660 }
3661 3679
3662 /* check if we can protect the eater */ 3680 /* check if we can protect the eater */
3663 for (i = 0; i < NROFATTACKS; i++) 3681 for (i = 0; i < NROFATTACKS; i++)
3664 { 3682 {
3665 if (food->resist[i] > 0) 3683 if (food->resist[i] > 0)
3858 */ 3876 */
3859 int i, j; 3877 int i, j;
3860 3878
3861 for (i = 0; i < NUM_STATS; i++) 3879 for (i = 0; i < NUM_STATS; i++)
3862 { 3880 {
3863 sint8 stat = get_attr_value (stats, i);
3864 int race_bonus = get_attr_value (&(pl->arch->clone.stats), i); 3881 int race_bonus = pl->arch->clone.stats.stat (i);
3882 sint8 stat = stats->stat (i) + ns->stat (i);
3865 3883
3866 stat += get_attr_value (ns, i);
3867 if (stat > 20 + race_bonus) 3884 if (stat > 20 + race_bonus)
3868 { 3885 {
3869 excess_stat++; 3886 excess_stat++;
3870 stat = 20 + race_bonus; 3887 stat = 20 + race_bonus;
3871 } 3888 }
3872 set_attr_value (stats, i, stat); 3889
3890 stats->stat (i) = stat;
3873 } 3891 }
3874 3892
3875 for (j = 0; excess_stat > 0 && j < 100; j++) 3893 for (j = 0; excess_stat > 0 && j < 100; j++)
3876 { /* try 100 times to assign excess stats */ 3894 { /* try 100 times to assign excess stats */
3877 int i = rndm (0, 6); 3895 int i = rndm (0, 6);
3878 int stat = get_attr_value (stats, i);
3879 int race_bonus = get_attr_value (&(pl->arch->clone.stats), i);
3880 3896
3881 if (i == CHA) 3897 if (i == CHA)
3882 continue; /* exclude cha from this */ 3898 continue; /* exclude cha from this */
3899
3900 int stat = stats->stat (i);
3901 int race_bonus = pl->arch->clone.stats.stat (i);
3883 if (stat < 20 + race_bonus) 3902 if (stat < 20 + race_bonus)
3884 { 3903 {
3885 change_attr_value (stats, i, 1); 3904 change_attr_value (stats, i, 1);
3886 excess_stat--; 3905 excess_stat--;
3887 } 3906 }
3890 /* insert the randomitems from the change's treasurelist into 3909 /* insert the randomitems from the change's treasurelist into
3891 * the player ref: player.c 3910 * the player ref: player.c
3892 */ 3911 */
3893 if (change->randomitems != NULL) 3912 if (change->randomitems != NULL)
3894 give_initial_items (pl, change->randomitems); 3913 give_initial_items (pl, change->randomitems);
3895
3896 3914
3897 /* set up the face, for some races. */ 3915 /* set up the face, for some races. */
3898 3916
3899 /* first, look for the force object banning 3917 /* first, look for the force object banning
3900 * changing the face. Certain races never change face with class. 3918 * changing the face. Certain races never change face with class.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines