Mercurial > mm7
changeset 1823:24b70fa98474
Merge
author | Grumpy7 |
---|---|
date | Wed, 09 Oct 2013 08:09:48 +0200 |
parents | 5f9eeb7bf8e6 (diff) 9442b7c19a64 (current diff) |
children | 6788e58c1715 |
files | UI/UiGame.cpp mm7_2.cpp mm7_data.cpp mm7_data.h |
diffstat | 10 files changed, 1131 insertions(+), 1177 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Tue Oct 08 11:06:24 2013 +0200 +++ b/Actor.cpp Wed Oct 09 08:09:48 2013 +0200 @@ -5001,7 +5001,7 @@ v59 = 1; if ( player->HasItemEquipped(EQUIP_MAIN_HAND) ) { - auto main_hand_skill = player->pInventoryItemList[main_hand_idx - 1].GetPlayerSkillType(); + auto main_hand_skill = player->GetMainHandItem()->GetPlayerSkillType(); //v55 = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType; //v28 = SkillToMastery(player->pActiveSkills[v55]); auto main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]);
--- a/Events.cpp Tue Oct 08 11:06:24 2013 +0200 +++ b/Events.cpp Wed Oct 09 08:09:48 2013 +0200 @@ -426,7 +426,7 @@ //v131 = uEventID; v133 = 0; EvtTargetObj = targetObj; - dword_5B65C4 = 0; + cancelEventProcessing = 0; if ( !uEventID ) { if ( !GameUI_Footer_TimeLeft ) @@ -457,7 +457,7 @@ //v7 = ""; while ( 1 ) { - if ( dword_5B65C4 ) + if ( cancelEventProcessing ) goto LABEL_301; //v8 = v4; if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) @@ -924,7 +924,7 @@ } else if ( player_choose == 6 ) //random { - if ( pPlayers[rand() % 4]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + if ( pPlayers[rand() % 4 + 1]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { v124 = -1; curr_seq_num = _evt->v11 - 1; @@ -1020,8 +1020,7 @@ v130 = 0; for(int i = 1; i < 5; ++i) { - if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - break; + pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } ++v130; }
--- a/Player.cpp Tue Oct 08 11:06:24 2013 +0200 +++ b/Player.cpp Wed Oct 09 08:09:48 2013 +0200 @@ -1328,7 +1328,7 @@ uNumFireSpikeCasts = 0; memset(field_1988, 0, 49 * sizeof(int)); - memset(field_1A50, 0, 64 * sizeof(char)); + memset(playerEventBits, 0, 64 * sizeof(char)); field_E0 = 0; field_E4 = 0; @@ -1670,6 +1670,10 @@ { totalDmg *= 2; } + else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_ELF) && ( enchType == 63 || itemId == ITEM_RELIC_OLD_NICK)) + { + totalDmg *= 2; + } else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_TITAN) && ( enchType == 65 )) { totalDmg *= 2; @@ -4310,7 +4314,7 @@ //----- (004908A8) -------------------------------------------------------- bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime) { - if ( pConditions[uCondition] && (uTime < (signed long long)pConditions[uCondition]) ) + if ( pConditions[uCondition] && (uTime < (unsigned long long)pConditions[uCondition]) ) { pConditions[uCondition] = 0i64; return true; @@ -4448,40 +4452,40 @@ if ( !playerAffected->pConditions[Condition_Weak] ) { v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[7].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_HASTE].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); } break; case 229: //Heroism v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[8].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_HEROISM].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 230: //Bless v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 231: //Preservation v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[11].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 232: //Shield v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[13].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_SHIELD].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 234: //Stoneskin v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[14].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_STONESKIN].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 235: //Water Breathing v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335), - playerAffected->pPlayerBuffs[23].Apply(pParty->uTimePlayed +v28, 3, 5, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].Apply(pParty->uTimePlayed +v28, 3, 5, 0, 0); break; case 237: //Remove Fear playerAffected->pConditions[Condition_Fear] = 0i64; @@ -4498,37 +4502,37 @@ case 240: //Might Boost v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[19].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_STRENGTH].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 241: //Intellect Boost v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[17].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_INTELLIGENCE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 242: //Personality Boost v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[20].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_WILLPOWER].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 243://Endurance Boost v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[16].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_ENDURANCE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 244: //Speed Boost v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[21].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_SPEED].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 245: //Accuracy Boost v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[15].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_ACCURACY].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 251: //Cure Paralysis @@ -4561,43 +4565,43 @@ case 255: //Luck Boost v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[18].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_LUCK].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 256: //Fire Resistance v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[5].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 257: //Air Resistance v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[0].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 258: //Water Resistance v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[22].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 259: //Earth Resistance v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[3].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 260: //Mind Resistance v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[9].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 261: //Body Resistance v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - playerAffected->pPlayerBuffs[2].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_BODY].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); playerAffected->PlaySound(SPEECH_36, 0); break; case 262: //Stone to Flesh @@ -4995,7 +4999,7 @@ if ( valToCompare <= 63 ) v4 = skillValue & 0x3F; else - v4 = valToCompare & skillValue; + v4 = skillValue & skillValue; return v4 >= valToCompare; } @@ -5310,7 +5314,7 @@ return (actStat >= baseStat); case VAR_PlayerBits: test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; - byteWithRequestedBit = this->field_1A50[((signed __int16)pValue - 1)/8]; + byteWithRequestedBit = this->playerEventBits[((signed __int16)pValue - 1)/8]; return ( test_bit_value & byteWithRequestedBit ) != 0; case VAR_NPCs2: return pNPCStats->pNewNPCData[pValue].Hired(); @@ -5407,21 +5411,12 @@ //----- (0044A5CB) -------------------------------------------------------- void Player::SetVariable(enum VariableType var_type, signed int var_value) { - signed int currPlayerId; // ebx@1 unsigned int v6; // esi@13 unsigned int v7; // esi@14 signed int v11; // eax@30 DDM_DLV_Header *v24; // ecx@148 ItemGen item; // [sp+Ch] [bp-28h]@52 - 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) { @@ -5431,7 +5426,7 @@ if (pStorylineText->StoreLine[var_type - VAR_History_0].pText) { bFlashHistoryBook = 1; - PlayAwardSound(currPlayerId); + PlayAwardSound(); } } return; @@ -5439,14 +5434,17 @@ if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 ) { - byte_5E4C15[var_type] = var_value; + if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_74 ) + stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] = (char)var_value; // originally (unsigned __int8)byte_5E4C15[VarNum]; + if ( var_type >= VAR_MapPersistentVariable_75 && var_type <= VAR_MapPersistentVariable_99 ) + stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] = (unsigned char)var_value; //not really sure whether the number gets up to 99, but can't ignore the possibility 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); + PlayAwardSound(); return; } @@ -5454,7 +5452,7 @@ { case VAR_Sex: this->uSex = (PLAYER_SEX)var_value; - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Class: this->classType = (PLAYER_CLASS_TYPE)var_value; @@ -5465,7 +5463,7 @@ if (this->pOwnItems[i].uItemID == ITEM_LICH_JAR_EMPTY) { this->pOwnItems[i].uItemID = ITEM_LICH_JAR_FULL; - this->pOwnItems[i].uHolderPlayer = currPlayerId + 1; + this->pOwnItems[i].uHolderPlayer = GetPlayerIndex() + 1; } } if ( this->sResFireBase < 20 ) @@ -5491,35 +5489,35 @@ this->uCurrentFace = 20; this->uVoiceID = 20; } - ReloadPlayerPortraits(currPlayerId, this->uCurrentFace); + ReloadPlayerPortraits(GetPlayerIndex(), this->uCurrentFace); } - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_CurrentHP: this->sHealth = var_value; - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_MaxHP: this->sHealth = GetMaxHealth(); return; case VAR_CurrentSP: this->sMana = var_value; - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_MaxSP: this->sMana = GetMaxMana(); return; case VAR_ACModifier: this->sACModifier = (unsigned __int8)var_value; - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_BaseLevel: this->uLevel = (unsigned __int8)var_value; - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_LevelModifier: this->sLevelModifier = (unsigned __int8)var_value; - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Age: this->sAgeModifier = var_value; @@ -5527,21 +5525,21 @@ case VAR_Award: if ( !_449B57_test_bit(this->_achieved_awards_bits, var_value) && pAwards[var_value].pText ) { - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); this->PlaySound(SPEECH_96, 0); } _449B7E_toggle_bit(this->_achieved_awards_bits, var_value, 1u); return; case VAR_Experience: this->uExperience = var_value; - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_QBits_QuestsDone: if ( !_449B57_test_bit(pParty->_quest_bits, var_value) && pQuestTable[var_value-1] ) { bFlashQuestBook = 1; - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, GetPlayerIndex()); + PlayAwardSound(); this->PlaySound(SPEECH_93, 0); } _449B7E_toggle_bit(pParty->_quest_bits, var_value, 1u); @@ -5566,7 +5564,7 @@ return; case VAR_FixedFood: Party::SetFood(var_value); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_RandomFood: v7 = rand() % var_value + 1; @@ -5574,239 +5572,239 @@ sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food ShowStatusBarString(pTmpBuf.data(), 2u); GameUI_DrawFoodAndGold(); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_BaseMight: this->uMight = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_BaseIntellect: this->uIntelligence = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_BasePersonality: this->uWillpower = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_BaseEndurance: this->uEndurance = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_BaseSpeed: this->uSpeed = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_BaseAccuracy: this->uAccuracy = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_BaseLuck: this->uLuck = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_MightBonus: case VAR_ActualMight: this->uMightBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_IntellectBonus: case VAR_ActualIntellect: this->uIntelligenceBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_PersonalityBonus: case VAR_ActualPersonality: this->uWillpowerBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_EnduranceBonus: case VAR_ActualEndurance: this->uEnduranceBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_SpeedBonus: case VAR_ActualSpeed: this->uSpeedBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_AccuracyBonus: case VAR_ActualAccuracy: this->uAccuracyBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_LuckBonus: case VAR_ActualLuck: this->uLuckBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_FireResistance: this->sResFireBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_AirResistance: this->sResAirBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_WaterResistance: this->sResWaterBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_EarthResistance: this->sResEarthBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_SpiritResistance: this->sResSpiritBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_MindResistance: this->sResMindBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_BodyResistance: this->sResBodyBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_LightResistance: this->sResLightBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_DarkResistance: this->sResDarkBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_MagicResistance: this->sResMagicBase = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_92); + PlayAwardSound_Anim_Face(SPEECH_92); return; case VAR_FireResistanceBonus: this->sResFireBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_AirResistanceBonus: this->sResAirBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_WaterResistanceBonus: this->sResWaterBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_EarthResistanceBonus: this->sResEarthBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_SpiritResistanceBonus: this->sResSpiritBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_MindResistanceBonus: this->sResMindBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_BodyResistanceBonus: this->sResBodyBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_LightResistanceBonus: this->sResLightBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_DarkResistanceBonus: this->sResDarkBonus = (unsigned __int8)var_value; - PlayAwardSound_Anim_Face(currPlayerId, SPEECH_91); + PlayAwardSound_Anim_Face(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); + PlayAwardSound_Anim_Face(SPEECH_91); return; case VAR_Cursed: this->SetCondition(Condition_Cursed, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Weak: this->SetCondition(Condition_Weak, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Asleep: this->SetCondition(Condition_Sleep, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Afraid: this->SetCondition(Condition_Fear, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Drunk: this->SetCondition(Condition_Drunk, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Insane: this->SetCondition(Condition_Insane, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_PoisonedGreen: this->SetCondition(Condition_Poison1, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_DiseasedGreen: this->SetCondition(Condition_Disease1, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_PoisonedYellow: this->SetCondition(Condition_Poison2, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_DiseasedYellow: this->SetCondition(Condition_Disease2, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_PoisonedRed: this->SetCondition(Condition_Poison3, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_DiseasedRed: this->SetCondition(Condition_Disease3, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Paralyzed: this->SetCondition(Condition_Paralyzed, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Unconsious: this->SetCondition(Condition_Unconcious, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Dead: this->SetCondition(Condition_Dead, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Stoned: this->SetCondition(Condition_Pertified, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_Eradicated: this->SetCondition(Condition_Eradicated, 1); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_MajorCondition: memset(this, 0, 0xA0u); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); return; case VAR_AutoNotes: if ( !_449B57_test_bit(pParty->_autonote_bits, var_value) && pAutonoteTxt[var_value-1].pText ) { - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, GetPlayerIndex()); 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); + PlayAwardSound(); return; case VAR_PlayerBits: - _449B7E_toggle_bit((unsigned char *)field_1A50, var_value, 1u); + _449B7E_toggle_bit((unsigned char *)playerEventBits, var_value, 1u); return; case VAR_NPCs2: pParty->hirelingScrollPosition = 0; @@ -5862,174 +5860,168 @@ pParty->uNumArenaLordWins = var_value; return; case VAR_StaffSkill: - SetSkillByEvent(&Player::skillStaff, var_type, currPlayerId); + SetSkillByEvent(&Player::skillStaff, var_value); return; case VAR_SwordSkill: - SetSkillByEvent(&Player::skillSword, var_type, currPlayerId); + SetSkillByEvent(&Player::skillSword, var_value); return; case VAR_DaggerSkill: - SetSkillByEvent(&Player::skillDagger, var_type, currPlayerId); + SetSkillByEvent(&Player::skillDagger, var_value); return; case VAR_AxeSkill: - SetSkillByEvent(&Player::skillAxe, var_type, currPlayerId); + SetSkillByEvent(&Player::skillAxe, var_value); return; case VAR_SpearSkill: - SetSkillByEvent(&Player::skillSpear, var_type, currPlayerId); + SetSkillByEvent(&Player::skillSpear, var_value); return; case VAR_BowSkill: - SetSkillByEvent(&Player::skillBow, var_type, currPlayerId); + SetSkillByEvent(&Player::skillBow, var_value); return; case VAR_MaceSkill: - SetSkillByEvent(&Player::skillMace, var_type, currPlayerId); + SetSkillByEvent(&Player::skillMace, var_value); return; case VAR_BlasterSkill: - SetSkillByEvent(&Player::skillBlaster, var_type, currPlayerId); + SetSkillByEvent(&Player::skillBlaster, var_value); return; case VAR_ShieldSkill: - SetSkillByEvent(&Player::skillShield, var_type, currPlayerId); + SetSkillByEvent(&Player::skillShield, var_value); return; case VAR_LeatherSkill: - SetSkillByEvent(&Player::skillLeather, var_type, currPlayerId); + SetSkillByEvent(&Player::skillLeather, var_value); return; case VAR_SkillChain: - SetSkillByEvent(&Player::skillChain, var_type, currPlayerId); + SetSkillByEvent(&Player::skillChain, var_value); return; case VAR_PlateSkill: - SetSkillByEvent(&Player::skillPlate, var_type, currPlayerId); + SetSkillByEvent(&Player::skillPlate, var_value); return; case VAR_FireSkill: - SetSkillByEvent(&Player::skillFire, var_type, currPlayerId); + SetSkillByEvent(&Player::skillFire, var_value); return; case VAR_AirSkill: - SetSkillByEvent(&Player::skillAir, var_type, currPlayerId); + SetSkillByEvent(&Player::skillAir, var_value); return; case VAR_WaterSkill: - SetSkillByEvent(&Player::skillWater, var_type, currPlayerId); + SetSkillByEvent(&Player::skillWater, var_value); return; case VAR_EarthSkill: - SetSkillByEvent(&Player::skillEarth, var_type, currPlayerId); + SetSkillByEvent(&Player::skillEarth, var_value); return; case VAR_SpiritSkill: - SetSkillByEvent(&Player::skillSpirit, var_type, currPlayerId); + SetSkillByEvent(&Player::skillSpirit, var_value); return; case VAR_MindSkill: - SetSkillByEvent(&Player::skillMind, var_type, currPlayerId); + SetSkillByEvent(&Player::skillMind, var_value); return; case VAR_BodySkill: - SetSkillByEvent(&Player::skillBody, var_type, currPlayerId); + SetSkillByEvent(&Player::skillBody, var_value); return; case VAR_LightSkill: - SetSkillByEvent(&Player::skillLight, var_type, currPlayerId); + SetSkillByEvent(&Player::skillLight, var_value); return; case VAR_DarkSkill: - SetSkillByEvent(&Player::skillDark, var_type, currPlayerId); + SetSkillByEvent(&Player::skillDark, var_value); return; case VAR_IdentifyItemSkill: - SetSkillByEvent(&Player::skillItemId, var_type, currPlayerId); + SetSkillByEvent(&Player::skillItemId, var_value); return; case VAR_MerchantSkill: - SetSkillByEvent(&Player::skillMerchant, var_type, currPlayerId); + SetSkillByEvent(&Player::skillMerchant, var_value); return; case VAR_RepairSkill: - SetSkillByEvent(&Player::skillRepair, var_type, currPlayerId); + SetSkillByEvent(&Player::skillRepair, var_value); return; case VAR_BodybuildingSkill: - SetSkillByEvent(&Player::skillBodybuilding, var_type, currPlayerId); + SetSkillByEvent(&Player::skillBodybuilding, var_value); return; case VAR_MeditationSkill: - SetSkillByEvent(&Player::skillMeditation, var_type, currPlayerId); + SetSkillByEvent(&Player::skillMeditation, var_value); return; case VAR_PerceptionSkill: - SetSkillByEvent(&Player::skillPerception, var_type, currPlayerId); + SetSkillByEvent(&Player::skillPerception, var_value); return; case VAR_DiplomacySkill: - SetSkillByEvent(&Player::skillDiplomacy, var_type, currPlayerId); + SetSkillByEvent(&Player::skillDiplomacy, var_value); return; case VAR_ThieverySkill: Error ("Thieving unsupported"); return; case VAR_DisarmTrapSkill: - SetSkillByEvent(&Player::skillDisarmTrap, var_type, currPlayerId); + SetSkillByEvent(&Player::skillDisarmTrap, var_value); return; case VAR_DodgeSkill: - SetSkillByEvent(&Player::skillDodge, var_type, currPlayerId); + SetSkillByEvent(&Player::skillDodge, var_value); return; case VAR_UnarmedSkill: - SetSkillByEvent(&Player::skillUnarmed, var_type, currPlayerId); + SetSkillByEvent(&Player::skillUnarmed, var_value); return; case VAR_IdentifyMonsterSkill: - SetSkillByEvent(&Player::skillMonsterId, var_type, currPlayerId); + SetSkillByEvent(&Player::skillMonsterId, var_value); return; case VAR_ArmsmasterSkill: - SetSkillByEvent(&Player::skillArmsmaster, var_type, currPlayerId); + SetSkillByEvent(&Player::skillArmsmaster, var_value); return; case VAR_StealingSkill: - SetSkillByEvent(&Player::skillStealing, var_type, currPlayerId); + SetSkillByEvent(&Player::skillStealing, var_value); return; case VAR_AlchemySkill: - SetSkillByEvent(&Player::skillAlchemy, var_type, currPlayerId); + SetSkillByEvent(&Player::skillAlchemy, var_value); return; case VAR_LearningSkill: - SetSkillByEvent(&Player::skillLearning, var_type, currPlayerId); + SetSkillByEvent(&Player::skillLearning, var_value); return; } } //----- (new function) -------------------------------------------------------- -void Player::PlayAwardSound(int currPlayerId) -{ - signed int v25 = 8 * currPlayerId + 400; - LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); +void Player::PlayAwardSound() +{ + int playerIndex = GetPlayerIndex(); + signed int v25 = 8 * playerIndex + 400; + LOBYTE(v25) = PID(OBJECT_Player,playerIndex - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); } //----- (new function) -------------------------------------------------------- -void Player::PlayAwardSound_Anim(int currPlayerId) -{ - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); +void Player::PlayAwardSound_Anim() +{ + int playerIndex = GetPlayerIndex(); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, playerIndex); + PlayAwardSound(); } //----- (new function) -------------------------------------------------------- -void Player::PlayAwardSound_Anim_Face(int currPlayerId, PlayerSpeech speech) +void Player::PlayAwardSound_Anim_Face( PlayerSpeech speech ) { this->PlaySound(speech, 0); - PlayAwardSound_Anim(currPlayerId); + PlayAwardSound_Anim(); } //----- (new function) -------------------------------------------------------- -void Player::SetSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 newSkillValue, int currPlayerId ) +void Player::SetSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 skillValue ) { unsigned __int16 currSkillValue = this->*skillToSet; - if ( newSkillValue > 63 ) //the original had the condition reversed which was probably wrong - { - this->*skillToSet = newSkillValue | currSkillValue & 63; + if ( skillValue > 63 ) //the original had the condition reversed which was probably wrong + { + this->*skillToSet = skillValue | currSkillValue & 63; } else { - this->*skillToSet = newSkillValue | currSkillValue & 0xC0; - } - pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); - PlayAwardSound(currPlayerId); + this->*skillToSet = skillValue | currSkillValue & 0xC0; + } + int playerIndex = GetPlayerIndex(); + pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, playerIndex); + PlayAwardSound(); } //----- (0044AFFB) -------------------------------------------------------- void Player::AddVariable(enum VariableType var_type, signed int val) { - signed int uPlayerIdx; // edi@1 int v6; // eax@15 unsigned int v7; // esi@18 DDM_DLV_Header *v27; // eax@153 ItemGen item; // [sp+Ch] [bp-2Ch]@45 - - uPlayerIdx = 0; - if ( this == pPlayers[2] ) - uPlayerIdx = 1; - else if ( this == pPlayers[3] ) - uPlayerIdx = 2; - else if ( this == pPlayers[4] ) - uPlayerIdx = 3; if ( var_type >= VAR_Counter1 && var_type <= VAR_Counter10) { @@ -6040,16 +6032,27 @@ if ( var_type >= VAR_UnknownTimeEvent0 && var_type <= VAR_UnknownTimeEvent19 ) { pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; - PlayAwardSound(uPlayerIdx); + PlayAwardSound(); return; } if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 ) { - if ( (unsigned __int8)val + (unsigned __int8)byte_5E4C15[var_type] <= 255 ) - byte_5E4C15[var_type] += val; - else - byte_5E4C15[var_type] = -1; + + if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_74 ) + { + if (255 - val > stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0]) + stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] += val; + else + stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] = 255; + } + if ( (signed int)var_type >= VAR_MapPersistentVariable_75 && var_type <= VAR_MapPersistentVariable_99 ) + { + if (255 - val > stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75]) + stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] += val; + else + stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] = 255; + } return; } @@ -6061,7 +6064,7 @@ if (pStorylineText->StoreLine[var_type - VAR_History_0].pText = 0) { bFlashHistoryBook = 1; - PlayAwardSound(uPlayerIdx); + PlayAwardSound(); } } return; @@ -6084,19 +6087,19 @@ sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], v7);// You find %lu food ShowStatusBarString(pTmpBuf.data(), 2u); GameUI_DrawFoodAndGold(); - PlayAwardSound(uPlayerIdx); + PlayAwardSound(); return; case VAR_Sex: this->uSex = (PLAYER_SEX)val; - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Class: this->classType = (PLAYER_CLASS_TYPE)val; - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_CurrentHP: this->sHealth = min(this->sHealth + val, this->GetMaxHealth() ); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_MaxHP: this->_health_related = 0; @@ -6105,7 +6108,7 @@ return; case VAR_CurrentSP: this->sMana = min(this->sMana + val, this->GetMaxMana() ); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_MaxSP: this->_mana_related = 0; @@ -6114,15 +6117,15 @@ return; case VAR_ACModifier: this->sACModifier = min(this->sACModifier + val, 255); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_BaseLevel: this->uLevel = min(this->uLevel + val, 255); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_LevelModifier: this->sLevelModifier = min(this->sLevelModifier + val, 255); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Age: this->sAgeModifier += val; @@ -6130,19 +6133,19 @@ case VAR_Award: if (_449B57_test_bit(this->_achieved_awards_bits, val) && pAwards[val].pText ) { - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_96); + PlayAwardSound_Anim97_Face(SPEECH_96); } _449B7E_toggle_bit(this->_achieved_awards_bits, val, 1); return; case VAR_Experience: this->uExperience = min(this->uExperience + val, 4000000000i64); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_QBits_QuestsDone: if ( !_449B57_test_bit(pParty->_quest_bits, val) && pQuestTable[val] ) { bFlashQuestBook = 1; - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_93); + PlayAwardSound_Anim97_Face(SPEECH_93); } _449B7E_toggle_bit(pParty->_quest_bits, val, 1); return; @@ -6164,31 +6167,31 @@ return; case VAR_BaseMight: this->uMight = min(this->uMight + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_BaseIntellect: this->uIntelligence = min(this->uIntelligence + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_BasePersonality: this->uWillpower = min(this->uWillpower + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_BaseEndurance: this->uEndurance = min(this->uEndurance + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_BaseSpeed: this->uSpeed = min(this->uSpeed + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_BaseAccuracy: this->uAccuracy = min(this->uAccuracy + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_BaseLuck: this->uLuck = min(this->uLuck + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_FixedFood: Party::GiveFood(val); @@ -6196,194 +6199,194 @@ ShowStatusBarString(pTmpBuf.data(), 2u); if ( pParty->uNumFoodRations > 0xFFFF ) Party::SetFood(0xFFFFu); - PlayAwardSound(uPlayerIdx); + PlayAwardSound(); return; case VAR_MightBonus: case VAR_ActualMight: this->uMightBonus = min(this->uMightBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_IntellectBonus: case VAR_ActualIntellect: this->uIntelligenceBonus = min(this->uIntelligenceBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_PersonalityBonus: case VAR_ActualPersonality: this->uWillpowerBonus = min(this->uWillpowerBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_EnduranceBonus: case VAR_ActualEndurance: this->uEnduranceBonus = min(this->uEnduranceBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_SpeedBonus: case VAR_ActualSpeed: this->uSpeedBonus = min(this->uSpeedBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_AccuracyBonus: case VAR_ActualAccuracy: this->uAccuracyBonus = min(this->uAccuracyBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_LuckBonus: case VAR_ActualLuck: this->uLuckBonus = min(this->uLuckBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_FireResistance: this->sResFireBase = min(this->sResFireBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_AirResistance: this->sResAirBase = min(this->sResAirBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_WaterResistance: this->sResWaterBase = min(this->sResWaterBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_EarthResistance: this->sResEarthBase = min(this->sResEarthBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_SpiritResistance: this->sResSpiritBase = min(this->sResSpiritBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_MindResistance: this->sResMindBase = min(this->sResMindBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_BodyResistance: this->sResBodyBase = min(this->sResBodyBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_LightResistance: this->sResLightBase = min(this->sResLightBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_DarkResistance: this->sResDarkBase = min(this->sResDarkBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_MagicResistance: this->sResMagicBase = min(this->sResMagicBase + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_92); + PlayAwardSound_Anim97_Face(SPEECH_92); return; case VAR_FireResistanceBonus: this->sResFireBonus = min(this->sResFireBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_AirResistanceBonus: this->sResAirBonus = min(this->sResAirBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_WaterResistanceBonus: this->sResWaterBonus = min(this->sResWaterBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_EarthResistanceBonus: this->sResEarthBonus = min(this->sResEarthBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_SpiritResistanceBonus: this->sResSpiritBonus = min(this->sResSpiritBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_MindResistanceBonus: this->sResMindBonus = min(this->sResMindBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_BodyResistanceBonus: this->sResBodyBonus = min(this->sResBodyBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_LightResistanceBonus: this->sResLightBonus = min(this->sResLightBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_DarkResistanceBonus: this->sResDarkBonus = min(this->sResDarkBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_MagicResistanceBonus: this->sResMagicBonus = min(this->sResMagicBonus + val, 255); - PlayAwardSound_Anim97_Face(uPlayerIdx, SPEECH_91); + PlayAwardSound_Anim97_Face(SPEECH_91); return; case VAR_Cursed: this->SetCondition(Condition_Cursed, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Weak: this->SetCondition(Condition_Weak, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Asleep: this->SetCondition(Condition_Sleep, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Afraid: this->SetCondition(Condition_Fear, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Drunk: this->SetCondition(Condition_Drunk, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Insane: this->SetCondition(Condition_Insane, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_PoisonedGreen: this->SetCondition(Condition_Poison1, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_DiseasedGreen: this->SetCondition(Condition_Disease1, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_PoisonedYellow: this->SetCondition(Condition_Poison2, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_DiseasedYellow: this->SetCondition(Condition_Disease2, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_PoisonedRed: this->SetCondition(Condition_Poison3, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_DiseasedRed: this->SetCondition(Condition_Disease3, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Paralyzed: this->SetCondition(Condition_Paralyzed, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Unconsious: this->SetCondition(Condition_Unconcious, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Dead: this->SetCondition(Condition_Dead, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Stoned: this->SetCondition(Condition_Pertified, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_Eradicated: this->SetCondition(Condition_Eradicated, 1); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_MajorCondition : memset(this, 0, 0xA0u); - PlayAwardSound_Anim97(uPlayerIdx); + PlayAwardSound_Anim97(); return; case VAR_AutoNotes: if ( !_449B57_test_bit(pParty->_autonote_bits, val) && pAutonoteTxt[val].pText ) @@ -6391,13 +6394,13 @@ this->PlaySound(SPEECH_96, 0); bFlashAutonotesBook = 1; _506568_autonote_type = pAutonoteTxt[val].eType; - pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, GetPlayerIndex()); } _449B7E_toggle_bit(pParty->_autonote_bits, val, 1); - PlayAwardSound(uPlayerIdx); + PlayAwardSound(); return; case VAR_PlayerBits: - _449B7E_toggle_bit((unsigned char *)this->field_1A50, val, 1u); + _449B7E_toggle_bit((unsigned char *)this->playerEventBits, val, 1u); return; case VAR_NPCs2: pParty->hirelingScrollPosition = 0; @@ -6441,115 +6444,115 @@ pParty->uNumArenaLordWins += val; return; case VAR_StaffSkill: - AddSkillByEvent(&Player::skillStaff, val, uPlayerIdx); + AddSkillByEvent(&Player::skillStaff, val); return; case VAR_SwordSkill: - AddSkillByEvent(&Player::skillSword, val, uPlayerIdx); + AddSkillByEvent(&Player::skillSword, val); return; case VAR_DaggerSkill: - AddSkillByEvent(&Player::skillDagger, val, uPlayerIdx); + AddSkillByEvent(&Player::skillDagger, val); return; case VAR_AxeSkill: - AddSkillByEvent(&Player::skillAxe, val, uPlayerIdx); + AddSkillByEvent(&Player::skillAxe, val); return; case VAR_SpearSkill: - AddSkillByEvent(&Player::skillSpear, val, uPlayerIdx); + AddSkillByEvent(&Player::skillSpear, val); return; case VAR_BowSkill: - AddSkillByEvent(&Player::skillBow, val, uPlayerIdx); + AddSkillByEvent(&Player::skillBow, val); return; case VAR_MaceSkill: - AddSkillByEvent(&Player::skillMace, val, uPlayerIdx); + AddSkillByEvent(&Player::skillMace, val); return; case VAR_BlasterSkill: - AddSkillByEvent(&Player::skillBlaster, val, uPlayerIdx); + AddSkillByEvent(&Player::skillBlaster, val); return; case VAR_ShieldSkill: - AddSkillByEvent(&Player::skillShield, val, uPlayerIdx); + AddSkillByEvent(&Player::skillShield, val); return; case VAR_LeatherSkill: - AddSkillByEvent(&Player::skillLeather, val, uPlayerIdx); + AddSkillByEvent(&Player::skillLeather, val); return; case VAR_SkillChain: - AddSkillByEvent(&Player::skillChain, val, uPlayerIdx); + AddSkillByEvent(&Player::skillChain, val); return; case VAR_PlateSkill: - AddSkillByEvent(&Player::skillPlate, val, uPlayerIdx); + AddSkillByEvent(&Player::skillPlate, val); return; case VAR_FireSkill: - AddSkillByEvent(&Player::skillFire, val, uPlayerIdx); + AddSkillByEvent(&Player::skillFire, val); return; case VAR_AirSkill: - AddSkillByEvent(&Player::skillAir, val, uPlayerIdx); + AddSkillByEvent(&Player::skillAir, val); return; case VAR_WaterSkill: - AddSkillByEvent(&Player::skillWater, val, uPlayerIdx); + AddSkillByEvent(&Player::skillWater, val); return; case VAR_EarthSkill: - AddSkillByEvent(&Player::skillEarth, val, uPlayerIdx); + AddSkillByEvent(&Player::skillEarth, val); return; case VAR_SpiritSkill: - AddSkillByEvent(&Player::skillSpirit, val, uPlayerIdx); + AddSkillByEvent(&Player::skillSpirit, val); return; case VAR_MindSkill: - AddSkillByEvent(&Player::skillMind, val, uPlayerIdx); + AddSkillByEvent(&Player::skillMind, val); return; case VAR_BodySkill: - AddSkillByEvent(&Player::skillBody, val, uPlayerIdx); + AddSkillByEvent(&Player::skillBody, val); return; case VAR_LightSkill: - AddSkillByEvent(&Player::skillLight, val, uPlayerIdx); + AddSkillByEvent(&Player::skillLight, val); return; case VAR_DarkSkill: - AddSkillByEvent(&Player::skillDark, val, uPlayerIdx); + AddSkillByEvent(&Player::skillDark, val); return; case VAR_IdentifyItemSkill: - AddSkillByEvent(&Player::skillItemId, val, uPlayerIdx); + AddSkillByEvent(&Player::skillItemId, val); return; case VAR_MerchantSkill: - AddSkillByEvent(&Player::skillMerchant, val, uPlayerIdx); + AddSkillByEvent(&Player::skillMerchant, val); return; case VAR_RepairSkill: - AddSkillByEvent(&Player::skillRepair, val, uPlayerIdx); + AddSkillByEvent(&Player::skillRepair, val); return; case VAR_BodybuildingSkill: - AddSkillByEvent(&Player::skillBodybuilding, val, uPlayerIdx); + AddSkillByEvent(&Player::skillBodybuilding, val); return; case VAR_MeditationSkill: - AddSkillByEvent(&Player::skillMeditation, val, uPlayerIdx); + AddSkillByEvent(&Player::skillMeditation, val); return; case VAR_PerceptionSkill: - AddSkillByEvent(&Player::skillPerception, val, uPlayerIdx); + AddSkillByEvent(&Player::skillPerception, val); return; case VAR_DiplomacySkill: - AddSkillByEvent(&Player::skillDiplomacy, val, uPlayerIdx); + AddSkillByEvent(&Player::skillDiplomacy, val); return; case VAR_ThieverySkill: Error ("Thieving unsupported"); return; case VAR_DisarmTrapSkill: - AddSkillByEvent(&Player::skillDisarmTrap, val, uPlayerIdx); + AddSkillByEvent(&Player::skillDisarmTrap, val); return; case VAR_DodgeSkill: - AddSkillByEvent(&Player::skillDodge, val, uPlayerIdx); + AddSkillByEvent(&Player::skillDodge, val); return; case VAR_UnarmedSkill: - AddSkillByEvent(&Player::skillUnarmed, val, uPlayerIdx); + AddSkillByEvent(&Player::skillUnarmed, val); return; case VAR_IdentifyMonsterSkill: - AddSkillByEvent(&Player::skillMonsterId, val, uPlayerIdx); + AddSkillByEvent(&Player::skillMonsterId, val); return; case VAR_ArmsmasterSkill: - AddSkillByEvent(&Player::skillArmsmaster, val, uPlayerIdx); + AddSkillByEvent(&Player::skillArmsmaster, val); return; case VAR_StealingSkill: - AddSkillByEvent(&Player::skillStealing, val, uPlayerIdx); + AddSkillByEvent(&Player::skillStealing, val); return; case VAR_AlchemySkill: - AddSkillByEvent(&Player::skillAlchemy, val, uPlayerIdx); + AddSkillByEvent(&Player::skillAlchemy, val); return; case VAR_LearningSkill: - AddSkillByEvent(&Player::skillLearning, val, uPlayerIdx); + AddSkillByEvent(&Player::skillLearning, val); return; default: return; @@ -6557,21 +6560,22 @@ } //----- (new function) -------------------------------------------------------- -void Player::PlayAwardSound_Anim97(int currPlayerId) -{ - pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, currPlayerId); - PlayAwardSound(currPlayerId); +void Player::PlayAwardSound_Anim97() +{ + int playerIndex = GetPlayerIndex(); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, playerIndex); + PlayAwardSound(); } //----- (new function) -------------------------------------------------------- -void Player::PlayAwardSound_Anim97_Face(int currPlayerId, PlayerSpeech speech) +void Player::PlayAwardSound_Anim97_Face( PlayerSpeech speech ) { this->PlaySound(speech, 0); - PlayAwardSound_Anim97(currPlayerId); + PlayAwardSound_Anim97(); } //----- (new function) -------------------------------------------------------- -void Player::AddSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 addSkillValue, int currPlayerId ) +void Player::AddSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 addSkillValue ) { if ( addSkillValue > 63 ) { @@ -6581,679 +6585,607 @@ { this->*skillToSet = min(this->*skillToSet + addSkillValue, 60) | this->*skillToSet & 0xC0; } - PlayAwardSound_Anim97(currPlayerId); + PlayAwardSound_Anim97(); return; } //----- (0044B9C4) -------------------------------------------------------- -bool Player::SubtractVariable(enum VariableType VarNum, signed int pValue) -{ - unsigned int v3; // ebx@1 - signed int v4; // esi@1 - bool result; // eax@8 - int v6; // esi@11 - int v7; // edi@14 - signed int v8; // eax@17 - char *v9; // eax@20 - char v10; // sf@20 - char *v11; // ecx@26 - char *v12; // ecx@27 - __int64 v13; // qax@27 - unsigned __int8 v14; // cf@27 - int *v15; // edx@29 - char *v16; // eax@90 - char *v17; // ecx@94 - int v18; // esi@97 - signed int v19; // edx@97 - char *v20; // ecx@98 - int v21; // eax@100 - __int16 v22; // dx@112 - int v23; // [sp-8h] [bp-14h]@45 - signed int v24; // [sp-4h] [bp-10h]@4 - int v25; // [sp-4h] [bp-10h]@45 - - v3 = 0; - v4 = uActiveCharacter - 1; - result = false; - if ( (signed int)VarNum > 222 ) - { - if ( (signed int)VarNum <= 307 ) +void Player::SubtractVariable( enum VariableType VarNum, signed int pValue ) +{ + DDM_DLV_Header *locationHeader; // eax@90 + int randGold; + int randFood; + int npcIndex; + + if ( VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_99 ) + { + if ( VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 ) + { + stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] -= pValue; + } + if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 ) { - if ( VarNum == 307 ) - { - pParty->uNumDeaths -= (unsigned int)pValue; - return pValue; - } - if ( VarNum == 223 ) - { - v11 = (char *)pParty->_autonote_bits; - v22 = (short)pValue - 1; - } - else - { - if ( VarNum != 231 ) - { - switch ( VarNum ) - { - case 232: - VarNum = (VariableType)0; - GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int*)&VarNum); - result = (bool) pValue; - npcIdToDismissAfterDialogue = 0; - if ( (int)VarNum == pValue ) - { - npcIdToDismissAfterDialogue = (int)pValue; - } - else - { - pParty->hirelingScrollPosition = 0; - LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu; - pParty->CountHirelings(); - viewparams->bRedrawGameUI = true; - } - break; - case 241: - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v20 = (char *)&pNPCStats->pNewNPCData[0].uFlags; - for ( v19 = 0; v19 < (signed int)pNPCStats->uNumNewNPCs; ++v19 ) - { - if ( *((void **)v20 + 4) == (void *)pValue ) - { - v21 = *(int *)v20; - if ( (char)*(int *)v20 < 0 ) - { - LOBYTE(v21) = v21 & 0x7F; - *(int *)v20 = v21; - } - } - v20 += 76; - } - } - if ( pParty->pHirelings[0].uProfession == pValue ) - memset(pParty->pHirelings, 0, 0x4Cu); - if ( pParty->pHirelings[1].uProfession == pValue ) - memset(&pParty->pHirelings[1], 0, 0x4Cu); - pParty->hirelingScrollPosition = 0; - pParty->CountHirelings(); - break; - case 243: - v17 = (char *)&this->uSkillPoints; - result = *v17 != NULL; - if ( (unsigned int)pValue <= *(int *)v17 ) - { - *(int *)v17 -= (int)pValue; - result = (v17 != NULL); - } - else - *(int *)v17 = 0; - break; - case 275: - v16 = (char *)&pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) - v16 = (char *)&pIndoor->dlv; - *((int *)v16 + 2) -= (int)pValue; - if ( *((int *)v16 + 2) < -10000 ) - *((int *)v16 + 2) = -10000; - break; - case 306: - result = VarNum - 306; - if ( (unsigned int)pValue <= pParty->uNumGoldInBank ) - { - result = (bool)pValue; - pParty->uNumGoldInBank -= (unsigned int)pValue; - } - else -LABEL_88: - dword_5B65C4 = 1; - break; - } - return result; - } - v11 = this->field_1A50; - v22 = (signed __int16)pValue; - } - _449B7E_toggle_bit((unsigned char *)v11, v22, 0); - return result; + stru_5E4C90_MapPersistVars._decor_events[VarNum - VAR_MapPersistentVariable_75] -= pValue; } - switch ( VarNum ) - { - case 308: - result = (bool)pValue; - pParty->uNumBountiesCollected -= (unsigned int)pValue; - break; - case 309: - result = (bool)pValue; - pParty->uNumPrisonTerms -= (int)pValue; - break; - case 310: - result = (bool)pValue; - pParty->uNumArenaPageWins -= (char)pValue; - break; - case 311: - result = (bool)pValue; - pParty->uNumArenaSquireWins -= (char)pValue; - break; - case 312: - result = (bool)pValue; - pParty->uNumArenaKnightWins -= (char)pValue; - break; - case 313: - result = (bool)pValue; - pParty->uNumArenaLordWins -= (char)pValue; - break; - } - Error("Function not returning any value! (%u)", VarNum); - } - else - { - if ( (signed int)VarNum >= 123 ) - { - byte_5E4C15[VarNum] -= (char)pValue; - } - else - { - switch ( VarNum ) + return; + } + + switch (VarNum) + { + case VAR_CurrentHP: + ReceiveDamage((signed int)pValue, DMGT_PHISYCAL); + PlayAwardSound_Anim98(); + return; + case VAR_CurrentSP: + this->sMana = max(this->sMana - pValue, 0); + PlayAwardSound_Anim98(); + return; + case VAR_ACModifier: + this->sACModifier -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_BaseLevel: + this->uLevel -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_LevelModifier: + this->sLevelModifier -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_Age: + this->sAgeModifier -= (signed __int16)pValue; + return; + case VAR_Award: + _449B7E_toggle_bit(this->_achieved_awards_bits, (signed __int16)pValue, 0); + return; + case VAR_Experience: + this->uExperience -= pValue; + PlayAwardSound_Anim98(); + return; + case VAR_QBits_QuestsDone: + _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0); + this->PlaySound(SPEECH_96, 0); + return; + case VAR_PlayerItemInHands: + for (int i = 0; i < 126; i++) { - case VAR_RandomGold: - v6 = rand() % (signed int)pValue + 1; - if ( v6 > pParty->uNumGold ) - v6 = pParty->uNumGold; - Party::TakeGold(v6); - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[503], v6); - ShowStatusBarString(pTmpBuf.data(), 2); - GameUI_DrawFoodAndGold(); - return result; - case VAR_RandomFood: - v7 = rand() % (signed int)pValue + 1; - if ( v7 > pParty->uNumFoodRations ) - v7 = pParty->uNumFoodRations; - Party::TakeFood(v7); - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[504], v7); - ShowStatusBarString(pTmpBuf.data(), 2u); - GameUI_DrawFoodAndGold(); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_CurrentHP: - ReceiveDamage((signed int)pValue, DMGT_PHISYCAL); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_CurrentSP: - v9 = (char *)&this->sMana; - v10 = this->sMana - (signed int)pValue < 0; - *(int *)v9 -= (int)pValue; - if ( v10 ) - *(int *)v9 = 0; - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_ACModifier: - this->sACModifier -= (unsigned __int8)pValue; - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BaseLevel: - this->uLevel -= (unsigned __int8)pValue; - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_LevelModifier: - this->sLevelModifier -= (unsigned __int8)pValue; - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_Age: - this->sAgeModifier -= (signed __int16)pValue; - return result; - case VAR_Award: - _449B7E_toggle_bit((unsigned char *)this->_achieved_awards_bits, (signed __int16)pValue, 0); - return result; - case VAR_Experience: - v12 = (char *)&this->uExperience; - v13 = (signed int)pValue; - v14 = *(int *)v12 < (unsigned int)pValue; - *(int *)v12 -= (int)pValue; - *((int *)v12 + 1) -= v14 + HIDWORD(v13); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_QBits_QuestsDone: - _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0); - pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0); - return true; - case VAR_PlayerItemInHands: - v15 = this->pInventoryMatrix; - break; - case VAR_FixedGold: - if ( (unsigned int)pValue > pParty->uNumGold ) - goto LABEL_88; - Party::TakeGold((unsigned int)pValue); - return result; - case VAR_MightBonus: - case VAR_ActualMight: - this->uMightBonus -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_IntellectBonus: - case VAR_ActualIntellect: - this->uIntelligenceBonus -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_PersonalityBonus: - case VAR_ActualPersonality: - this->uWillpowerBonus -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_EnduranceBonus: - case VAR_ActualEndurance: - this->uEnduranceBonus -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_SpeedBonus: - case VAR_ActualSpeed: - this->uSpeedBonus -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_AccuracyBonus: - case VAR_ActualAccuracy: - this->uAccuracyBonus -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_LuckBonus: - case VAR_ActualLuck: - this->uLuckBonus -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BaseMight: - this->uMight -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BaseIntellect: - this->uIntelligence -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BasePersonality: - this->uWillpower -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BaseEndurance: - this->uEndurance -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BaseSpeed: - this->uSpeed -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BaseAccuracy: - this->uAccuracy -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BaseLuck: - this->uLuck -= (unsigned __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_FireResistance: - this->sResFireBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_AirResistance: - this->sResAirBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_WaterResistance: - this->sResWaterBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_EarthResistance: - this->sResEarthBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_SpiritResistance: - this->sResSpiritBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_MindResistance: - this->sResMindBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BodyResistance: - this->sResBodyBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_LightResistance: - this->sResLightBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_DarkResistance: - this->sResDarkBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_MagicResistance: - this->sResMagicBase -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_FireResistanceBonus: - this->sResFireBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_AirResistanceBonus: - this->sResAirBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_WaterResistanceBonus: - this->sResWaterBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_EarthResistanceBonus: - this->sResEarthBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_SpiritResistanceBonus: - this->sResSpiritBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_MindResistanceBonus: - this->sResMindBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_BodyResistanceBonus: - this->sResBodyBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_LightResistanceBonus: - this->sResLightBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_DarkResistanceBonus: - this->sResDarkBonus -= (signed __int16)pValue; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_MagicResistanceBonus: - this->sResMagicBonus -= (signed __int16)pValue; - v25 = 0; - v23 = SPEECH_91; - pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_FixedFood: - Party::TakeFood((unsigned int)pValue); - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_StaffSkill: - case VAR_SwordSkill: - case VAR_DaggerSkill: - case VAR_AxeSkill: - case VAR_SpearSkill: - case VAR_BowSkill: - case VAR_MaceSkill: - case VAR_BlasterSkill: - case VAR_ShieldSkill: - case VAR_LeatherSkill: - case VAR_SkillChain: - case VAR_PlateSkill: - case VAR_FireSkill: - case VAR_AirSkill: - case VAR_WaterSkill: - case VAR_EarthSkill: - case VAR_SpiritSkill: - case VAR_MindSkill: - case VAR_BodySkill: - case VAR_LightSkill: - case VAR_DarkSkill: - case VAR_IdentifyItemSkill: - case VAR_MerchantSkill: - case VAR_RepairSkill: - case VAR_BodybuildingSkill: - case VAR_MeditationSkill: - case VAR_PerceptionSkill: - case VAR_DiplomacySkill: - case VAR_DisarmTrapSkill: - case VAR_LearningSkill: - *((short *)&this->pConditions[16] + VarNum) -= (unsigned __int8)pValue; - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - case VAR_Cursed: - case VAR_Weak: - case VAR_Asleep: - case VAR_Afraid: - case VAR_Drunk: - case VAR_Insane: - case VAR_PoisonedGreen: - case VAR_DiseasedGreen: - case VAR_PoisonedYellow: - case VAR_DiseasedYellow: - case VAR_PoisonedRed: - case VAR_DiseasedRed: - case VAR_Paralyzed: - case VAR_Unconsious: - case VAR_Dead: - case VAR_Stoned: - case VAR_Eradicated: - //*((int *)this + 2 * VarNum - 210) = 0; - //*((int *)this + 2 * result - 209) = 0; - this->pConditions[VarNum] = 0; - pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); - v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); - pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return result; - default: - return result; - } - for (v3 = 1; v3 < 126; v3++) - { - if ( *(&this->pInventoryItemList[pInventoryMatrix[v3] - 1].uItemID) == pValue ) + if ( this->pInventoryItemList[pInventoryMatrix[i]].uItemID == pValue ) { - RemoveItemAtInventoryIndex(v3); - return true; + RemoveItemAtInventoryIndex(i); + return; } } if ( pParty->pPickedItem.uItemID == pValue ) { pMouse->RemoveHoldingItem(); - return true; + return; + } + return; + case VAR_FixedGold: + if ( (unsigned int)pValue > pParty->uNumGold ) + { + cancelEventProcessing = 1; + return; } - return false; - } - } - - //assert(false); - return false; + Party::TakeGold((unsigned int)pValue); + return; + case VAR_RandomGold: + randGold = rand() % (signed int)pValue + 1; + if ( (unsigned int)randGold > pParty->uNumGold ) + randGold = pParty->uNumGold; + Party::TakeGold(randGold); + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[503], randGold); + ShowStatusBarString(pTmpBuf.data(), 2); + GameUI_DrawFoodAndGold(); + return; + case VAR_FixedFood: + Party::TakeFood((unsigned int)pValue); + PlayAwardSound_Anim98(); + return; + case VAR_RandomFood: + randFood = rand() % (signed int)pValue + 1; + if ( (unsigned int)randFood > pParty->uNumFoodRations ) + randFood = pParty->uNumFoodRations; + Party::TakeFood(randFood); + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[504], randFood); + ShowStatusBarString(pTmpBuf.data(), 2u); + GameUI_DrawFoodAndGold(); + PlayAwardSound_Anim98(); + return; + case VAR_MightBonus: + case VAR_ActualMight: + this->uMightBonus -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_IntellectBonus: + case VAR_ActualIntellect: + this->uIntelligenceBonus -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_PersonalityBonus: + case VAR_ActualPersonality: + this->uWillpowerBonus -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_EnduranceBonus: + case VAR_ActualEndurance: + this->uEnduranceBonus -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_SpeedBonus: + case VAR_ActualSpeed: + this->uSpeedBonus -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_AccuracyBonus: + case VAR_ActualAccuracy: + this->uAccuracyBonus -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_LuckBonus: + case VAR_ActualLuck: + this->uLuckBonus -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_BaseMight: + this->uMight -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_BaseIntellect: + this->uIntelligence -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_BasePersonality: + this->uWillpower -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_BaseEndurance: + this->uEndurance -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_BaseSpeed: + this->uSpeed -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_BaseAccuracy: + this->uAccuracy -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_BaseLuck: + this->uLuck -= (unsigned __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_FireResistance: + this->sResFireBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_AirResistance: + this->sResAirBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_WaterResistance: + this->sResWaterBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_EarthResistance: + this->sResEarthBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_SpiritResistance: + this->sResSpiritBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_MindResistance: + this->sResMindBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_BodyResistance: + this->sResBodyBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_LightResistance: + this->sResLightBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_DarkResistance: + this->sResDarkBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_MagicResistance: + this->sResMagicBase -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_FireResistanceBonus: + this->sResFireBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_AirResistanceBonus: + this->sResAirBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_92); + return; + case VAR_WaterResistanceBonus: + this->sResWaterBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_EarthResistanceBonus: + this->sResEarthBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_SpiritResistanceBonus: + this->sResSpiritBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_MindResistanceBonus: + this->sResMindBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_BodyResistanceBonus: + this->sResBodyBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_LightResistanceBonus: + this->sResLightBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_DarkResistanceBonus: + this->sResDarkBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_MagicResistanceBonus: + this->sResMagicBonus -= (signed __int16)pValue; + this->PlayAwardSound_Anim98_Face(SPEECH_91); + return; + case VAR_StaffSkill: + this->skillStaff -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_SwordSkill: + this->skillSword -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_DaggerSkill: + this->skillDagger -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_AxeSkill: + this->skillAxe -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_SpearSkill: + this->skillSpear -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_BowSkill: + this->skillBow -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_MaceSkill: + this->skillMace -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_BlasterSkill: + this->skillBlaster -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_ShieldSkill: + this->skillShield -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_LeatherSkill: + this->skillLearning -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_SkillChain: + this->skillChain -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_PlateSkill: + this->skillPlate -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_FireSkill: + this->skillFire -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_AirSkill: + this->skillAir -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_WaterSkill: + this->skillWater -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_EarthSkill: + this->skillEarth -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_SpiritSkill: + this->skillSpirit -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_MindSkill: + this->skillMind -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_BodySkill: + this->skillBody -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_LightSkill: + this->skillLight -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_DarkSkill: + this->skillDark -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_IdentifyItemSkill: + this->skillItemId -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_MerchantSkill: + this->skillMerchant -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_RepairSkill: + this->skillRepair -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_BodybuildingSkill: + this->skillBodybuilding -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_MeditationSkill: + this->skillMeditation -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_PerceptionSkill: + this->skillPerception -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_DiplomacySkill: + this->skillDiplomacy -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_ThieverySkill: + Error ("Thieving unsupported"); + return; + case VAR_DisarmTrapSkill: + this->skillDisarmTrap -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_DodgeSkill: + this->skillDodge -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_UnarmedSkill: + this->skillUnarmed -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_IdentifyMonsterSkill: + this->skillMonsterId -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_ArmsmasterSkill: + this->skillArmsmaster -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_StealingSkill: + this->skillStealing -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_AlchemySkill: + this->skillAlchemy -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_LearningSkill: + this->skillLearning -= (unsigned __int8)pValue; + PlayAwardSound_Anim98(); + return; + case VAR_Cursed: + this->pConditions[Condition_Cursed] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Weak: + this->pConditions[Condition_Weak] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Asleep: + this->pConditions[Condition_Sleep] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Afraid: + this->pConditions[Condition_Fear] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Drunk: + this->pConditions[Condition_Drunk] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Insane: + this->pConditions[Condition_Insane] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_PoisonedGreen: + this->pConditions[Condition_Poison1] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_DiseasedGreen: + this->pConditions[Condition_Disease1] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_PoisonedYellow: + this->pConditions[Condition_Poison2] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_DiseasedYellow: + this->pConditions[Condition_Disease2] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_PoisonedRed: + this->pConditions[Condition_Poison3] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_DiseasedRed: + this->pConditions[Condition_Disease3] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Paralyzed: + this->pConditions[Condition_Paralyzed] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Unconsious: + this->pConditions[Condition_Unconcious] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Dead: + this->pConditions[Condition_Dead] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Stoned: + this->pConditions[Condition_Pertified] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_Eradicated: + this->pConditions[Condition_Eradicated] = 0; + PlayAwardSound_Anim98(); + return; + case VAR_AutoNotes: + _449B7E_toggle_bit(pParty->_autonote_bits, pValue - 1, 0); + return; + case VAR_NPCs2: + npcIndex = 0; + GetNewNPCData(sDialogue_SpeakingActorNPC_ID, &npcIndex); + if ( npcIndex == pValue ) + { + npcIdToDismissAfterDialogue = pValue; + } + else + { + npcIdToDismissAfterDialogue = 0; + pParty->hirelingScrollPosition = 0; + LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; + } + return; + case VAR_HiredNPCHasSpeciality: + for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; i++) + { + if (pNPCStats->pNewNPCData[i].uProfession == pValue) + { + LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu; + } + } + if ( pParty->pHirelings[0].uProfession == pValue ) + memset(pParty->pHirelings, 0, sizeof(NPCData)); + if ( pParty->pHirelings[1].uProfession == pValue ) + memset(&pParty->pHirelings[1], 0, sizeof(NPCData)); + pParty->hirelingScrollPosition = 0; + pParty->CountHirelings(); + return; + case VAR_NumSkillPoints: + if ((unsigned int)pValue <= this->uSkillPoints) + { + this->uSkillPoints -= pValue; + } + else + { + this->uSkillPoints = 0; + } + return; + case VAR_ReputationInCurrentLocation: + locationHeader = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) + locationHeader = &pIndoor->dlv; + locationHeader->uReputation -= pValue; + if (locationHeader->uReputation < -10000) + locationHeader->uReputation = -10000; + return; + case VAR_GoldInBank: + if ( (unsigned int)pValue <= pParty->uNumGoldInBank ) + { + pParty->uNumGoldInBank -= (unsigned int)pValue; + } + else + { + cancelEventProcessing = 1; + } + return; + case VAR_NumDeaths: + pParty->uNumDeaths -= (unsigned int)pValue; + return; + case VAR_NumBounties: + pParty->uNumBountiesCollected -= (unsigned int)pValue; + return; + case VAR_PrisonTerms: + pParty->uNumPrisonTerms -= (int)pValue; + return; + case VAR_ArenaWinsPage: + pParty->uNumArenaPageWins -= (char)pValue; + return; + case VAR_ArenaWinsSquire: + pParty->uNumArenaSquireWins -= (char)pValue; + return; + case VAR_ArenaWinsKnight: + pParty->uNumArenaKnightWins -= (char)pValue; + return; + case VAR_ArenaWinsLord: + pParty->uNumArenaLordWins -= (char)pValue; + return; + } } // 5B65C4: using guessed type int dword_5B65C4; // 5B65CC: using guessed type int dword_5B65CC; +//----- (new function) -------------------------------------------------------- +void Player::PlayAwardSound_Anim98() +{ + int playerIndex = GetPlayerIndex(); + pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, playerIndex); + PlayAwardSound(); +} + +//----- (new function) -------------------------------------------------------- +void Player::PlayAwardSound_Anim98_Face( PlayerSpeech speech ) +{ + this->PlaySound(speech, 0); + PlayAwardSound_Anim98(); +} //----- (00467E7F) -------------------------------------------------------- void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType) { - int v2; // ebx@1 - Player *v3; // eax@1 - int v4; // edx@1 - int v7; // eax@3 + int itemAnchor; // ebx@1 + Player *currChar; // eax@1 + int itemInvLocation; // edx@1 + int freeSlot; // eax@3 ItemGen tempPickedItem; // [sp+Ch] [bp-30h]@1 - unsigned int *v11; // [sp+38h] [bp-4h]@1 + unsigned int *equipAnchor; // [sp+38h] [bp-4h]@1 tempPickedItem.Reset(); - v2 = pEquipTypeToBodyAnchor[uEquipType]; - v3 = pPlayers[uActiveCharacter]; - v11 = &v3->pEquipment.pIndices[v2]; - v4 = *v11; - if ( v4 ) + itemAnchor = pEquipTypeToBodyAnchor[uEquipType]; + currChar = pPlayers[uActiveCharacter]; + equipAnchor = &currChar->pEquipment.pIndices[itemAnchor]; + itemInvLocation = currChar->pEquipment.pIndices[itemAnchor]; + if ( itemInvLocation ) { memcpy(&tempPickedItem, &pParty->pPickedItem, sizeof(tempPickedItem)); - v3->pInventoryItemList[v4 - 1].uBodyAnchor = 0; + currChar->pInventoryItemList[itemInvLocation - 1].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem(&v3->pInventoryItemList[v4 - 1]); - tempPickedItem.uBodyAnchor = v2 + 1; - memcpy(&v3->pInventoryItemList[v4 - 1], &tempPickedItem, sizeof(ItemGen)); - *v11 = v4; + pParty->SetHoldingItem(&currChar->pInventoryItemList[itemInvLocation - 1]); + tempPickedItem.uBodyAnchor = itemAnchor + 1; + memcpy(&currChar->pInventoryItemList[itemInvLocation - 1], &tempPickedItem, sizeof(ItemGen)); + *equipAnchor = itemInvLocation; } else { - v7 = v3->FindFreeInventoryListSlot(); - if (v7 >= 0) + freeSlot = currChar->FindFreeInventoryListSlot(); + if (freeSlot >= 0) { - pParty->pPickedItem.uBodyAnchor = v2 + 1; - memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(ItemGen)); - *v11 = v7 + 1; + pParty->pPickedItem.uBodyAnchor = itemAnchor + 1; + memcpy(&currChar->pInventoryItemList[freeSlot], &pParty->pPickedItem, sizeof(ItemGen)); + *equipAnchor = freeSlot + 1; pMouse->RemoveHoldingItem(); } } @@ -7289,9 +7221,9 @@ } //----- (0043EE15) -------------------------------------------------------- -bool Player::HasItem( unsigned int uItemID, char a3 ) -{ - if ( !a3 || pParty->pPickedItem.uItemID != uItemID ) +bool Player::HasItem( unsigned int uItemID, bool checkHeldItem ) +{ + if ( !checkHeldItem || pParty->pPickedItem.uItemID != uItemID ) { for ( uint i = 0; i < 126; ++i ) { @@ -7309,8 +7241,12 @@ return true; } } - } - return false; + return false; + } + else + { + return true; + } } //----- (0043EDB9) -------------------------------------------------------- bool ShouldLoadTexturesForRaceAndGender(unsigned int _this) @@ -7442,7 +7378,7 @@ if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { dmgToReceive = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); - if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) + if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime > 0 ) { int actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) @@ -7511,15 +7447,18 @@ } else { - element = 0; + int activePlayerCounter = 0; for (int i = 1; i <= 4; i++) { - v72[element] = i; - element++; + if (pPlayers[i]->CanAct()) + { + v72[activePlayerCounter] = i; + activePlayerCounter++; + } } - if ( element ) + if ( activePlayerCounter ) { - playerPtr = &pParty->pPlayers[v72[rand() % element]];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; + playerPtr = &pParty->pPlayers[v72[rand() % activePlayerCounter]];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; } } int v68; @@ -7576,7 +7515,7 @@ { if ( !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) return; - if ( playerPtr->pPlayerBuffs[13].uExpireTime > 0 ) + if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime > 0 ) dmgToReceive >>= 1; if ( playerPtr->HasEnchantedItemEquipped(36) ) dmgToReceive >>= 1; @@ -7631,7 +7570,7 @@ if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { int reflectedDmg = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); - if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) + if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime > 0 ) { unsigned __int16 actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) @@ -7692,106 +7631,99 @@ //----- (00421EA6) -------------------------------------------------------- void Player::OnInventoryLeftClick() { - signed int v2; // ecx@2 - int v3; // eax@2 + signed int inventoryXCoord; // ecx@2 + int inventoryYCoord; // eax@2 int invMatrixIndex; // eax@2 - unsigned int v6; // eax@7 + unsigned int enchantedItemPos; // eax@7 unsigned int pickedItemId; // esi@12 unsigned int invItemIndex; // eax@12 - unsigned int v9; // eax@16 - unsigned int v10; // eax@18 + unsigned int itemPos; // eax@18 ItemGen tmpItem; // [sp+Ch] [bp-3Ch]@1 - POINT a2; // [sp+30h] [bp-18h]@4 unsigned int pY; // [sp+3Ch] [bp-Ch]@2 unsigned int pX; // [sp+40h] [bp-8h]@2 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) { pMouse->GetClickPos(&pX, &pY); - v3 = Player::INVETORYSLOTSWIDTH * ((pY - 17) / 32); - v2 = (pX - 14) / 32; - invMatrixIndex = v2 + v3; - if ( v2 + v3 >= 0 ) + inventoryYCoord = (pY - 17) / 32; + inventoryXCoord = (pX - 14) / 32; + invMatrixIndex = inventoryXCoord + (INVETORYSLOTSWIDTH * inventoryYCoord); + if ( inventoryYCoord >= 0 && inventoryYCoord < INVETORYSLOTSHEIGHT && inventoryXCoord >= 0 && inventoryXCoord < INVETORYSLOTSWIDTH) { - if ( invMatrixIndex <= 126 && pMouse->GetCursorPos(&a2)->x < 462 - && pMouse->GetCursorPos(&a2)->x >= 14 ) + if ( _50C9A0_IsEnchantingInProgress ) { - if ( _50C9A0_IsEnchantingInProgress ) + enchantedItemPos = this->GetItemIDAtInventoryIndex(&invMatrixIndex); + if ( enchantedItemPos ) { - v6 = this->GetItemIDAtInventoryIndex(&invMatrixIndex); - if ( v6 ) - { - *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; - *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; - *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; - *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex; - ptr_50C9A4_ItemToEnchant = &this->pInventoryItemList[v6-1]; - _50C9A0_IsEnchantingInProgress = 0; - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMouse->SetCursorBitmap("MICON1"); - _50C9D0_AfterEnchClickEventId = 113; - _50C9D4_AfterEnchClickEventSecondParam = 0; - _50C9D8_AfterEnchClickEventTimeout = 256; - } + *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; + *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; + *((int *)pGUIWindow_Settings->ptr_1C + 3) = enchantedItemPos - 1; + *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex; + ptr_50C9A4_ItemToEnchant = &this->pInventoryItemList[enchantedItemPos-1]; + _50C9A0_IsEnchantingInProgress = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMouse->SetCursorBitmap("MICON1"); + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 256; + } + return; + } + if ( ptr_50C9A4_ItemToEnchant ) + return; + pickedItemId = pParty->pPickedItem.uItemID; + invItemIndex = this->GetItemIDAtInventoryIndex(&invMatrixIndex); + if (!pickedItemId) + { + if ( !invItemIndex ) + return; + else + { + memcpy(&pParty->pPickedItem, &this->pInventoryItemList[invItemIndex-1], sizeof(pParty->pPickedItem)); + this->RemoveItemAtInventoryIndex(invMatrixIndex); + pickedItemId = pParty->pPickedItem.uItemID; + pMouse->SetCursorBitmap(pItemsTable->pItems[pickedItemId].pIconName); return; } - if ( ptr_50C9A4_ItemToEnchant ) - return; - pickedItemId = pParty->pPickedItem.uItemID; - invItemIndex = this->GetItemIDAtInventoryIndex(&invMatrixIndex); - if (!pickedItemId) + } + else + { + if ( invItemIndex ) { - if ( !invItemIndex ) - return; - else + ItemGen* invItemPtr = &this->pInventoryItemList[invItemIndex-1]; + memcpy(&tmpItem, invItemPtr, sizeof(tmpItem)); + this->RemoveItemAtInventoryIndex(invMatrixIndex); + int emptyIndex = this->AddItem2(invMatrixIndex, &pParty->pPickedItem); + if ( !emptyIndex ) { - memcpy(&pParty->pPickedItem, &this->pInventoryItemList[invItemIndex-1], sizeof(pParty->pPickedItem)); - this->RemoveItemAtInventoryIndex(invMatrixIndex); - v9 = pParty->pPickedItem.uItemID; - pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); - return; + emptyIndex = this->AddItem2(-1, &pParty->pPickedItem); + if ( !emptyIndex ) + { + this->PutItemArInventoryIndex(tmpItem.uItemID, invItemIndex - 1, invMatrixIndex); + memcpy(invItemPtr, &tmpItem, sizeof(ItemGen)); + return; + } } + memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen)); + pMouse->SetCursorBitmap(pParty->pPickedItem.GetIconName()); + return; } else { - if ( invItemIndex ) + itemPos = this->AddItem(invMatrixIndex, pickedItemId); + if ( itemPos ) { - ItemGen* invItemPtr = &this->pInventoryItemList[invItemIndex-1]; - memcpy(&tmpItem, invItemPtr, sizeof(tmpItem)); - this->RemoveItemAtInventoryIndex(invMatrixIndex); - int emptyIndex = this->AddItem2(invMatrixIndex, &pParty->pPickedItem); - if ( !emptyIndex ) - { - emptyIndex = this->AddItem2(-1, &pParty->pPickedItem); - if ( !emptyIndex ) - { - this->PutItemArInventoryIndex(tmpItem.uItemID, invItemIndex - 1, invMatrixIndex); - memcpy(invItemPtr, &tmpItem, sizeof(ItemGen)); - return; - } - } - v9 = tmpItem.uItemID; - memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen)); - pMouse->SetCursorBitmap(pParty->pPickedItem.GetIconName()); + memcpy(&this->pInventoryItemList[itemPos-1], &pParty->pPickedItem, sizeof(ItemGen)); + pMouse->RemoveHoldingItem(); return; } - else + itemPos = this->AddItem(-1, pickedItemId); + if ( itemPos ) { - v10 = this->AddItem(invMatrixIndex, pickedItemId); - if ( v10 ) - { - memcpy(&this->pInventoryItemList[v10-1], &pParty->pPickedItem, sizeof(ItemGen)); - pMouse->RemoveHoldingItem(); - return; - } - v10 = this->AddItem(-1, pickedItemId); - if ( v10 ) - { - memcpy(&this->pInventoryItemList[v10-1], &pParty->pPickedItem, sizeof(ItemGen)); - pMouse->RemoveHoldingItem(); - return; - } + memcpy(&this->pInventoryItemList[itemPos-1], &pParty->pPickedItem, sizeof(ItemGen)); + pMouse->RemoveHoldingItem(); + return; } } } @@ -8031,4 +7963,18 @@ return nullptr; } return &this->pInventoryItemList[this->pEquipment.*itemPos - 1]; +} + +int Player::GetPlayerIndex() +{ + int uPlayerIdx = 0; + if ( this == pPlayers[1] ) + uPlayerIdx = 0; + else if( this == pPlayers[2] ) + uPlayerIdx = 1; + else if ( this == pPlayers[3] ) + uPlayerIdx = 2; + else if ( this == pPlayers[4] ) + uPlayerIdx = 3; + Error("Unexpected player pointer"); } \ No newline at end of file
--- a/Player.h Tue Oct 08 11:06:24 2013 +0200 +++ b/Player.h Wed Oct 09 08:09:48 2013 +0200 @@ -12,7 +12,7 @@ PLAYER_BUFF_RESIST_BODY = 2, PLAYER_BUFF_RESIST_EARTH = 3, PLAYER_BUFF_FATE = 4, - PLAYER_BUFF_RESIST_FIRE = 3, + PLAYER_BUFF_RESIST_FIRE = 5, PLAYER_BUFF_HAMMERHANDS = 6, PLAYER_BUFF_HASTE = 7, PLAYER_BUFF_HEROISM = 8, @@ -20,7 +20,7 @@ PLAYER_BUFF_PAIN_REFLECTION = 10, PLAYER_BUFF_PRESERVATION = 11, PLAYER_BUFF_REGENERATION = 12, - PLAYER_BUFF_13 = 13, + PLAYER_BUFF_SHIELD = 13, PLAYER_BUFF_STONESKIN = 14, PLAYER_BUFF_ACCURACY = 15, PLAYER_BUFF_ENDURANCE = 16, @@ -29,7 +29,8 @@ PLAYER_BUFF_STRENGTH = 19, PLAYER_BUFF_WILLPOWER = 20, PLAYER_BUFF_SPEED = 21, - PLAYER_BUFF_RESIST_WATER = 22 + PLAYER_BUFF_RESIST_WATER = 22, + PLAYER_BUFF_WATER_WALK = 23 }; @@ -474,7 +475,7 @@ void SetVariable(enum VariableType var, signed int a3); void AddVariable(enum VariableType var, signed int val); - bool SubtractVariable(enum VariableType VarNum, signed int pValue); + void SubtractVariable(enum VariableType VarNum, signed int pValue); bool CompareVariable(enum VariableType VarNum, signed int pValue); void UseItem_DrinkPotion_etc(signed int a2, int a3); bool AddItem(struct ItemGen *pItem); @@ -592,22 +593,24 @@ void SalesProcess(unsigned int inventory_idnx, int item_index, int _2devent_idx);//0x4BE2DD bool Recover(signed int a2); bool CanCastSpell(unsigned int uRequiredMana); - void PlayAwardSound(int currPlayerId); + void PlayAwardSound(); void EquipBody(ITEM_EQUIP_TYPE uEquipType); bool HasUnderwaterSuitEquipped(); - bool HasItem(unsigned int uItemID, char a3); + bool HasItem(unsigned int uItemID, bool checkHeldItem); void OnInventoryLeftClick(); unsigned int GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4); 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 AddSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 addSkillValue, int currPlayerId ); - void PlayAwardSound_Anim(int currPlayerId); - void PlayAwardSound_Anim_Face(int currPlayerId, PlayerSpeech speech); - void PlayAwardSound_Anim97(int currPlayerId); - void PlayAwardSound_Anim97_Face(int currPlayerId, PlayerSpeech speech); + void SetSkillByEvent(unsigned __int16 Player::* skillToSet, unsigned __int16 skillValue); + void AddSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 addSkillValue); + void PlayAwardSound_Anim(); + void PlayAwardSound_Anim_Face(PlayerSpeech speech); + void PlayAwardSound_Anim97(); + void PlayAwardSound_Anim97_Face(PlayerSpeech speech); + void PlayAwardSound_Anim98(); + void PlayAwardSound_Anim98_Face(PlayerSpeech speech); bool IsWeak(); bool IsDead(); @@ -665,6 +668,8 @@ ItemGen* GetNthRingItem(int ringNum); ItemGen* GetNthEquippedIndexItem(int index); ItemGen* GetItem(unsigned int PlayerEquipment::* itemPos); + int GetPlayerIndex(); + __int64 pConditions[20]; unsigned __int64 uExperience; char pName[16]; @@ -806,7 +811,7 @@ char field_1A4D; char lastOpenedSpellbookPage; unsigned __int8 uQuickSpell; - char field_1A50[64]; + char playerEventBits[64]; char _some_attack_bonus; char field_1A91; char _melee_dmg_bonus;
--- a/UI/UICharacter.cpp Tue Oct 08 11:06:24 2013 +0200 +++ b/UI/UICharacter.cpp Wed Oct 09 08:09:48 2013 +0200 @@ -776,16 +776,16 @@ if ( !bRingsShownInCharScreen ) pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]), player->pEquipment.uArmor); //Рука не занята или ... - if ( !player->pEquipment.uMainHand - || ( pPlayers[uPlayerID]->pInventoryItemList[player->pEquipment.uMainHand - 1].GetItemEquipType() != EQUIP_MAIN_HAND) - && (pPlayers[uPlayerID]->pInventoryItemList[player->pEquipment.uMainHand - 1].GetItemEquipType() != PLAYER_SKILL_SPEAR - || pPlayers[uPlayerID]->pEquipment.uShield) ) + if ( !player->GetItem(&PlayerEquipment::uMainHand) + || ( player->GetMainHandItem()->GetItemEquipType() != EQUIP_MAIN_HAND) + && (player->GetMainHandItem()->GetItemEquipType() != PLAYER_SKILL_SPEAR + || player->GetItem(&PlayerEquipment::uShield)) ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1])); //-----------------------------------------------------(Hand/Рука)--------------------------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uMainHand ) + if ( player->GetItem(&PlayerEquipment::uMainHand) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uMainHand - 1]; + item = player->GetMainHandItem(); item_X = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item->uItemID].uEquipX; item_Y = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item->uItemID].uEquipY; if ( item->uItemID == 64 ) //blaster @@ -825,15 +825,15 @@ pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); } if ( !bRingsShownInCharScreen ) - pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)), pPlayers[uPlayerID]->pEquipment.uMainHand); + pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)), player->pEquipment.uMainHand); } } else// без акваланга { //----------------(Bow/ Лук)------------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uBow ) + if ( player->GetItem(&PlayerEquipment::uBow) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uBow - 1]; + item = player->GetBowItem(); item_X = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][2][0] - pItemsTable->pItems[item->uItemID].uEquipX; item_Y = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][2][1] - pItemsTable->pItems[item->uItemID].uEquipY; if ( !(item->uAttributes & 0xF0) )// если не применён закл @@ -871,12 +871,12 @@ } if ( !bRingsShownInCharScreen ) pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)), - pPlayers[uPlayerID]->pEquipment.uBow); + player->pEquipment.uBow); } //-----------------------------(Cloak/Плащ)--------------------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uCloak ) + if ( player->GetItem(&PlayerEquipment::uCloak) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uCloak - 1]; + item = player->GetCloakItem(); switch ( item->uItemID ) { case ITEM_RELIC_TWILIGHT: @@ -931,15 +931,15 @@ } if ( !bRingsShownInCharScreen ) pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]), - pPlayers[uPlayerID]->pEquipment.uCloak); + player->pEquipment.uCloak); } } //-------------------------------(Paperdoll/Кукла)------------------------------------------- pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1])); //-------------------------------(Armor/Броня)----------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uArmor ) + if ( player->GetItem(&PlayerEquipment::uArmor) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uArmor - 1]; + item = player->GetArmorItem(); switch ( item->uItemID ) { case ITEM_ARTIFACT_GOVERNORS_ARMOR: @@ -997,19 +997,19 @@ if ( !bRingsShownInCharScreen ) pRenderer->DrawMaskToZBuffer(item_X, item_Y, &pIcons_LOD->pTextures[paperdoll_armor_texture[pBodyComplection][index][0]], - pPlayers[uPlayerID]->pEquipment.uArmor); + player->pEquipment.uArmor); } } //----------------------------------(End of Armor/Конец Брони)------------------------------------------ //----------------------------------(Boot/Обувь)-------------------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uBoot ) + if ( player->GetItem(&PlayerEquipment::uBoot) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uBoot - 1]; + item = player->GetBootItem(); switch ( item->uItemID ) { case ITEM_ARTIFACT_HERMES_SANDALS: index = 5; - v59 = papredoll_flying_feet[pPlayers[uPlayerID]->uCurrentFace]; + v59 = papredoll_flying_feet[player->uCurrentFace]; break; case ITEM_ARTIFACT_LEAGUE_BOOTS: index = 6; @@ -1057,20 +1057,20 @@ GetTickCount() * 0.1, 0, 255); } if ( !bRingsShownInCharScreen ) - pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v59), pPlayers[uPlayerID]->pEquipment.uBoot); + pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v59), player->pEquipment.uBoot); } } //--------------------------------------------(Hand/Рука)------------------------------------------------------ - if ( !pPlayers[uPlayerID]->pEquipment.uMainHand - || ( pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uMainHand -1].GetItemEquipType() != EQUIP_MAIN_HAND) - && (pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uMainHand -1].GetPlayerSkillType() != PLAYER_SKILL_SPEAR - || pPlayers[uPlayerID]->pEquipment.uShield) ) + if ( !player->GetItem(&PlayerEquipment::uMainHand) + || ( player->GetMainHandItem()->GetItemEquipType() != EQUIP_MAIN_HAND) + && (player->GetMainHandItem()->GetPlayerSkillType() != PLAYER_SKILL_SPEAR + || player->GetItem(&PlayerEquipment::uShield)) ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1])); //--------------------------------------------(Belt/Пояс)------------------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uBelt ) + if ( player->GetItem(&PlayerEquipment::uBelt)) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uBelt - 1]; + item = player->GetBeltItem(); switch ( item->uItemID ) { case ITEM_RILIC_TITANS_BELT: @@ -1103,7 +1103,7 @@ pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v75)); } if ( !bRingsShownInCharScreen ) - pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v75), pPlayers[uPlayerID]->pEquipment.uBelt); + pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v75), player->pEquipment.uBelt); } else { @@ -1128,18 +1128,20 @@ } } //---------------------------------------------(Hand2/Рука2)-------------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uMainHand ) + if ( player->GetItem(&PlayerEquipment::uMainHand) ) { - if ( pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uMainHand - 1].GetItemEquipType() == EQUIP_MAIN_HAND - || pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uMainHand - 1].GetPlayerSkillType() == PLAYER_SKILL_SPEAR - && !pPlayers[uPlayerID]->pEquipment.uShield ) + if ( player->GetMainHandItem()->GetItemEquipType() == EQUIP_MAIN_HAND + || player->GetMainHandItem()->GetPlayerSkillType() == PLAYER_SKILL_SPEAR + && !player->GetItem(&PlayerEquipment::uShield) ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1])); } //--------------------------------(Shoulder/Плечи)--------------------------------------------- - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uArmor - 1]; - switch ( item->uItemID ) + if (player->GetItem(&PlayerEquipment::uArmor)) { + item = player->GetArmorItem(); + switch ( item->uItemID ) + { case ITEM_ARTIFACT_GOVERNORS_ARMOR: index = 15; break; @@ -1155,114 +1157,115 @@ default: index = item->uItemID - 66; break; - } - if ( index >= 0 && index < 17 ) - { - if ( pPlayers[uPlayerID]->pEquipment.uMainHand - && (pPlayers[uPlayerID]->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_MAIN_HAND - || pPlayers[uPlayerID]->GetEquippedItemSkillType(EQUIP_MAIN_HAND) == EQUIP_SHIELD - && !pPlayers[uPlayerID]->pEquipment.uShield) )//без щита + } + if ( index >= 0 && index < 17 ) { - v94 = paperdoll_armor_texture[pBodyComplection][index][2]; - if ( paperdoll_armor_texture[pBodyComplection][index][2] == pIcons_LOD->FindTextureByName("pending") ) - { - v94 = paperdoll_armor_texture[pBodyComplection][index][1]; - item_X = pPaperdoll_BodyX + paperdoll_shoulder_coord[pBodyComplection][index][0]; - item_Y = pPaperdoll_BodyY + paperdoll_shoulder_coord[pBodyComplection][index][1]; - } - else + if ( player->GetItem(&PlayerEquipment::uMainHand) + && (player->GetMainHandItem()->GetItemEquipType() == EQUIP_MAIN_HAND + || player->GetMainHandItem()->GetPlayerSkillType() == PLAYER_SKILL_SPEAR + && !player->GetItem(&PlayerEquipment::uShield) ))//без щита { - item_X = pPaperdoll_BodyX + paperdoll_shoulder_second_coord[pBodyComplection][index][0]; - item_Y = pPaperdoll_BodyY + paperdoll_shoulder_second_coord[pBodyComplection][index][1]; - } - if ( v94 != pIcons_LOD->FindTextureByName("pending") ) - { - if ( !(item->uAttributes & 0xF0) ) + v94 = paperdoll_armor_texture[pBodyComplection][index][2]; + if ( paperdoll_armor_texture[pBodyComplection][index][2] == pIcons_LOD->FindTextureByName("pending") ) { - if ( item->uAttributes & 2 ) - pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v94)); - else - { - if ( item->uAttributes & 1 ) - pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v94)); - else - pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v94)); - } + v94 = paperdoll_armor_texture[pBodyComplection][index][1]; + item_X = pPaperdoll_BodyX + paperdoll_shoulder_coord[pBodyComplection][index][0]; + item_Y = pPaperdoll_BodyY + paperdoll_shoulder_coord[pBodyComplection][index][1]; } else { - if ( paperdoll_armor_texture[pBodyComplection][index][2] != pIcons_LOD->FindTextureByName("pending") ) + item_X = pPaperdoll_BodyX + paperdoll_shoulder_second_coord[pBodyComplection][index][0]; + item_Y = pPaperdoll_BodyY + paperdoll_shoulder_second_coord[pBodyComplection][index][1]; + } + if ( v94 != pIcons_LOD->FindTextureByName("pending") ) + { + if ( !(item->uAttributes & 0xF0) ) { - if ( item->uAttributes & 0xF0 ) + if ( item->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v94)); + else + { + if ( item->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v94)); + else + pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v94)); + } + } + else + { + if ( paperdoll_armor_texture[pBodyComplection][index][2] != pIcons_LOD->FindTextureByName("pending") ) { - if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED ) - container = "sptext01"; - if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE ) - container = "sp28a"; - if ( ( item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN ) - container = "sp30a"; - if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE ) - container = "sp91a"; - _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; - if ( _50C9A8_item_enchantment_timer <= 0 ) + if ( item->uAttributes & 0xF0 ) { - _50C9A8_item_enchantment_timer = 0; - item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED ) + container = "sptext01"; + if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE ) + container = "sp28a"; + if ( ( item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN ) + container = "sp30a"; + if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE ) + container = "sp91a"; + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4_ItemToEnchant = 0; + } + pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v94), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), + GetTickCount() * 0.1, 0, 255); } - pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v94), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), - GetTickCount() * 0.1, 0, 255); } } } } - } - else//без ничего или с щитом - { - //v94 = paperdoll_armor_texture[pBodyComplection][index][1]; - if ( paperdoll_armor_texture[pBodyComplection][index][1] != pIcons_LOD->FindTextureByName("pending") ) + else//без ничего или с щитом { - item_X = pPaperdoll_BodyX + paperdoll_shoulder_coord[pBodyComplection][index][0]; - item_Y = pPaperdoll_BodyY + paperdoll_shoulder_coord[pBodyComplection][index][1]; - if ( !(item->uAttributes & 0xF0) ) + //v94 = paperdoll_armor_texture[pBodyComplection][index][1]; + if ( paperdoll_armor_texture[pBodyComplection][index][1] != pIcons_LOD->FindTextureByName("pending") ) { - if ( item->uAttributes & 2 ) - pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1])); + item_X = pPaperdoll_BodyX + paperdoll_shoulder_coord[pBodyComplection][index][0]; + item_Y = pPaperdoll_BodyY + paperdoll_shoulder_coord[pBodyComplection][index][1]; + if ( !(item->uAttributes & 0xF0) ) + { + if ( item->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1])); + else + { + if ( item->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1])); + else + pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1])); + } + } else { - if ( item->uAttributes & 1 ) - pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1])); - else - pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1])); + if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED ) + container = "sptext01"; + if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE ) + container = "sp28a"; + if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN ) + container = "sp30a"; + if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE ) + container = "sp91a"; + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4_ItemToEnchant = 0; + } + pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]), + pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); } } - else - { - if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED ) - container = "sptext01"; - if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE ) - container = "sp28a"; - if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN ) - container = "sp30a"; - if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE ) - container = "sp91a"; - _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; - if ( _50C9A8_item_enchantment_timer <= 0 ) - { - _50C9A8_item_enchantment_timer = 0; - item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; - } - pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]), - pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); - } } } } //----------------------------------------------(Cloak collar/воротник плаща)------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uCloak ) + if ( player->GetItem(&PlayerEquipment::uCloak) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uCloak - 1]; + item = player->GetCloakItem(); switch ( item->uItemID ) { case ITEM_RELIC_TWILIGHT: @@ -1297,7 +1300,7 @@ pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index])); if ( !bRingsShownInCharScreen ) pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]), - pPlayers[uPlayerID]->pEquipment.uCloak); + player->pEquipment.uCloak); } else { @@ -1323,17 +1326,17 @@ } } //--------------------------------------------(Beards/Борода)------------------------------------------------------- - if ( pPlayers[uPlayerID]->uCurrentFace == 12 || pPlayers[uPlayerID]->uCurrentFace == 13 ) + if ( player->uCurrentFace == 12 || player->uCurrentFace == 13 ) { - if ( papredoll_dbrds[pPlayers[uPlayerID]->uCurrentFace] != pIcons_LOD->FindTextureByName("Pending") ) - pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uCurrentFace - 24], - pPaperdoll_BodyY + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uCurrentFace - 23], - pIcons_LOD->GetTexture(papredoll_dbrds[pPlayers[uPlayerID]->uCurrentFace])); + if ( papredoll_dbrds[player->uCurrentFace] != pIcons_LOD->FindTextureByName("Pending") ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_Beards[2 * player->uCurrentFace - 24], + pPaperdoll_BodyY + pPaperdoll_Beards[2 * player->uCurrentFace - 23], + pIcons_LOD->GetTexture(papredoll_dbrds[player->uCurrentFace])); } //--------------------------------------------(Helm/Шлем)------------------------------------------------------------ - if ( pPlayers[uPlayerID]->pEquipment.uHelm ) + if ( player->GetItem(&PlayerEquipment::uHelm) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uHelm - 1]; + item = player->GetHelmItem(); switch ( item->uItemID ) { case ITEM_RELIC_TALEDONS_HELM: @@ -1395,13 +1398,13 @@ } } if ( !bRingsShownInCharScreen ) - pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v127), pPlayers[uPlayerID]->pEquipment.uHelm); + pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v127), player->pEquipment.uHelm); } } //------------------------------------------------(Hand3/Рука3)------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uMainHand ) + if ( player->GetItem(&PlayerEquipment::uMainHand) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uMainHand - 1]; + item = player->GetMainHandItem(); item_X = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item->uItemID].uEquipX; item_Y = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item->uItemID].uEquipY; if ( item->uItemID == 64 ) @@ -1442,12 +1445,12 @@ } if ( !bRingsShownInCharScreen ) pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)), - pPlayers[uPlayerID]->pEquipment.uMainHand); + player->pEquipment.uMainHand); } //--------------------------------------------------(Shield/Щит)--------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uShield ) + if ( player->GetItem(&PlayerEquipment::uShield) ) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uShield - 1]; + item = player->GetOffHandItem(); if ( item->GetPlayerSkillType() == PLAYER_SKILL_DAGGER || item->GetPlayerSkillType() == PLAYER_SKILL_SWORD ) { @@ -1516,18 +1519,18 @@ pPaperdoll_BodyY + pPaperdollLeftEmptyHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhs[uPlayerID - 1])); } if ( !bRingsShownInCharScreen ) - pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v153), pPlayers[uPlayerID]->pEquipment.uShield); + pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v153), player->pEquipment.uShield); } } //--------------------------------------------------------(RightHand/Правая рука)-------------------------------------------------- pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_drhs[uPlayerID - 1])); //--------------------------------------------------------(LeftHand/Левая рука)---------------------------------------------------- - if ( pPlayers[uPlayerID]->pEquipment.uMainHand ) + if ( player->GetItem(&PlayerEquipment::uMainHand)) { - item = &pPlayers[uPlayerID]->pInventoryItemList[pPlayers[uPlayerID]->pEquipment.uMainHand - 1]; + item = player->GetMainHandItem(); if ( item->GetItemEquipType() == EQUIP_MAIN_HAND || item->GetPlayerSkillType() == PLAYER_SKILL_SPEAR - && !pPlayers[uPlayerID]->pEquipment.uShield ) + && !player->GetItem(&PlayerEquipment::uShield) ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1])); @@ -1661,9 +1664,9 @@ player->pEquipment.uRings[i]); } if (player->pEquipment.uAmulet) - CharacterUI_DrawItem(493, 91, &player->pInventoryItemList[player->pEquipment.uAmulet - 1], player->pEquipment.uAmulet); + CharacterUI_DrawItem(493, 91, player->GetAmuletItem(), player->pEquipment.uAmulet); if (player->pEquipment.uGlove) - CharacterUI_DrawItem(586, 88, &player->pInventoryItemList[player->pEquipment.uGlove - 1], player->pEquipment.uGlove); + CharacterUI_DrawItem(586, 88, player->GetGloveItem(), player->pEquipment.uGlove); } //----- (0043BCA7) --------------------------------------------------------
--- a/UI/UiGame.cpp Tue Oct 08 11:06:24 2013 +0200 +++ b/UI/UiGame.cpp Wed Oct 09 08:09:48 2013 +0200 @@ -1720,7 +1720,7 @@ else pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime - | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_13].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uExpireTime ) sub_441A4E(i); continue; @@ -1733,7 +1733,7 @@ else pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime - | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_13].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uExpireTime ) sub_441A4E(i); continue; @@ -1760,7 +1760,7 @@ else pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime - | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_13].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uExpireTime ) sub_441A4E(i); continue;
--- a/mm7_2.cpp Tue Oct 08 11:06:24 2013 +0200 +++ b/mm7_2.cpp Wed Oct 09 08:09:48 2013 +0200 @@ -1741,7 +1741,7 @@ //----- (00450AAA) -------------------------------------------------------- void RespawnGlobalDecorations() { - memset(stru_5E4C90_MapPersistVars._decor_events, 0, 125); + memset(stru_5E4C90_MapPersistVars._decor_events.data(), 0, 125); uint decorEventIdx = 0; for (uint i = 0; i < uNumLevelDecorations; ++i)
--- a/mm7_data.cpp Tue Oct 08 11:06:24 2013 +0200 +++ b/mm7_data.cpp Wed Oct 09 08:09:48 2013 +0200 @@ -1052,7 +1052,7 @@ int _5B65B8_npcdata_hiword_house_or_other; // weak int dword_5B65BC; // weak int dword_5B65C0; // weak -int dword_5B65C4; // weak +int cancelEventProcessing; // weak int dword_5B65C8_timers_count; // weak int npcIdToDismissAfterDialogue; // weak signed int dword_5B65D0_dialogue_actor_npc_id; // weak
--- a/mm7_data.h Tue Oct 08 11:06:24 2013 +0200 +++ b/mm7_data.h Wed Oct 09 08:09:48 2013 +0200 @@ -700,7 +700,7 @@ extern int _5B65B8_npcdata_hiword_house_or_other; // weak extern int dword_5B65BC; // weak extern int dword_5B65C0; // weak -extern int dword_5B65C4; // weak +extern int cancelEventProcessing; // weak extern int dword_5B65C8_timers_count; // weak extern int npcIdToDismissAfterDialogue; // weak extern int dword_5B65D0_dialogue_actor_npc_id; // weak
--- a/stru123.h Tue Oct 08 11:06:24 2013 +0200 +++ b/stru123.h Wed Oct 09 08:09:48 2013 +0200 @@ -1,12 +1,13 @@ #pragma once +#include <array> /* 62 */ #pragma pack(push, 1) struct stru123 { - char field_0[75]; - unsigned char _decor_events[125]; + std::array<unsigned char, 75> field_0; + std::array<unsigned char, 125> _decor_events; }; #pragma pack(pop) extern stru123 stru_5E4C90_MapPersistVars; \ No newline at end of file