1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
461 | if (op->flag [FLAG_WIZ]) |
461 | if (op->flag [FLAG_WIZ]) |
462 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self is blinded."); |
462 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self is blinded."); |
463 | else |
463 | else |
464 | { |
464 | { |
465 | new_draw_info (NDI_UNIQUE, 0, op, "You are blinded."); |
465 | new_draw_info (NDI_UNIQUE, 0, op, "You are blinded."); |
466 | SET_FLAG (op, FLAG_BLIND); |
466 | op->set_flag (FLAG_BLIND); |
467 | if (op->type == PLAYER) |
467 | if (op->type == PLAYER) |
468 | op->contr->do_los = 1; |
468 | op->contr->do_los = 1; |
469 | } |
469 | } |
470 | } |
470 | } |
471 | else |
471 | else |
… | |
… | |
473 | if (op->flag [FLAG_WIZ]) |
473 | if (op->flag [FLAG_WIZ]) |
474 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self can now see again."); |
474 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self can now see again."); |
475 | else |
475 | else |
476 | { |
476 | { |
477 | new_draw_info (NDI_UNIQUE, 0, op, "Your vision returns."); |
477 | new_draw_info (NDI_UNIQUE, 0, op, "Your vision returns."); |
478 | CLEAR_FLAG (op, FLAG_BLIND); |
478 | op->clr_flag (FLAG_BLIND); |
479 | if (op->type == PLAYER) |
479 | if (op->type == PLAYER) |
480 | op->contr->do_los = 1; |
480 | op->contr->do_los = 1; |
481 | } |
481 | } |
482 | } |
482 | } |
483 | } |
483 | } |
… | |
… | |
521 | { |
521 | { |
522 | success = 1; |
522 | success = 1; |
523 | DIFF_MSG (flag * tmp->stats.luck, "You feel more lucky.", "You feel less lucky."); |
523 | DIFF_MSG (flag * tmp->stats.luck, "You feel more lucky.", "You feel less lucky."); |
524 | } |
524 | } |
525 | |
525 | |
|
|
526 | if (digest_types [tmp->type]) |
|
|
527 | { |
526 | if (tmp->stats.hp && op->type == PLAYER) |
528 | if (tmp->stats.hp && op->type == PLAYER) |
527 | { |
529 | { |
528 | success = 1; |
530 | success = 1; |
529 | DIFF_MSG (flag * tmp->stats.hp, "You feel much more healthy!", "You feel much less healthy!"); |
531 | DIFF_MSG (flag * tmp->stats.hp, "You feel much more healthy!", "You feel much less healthy!"); |
530 | } |
532 | } |
531 | |
533 | |
532 | if (tmp->stats.sp && op->type == PLAYER && tmp->type != SKILL) |
534 | if (tmp->stats.sp && op->type == PLAYER |
533 | { |
535 | && tmp->type != SKILL && tmp->type != BOW) |
|
|
536 | { |
534 | success = 1; |
537 | success = 1; |
535 | DIFF_MSG (flag * tmp->stats.sp, "You feel one with the powers of magic!", "You suddenly feel very mundane."); |
538 | DIFF_MSG (flag * tmp->stats.sp, "You feel one with the powers of magic!", "You suddenly feel very mundane."); |
536 | } |
539 | } |
537 | |
540 | |
538 | /* for the future when artifacts set this -b.t. */ |
541 | /* for the future when artifacts set this -b.t. */ |
539 | if (tmp->stats.grace && op->type == PLAYER) |
542 | if (tmp->stats.grace && op->type == PLAYER) |
540 | { |
543 | { |
541 | success = 1; |
544 | success = 1; |
542 | DIFF_MSG (flag * tmp->stats.grace, "You feel closer to your god!", "You suddenly feel less holy."); |
545 | DIFF_MSG (flag * tmp->stats.grace, "You feel closer to your god!", "You suddenly feel less holy."); |
543 | } |
546 | } |
544 | |
547 | |
545 | if (tmp->stats.food && op->type == PLAYER) |
548 | if (tmp->stats.food && op->type == PLAYER) |
546 | { |
549 | { |
547 | success = 1; |
550 | success = 1; |
548 | DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); |
551 | DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); |
|
|
552 | } |
549 | } |
553 | } |
550 | |
554 | |
551 | /* Messages for changed resistance */ |
555 | /* Messages for changed resistance */ |
552 | for (int i = 0; i < NROFATTACKS; i++) |
556 | for (int i = 0; i < NROFATTACKS; i++) |
553 | { |
557 | { |
… | |
… | |
606 | |
610 | |
607 | if (!tmp) |
611 | if (!tmp) |
608 | { |
612 | { |
609 | tmp = at->instance (); |
613 | tmp = at->instance (); |
610 | tmp = insert_ob_in_ob (tmp, this); |
614 | tmp = insert_ob_in_ob (tmp, this); |
611 | SET_FLAG (tmp, FLAG_APPLIED); |
615 | tmp->set_flag (FLAG_APPLIED); |
612 | } |
616 | } |
613 | } |
617 | } |
614 | |
618 | |
615 | new_draw_info (NDI_UNIQUE, 0, this, drain_msg[deplete_stats]); |
619 | new_draw_info (NDI_UNIQUE, 0, this, drain_msg[deplete_stats]); |
616 | change_attr_value (&tmp->stats, deplete_stats, -1); |
620 | change_attr_value (&tmp->stats, deplete_stats, -1); |
… | |
… | |
636 | if (!value) |
640 | if (!value) |
637 | return; |
641 | return; |
638 | |
642 | |
639 | tmp = at->instance (); |
643 | tmp = at->instance (); |
640 | tmp = insert_ob_in_ob (tmp, this); |
644 | tmp = insert_ob_in_ob (tmp, this); |
641 | SET_FLAG (tmp, FLAG_APPLIED); |
645 | tmp->set_flag (FLAG_APPLIED); |
642 | } |
646 | } |
643 | |
647 | |
644 | if (value) |
648 | if (value) |
645 | { |
649 | { |
646 | /* Limit the luck value of the bad luck object to +/-100. This |
650 | /* Limit the luck value of the bad luck object to +/-100. This |
… | |
… | |
699 | sint8 v = arch->stats.stat (i); |
703 | sint8 v = arch->stats.stat (i); |
700 | stats.stat (i) += v; |
704 | stats.stat (i) += v; |
701 | contr->orig_stats.stat (i) += v; |
705 | contr->orig_stats.stat (i) += v; |
702 | } |
706 | } |
703 | } |
707 | } |
704 | |
|
|
705 | /* These are the items that currently can change digestion, regeneration, |
|
|
706 | * spell point recovery and mana point recovery. Seems sort of an arbitary |
|
|
707 | * list, but other items store other info into stats array. |
|
|
708 | */ |
|
|
709 | static struct digest_types : std::bitset<NUM_TYPES> |
|
|
710 | { |
|
|
711 | digest_types () |
|
|
712 | { |
|
|
713 | set (WEAPON); |
|
|
714 | set (BOW); |
|
|
715 | set (ARMOUR); |
|
|
716 | set (HELMET); |
|
|
717 | set (SHIELD); |
|
|
718 | set (RING); |
|
|
719 | set (BOOTS); |
|
|
720 | set (GLOVES); |
|
|
721 | set (AMULET); |
|
|
722 | set (GIRDLE); |
|
|
723 | set (BRACERS); |
|
|
724 | set (CLOAK); |
|
|
725 | set (DISEASE); |
|
|
726 | set (FORCE); |
|
|
727 | set (SKILL); |
|
|
728 | } |
|
|
729 | } digest_types; |
|
|
730 | |
708 | |
731 | static struct copy_flags : object::flags_t |
709 | static struct copy_flags : object::flags_t |
732 | { |
710 | { |
733 | copy_flags () |
711 | copy_flags () |
734 | { |
712 | { |
… | |
… | |
789 | for (int i = NUM_BODY_LOCATIONS; i--; ) |
767 | for (int i = NUM_BODY_LOCATIONS; i--; ) |
790 | slot[i].used = slot[i].info; |
768 | slot[i].used = slot[i].info; |
791 | |
769 | |
792 | slaying = 0; |
770 | slaying = 0; |
793 | |
771 | |
794 | if (!QUERY_FLAG (this, FLAG_WIZ)) |
772 | if (!this->flag [FLAG_WIZ]) |
795 | { |
|
|
796 | CLEAR_FLAG (this, FLAG_XRAYS); |
|
|
797 | CLEAR_FLAG (this, FLAG_MAKE_INVIS); |
|
|
798 | } |
773 | { |
|
|
774 | this->clr_flag (FLAG_XRAYS); |
|
|
775 | this->clr_flag (FLAG_MAKE_INVIS); |
|
|
776 | } |
799 | |
777 | |
800 | CLEAR_FLAG (this, FLAG_LIFESAVE); |
778 | this->clr_flag (FLAG_LIFESAVE); |
801 | CLEAR_FLAG (this, FLAG_STEALTH); |
779 | this->clr_flag (FLAG_STEALTH); |
802 | CLEAR_FLAG (this, FLAG_BLIND); |
780 | this->clr_flag (FLAG_BLIND); |
803 | |
781 | |
804 | if (!QUERY_FLAG (arch, FLAG_REFL_SPELL )) CLEAR_FLAG (this, FLAG_REFL_SPELL); |
782 | if (!arch->flag [FLAG_REFL_SPELL ]) this->clr_flag (FLAG_REFL_SPELL); |
805 | if (!QUERY_FLAG (arch, FLAG_REFL_MISSILE)) CLEAR_FLAG (this, FLAG_REFL_MISSILE); |
783 | if (!arch->flag [FLAG_REFL_MISSILE]) this->clr_flag (FLAG_REFL_MISSILE); |
806 | if (!QUERY_FLAG (arch, FLAG_UNDEAD )) CLEAR_FLAG (this, FLAG_UNDEAD); |
784 | if (!arch->flag [FLAG_UNDEAD ]) this->clr_flag (FLAG_UNDEAD); |
807 | if (!QUERY_FLAG (arch, FLAG_SEE_IN_DARK )) CLEAR_FLAG (this, FLAG_SEE_IN_DARK); |
785 | if (!arch->flag [FLAG_SEE_IN_DARK ]) this->clr_flag (FLAG_SEE_IN_DARK); |
808 | |
786 | |
809 | path_attuned = arch->path_attuned; |
787 | path_attuned = arch->path_attuned; |
810 | path_repelled = arch->path_repelled; |
788 | path_repelled = arch->path_repelled; |
811 | path_denied = arch->path_denied; |
789 | path_denied = arch->path_denied; |
812 | glow_radius = arch->glow_radius; |
790 | glow_radius = arch->glow_radius; |
813 | move_type = arch->move_type; |
791 | move_type = arch->move_type; |
814 | |
792 | |
815 | chosen_skill = 0; |
|
|
816 | |
|
|
817 | /* initializing resistances from the values in player/monster's |
793 | /* initializing resistances from the values in player/monster's |
818 | * archetype clone |
794 | * archetype clone |
819 | */ |
795 | */ |
820 | memcpy (&resist, &arch->resist, sizeof (resist)); |
796 | memcpy (&resist, &arch->resist, sizeof (resist)); |
821 | |
797 | |
822 | for (int i = 0; i < NROFATTACKS; i++) |
798 | for (int i = 0; i < NROFATTACKS; i++) |
823 | { |
799 | { |
824 | if (resist[i] > 0) |
800 | if (resist[i] > 0) |
825 | prot[i] = resist[i], vuln[i] = 0; |
801 | prot[i] = resist[i], vuln[i] = 0; |
826 | else |
802 | else |
827 | vuln[i] = -(resist[i]), prot[i] = 0; |
803 | vuln[i] = -resist[i], prot[i] = 0; |
828 | |
804 | |
829 | potion_resist[i] = 0; |
805 | potion_resist[i] = -1000; |
830 | } |
806 | } |
831 | |
807 | |
832 | wc = arch->stats.wc; |
808 | wc = arch->stats.wc; |
833 | stats.dam = arch->stats.dam; |
809 | stats.dam = arch->stats.dam; |
834 | |
810 | |
… | |
… | |
837 | * the fact that maxlevel is factored in could be considered sort of bogus - |
813 | * the fact that maxlevel is factored in could be considered sort of bogus - |
838 | * we should probably give them some bonus and cap it off - otherwise, |
814 | * we should probably give them some bonus and cap it off - otherwise, |
839 | * basically, if a server updates its max level, these playes may find |
815 | * basically, if a server updates its max level, these playes may find |
840 | * that their protection from physical goes down |
816 | * that their protection from physical goes down |
841 | */ |
817 | */ |
842 | if (!QUERY_FLAG (this, FLAG_USE_ARMOUR) && type == PLAYER) |
818 | if (!this->flag [FLAG_USE_ARMOUR] && type == PLAYER) |
843 | { |
819 | { |
844 | ac = max (-10, arch->stats.ac - level / 3); |
820 | ac = max (-10, arch->stats.ac - level / 3); |
845 | prot[ATNR_PHYSICAL] += ((100 - prot[AT_PHYSICAL]) * (80 * level / settings.max_level)) / 100; |
821 | prot[ATNR_PHYSICAL] += ((100 - prot[AT_PHYSICAL]) * (80 * level / settings.max_level)) / 100; |
846 | } |
822 | } |
847 | else |
823 | else |
848 | ac = arch->stats.ac; |
824 | ac = arch->stats.ac; |
849 | |
825 | |
850 | stats.luck = arch->stats.luck; |
826 | stats.luck = arch->stats.luck; |
851 | speed = arch->speed; |
827 | speed = arch->speed; |
|
|
828 | |
|
|
829 | chosen_skill = 0; |
852 | |
830 | |
853 | /* OK - we've reset most all the objects attributes to sane values. |
831 | /* OK - we've reset most all the objects attributes to sane values. |
854 | * now go through and make adjustments for what the player has equipped. |
832 | * now go through and make adjustments for what the player has equipped. |
855 | */ |
833 | */ |
856 | for (tmp = inv; tmp; tmp = tmp->below) |
834 | for (tmp = inv; tmp; tmp = tmp->below) |
857 | { |
835 | { |
858 | /* This happens because apply_potion calls change_abil with the potion |
836 | /* This happens because apply_potion calls change_abil with the potion |
859 | * applied so we can tell the player what changed. But change_abil |
837 | * applied so we can tell the player what changed. But change_abil |
860 | * then calls this function. |
838 | * then calls this function. |
861 | */ |
839 | */ |
862 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION) |
840 | if (tmp->flag [FLAG_APPLIED] && tmp->type == POTION) |
863 | continue; |
841 | continue; |
864 | |
842 | |
865 | glow_radius += tmp->glow_radius; |
843 | glow_radius += tmp->glow_radius; |
866 | |
844 | |
867 | /* For some things, we don't care what is equipped */ |
845 | /* For some things, we don't care what is equipped */ |
… | |
… | |
895 | * up, etc. |
873 | * up, etc. |
896 | */ |
874 | */ |
897 | if ((tmp->flag [FLAG_APPLIED] |
875 | if ((tmp->flag [FLAG_APPLIED] |
898 | && tmp->type != CONTAINER |
876 | && tmp->type != CONTAINER |
899 | && tmp->type != CLOSE_CON) |
877 | && tmp->type != CLOSE_CON) |
900 | || (tmp->type == SKILL |
|
|
901 | && tmp->subtype == SK_PRAYING)) |
878 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
902 | { |
879 | { |
903 | if (type == PLAYER) |
880 | if (type == PLAYER) |
904 | { |
881 | { |
905 | contr->item_power += tmp->item_power; |
882 | contr->item_power += tmp->item_power; |
906 | |
|
|
907 | if (tmp == contr->combat_ob || tmp == contr->ranged_ob) |
|
|
908 | if (tmp != current_weapon |
|
|
909 | && (tmp->type != SKILL || tmp->subtype != SK_PRAYING) |
|
|
910 | && !tmp->flag [FLAG_CURSED] |
|
|
911 | && !tmp->flag [FLAG_DAMNED]) |
|
|
912 | continue; |
|
|
913 | |
883 | |
914 | for (int i = 0; i < NUM_STATS; i++) |
884 | for (int i = 0; i < NUM_STATS; i++) |
915 | stat_sum [i] += tmp->stats.stat (i); |
885 | stat_sum [i] += tmp->stats.stat (i); |
916 | |
886 | |
917 | if (digest_types [tmp->type]) |
887 | if (digest_types [tmp->type]) |
… | |
… | |
929 | if (tmp->type == WEAPON) |
899 | if (tmp->type == WEAPON) |
930 | current_weapon = tmp; |
900 | current_weapon = tmp; |
931 | } |
901 | } |
932 | |
902 | |
933 | /* Update slots used for items */ |
903 | /* Update slots used for items */ |
934 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
904 | if (tmp->flag [FLAG_APPLIED]) // exclude praying... |
935 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
905 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
936 | slot[i].used += tmp->slot[i].info; |
906 | slot[i].used += tmp->slot[i].info; |
937 | |
907 | |
938 | if (tmp->type == SYMPTOM) |
908 | if (tmp->type == SYMPTOM) |
939 | speed_reduce_from_disease = |
|
|
940 | min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
909 | min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
941 | |
910 | |
942 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
911 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
943 | * (Negative protections are calculated exactly like positive.) |
912 | * (Negative protections are calculated exactly like positive.) |
944 | * Resistance from potions are treated special as well. If there's |
913 | * Resistance from potions are treated special as well. If there's |
945 | * more than one potion-effect, the bigger prot.-value is taken. |
914 | * more than one potion-effect, the bigger prot.-value is taken. |
946 | */ |
915 | */ |
947 | if (tmp->type != POTION) |
916 | if (tmp->type == POTION_EFFECT) |
948 | { |
|
|
949 | for (int i = 0; i < NROFATTACKS; i++) |
917 | for (int i = 0; i < NROFATTACKS; i++) |
950 | { |
|
|
951 | /* Potential for cursed potions, in which case we just can use |
|
|
952 | * a straight MAX, as potion_resist is initialised to zero. |
|
|
953 | */ |
|
|
954 | if (tmp->type == POTION_EFFECT) |
|
|
955 | { |
|
|
956 | if (potion_resist[i]) |
|
|
957 | potion_resist[i] = max (potion_resist[i], tmp->resist[i]); |
|
|
958 | else |
|
|
959 | potion_resist[i] = tmp->resist[i]; |
918 | max_it (potion_resist[i], tmp->resist[i]); |
960 | } |
919 | else if (tmp->type != POTION) |
|
|
920 | for (int i = 0; i < NROFATTACKS; i++) |
961 | else if (tmp->resist[i] > 0) |
921 | if (tmp->resist[i] > 0) |
962 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
922 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
963 | else if (tmp->resist[i] < 0) |
923 | else if (tmp->resist[i] < 0) |
964 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
924 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
965 | } |
|
|
966 | } |
|
|
967 | |
925 | |
968 | /* There may be other things that should not adjust the attacktype */ |
926 | /* There may be other things that should not adjust the attacktype */ |
969 | if (tmp->type != SYMPTOM) |
927 | if (tmp->type != SYMPTOM) |
970 | { |
928 | { |
971 | attacktype |= tmp->attacktype; |
929 | attacktype |= tmp->attacktype; |
… | |
… | |
976 | stats.luck += tmp->stats.luck; |
934 | stats.luck += tmp->stats.luck; |
977 | } |
935 | } |
978 | |
936 | |
979 | flag |= tmp->flag & copy_flags; |
937 | flag |= tmp->flag & copy_flags; |
980 | |
938 | |
981 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
939 | if (tmp->flag [FLAG_UNDEAD] && !arch->flag [FLAG_UNDEAD]) |
982 | SET_FLAG (this, FLAG_UNDEAD); |
940 | this->set_flag (FLAG_UNDEAD); |
983 | |
941 | |
984 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
942 | //TODO: copy_flags? |
|
|
943 | if (tmp->flag [FLAG_MAKE_INVIS]) |
985 | { |
944 | { |
986 | SET_FLAG (this, FLAG_MAKE_INVIS); |
945 | this->set_flag (FLAG_MAKE_INVIS); |
987 | invisible = 1; |
946 | invisible = 1; |
988 | } |
947 | } |
989 | |
948 | |
990 | if (tmp->stats.exp && tmp->type != SKILL) |
949 | if (tmp->stats.exp && tmp->type != SKILL) |
991 | { |
950 | { |
… | |
… | |
998 | added_speed += tmp->stats.exp; |
957 | added_speed += tmp->stats.exp; |
999 | } |
958 | } |
1000 | |
959 | |
1001 | switch (tmp->type) |
960 | switch (tmp->type) |
1002 | { |
961 | { |
1003 | #if 0 |
|
|
1004 | case WAND: |
|
|
1005 | case ROD: |
|
|
1006 | case HORN: |
|
|
1007 | if (type != PLAYER || current_weapon == tmp) |
|
|
1008 | chosen_skill = tmp; |
|
|
1009 | break; |
|
|
1010 | #endif |
|
|
1011 | |
|
|
1012 | /* skills modifying the character -b.t. */ |
|
|
1013 | /* for all skills and skill granting objects */ |
|
|
1014 | case SKILL: |
962 | case SKILL: |
1015 | { |
963 | { |
|
|
964 | // some skills will end up here without counting as "applied" |
1016 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) |
965 | if (!tmp->flag [FLAG_APPLIED] || skill_flags [tmp->subtype] & SF_AUTARK) |
1017 | break; |
966 | break; |
1018 | |
967 | |
1019 | if (chosen_skill) |
968 | if (chosen_skill) |
1020 | { |
969 | { |
1021 | LOG (llevDebug, "fix_player, op %s has multiple skills applied (%s and %s)\n", |
970 | LOG (llevDebug, "fix_player, op %s has multiple skills applied (%s and %s)\n", |
… | |
… | |
1023 | |
972 | |
1024 | tmp->flag [FLAG_APPLIED] = false; |
973 | tmp->flag [FLAG_APPLIED] = false; |
1025 | update_stats (); |
974 | update_stats (); |
1026 | return; |
975 | return; |
1027 | } |
976 | } |
1028 | else |
977 | |
1029 | chosen_skill = tmp; |
978 | chosen_skill = tmp; |
1030 | |
979 | |
1031 | if (tmp->stats.dam > 0) |
980 | if (tmp->stats.dam > 0) |
1032 | { /* skill is a 'weapon' */ |
981 | { /* skill is a 'weapon' */ |
1033 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
982 | if (!this->flag [FLAG_READY_WEAPON]) |
1034 | weapon_speed = WEAPON_SPEED (tmp); |
983 | weapon_speed = max (0, WEAPON_SPEED (tmp)); |
1035 | |
|
|
1036 | if (weapon_speed < 0) |
|
|
1037 | weapon_speed = 0; |
|
|
1038 | |
984 | |
1039 | weapon_weight = tmp->weight; |
985 | weapon_weight = tmp->weight; |
1040 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
986 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
1041 | |
987 | |
1042 | if (tmp->magic) |
988 | if (tmp->magic) |
… | |
… | |
1051 | |
997 | |
1052 | if (tmp->stats.ac) |
998 | if (tmp->stats.ac) |
1053 | ac -= tmp->stats.ac + tmp->magic; |
999 | ac -= tmp->stats.ac + tmp->magic; |
1054 | |
1000 | |
1055 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1001 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1056 | contr->encumbrance += (int) 3 *tmp->weight / 1000; |
1002 | contr->encumbrance += 3 * tmp->weight / 1000; |
1057 | } |
1003 | } |
1058 | |
1004 | |
1059 | break; |
1005 | break; |
1060 | |
1006 | |
1061 | case SHIELD: |
1007 | case SHIELD: |
1062 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1008 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1063 | contr->encumbrance += (int) tmp->weight / 2000; |
1009 | contr->encumbrance += tmp->weight / 2000; |
|
|
1010 | //FALLTHROUGH |
1064 | case RING: |
1011 | case RING: |
1065 | case AMULET: |
1012 | case AMULET: |
1066 | case GIRDLE: |
1013 | case GIRDLE: |
1067 | case HELMET: |
1014 | case HELMET: |
1068 | case BOOTS: |
1015 | case BOOTS: |
… | |
… | |
1077 | if (tmp->stats.ac) |
1024 | if (tmp->stats.ac) |
1078 | ac -= tmp->stats.ac + tmp->magic; |
1025 | ac -= tmp->stats.ac + tmp->magic; |
1079 | |
1026 | |
1080 | break; |
1027 | break; |
1081 | |
1028 | |
|
|
1029 | case WAND: |
|
|
1030 | case ROD: |
|
|
1031 | case HORN: |
|
|
1032 | break; |
|
|
1033 | |
1082 | case BOW: |
1034 | case BOW: |
1083 | case WEAPON: |
1035 | case WEAPON: |
1084 | if (type != PLAYER || current_weapon == tmp) |
|
|
1085 | { |
|
|
1086 | wc -= tmp->stats.wc + tmp->magic; |
1036 | wc -= tmp->stats.wc + tmp->magic; |
1087 | |
1037 | |
1088 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1038 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1089 | ac -= tmp->stats.ac + tmp->magic; |
1039 | ac -= tmp->stats.ac + tmp->magic; |
1090 | |
1040 | |
1091 | stats.dam += tmp->stats.dam + tmp->magic; |
1041 | stats.dam += tmp->stats.dam + tmp->magic; |
1092 | weapon_weight = tmp->weight; |
1042 | weapon_weight = tmp->weight; |
1093 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1043 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1094 | |
1044 | |
1095 | if (weapon_speed < 0) |
1045 | if (weapon_speed < 0) |
1096 | weapon_speed = 0; |
1046 | weapon_speed = 0; |
1097 | |
1047 | |
1098 | slaying = tmp->slaying; |
1048 | slaying = tmp->slaying; |
1099 | |
1049 | |
1100 | /* If there is desire that two handed weapons should do |
1050 | /* If there is desire that two handed weapons should do |
1101 | * extra strength damage, this is where the code should |
1051 | * extra strength damage, this is where the code should |
1102 | * go. |
1052 | * go. |
1103 | */ |
1053 | */ |
1104 | |
1054 | |
1105 | if (type == PLAYER) |
1055 | if (type == PLAYER) |
1106 | if (settings.spell_encumbrance) |
1056 | if (settings.spell_encumbrance) |
1107 | contr->encumbrance += tmp->weight * 3 / 1000; |
1057 | contr->encumbrance += tmp->weight * 3 / 1000; |
1108 | } |
|
|
1109 | |
1058 | |
1110 | break; |
1059 | break; |
1111 | |
1060 | |
1112 | case ARMOUR: /* Only the best of these three are used: */ |
1061 | case ARMOUR: /* Only the best of these three are used: */ |
1113 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1062 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
… | |
… | |
1149 | break; |
1098 | break; |
1150 | } /* switch tmp->type */ |
1099 | } /* switch tmp->type */ |
1151 | } /* item is equipped */ |
1100 | } /* item is equipped */ |
1152 | } /* for loop of items */ |
1101 | } /* for loop of items */ |
1153 | |
1102 | |
1154 | glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); |
1103 | min_it (glow_radius, MAX_LIGHT_RADIUS); |
1155 | |
1104 | |
1156 | /* We've gone through all the objects the player has equipped. For many things, we |
1105 | /* We've gone through all the objects the player has equipped. For many things, we |
1157 | * have generated intermediate values which we now need to assign. |
1106 | * have generated intermediate values which we now need to assign. |
1158 | */ |
1107 | */ |
1159 | |
1108 | |
… | |
… | |
1165 | */ |
1114 | */ |
1166 | for (int i = 0; i < NROFATTACKS; i++) |
1115 | for (int i = 0; i < NROFATTACKS; i++) |
1167 | { |
1116 | { |
1168 | resist[i] = prot[i] - vuln[i]; |
1117 | resist[i] = prot[i] - vuln[i]; |
1169 | |
1118 | |
1170 | if (potion_resist[i] && ((potion_resist[i] > resist[i]) || (potion_resist[i] < 0))) |
1119 | if (potion_resist[i] != -1000 |
|
|
1120 | && (potion_resist[i] < 0 || potion_resist[i] > resist[i])) |
1171 | resist[i] = potion_resist[i]; |
1121 | resist[i] = potion_resist[i]; |
1172 | } |
1122 | } |
1173 | |
1123 | |
1174 | if (type == PLAYER) |
1124 | if (type == PLAYER) |
1175 | { |
1125 | { |
… | |
… | |
1575 | } |
1525 | } |
1576 | |
1526 | |
1577 | /* clear the flag - exp goes into this bucket, but player |
1527 | /* clear the flag - exp goes into this bucket, but player |
1578 | * still doesn't know it. |
1528 | * still doesn't know it. |
1579 | */ |
1529 | */ |
1580 | CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); |
1530 | skill_obj->clr_flag (FLAG_CAN_USE_SKILL); |
1581 | skill_obj->stats.exp = 0; |
1531 | skill_obj->stats.exp = 0; |
1582 | skill_obj->level = 1; |
1532 | skill_obj->level = 1; |
1583 | op->insert (skill_obj); |
1533 | op->insert (skill_obj); |
1584 | |
1534 | |
1585 | if (player *pl = op->contr) |
1535 | if (player *pl = op->contr) |
… | |
… | |
1898 | * worth. |
1848 | * worth. |
1899 | */ |
1849 | */ |
1900 | if (op->type != PLAYER) |
1850 | if (op->type != PLAYER) |
1901 | { |
1851 | { |
1902 | /* Sanity check */ |
1852 | /* Sanity check */ |
1903 | if (!QUERY_FLAG (op, FLAG_ALIVE)) |
1853 | if (!op->flag [FLAG_ALIVE]) |
1904 | return; |
1854 | return; |
1905 | |
1855 | |
1906 | /* reset exp to max allowed value. We subtract from |
1856 | /* reset exp to max allowed value. We subtract from |
1907 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1857 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1908 | * more than max exp, just return. |
1858 | * more than max exp, just return. |