comparison Player.cpp @ 1792:3155be890554

Player::AddVariable moving everything to a switch, cleaning up, finishing
author Grumpy7
date Thu, 03 Oct 2013 09:35:51 +0200
parents 9f610f471283
children 4dee76d79c78
comparison
equal deleted inserted replaced
1791:9f610f471283 1792:3155be890554
6015 } 6015 }
6016 6016
6017 //----- (0044AFFB) -------------------------------------------------------- 6017 //----- (0044AFFB) --------------------------------------------------------
6018 void Player::AddVariable(enum VariableType var_type, signed int val) 6018 void Player::AddVariable(enum VariableType var_type, signed int val)
6019 { 6019 {
6020 char v3; // bl@1
6021 signed int uPlayerIdx; // edi@1 6020 signed int uPlayerIdx; // edi@1
6022 int v6; // eax@15 6021 int v6; // eax@15
6023 unsigned int v7; // esi@18 6022 unsigned int v7; // esi@18
6024 int *v8; // ebx@21
6025 int v9; // eax@22
6026 signed int v10; // eax@24
6027 int v11; // eax@27
6028 __int16 *v12; // esi@28
6029 char *v15; // ecx@37
6030 unsigned __int8 v16; // cf@38
6031 __int16 *v18; // esi@53
6032 __int16 *v19; // esi@62
6033 char *v20; // esi@107
6034 __int16 v21; // dx@107
6035 int v22; // ecx@107
6036 int v24; // eax@132
6037 int v25; // eax@150
6038 char v26; // zf@151
6039 DDM_DLV_Header *v27; // eax@153 6023 DDM_DLV_Header *v27; // eax@153
6040 signed int v28; // eax@176
6041 int v29; // [sp-8h] [bp-40h]@84
6042 // signed int v30; // [sp-4h] [bp-3Ch]@4
6043 ItemGen item; // [sp+Ch] [bp-2Ch]@45 6024 ItemGen item; // [sp+Ch] [bp-2Ch]@45
6044 unsigned int v33; // [sp+30h] [bp-8h]@34 6025
6045 char v34; // [sp+37h] [bp-1h]@1
6046
6047 v3 = 0;
6048 v34 = 0;
6049 uPlayerIdx = 0; 6026 uPlayerIdx = 0;
6050 if ( this == pPlayers[2] ) 6027 if ( this == pPlayers[2] )
6051 uPlayerIdx = 1; 6028 uPlayerIdx = 1;
6052 else if ( this == pPlayers[3] ) 6029 else if ( this == pPlayers[3] )
6053 uPlayerIdx = 2; 6030 uPlayerIdx = 2;
6054 else if ( this == pPlayers[4] ) 6031 else if ( this == pPlayers[4] )
6055 uPlayerIdx = 3; 6032 uPlayerIdx = 3;
6056 6033
6057 if ( var_type <= VAR_AutoNotes ) 6034 if ( var_type >= VAR_Counter1 && var_type <= VAR_Counter10)
6058 { 6035 {
6059 if ( var_type != VAR_AutoNotes ) 6036 pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed;
6060 { 6037 return;
6061 if ( var_type <= VAR_ActualMight ) 6038 }
6062 { 6039
6063 if ( var_type != VAR_ActualMight ) 6040 if ( var_type >= VAR_UnknownTimeEvent0 && var_type <= VAR_UnknownTimeEvent19 )
6064 { 6041 {
6065 switch ( var_type ) 6042 pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed;
6066 {
6067 case VAR_RandomGold:
6068 if ( val == 0 )
6069 val = 1;
6070 v6 = rand();
6071 party_finds_gold(v6 % val + 1, 1);
6072 GameUI_DrawFoodAndGold();
6073 return;
6074 case VAR_RandomFood:
6075 if ( val == 0 )
6076 val = 1;
6077 v7 = rand() % val + 1;
6078 Party::GiveFood(v7);
6079 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], v7);// You find %lu food
6080 ShowStatusBarString(pTmpBuf.data(), 2u);
6081 GameUI_DrawFoodAndGold();
6082 PlayAwardSound(uPlayerIdx);
6083 return;
6084 case VAR_Sex:
6085 this->uSex = (PLAYER_SEX)val;
6086 PlayAwardSound_Anim97(uPlayerIdx);
6087 return;
6088 case VAR_Class:
6089 this->classType = (PLAYER_CLASS_TYPE)val;
6090 PlayAwardSound_Anim97(uPlayerIdx);
6091 return;
6092 case VAR_CurrentHP:
6093 this->sHealth = min(this->sHealth + val, this->GetMaxHealth() );
6094 PlayAwardSound_Anim97(uPlayerIdx);
6095 return;
6096 case VAR_MaxHP:
6097 this->_health_related = 0;
6098 this->uFullHealthBonus = 0;
6099 this->sHealth = this->GetMaxHealth();
6100 return;
6101 case VAR_CurrentSP:
6102 this->sMana = min(this->sMana + val, this->GetMaxMana() );
6103 PlayAwardSound_Anim97(uPlayerIdx);
6104 return;
6105 case VAR_MaxSP:
6106 this->_mana_related = 0;
6107 this->uFullManaBonus = 0;
6108 this->sMana = GetMaxMana();
6109 return;
6110 case VAR_ACModifier:
6111 this->sACModifier = min(this->sACModifier + val, 255);
6112 PlayAwardSound_Anim97(uPlayerIdx);
6113 return;
6114 case VAR_BaseLevel:
6115 this->uLevel = min(this->uLevel + val, 255);
6116 PlayAwardSound_Anim97(uPlayerIdx);
6117 return;
6118 case VAR_LevelModifier:
6119 this->sLevelModifier = min(this->sLevelModifier + val, 255);
6120 PlayAwardSound_Anim97(uPlayerIdx);
6121 return;
6122 case VAR_Age:
6123 this->sAgeModifier += val;
6124 return;
6125 case VAR_Award:
6126 if (_449B57_test_bit(this->_achieved_awards_bits, val) && pAwards[val].pText )
6127 {
6128 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_96);
6129 }
6130 _449B7E_toggle_bit(this->_achieved_awards_bits, val, 1);
6131 return;
6132 case VAR_Experience:
6133 this->uExperience = min(this->uExperience + val, 4000000000i64);
6134 PlayAwardSound_Anim97(uPlayerIdx);
6135 return;
6136 case VAR_QBits_QuestsDone:
6137 if ( !_449B57_test_bit(pParty->_quest_bits, val) && pQuestTable[val] )
6138 {
6139 bFlashQuestBook = 1;
6140 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_93);
6141 }
6142 _449B7E_toggle_bit(pParty->_quest_bits, val, 1);
6143 return;
6144 case VAR_PlayerItemInHands:
6145 item.Reset();
6146 item.uAttributes = 1;
6147 item.uItemID = val;
6148 if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER )
6149 pParty->pIsArtifactFound[val-500] = 1;
6150 else if ( val >= ITEM_WAND_FIRE && val <= ITEM_WAND_INCENERATION )
6151 {
6152 item.uNumCharges = rand() % 6 + item.GetDamageMod() + 1;
6153 item.uMaxCharges = LOBYTE(item.uNumCharges);
6154 }
6155 pParty->SetHoldingItem(&item);
6156 return;
6157 case VAR_FixedGold:
6158 party_finds_gold(val, 1);
6159 return;
6160 case VAR_BaseMight:
6161 this->uMight = min(this->uMight + val, 255);
6162 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6163 return;
6164 case VAR_BaseIntellect:
6165 this->uIntelligence = min(this->uIntelligence + val, 255);
6166 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6167 return;
6168 case VAR_BasePersonality:
6169 this->uWillpower = min(this->uWillpower + val, 255);
6170 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6171 return;
6172 case VAR_BaseEndurance:
6173 this->uEndurance = min(this->uEndurance + val, 255);
6174 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6175 return;
6176 case VAR_BaseSpeed:
6177 this->uSpeed = min(this->uSpeed + val, 255);
6178 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6179 return;
6180 case VAR_BaseAccuracy:
6181 this->uAccuracy = min(this->uAccuracy + val, 255);
6182 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6183 return;
6184 case VAR_BaseLuck:
6185 this->uLuck = min(this->uLuck + val, 255);
6186 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6187 return;
6188 case VAR_FixedFood:
6189 Party::GiveFood(val);
6190 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], val);
6191 ShowStatusBarString(pTmpBuf.data(), 2u);
6192 if ( pParty->uNumFoodRations > 0xFFFF )
6193 Party::SetFood(0xFFFFu);
6194 PlayAwardSound(uPlayerIdx);
6195 return;
6196 case VAR_MightBonus:
6197 goto LABEL_62;
6198 case VAR_IntellectBonus:
6199 goto LABEL_66;
6200 case VAR_PersonalityBonus:
6201 goto LABEL_67;
6202 case VAR_EnduranceBonus:
6203 goto LABEL_68;
6204 case VAR_SpeedBonus:
6205 goto LABEL_69;
6206 case VAR_AccuracyBonus:
6207 goto LABEL_70;
6208 case VAR_LuckBonus:
6209 goto LABEL_71;
6210 default:
6211 return;
6212 }
6213 return;
6214 }
6215 LABEL_62:
6216 this->uMightBonus = min(this->uMightBonus + val, 255);
6217 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6218 return;
6219 }
6220 if ( var_type <= VAR_FireResistanceBonus )
6221 {
6222 if ( var_type != VAR_FireResistanceBonus )
6223 {
6224 switch ( var_type )
6225 {
6226 case VAR_ActualIntellect:
6227 LABEL_66:
6228 this->uIntelligenceBonus = min(this->uIntelligenceBonus + val, 255);
6229 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6230 return;
6231 case VAR_ActualPersonality:
6232 LABEL_67:
6233 this->uWillpowerBonus = min(this->uWillpowerBonus + val, 255);
6234 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6235 return;
6236 case VAR_ActualEndurance:
6237 LABEL_68:
6238 this->uEnduranceBonus = min(this->uEnduranceBonus + val, 255);
6239 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6240 return;
6241 case VAR_ActualSpeed:
6242 LABEL_69:
6243 this->uSpeedBonus = min(this->uSpeedBonus + val, 255);
6244 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6245 return;
6246 case VAR_ActualAccuracy:
6247 LABEL_70:
6248 this->uAccuracyBonus = min(this->uAccuracyBonus + val, 255);
6249 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6250 return;
6251 case VAR_ActualLuck:
6252 LABEL_71:
6253 this->uLuckBonus = min(this->uLuckBonus + val, 255);
6254 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6255 return;
6256 case VAR_FireResistance:
6257 this->sResFireBase = min(this->sResFireBase + val, 255);
6258 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6259 return;
6260 case VAR_AirResistance:
6261 this->sResAirBase = min(this->sResAirBase + val, 255);
6262 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6263 return;
6264 case VAR_WaterResistance:
6265 this->sResWaterBase = min(this->sResWaterBase + val, 255);
6266 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6267 return;
6268 case VAR_EarthResistance:
6269 this->sResEarthBase = min(this->sResEarthBase + val, 255);
6270 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6271 return;
6272 case VAR_SpiritResistance:
6273 this->sResSpiritBase = min(this->sResSpiritBase + val, 255);
6274 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6275 return;
6276 case VAR_MindResistance:
6277 this->sResMindBase = min(this->sResMindBase + val, 255);
6278 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6279 return;
6280 case VAR_BodyResistance:
6281 this->sResBodyBase = min(this->sResBodyBase + val, 255);
6282 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6283 return;
6284 case VAR_LightResistance:
6285 this->sResLightBase = min(this->sResLightBase + val, 255);
6286 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6287 return;
6288 case VAR_DarkResistance:
6289 this->sResDarkBase = min(this->sResDarkBase + val, 255);
6290 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6291 return;
6292 case VAR_MagicResistance:
6293 this->sResMagicBase = min(this->sResMagicBase + val, 255);
6294 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6295 return;
6296 default:
6297 return;
6298 }
6299 return;
6300 }
6301 this->sResFireBonus = min(this->sResFireBonus + val, 255);
6302 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6303 return;
6304 }
6305 if ( var_type <= VAR_DisarmTrapSkill )
6306 {
6307 if ( var_type != VAR_DisarmTrapSkill )
6308 {
6309 if ( var_type <= VAR_BodyResistanceBonus )
6310 {
6311 switch ( var_type )
6312 {
6313 case VAR_BodyResistanceBonus:
6314 this->sResBodyBonus = min(this->sResBodyBonus + val, 255);
6315 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6316 return;
6317 case VAR_AirResistanceBonus:
6318 this->sResAirBonus = min(this->sResAirBonus + val, 255);
6319 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6320 return;
6321 case VAR_WaterResistanceBonus:
6322 this->sResWaterBonus = min(this->sResWaterBonus + val, 255);
6323 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6324 return;
6325 case VAR_EarthResistanceBonus:
6326 this->sResEarthBonus = min(this->sResEarthBonus + val, 255);
6327 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6328 return;
6329 case VAR_SpiritResistanceBonus:
6330 this->sResSpiritBonus = min(this->sResSpiritBonus + val, 255);
6331 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6332 return;
6333 case VAR_MindResistanceBonus:
6334 this->sResMindBonus = min(this->sResMindBonus + val, 255);
6335 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6336 return;
6337 break;
6338 default:
6339 return;
6340 }
6341 }
6342 if ( var_type == VAR_LightResistanceBonus )
6343 {
6344 this->sResLightBonus = min(this->sResLightBonus + val, 255);
6345 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6346 return;
6347 }
6348 if ( var_type == VAR_DarkResistanceBonus )
6349 {
6350 this->sResDarkBonus = min(this->sResDarkBonus + val, 255);
6351 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6352 return;
6353 }
6354 if ( var_type == VAR_MagicResistanceBonus )
6355 {
6356 this->sResMagicBonus = min(this->sResMagicBonus + val, 255);
6357 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6358 return;
6359 }
6360 if ( var_type <= VAR_MagicResistanceBonus || var_type > VAR_DiplomacySkill )
6361 return;
6362 }
6363 if ( val <= 63 )
6364 {
6365 *((short *)&this->pConditions[16] + var_type) = (unsigned __int8)val | *((char *)&this->pConditions[16] + 2 * var_type) & 63;
6366 }
6367 else
6368 {
6369 v20 = (char *)&this->pConditions[16] + 2 * var_type;
6370 v21 = *(short *)v20;
6371 v22 = (unsigned __int8)val + (v21 & 63);
6372 if ( v22 > 60 )
6373 LOWORD(v22) = 60;
6374 LOBYTE(v21) = v21 & 0xC0;
6375 *(short *)v20 = v22 | v21;
6376 }
6377 PlayAwardSound_Anim97(uPlayerIdx);
6378 return;
6379 }
6380 if ( var_type == VAR_LearningSkill )
6381 {
6382 if ( val <= 63 )
6383 {
6384 *((short *)&this->pConditions[16] + var_type) = (unsigned __int8)val | *((char *)&this->pConditions[16] + 2 * var_type) & 63;
6385 }
6386 else
6387 {
6388 v20 = (char *)&this->pConditions[16] + 2 * var_type;
6389 v21 = *(short *)v20;
6390 v22 = (unsigned __int8)val + (v21 & 63);
6391 if ( v22 > 60 )
6392 LOWORD(v22) = 60;
6393 LOBYTE(v21) = v21 & 0xC0;
6394 *(short *)v20 = v22 | v21;
6395 }
6396 PlayAwardSound_Anim97(uPlayerIdx);
6397 return;
6398 }
6399 if ( var_type <= VAR_LearningSkill )
6400 return;
6401 if ( var_type <= VAR_Eradicated )
6402 {
6403 this->SetCondition(var_type - 105, 0);
6404 }
6405 else
6406 {
6407 if ( var_type != VAR_MajorCondition )
6408 {
6409 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 )
6410 {
6411 if ( (unsigned __int8)val + (unsigned __int8)byte_5E4C15[var_type] <= 255 )
6412 byte_5E4C15[var_type] += val;
6413 else
6414 byte_5E4C15[var_type] = -1;
6415 }
6416 return;
6417 }
6418 memset(this, 0, 0xA0u);
6419 }
6420 PlayAwardSound_Anim97(uPlayerIdx);
6421 return;
6422 }
6423 if ( !_449B57_test_bit(pParty->_autonote_bits, val) && pAutonoteTxt[val].pText )
6424 {
6425 this->PlaySound(SPEECH_96, 0);
6426 //v24 = pAutonoteTxt[val].eType;//dword_72371C[2 * val];
6427 bFlashAutonotesBook = 1;
6428 _506568_autonote_type = pAutonoteTxt[val].eType;
6429 pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx);
6430 }
6431 _449B7E_toggle_bit(pParty->_autonote_bits, val, 1);
6432 PlayAwardSound(uPlayerIdx); 6043 PlayAwardSound(uPlayerIdx);
6433 return; 6044 return;
6434 } 6045 }
6435 if ( var_type > VAR_GoldInBank ) 6046
6436 { 6047 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 )
6437 if ( var_type == 307 ) 6048 {
6438 { 6049 if ( (unsigned __int8)val + (unsigned __int8)byte_5E4C15[var_type] <= 255 )
6050 byte_5E4C15[var_type] += val;
6051 else
6052 byte_5E4C15[var_type] = -1;
6053 return;
6054 }
6055
6056 if ( var_type >= VAR_History_0 && var_type <= VAR_History_28)
6057 {
6058 if (!pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0])
6059 {
6060 pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0] = pParty->uTimePlayed;
6061 if (pStorylineText->StoreLine[var_type - VAR_History_0].pText = 0)
6062 {
6063 bFlashHistoryBook = 1;
6064 PlayAwardSound(uPlayerIdx);
6065 }
6066 }
6067 return;
6068 }
6069
6070 switch ( var_type )
6071 {
6072 case VAR_RandomGold:
6073 if ( val == 0 )
6074 val = 1;
6075 v6 = rand();
6076 party_finds_gold(v6 % val + 1, 1);
6077 GameUI_DrawFoodAndGold();
6078 return;
6079 case VAR_RandomFood:
6080 if ( val == 0 )
6081 val = 1;
6082 v7 = rand() % val + 1;
6083 Party::GiveFood(v7);
6084 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], v7);// You find %lu food
6085 ShowStatusBarString(pTmpBuf.data(), 2u);
6086 GameUI_DrawFoodAndGold();
6087 PlayAwardSound(uPlayerIdx);
6088 return;
6089 case VAR_Sex:
6090 this->uSex = (PLAYER_SEX)val;
6091 PlayAwardSound_Anim97(uPlayerIdx);
6092 return;
6093 case VAR_Class:
6094 this->classType = (PLAYER_CLASS_TYPE)val;
6095 PlayAwardSound_Anim97(uPlayerIdx);
6096 return;
6097 case VAR_CurrentHP:
6098 this->sHealth = min(this->sHealth + val, this->GetMaxHealth() );
6099 PlayAwardSound_Anim97(uPlayerIdx);
6100 return;
6101 case VAR_MaxHP:
6102 this->_health_related = 0;
6103 this->uFullHealthBonus = 0;
6104 this->sHealth = this->GetMaxHealth();
6105 return;
6106 case VAR_CurrentSP:
6107 this->sMana = min(this->sMana + val, this->GetMaxMana() );
6108 PlayAwardSound_Anim97(uPlayerIdx);
6109 return;
6110 case VAR_MaxSP:
6111 this->_mana_related = 0;
6112 this->uFullManaBonus = 0;
6113 this->sMana = GetMaxMana();
6114 return;
6115 case VAR_ACModifier:
6116 this->sACModifier = min(this->sACModifier + val, 255);
6117 PlayAwardSound_Anim97(uPlayerIdx);
6118 return;
6119 case VAR_BaseLevel:
6120 this->uLevel = min(this->uLevel + val, 255);
6121 PlayAwardSound_Anim97(uPlayerIdx);
6122 return;
6123 case VAR_LevelModifier:
6124 this->sLevelModifier = min(this->sLevelModifier + val, 255);
6125 PlayAwardSound_Anim97(uPlayerIdx);
6126 return;
6127 case VAR_Age:
6128 this->sAgeModifier += val;
6129 return;
6130 case VAR_Award:
6131 if (_449B57_test_bit(this->_achieved_awards_bits, val) && pAwards[val].pText )
6132 {
6133 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_96);
6134 }
6135 _449B7E_toggle_bit(this->_achieved_awards_bits, val, 1);
6136 return;
6137 case VAR_Experience:
6138 this->uExperience = min(this->uExperience + val, 4000000000i64);
6139 PlayAwardSound_Anim97(uPlayerIdx);
6140 return;
6141 case VAR_QBits_QuestsDone:
6142 if ( !_449B57_test_bit(pParty->_quest_bits, val) && pQuestTable[val] )
6143 {
6144 bFlashQuestBook = 1;
6145 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_93);
6146 }
6147 _449B7E_toggle_bit(pParty->_quest_bits, val, 1);
6148 return;
6149 case VAR_PlayerItemInHands:
6150 item.Reset();
6151 item.uAttributes = 1;
6152 item.uItemID = val;
6153 if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER )
6154 pParty->pIsArtifactFound[val-500] = 1;
6155 else if ( val >= ITEM_WAND_FIRE && val <= ITEM_WAND_INCENERATION )
6156 {
6157 item.uNumCharges = rand() % 6 + item.GetDamageMod() + 1;
6158 item.uMaxCharges = LOBYTE(item.uNumCharges);
6159 }
6160 pParty->SetHoldingItem(&item);
6161 return;
6162 case VAR_FixedGold:
6163 party_finds_gold(val, 1);
6164 return;
6165 case VAR_BaseMight:
6166 this->uMight = min(this->uMight + val, 255);
6167 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6168 return;
6169 case VAR_BaseIntellect:
6170 this->uIntelligence = min(this->uIntelligence + val, 255);
6171 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6172 return;
6173 case VAR_BasePersonality:
6174 this->uWillpower = min(this->uWillpower + val, 255);
6175 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6176 return;
6177 case VAR_BaseEndurance:
6178 this->uEndurance = min(this->uEndurance + val, 255);
6179 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6180 return;
6181 case VAR_BaseSpeed:
6182 this->uSpeed = min(this->uSpeed + val, 255);
6183 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6184 return;
6185 case VAR_BaseAccuracy:
6186 this->uAccuracy = min(this->uAccuracy + val, 255);
6187 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6188 return;
6189 case VAR_BaseLuck:
6190 this->uLuck = min(this->uLuck + val, 255);
6191 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6192 return;
6193 case VAR_FixedFood:
6194 Party::GiveFood(val);
6195 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], val);
6196 ShowStatusBarString(pTmpBuf.data(), 2u);
6197 if ( pParty->uNumFoodRations > 0xFFFF )
6198 Party::SetFood(0xFFFFu);
6199 PlayAwardSound(uPlayerIdx);
6200 return;
6201 case VAR_MightBonus:
6202 case VAR_ActualMight:
6203 this->uMightBonus = min(this->uMightBonus + val, 255);
6204 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6205 return;
6206 case VAR_IntellectBonus:
6207 case VAR_ActualIntellect:
6208 this->uIntelligenceBonus = min(this->uIntelligenceBonus + val, 255);
6209 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6210 return;
6211 case VAR_PersonalityBonus:
6212 case VAR_ActualPersonality:
6213 this->uWillpowerBonus = min(this->uWillpowerBonus + val, 255);
6214 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6215 return;
6216 case VAR_EnduranceBonus:
6217 case VAR_ActualEndurance:
6218 this->uEnduranceBonus = min(this->uEnduranceBonus + val, 255);
6219 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6220 return;
6221 case VAR_SpeedBonus:
6222 case VAR_ActualSpeed:
6223 this->uSpeedBonus = min(this->uSpeedBonus + val, 255);
6224 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6225 return;
6226 case VAR_AccuracyBonus:
6227 case VAR_ActualAccuracy:
6228 this->uAccuracyBonus = min(this->uAccuracyBonus + val, 255);
6229 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6230 return;
6231 case VAR_LuckBonus:
6232 case VAR_ActualLuck:
6233 this->uLuckBonus = min(this->uLuckBonus + val, 255);
6234 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6235 return;
6236 case VAR_FireResistance:
6237 this->sResFireBase = min(this->sResFireBase + val, 255);
6238 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6239 return;
6240 case VAR_AirResistance:
6241 this->sResAirBase = min(this->sResAirBase + val, 255);
6242 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6243 return;
6244 case VAR_WaterResistance:
6245 this->sResWaterBase = min(this->sResWaterBase + val, 255);
6246 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6247 return;
6248 case VAR_EarthResistance:
6249 this->sResEarthBase = min(this->sResEarthBase + val, 255);
6250 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6251 return;
6252 case VAR_SpiritResistance:
6253 this->sResSpiritBase = min(this->sResSpiritBase + val, 255);
6254 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6255 return;
6256 case VAR_MindResistance:
6257 this->sResMindBase = min(this->sResMindBase + val, 255);
6258 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6259 return;
6260 case VAR_BodyResistance:
6261 this->sResBodyBase = min(this->sResBodyBase + val, 255);
6262 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6263 return;
6264 case VAR_LightResistance:
6265 this->sResLightBase = min(this->sResLightBase + val, 255);
6266 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6267 return;
6268 case VAR_DarkResistance:
6269 this->sResDarkBase = min(this->sResDarkBase + val, 255);
6270 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6271 return;
6272 case VAR_MagicResistance:
6273 this->sResMagicBase = min(this->sResMagicBase + val, 255);
6274 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92);
6275 return;
6276 case VAR_FireResistanceBonus:
6277 this->sResFireBonus = min(this->sResFireBonus + val, 255);
6278 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6279 return;
6280 case VAR_AirResistanceBonus:
6281 this->sResAirBonus = min(this->sResAirBonus + val, 255);
6282 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6283 return;
6284 case VAR_WaterResistanceBonus:
6285 this->sResWaterBonus = min(this->sResWaterBonus + val, 255);
6286 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6287 return;
6288 case VAR_EarthResistanceBonus:
6289 this->sResEarthBonus = min(this->sResEarthBonus + val, 255);
6290 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6291 return;
6292 case VAR_SpiritResistanceBonus:
6293 this->sResSpiritBonus = min(this->sResSpiritBonus + val, 255);
6294 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6295 return;
6296 case VAR_MindResistanceBonus:
6297 this->sResMindBonus = min(this->sResMindBonus + val, 255);
6298 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6299 return;
6300 case VAR_BodyResistanceBonus:
6301 this->sResBodyBonus = min(this->sResBodyBonus + val, 255);
6302 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6303 return;
6304 case VAR_LightResistanceBonus:
6305 this->sResLightBonus = min(this->sResLightBonus + val, 255);
6306 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6307 return;
6308 case VAR_DarkResistanceBonus:
6309 this->sResDarkBonus = min(this->sResDarkBonus + val, 255);
6310 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6311 return;
6312 case VAR_MagicResistanceBonus:
6313 this->sResMagicBonus = min(this->sResMagicBonus + val, 255);
6314 PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91);
6315 return;
6316 case VAR_Cursed:
6317 this->SetCondition(Condition_Cursed, 1);
6318 PlayAwardSound_Anim97(uPlayerIdx);
6319 return;
6320 case VAR_Weak:
6321 this->SetCondition(Condition_Weak, 1);
6322 PlayAwardSound_Anim97(uPlayerIdx);
6323 return;
6324 case VAR_Asleep:
6325 this->SetCondition(Condition_Sleep, 1);
6326 PlayAwardSound_Anim97(uPlayerIdx);
6327 return;
6328 case VAR_Afraid:
6329 this->SetCondition(Condition_Fear, 1);
6330 PlayAwardSound_Anim97(uPlayerIdx);
6331 return;
6332 case VAR_Drunk:
6333 this->SetCondition(Condition_Drunk, 1);
6334 PlayAwardSound_Anim97(uPlayerIdx);
6335 return;
6336 case VAR_Insane:
6337 this->SetCondition(Condition_Insane, 1);
6338 PlayAwardSound_Anim97(uPlayerIdx);
6339 return;
6340 case VAR_PoisonedGreen:
6341 this->SetCondition(Condition_Poison1, 1);
6342 PlayAwardSound_Anim97(uPlayerIdx);
6343 return;
6344 case VAR_DiseasedGreen:
6345 this->SetCondition(Condition_Disease1, 1);
6346 PlayAwardSound_Anim97(uPlayerIdx);
6347 return;
6348 case VAR_PoisonedYellow:
6349 this->SetCondition(Condition_Poison2, 1);
6350 PlayAwardSound_Anim97(uPlayerIdx);
6351 return;
6352 case VAR_DiseasedYellow:
6353 this->SetCondition(Condition_Disease2, 1);
6354 PlayAwardSound_Anim97(uPlayerIdx);
6355 return;
6356 case VAR_PoisonedRed:
6357 this->SetCondition(Condition_Poison3, 1);
6358 PlayAwardSound_Anim97(uPlayerIdx);
6359 return;
6360 case VAR_DiseasedRed:
6361 this->SetCondition(Condition_Disease3, 1);
6362 PlayAwardSound_Anim97(uPlayerIdx);
6363 return;
6364 case VAR_Paralyzed:
6365 this->SetCondition(Condition_Paralyzed, 1);
6366 PlayAwardSound_Anim97(uPlayerIdx);
6367 return;
6368 case VAR_Unconsious:
6369 this->SetCondition(Condition_Unconcious, 1);
6370 PlayAwardSound_Anim97(uPlayerIdx);
6371 return;
6372 case VAR_Dead:
6373 this->SetCondition(Condition_Dead, 1);
6374 PlayAwardSound_Anim97(uPlayerIdx);
6375 return;
6376 case VAR_Stoned:
6377 this->SetCondition(Condition_Pertified, 1);
6378 PlayAwardSound_Anim97(uPlayerIdx);
6379 return;
6380 case VAR_Eradicated:
6381 this->SetCondition(Condition_Eradicated, 1);
6382 PlayAwardSound_Anim97(uPlayerIdx);
6383 return;
6384 case VAR_MajorCondition :
6385 memset(this, 0, 0xA0u);
6386 PlayAwardSound_Anim97(uPlayerIdx);
6387 return;
6388 case VAR_AutoNotes:
6389 if ( !_449B57_test_bit(pParty->_autonote_bits, val) && pAutonoteTxt[val].pText )
6390 {
6391 this->PlaySound(SPEECH_96, 0);
6392 bFlashAutonotesBook = 1;
6393 _506568_autonote_type = pAutonoteTxt[val].eType;
6394 pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx);
6395 }
6396 _449B7E_toggle_bit(pParty->_autonote_bits, val, 1);
6397 PlayAwardSound(uPlayerIdx);
6398 return;
6399 case VAR_PlayerBits:
6400 _449B7E_toggle_bit((unsigned char *)this->field_1A50, val, 1u);
6401 return;
6402 case VAR_NPCs2:
6403 pParty->field_709 = 0;
6404 LOBYTE(pNPCStats->pNewNPCData[val].uFlags) |= 0x80u;
6405 pParty->CountHirelings();
6406 viewparams->bRedrawGameUI = true;
6407 return;
6408 case VAR_NumSkillPoints:
6409 this->uSkillPoints += val;
6410 return;
6411 case VAR_ReputationInCurrentLocation:
6412 v27 = &pOutdoor->ddm;
6413 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
6414 v27 = &pIndoor->dlv;
6415 v27->uReputation += val;
6416 if ( v27->uReputation > 10000 )
6417 v27->uReputation = 10000;
6418 return;
6419 case VAR_GoldInBank:
6420 pParty->uNumGoldInBank += val;
6421 return;
6422 case VAR_NumDeaths:
6439 pParty->uNumDeaths += val; 6423 pParty->uNumDeaths += val;
6440 return; 6424 return;
6441 } 6425 case VAR_NumBounties:
6442 switch ( var_type ) 6426 pParty->uNumBountiesCollected += val;
6443 { 6427 return;
6444 case 308: 6428 case VAR_PrisonTerms:
6445 pParty->uNumBountiesCollected += val; 6429 pParty->uNumPrisonTerms += val;
6446 break; 6430 return;
6447 case 309: 6431 case VAR_ArenaWinsPage:
6448 pParty->uNumPrisonTerms += val; 6432 pParty->uNumArenaPageWins += val;
6449 break; 6433 return;
6450 case 310: 6434 case VAR_ArenaWinsSquire:
6451 pParty->uNumArenaPageWins += val; 6435 pParty->uNumArenaSquireWins += val;
6452 break; 6436 return;
6453 case 311: 6437 case VAR_ArenaWinsKnight:
6454 pParty->uNumArenaSquireWins += val; 6438 pParty->uNumArenaKnightWins += val;
6455 break; 6439 return;
6456 case 312: 6440 case VAR_ArenaWinsLord:
6457 pParty->uNumArenaKnightWins += val; 6441 pParty->uNumArenaLordWins += val;
6458 break; 6442 return;
6459 case 313: 6443 case VAR_StaffSkill:
6460 pParty->uNumArenaLordWins += val; 6444 AddSkillByEvent(&Player::skillStaff, val, uPlayerIdx);
6461 break; 6445 return;
6462 } 6446 case VAR_SwordSkill:
6463 } 6447 AddSkillByEvent(&Player::skillSword, val, uPlayerIdx);
6464 else 6448 return;
6465 { 6449 case VAR_DaggerSkill:
6466 if ( var_type == VAR_GoldInBank ) 6450 AddSkillByEvent(&Player::skillDagger, val, uPlayerIdx);
6467 { 6451 return;
6468 pParty->uNumGoldInBank += val; 6452 case VAR_AxeSkill:
6469 return; 6453 AddSkillByEvent(&Player::skillAxe, val, uPlayerIdx);
6470 } 6454 return;
6471 if ( var_type <= VAR_Counter10 ) 6455 case VAR_SpearSkill:
6472 { 6456 AddSkillByEvent(&Player::skillSpear, val, uPlayerIdx);
6473 if ( (signed int)var_type >= 245 ) 6457 return;
6474 { 6458 case VAR_BowSkill:
6475 pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; 6459 AddSkillByEvent(&Player::skillBow, val, uPlayerIdx);
6476 } 6460 return;
6477 else 6461 case VAR_MaceSkill:
6478 { 6462 AddSkillByEvent(&Player::skillMace, val, uPlayerIdx);
6479 switch ( var_type ) 6463 return;
6480 { 6464 case VAR_BlasterSkill:
6481 case VAR_PlayerBits: 6465 AddSkillByEvent(&Player::skillBlaster, val, uPlayerIdx);
6482 _449B7E_toggle_bit((unsigned char *)this->field_1A50, val, 1u); 6466 return;
6483 break; 6467 case VAR_ShieldSkill:
6484 case VAR_NPCs2: 6468 AddSkillByEvent(&Player::skillShield, val, uPlayerIdx);
6485 pParty->field_709 = 0; 6469 return;
6486 LOBYTE(pNPCStats->pNewNPCData[val].uFlags) |= 0x80u; 6470 case VAR_LeatherSkill:
6487 pParty->CountHirelings(); 6471 AddSkillByEvent(&Player::skillLeather, val, uPlayerIdx);
6488 viewparams->bRedrawGameUI = true; 6472 return;
6489 break; 6473 case VAR_SkillChain:
6490 case VAR_NumSkillPoints: 6474 AddSkillByEvent(&Player::skillChain, val, uPlayerIdx);
6491 this->uSkillPoints += val; 6475 return;
6492 break; 6476 case VAR_PlateSkill:
6493 } 6477 AddSkillByEvent(&Player::skillPlate, val, uPlayerIdx);
6494 } 6478 return;
6495 return; 6479 case VAR_FireSkill:
6496 } 6480 AddSkillByEvent(&Player::skillFire, val, uPlayerIdx);
6497 if ( var_type <= VAR_Counter10 ) 6481 return;
6498 return; 6482 case VAR_AirSkill:
6499 if ( var_type <= VAR_UnknownTimeEvent19 ) 6483 AddSkillByEvent(&Player::skillAir, val, uPlayerIdx);
6500 { 6484 return;
6501 pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; 6485 case VAR_WaterSkill:
6502 PlayAwardSound(uPlayerIdx); 6486 AddSkillByEvent(&Player::skillWater, val, uPlayerIdx);
6503 return; 6487 return;
6504 } 6488 case VAR_EarthSkill:
6505 if ( var_type != VAR_ReputationInCurrentLocation ) 6489 AddSkillByEvent(&Player::skillEarth, val, uPlayerIdx);
6506 { 6490 return;
6507 if ( var_type <= VAR_ReputationInCurrentLocation 6491 case VAR_SpiritSkill:
6508 || var_type > VAR_History_28 6492 AddSkillByEvent(&Player::skillSpirit, val, uPlayerIdx);
6509 || (v25 = var_type - 276, pParty->PartyTimes.HistoryEventTimes[v25]) 6493 return;
6510 || (pParty->PartyTimes.HistoryEventTimes[var_type - 276] = pParty->uTimePlayed, 6494 case VAR_MindSkill:
6511 v26 = pStorylineText->StoreLine[v25].pText==0,//*(&pStorylineText->field_0 + 3 * v25) == 0, 6495 AddSkillByEvent(&Player::skillMind, val, uPlayerIdx);
6512 v26) ) 6496 return;
6513 return; 6497 case VAR_BodySkill:
6514 bFlashHistoryBook = 1; 6498 AddSkillByEvent(&Player::skillBody, val, uPlayerIdx);
6515 PlayAwardSound(uPlayerIdx); 6499 return;
6516 return; 6500 case VAR_LightSkill:
6517 } 6501 AddSkillByEvent(&Player::skillLight, val, uPlayerIdx);
6518 v27 = &pOutdoor->ddm; 6502 return;
6519 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) 6503 case VAR_DarkSkill:
6520 v27 = &pIndoor->dlv; 6504 AddSkillByEvent(&Player::skillDark, val, uPlayerIdx);
6521 v27->uReputation += val; 6505 return;
6522 if ( v27->uReputation > 10000 ) 6506 case VAR_IdentifyItemSkill:
6523 v27->uReputation = 10000; 6507 AddSkillByEvent(&Player::skillItemId, val, uPlayerIdx);
6508 return;
6509 case VAR_MerchantSkill:
6510 AddSkillByEvent(&Player::skillMerchant, val, uPlayerIdx);
6511 return;
6512 case VAR_RepairSkill:
6513 AddSkillByEvent(&Player::skillRepair, val, uPlayerIdx);
6514 return;
6515 case VAR_BodybuildingSkill:
6516 AddSkillByEvent(&Player::skillBodybuilding, val, uPlayerIdx);
6517 return;
6518 case VAR_MeditationSkill:
6519 AddSkillByEvent(&Player::skillMeditation, val, uPlayerIdx);
6520 return;
6521 case VAR_PerceptionSkill:
6522 AddSkillByEvent(&Player::skillPerception, val, uPlayerIdx);
6523 return;
6524 case VAR_DiplomacySkill:
6525 AddSkillByEvent(&Player::skillDiplomacy, val, uPlayerIdx);
6526 return;
6527 case VAR_ThieverySkill:
6528 Error ("Thieving unsupported");
6529 return;
6530 case VAR_DisarmTrapSkill:
6531 AddSkillByEvent(&Player::skillDisarmTrap, val, uPlayerIdx);
6532 return;
6533 case VAR_DodgeSkill:
6534 AddSkillByEvent(&Player::skillDodge, val, uPlayerIdx);
6535 return;
6536 case VAR_UnarmedSkill:
6537 AddSkillByEvent(&Player::skillUnarmed, val, uPlayerIdx);
6538 return;
6539 case VAR_IdentifyMonsterSkill:
6540 AddSkillByEvent(&Player::skillMonsterId, val, uPlayerIdx);
6541 return;
6542 case VAR_ArmsmasterSkill:
6543 AddSkillByEvent(&Player::skillArmsmaster, val, uPlayerIdx);
6544 return;
6545 case VAR_StealingSkill:
6546 AddSkillByEvent(&Player::skillStealing, val, uPlayerIdx);
6547 return;
6548 case VAR_AlchemySkill:
6549 AddSkillByEvent(&Player::skillAlchemy, val, uPlayerIdx);
6550 return;
6551 case VAR_LearningSkill:
6552 AddSkillByEvent(&Player::skillLearning, val, uPlayerIdx);
6553 return;
6554 default:
6555 return;
6524 } 6556 }
6525 } 6557 }
6526 6558
6527 //----- (new function) -------------------------------------------------------- 6559 //----- (new function) --------------------------------------------------------
6528 void Player::PlayAwardSound_Anim97(int currPlayerId) 6560 void Player::PlayAwardSound_Anim97(int currPlayerId)