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.85 by root, Fri May 11 19:41:06 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)
3156 switch (op->type) 3179 switch (op->type)
3157 { 3180 {
3158 case WEAPON: 3181 case WEAPON:
3159 if (!check_weapon_power (who, op->last_eat)) 3182 if (!check_weapon_power (who, op->last_eat))
3160 { 3183 {
3161 new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use."); 3184 new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use.\n"
3162 new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); 3185 "It would consume your soul!.");
3163 3186
3164 if (tmp) 3187 if (tmp)
3165 insert_ob_in_ob (tmp, who); 3188 insert_ob_in_ob (tmp, who);
3166 3189
3167 return 1; 3190 return 1;
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 {
3195 who->contr->combat_ob = op; 3217 who->change_weapon (who->contr->combat_ob = op);
3196 who->current_weapon = op;
3197 }
3198 3218
3199 if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) 3219 if (!QUERY_FLAG (who, FLAG_READY_WEAPON))
3200 SET_FLAG (who, FLAG_READY_WEAPON); 3220 SET_FLAG (who, FLAG_READY_WEAPON);
3201 3221
3202 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));
3280 if (skill_flags [op->subtype] & SF_NEED_WEAPON) 3300 if (skill_flags [op->subtype] & SF_NEED_WEAPON)
3281 { 3301 {
3282 for (object *item = who->inv; item; item = item->below) 3302 for (object *item = who->inv; item; item = item->below)
3283 if (item->type == WEAPON && item->flag [FLAG_APPLIED]) 3303 if (item->type == WEAPON && item->flag [FLAG_APPLIED])
3284 { 3304 {
3285 pl->combat_ob = who->current_weapon = item; 3305 who->change_weapon (pl->combat_ob = item);
3286 goto found_weapon; 3306 goto found_weapon;
3287 } 3307 }
3288 3308
3289 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");
3290 return 1; 3310 return 1;
3291 3311
3292 found_weapon:; 3312 found_weapon:;
3293 } 3313 }
3294 else 3314 else
3295 {
3296 pl->combat_ob = op; 3315 who->change_weapon (pl->combat_ob = op);
3297 op->current_weapon = 0;
3298 }
3299 } 3316 }
3300 else if (IS_RANGED_SKILL (op->subtype)) 3317 else if (IS_RANGED_SKILL (op->subtype))
3301 { 3318 {
3302 if (skill_flags [op->subtype] & SF_NEED_BOW) 3319 if (skill_flags [op->subtype] & SF_NEED_BOW)
3303 { 3320 {
3304 for (object *item = who->inv; item; item = item->below) 3321 for (object *item = who->inv; item; item = item->below)
3305 if (item->type == BOW && item->flag [FLAG_APPLIED]) 3322 if (item->type == BOW && item->flag [FLAG_APPLIED])
3306 { 3323 {
3307 pl->ranged_ob = who->current_weapon = item; 3324 who->change_weapon (pl->ranged_ob = item);
3308 goto found_bow; 3325 goto found_bow;
3309 } 3326 }
3310 3327
3311 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");
3312 return 1; 3329 return 1;
3317 { 3334 {
3318 for (object *item = who->inv; item; item = item->below) 3335 for (object *item = who->inv; item; item = item->below)
3319 if (item->flag [FLAG_APPLIED] 3336 if (item->flag [FLAG_APPLIED]
3320 && (item->type == WAND || item->type == ROD || item->type == HORN)) 3337 && (item->type == WAND || item->type == ROD || item->type == HORN))
3321 { 3338 {
3322 pl->ranged_ob = who->current_weapon = item; 3339 who->change_weapon (pl->ranged_ob = item);
3323 goto found_item; 3340 goto found_item;
3324 } 3341 }
3325 3342
3326 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");
3327 return 1; 3344 return 1;
3328 3345
3329 found_item:; 3346 found_item:;
3330 } 3347 }
3331 else 3348 else
3332 {
3333 pl->ranged_ob = op; 3349 who->change_weapon (pl->ranged_ob = op);
3334 op->current_weapon = 0;
3335 }
3336 } 3350 }
3337 3351
3338 if (!op->invisible) 3352 if (!op->invisible)
3339 { 3353 {
3340 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));
3646 * Handles player eating food that temporarily changes status (resistances, stats). 3660 * Handles player eating food that temporarily changes status (resistances, stats).
3647 * This used to call cast_change_attr(), but 3661 * This used to call cast_change_attr(), but
3648 * 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
3649 * the food changes, just grab a force and use that instead. 3663 * the food changes, just grab a force and use that instead.
3650 */ 3664 */
3651
3652void 3665void
3653eat_special_food (object *who, object *food) 3666eat_special_food (object *who, object *food)
3654{ 3667{
3655 object *force; 3668 object *force;
3656 int i, did_one = 0; 3669 int i, did_one = 0;
3657 sint8 k;
3658 3670
3659 force = get_archetype (FORCE_NAME); 3671 force = get_archetype (FORCE_NAME);
3660 3672
3661 for (i = 0; i < NUM_STATS; i++) 3673 for (i = 0; i < NUM_STATS; i++)
3662 { 3674 if (sint8 k = food->stats.stat (i))
3663 k = get_attr_value (&food->stats, i);
3664 if (k)
3665 { 3675 {
3666 set_attr_value (&force->stats, i, k); 3676 force->stats.stat (i) = k;
3667 did_one = 1; 3677 did_one = 1;
3668 } 3678 }
3669 }
3670 3679
3671 /* check if we can protect the eater */ 3680 /* check if we can protect the eater */
3672 for (i = 0; i < NROFATTACKS; i++) 3681 for (i = 0; i < NROFATTACKS; i++)
3673 { 3682 {
3674 if (food->resist[i] > 0) 3683 if (food->resist[i] > 0)
3835 new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!"); 3844 new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!");
3836 blind_player (op, op, power); 3845 blind_player (op, op, power);
3837 } 3846 }
3838 else if (failure <= -80) 3847 else if (failure <= -80)
3839 { /* blast the immediate area */ 3848 { /* blast the immediate area */
3840 object *tmp;
3841
3842 tmp = get_archetype (LOOSE_MANA); 3849 object *tmp = get_archetype (LOOSE_MANA);
3843 cast_magic_storm (op, tmp, power); 3850 cast_magic_storm (op, tmp, power);
3844 new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); 3851 new_draw_info (NDI_UNIQUE, 0, op, "You unleash uncontrolled mana!");
3845 tmp->destroy (); 3852 tmp->destroy ();
3846 } 3853 }
3847 } 3854 }
3848} 3855}
3849 3856
3869 */ 3876 */
3870 int i, j; 3877 int i, j;
3871 3878
3872 for (i = 0; i < NUM_STATS; i++) 3879 for (i = 0; i < NUM_STATS; i++)
3873 { 3880 {
3874 sint8 stat = get_attr_value (stats, i);
3875 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);
3876 3883
3877 stat += get_attr_value (ns, i);
3878 if (stat > 20 + race_bonus) 3884 if (stat > 20 + race_bonus)
3879 { 3885 {
3880 excess_stat++; 3886 excess_stat++;
3881 stat = 20 + race_bonus; 3887 stat = 20 + race_bonus;
3882 } 3888 }
3883 set_attr_value (stats, i, stat); 3889
3890 stats->stat (i) = stat;
3884 } 3891 }
3885 3892
3886 for (j = 0; excess_stat > 0 && j < 100; j++) 3893 for (j = 0; excess_stat > 0 && j < 100; j++)
3887 { /* try 100 times to assign excess stats */ 3894 { /* try 100 times to assign excess stats */
3888 int i = rndm (0, 6); 3895 int i = rndm (0, 6);
3889 int stat = get_attr_value (stats, i);
3890 int race_bonus = get_attr_value (&(pl->arch->clone.stats), i);
3891 3896
3892 if (i == CHA) 3897 if (i == CHA)
3893 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);
3894 if (stat < 20 + race_bonus) 3902 if (stat < 20 + race_bonus)
3895 { 3903 {
3896 change_attr_value (stats, i, 1); 3904 change_attr_value (stats, i, 1);
3897 excess_stat--; 3905 excess_stat--;
3898 } 3906 }
3901 /* insert the randomitems from the change's treasurelist into 3909 /* insert the randomitems from the change's treasurelist into
3902 * the player ref: player.c 3910 * the player ref: player.c
3903 */ 3911 */
3904 if (change->randomitems != NULL) 3912 if (change->randomitems != NULL)
3905 give_initial_items (pl, change->randomitems); 3913 give_initial_items (pl, change->randomitems);
3906
3907 3914
3908 /* set up the face, for some races. */ 3915 /* set up the face, for some races. */
3909 3916
3910 /* first, look for the force object banning 3917 /* first, look for the force object banning
3911 * 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