Mercurial > mm7
diff Player.cpp @ 1780:01b3c314e9be
Player::SetVariable moved most of the conditions into a switch
author | Grumpy7 |
---|---|
date | Thu, 03 Oct 2013 05:27:54 +0200 |
parents | 50e91a820f6f |
children | 7b42e79eb2d0 |
line wrap: on
line diff
--- a/Player.cpp Wed Oct 02 08:51:43 2013 +0200 +++ b/Player.cpp Thu Oct 03 05:27:54 2013 +0200 @@ -5438,554 +5438,570 @@ currPlayerId = 2; else if ( this == pPlayers[4] ) currPlayerId = 3; - if ( var_type > VAR_AutoNotes ) - { - if ( var_type <= VAR_GoldInBank ) - { - if ( var_type == VAR_GoldInBank ) + + + if ( var_type >= VAR_History_0 && var_type <= VAR_History_28) + { + if (!pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0]) + { + pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0] = pParty->uTimePlayed; + if (pStorylineText->StoreLine[var_type - VAR_History_0].pText) { - pParty->uNumGoldInBank = var_value; - return; + bFlashHistoryBook = 1; + PlayAwardSound(currPlayerId); } - if ( var_type <= VAR_Counter10 ) + } + return; + } + + if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 ) + { + byte_5E4C15[var_type] = var_value; + return; + } + + if ( var_type >= VAR_UnknownTimeEvent0 && var_type <= VAR_UnknownTimeEvent19 ) + { + pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; //*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed);, *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed + PlayAwardSound(currPlayerId); + return; + } + + switch ( var_type ) + { + case VAR_Sex: + this->uSex = (PLAYER_SEX)var_value; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Class: + this->classType = (PLAYER_CLASS_TYPE)var_value; + if ( (PLAYER_CLASS_TYPE)var_value == PLAYER_CLASS_LICH ) { - if ( (signed int)var_type >= 0xF5 ) + for (int i = 0; i < 138; i++) { - pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; // *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed);*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed); - return; + if (this->pOwnItems[i].uItemID == ITEM_LICH_JAR_EMPTY) + { + this->pOwnItems[i].uItemID = ITEM_LICH_JAR_FULL; + this->pOwnItems[i].uHolderPlayer = currPlayerId + 1; + } + } + if ( this->sResFireBase < 20 ) + this->sResFireBase = 20; + if ( this->sResAirBase < 20 ) + this->sResAirBase = 20; + if ( this->sResWaterBase < 20 ) + this->sResWaterBase = 20; + if ( this->sResEarthBase < 20 ) + this->sResEarthBase = 20; + this->sResMindBase = 200; + this->sResBodyBase = 200; + v11 = this->GetSexByVoice(); + this->uPrevVoiceID = this->uVoiceID; + this->uPrevFace = this->uCurrentFace; + if ( v11 ) + { + this->uCurrentFace = 21; + this->uVoiceID = 21; } else { - switch ( var_type ) - { - case VAR_PlayerBits: - _449B7E_toggle_bit((unsigned char *)field_1A50, var_value, 1u); - return; - case VAR_NPCs2: - pParty->field_709 = 0; - LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u; - pParty->CountHirelings(); - viewparams->bRedrawGameUI = true; - return; - case VAR_NumSkillPoints: - this->uSkillPoints = var_value; - return; - } + this->uCurrentFace = 20; + this->uVoiceID = 20; } - return; + ReloadPlayerPortraits(currPlayerId, this->uCurrentFace); } - if ( var_type <= VAR_Counter10 ) - return; - if ( (signed int)var_type <= VAR_UnknownTimeEvent19 ) - { - pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; //*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed);, *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed - PlayAwardSound(currPlayerId); - return; - } - else - { - if ( var_type == VAR_ReputationInCurrentLocation ) - { - v24 = &pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) - v24 = &pIndoor->dlv; - v24->uReputation = var_value; - if ( var_value > 10000 ) - v24->uReputation = 10000; - return; - } - if ( var_type >= VAR_History_0 && var_type <= VAR_History_28 && !pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0]) - { - pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0] = pParty->uTimePlayed; - if (pStorylineText->StoreLine[v22].pText) - { - bFlashHistoryBook = 1; - PlayAwardSound(currPlayerId); - } - return; - } - } + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_CurrentHP: + this->sHealth = var_value; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_MaxHP: + this->sHealth = GetMaxHealth(); + return; + case VAR_CurrentSP: + this->sMana = var_value; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_MaxSP: + this->sMana = GetMaxMana(); + return; + case VAR_ACModifier: + this->sACModifier = (unsigned __int8)var_value; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); return; - } - if ( var_type != 307 ) - { - switch ( var_type ) - { - case 308: - pParty->uNumBountiesCollected = var_value; - return; - case 309: - pParty->uNumPrisonTerms = var_value; - return; - case 310: - pParty->uNumArenaPageWins = var_value; - return; - case 311: - pParty->uNumArenaSquireWins = var_value; - return; - case 312: - pParty->uNumArenaKnightWins = var_value; - return; - case 313: - pParty->uNumArenaLordWins = var_value; - return; - } + case VAR_BaseLevel: + this->uLevel = (unsigned __int8)var_value; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_LevelModifier: + this->sLevelModifier = (unsigned __int8)var_value; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Age: + this->sAgeModifier = var_value; return; - } - pParty->uNumDeaths = var_value; - return; - } - if ( var_type == VAR_AutoNotes ) - { - if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_autonote_bits[((signed __int16)var_value - 1) >> 3]) - //&& (&dword_723718_autonote_related)[8 * a3] ) - && pAutonoteTxt[var_value-1].pText ) - { + case VAR_Award: + if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & + this->_achieved_awards_bits[((signed __int16)var_value - 1)/ 8]) //&& dword_723E80_award_related[2 * a3] ) + && pAwards[var_value].pText ) + { + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + this->PlaySound(SPEECH_96, 0); + } + _449B7E_toggle_bit(this->_achieved_awards_bits, var_value, 1u); + return; + case VAR_Experience: + this->uExperience = var_value; pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - this->PlaySound(SPEECH_96, 0); - bFlashAutonotesBook = 1; - _506568_autonote_type = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3]; - } - _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u); - PlayAwardSound(currPlayerId); - return; - } - if ( var_type <= VAR_ActualMight ) - { - if ( var_type != VAR_ActualMight ) - { - switch ( var_type ) + PlayAwardSound(currPlayerId); + return; + case VAR_QBits_QuestsDone: + if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_quest_bits[((signed __int16)var_value - 1) >> 3])// && (&dword_722F10)[4 * a3] ) + && pQuestTable[var_value-1] ) { - case VAR_RandomGold: - v6 = rand() % var_value + 1; - Party::SetGold(v6); - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold - ShowStatusBarString(pTmpBuf.data(), 2u); - GameUI_DrawFoodAndGold(); - return; - case VAR_RandomFood: - v7 = rand() % var_value + 1; - Party::SetFood(v7); - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food - ShowStatusBarString(pTmpBuf.data(), 2u); - GameUI_DrawFoodAndGold(); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_Sex: - this->uSex = (PLAYER_SEX)var_value; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_Class: - this->classType = (PLAYER_CLASS_TYPE)var_value; - if ( (PLAYER_CLASS_TYPE)var_value == PLAYER_CLASS_LICH ) - { - for (int i = 0; i < 138; i++) - { - if (this->pOwnItems[i].uItemID == ITEM_LICH_JAR_EMPTY) - { - this->pOwnItems[i].uItemID = ITEM_LICH_JAR_FULL; - this->pOwnItems[i].uHolderPlayer = currPlayerId + 1; - } - } - if ( this->sResFireBase < 20 ) - this->sResFireBase = 20; - if ( this->sResAirBase < 20 ) - this->sResAirBase = 20; - if ( this->sResWaterBase < 20 ) - this->sResWaterBase = 20; - if ( this->sResEarthBase < 20 ) - this->sResEarthBase = 20; - this->sResMindBase = 200; - this->sResBodyBase = 200; - v11 = this->GetSexByVoice(); - this->uPrevVoiceID = this->uVoiceID; - this->uPrevFace = this->uCurrentFace; - if ( v11 ) - { - this->uCurrentFace = 21; - this->uVoiceID = 21; - } - else - { - this->uCurrentFace = 20; - this->uVoiceID = 20; - } - ReloadPlayerPortraits(currPlayerId, this->uCurrentFace); - } - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_CurrentHP: - this->sHealth = var_value; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_MaxHP: - this->sHealth = GetMaxHealth(); - return; - case VAR_CurrentSP: - this->sMana = var_value; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_MaxSP: - this->sMana = GetMaxMana(); - return; - case VAR_ACModifier: - this->sACModifier = (unsigned __int8)var_value; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BaseLevel: - this->uLevel = (unsigned __int8)var_value; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_LevelModifier: - this->sLevelModifier = (unsigned __int8)var_value; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_Age: - this->sAgeModifier = var_value; - return; - case VAR_Award: - if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & - this->_achieved_awards_bits[((signed __int16)var_value - 1)/ 8]) - //&& dword_723E80_award_related[2 * a3] ) - && pAwards[var_value].pText ) - { - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - this->PlaySound(SPEECH_96, 0); - } - _449B7E_toggle_bit(this->_achieved_awards_bits, var_value, 1u); - return; - case VAR_Experience: - this->uExperience = var_value; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_QBits_QuestsDone: - if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_quest_bits[((signed __int16)var_value - 1) >> 3]) - // && (&dword_722F10)[4 * a3] ) - && pQuestTable[var_value-1] ) - { - bFlashQuestBook = 1; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - this->PlaySound(SPEECH_93, 0); - } - _449B7E_toggle_bit(pParty->_quest_bits, var_value, 1u); - return; - case VAR_PlayerItemInHands: - item.Reset(); - item.uItemID = var_value; - item.uAttributes = 1; - pParty->SetHoldingItem(&item); - if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER ) - pParty->pIsArtifactFound[var_value-500] = 1; - return; - case VAR_FixedGold: - Party::SetGold(var_value); - return; - case VAR_BaseMight: - this->uMight = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BaseIntellect: - this->uIntelligence = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BasePersonality: - this->uWillpower = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BaseEndurance: - this->uEndurance = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BaseSpeed: - this->uSpeed = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BaseAccuracy: - this->uAccuracy = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BaseLuck: - this->uLuck = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_FixedFood: - Party::SetFood(var_value); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_MightBonus: - goto LABEL_64; - case VAR_IntellectBonus: - goto LABEL_68; - case VAR_PersonalityBonus: - goto LABEL_69; - case VAR_EnduranceBonus: - goto LABEL_70; - case VAR_SpeedBonus: - goto LABEL_71; - case VAR_AccuracyBonus: - goto LABEL_72; - case VAR_LuckBonus: - goto LABEL_73; - default: - return; + bFlashQuestBook = 1; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + this->PlaySound(SPEECH_93, 0); } - } -LABEL_64: - this->uMightBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - } - if ( var_type <= VAR_FireResistanceBonus ) - { - if ( var_type == VAR_FireResistanceBonus ) - { + _449B7E_toggle_bit(pParty->_quest_bits, var_value, 1u); + return; + case VAR_PlayerItemInHands: + item.Reset(); + item.uItemID = var_value; + item.uAttributes = 1; + pParty->SetHoldingItem(&item); + if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER ) + pParty->pIsArtifactFound[var_value-500] = 1; + return; + case VAR_FixedGold: + Party::SetGold(var_value); + return; + case VAR_RandomGold: + v6 = rand() % var_value + 1; + Party::SetGold(v6); + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold + ShowStatusBarString(pTmpBuf.data(), 2u); + GameUI_DrawFoodAndGold(); + return; + case VAR_FixedFood: + Party::SetFood(var_value); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_RandomFood: + v7 = rand() % var_value + 1; + Party::SetFood(v7); + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food + ShowStatusBarString(pTmpBuf.data(), 2u); + GameUI_DrawFoodAndGold(); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BaseMight: + this->uMight = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BaseIntellect: + this->uIntelligence = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BasePersonality: + this->uWillpower = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BaseEndurance: + this->uEndurance = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BaseSpeed: + this->uSpeed = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BaseAccuracy: + this->uAccuracy = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BaseLuck: + this->uLuck = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_MightBonus: + case VAR_ActualMight: + this->uMightBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_IntellectBonus: + case VAR_ActualIntellect: + this->uIntelligenceBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_PersonalityBonus: + case VAR_ActualPersonality: + this->uWillpowerBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_EnduranceBonus: + case VAR_ActualEndurance: + this->uEnduranceBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_SpeedBonus: + case VAR_ActualSpeed: + this->uSpeedBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_AccuracyBonus: + case VAR_ActualAccuracy: + this->uAccuracyBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_LuckBonus: + case VAR_ActualLuck: + this->uLuckBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_FireResistance: + this->sResFireBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_AirResistance: + this->sResAirBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_WaterResistance: + this->sResWaterBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_EarthResistance: + this->sResEarthBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_SpiritResistance: + this->sResSpiritBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_MindResistance: + this->sResMindBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BodyResistance: + this->sResBodyBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_LightResistance: + this->sResLightBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_DarkResistance: + this->sResDarkBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_MagicResistance: + this->sResMagicBase = (unsigned __int8)var_value; + this->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_FireResistanceBonus: this->sResFireBonus = (unsigned __int8)var_value; this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); PlayAwardSound(currPlayerId); return; - } - switch ( var_type ) - { - case VAR_ActualIntellect: -LABEL_68: - this->uIntelligenceBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_ActualPersonality: -LABEL_69: - this->uWillpowerBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_ActualEndurance: -LABEL_70: - this->uEnduranceBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_ActualSpeed: -LABEL_71: - this->uSpeedBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_ActualAccuracy: -LABEL_72: - this->uAccuracyBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_ActualLuck: -LABEL_73: - this->uLuckBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_FireResistance: - this->sResFireBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_AirResistance: - this->sResAirBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_WaterResistance: - this->sResWaterBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_EarthResistance: - this->sResEarthBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_SpiritResistance: - this->sResSpiritBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_MindResistance: - this->sResMindBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_BodyResistance: - this->sResBodyBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_LightResistance: - this->sResLightBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_DarkResistance: - this->sResDarkBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - case VAR_MagicResistance: - this->sResMagicBase = (unsigned __int8)var_value; - this->PlaySound(SPEECH_92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - default: - return; - } - return; - } - HIWORD(v15) = 0; - if ( var_type > VAR_DisarmTrapSkill ) - { - if ( var_type != VAR_LearningSkill ) - { - if ( var_type <= VAR_LearningSkill ) - return; - if ( var_type <= VAR_Eradicated ) - { - this->SetCondition(var_type - 105, 1); - } - else - { - if ( var_type != VAR_MajorCondition ) - { - if ( var_type > VAR_MajorCondition && var_type <= VAR_MapPersistentVariable_99 ) - byte_5E4C15[var_type] = var_value; - return; - } - memset(this, 0, 0xA0u); - } + case VAR_AirResistanceBonus: + this->sResAirBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_WaterResistanceBonus: + this->sResWaterBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_EarthResistanceBonus: + this->sResEarthBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_SpiritResistanceBonus: + this->sResSpiritBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_MindResistanceBonus: + this->sResMindBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_BodyResistanceBonus: + this->sResBodyBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_LightResistanceBonus: + this->sResLightBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_DarkResistanceBonus: + this->sResDarkBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_PhysicalResistanceBonus: + Error("Physical res. bonus not used"); + return; + case VAR_MagicResistanceBonus: + this->sResMagicBonus = (unsigned __int8)var_value; + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Cursed: + this->SetCondition(Condition_Cursed, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Weak: + this->SetCondition(Condition_Weak, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Asleep: + this->SetCondition(Condition_Sleep, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Afraid: + this->SetCondition(Condition_Fear, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Drunk: + this->SetCondition(Condition_Drunk, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Insane: + this->SetCondition(Condition_Insane, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_PoisonedGreen: + this->SetCondition(Condition_Poison1, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_DiseasedGreen: + this->SetCondition(Condition_Disease1, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_PoisonedYellow: + this->SetCondition(Condition_Poison2, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_DiseasedYellow: + this->SetCondition(Condition_Disease2, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_PoisonedRed: + this->SetCondition(Condition_Poison3, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_DiseasedRed: + this->SetCondition(Condition_Disease3, 1); pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); PlayAwardSound(currPlayerId); return; - } - } - else - { - if (var_type != VAR_DisarmTrapSkill) - { - if ( var_type <= VAR_BodyResistanceBonus ) + case VAR_Paralyzed: + this->SetCondition(Condition_Paralyzed, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Unconsious: + this->SetCondition(Condition_Unconcious, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Dead: + this->SetCondition(Condition_Dead, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Stoned: + this->SetCondition(Condition_Pertified, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_Eradicated: + this->SetCondition(Condition_Eradicated, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_MajorCondition: + memset(this, 0, 0xA0u); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; + case VAR_AutoNotes: + if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_autonote_bits[((signed __int16)var_value - 1) >> 3]) //&& (&dword_723718_autonote_related)[8 * a3] ) + && pAutonoteTxt[var_value-1].pText ) { - switch ( var_type ) - { - case VAR_BodyResistanceBonus: - this->sResBodyBonus = (unsigned __int8)var_value; - break; - case VAR_AirResistanceBonus: - this->sResAirBonus = (unsigned __int8)var_value; - break; - case VAR_WaterResistanceBonus: - this->sResWaterBonus = (unsigned __int8)var_value; - break; - case VAR_EarthResistanceBonus: - this->sResEarthBonus = (unsigned __int8)var_value; - break; - case VAR_SpiritResistanceBonus: - this->sResSpiritBonus = (unsigned __int8)var_value; - break; - default: - if ( var_type != 62 ) - return; - this->sResMindBonus = (unsigned __int8)var_value; - break; - } - this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; + this->PlaySound(SPEECH_96, 0); + bFlashAutonotesBook = 1; + _506568_autonote_type = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3]; } - if ( var_type == VAR_LightResistanceBonus ) - { - this->sResLightBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - } - if ( var_type == VAR_DarkResistanceBonus ) - { - this->sResDarkBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - } - if ( var_type == VAR_MagicResistanceBonus ) - { - this->sResMagicBonus = (unsigned __int8)var_value; - this->PlaySound(SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; - } - if ( var_type <= VAR_MagicResistanceBonus || var_type > VAR_DiplomacySkill ) - return; - } + _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u); + PlayAwardSound(currPlayerId); + return; + case VAR_PlayerBits: + _449B7E_toggle_bit((unsigned char *)field_1A50, var_value, 1u); + return; + case VAR_NPCs2: + pParty->field_709 = 0; + LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; + return; + case VAR_NumSkillPoints: + this->uSkillPoints = var_value; + return; + case VAR_Counter1: + case VAR_Counter2: + case VAR_Counter3: + case VAR_Counter4: + case VAR_Counter5: + case VAR_Counter6: + case VAR_Counter7: + case VAR_Counter8: + case VAR_Counter9: + case VAR_Counter10: + pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; // *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed);*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed); + return; + case VAR_ReputationInCurrentLocation: + v24 = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) + v24 = &pIndoor->dlv; + v24->uReputation = var_value; + if ( var_value > 10000 ) + v24->uReputation = 10000; + return; + case VAR_GoldInBank: + pParty->uNumGoldInBank = var_value; + return; + case VAR_NumDeaths: + pParty->uNumDeaths = var_value; + return; + case VAR_NumBounties: + pParty->uNumBountiesCollected = var_value; + return; + case VAR_PrisonTerms: + pParty->uNumPrisonTerms = var_value; + return; + case VAR_ArenaWinsPage: + pParty->uNumArenaPageWins = var_value; + return; + case VAR_ArenaWinsSquire: + pParty->uNumArenaSquireWins = var_value; + return; + case VAR_ArenaWinsKnight: + pParty->uNumArenaKnightWins = var_value; + return; + case VAR_ArenaWinsLord: + pParty->uNumArenaLordWins = var_value; + return; + } + + if (var_type >= VAR_StaffSkill && var_type <= VAR_LearningSkill) + { + HIWORD(v15) = 0; + + v16 = (int)((char *)&this->pConditions[16] + 2 * var_type); + v17 = *(char *)v16; + if ( var_value <= 63 ) + { + LOWORD(v15) = (unsigned __int8)var_value; + v18 = v15 | v17 & 63; + } + else + { + LOWORD(v18) = (unsigned __int8)(var_value | v17 & 0xC0); + } + *(short *)v16 = v18; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + return; } - v16 = (int)((char *)&this->pConditions[16] + 2 * var_type); - v17 = *(char *)v16; - if ( var_value <= 63 ) - { - LOWORD(v15) = (unsigned __int8)var_value; - v18 = v15 | v17 & 63; - } - else - { - LOWORD(v18) = (unsigned __int8)(var_value | v17 & 0xC0); - } - *(short *)v16 = v18; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); - return; } @@ -5997,6 +6013,21 @@ pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); } +void Player::SetSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 newSkillValue, int currPlayerId ) +{ + unsigned __int16 currSkillValue = this->*skillToSet; + if ( newSkillValue > 63 ) //the original had the condition reversed which was probably wrong + { + this->*skillToSet = newSkillValue | currSkillValue & 63; + } + else + { + this->*skillToSet = newSkillValue | currSkillValue & 0xC0; + } + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); +} + //----- (0044AFFB) -------------------------------------------------------- void Player::AddVariable(enum VariableType var_type, signed int val) {