Mercurial > mm7
changeset 1785:644d10ad682e
Слияние
author | Ritor1 |
---|---|
date | Thu, 03 Oct 2013 18:08:18 +0600 |
parents | d73f4668ef94 (current diff) a3e86ec5d3ce (diff) |
children | 11f36943e818 |
files | mm7_data.h |
diffstat | 5 files changed, 733 insertions(+), 651 deletions(-) [+] |
line wrap: on
line diff
--- a/Items.h Thu Oct 03 18:07:55 2013 +0600 +++ b/Items.h Thu Oct 03 18:08:18 2013 +0600 @@ -192,13 +192,13 @@ typedef struct CEnchantment { + unsigned __int16 Player::* statPtr; + int statBonus; CEnchantment(int bonus, unsigned __int16 Player::* skillPtr = NULL): -statBonus(bonus), + statBonus(bonus), statPtr(skillPtr) -{ -} -int statBonus; -unsigned __int16 Player::* statPtr; + { + } } CEnchantment; /* 64 */
--- a/Player.cpp Thu Oct 03 18:07:55 2013 +0600 +++ b/Player.cpp Thu Oct 03 18:08:18 2013 +0600 @@ -297,7 +297,7 @@ { baseConditionMultiplier = 5; } - if ( conditionIdx == 16 ) + else //if ( conditionIdx == 16 ) { baseConditionMultiplier = 10; } @@ -900,8 +900,6 @@ //----- (004927A8) -------------------------------------------------------- int Player::AddItem(int index, unsigned int uItemID) { - int xStartValue = 0; - if ( index == -1 ) { for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) @@ -1142,7 +1140,6 @@ { unsigned __int16 v2; // ax@1 int v5; // edi@7 - return true; if (CheckHiredNPCSpeciality(Scholar)) return true; @@ -2098,7 +2095,7 @@ fineIfFailed = actroPtr->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); currMaxItemValue = v29 + v7 * v30; pGlobalTXT_LocalizationStrings[200]; - if ( false && (rand() % 100 < 5 || fineIfFailed > currMaxItemValue || BYTE2(actroPtr->uAttributes) & 8) ) + if ( rand() % 100 < 5 || fineIfFailed > currMaxItemValue || BYTE2(actroPtr->uAttributes) & 8 ) { Actor::AggroSurroundingPeasants(uActorID, 1); sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[376], this->pName); @@ -2279,6 +2276,7 @@ v4 = 0; v47 = 0; + v48 = nullptr; switch ( attTypeCast ) { case SPECIAL_ATTACK_CURSE: @@ -2873,6 +2871,8 @@ if (IsRaceHuman()) racialBonus = 5; break; + default: + Error("Unknown attribute"); } v7 = GetItemsBonus(a2) + racialBonus; return v7 + *resStat; @@ -2899,25 +2899,26 @@ v10 += leatherArmorSkillLevel & 0x3F; switch (a2) { - case CHARACTER_ATTRIBUTE_RESIST_FIRE: - resStat = &sResFireBonus; - break; - case CHARACTER_ATTRIBUTE_RESIST_AIR: - resStat = &sResAirBonus; - break; - case CHARACTER_ATTRIBUTE_RESIST_WATER: - resStat = &sResWaterBonus; - break; - case CHARACTER_ATTRIBUTE_RESIST_EARTH: - resStat = &sResEarthBonus; - break; - case CHARACTER_ATTRIBUTE_RESIST_MIND: - resStat = &sResMindBonus; - break; - case CHARACTER_ATTRIBUTE_RESIST_BODY: - case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: - resStat = &sResBodyBonus; - break; + case CHARACTER_ATTRIBUTE_RESIST_FIRE: + resStat = &sResFireBonus; + break; + case CHARACTER_ATTRIBUTE_RESIST_AIR: + resStat = &sResAirBonus; + break; + case CHARACTER_ATTRIBUTE_RESIST_WATER: + resStat = &sResWaterBonus; + break; + case CHARACTER_ATTRIBUTE_RESIST_EARTH: + resStat = &sResEarthBonus; + break; + case CHARACTER_ATTRIBUTE_RESIST_MIND: + resStat = &sResMindBonus; + break; + case CHARACTER_ATTRIBUTE_RESIST_BODY: + case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: + resStat = &sResBodyBonus; + break; + default: Error("Unexpected attribute"); } baseRes = GetBaseResistance(a2); result = v10 + GetMagicalBonus(a2) + baseRes + *(resStat); @@ -4295,6 +4296,7 @@ case 4: attribute_value = uAccuracy; break; case 5: attribute_value = uSpeed; break; case 6: attribute_value = uLuck; break; + default: Error("Unexpected attribute"); }; if (attribute_value == base_attribute_value) @@ -4911,6 +4913,8 @@ playerAffected->sResBodyBase += thisa; v13 = pGlobalTXT_LocalizationStrings[29]; break; + default: ("Unexpected attribute"); + return; } sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]); break; @@ -5008,140 +5012,14 @@ int actStat; // ebx@161 int baseStat; // eax@161 - if ( VarNum > VAR_AutoNotes ) - { - switch ( VarNum ) - { - case VAR_AutoNotes : //TODO: find out why the double subtraction. or whether this is even used - test_bit_value = 0x80u >> (pValue - 2) % 8; - byteWithRequestedBit = pParty->_autonote_bits[(pValue - 2) /8]; - return (test_bit_value & byteWithRequestedBit) != 0; - case VAR_IsMightMoreThanBase: - actStat = GetActualMight(); - baseStat = GetBaseStrength(); - return (actStat >= baseStat); - case VAR_IsIntellectMoreThanBase: - actStat = GetActualIntelligence(); - baseStat = GetBaseIntelligence(); - return (actStat >= baseStat); - case VAR_IsPersonalityMoreThanBase: - actStat = GetActualWillpower(); - baseStat = GetBaseWillpower(); - return (actStat >= baseStat); - case VAR_IsEnduranceMoreThanBase: - actStat = GetActualEndurance(); - baseStat = GetBaseEndurance(); - return (actStat >= baseStat); - case VAR_IsSpeedMoreThanBase: - actStat = GetActualSpeed(); - baseStat = GetBaseSpeed(); - return (actStat >= baseStat); - case VAR_IsAccuracyMoreThanBase: - actStat = GetActualAccuracy(); - baseStat = GetBaseAccuracy(); - return (actStat >= baseStat); - case VAR_IsLuckMoreThanBase: - actStat = GetActualLuck(); - baseStat = GetBaseLuck(); - return (actStat >= baseStat); - case VAR_PlayerBits: - test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; - byteWithRequestedBit = this->field_1A50[((signed __int16)pValue - 1)/8]; - return ( test_bit_value & byteWithRequestedBit ) != 0; - case VAR_NPCs2: - return pNPCStats->pNewNPCData[pValue].Hired(); - case VAR_IsFlying: - if ( pParty->bFlying - && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) ) - return true; - return false; - case VAR_HiredNPCHasSpeciality: - return CheckHiredNPCSpeciality(pValue); - case VAR_CircusPrises: //isn't used in MM6 since 0x1D6u is a book of regeneration - v4 = 0; - for (int playerNum = 0; playerNum < 4; playerNum++) - { - for (int invPos = 0; invPos < 138; invPos++) - { - int itemId = pParty->pPlayers[playerNum].pInventoryItemList[invPos].uItemID; - switch ( itemId ) - { - case 0x1D6u: - ++v4; - break; - case 0x1D7u: - v4 += 3; - break; - case 0x1DDu: - v4 += 5; - break; - } - } - } - return v4 >= pValue; - case VAR_NumSkillPoints: - return this->uSkillPoints >= (unsigned int)pValue; - case VAR_MonthIs: - return (pParty->uCurrentMonth == (unsigned int)pValue); - 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: - if (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1]) //originally (signed __int64)(__PAIR__(*(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44304], *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44300]) - { - return (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1] + 460800 * pValue * 0.033333335) <= pParty->uTimePlayed ; - } - case VAR_ReputationInCurrentLocation: - v19 = &pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) - v19 = &pIndoor->dlv; - return (v19->uReputation >= pValue); - case VAR_Unknown1: - v21 = &pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) - v21 = &pIndoor->dlv; - return (v21->field_C_alert == pValue); //yes, equality, not >= - case VAR_GoldInBank: - return pParty->uNumGoldInBank >= (unsigned int)pValue; - case VAR_NumDeaths: - return pParty->uNumDeaths >= (unsigned int)pValue; - case VAR_NumBounties: - return pParty->uNumBountiesCollected >= (unsigned int)pValue; - case VAR_PrisonTerms: - return pParty->uNumPrisonTerms >= pValue; - case VAR_ArenaWinsPage: - return (unsigned __int8)pParty->uNumArenaPageWins >= pValue; - case VAR_ArenaWinsSquire: - return (unsigned __int8)pParty->uNumArenaSquireWins >= pValue; - case VAR_ArenaWinsKnight: - return (unsigned __int8)pParty->uNumArenaKnightWins >= pValue; - case VAR_ArenaWinsLord: - return pParty->uNumArenaLordWins >= pValue; - case VAR_Invisible: - return ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ); - case VAR_ItemEquipped: - for (int i = 0; i < 16; i++) - { - if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uItemID == pValue ) - { - return true; - } - } - return false; - default: - return false; - } - } - if ( VarNum <= VAR_MajorCondition ) - { - switch ( VarNum ) - { + + if ( (signed int)VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 ) + return (unsigned __int8)stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] > 0; // originally (unsigned __int8)byte_5E4C15[VarNum]; + if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 ) + 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 + + switch ( VarNum ) + { case VAR_Sex: return ( pValue == this->uSex ); case VAR_Class: @@ -5167,15 +5045,11 @@ case VAR_Age: return GetActualAge() >= (unsigned int)pValue; case VAR_Award: - test_bit_value = 0x80u >> (pValue - 1) % 8; - byteWithRequestedBit = this->_achieved_awards_bits[(pValue - 1) /8]; - return ( test_bit_value & byteWithRequestedBit ) != 0; + return _449B57_test_bit(this->_achieved_awards_bits, pValue); case VAR_Experience: return this->uExperience >= pValue; //TODO change pValue to long long case VAR_QBits_QuestsDone: - test_bit_value = 0x80u >> (pValue - 1) % 8; - byteWithRequestedBit = pParty->_quest_bits[(pValue - 1)/8]; - return ( test_bit_value & byteWithRequestedBit ) != 0; + return _449B57_test_bit(pParty->_quest_bits, pValue); case VAR_PlayerItemInHands: for (int i = 0; i < 138; i++) { @@ -5402,13 +5276,130 @@ return v4 >= pValue; } return true; - } - } - if ( (signed int)VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 ) - return (unsigned __int8)stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] > 0; // originally (unsigned __int8)byte_5E4C15[VarNum]; - if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 ) - 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 - + case VAR_AutoNotes : //TODO: find out why the double subtraction. or whether this is even used + test_bit_value = 0x80u >> (pValue - 2) % 8; + byteWithRequestedBit = pParty->_autonote_bits[(pValue - 2) /8]; + return (test_bit_value & byteWithRequestedBit) != 0; + case VAR_IsMightMoreThanBase: + actStat = GetActualMight(); + baseStat = GetBaseStrength(); + return (actStat >= baseStat); + case VAR_IsIntellectMoreThanBase: + actStat = GetActualIntelligence(); + baseStat = GetBaseIntelligence(); + return (actStat >= baseStat); + case VAR_IsPersonalityMoreThanBase: + actStat = GetActualWillpower(); + baseStat = GetBaseWillpower(); + return (actStat >= baseStat); + case VAR_IsEnduranceMoreThanBase: + actStat = GetActualEndurance(); + baseStat = GetBaseEndurance(); + return (actStat >= baseStat); + case VAR_IsSpeedMoreThanBase: + actStat = GetActualSpeed(); + baseStat = GetBaseSpeed(); + return (actStat >= baseStat); + case VAR_IsAccuracyMoreThanBase: + actStat = GetActualAccuracy(); + baseStat = GetBaseAccuracy(); + return (actStat >= baseStat); + case VAR_IsLuckMoreThanBase: + actStat = GetActualLuck(); + baseStat = GetBaseLuck(); + return (actStat >= baseStat); + case VAR_PlayerBits: + test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; + byteWithRequestedBit = this->field_1A50[((signed __int16)pValue - 1)/8]; + return ( test_bit_value & byteWithRequestedBit ) != 0; + case VAR_NPCs2: + return pNPCStats->pNewNPCData[pValue].Hired(); + case VAR_IsFlying: + if ( pParty->bFlying + && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) ) + return true; + return false; + case VAR_HiredNPCHasSpeciality: + return CheckHiredNPCSpeciality(pValue); + case VAR_CircusPrises: //isn't used in MM6 since 0x1D6u is a book of regeneration + v4 = 0; + for (int playerNum = 0; playerNum < 4; playerNum++) + { + for (int invPos = 0; invPos < 138; invPos++) + { + int itemId = pParty->pPlayers[playerNum].pInventoryItemList[invPos].uItemID; + switch ( itemId ) + { + case 0x1D6u: + ++v4; + break; + case 0x1D7u: + v4 += 3; + break; + case 0x1DDu: + v4 += 5; + break; + } + } + } + return v4 >= pValue; + case VAR_NumSkillPoints: + return this->uSkillPoints >= (unsigned int)pValue; + case VAR_MonthIs: + return (pParty->uCurrentMonth == (unsigned int)pValue); + 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: + if (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1]) //originally (signed __int64)(__PAIR__(*(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44304], *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44300]) + { + return (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1] + 460800 * pValue * 0.033333335) <= pParty->uTimePlayed ; + } + case VAR_ReputationInCurrentLocation: + v19 = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) + v19 = &pIndoor->dlv; + return (v19->uReputation >= pValue); + case VAR_Unknown1: + v21 = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) + v21 = &pIndoor->dlv; + return (v21->field_C_alert == pValue); //yes, equality, not >= + case VAR_GoldInBank: + return pParty->uNumGoldInBank >= (unsigned int)pValue; + case VAR_NumDeaths: + return pParty->uNumDeaths >= (unsigned int)pValue; + case VAR_NumBounties: + return pParty->uNumBountiesCollected >= (unsigned int)pValue; + case VAR_PrisonTerms: + return pParty->uNumPrisonTerms >= pValue; + case VAR_ArenaWinsPage: + return (unsigned __int8)pParty->uNumArenaPageWins >= pValue; + case VAR_ArenaWinsSquire: + return (unsigned __int8)pParty->uNumArenaSquireWins >= pValue; + case VAR_ArenaWinsKnight: + return (unsigned __int8)pParty->uNumArenaKnightWins >= pValue; + case VAR_ArenaWinsLord: + return pParty->uNumArenaLordWins >= pValue; + case VAR_Invisible: + return ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ); + case VAR_ItemEquipped: + for (int i = 0; i < 16; i++) + { + if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uItemID == pValue ) + { + return true; + } + } + return false; + } + return false; } @@ -5417,513 +5408,576 @@ void Player::SetVariable(enum VariableType var_type, signed int var_value) { signed int currPlayerId; // ebx@1 - Player *v4_unused; // esi@1 - unsigned int v5_unused; // edi@1 unsigned int v6; // esi@13 unsigned int v7; // esi@14 - signed int v8_unused; // eax@17 - ItemGen *v9; // ecx@17 - int v10; // eax@21 signed int v11; // eax@30 - Player *unused12; // ecx@44 - char *v13; // ecx@45 - Player *v14; // ecx@49 - int v15; // ecx@86 - int v16; // esi@106 - char v17; // al@106 - int v18; // eax@107 - Player *v19; // ecx@112 - Player *v20; // ecx@127 - int v21; // eax@127 - int v22; // eax@145 - char v23; // zf@146 DDM_DLV_Header *v24; // ecx@148 - signed int v25; // eax@172 - int v26; // [sp-8h] [bp-3Ch]@84 - signed int unused27; // [sp-4h] [bp-38h]@4 - int v28_unused; // [sp-4h] [bp-38h]@84 ItemGen item; // [sp+Ch] [bp-28h]@52 - char v30_unused; // [sp+32h] [bp-2h]@1 - char v31_unused; // [sp+33h] [bp-1h]@1 - - currPlayerId = -1; - for (int i = 1; i <= 4; i++) //TODO: add a member variable for playerid in the future - { - if ( this == pPlayers[i] ) - { - currPlayerId = i - 1; - break; - } - } - - Assert(currPlayerId != -1); - if ( var_type > VAR_AutoNotes ) - { - if ( var_type <= VAR_GoldInBank ) - { - if ( var_type == VAR_GoldInBank ) + + currPlayerId = 0; + if ( this == pPlayers[2] ) + currPlayerId = 1; + else if ( this == pPlayers[3] ) + currPlayerId = 2; + else if ( this == pPlayers[4] ) + currPlayerId = 3; + + + 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; + PlayAwardSound_Anim(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); + 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); - break; - case VAR_NPCs2: - pParty->field_709 = 0; - LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u; - pParty->CountHirelings(); - viewparams->bRedrawGameUI = true; - break; - case VAR_NumSkillPoints: - this->uSkillPoints = var_value; - break; - } + this->uCurrentFace = 20; + this->uVoiceID = 20; } - return; + ReloadPlayerPortraits(currPlayerId, this->uCurrentFace); } - if ( var_type <= VAR_Counter10 ) - return; - if ( (signed int)var_type <= VAR_UnknownTimeEvent19 ) + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_CurrentHP: + this->sHealth = var_value; + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_MaxHP: + this->sHealth = GetMaxHealth(); + return; + case VAR_CurrentSP: + this->sMana = var_value; + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_MaxSP: + this->sMana = GetMaxMana(); + return; + case VAR_ACModifier: + this->sACModifier = (unsigned __int8)var_value; + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_BaseLevel: + this->uLevel = (unsigned __int8)var_value; + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_LevelModifier: + this->sLevelModifier = (unsigned __int8)var_value; + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Age: + this->sAgeModifier = var_value; + return; + case VAR_Award: + if ( !_449B57_test_bit(this->_achieved_awards_bits, var_value) && pAwards[var_value].pText ) { - 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_Anim(currPlayerId); + this->PlaySound(SPEECH_96, 0); } - else + _449B7E_toggle_bit(this->_achieved_awards_bits, var_value, 1u); + return; + case VAR_Experience: + this->uExperience = var_value; + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_QBits_QuestsDone: + if ( !_449B57_test_bit(pParty->_quest_bits, var_value) && pQuestTable[var_value-1] ) { - 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_ReputationInCurrentLocation - || var_type > VAR_History_28 - || (v22 = var_type - VAR_History_0, pParty->PartyTimes.HistoryEventTimes[v22]) - || (pParty->PartyTimes.HistoryEventTimes[v22] = pParty->uTimePlayed, - pStorylineText->StoreLine[v22].pText == 0) )//*(&pStorylineText->field_0 + 3 * v22) == 0, - return; - bFlashHistoryBook = 1; + bFlashQuestBook = 1; + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); + this->PlaySound(SPEECH_93, 0); } - v25 = 8 * currPlayerId + 400; - LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); - pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); - return; - } - switch ( var_type ) - { + _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); + PlayAwardSound_Anim(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(); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_BaseMight: + this->uMight = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_BaseIntellect: + this->uIntelligence = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_BasePersonality: + this->uWillpower = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_BaseEndurance: + this->uEndurance = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_BaseSpeed: + this->uSpeed = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_BaseAccuracy: + this->uAccuracy = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_BaseLuck: + this->uLuck = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_MightBonus: + case VAR_ActualMight: + this->uMightBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_IntellectBonus: + case VAR_ActualIntellect: + this->uIntelligenceBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_PersonalityBonus: + case VAR_ActualPersonality: + this->uWillpowerBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_EnduranceBonus: + case VAR_ActualEndurance: + this->uEnduranceBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_SpeedBonus: + case VAR_ActualSpeed: + this->uSpeedBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_AccuracyBonus: + case VAR_ActualAccuracy: + this->uAccuracyBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_LuckBonus: + case VAR_ActualLuck: + this->uLuckBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_FireResistance: + this->sResFireBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_AirResistance: + this->sResAirBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_WaterResistance: + this->sResWaterBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_EarthResistance: + this->sResEarthBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_SpiritResistance: + this->sResSpiritBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_MindResistance: + this->sResMindBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_BodyResistance: + this->sResBodyBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_LightResistance: + this->sResLightBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_DarkResistance: + this->sResDarkBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_MagicResistance: + this->sResMagicBase = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + return; + case VAR_FireResistanceBonus: + this->sResFireBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_AirResistanceBonus: + this->sResAirBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_WaterResistanceBonus: + this->sResWaterBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_EarthResistanceBonus: + this->sResEarthBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_SpiritResistanceBonus: + this->sResSpiritBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_MindResistanceBonus: + this->sResMindBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_BodyResistanceBonus: + this->sResBodyBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_LightResistanceBonus: + this->sResLightBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_DarkResistanceBonus: + this->sResDarkBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_PhysicalResistanceBonus: + Error("Physical res. bonus not used"); + return; + case VAR_MagicResistanceBonus: + this->sResMagicBonus = (unsigned __int8)var_value; + PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + return; + case VAR_Cursed: + this->SetCondition(Condition_Cursed, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Weak: + this->SetCondition(Condition_Weak, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Asleep: + this->SetCondition(Condition_Sleep, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Afraid: + this->SetCondition(Condition_Fear, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Drunk: + this->SetCondition(Condition_Drunk, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Insane: + this->SetCondition(Condition_Insane, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_PoisonedGreen: + this->SetCondition(Condition_Poison1, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_DiseasedGreen: + this->SetCondition(Condition_Disease1, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_PoisonedYellow: + this->SetCondition(Condition_Poison2, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_DiseasedYellow: + this->SetCondition(Condition_Disease2, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_PoisonedRed: + this->SetCondition(Condition_Poison3, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_DiseasedRed: + this->SetCondition(Condition_Disease3, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Paralyzed: + this->SetCondition(Condition_Paralyzed, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Unconsious: + this->SetCondition(Condition_Unconcious, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Dead: + this->SetCondition(Condition_Dead, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Stoned: + this->SetCondition(Condition_Pertified, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_Eradicated: + this->SetCondition(Condition_Eradicated, 1); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_MajorCondition: + memset(this, 0, 0xA0u); + PlayAwardSound_Anim(currPlayerId); + return; + case VAR_AutoNotes: + if ( !_449B57_test_bit(pParty->_autonote_bits, var_value) && pAutonoteTxt[var_value-1].pText ) + { + 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; + 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; - break; + return; case VAR_NumBounties: pParty->uNumBountiesCollected = var_value; - break; + return; case VAR_PrisonTerms: pParty->uNumPrisonTerms = var_value; - break; + return; case VAR_ArenaWinsPage: pParty->uNumArenaPageWins = var_value; - break; + return; case VAR_ArenaWinsSquire: pParty->uNumArenaSquireWins = var_value; - break; + return; case VAR_ArenaWinsKnight: pParty->uNumArenaKnightWins = var_value; - break; + return; case VAR_ArenaWinsLord: pParty->uNumArenaLordWins = var_value; - break; - } - 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].pText ) - { - v20 = pPlayers[currPlayerId + 1]; - v20->PlaySound(SPEECH_96, 0); - //v21 = pAutonoteTxt[var_value].eType;// dword_72371C[2 * a3]; - bFlashAutonotesBook = 1; - _506568_autonote_type = pAutonoteTxt[var_value].eType; - DrawPlayerBuffAnimBasedOnCondition(currPlayerId); - } - _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1); - PlaySoundBasedOnCondition(currPlayerId); - return; - } - if ( var_type <= VAR_BaseLuck ) - { - switch ( var_type ) - { - case VAR_Sex: - this->uSex = (PLAYER_SEX)var_value; - goto LABEL_124; - case VAR_Class: - this->classType = (PLAYER_CLASS_TYPE)var_value; - if ( (char)var_value == PLAYER_CLASS_LICH ) - { - for (int i = 0; i < 138; i++) - { - v9 = &this->pInventoryItemList[i]; - if (v9->uItemID == ITEM_LICH_JAR_EMPTY) - { - v9->uItemID = ITEM_LICH_JAR_FULL; - v9->uHolderPlayer = currPlayerId + 1; - v10 = (int)((char *)this + 36 * 138); - *(int *)(v10 + 532) = 601; - *(char *)(v10 + 558) = currPlayerId + 1; - break; - } - } - 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; - this->uPrevVoiceID = this->uVoiceID; - this->uPrevFace = this->uCurrentFace; - if ( IsFemale() ) - { - this->uCurrentFace = 21; - this->uVoiceID = 21; - } - else - { - this->uCurrentFace = 20; - this->uVoiceID = 20; - } - ReloadPlayerPortraits(currPlayerId, this->uCurrentFace); - } - goto LABEL_124; - case VAR_CurrentHP: - this->sHealth = var_value; - goto LABEL_124; - case VAR_MaxHP: - this->sHealth = GetMaxHealth(); - return; - case VAR_CurrentSP: - this->sMana = var_value; - goto LABEL_124; - case VAR_MaxSP: - this->sMana = GetMaxMana(); - return; - case VAR_ACModifier: - this->sACModifier = (unsigned __int8)var_value; - goto LABEL_124; - case VAR_BaseLevel: - this->uLevel = (unsigned __int8)var_value; - goto LABEL_124; - case VAR_LevelModifier: - this->sLevelModifier = (unsigned __int8)var_value; - goto LABEL_124; - case VAR_Age: - this->sAgeModifier = var_value; - return; - case VAR_Award: - if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & - pPlayers[currPlayerId + 1]->_achieved_awards_bits[((signed __int16)var_value - 1)/ 8]) - //&& dword_723E80_award_related[2 * a3] ) - && pAwards[var_value].pText ) - { - pPlayers[currPlayerId + 1]->PlaySound(SPEECH_96, 0); - DrawPlayerBuffAnimBasedOnCondition(currPlayerId); - PlaySoundBasedOnCondition(currPlayerId); - } - _449B7E_toggle_bit((unsigned char *)this->_achieved_awards_bits, var_value, 1u); - return; - case VAR_Experience: - this->uExperience = var_value; - goto LABEL_124; - 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] ) - { - v14 = pPlayers[currPlayerId + 1]; - bFlashQuestBook = 1; - v14->PlaySound(SPEECH_93, 0); - DrawPlayerBuffAnimBasedOnCondition(currPlayerId); - PlaySoundBasedOnCondition(currPlayerId); - } - v13 = (char *)pParty->_quest_bits; - _449B7E_toggle_bit((unsigned char *)v13, var_value, 1u); - return; - case VAR_PlayerItemInHands: - item.Reset(); - 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); - goto LABEL_124; - 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(); - goto LABEL_124; - 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; - case VAR_BaseMight: - this->uMight = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_BaseIntellect: - this->uIntelligence = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_BasePersonality: - this->uWillpower = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_BaseEndurance: - this->uEndurance = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_BaseSpeed: - this->uSpeed = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_BaseAccuracy: - this->uAccuracy = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_BaseLuck: - this->uLuck = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - default: - return; - } -LABEL_111: - v26 = SPEECH_91; -LABEL_112: - v19 = pPlayers[currPlayerId + 1]; - v19->PlaySound((PlayerSpeech)v26, 0); - DrawPlayerBuffAnimBasedOnCondition(currPlayerId); - PlaySoundBasedOnCondition(currPlayerId); - return; - } - if ( var_type <= VAR_MagicResistance ) - { - switch ( var_type ) - { - case VAR_ActualMight: -LABEL_64: - this->uMightBonus = (unsigned __int8)var_value; - goto LABEL_111; - case VAR_ActualIntellect: -LABEL_68: - this->uIntelligenceBonus = (unsigned __int8)var_value; - goto LABEL_111; - case VAR_ActualPersonality: -LABEL_69: - this->uWillpowerBonus = (unsigned __int8)var_value; - goto LABEL_111; - case VAR_ActualEndurance: -LABEL_70: - this->uEnduranceBonus = (unsigned __int8)var_value; - goto LABEL_111; - case VAR_ActualSpeed: -LABEL_71: - this->uSpeedBonus = (unsigned __int8)var_value; - goto LABEL_111; - case VAR_ActualAccuracy: -LABEL_72: - this->uAccuracyBonus = (unsigned __int8)var_value; - goto LABEL_111; - case VAR_ActualLuck: -LABEL_73: - this->uLuckBonus = (unsigned __int8)var_value; - goto LABEL_111; - case VAR_FireResistance: - this->sResFireBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_AirResistance: - this->sResAirBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_WaterResistance: - this->sResWaterBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_EarthResistance: - this->sResEarthBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_SpiritResistance: - this->sResSpiritBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_MindResistance: - this->sResMindBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_BodyResistance: - this->sResBodyBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_LightResistance: - this->sResLightBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_DarkResistance: - this->sResDarkBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - case VAR_MagicResistance: - this->sResMagicBase = (unsigned __int8)var_value; - v26 = 92; - goto LABEL_112; - 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); - } - } - else - { - 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; - } -LABEL_124: - DrawPlayerBuffAnimBasedOnCondition(currPlayerId); - PlaySoundBasedOnCondition(currPlayerId); - return; - } - if ( var_type <= VAR_MagicResistanceBonus ) - { - switch ( var_type ) - { - case VAR_FireResistanceBonus: - this->sResFireBonus = (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; - case VAR_MindResistanceBonus: - this->sResMindBonus = (unsigned __int8)var_value; - break; - case VAR_BodyResistanceBonus: - this->sResBodyBonus = (unsigned __int8)var_value; - break; - case VAR_LightResistanceBonus: - this->sResLightBonus = (unsigned __int8)var_value; - break; - case VAR_DarkResistanceBonus: - this->sResDarkBonus = (unsigned __int8)var_value; - break; - case VAR_PhysicalResistanceBonus: - Assert("VAR_PhysicalResistanceBonus variable unsupported" && false); - return; - break; - case VAR_MagicResistanceBonus: - this->sResMagicBonus = (unsigned __int8)var_value; - break; - default: - Error("Unexpected var_type: %u", var_type); - return; - break; - } - goto LABEL_111; - } - if ( var_type > VAR_MagicResistanceBonus && var_type <= VAR_DiplomacySkill || var_type == VAR_DisarmTrapSkill) //VAR_ThieverySkill wasn't present in the original function - { - return; + return; + case VAR_StaffSkill: + SetSkillByEvent(&Player::skillStaff, var_type, currPlayerId); + return; + case VAR_SwordSkill: + SetSkillByEvent(&Player::skillSword, var_type, currPlayerId); + return; + case VAR_DaggerSkill: + SetSkillByEvent(&Player::skillDagger, var_type, currPlayerId); + return; + case VAR_AxeSkill: + SetSkillByEvent(&Player::skillAxe, var_type, currPlayerId); + return; + case VAR_SpearSkill: + SetSkillByEvent(&Player::skillSpear, var_type, currPlayerId); + return; + case VAR_BowSkill: + SetSkillByEvent(&Player::skillBow, var_type, currPlayerId); + return; + case VAR_MaceSkill: + SetSkillByEvent(&Player::skillMace, var_type, currPlayerId); + return; + case VAR_BlasterSkill: + SetSkillByEvent(&Player::skillBlaster, var_type, currPlayerId); + return; + case VAR_ShieldSkill: + SetSkillByEvent(&Player::skillShield, var_type, currPlayerId); + return; + case VAR_LeatherSkill: + SetSkillByEvent(&Player::skillLeather, var_type, currPlayerId); + return; + case VAR_SkillChain: + SetSkillByEvent(&Player::skillChain, var_type, currPlayerId); + return; + case VAR_PlateSkill: + SetSkillByEvent(&Player::skillPlate, var_type, currPlayerId); + return; + case VAR_FireSkill: + SetSkillByEvent(&Player::skillFire, var_type, currPlayerId); + return; + case VAR_AirSkill: + SetSkillByEvent(&Player::skillAir, var_type, currPlayerId); + return; + case VAR_WaterSkill: + SetSkillByEvent(&Player::skillWater, var_type, currPlayerId); + return; + case VAR_EarthSkill: + SetSkillByEvent(&Player::skillEarth, var_type, currPlayerId); + return; + case VAR_SpiritSkill: + SetSkillByEvent(&Player::skillSpirit, var_type, currPlayerId); + return; + case VAR_MindSkill: + SetSkillByEvent(&Player::skillMind, var_type, currPlayerId); + return; + case VAR_BodySkill: + SetSkillByEvent(&Player::skillBody, var_type, currPlayerId); + return; + case VAR_LightSkill: + SetSkillByEvent(&Player::skillLight, var_type, currPlayerId); + return; + case VAR_DarkSkill: + SetSkillByEvent(&Player::skillDark, var_type, currPlayerId); + return; + case VAR_IdentifyItemSkill: + SetSkillByEvent(&Player::skillItemId, var_type, currPlayerId); + return; + case VAR_MerchantSkill: + SetSkillByEvent(&Player::skillMerchant, var_type, currPlayerId); + return; + case VAR_RepairSkill: + SetSkillByEvent(&Player::skillRepair, var_type, currPlayerId); + return; + case VAR_BodybuildingSkill: + SetSkillByEvent(&Player::skillBodybuilding, var_type, currPlayerId); + return; + case VAR_MeditationSkill: + SetSkillByEvent(&Player::skillMeditation, var_type, currPlayerId); + return; + case VAR_PerceptionSkill: + SetSkillByEvent(&Player::skillPerception, var_type, currPlayerId); + return; + case VAR_DiplomacySkill: + SetSkillByEvent(&Player::skillDiplomacy, var_type, currPlayerId); + return; + case VAR_ThieverySkill: + Error ("Thieving unsupported"); + return; + case VAR_DisarmTrapSkill: + SetSkillByEvent(&Player::skillDisarmTrap, var_type, currPlayerId); + return; + case VAR_DodgeSkill: + SetSkillByEvent(&Player::skillDodge, var_type, currPlayerId); + return; + case VAR_UnarmedSkill: + SetSkillByEvent(&Player::skillUnarmed, var_type, currPlayerId); + return; + case VAR_IdentifyMonsterSkill: + SetSkillByEvent(&Player::skillMonsterId, var_type, currPlayerId); + return; + case VAR_ArmsmasterSkill: + SetSkillByEvent(&Player::skillArmsmaster, var_type, currPlayerId); + return; + case VAR_StealingSkill: + SetSkillByEvent(&Player::skillStealing, var_type, currPlayerId); + return; + case VAR_AlchemySkill: + SetSkillByEvent(&Player::skillAlchemy, var_type, currPlayerId); + return; + case VAR_LearningSkill: + SetSkillByEvent(&Player::skillLearning, var_type, currPlayerId); + return; } } //----- (new function) -------------------------------------------------------- -void Player::PlaySoundBasedOnCondition(int currPlayerId) +void Player::PlayAwardSound(int currPlayerId) { signed int v25 = 8 * currPlayerId + 400; LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); @@ -5931,9 +5985,33 @@ } //----- (new function) -------------------------------------------------------- -void Player::DrawPlayerBuffAnimBasedOnCondition(int currPlayerId) +void Player::PlayAwardSound_Anim(int currPlayerId) { pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + PlayAwardSound(currPlayerId); +} + +//----- (new function) -------------------------------------------------------- +void Player::PlayAwardSound_Anim_Face(int currPlayerId, PlayerSpeech speech) +{ + this->PlaySound(speech, 0); + PlayAwardSound_Anim(currPlayerId); +} + +//----- (new function) -------------------------------------------------------- +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) -------------------------------------------------------- @@ -7309,6 +7387,7 @@ case 1 : soundToPlay = (SoundID)109; break; case 2 : soundToPlay = (SoundID)110; break; case 3 : soundToPlay = (SoundID)44; break; + default: Error("Unexpected sound value"); } } else @@ -7320,6 +7399,7 @@ case 1 : soundToPlay = (SoundID)106; break; case 2 : soundToPlay = (SoundID)107; break; case 3 : soundToPlay = (SoundID)45; break; + default: Error("Unexpected sound value"); } } pAudioPlayer->PlaySound(soundToPlay, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0);
--- a/Player.h Thu Oct 03 18:07:55 2013 +0600 +++ b/Player.h Thu Oct 03 18:08:18 2013 +0600 @@ -592,8 +592,7 @@ void SalesProcess(unsigned int inventory_idnx, int item_index, int _2devent_idx);//0x4BE2DD bool Recover(signed int a2); bool CanCastSpell(unsigned int uRequiredMana); - void PlaySoundBasedOnCondition(int currPlayerId); - void DrawPlayerBuffAnimBasedOnCondition(int currPlayerId); + void PlayAwardSound(int currPlayerId); void EquipBody(ITEM_EQUIP_TYPE uEquipType); bool HasUnderwaterSuitEquipped(); bool HasItem(unsigned int uItemID, char a3); @@ -603,6 +602,9 @@ int CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice); bool WearsItemAnyWhere(int item_id); float GetArmorRecoveryMultiplierFromSkillLevel( unsigned char armour_skill_type, float param2, float param3, float param4, float param5 ); + void SetSkillByEvent(unsigned __int16 Player::* skillToSet, unsigned __int16 skillValue, int currPlayerId); + void PlayAwardSound_Anim_Face(int currPlayerId, PlayerSpeech speech); + void PlayAwardSound_Anim(int currPlayerId); bool IsWeak(); bool IsDead();
--- a/mm7_2.cpp Thu Oct 03 18:07:55 2013 +0600 +++ b/mm7_2.cpp Thu Oct 03 18:08:18 2013 +0600 @@ -2736,7 +2736,7 @@ } //----- (00458244) -------------------------------------------------------- -int SkillToMastery( unsigned int skill_value ) +unsigned int SkillToMastery( unsigned int skill_value ) { switch (skill_value & 0x1C0) {
--- a/mm7_data.h Thu Oct 03 18:07:55 2013 +0600 +++ b/mm7_data.h Thu Oct 03 18:08:18 2013 +0600 @@ -1154,7 +1154,7 @@ char *GetEventHintString(unsigned int uEventID); // idb int GetTravelTime(); void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); -int SkillToMastery(unsigned int skill_value); +unsigned int SkillToMastery(unsigned int skill_value); unsigned int __fastcall GetSpellColor(signed int a1); unsigned short * MakeScreenshot(signed int width, signed int height); void SaveScreenshot(const char *pFilename);