… | |
… | |
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 | { |
… | |
… | |
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 | { |
… | |
… | |
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 | object *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 | |
… | |
… | |
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) |
… | |
… | |
900 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
878 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
901 | { |
879 | { |
902 | if (type == PLAYER) |
880 | if (type == PLAYER) |
903 | { |
881 | { |
904 | contr->item_power += tmp->item_power; |
882 | contr->item_power += tmp->item_power; |
905 | |
|
|
906 | if (tmp == contr->combat_ob || tmp == contr->ranged_ob) |
|
|
907 | if (tmp != current_weapon |
|
|
908 | && (tmp->type != SKILL || tmp->subtype != SK_PRAYING) |
|
|
909 | && !tmp->flag [FLAG_CURSED] |
|
|
910 | && !tmp->flag [FLAG_DAMNED]) |
|
|
911 | continue; |
|
|
912 | |
883 | |
913 | for (int i = 0; i < NUM_STATS; i++) |
884 | for (int i = 0; i < NUM_STATS; i++) |
914 | stat_sum [i] += tmp->stats.stat (i); |
885 | stat_sum [i] += tmp->stats.stat (i); |
915 | |
886 | |
916 | if (digest_types [tmp->type]) |
887 | if (digest_types [tmp->type]) |
… | |
… | |
928 | if (tmp->type == WEAPON) |
899 | if (tmp->type == WEAPON) |
929 | current_weapon = tmp; |
900 | current_weapon = tmp; |
930 | } |
901 | } |
931 | |
902 | |
932 | /* Update slots used for items */ |
903 | /* Update slots used for items */ |
933 | if (tmp->flag [FLAG_APPLIED]) |
904 | if (tmp->flag [FLAG_APPLIED]) // exclude praying... |
934 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
905 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
935 | slot[i].used += tmp->slot[i].info; |
906 | slot[i].used += tmp->slot[i].info; |
936 | |
907 | |
937 | if (tmp->type == SYMPTOM) |
908 | if (tmp->type == SYMPTOM) |
938 | min_it (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); |
… | |
… | |
966 | flag |= tmp->flag & copy_flags; |
937 | flag |= tmp->flag & copy_flags; |
967 | |
938 | |
968 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
939 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
969 | SET_FLAG (this, FLAG_UNDEAD); |
940 | SET_FLAG (this, FLAG_UNDEAD); |
970 | |
941 | |
|
|
942 | //TODO: copy_flags? |
971 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
943 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
972 | { |
944 | { |
973 | SET_FLAG (this, FLAG_MAKE_INVIS); |
945 | SET_FLAG (this, FLAG_MAKE_INVIS); |
974 | invisible = 1; |
946 | invisible = 1; |
975 | } |
947 | } |
… | |
… | |
985 | added_speed += tmp->stats.exp; |
957 | added_speed += tmp->stats.exp; |
986 | } |
958 | } |
987 | |
959 | |
988 | switch (tmp->type) |
960 | switch (tmp->type) |
989 | { |
961 | { |
990 | /* skills modifying the character -b.t. */ |
|
|
991 | /* for all skills and skill granting objects */ |
|
|
992 | case SKILL: |
962 | case SKILL: |
993 | { |
963 | { |
|
|
964 | // some skills will end up here without counting as "applied" |
994 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) |
965 | if (!tmp->flag [FLAG_APPLIED] || skill_flags [tmp->subtype] & SF_AUTARK) |
995 | break; |
966 | break; |
996 | |
967 | |
997 | if (chosen_skill) |
968 | if (chosen_skill) |
998 | { |
969 | { |
999 | 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", |
… | |
… | |
1001 | |
972 | |
1002 | tmp->flag [FLAG_APPLIED] = false; |
973 | tmp->flag [FLAG_APPLIED] = false; |
1003 | update_stats (); |
974 | update_stats (); |
1004 | return; |
975 | return; |
1005 | } |
976 | } |
1006 | else |
977 | |
1007 | chosen_skill = tmp; |
978 | chosen_skill = tmp; |
1008 | |
979 | |
1009 | if (tmp->stats.dam > 0) |
980 | if (tmp->stats.dam > 0) |
1010 | { /* skill is a 'weapon' */ |
981 | { /* skill is a 'weapon' */ |
1011 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
982 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
1012 | weapon_speed = WEAPON_SPEED (tmp); |
983 | weapon_speed = max (0, WEAPON_SPEED (tmp)); |
1013 | |
|
|
1014 | if (weapon_speed < 0) |
|
|
1015 | weapon_speed = 0; |
|
|
1016 | |
984 | |
1017 | weapon_weight = tmp->weight; |
985 | weapon_weight = tmp->weight; |
1018 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
986 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
1019 | |
987 | |
1020 | if (tmp->magic) |
988 | if (tmp->magic) |
… | |
… | |
1059 | break; |
1027 | break; |
1060 | |
1028 | |
1061 | case WAND: |
1029 | case WAND: |
1062 | case ROD: |
1030 | case ROD: |
1063 | case HORN: |
1031 | case HORN: |
1064 | case SKILL_TOOL: |
|
|
1065 | if (type != PLAYER) |
|
|
1066 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1067 | break; |
1032 | break; |
1068 | |
1033 | |
1069 | case BOW: |
1034 | case BOW: |
1070 | case WEAPON: |
1035 | case WEAPON: |
1071 | if (type != PLAYER || current_weapon == tmp) |
|
|
1072 | { |
|
|
1073 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1074 | |
|
|
1075 | wc -= tmp->stats.wc + tmp->magic; |
1036 | wc -= tmp->stats.wc + tmp->magic; |
1076 | |
1037 | |
1077 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1038 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1078 | ac -= tmp->stats.ac + tmp->magic; |
1039 | ac -= tmp->stats.ac + tmp->magic; |
1079 | |
1040 | |
1080 | stats.dam += tmp->stats.dam + tmp->magic; |
1041 | stats.dam += tmp->stats.dam + tmp->magic; |
1081 | weapon_weight = tmp->weight; |
1042 | weapon_weight = tmp->weight; |
1082 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1043 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1083 | |
1044 | |
1084 | if (weapon_speed < 0) |
1045 | if (weapon_speed < 0) |
1085 | weapon_speed = 0; |
1046 | weapon_speed = 0; |
1086 | |
1047 | |
1087 | slaying = tmp->slaying; |
1048 | slaying = tmp->slaying; |
1088 | |
1049 | |
1089 | /* If there is desire that two handed weapons should do |
1050 | /* If there is desire that two handed weapons should do |
1090 | * extra strength damage, this is where the code should |
1051 | * extra strength damage, this is where the code should |
1091 | * go. |
1052 | * go. |
1092 | */ |
1053 | */ |
1093 | |
1054 | |
1094 | if (type == PLAYER) |
1055 | if (type == PLAYER) |
1095 | if (settings.spell_encumbrance) |
1056 | if (settings.spell_encumbrance) |
1096 | contr->encumbrance += tmp->weight * 3 / 1000; |
1057 | contr->encumbrance += tmp->weight * 3 / 1000; |
1097 | } |
|
|
1098 | |
1058 | |
1099 | break; |
1059 | break; |
1100 | |
1060 | |
1101 | case ARMOUR: /* Only the best of these three are used: */ |
1061 | case ARMOUR: /* Only the best of these three are used: */ |
1102 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1062 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
… | |
… | |
1137 | |
1097 | |
1138 | break; |
1098 | break; |
1139 | } /* switch tmp->type */ |
1099 | } /* switch tmp->type */ |
1140 | } /* item is equipped */ |
1100 | } /* item is equipped */ |
1141 | } /* for loop of items */ |
1101 | } /* for loop of items */ |
1142 | |
|
|
1143 | if (type != PLAYER) |
|
|
1144 | this->chosen_skill = chosen_skill; |
|
|
1145 | |
1102 | |
1146 | min_it (glow_radius, MAX_LIGHT_RADIUS); |
1103 | min_it (glow_radius, MAX_LIGHT_RADIUS); |
1147 | |
1104 | |
1148 | /* 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 |
1149 | * have generated intermediate values which we now need to assign. |
1106 | * have generated intermediate values which we now need to assign. |