… | |
… | |
279 | * that gives them that ability. |
279 | * that gives them that ability. |
280 | */ |
280 | */ |
281 | int |
281 | int |
282 | change_abil (object *op, object *tmp) |
282 | change_abil (object *op, object *tmp) |
283 | { |
283 | { |
284 | int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, success = 0; |
284 | int flag = tmp->flag [FLAG_APPLIED] ? 1 : -1; |
|
|
285 | int success = 0; |
285 | char message[MAX_BUF]; |
286 | char message[MAX_BUF]; |
286 | int potion_max = 0; |
287 | int potion_max = 0; |
287 | |
288 | |
|
|
289 | // keep some stats for comparison purposes |
288 | object::flags_t prev_flag = op->flag; |
290 | object::flags_t prev_flag = op->flag; |
289 | MoveType prev_move_type = op->move_type; |
291 | MoveType prev_move_type = op->move_type; |
290 | sint16 prev_resist [NROFATTACKS]; // clumsy |
292 | sint16 prev_resist [NROFATTACKS]; // clumsy |
291 | assert (sizeof (prev_resist) == sizeof (op->resist)); |
293 | assert (sizeof (prev_resist) == sizeof (op->resist)); |
292 | memcpy (prev_resist, op->resist, sizeof (prev_resist)); |
294 | memcpy (prev_resist, op->resist, sizeof (prev_resist)); |
… | |
… | |
294 | if (op->type == PLAYER) |
296 | if (op->type == PLAYER) |
295 | { |
297 | { |
296 | if (tmp->type == POTION) |
298 | if (tmp->type == POTION) |
297 | { |
299 | { |
298 | potion_max = 1; |
300 | potion_max = 1; |
|
|
301 | |
299 | for (int j = 0; j < NUM_STATS; j++) |
302 | for (int j = 0; j < NUM_STATS; j++) |
300 | { |
303 | { |
301 | int ostat = op->contr->orig_stats.stat (j); |
304 | int ostat = op->contr->orig_stats.stat (j); |
302 | int i = tmp->stats.stat (j); |
305 | int i = tmp->stats.stat (j); |
303 | |
306 | |
304 | /* nstat is what the stat will be after use of the potion */ |
307 | /* nstat is what the stat will be after use of the potion */ |
305 | int nstat = flag * i + ostat; |
308 | int nstat = flag * i + ostat; |
306 | |
309 | |
307 | /* Do some bounds checking. While I don't think any |
310 | /* Do some bounds checking. There is the potential for potions |
308 | * potions do so right now, there is the potential for potions |
|
|
309 | * that adjust that stat by more than one point, so we need |
311 | * that adjust that stat by more than one point, so we need |
310 | * to allow for that. |
312 | * to allow for that. |
311 | */ |
313 | */ |
312 | if (nstat < 1 && i * flag < 0) |
314 | if (nstat < 1 && i * flag < 0) |
313 | nstat = 1; |
315 | nstat = 1; |
… | |
… | |
566 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, op, message); |
568 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, op, message); |
567 | } |
569 | } |
568 | } |
570 | } |
569 | |
571 | |
570 | if (!potion_max) |
572 | if (!potion_max) |
571 | { |
|
|
572 | for (int j = 0; j < NUM_STATS; j++) |
573 | for (int j = 0; j < NUM_STATS; j++) |
573 | { |
|
|
574 | if (int i = tmp->stats.stat (j)) |
574 | if (int i = tmp->stats.stat (j)) |
575 | { |
575 | { |
576 | success = 1; |
576 | success = 1; |
577 | DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); |
577 | DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); |
578 | } |
578 | } |
579 | } |
|
|
580 | } |
|
|
581 | |
579 | |
582 | return success; |
580 | return success; |
583 | } |
581 | } |
584 | |
582 | |
585 | /* |
583 | /* |
… | |
… | |
863 | continue; |
861 | continue; |
864 | |
862 | |
865 | /* See note in map.c:update_position about making this additive |
863 | /* See note in map.c:update_position about making this additive |
866 | * since light sources are never applied, need to put check here. |
864 | * since light sources are never applied, need to put check here. |
867 | */ |
865 | */ |
868 | if (tmp->glow_radius > glow_radius) |
|
|
869 | glow_radius = tmp->glow_radius; |
866 | glow_radius = max (glow_radius, tmp->glow_radius); |
870 | |
867 | |
871 | /* For some things, we don't care what is equipped */ |
868 | /* For some things, we don't care what is equipped */ |
872 | if (tmp->type == SKILL) |
869 | if (tmp->type == SKILL) |
873 | { |
870 | { |
874 | /* Want to take the highest skill here. */ |
871 | /* Want to take the highest skill here. */ |
… | |
… | |
887 | else if (tmp->level > grace_obj->level) |
884 | else if (tmp->level > grace_obj->level) |
888 | grace_obj = tmp; |
885 | grace_obj = tmp; |
889 | } |
886 | } |
890 | } |
887 | } |
891 | |
888 | |
892 | /* Container objects are not meant to adjust a players, but other applied |
889 | /* Container objects are not meant to adjust players, but other applied |
893 | * objects need to make adjustments. |
890 | * objects need to make adjustments. |
894 | * This block should handle all player specific changes |
891 | * This block should handle all player specific changes |
895 | * The check for Praying is a bit of a hack - god given bonuses are put |
892 | * The check for Praying is a bit of a hack - god given bonuses are put |
896 | * in the praying skill, and the player should always get those. |
893 | * in the praying skill, and the player should always get those. |
897 | * It also means we need to put in additional checks for applied below, |
894 | * It also means we need to put in additional checks for applied below, |
… | |
… | |
940 | |
937 | |
941 | if (tmp->type == SYMPTOM) |
938 | if (tmp->type == SYMPTOM) |
942 | speed_reduce_from_disease = |
939 | speed_reduce_from_disease = |
943 | min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
940 | min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
944 | |
941 | |
945 | /* Pos. and neg. protections are counted seperate (-> pro/vuln). |
942 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
946 | * (Negative protections are calculated exactly like positive.) |
943 | * (Negative protections are calculated exactly like positive.) |
947 | * Resistance from potions are treated special as well. If there's |
944 | * Resistance from potions are treated special as well. If there's |
948 | * more than one potion-effect, the bigger prot.-value is taken. |
945 | * more than one potion-effect, the bigger prot.-value is taken. |
949 | */ |
946 | */ |
950 | if (tmp->type != POTION) |
947 | if (tmp->type != POTION) |