… | |
… | |
242 | change_attr_value (living *stats, int attr, sint8 value) |
242 | change_attr_value (living *stats, int attr, sint8 value) |
243 | { |
243 | { |
244 | stats->stat (attr) += value; |
244 | stats->stat (attr) += value; |
245 | } |
245 | } |
246 | |
246 | |
247 | sint8 & |
|
|
248 | living::stat (int index) |
|
|
249 | { |
|
|
250 | switch (index) |
|
|
251 | { |
|
|
252 | case STR: return Str; |
|
|
253 | case DEX: return Dex; |
|
|
254 | case CON: return Con; |
|
|
255 | case INT: return Int; |
|
|
256 | case WIS: return Wis; |
|
|
257 | case POW: return Pow; |
|
|
258 | case CHA: return Cha; |
|
|
259 | } |
|
|
260 | |
|
|
261 | LOG (llevError | logBacktrace, "living.stat() called with out-of-range stat index"); |
|
|
262 | static sint8 dummy; |
|
|
263 | return dummy; |
|
|
264 | } |
|
|
265 | |
|
|
266 | sint8 |
|
|
267 | living::stat (int index) const |
|
|
268 | { |
|
|
269 | switch (index) |
|
|
270 | { |
|
|
271 | case STR: return Str; |
|
|
272 | case DEX: return Dex; |
|
|
273 | case CON: return Con; |
|
|
274 | case INT: return Int; |
|
|
275 | case WIS: return Wis; |
|
|
276 | case POW: return Pow; |
|
|
277 | case CHA: return Cha; |
|
|
278 | } |
|
|
279 | |
|
|
280 | LOG (llevError | logBacktrace, "living.stat() called with out-of-range stat index"); |
|
|
281 | static sint8 dummy; |
|
|
282 | return dummy; |
|
|
283 | } |
|
|
284 | |
|
|
285 | /* |
247 | /* |
286 | * Ensures that all stats (str/dex/con/wis/cha/int) are within the |
248 | * Ensures that all stats (str/dex/con/wis/cha/int) are within the |
287 | * 1-30 stat limit. |
249 | * 1-30 stat limit. |
288 | */ |
250 | */ |
289 | void |
251 | void |
… | |
… | |
319 | * that gives them that ability. |
281 | * that gives them that ability. |
320 | */ |
282 | */ |
321 | int |
283 | int |
322 | change_abil (object *op, object *tmp) |
284 | change_abil (object *op, object *tmp) |
323 | { |
285 | { |
324 | int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, i, j, success = 0; |
286 | int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, success = 0; |
325 | char message[MAX_BUF]; |
287 | char message[MAX_BUF]; |
326 | int potion_max = 0; |
288 | int potion_max = 0; |
327 | |
289 | |
328 | /* remember what object was like before it was changed. note that |
290 | /* remember what object was like before it was changed. note that |
329 | * refop is a local copy of op only to be used for detecting changes |
291 | * refop is a local copy of op only to be used for detecting changes |
… | |
… | |
334 | if (op->type == PLAYER) |
296 | if (op->type == PLAYER) |
335 | { |
297 | { |
336 | if (tmp->type == POTION) |
298 | if (tmp->type == POTION) |
337 | { |
299 | { |
338 | potion_max = 1; |
300 | potion_max = 1; |
339 | for (j = 0; j < NUM_STATS; j++) |
301 | for (int j = 0; j < NUM_STATS; j++) |
340 | { |
302 | { |
341 | int nstat, ostat; |
|
|
342 | |
|
|
343 | ostat = op->contr->orig_stats.stat (j); |
303 | int ostat = op->contr->orig_stats.stat (j); |
344 | i = tmp->stats.stat (j); |
304 | int i = tmp->stats.stat (j); |
345 | |
305 | |
346 | /* nstat is what the stat will be after use of the potion */ |
306 | /* nstat is what the stat will be after use of the potion */ |
347 | nstat = flag * i + ostat; |
307 | int nstat = flag * i + ostat; |
348 | |
308 | |
349 | /* Do some bounds checking. While I don't think any |
309 | /* Do some bounds checking. While I don't think any |
350 | * potions do so right now, there is the potential for potions |
310 | * potions do so right now, there is the potential for potions |
351 | * 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 |
352 | * to allow for that. |
312 | * to allow for that. |
… | |
… | |
370 | |
330 | |
371 | /* This section of code ups the characters normal stats also. I am not |
331 | /* This section of code ups the characters normal stats also. I am not |
372 | * sure if this is strictly necessary, being that fix_player probably |
332 | * sure if this is strictly necessary, being that fix_player probably |
373 | * recalculates this anyway. |
333 | * recalculates this anyway. |
374 | */ |
334 | */ |
375 | for (j = 0; j < NUM_STATS; j++) |
335 | for (int j = 0; j < NUM_STATS; j++) |
376 | change_attr_value (&op->stats, j, flag * tmp->stats.stat (j)); |
336 | change_attr_value (&op->stats, j, flag * tmp->stats.stat (j)); |
377 | |
337 | |
378 | check_stat_bounds (&op->stats); |
338 | check_stat_bounds (&op->stats); |
379 | } /* end of potion handling code */ |
339 | } /* end of potion handling code */ |
380 | } |
340 | } |
381 | |
341 | |
382 | /* reset attributes that fix_player doesn't reset since it doesn't search |
342 | /* reset attributes that update_stats doesn't reset since it doesn't search |
383 | * everything to set |
343 | * everything to set |
384 | */ |
344 | */ |
385 | if (flag == -1) |
345 | if (flag == -1) |
386 | { |
346 | { |
387 | op->attacktype &= ~tmp->attacktype; |
347 | op->attacktype &= ~tmp->attacktype; |
… | |
… | |
393 | */ |
353 | */ |
394 | op->move_type &= ~tmp->move_type; |
354 | op->move_type &= ~tmp->move_type; |
395 | } |
355 | } |
396 | |
356 | |
397 | /* call fix_player since op object could have whatever attribute due |
357 | /* call fix_player since op object could have whatever attribute due |
398 | * to multiple items. if fix_player always has to be called after |
358 | * to multiple items. if update_stats always has to be called after |
399 | * change_ability then might as well call it from here |
359 | * change_ability then might as well call it from here |
400 | */ |
360 | */ |
401 | op->update_stats (); |
361 | op->update_stats (); |
402 | |
362 | |
403 | /* Fix player won't add the bows ability to the player, so don't |
363 | /* update_stats won't add the bows ability to the player, so don't |
404 | * print out message if this is a bow. |
364 | * print out message if this is a bow. |
405 | */ |
365 | */ |
406 | if (tmp->attacktype & AT_CONFUSION && tmp->type != BOW) |
366 | if (tmp->attacktype & AT_CONFUSION && tmp->type != BOW) |
407 | { |
367 | { |
408 | success = 1; |
368 | success = 1; |
… | |
… | |
448 | if (tmp->move_type & MOVE_FLY_HIGH) |
408 | if (tmp->move_type & MOVE_FLY_HIGH) |
449 | { |
409 | { |
450 | /* double conditional - second case covers if you have move_fly_low - |
410 | /* double conditional - second case covers if you have move_fly_low - |
451 | * in that case, you don't actually land |
411 | * in that case, you don't actually land |
452 | */ |
412 | */ |
453 | DIFF_MSG (flag, "You soar into the air air!.", |
413 | DIFF_MSG (flag, "You soar into the air!", |
454 | (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground.")); |
414 | (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground.")); |
455 | } |
415 | } |
456 | |
416 | |
457 | if (tmp->move_type & MOVE_SWIM) |
417 | if (tmp->move_type & MOVE_SWIM) |
458 | DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); |
418 | DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); |
… | |
… | |
589 | success = 1; |
549 | success = 1; |
590 | DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); |
550 | DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); |
591 | } |
551 | } |
592 | |
552 | |
593 | /* Messages for changed resistance */ |
553 | /* Messages for changed resistance */ |
594 | for (i = 0; i < NROFATTACKS; i++) |
554 | for (int i = 0; i < NROFATTACKS; i++) |
595 | { |
555 | { |
596 | if (i == ATNR_PHYSICAL) |
556 | if (i == ATNR_PHYSICAL) |
597 | continue; /* Don't display about armour */ |
557 | continue; /* Don't display about armour */ |
598 | |
558 | |
599 | if (op->resist[i] != refop.resist[i]) |
559 | if (op->resist[i] != refop.resist[i]) |
… | |
… | |
608 | } |
568 | } |
609 | } |
569 | } |
610 | |
570 | |
611 | if (!potion_max) |
571 | if (!potion_max) |
612 | { |
572 | { |
613 | for (j = 0; j < NUM_STATS; j++) |
573 | for (int j = 0; j < NUM_STATS; j++) |
614 | { |
574 | { |
615 | if ((i = tmp->stats.stat (j))) |
575 | if (int i = tmp->stats.stat (j)) |
616 | { |
576 | { |
617 | success = 1; |
577 | success = 1; |
618 | DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); |
578 | DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); |
619 | } |
579 | } |
620 | } |
580 | } |
… | |
… | |
723 | * Subtracts stat-bonuses given by the class which the player has chosen. |
683 | * Subtracts stat-bonuses given by the class which the player has chosen. |
724 | */ |
684 | */ |
725 | void |
685 | void |
726 | object::remove_statbonus () |
686 | object::remove_statbonus () |
727 | { |
687 | { |
728 | stats.Str -= arch->clone.stats.Str; |
688 | for (int i = 0; i < NUM_STATS; ++i) |
729 | stats.Dex -= arch->clone.stats.Dex; |
689 | { |
730 | stats.Con -= arch->clone.stats.Con; |
690 | sint8 v = arch->clone.stats.stat (i); |
731 | stats.Wis -= arch->clone.stats.Wis; |
691 | stats.stat (i) -= v; |
732 | stats.Pow -= arch->clone.stats.Pow; |
692 | contr->orig_stats.stat (i) -= v; |
733 | stats.Cha -= arch->clone.stats.Cha; |
693 | } |
734 | stats.Int -= arch->clone.stats.Int; |
|
|
735 | |
|
|
736 | contr->orig_stats.Str -= arch->clone.stats.Str; |
|
|
737 | contr->orig_stats.Dex -= arch->clone.stats.Dex; |
|
|
738 | contr->orig_stats.Con -= arch->clone.stats.Con; |
|
|
739 | contr->orig_stats.Wis -= arch->clone.stats.Wis; |
|
|
740 | contr->orig_stats.Pow -= arch->clone.stats.Pow; |
|
|
741 | contr->orig_stats.Cha -= arch->clone.stats.Cha; |
|
|
742 | contr->orig_stats.Int -= arch->clone.stats.Int; |
|
|
743 | } |
694 | } |
744 | |
695 | |
745 | /* |
696 | /* |
746 | * Adds stat-bonuses given by the class which the player has chosen. |
697 | * Adds stat-bonuses given by the class which the player has chosen. |
747 | */ |
698 | */ |
748 | void |
699 | void |
749 | object::add_statbonus () |
700 | object::add_statbonus () |
750 | { |
701 | { |
751 | stats.Str += arch->clone.stats.Str; |
702 | for (int i = 0; i < NUM_STATS; ++i) |
752 | stats.Dex += arch->clone.stats.Dex; |
703 | { |
753 | stats.Con += arch->clone.stats.Con; |
704 | sint8 v = arch->clone.stats.stat (i); |
754 | stats.Wis += arch->clone.stats.Wis; |
705 | stats.stat (i) += v; |
755 | stats.Pow += arch->clone.stats.Pow; |
706 | contr->orig_stats.stat (i) += v; |
756 | stats.Cha += arch->clone.stats.Cha; |
707 | } |
757 | stats.Int += arch->clone.stats.Int; |
|
|
758 | |
|
|
759 | contr->orig_stats.Str += arch->clone.stats.Str; |
|
|
760 | contr->orig_stats.Dex += arch->clone.stats.Dex; |
|
|
761 | contr->orig_stats.Con += arch->clone.stats.Con; |
|
|
762 | contr->orig_stats.Wis += arch->clone.stats.Wis; |
|
|
763 | contr->orig_stats.Pow += arch->clone.stats.Pow; |
|
|
764 | contr->orig_stats.Cha += arch->clone.stats.Cha; |
|
|
765 | contr->orig_stats.Int += arch->clone.stats.Int; |
|
|
766 | } |
708 | } |
767 | |
709 | |
768 | /* |
710 | /* |
769 | * Updates all abilities given by applied objects in the inventory |
711 | * Updates all abilities given by applied objects in the inventory |
770 | * of the given object. Note: This function works for both monsters |
712 | * of the given object. Note: This function works for both monsters |
… | |
… | |
997 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
939 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
998 | } |
940 | } |
999 | } |
941 | } |
1000 | |
942 | |
1001 | /* There may be other things that should not adjust the attacktype */ |
943 | /* There may be other things that should not adjust the attacktype */ |
1002 | if ((tmp->type != WEAPON && tmp->type != BOW && tmp->type != SYMPTOM) |
944 | if (tmp->type != SYMPTOM) |
1003 | || current_weapon == tmp) |
|
|
1004 | { |
945 | { |
1005 | attacktype |= tmp->attacktype; |
946 | attacktype |= tmp->attacktype; |
1006 | path_attuned |= tmp->path_attuned; |
947 | path_attuned |= tmp->path_attuned; |
1007 | path_repelled |= tmp->path_repelled; |
948 | path_repelled |= tmp->path_repelled; |
1008 | path_denied |= tmp->path_denied; |
949 | path_denied |= tmp->path_denied; |