… | |
… | |
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); |
… | |
… | |
1337 | |
1338 | |
1338 | /* Just put in some sanity check. I think there is a bug in the |
1339 | /* Just put in some sanity check. I think there is a bug in the |
1339 | * above with some objects have zero speed, and thus the player |
1340 | * above with some objects have zero speed, and thus the player |
1340 | * getting permanently paralyzed. |
1341 | * getting permanently paralyzed. |
1341 | */ |
1342 | */ |
1342 | if (victim->speed_left < -50.0) |
1343 | if (victim->speed_left < -50.f) |
1343 | victim->speed_left = -50.0; |
1344 | victim->speed_left = -50.f; |
1344 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
1345 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
1345 | } |
1346 | } |
1346 | goto leave; |
1347 | goto leave; |
1347 | |
1348 | |
1348 | case SPINNER: |
1349 | case SPINNER: |
… | |
… | |
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 | |
|
|
2585 | void |
2585 | void |
2586 | player_apply_below (object *pl) |
2586 | player_apply_below (object *pl) |
2587 | { |
2587 | { |
2588 | int floors = 0; |
2588 | int floors = 0; |
2589 | |
2589 | |
… | |
… | |
2634 | |
2634 | |
2635 | object *tmp2; |
2635 | object *tmp2; |
2636 | |
2636 | |
2637 | CLEAR_FLAG (op, FLAG_APPLIED); |
2637 | CLEAR_FLAG (op, FLAG_APPLIED); |
2638 | |
2638 | |
|
|
2639 | if (player *pl = who->contr) |
|
|
2640 | { |
|
|
2641 | if (op == pl->ranged_ob) pl->ranged_ob = 0; |
|
|
2642 | if (op == pl->combat_ob) pl->combat_ob = 0; |
|
|
2643 | } |
|
|
2644 | |
2639 | switch (op->type) |
2645 | switch (op->type) |
2640 | { |
2646 | { |
|
|
2647 | case SKILL_TOOL: |
|
|
2648 | // unapplying a skill tool should also unapply the skill it governs |
|
|
2649 | // but this is hard, as it shouldn't do so when the skill can |
|
|
2650 | // be used for other reasons |
|
|
2651 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
|
|
2652 | if (tmp->skill == op->skill |
|
|
2653 | && tmp->type == SKILL |
|
|
2654 | && tmp->flag [FLAG_APPLIED] |
|
|
2655 | && !tmp->flag [FLAG_CAN_USE_SKILL]) |
|
|
2656 | unapply_special (who, tmp, 0); |
|
|
2657 | |
|
|
2658 | change_abil (who, op); |
|
|
2659 | break; |
|
|
2660 | |
2641 | case WEAPON: |
2661 | case WEAPON: |
2642 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); |
2662 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); |
2643 | |
2663 | |
2644 | change_abil (who, op); |
2664 | change_abil (who, op); |
2645 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2665 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2646 | |
|
|
2647 | if (who->contr) |
|
|
2648 | { |
|
|
2649 | if (who->contr->combat_ob == op) |
|
|
2650 | who->contr->combat_ob = 0; |
|
|
2651 | |
|
|
2652 | if (who->current_weapon == op) |
|
|
2653 | who->current_weapon = 0; |
|
|
2654 | } |
|
|
2655 | |
|
|
2656 | clear_skill (who); |
2666 | clear_skill (who); |
2657 | break; |
2667 | break; |
2658 | |
2668 | |
2659 | case SKILL: /* allows objects to impart skills */ |
|
|
2660 | case SKILL_TOOL: |
2669 | case SKILL: |
2661 | if (op != who->chosen_skill) |
2670 | if (op != who->chosen_skill) |
2662 | LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n"); |
2671 | LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n"); |
2663 | |
2672 | |
2664 | if (who->contr) |
2673 | if (who->contr) |
2665 | { |
2674 | { |
… | |
… | |
2788 | /** |
2797 | /** |
2789 | * Returns the object that is using location 'loc'. |
2798 | * Returns the object that is using location 'loc'. |
2790 | * Note that 'start' is the first object to start examing - we |
2799 | * Note that 'start' is the first object to start examing - we |
2791 | * then go through the below of this. In this way, you can do |
2800 | * then go through the below of this. In this way, you can do |
2792 | * something like: |
2801 | * something like: |
2793 | * tmp = get_item_from_body_location(who->inv, 1); |
2802 | * tmp = get_next_item_from_body_location(who->inv, 1); |
2794 | * if (tmp) tmp1 = get_item_from_body_location(tmp->below, 1); |
2803 | * if (tmp) tmp1 = get_next_item_from_body_location(tmp->below, 1); |
2795 | * to find the second object that may use this location, etc. |
2804 | * to find the second object that may use this location, etc. |
2796 | * Returns NULL if no match is found. |
2805 | * Returns NULL if no match is found. |
2797 | * loc is the index into the array we are looking for a match. |
2806 | * loc is the index into the array we are looking for a match. |
2798 | * don't return invisible objects unless they are skill objects |
2807 | * don't return invisible objects unless they are skill objects |
2799 | * invisible other objects that use |
2808 | * invisible other objects that use |
2800 | * up body locations can be used as restrictions. |
2809 | * up body locations can be used as restrictions. |
2801 | */ |
2810 | */ |
2802 | static object * |
2811 | static object * |
2803 | get_item_from_body_location (int loc, object *start) |
2812 | get_next_item_from_body_location (int loc, object *start) |
2804 | { |
2813 | { |
2805 | if (start) |
|
|
2806 | for (object *tmp = start; tmp; tmp = tmp->below) |
2814 | for (object *tmp = start; tmp; tmp = tmp->below) |
2807 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->slot[loc].info && (!tmp->invisible || tmp->type == SKILL)) |
2815 | if (tmp->flag [FLAG_APPLIED] |
|
|
2816 | && tmp->slot[loc].info |
|
|
2817 | && (!tmp->invisible || tmp->type == SKILL)) |
2808 | return tmp; |
2818 | return tmp; |
2809 | |
2819 | |
2810 | return 0; |
2820 | return 0; |
2811 | } |
2821 | } |
2812 | |
2822 | |
2813 | /** |
2823 | /** |
… | |
… | |
2854 | /* We do a while loop - may need to remove several items in order |
2864 | /* We do a while loop - may need to remove several items in order |
2855 | * to free up enough slots. |
2865 | * to free up enough slots. |
2856 | */ |
2866 | */ |
2857 | while ((who->slot[i].used + op->slot[i].info) < 0) |
2867 | while ((who->slot[i].used + op->slot[i].info) < 0) |
2858 | { |
2868 | { |
2859 | object *tmp = get_item_from_body_location (i, last); |
2869 | object *tmp = get_next_item_from_body_location (i, last); |
2860 | |
2870 | |
2861 | if (!tmp) |
2871 | if (!tmp) |
2862 | { |
2872 | { |
2863 | #if 0 |
2873 | #if 0 |
2864 | /* Not a bug - we'll get this if the player has cursed items |
2874 | /* Not a bug - we'll get this if the player has cursed items |
… | |
… | |
2902 | * Checks to see if 'who' can apply object 'op'. |
2912 | * Checks to see if 'who' can apply object 'op'. |
2903 | * Returns 0 if apply can be done without anything special. |
2913 | * Returns 0 if apply can be done without anything special. |
2904 | * Otherwise returns a bitmask - potentially several of these may be |
2914 | * Otherwise returns a bitmask - potentially several of these may be |
2905 | * set, but largely depends on circumstance - in the future, processing |
2915 | * set, but largely depends on circumstance - in the future, processing |
2906 | * may be pruned once we know some status (eg, once CAN_APPLY_NEVER |
2916 | * may be pruned once we know some status (eg, once CAN_APPLY_NEVER |
2907 | * is set, do we really are what the other flags may be?) |
2917 | * is set, do we really care what the other flags may be?) |
2908 | * |
2918 | * |
2909 | * See include/define.h for detailed description of the meaning of |
2919 | * See include/define.h for detailed description of the meaning of |
2910 | * these return values. |
2920 | * these return values. |
2911 | */ |
2921 | */ |
2912 | int |
2922 | int |
… | |
… | |
2921 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2931 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2922 | { |
2932 | { |
2923 | if (op->slot[i].info) |
2933 | if (op->slot[i].info) |
2924 | { |
2934 | { |
2925 | /* Item uses more slots than we have */ |
2935 | /* Item uses more slots than we have */ |
2926 | if (abs (op->slot[i].info) > who->slot[i].info) |
2936 | if (who->slot[i].info + op->slot [i].info < 0) |
2927 | { |
2937 | { |
2928 | /* Could return now for efficiency - rest of info below isn't |
2938 | /* Could return now for efficiency - rest of info below isn't |
2929 | * really needed. |
2939 | * really needed. |
2930 | */ |
2940 | */ |
2931 | retval |= CAN_APPLY_NEVER; |
2941 | retval |= CAN_APPLY_NEVER; |
2932 | } |
2942 | } |
2933 | else if ((who->slot[i].used + op->slot[i].info) < 0) |
2943 | else if (who->slot[i].used + op->slot[i].info < 0) |
2934 | { |
2944 | { |
2935 | /* in this case, equipping this would use more free spots than |
2945 | /* in this case, equipping this would use more free spots than |
2936 | * we have. |
2946 | * we have. |
2937 | */ |
2947 | */ |
2938 | |
2948 | |
… | |
… | |
2943 | * one choice. However, the check for the number of body locations |
2953 | * one choice. However, the check for the number of body locations |
2944 | * does take into the account cases where what is being applied |
2954 | * does take into the account cases where what is being applied |
2945 | * may be two handed for example. |
2955 | * may be two handed for example. |
2946 | */ |
2956 | */ |
2947 | if (ws) |
2957 | if (ws) |
2948 | { |
|
|
2949 | if ((who->slot[i].used - ws->slot[i].info + op->slot[i].info) >= 0) |
2958 | if ((who->slot[i].used - ws->slot[i].info + op->slot[i].info) >= 0) |
2950 | { |
2959 | { |
2951 | retval |= CAN_APPLY_UNAPPLY; |
2960 | retval |= CAN_APPLY_UNAPPLY; |
2952 | continue; |
2961 | continue; |
2953 | } |
2962 | } |
2954 | } |
|
|
2955 | |
2963 | |
2956 | object *tmp1 = get_item_from_body_location (i, who->inv); |
2964 | object *tmp1 = get_next_item_from_body_location (i, who->inv); |
2957 | if (!tmp1) |
2965 | if (!tmp1) |
2958 | { |
2966 | { |
2959 | #if 0 |
2967 | #if 0 |
2960 | /* This is sort of an error, but happens a lot when old players |
2968 | /* This is sort of an error, but happens a lot when old players |
2961 | * join in with more stuff equipped than they are now allowed. |
2969 | * join in with more stuff equipped than they are now allowed. |
2962 | */ |
2970 | */ |
2963 | LOG (llevError, "Can't find object using location %d on %s\n", i, who->name); |
2971 | LOG (llevError, "Can't find object using location %d on %s\n", i, who->name); |
2964 | #endif |
2972 | #endif |
|
|
2973 | fprintf (stderr, "can apply never due to %d but %d - %d + %d\n",//D |
|
|
2974 | i, who->slot[i].used,ws ? ws->slot[i].info :-77,op->slot[i].info);//D |
2965 | retval |= CAN_APPLY_NEVER; |
2975 | retval |= CAN_APPLY_NEVER; |
2966 | } |
2976 | } |
2967 | else |
2977 | else |
2968 | { |
2978 | { |
2969 | /* need to unapply something. However, if this something |
2979 | /* need to unapply something. However, if this something |
2970 | * is different than we had found before, it means they need |
2980 | * is different than we had found before, it means they need |
2971 | * to apply multiple objects |
2981 | * to apply multiple objects |
2972 | */ |
2982 | */ |
2973 | retval |= CAN_APPLY_UNAPPLY; |
2983 | retval |= CAN_APPLY_UNAPPLY; |
|
|
2984 | |
2974 | if (!tmp) |
2985 | if (!tmp) |
2975 | tmp = tmp1; |
2986 | tmp = tmp1; |
2976 | else if (tmp != tmp1) |
2987 | else if (tmp != tmp1) |
2977 | retval |= CAN_APPLY_UNAPPLY_MULT; |
2988 | retval |= CAN_APPLY_UNAPPLY_MULT; |
2978 | |
2989 | |
… | |
… | |
3069 | if (basic_flag == AP_APPLY) |
3080 | if (basic_flag == AP_APPLY) |
3070 | return 0; |
3081 | return 0; |
3071 | |
3082 | |
3072 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3083 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3073 | { |
3084 | { |
3074 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't\nremove %s.", query_name (op)); |
3085 | 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; |
3086 | return 1; |
3076 | } |
3087 | } |
3077 | |
3088 | |
3078 | return unapply_special (who, op, aflags); |
3089 | return unapply_special (who, op, aflags); |
3079 | } |
3090 | } |
3080 | |
3091 | |
3081 | if (basic_flag == AP_UNAPPLY) |
3092 | if (basic_flag == AP_UNAPPLY) |
3082 | return 0; |
3093 | return 0; |
|
|
3094 | |
|
|
3095 | // if the item is combat/ranged, wield the relevant slot first |
|
|
3096 | // to resolve conflicts. |
|
|
3097 | if (player *pl = who->contr) |
|
|
3098 | switch (op->slottype ()) |
|
|
3099 | { |
|
|
3100 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
|
|
3101 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
|
|
3102 | } |
3083 | |
3103 | |
3084 | /* Can't just apply this object. Lets see what not and what to do */ |
3104 | /* Can't just apply this object. Lets see what not and what to do */ |
3085 | if (int i = can_apply_object (who, op)) |
3105 | if (int i = can_apply_object (who, op)) |
3086 | { |
3106 | { |
3087 | if (i & CAN_APPLY_NEVER) |
3107 | if (i & CAN_APPLY_NEVER) |
… | |
… | |
3156 | switch (op->type) |
3176 | switch (op->type) |
3157 | { |
3177 | { |
3158 | case WEAPON: |
3178 | case WEAPON: |
3159 | if (!check_weapon_power (who, op->last_eat)) |
3179 | if (!check_weapon_power (who, op->last_eat)) |
3160 | { |
3180 | { |
3161 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use."); |
3181 | 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!."); |
3182 | "It would consume your soul!."); |
3163 | |
3183 | |
3164 | if (tmp) |
3184 | if (tmp) |
3165 | insert_ob_in_ob (tmp, who); |
3185 | insert_ob_in_ob (tmp, who); |
3166 | |
3186 | |
3167 | return 1; |
3187 | return 1; |
… | |
… | |
3189 | |
3209 | |
3190 | SET_FLAG (op, FLAG_APPLIED); |
3210 | SET_FLAG (op, FLAG_APPLIED); |
3191 | change_skill (who, skop, 1); |
3211 | change_skill (who, skop, 1); |
3192 | |
3212 | |
3193 | if (who->contr) |
3213 | if (who->contr) |
3194 | { |
|
|
3195 | who->contr->combat_ob = op; |
3214 | who->change_weapon (who->contr->combat_ob = op); |
3196 | who->current_weapon = op; |
|
|
3197 | } |
|
|
3198 | |
3215 | |
3199 | if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) |
3216 | if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) |
3200 | SET_FLAG (who, FLAG_READY_WEAPON); |
3217 | SET_FLAG (who, FLAG_READY_WEAPON); |
3201 | |
3218 | |
3202 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3219 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
… | |
… | |
3262 | if (who->type == PLAYER) |
3279 | if (who->type == PLAYER) |
3263 | esrv_send_item (who, tmp2); |
3280 | esrv_send_item (who, tmp2); |
3264 | |
3281 | |
3265 | return 0; |
3282 | return 0; |
3266 | |
3283 | |
3267 | /* this part is needed for skill-tools */ |
3284 | case SKILL_TOOL: |
|
|
3285 | // applying a skill tool also readies the skill |
|
|
3286 | SET_FLAG (op, FLAG_APPLIED); |
|
|
3287 | skop = find_skill_by_name (who, op->skill); |
|
|
3288 | if (!skop->flag [FLAG_APPLIED]) |
|
|
3289 | apply_special (who, skop, AP_APPLY); |
|
|
3290 | break; |
|
|
3291 | |
3268 | case SKILL: |
3292 | case SKILL: |
3269 | case SKILL_TOOL: |
|
|
3270 | if (who->chosen_skill) |
3293 | if (who->chosen_skill) |
3271 | { |
3294 | { |
3272 | LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); |
3295 | LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); |
3273 | return 1; |
3296 | return 1; |
3274 | } |
3297 | } |
… | |
… | |
3280 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3303 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3281 | { |
3304 | { |
3282 | for (object *item = who->inv; item; item = item->below) |
3305 | for (object *item = who->inv; item; item = item->below) |
3283 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3306 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3284 | { |
3307 | { |
3285 | pl->combat_ob = who->current_weapon = item; |
3308 | who->change_weapon (pl->combat_ob = item); |
3286 | goto found_weapon; |
3309 | goto found_weapon; |
3287 | } |
3310 | } |
3288 | |
3311 | |
3289 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill"); |
3312 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill"); |
3290 | return 1; |
3313 | return 1; |
3291 | |
3314 | |
3292 | found_weapon:; |
3315 | found_weapon:; |
3293 | } |
3316 | } |
3294 | else |
3317 | else |
3295 | { |
|
|
3296 | pl->combat_ob = op; |
3318 | who->change_weapon (pl->combat_ob = op); |
3297 | op->current_weapon = 0; |
|
|
3298 | } |
|
|
3299 | } |
3319 | } |
3300 | else if (IS_RANGED_SKILL (op->subtype)) |
3320 | else if (IS_RANGED_SKILL (op->subtype)) |
3301 | { |
3321 | { |
3302 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3322 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3303 | { |
3323 | { |
3304 | for (object *item = who->inv; item; item = item->below) |
3324 | for (object *item = who->inv; item; item = item->below) |
3305 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3325 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3306 | { |
3326 | { |
3307 | pl->ranged_ob = who->current_weapon = item; |
3327 | who->change_weapon (pl->ranged_ob = item); |
3308 | goto found_bow; |
3328 | goto found_bow; |
3309 | } |
3329 | } |
3310 | |
3330 | |
3311 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3331 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3312 | return 1; |
3332 | return 1; |
… | |
… | |
3317 | { |
3337 | { |
3318 | for (object *item = who->inv; item; item = item->below) |
3338 | for (object *item = who->inv; item; item = item->below) |
3319 | if (item->flag [FLAG_APPLIED] |
3339 | if (item->flag [FLAG_APPLIED] |
3320 | && (item->type == WAND || item->type == ROD || item->type == HORN)) |
3340 | && (item->type == WAND || item->type == ROD || item->type == HORN)) |
3321 | { |
3341 | { |
3322 | pl->ranged_ob = who->current_weapon = item; |
3342 | who->change_weapon (pl->ranged_ob = item); |
3323 | goto found_item; |
3343 | goto found_item; |
3324 | } |
3344 | } |
3325 | |
3345 | |
3326 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill"); |
3346 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill"); |
3327 | return 1; |
3347 | return 1; |
3328 | |
3348 | |
3329 | found_item:; |
3349 | found_item:; |
3330 | } |
3350 | } |
3331 | else |
3351 | else |
3332 | { |
|
|
3333 | pl->ranged_ob = op; |
3352 | who->change_weapon (pl->ranged_ob = op); |
3334 | op->current_weapon = 0; |
|
|
3335 | } |
|
|
3336 | } |
3353 | } |
3337 | |
3354 | |
3338 | if (!op->invisible) |
3355 | if (!op->invisible) |
3339 | { |
3356 | { |
3340 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); |
3357 | 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). |
3663 | * Handles player eating food that temporarily changes status (resistances, stats). |
3647 | * This used to call cast_change_attr(), but |
3664 | * This used to call cast_change_attr(), but |
3648 | * that doesn't work with the new spell code. Since we know what |
3665 | * 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. |
3666 | * the food changes, just grab a force and use that instead. |
3650 | */ |
3667 | */ |
3651 | |
|
|
3652 | void |
3668 | void |
3653 | eat_special_food (object *who, object *food) |
3669 | eat_special_food (object *who, object *food) |
3654 | { |
3670 | { |
3655 | object *force; |
3671 | object *force; |
3656 | int i, did_one = 0; |
3672 | int i, did_one = 0; |
3657 | sint8 k; |
|
|
3658 | |
3673 | |
3659 | force = get_archetype (FORCE_NAME); |
3674 | force = get_archetype (FORCE_NAME); |
3660 | |
3675 | |
3661 | for (i = 0; i < NUM_STATS; i++) |
3676 | for (i = 0; i < NUM_STATS; i++) |
3662 | { |
3677 | if (sint8 k = food->stats.stat (i)) |
3663 | k = get_attr_value (&food->stats, i); |
|
|
3664 | if (k) |
|
|
3665 | { |
3678 | { |
3666 | set_attr_value (&force->stats, i, k); |
3679 | force->stats.stat (i) = k; |
3667 | did_one = 1; |
3680 | did_one = 1; |
3668 | } |
3681 | } |
3669 | } |
|
|
3670 | |
3682 | |
3671 | /* check if we can protect the eater */ |
3683 | /* check if we can protect the eater */ |
3672 | for (i = 0; i < NROFATTACKS; i++) |
3684 | for (i = 0; i < NROFATTACKS; i++) |
3673 | { |
3685 | { |
3674 | if (food->resist[i] > 0) |
3686 | if (food->resist[i] > 0) |
… | |
… | |
3867 | */ |
3879 | */ |
3868 | int i, j; |
3880 | int i, j; |
3869 | |
3881 | |
3870 | for (i = 0; i < NUM_STATS; i++) |
3882 | for (i = 0; i < NUM_STATS; i++) |
3871 | { |
3883 | { |
3872 | sint8 stat = get_attr_value (stats, i); |
|
|
3873 | int race_bonus = get_attr_value (&(pl->arch->clone.stats), i); |
3884 | int race_bonus = pl->arch->clone.stats.stat (i); |
|
|
3885 | sint8 stat = stats->stat (i) + ns->stat (i); |
3874 | |
3886 | |
3875 | stat += get_attr_value (ns, i); |
|
|
3876 | if (stat > 20 + race_bonus) |
3887 | if (stat > 20 + race_bonus) |
3877 | { |
3888 | { |
3878 | excess_stat++; |
3889 | excess_stat++; |
3879 | stat = 20 + race_bonus; |
3890 | stat = 20 + race_bonus; |
3880 | } |
3891 | } |
3881 | set_attr_value (stats, i, stat); |
3892 | |
|
|
3893 | stats->stat (i) = stat; |
3882 | } |
3894 | } |
3883 | |
3895 | |
3884 | for (j = 0; excess_stat > 0 && j < 100; j++) |
3896 | for (j = 0; excess_stat > 0 && j < 100; j++) |
3885 | { /* try 100 times to assign excess stats */ |
3897 | { /* try 100 times to assign excess stats */ |
3886 | int i = rndm (0, 6); |
3898 | int i = rndm (0, 6); |
3887 | int stat = get_attr_value (stats, i); |
|
|
3888 | int race_bonus = get_attr_value (&(pl->arch->clone.stats), i); |
|
|
3889 | |
3899 | |
3890 | if (i == CHA) |
3900 | if (i == CHA) |
3891 | continue; /* exclude cha from this */ |
3901 | continue; /* exclude cha from this */ |
|
|
3902 | |
|
|
3903 | int stat = stats->stat (i); |
|
|
3904 | int race_bonus = pl->arch->clone.stats.stat (i); |
3892 | if (stat < 20 + race_bonus) |
3905 | if (stat < 20 + race_bonus) |
3893 | { |
3906 | { |
3894 | change_attr_value (stats, i, 1); |
3907 | change_attr_value (stats, i, 1); |
3895 | excess_stat--; |
3908 | excess_stat--; |
3896 | } |
3909 | } |
… | |
… | |
3899 | /* insert the randomitems from the change's treasurelist into |
3912 | /* insert the randomitems from the change's treasurelist into |
3900 | * the player ref: player.c |
3913 | * the player ref: player.c |
3901 | */ |
3914 | */ |
3902 | if (change->randomitems != NULL) |
3915 | if (change->randomitems != NULL) |
3903 | give_initial_items (pl, change->randomitems); |
3916 | give_initial_items (pl, change->randomitems); |
3904 | |
|
|
3905 | |
3917 | |
3906 | /* set up the face, for some races. */ |
3918 | /* set up the face, for some races. */ |
3907 | |
3919 | |
3908 | /* first, look for the force object banning |
3920 | /* first, look for the force object banning |
3909 | * changing the face. Certain races never change face with class. |
3921 | * changing the face. Certain races never change face with class. |