Mercurial > mm7
comparison Player.cpp @ 1736:c6fe09a06712
Player::CompareVariable finished, renamed stru_5E4C90 to stru_5E4C90_MapPersistVars, party::field_4A0 to party::CounterEventValues
author | Grumpy7 |
---|---|
date | Fri, 27 Sep 2013 10:04:45 +0200 |
parents | 34dd357a489d |
children | ef86fc6d6a80 |
comparison
equal
deleted
inserted
replaced
1732:e8d477b48596 | 1736:c6fe09a06712 |
---|---|
22 #include "StorylineTextTable.h" | 22 #include "StorylineTextTable.h" |
23 #include "Autonotes.h" | 23 #include "Autonotes.h" |
24 #include "Awards.h" | 24 #include "Awards.h" |
25 #include "texts.h" | 25 #include "texts.h" |
26 | 26 |
27 #include "stru123.h" | |
27 #include "mm7_data.h" | 28 #include "mm7_data.h" |
28 #include "MM7.h" | 29 #include "MM7.h" |
29 #include "SpriteObject.h" | 30 #include "SpriteObject.h" |
30 #include "DecalBuilder.h" | 31 #include "DecalBuilder.h" |
31 | 32 |
1686 | 1687 |
1687 | 1688 |
1688 //----- (0048D0B9) -------------------------------------------------------- | 1689 //----- (0048D0B9) -------------------------------------------------------- |
1689 int Player::GetRangedAttack() | 1690 int Player::GetRangedAttack() |
1690 { | 1691 { |
1691 int v2; // eax@1 | |
1692 int v3; // edi@3 | 1692 int v3; // edi@3 |
1693 int v4; // eax@4 | 1693 int v4; // eax@4 |
1694 int v5; // edi@4 | 1694 int v5; // edi@4 |
1695 int v6; // edi@4 | 1695 int v6; // edi@4 |
1696 int v7; // edi@4 | 1696 int v7; // edi@4 |
4983 pMouse->RemoveHoldingItem(); | 4983 pMouse->RemoveHoldingItem(); |
4984 return; | 4984 return; |
4985 } | 4985 } |
4986 } | 4986 } |
4987 | 4987 |
4988 | |
4989 bool CmpSkillValue(int valToCompare, int skillValue) | |
4990 { | |
4991 int v4; | |
4992 if ( valToCompare <= 63 ) | |
4993 v4 = skillValue & 0x3F; | |
4994 else | |
4995 v4 = valToCompare & skillValue; | |
4996 return v4 >= valToCompare; | |
4997 } | |
4998 | |
4988 //----- (00449BB4) -------------------------------------------------------- | 4999 //----- (00449BB4) -------------------------------------------------------- |
4989 bool Player::CompareVariable( enum VariableType VarNum, signed int pValue ) // in some cases this calls only calls v4 >= pValue, which i've changed to return false, since these values are supposed to be positive | 5000 bool Player::CompareVariable( enum VariableType VarNum, signed int pValue ) // in some cases this calls only calls v4 >= pValue, which i've changed to return false, since these values are supposed to be positive and v4 was -1 by default |
4990 { | 5001 { |
4991 Assert(pValue >= 0, "Compare variable shouldn't have negative arguments"); | 5002 Assert(pValue >= 0, "Compare variable shouldn't have negative arguments"); |
4992 | 5003 |
4993 signed int v4; // edi@1 | 5004 signed int v4; // edi@1 |
4994 unsigned int v5; // eax@8 | 5005 unsigned __int8 test_bit_value; // eax@25 |
4995 int v6; // eax@9 | |
4996 enum CHARACTER_RACE v7; // eax@11 | |
4997 signed int v8; // eax@17 | |
4998 unsigned __int8 v9; // sf@17 | |
4999 unsigned __int8 v10; // of@17 | |
5000 int v11; // eax@19 | |
5001 unsigned int v12; // eax@20 | |
5002 unsigned int test_bit_value; // eax@25 | |
5003 unsigned __int8 byteWithRequestedBit; // cl@25 | 5006 unsigned __int8 byteWithRequestedBit; // cl@25 |
5004 signed int v15; // ecx@28 | |
5005 ItemGen *v16; // eax@28 | |
5006 int v18; // edi@90 | |
5007 DDM_DLV_Header *v19; // eax@122 | 5007 DDM_DLV_Header *v19; // eax@122 |
5008 DDM_DLV_Header *v21; // eax@126 | 5008 DDM_DLV_Header *v21; // eax@126 |
5009 unsigned int v22; // edi@129 | 5009 int actStat; // ebx@161 |
5010 Player *v23; // esi@134 | 5010 int baseStat; // eax@161 |
5011 ItemGen *v24; // ecx@135 | 5011 |
5012 signed int v25; // edx@135 | |
5013 ITEM_EQUIP_TYPE v26; // ebx@155 | |
5014 char *v27; // edi@155 | |
5015 int v28; // ebx@161 | |
5016 int v29; // eax@161 | |
5017 | |
5018 v6 = 0; | |
5019 v4 = -1; | |
5020 if ( VarNum > VAR_AutoNotes ) | 5012 if ( VarNum > VAR_AutoNotes ) |
5021 { | 5013 { |
5022 switch ( VarNum ) | 5014 switch ( VarNum ) |
5023 { | 5015 { |
5024 case VAR_Invisible: | 5016 case VAR_AutoNotes : //TODO: find out why the double subtraction. or whether this is even used |
5025 if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime >0 ) | 5017 test_bit_value = 0x80u >> (pValue - 2) % 8; |
5018 byteWithRequestedBit = pParty->_autonote_bits[(pValue - 2) /8]; | |
5019 return (test_bit_value & byteWithRequestedBit) != 0; | |
5020 case VAR_IsMightMoreThanBase: | |
5021 actStat = GetActualMight(); | |
5022 baseStat = GetBaseStrength(); | |
5023 return (actStat >= baseStat); | |
5024 case VAR_IsIntellectMoreThanBase: | |
5025 actStat = GetActualIntelligence(); | |
5026 baseStat = GetBaseIntelligence(); | |
5027 return (actStat >= baseStat); | |
5028 case VAR_IsPersonalityMoreThanBase: | |
5029 actStat = GetActualWillpower(); | |
5030 baseStat = GetBaseWillpower(); | |
5031 return (actStat >= baseStat); | |
5032 case VAR_IsEnduranceMoreThanBase: | |
5033 actStat = GetActualEndurance(); | |
5034 baseStat = GetBaseEndurance(); | |
5035 return (actStat >= baseStat); | |
5036 case VAR_IsSpeedMoreThanBase: | |
5037 actStat = GetActualSpeed(); | |
5038 baseStat = GetBaseSpeed(); | |
5039 return (actStat >= baseStat); | |
5040 case VAR_IsAccuracyMoreThanBase: | |
5041 actStat = GetActualAccuracy(); | |
5042 baseStat = GetBaseAccuracy(); | |
5043 return (actStat >= baseStat); | |
5044 case VAR_IsLuckMoreThanBase: | |
5045 actStat = GetActualLuck(); | |
5046 baseStat = GetBaseLuck(); | |
5047 return (actStat >= baseStat); | |
5048 case VAR_PlayerBits: | |
5049 test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; | |
5050 byteWithRequestedBit = this->field_1A50[((signed __int16)pValue - 1)/8]; | |
5051 return ( test_bit_value & byteWithRequestedBit ) != 0; | |
5052 case VAR_NPCs2: | |
5053 return pNPCStats->pNewNPCData[pValue].Hired(); | |
5054 case VAR_IsFlying: | |
5055 if ( pParty->bFlying | |
5056 && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) ) | |
5026 return true; | 5057 return true; |
5027 return false; | 5058 return false; |
5028 case VAR_NumDeaths: | 5059 case VAR_HiredNPCHasSpeciality: |
5029 v4 = pParty->uNumDeaths; | 5060 return CheckHiredNPCSpeciality(pValue); |
5030 return v4 >= pValue; | |
5031 case VAR_NumBounties: | |
5032 v4 = pParty->uNumBountiesCollected; | |
5033 return v4 >= pValue; | |
5034 case VAR_PrisonTerms: | |
5035 v4 = pParty->uNumPrisonTerms; | |
5036 return v4 >= pValue; | |
5037 case VAR_ArenaWinsPage: | |
5038 v4 = (unsigned __int8)pParty->uNumArenaPageWins; | |
5039 return v4 >= pValue; | |
5040 case VAR_ArenaWinsSquire: | |
5041 v4 = (unsigned __int8)pParty->uNumArenaSquireWins; | |
5042 return v4 >= pValue; | |
5043 case VAR_ArenaWinsKnight: | |
5044 v4 = (unsigned __int8)pParty->uNumArenaKnightWins; | |
5045 return v4 >= pValue; | |
5046 case VAR_ArenaWinsLord: | |
5047 v4 = (unsigned __int8)pParty->uNumArenaLordWins; | |
5048 return v4 >= pValue; | |
5049 case VAR_ReputationInCurrentLocation: | |
5050 v19 = &pOutdoor->ddm; | |
5051 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
5052 v19 = &pIndoor->dlv; | |
5053 v6 = v19->uReputation >= pValue; | |
5054 return v6; | |
5055 case VAR_Unknown1: | |
5056 v21 = &pOutdoor->ddm; | |
5057 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
5058 v21 = &pIndoor->dlv; | |
5059 v6 = v21->field_C_alert == pValue; | |
5060 return v6; | |
5061 case VAR_Counter1: | |
5062 case VAR_Counter2: | |
5063 case VAR_Counter3: | |
5064 case VAR_Counter4: | |
5065 case VAR_Counter5: | |
5066 case VAR_Counter6: | |
5067 case VAR_Counter7: | |
5068 case VAR_Counter8: | |
5069 case VAR_Counter9: | |
5070 case VAR_Counter10: | |
5071 v22 = *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44304]; | |
5072 if ( v22 | *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44300] | |
5073 && (signed __int64)(__PAIR__(v22, *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44300]) | |
5074 + (signed __int64)((double)(460800 * pValue) * 0.033333335)) <= (signed __int64)pParty->uTimePlayed ) | |
5075 return true; | |
5076 return false; | |
5077 case VAR_NumSkillPoints: | |
5078 v4 = this->uSkillPoints; | |
5079 return v4 >= pValue; | |
5080 case VAR_CircusPrises: //isn't used in MM6 since 0x1D6u is a book of regeneration | 5061 case VAR_CircusPrises: //isn't used in MM6 since 0x1D6u is a book of regeneration |
5081 v4 = 0; | 5062 v4 = 0; |
5082 for (int playerNum = 0; playerNum < 4; playerNum++) | 5063 for (int playerNum = 0; playerNum < 4; playerNum++) |
5083 { | 5064 { |
5084 for (int invPos = 0; invPos < 138; invPos++) | 5065 for (int invPos = 0; invPos < 138; invPos++) |
5097 break; | 5078 break; |
5098 } | 5079 } |
5099 } | 5080 } |
5100 } | 5081 } |
5101 return v4 >= pValue; | 5082 return v4 >= pValue; |
5083 case VAR_NumSkillPoints: | |
5084 return this->uSkillPoints >= (unsigned int)pValue; | |
5102 case VAR_MonthIs: | 5085 case VAR_MonthIs: |
5103 v6 = pParty->uCurrentMonth == pValue; | 5086 return (pParty->uCurrentMonth == (unsigned int)pValue); |
5104 return v6; | 5087 case VAR_Counter1: |
5105 case VAR_IsFlying: | 5088 case VAR_Counter2: |
5106 if ( pParty->bFlying | 5089 case VAR_Counter3: |
5107 && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) ) | 5090 case VAR_Counter4: |
5108 return true; | 5091 case VAR_Counter5: |
5109 return false; | 5092 case VAR_Counter6: |
5110 case VAR_HiredNPCHasSpeciality: | 5093 case VAR_Counter7: |
5111 return CheckHiredNPCSpeciality(pValue); | 5094 case VAR_Counter8: |
5112 case VAR_NPCs2: | 5095 case VAR_Counter9: |
5113 return pNPCStats->pNewNPCData[pValue].Hired(); | 5096 case VAR_Counter10: |
5114 case VAR_PlayerBits: | 5097 if (pParty->field_3C.CounterEventValues[VarNum - VAR_Counter1]) |
5115 test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; | 5098 { |
5116 byteWithRequestedBit = this->field_1A50[((signed __int16)pValue - 1)/8]; | 5099 return (pParty->field_3C.CounterEventValues[VarNum - VAR_Counter1] + 460800 * pValue * 0.033333335) <= pParty->uTimePlayed ; |
5117 if ( !((unsigned __int8)test_bit_value & byteWithRequestedBit) ) | 5100 } |
5118 return v4 >= pValue; | 5101 case VAR_ReputationInCurrentLocation: |
5119 v4 = pValue; | 5102 v19 = &pOutdoor->ddm; |
5120 return v4 >= pValue; | 5103 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) |
5104 v19 = &pIndoor->dlv; | |
5105 return (v19->uReputation >= pValue); | |
5106 case VAR_Unknown1: | |
5107 v21 = &pOutdoor->ddm; | |
5108 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
5109 v21 = &pIndoor->dlv; | |
5110 return (v21->field_C_alert == pValue); //yes, equality, not >= | |
5111 case VAR_GoldInBank: | |
5112 return pParty->uNumGoldInBank >= (unsigned int)pValue; | |
5113 case VAR_NumDeaths: | |
5114 return pParty->uNumDeaths >= (unsigned int)pValue; | |
5115 case VAR_NumBounties: | |
5116 return pParty->uNumBountiesCollected >= (unsigned int)pValue; | |
5117 case VAR_PrisonTerms: | |
5118 return pParty->uNumPrisonTerms >= pValue; | |
5119 case VAR_ArenaWinsPage: | |
5120 return (unsigned __int8)pParty->uNumArenaPageWins >= pValue; | |
5121 case VAR_ArenaWinsSquire: | |
5122 return (unsigned __int8)pParty->uNumArenaSquireWins >= pValue; | |
5123 case VAR_ArenaWinsKnight: | |
5124 return (unsigned __int8)pParty->uNumArenaKnightWins >= pValue; | |
5125 case VAR_ArenaWinsLord: | |
5126 return pParty->uNumArenaLordWins >= pValue; | |
5127 case VAR_Invisible: | |
5128 return ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ); | |
5121 case VAR_ItemEquipped: | 5129 case VAR_ItemEquipped: |
5122 for (int i = 0; i < 16; i++) | 5130 for (int i = 0; i < 16; i++) |
5123 { | 5131 { |
5124 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uItemID == pValue ) | 5132 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uItemID == pValue ) |
5125 { | 5133 { |
5126 return true; | 5134 return true; |
5127 } | 5135 } |
5128 } | 5136 } |
5129 return false; | 5137 return false; |
5130 case VAR_GoldInBank: | |
5131 v4 = pParty->uNumGoldInBank; | |
5132 return v4 >= pValue; | |
5133 case VAR_IsMightMoreThanBase: | |
5134 v28 = GetActualMight(); | |
5135 v29 = GetBaseStrength(); | |
5136 return (v28 >= v29); | |
5137 case VAR_IsIntellectMoreThanBase: | |
5138 v28 = GetActualIntelligence(); | |
5139 v29 = GetBaseIntelligence(); | |
5140 return (v28 >= v29); | |
5141 case VAR_IsPersonalityMoreThanBase: | |
5142 v28 = GetActualWillpower(); | |
5143 v29 = GetBaseWillpower(); | |
5144 return (v28 >= v29); | |
5145 case VAR_IsEnduranceMoreThanBase: | |
5146 v28 = GetActualEndurance(); | |
5147 v29 = GetBaseEndurance(); | |
5148 return (v28 >= v29); | |
5149 case VAR_IsSpeedMoreThanBase: | |
5150 v28 = GetActualSpeed(); | |
5151 v29 = GetBaseSpeed(); | |
5152 return (v28 >= v29); | |
5153 case VAR_IsAccuracyMoreThanBase: | |
5154 v28 = GetActualAccuracy(); | |
5155 v29 = GetBaseAccuracy(); | |
5156 return (v28 >= v29); | |
5157 case VAR_IsLuckMoreThanBase: | |
5158 v28 = GetActualLuck(); | |
5159 v29 = GetBaseLuck(); | |
5160 return (v28 >= v29); | |
5161 default: | 5138 default: |
5162 return false; | 5139 return false; |
5163 } | 5140 } |
5164 } | 5141 } |
5165 if ( VarNum == VAR_AutoNotes ) //TODO: find out why the double subtraction. or whether this is even used | 5142 if ( VarNum <= VAR_MajorCondition ) |
5166 { | 5143 { |
5167 test_bit_value = 0x80u >> (pValue - 2) % 8; | 5144 switch ( VarNum ) |
5168 byteWithRequestedBit = pParty->_autonote_bits[(pValue - 2) /8]; | 5145 { |
5169 return (test_bit_value & byteWithRequestedBit); | 5146 case VAR_Sex: |
5170 } | 5147 return ( pValue == this->uSex ); |
5171 if ( VarNum <= VAR_BaseLuck ) | 5148 case VAR_Class: |
5172 { | 5149 return ( pValue == this->classType ); |
5173 if ( VarNum != VAR_BaseLuck ) | 5150 case VAR_Race: |
5174 { | 5151 return pValue == GetRace(); |
5175 switch ( VarNum ) | 5152 case VAR_CurrentHP: |
5176 { | 5153 return this->sHealth >= pValue; |
5177 case VAR_Hour: | 5154 case VAR_MaxHP: |
5178 if ( (long long)(pParty->uTimePlayed * 0.234375) / 60 / 60 % 24 == pValue ) | 5155 return (this->sHealth >= GetMaxHealth()); |
5179 return true; | 5156 case VAR_CurrentSP: |
5180 return false; | 5157 return this->sMana >= pValue; |
5181 case VAR_DayOfYear: | 5158 case VAR_MaxSP: |
5182 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 336 + 1 == pValue) | 5159 return (this->sMana >= GetMaxMana()); |
5183 return true; | 5160 case VAR_ActualAC: |
5184 return false; | 5161 return GetActualAC() >= pValue; |
5185 case VAR_DayOfWeek: | 5162 case VAR_ACModifier: |
5186 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 7) | 5163 return this->sACModifier >= pValue; |
5187 return true; | 5164 case VAR_BaseLevel: |
5188 return false; | 5165 return this->uLevel >= pValue; |
5189 case VAR_Sex: | 5166 case VAR_LevelModifier: |
5190 if ( pValue == this->uSex ) | 5167 return this->sLevelModifier >= pValue; |
5191 return true; | 5168 case VAR_Age: |
5192 return false; | 5169 return GetActualAge() >= (unsigned int)pValue; |
5193 case VAR_Class: | 5170 case VAR_Award: |
5194 if ( pValue == this->classType ) | 5171 test_bit_value = 0x80u >> (pValue - 1) % 8; |
5195 return true; | 5172 byteWithRequestedBit = this->_achieved_awards_bits[(pValue - 1) /8]; |
5196 return false; | 5173 return ( test_bit_value & byteWithRequestedBit ) != 0; |
5197 case VAR_Race: | 5174 case VAR_Experience: |
5198 if ( pValue == GetRace() ) | 5175 return this->uExperience >= pValue; //TODO change pValue to long long |
5199 return true; | 5176 case VAR_QBits_QuestsDone: |
5200 return v4 >= pValue; | 5177 test_bit_value = 0x80u >> (pValue - 1) % 8; |
5201 case VAR_CurrentHP: | 5178 byteWithRequestedBit = pParty->_quest_bits[(pValue - 1)/8]; |
5202 v4 = this->sHealth; | 5179 return ( test_bit_value & byteWithRequestedBit ) != 0; |
5203 return v4 >= pValue; | 5180 case VAR_PlayerItemInHands: |
5204 case VAR_MaxHP: | 5181 for (int i = 0; i < 138; i++) |
5205 v8 = GetMaxHealth(); | 5182 { |
5206 v9 = this->sHealth; | 5183 if (pInventoryItemList[i].uItemID == pValue) |
5207 return (v9 >= v8); | |
5208 case VAR_CurrentSP: | |
5209 v4 = this->sMana; | |
5210 return v4 >= pValue; | |
5211 case VAR_MaxSP: | |
5212 v8 = GetMaxMana(); | |
5213 v9 = this->sMana; | |
5214 return (v9 >= v8); | |
5215 case VAR_ActualAC: | |
5216 v4 = GetActualAC(); | |
5217 return v4 >= pValue; | |
5218 case VAR_ACModifier: | |
5219 v4 = this->sACModifier; | |
5220 return v4 >= pValue; | |
5221 case VAR_BaseLevel: | |
5222 v4 = this->uLevel; | |
5223 return v4 >= pValue; | |
5224 case VAR_LevelModifier: | |
5225 v4 = this->sLevelModifier; | |
5226 return v4 >= pValue; | |
5227 case VAR_Age: | |
5228 v4 = GetActualAge(); | |
5229 return v4 >= pValue; | |
5230 case VAR_Award: | |
5231 test_bit_value = 0x80u >> (pValue - 1) % 8; | |
5232 byteWithRequestedBit = this->_achieved_awards_bits[(pValue - 1) /8]; | |
5233 return ( test_bit_value & byteWithRequestedBit ); | |
5234 case VAR_Experience: | |
5235 v4 = LODWORD(this->uExperience); | |
5236 return v4 >= pValue; | |
5237 case VAR_QBits_QuestsDone: | |
5238 test_bit_value = 0x80u >> (pValue - 1) % 8; | |
5239 byteWithRequestedBit = pParty->_quest_bits[(pValue - 1)/8]; | |
5240 return ( test_bit_value & byteWithRequestedBit ); | |
5241 case VAR_PlayerItemInHands: | |
5242 for (int i = 0; i < 138; i++) | |
5243 { | |
5244 if (pInventoryItemList[i].uItemID == pValue) | |
5245 { | |
5246 return true; | |
5247 } | |
5248 } | |
5249 return pParty->pPickedItem.uItemID == pValue; | |
5250 case VAR_FixedGold: | |
5251 v4 = pParty->uNumGold; | |
5252 return v4 >= pValue; | |
5253 case VAR_MightBonus: | |
5254 v4 = this->uMightBonus; | |
5255 return v4 >= pValue; | |
5256 case VAR_IntellectBonus: | |
5257 v4 = this->uIntelligenceBonus; | |
5258 return v4 >= pValue; | |
5259 case VAR_PersonalityBonus: | |
5260 v4 = this->uWillpowerBonus; | |
5261 return v4 >= pValue; | |
5262 case VAR_EnduranceBonus: | |
5263 v4 = this->uEnduranceBonus; | |
5264 return v4 >= pValue; | |
5265 case VAR_SpeedBonus: | |
5266 v4 = this->uSpeedBonus; | |
5267 return v4 >= pValue; | |
5268 case VAR_AccuracyBonus: | |
5269 v4 = this->uAccuracyBonus; | |
5270 return v4 >= pValue; | |
5271 case VAR_LuckBonus: | |
5272 v4 = this->uLuckBonus; | |
5273 return v4 >= pValue; | |
5274 case VAR_BaseMight: | |
5275 v4 = this->uMight; | |
5276 return v4 >= pValue; | |
5277 case VAR_BaseIntellect: | |
5278 v4 = this->uIntelligence; | |
5279 return v4 >= pValue; | |
5280 case VAR_BasePersonality: | |
5281 v4 = this->uWillpower; | |
5282 return v4 >= pValue; | |
5283 case VAR_BaseEndurance: | |
5284 v4 = this->uEndurance; | |
5285 return v4 >= pValue; | |
5286 case VAR_BaseSpeed: | |
5287 v4 = this->uSpeed; | |
5288 return v4 >= pValue; | |
5289 case VAR_BaseAccuracy: | |
5290 v4 = this->uAccuracy; | |
5291 return v4 >= pValue; | |
5292 case VAR_FixedFood: | |
5293 v4 = pParty->uNumFoodRations; | |
5294 return v4 >= pValue; | |
5295 default: | |
5296 return false; | |
5297 } | |
5298 } | |
5299 v4 = this->uLuck; | |
5300 return v4 >= pValue; | |
5301 } | |
5302 if ( VarNum <= VAR_MagicResistance ) | |
5303 { | |
5304 if ( VarNum == VAR_MagicResistance ) | |
5305 { | |
5306 v4 = this->sResMagicBase; | |
5307 } | |
5308 else | |
5309 { | |
5310 switch ( VarNum ) | |
5311 { | |
5312 case VAR_FireResistance: | |
5313 v4 = this->sResFireBase; | |
5314 return v4 >= pValue; | |
5315 case VAR_AirResistance: | |
5316 v4 = this->sResAirBase; | |
5317 return v4 >= pValue; | |
5318 case VAR_WaterResistance: | |
5319 v4 = this->sResWaterBase; | |
5320 return v4 >= pValue; | |
5321 case VAR_EarthResistance: | |
5322 v4 = this->sResEarthBase; | |
5323 return v4 >= pValue; | |
5324 case VAR_SpiritResistance: | |
5325 v4 = this->sResSpiritBase; | |
5326 return v4 >= pValue; | |
5327 case VAR_MindResistance: | |
5328 v4 = this->sResMindBase; | |
5329 return v4 >= pValue; | |
5330 case VAR_BodyResistance: | |
5331 v4 = this->sResBodyBase; | |
5332 return v4 >= pValue; | |
5333 case VAR_LightResistance: | |
5334 v4 = this->sResLightBase; | |
5335 return v4 >= pValue; | |
5336 case VAR_DarkResistance: | |
5337 v4 = this->sResDarkBase; | |
5338 return v4 >= pValue; | |
5339 case VAR_ActualMight: | |
5340 v4 = GetActualMight(); | |
5341 return v4 >= pValue; | |
5342 case VAR_ActualIntellect: | |
5343 v4 = GetActualIntelligence(); | |
5344 return v4 >= pValue; | |
5345 case VAR_ActualPersonality: | |
5346 v4 = GetActualWillpower(); | |
5347 return v4 >= pValue; | |
5348 case VAR_ActualEndurance: | |
5349 v4 = GetActualEndurance(); | |
5350 return v4 >= pValue; | |
5351 case VAR_ActualSpeed: | |
5352 v4 = GetActualSpeed(); | |
5353 return v4 >= pValue; | |
5354 case VAR_ActualAccuracy: | |
5355 v4 = GetActualAccuracy(); | |
5356 return v4 >= pValue; | |
5357 case VAR_ActualLuck: | |
5358 v4 = GetActualLuck(); | |
5359 return v4 >= pValue; | |
5360 break; | |
5361 default: | |
5362 return v4 >= pValue; | |
5363 } | |
5364 } | |
5365 return v4 >= pValue; | |
5366 } | |
5367 if ( VarNum <= VAR_DisarmTrapSkill ) | |
5368 { | |
5369 if ( VarNum != VAR_DisarmTrapSkill ) | |
5370 { | |
5371 if ( VarNum <= VAR_MindResistanceBonus ) | |
5372 { | |
5373 switch ( VarNum ) | |
5374 { | 5184 { |
5375 case VAR_MindResistanceBonus: | 5185 return true; |
5376 v4 = this->sResMindBonus; | |
5377 return v4 >= pValue; | |
5378 case VAR_FireResistanceBonus: | |
5379 v4 = this->sResFireBonus; | |
5380 return v4 >= pValue; | |
5381 case VAR_AirResistanceBonus: | |
5382 v4 = this->sResAirBonus; | |
5383 return v4 >= pValue; | |
5384 case VAR_WaterResistanceBonus: | |
5385 v4 = this->sResWaterBonus; | |
5386 return v4 >= pValue; | |
5387 case VAR_EarthResistanceBonus: | |
5388 v4 = this->sResEarthBonus; | |
5389 return v4 >= pValue; | |
5390 case VAR_SpiritResistanceBonus: | |
5391 v4 = this->sResSpiritBonus; | |
5392 return v4 >= pValue; | |
5393 } | 5186 } |
5394 } | 5187 } |
5395 if ( VarNum == VAR_BodyResistanceBonus ) | 5188 return pParty->pPickedItem.uItemID == pValue; |
5396 { | 5189 case VAR_Hour: |
5397 v4 = this->sResBodyBonus; | 5190 if ( (long long)(pParty->uTimePlayed * 0.234375) / 60 / 60 % 24 == pValue ) |
5191 return true; | |
5192 return false; | |
5193 case VAR_DayOfYear: | |
5194 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 336 + 1 == pValue) | |
5195 return true; | |
5196 return false; | |
5197 case VAR_DayOfWeek: | |
5198 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 7) | |
5199 return true; | |
5200 return false; | |
5201 case VAR_FixedGold: | |
5202 return pParty->uNumGold >= (unsigned int)pValue; | |
5203 case VAR_FixedFood: | |
5204 return pParty->uNumFoodRations >= (unsigned int)pValue; | |
5205 case VAR_MightBonus: | |
5206 return this->uMightBonus >= pValue; | |
5207 case VAR_IntellectBonus: | |
5208 return this->uIntelligenceBonus >= pValue; | |
5209 case VAR_PersonalityBonus: | |
5210 return this->uWillpowerBonus >= pValue; | |
5211 case VAR_EnduranceBonus: | |
5212 return this->uEnduranceBonus >= pValue; | |
5213 case VAR_SpeedBonus: | |
5214 return this->uSpeedBonus >= pValue; | |
5215 case VAR_AccuracyBonus: | |
5216 return this->uAccuracyBonus >= pValue; | |
5217 case VAR_LuckBonus: | |
5218 return this->uLuckBonus >= pValue; | |
5219 case VAR_BaseMight: | |
5220 return this->uMight >= pValue; | |
5221 case VAR_BaseIntellect: | |
5222 return this->uIntelligence >= pValue; | |
5223 case VAR_BasePersonality: | |
5224 return this->uWillpower >= pValue; | |
5225 case VAR_BaseEndurance: | |
5226 return this->uEndurance >= pValue; | |
5227 case VAR_BaseSpeed: | |
5228 return this->uSpeed >= pValue; | |
5229 case VAR_BaseAccuracy: | |
5230 return this->uAccuracy >= pValue; | |
5231 case VAR_BaseLuck: | |
5232 return this->uLuck >= pValue; | |
5233 case VAR_ActualMight: | |
5234 return GetActualMight() >= pValue; | |
5235 case VAR_ActualIntellect: | |
5236 return GetActualIntelligence() >= pValue; | |
5237 case VAR_ActualPersonality: | |
5238 return GetActualWillpower() >= pValue; | |
5239 case VAR_ActualEndurance: | |
5240 return GetActualEndurance() >= pValue; | |
5241 case VAR_ActualSpeed: | |
5242 return GetActualSpeed() >= pValue; | |
5243 case VAR_ActualAccuracy: | |
5244 return GetActualAccuracy() >= pValue; | |
5245 case VAR_ActualLuck: | |
5246 return GetActualLuck() >= pValue; | |
5247 case VAR_FireResistance: | |
5248 return this->sResFireBase >= pValue; | |
5249 case VAR_AirResistance: | |
5250 return this->sResAirBase >= pValue; | |
5251 case VAR_WaterResistance: | |
5252 return this->sResWaterBase >= pValue; | |
5253 case VAR_EarthResistance: | |
5254 return this->sResEarthBase >= pValue; | |
5255 case VAR_SpiritResistance: | |
5256 return this->sResSpiritBase >= pValue; | |
5257 case VAR_MindResistance: | |
5258 return this->sResMindBase >= pValue; | |
5259 case VAR_BodyResistance: | |
5260 return this->sResBodyBase >= pValue; | |
5261 case VAR_LightResistance: | |
5262 return this->sResLightBase >= pValue; | |
5263 case VAR_DarkResistance: | |
5264 return this->sResDarkBase >= pValue; | |
5265 case VAR_PhysicalResistance: | |
5266 Error("Physical resistance isn't used in events"); | |
5267 return false; | |
5268 case VAR_MagicResistance: | |
5269 return this->sResMagicBase >= pValue; | |
5270 case VAR_FireResistanceBonus: | |
5271 return this->sResFireBonus >= pValue; | |
5272 case VAR_AirResistanceBonus: | |
5273 return this->sResAirBonus >= pValue; | |
5274 case VAR_WaterResistanceBonus: | |
5275 return this->sResWaterBonus >= pValue; | |
5276 case VAR_EarthResistanceBonus: | |
5277 return this->sResEarthBonus >= pValue; | |
5278 case VAR_SpiritResistanceBonus: | |
5279 return this->sResSpiritBonus >= pValue; | |
5280 case VAR_MindResistanceBonus: | |
5281 return this->sResMindBonus >= pValue; | |
5282 case VAR_BodyResistanceBonus: | |
5283 return this->sResBodyBonus >= pValue; | |
5284 case VAR_LightResistanceBonus: | |
5285 return this->sResLightBonus >= pValue; | |
5286 case VAR_DarkResistanceBonus: | |
5287 return this->sResDarkBonus >= pValue; | |
5288 case VAR_MagicResistanceBonus: | |
5289 return this->sResMagicBonus >= pValue; | |
5290 case VAR_StaffSkill: | |
5291 return CmpSkillValue(pValue, this->skillStaff); | |
5292 case VAR_SwordSkill: | |
5293 return CmpSkillValue(pValue, this->skillSword); | |
5294 case VAR_DaggerSkill: | |
5295 return CmpSkillValue(pValue, this->skillDagger); | |
5296 case VAR_AxeSkill: | |
5297 return CmpSkillValue(pValue, this->skillAxe); | |
5298 case VAR_SpearSkill: | |
5299 return CmpSkillValue(pValue, this->skillSpear); | |
5300 case VAR_BowSkill: | |
5301 return CmpSkillValue(pValue, this->skillBow); | |
5302 case VAR_MaceSkill: | |
5303 return CmpSkillValue(pValue, this->skillMace); | |
5304 case VAR_BlasterSkill: | |
5305 return CmpSkillValue(pValue, this->skillBlaster); | |
5306 case VAR_ShieldSkill: | |
5307 return CmpSkillValue(pValue, this->skillShield); | |
5308 case VAR_LeatherSkill: | |
5309 return CmpSkillValue(pValue, this->skillLeather); | |
5310 case VAR_SkillChain: | |
5311 return CmpSkillValue(pValue, this->skillChain); | |
5312 case VAR_PlateSkill: | |
5313 return CmpSkillValue(pValue, this->skillPlate); | |
5314 case VAR_FireSkill: | |
5315 return CmpSkillValue(pValue, this->skillFire); | |
5316 case VAR_AirSkill: | |
5317 return CmpSkillValue(pValue, this->skillAir); | |
5318 case VAR_WaterSkill: | |
5319 return CmpSkillValue(pValue, this->skillWater); | |
5320 case VAR_EarthSkill: | |
5321 return CmpSkillValue(pValue, this->skillEarth); | |
5322 case VAR_SpiritSkill: | |
5323 return CmpSkillValue(pValue, this->skillSpirit); | |
5324 case VAR_MindSkill: | |
5325 return CmpSkillValue(pValue, this->skillMind); | |
5326 case VAR_BodySkill: | |
5327 return CmpSkillValue(pValue, this->skillBody); | |
5328 case VAR_LightSkill: | |
5329 return CmpSkillValue(pValue, this->skillLight); | |
5330 case VAR_DarkSkill: | |
5331 return CmpSkillValue(pValue, this->skillDark); | |
5332 case VAR_IdentifyItemSkill: | |
5333 return CmpSkillValue(pValue, this->skillItemId); | |
5334 case VAR_MerchantSkill: | |
5335 return CmpSkillValue(pValue, this->skillMerchant); | |
5336 case VAR_RepairSkill: | |
5337 return CmpSkillValue(pValue, this->skillRepair); | |
5338 case VAR_BodybuildingSkill: | |
5339 return CmpSkillValue(pValue, this->skillBodybuilding); | |
5340 case VAR_MeditationSkill: | |
5341 return CmpSkillValue(pValue, this->skillMeditation); | |
5342 case VAR_PerceptionSkill: | |
5343 return CmpSkillValue(pValue, this->skillPerception); | |
5344 case VAR_DiplomacySkill: | |
5345 return CmpSkillValue(pValue, this->skillDiplomacy); | |
5346 case VAR_ThieverySkill: | |
5347 Error("Thievery isn't used in events"); | |
5348 return false; | |
5349 case VAR_DisarmTrapSkill: //wasn't in the original | |
5350 return CmpSkillValue(pValue, this->skillDisarmTrap); | |
5351 case VAR_DodgeSkill: //wasn't in the original | |
5352 return CmpSkillValue(pValue, this->skillDodge); | |
5353 case VAR_UnarmedSkill: //wasn't in the original | |
5354 return CmpSkillValue(pValue, this->skillUnarmed); | |
5355 case VAR_IdentifyMonsterSkill: //wasn't in the original | |
5356 return CmpSkillValue(pValue, this->skillMonsterId); | |
5357 case VAR_ArmsmasterSkill: //wasn't in the original | |
5358 return CmpSkillValue(pValue, this->skillArmsmaster); | |
5359 case VAR_StealingSkill: //wasn't in the original | |
5360 return CmpSkillValue(pValue, this->skillStealing); | |
5361 case VAR_AlchemySkill: //wasn't in the original | |
5362 return CmpSkillValue(pValue, this->skillAlchemy); | |
5363 case VAR_LearningSkill: | |
5364 return CmpSkillValue(pValue, this->skillLearning); | |
5365 case VAR_Cursed: | |
5366 return pConditions[Condition_Cursed] > 0; | |
5367 case VAR_Weak: | |
5368 return pConditions[Condition_Weak] > 0; | |
5369 case VAR_Asleep: | |
5370 return pConditions[Condition_Sleep] > 0; | |
5371 case VAR_Afraid: | |
5372 return pConditions[Condition_Fear] > 0; | |
5373 case VAR_Drunk: | |
5374 return pConditions[Condition_Drunk] > 0; | |
5375 case VAR_Insane: | |
5376 return pConditions[Condition_Insane] > 0; | |
5377 case VAR_PoisonedGreen: | |
5378 return pConditions[Condition_Poison1] > 0; | |
5379 case VAR_DiseasedGreen: | |
5380 return pConditions[Condition_Disease1] > 0; | |
5381 case VAR_PoisonedYellow: | |
5382 return pConditions[Condition_Poison2] > 0; | |
5383 case VAR_DiseasedYellow: | |
5384 return pConditions[Condition_Disease2] > 0; | |
5385 case VAR_PoisonedRed: | |
5386 return pConditions[Condition_Poison3] > 0; | |
5387 case VAR_DiseasedRed: | |
5388 return pConditions[Condition_Disease3] > 0; | |
5389 case VAR_Paralyzed: | |
5390 return pConditions[Condition_Paralyzed] > 0; | |
5391 case VAR_Unconsious: | |
5392 return pConditions[Condition_Unconcious] > 0; | |
5393 case VAR_Dead: | |
5394 return pConditions[Condition_Dead] > 0; | |
5395 case VAR_Stoned: | |
5396 return pConditions[Condition_Pertified] > 0; | |
5397 case VAR_Eradicated: | |
5398 return pConditions[Condition_Eradicated] > 0; | |
5399 case VAR_MajorCondition: | |
5400 v4 = GetMajorConditionIdx(); | |
5401 if ( v4 != 18 ) | |
5402 { | |
5398 return v4 >= pValue; | 5403 return v4 >= pValue; |
5399 } | 5404 } |
5400 if ( VarNum == VAR_LightResistanceBonus ) | 5405 return true; |
5401 { | 5406 } |
5402 v4 = this->sResLightBonus; | 5407 } |
5403 return v4 >= pValue; | 5408 if ( (signed int)VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 ) |
5404 } | 5409 return (unsigned __int8)stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] > 0; // originally (unsigned __int8)byte_5E4C15[VarNum]; |
5405 if ( VarNum == VAR_DarkResistanceBonus ) | 5410 if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 ) |
5406 { | 5411 return (unsigned __int8)stru_5E4C90_MapPersistVars._decor_events[VarNum - VAR_MapPersistentVariable_75] > 0; //not really sure whether the number gets up to 99, but can't ignore the possibility |
5407 v4 = this->sResDarkBonus; | 5412 |
5408 return v4 >= pValue; | 5413 return false; |
5409 } | |
5410 if ( VarNum == VAR_MagicResistanceBonus ) | |
5411 { | |
5412 v4 = this->sResMagicBonus; | |
5413 return v4 >= pValue; | |
5414 } | |
5415 if ( VarNum <= VAR_MagicResistanceBonus || VarNum > VAR_DiplomacySkill ) | |
5416 return v4 >= pValue; | |
5417 } | |
5418 v18 = *((short *)&this->pConditions[16] + VarNum); | |
5419 if ( pValue <= 63 ) | |
5420 v4 = v18 & 0x3F; | |
5421 else | |
5422 v4 = pValue & v18; | |
5423 return v4 >= pValue; | |
5424 } | |
5425 if ( VarNum == 104 ) | |
5426 { | |
5427 v18 = *((short *)&this->pConditions[16] + VarNum); | |
5428 if ( pValue <= 63 ) | |
5429 v4 = v18 & 0x3F; | |
5430 else | |
5431 v4 = pValue & v18; | |
5432 return v4 >= pValue; | |
5433 } | |
5434 if ( (signed int)VarNum <= 104 ) | |
5435 return v4 >= pValue; | |
5436 if ( (signed int)VarNum > 0x79 ) | |
5437 { | |
5438 if ( VarNum != 122 ) | |
5439 { | |
5440 if ( (signed int)VarNum > 122 && VarNum <= VAR_ActiveSpells ) | |
5441 v4 = (unsigned __int8)byte_5E4C15[VarNum]; | |
5442 return v4 >= pValue; | |
5443 } | |
5444 v4 = GetMajorConditionIdx(); | |
5445 if ( v4 != 18 ) | |
5446 { | |
5447 return v4 >= pValue; | |
5448 } | |
5449 v4 = pValue; | |
5450 return v4 >= pValue; | |
5451 } | |
5452 return (this->pConditions[VarNum - 105] > 0);// *((int *)this + 2 * VarNum - 210); the original was never used, which is why probably it wasn't correct | |
5453 } | 5414 } |
5454 | 5415 |
5455 | 5416 |
5456 //----- (0044A5CB) -------------------------------------------------------- | 5417 //----- (0044A5CB) -------------------------------------------------------- |
5457 void Player::SetVariable(enum VariableType var_type, signed int var_value) | 5418 void Player::SetVariable(enum VariableType var_type, signed int var_value) |
5891 } | 5852 } |
5892 else | 5853 else |
5893 { | 5854 { |
5894 if ( var_type != VAR_MajorCondition ) | 5855 if ( var_type != VAR_MajorCondition ) |
5895 { | 5856 { |
5896 if ( var_type > VAR_MajorCondition && var_type <= VAR_ActiveSpells ) | 5857 if ( var_type > VAR_MajorCondition && var_type <= VAR_MapPersistentVariable_99 ) |
5897 byte_5E4C15[var_type] = var_value; | 5858 byte_5E4C15[var_type] = var_value; |
5898 return; | 5859 return; |
5899 } | 5860 } |
5900 memset(this, 0, 0xA0u); | 5861 memset(this, 0, 0xA0u); |
5901 } | 5862 } |
6401 } | 6362 } |
6402 else | 6363 else |
6403 { | 6364 { |
6404 if ( var_type != VAR_MajorCondition ) | 6365 if ( var_type != VAR_MajorCondition ) |
6405 { | 6366 { |
6406 if ( var_type > VAR_MajorCondition && var_type <= VAR_ActiveSpells ) | 6367 if ( var_type > VAR_MajorCondition && var_type <= VAR_MapPersistentVariable_99 ) |
6407 { | 6368 { |
6408 if ( (unsigned __int8)val + (unsigned __int8)byte_5E4C15[var_type] <= 255 ) | 6369 if ( (unsigned __int8)val + (unsigned __int8)byte_5E4C15[var_type] <= 255 ) |
6409 byte_5E4C15[var_type] += val; | 6370 byte_5E4C15[var_type] += val; |
6410 else | 6371 else |
6411 byte_5E4C15[var_type] = -1; | 6372 byte_5E4C15[var_type] = -1; |