Mercurial > mm7
changeset 1836:f017f8e79aa1
Merge
author | Ritor1 |
---|---|
date | Fri, 11 Oct 2013 18:55:43 +0600 |
parents | a5637690ffbb (current diff) 5ea627a263dd (diff) |
children | 303a56458f7b |
files | Render.cpp mm7_2.cpp |
diffstat | 41 files changed, 1641 insertions(+), 2060 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Actor.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -32,6 +32,7 @@ #include "stru298.h" #include "Log.h" #include "Texts.h" +#include "Level/Decoration.h" @@ -2038,7 +2039,7 @@ if ( v3 ) { LABEL_12: - pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + GetPartyReputation()); + pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + pParty->GetPartyReputation()); if ( pParty->uFine < 0 ) pParty->uFine = 0; if ( pParty->uFine > 4000000 ) @@ -4109,7 +4110,7 @@ { Actor::Die(i); if ( pActor->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp); + pParty->GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp); } } } @@ -5001,7 +5002,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]); @@ -5286,7 +5287,7 @@ Actor::ApplyFineForKillingPeasant(uActorID_Monster_); Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); if ( pMonster->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); + pParty->GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); v40 = SPEECH_51; if ( rand() % 100 < 20 ) v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
--- a/Arcomage.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Arcomage.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -3901,7 +3901,7 @@ { pParty->pArcomageWins[v8-108] = 1; auto _a = (signed int)(p2DEvents[ window_SpeakInHouse->par1C - 1].fPriceMultiplier * 100.0); - party_finds_gold(_a, 0); + pParty->PartyFindsGold(_a, 0); } }
--- a/AudioPlayer.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/AudioPlayer.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -21,6 +21,7 @@ #include "GUIWindow.h" #include "Log.h" #include "ErrorHandling.h" +#include "Level/Decoration.h" #include "Bink_Smacker.h"
--- a/CastSpellInfo.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/CastSpellInfo.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -24,6 +24,7 @@ #include "TurnEngine.h" #include "texts.h" #include "LOD.h" +#include "Level/Decoration.h" const size_t CastSpellInfoCount = 10; std::array<CastSpellInfo, CastSpellInfoCount> pCastSpellInfo; @@ -2950,7 +2951,7 @@ v450 = *(int *)v449; if ( pItemsTable->pItems[v450].uEquipType == 18 ) { - party_finds_gold(*((int *)v449 + 3), 0); + pParty->PartyFindsGold(*((int *)v449 + 3), 0); viewparams->bRedrawGameUI = 1; } else @@ -4346,7 +4347,7 @@ pGUIWindow_Settings->CreateButton(165, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 1, 50, "", 0); pGUIWindow_Settings->CreateButton(280, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 2, 51, "", 0); pGUIWindow_Settings->CreateButton(390, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 3, 52, "", 0); - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; } if ( a5 & 8 ) @@ -4356,7 +4357,7 @@ pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Shoot_Monster, 0, 0, "", 0); - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; } if ( a5 & 0x40 ) @@ -4366,7 +4367,7 @@ pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Telekinesis, 0, 0, "", 0); - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; } if ( (char)a5 < 0 ) @@ -4379,7 +4380,7 @@ pGUIWindow_Settings = pCastSpellInfo[result].GetCastSpellInInventoryWindow(); _50C9A0_IsEnchantingInProgress = 1; some_active_character = uActiveCharacter; - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; } if ( HIBYTE(a5) & 1 ) @@ -4392,7 +4393,7 @@ pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 2, 0x33u, "", 0); pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 3, 0x34u, "", 0); pGUIWindow_Settings->CreateButton(8, 8, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Monster_Improvement, 0, 0, "", NULL); - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); } if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings ) {
--- a/Chest.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Chest.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -27,6 +27,7 @@ #include "SpriteObject.h" #include "Mouse.h" #include "Viewport.h" +#include "Level/Decoration.h" size_t uNumChests; // idb struct ChestList *pChestList; @@ -835,7 +836,7 @@ v4 = pChests[chest_id].pInventoryIndices[v3] - 1; if ( pChests[chest_id].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD ) { - party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); + pParty->PartyFindsGold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; } else
--- a/Events.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Events.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -32,6 +32,7 @@ #include "UI\UIHouses.h" #include "Log.h" #include "MM7.h" +#include "Level/Decoration.h" @@ -426,7 +427,7 @@ //v131 = uEventID; v133 = 0; EvtTargetObj = targetObj; - dword_5B65C4 = 0; + dword_5B65C4_cancelEventProcessing = 0; if ( !uEventID ) { if ( !GameUI_Footer_TimeLeft ) @@ -457,7 +458,7 @@ //v7 = ""; while ( 1 ) { - if ( dword_5B65C4 ) + if ( dword_5B65C4_cancelEventProcessing ) goto LABEL_301; //v8 = v4; if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) @@ -924,7 +925,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; @@ -953,7 +954,7 @@ v4 = v124; break; } - v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix; + v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix.data(); for ( v65 = 0; v65 < 126; ++v65 ) { if ( (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v67] == pValue ) @@ -980,7 +981,7 @@ } for (int i = 1; i < 5; i++) { - v72 = (int)pPlayers[i]->pInventoryMatrix; + v72 = (int)pPlayers[i]->pInventoryMatrix.data(); for ( int v71 = 0; v71 < 126; ++v71 ) { if ( (int)&pPlayers[i]->pInventoryItemList[v72] == pValue ) @@ -1020,8 +1021,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/Game.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Game.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -473,8 +473,8 @@ //do for(int i=0; i<4; ++i) { - memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) - memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) + memset(pParty->pPlayers[i].pConditions.data(), 0, 0xA0u);//(pConditions, 0, 160) + memset(pParty->pPlayers[i].pPlayerBuffs.data(), 0, 0x180u);//(pPlayerBuffs[0], 0, 384) //*pHealth = 1; pParty->pPlayers[i].sHealth=1; //pHealth += 1743; //6CF
--- a/Indoor.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Indoor.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -40,6 +40,7 @@ #include "Outdoor_stuff.h" #include "texts.h" #include "GUIWindow.h" +#include "Level/Decoration.h" @@ -6059,7 +6060,7 @@ v20 = pSpriteObjects[v18].stru_24.uItemID; if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) { - party_finds_gold(v19->uSpecEnchantmentType, 0); + pParty->PartyFindsGold(v19->uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; v21 = v17; }
--- a/Indoor.h Fri Oct 11 18:55:07 2013 +0600 +++ b/Indoor.h Fri Oct 11 18:55:43 2013 +0600 @@ -1,6 +1,5 @@ #pragma once -#include "Level/Decoration.h" #include "Indoor_stuff.h" @@ -30,10 +29,6 @@ -extern std::array<LevelDecoration, 3000> pLevelDecorations; -extern size_t uNumLevelDecorations; -extern LevelDecoration* activeLevelDecoration; -
--- a/Items.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Items.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -2215,11 +2215,11 @@ itemId = ITEM_ARTIFACT_LEAGUE_BOOTS; NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, 40); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_WATER, 0, &Player::skillWater); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_WATER, 0, &Player::skillWater); itemId = ITEM_ARTIFACT_RULERS_RING; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); itemId = ITEM_RELIC_MASH; NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 150); @@ -2228,7 +2228,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, -40); itemId = ITEM_RELIC_ETHRICS_STAFF; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 15); itemId = ITEM_RELIC_HARECS_LEATHER; @@ -2251,7 +2251,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -15); itemId = ITEM_RELIC_GLORY_SHIELD; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 5); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, -10); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, -10); @@ -2261,7 +2261,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, -30); itemId = ITEM_RELIC_TALEDONS_HELM; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0, &Player::skillLight); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0, &Player::skillLight); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 15); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 15); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_LUCK, -40); @@ -2271,7 +2271,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, -50); itemId = ITEM_RELIC_PHYNAXIAN_CROWN; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0, &Player::skillFire); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0, &Player::skillFire); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, +50); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 30); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -20); @@ -2296,12 +2296,12 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -25); itemId = ITEM_RELIC_JUSTICE; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_BODY, 0, &Player::skillBody); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_BODY, 0, &Player::skillBody); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, -40); itemId = ITEM_RELIC_MEKORIGS_HAMMER; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 75); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, -50);
--- a/Keyboard.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Keyboard.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -16,6 +16,7 @@ #include "Indoor.h" #include "viewport.h" #include "AudioPlayer.h" +#include "Level/Decoration.h" struct KeyboardActionMapping *pKeyActionMap;
--- a/Level/Decoration.h Fri Oct 11 18:55:07 2013 +0600 +++ b/Level/Decoration.h Fri Oct 11 18:55:43 2013 +0600 @@ -1,9 +1,11 @@ #pragma once #include <cstdint> +#include <array> #include "../VectorTypes.h" + enum LEVEL_DECORATION_FLAGS: uint16_t { LEVEL_DECORATION_TRIGGERED_BY_TOUCH = 0x01, @@ -35,4 +37,10 @@ int16_t _idx_in_stru123; int16_t field_1E; }; + + + +extern std::array<LevelDecoration, 3000> pLevelDecorations; +extern size_t uNumLevelDecorations; +extern LevelDecoration* activeLevelDecoration; #pragma pack(pop)
--- a/Mouse.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Mouse.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -512,7 +512,9 @@ y = pY; x = pX; } - if ( pCurrentScreen != SCREEN_GAME)// || !dword_507B98_ctrl_pressed ) // stealing cursor + + extern bool _507B98_ctrl_pressed; + if ( pCurrentScreen != SCREEN_GAME || !_507B98_ctrl_pressed ) // stealing cursor goto LABEL_30; v4 = GetCurrentMenuID(); x = pX; @@ -580,7 +582,9 @@ else v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; v6 = (unsigned __int16)v5; - if (PID_TYPE(v5) == OBJECT_Actor + + auto type = PID_TYPE(v6); + if (type == OBJECT_Actor && uActiveCharacter && v5 < 0x2000000 && pPlayers[uActiveCharacter]->CanAct()
--- a/NPC.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/NPC.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -16,6 +16,7 @@ #include "UI\UIHouses.h" #include "Indoor.h" #include "MapInfo.h" +#include "Level/Decoration.h" int pDialogueNPCCount; std::array<struct Texture *, 6> pDialogueNPCPortraits;
--- a/NewUI/Core/UIControl.h Fri Oct 11 18:55:07 2013 +0600 +++ b/NewUI/Core/UIControl.h Fri Oct 11 18:55:43 2013 +0600 @@ -1,5 +1,6 @@ #pragma once #include <list> +#include <algorithm> class UIControl {
--- a/OSWindow.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/OSWindow.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -57,12 +57,16 @@ } +bool _507B98_ctrl_pressed = false; bool OSWindow::WinApiMessageProc(UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *result) { switch (msg) { case WM_KEYUP: { + if (wparam == VK_CONTROL) + _507B98_ctrl_pressed = false; + OnKey(wparam); return *result = 0, true; } @@ -207,6 +211,11 @@ UI_OnKeyDown(wparam); return 0; } + if (wparam == VK_CONTROL) + { + _507B98_ctrl_pressed = true; + return false; + } if ( wparam == VK_ESCAPE ) { pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0); @@ -690,7 +699,7 @@ //SubMenu "Party" case 40006: pParty->SetFood(pParty->uNumFoodRations + 20); break; case 40007: pParty->SetGold(pParty->uNumGold + 10000); break; - case 40008: GivePartyExp(20000); break; + case 40008: pParty->GivePartyExp(20000); break; case 40013: pParty->SetGold(0); break; case 40059:
--- a/Outdoor.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Outdoor.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -35,6 +35,7 @@ #include "Outdoor_stuff.h" #include "BSPModel.h" #include "GUIWindow.h" +#include "Level/Decoration.h" MapStartPoint uLevel_StartingPointType; // weak
--- a/Party.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Party.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -31,6 +31,10 @@ struct ActionQueue *pPartyActionQueue = new ActionQueue; +std::array<bool, 4> playerAlreadyPicked; // byte_AE3368_ +char PickedPlayer2_unused; // byte_AE3369_ +char PickedPlayer3_unused; // byte_AE336A_ +char PickedPlayer4_unused; // byte_AE336B_ @@ -39,7 +43,7 @@ { field_70A = 0; - for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) + for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; ++i) { auto npc = pNPCStats->pNewNPCData + i; if (npc->Hired() && @@ -112,27 +116,19 @@ bool Party::_497FC5_check_party_perception_against_level() { int uMaxPerception; // edi@1 - Player *v2; // esi@1 - signed int v3; // ebx@1 - Player *v4; // ecx@2 signed int v5; // eax@3 bool result; // eax@7 uMaxPerception = 0; - v2 = this->pPlayers; - v3 = 4; - do + for (int i = 0; i < 4; i++) { - if ( v2->CanAct() ) + if ( this->pPlayers[i].CanAct() ) { - v5 = v2->GetPerception(); + v5 = this->pPlayers[i].GetPerception(); if ( v5 > uMaxPerception ) uMaxPerception = v5; } - ++v2; - --v3; } - while ( v3 ); if ( uLevelMapStatsID && (signed int)uLevelMapStatsID < 77 ) result = uMaxPerception >= 2 * pMapStats->pInfos[uLevelMapStatsID]._per; else @@ -151,19 +147,11 @@ //----- (0049370F) -------------------------------------------------------- int Party::GetNextActiveCharacter() { - Party *v1; // esi@1 int v2; // eax@4 - signed int v4; // ecx@6 - Player *v5; // edx@6 Player *v6; // eax@7 - Player *v7; // ecx@23 signed int v8; // esi@23 - signed int v9; // edx@23 - Player **v10; // edi@23 - Player *v11; // eax@24 int v12; // [sp+Ch] [bp-4h]@1 - v1 = this; v12 = 0; if ( pParty->bTurnBasedModeOn == 1 ) { @@ -172,100 +160,54 @@ v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID); return v2 + 1; } - v4 = 0; - v5 = v1->pPlayers;//[0].uTimeToRecovery; - while ( 1 ) + + if ( playerAlreadyPicked[0] && playerAlreadyPicked[1] && playerAlreadyPicked[2] && playerAlreadyPicked[3] ) + memset(playerAlreadyPicked.data(), 0, 4u); + for (int i = 0; i < 4; i++) { - v6 = ::pPlayers[v4 + 1]; - if ( v6->pConditions[2] - || v6->pConditions[12] - || v6->pConditions[13] - || v6->pConditions[14] - || v6->pConditions[15] - || v6->pConditions[16] - || v5->uTimeToRecovery ) + v6 = &this->pPlayers[i]; + if ( !v6->CanAct() + || v6->uTimeToRecovery > 0) { - byte_AE3368[v4] = 1; + playerAlreadyPicked[i] = true; } - else if ( !byte_AE3368[v4] ) + else if ( !playerAlreadyPicked[i] ) + { + playerAlreadyPicked[i] = true; + if (i > 0) //TODO check if this condition really should be here. it is equal to the original source but still seems kind of weird + return i + 1; break; - ++v4; - ++v5; - if ( v4 >= 4 ) - break; - } - if(v4<4) - { - v12 = v4; - byte_AE3368[v4] = 1; + } } - if ( (unsigned __int8)(byte_AE3369 & byte_AE336A & byte_AE336B) & byte_AE3368[0] ) - memset(byte_AE3368.data(), 0, 4u); - v2 = v12; - if ( v12 ) - return v2 + 1; - v7 = v1->pPlayers;//[0].uSpeedBonus; - v8 = 0; - v9 = 1; - v10 = &::pPlayers[1]; - while ( 2 ) + + for (int i = 0; i < 4; i++) { - v11 = *v10; - if ( !(*v10)->pConditions[2] - && !v11->pConditions[12] - && !v11->pConditions[13] - && !v11->pConditions[14] - && !v11->pConditions[15] - && !v11->pConditions[16] - && !v7->uTimeToRecovery ) + if ( this->pPlayers[i].CanAct() + && this->pPlayers[i].uTimeToRecovery == 0 ) { - if ( v12 ) + if ( v12 == 0 || this->pPlayers[i].uSpeedBonus > v8 ) { - if ( v7->uSpeedBonus > v8 ) - { - v8 = v7->uSpeedBonus; - v12 = v9; - } - } - else - { - v8 = *(short *)v7; - v12 = v9; + v8 = this->pPlayers[i].uSpeedBonus; + v12 = i + 1; } } - ++v10; - ++v9; - ++v7; - if ( v9 - 1 < 4 ) - continue; - return v12; } + return v12; } //----- (00493244) -------------------------------------------------------- bool Party::HasItem(unsigned int uItemID) { - Player *v2; // edx@1 - signed int v3; // ecx@2 - ItemGen *v4; // eax@2 - - v2 = pParty->pPlayers;//[0].pInventoryItems; - while ( v2 <= &pParty->pPlayers[3] ) + for (int player = 0; player < 4; player++) { - v3 = 0; - v4 = v2->pInventoryItemList; - do + for (int itemPos = 0; itemPos < 138; itemPos++) { - if ( v4->uItemID == uItemID ) - return 1; - ++v3; - ++v4; + if (pParty->pPlayers[player].pOwnItems[itemPos].uItemID == uItemID) + return true; } - while ( v3 < 138 ); - ++v2; } - return 0; + return false; } @@ -324,216 +266,166 @@ unsigned __int64 total_exp = 0; for (uint i = 0; i < 4; ++i) total_exp += pPlayers[i].uExperience; - return total_exp / 1000; + return (unsigned int)(min(total_exp / 1000, UINT_MAX)); //min wasn't present, but could be incorrect without it } //----- (0049137D) -------------------------------------------------------- void Party::CreateDefaultParty(char bGiveItems) { - Party *pParty; // esi@1 - signed __int16 v3; // ax@1 - //int pResMagicBase; // ecx@1 Player *pCharacter; // esi@3 - //signed int uSpellBookPageCount; // edx@5 - int pMagicSkills; // eax@5 int uSkillIdx; // eax@11 - //unsigned __int8 v9; // zf@37 - //char v10; // sf@37 - //unsigned __int8 v11; // of@37 - ItemGen *pItems; // eax@38 - signed int v13; // ecx@38 - int uMaxSP; // eax@42 - unsigned int v15; // [sp-4h] [bp-44h]@14 unsigned int v16; // [sp-4h] [bp-44h]@26 - int v17; // [sp+10h] [bp-30h]@1 - int v18; // [sp+14h] [bp-2Ch]@11 signed int uNumPlayers; // [sp+18h] [bp-28h]@1 ItemGen Dst; // [sp+1Ch] [bp-24h]@10 - - pParty = this; - pHireling1Name[0] = 0; pHireling2Name[0] = 0; - pParty->hirelingScrollPosition = 0; + this->hirelingScrollPosition = 0; memset(pHirelings, 0, 2 * sizeof(*pHirelings)); strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan - pParty->pPlayers[0].uPrevFace = 17; - pParty->pPlayers[0].uCurrentFace = 17; - pParty->pPlayers[0].uPrevVoiceID = 17; - pParty->pPlayers[0].uVoiceID = 17; - pParty->pPlayers[0].uMight = 30; - pParty->pPlayers[0].uIntelligence = 5; - pParty->pPlayers[0].uWillpower = 5; - pParty->pPlayers[0].uEndurance = 13; - pParty->pPlayers[0].uAccuracy = 13; - pParty->pPlayers[0].uSpeed = 14; - pParty->pPlayers[0].uLuck = 7; - pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1; // armsmaster - pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1; // bow - pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1; // sword - pParty->pPlayers[1].uPrevFace = 3; - pParty->pPlayers[1].uCurrentFace = 3; - pParty->pPlayers[1].uPrevVoiceID = 3; - pParty->pPlayers[1].uVoiceID = 3; - strcpy(pParty->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic - pParty->pPlayers[1].uMight = 13; - pParty->pPlayers[1].uIntelligence = 9; - pParty->pPlayers[1].uWillpower = 9; - pParty->pPlayers[1].uEndurance = 13; - pParty->pPlayers[1].uAccuracy = 13; - pParty->pPlayers[1].uSpeed = 13; - pParty->pPlayers[1].uLuck = 13; - pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1; // stealing - pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1; // dagger - pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1; // disarm trap - pParty->pPlayers[2].uPrevFace = 14; - pParty->pPlayers[2].uCurrentFace = 14; - pParty->pPlayers[2].uPrevVoiceID = 14; - pParty->pPlayers[2].uVoiceID = 14; - strcpy(pParty->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena - pParty->pPlayers[2].uMight = 12; - pParty->pPlayers[2].uIntelligence = 9; - pParty->pPlayers[2].uWillpower = 20; - pParty->pPlayers[2].uEndurance = 22; - pParty->pPlayers[2].uAccuracy = 7; - pParty->pPlayers[2].uSpeed = 13; - pParty->pPlayers[2].uLuck = 7; - pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1; // alchemy - pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1; // body - pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1; // mace - strcpy(pParty->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis - v3 = 10; - pParty->pPlayers[3].uPrevFace = 10; - pParty->pPlayers[3].uCurrentFace = 10; - //pResMagicBase = (int)&pParty->pPlayers[0].sResMagicBase; - pParty->pPlayers[3].uEndurance = 13; - pParty->pPlayers[3].uAccuracy = 13; - pParty->pPlayers[3].uSpeed = 13; - pParty->pPlayers[3].uPrevVoiceID = 10; - pParty->pPlayers[3].uVoiceID = 10; - pParty->pPlayers[3].uMight = 5; - pParty->pPlayers[3].uIntelligence = 30; - pParty->pPlayers[3].uWillpower = 9; - pParty->pPlayers[3].uLuck = 7; - pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1; // air - pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1; // fire - pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1; // staff - //uNumPlayers = 4; - //while ( 1 ) + this->pPlayers[0].uPrevFace = 17; + this->pPlayers[0].uCurrentFace = 17; + this->pPlayers[0].uPrevVoiceID = 17; + this->pPlayers[0].uVoiceID = 17; + this->pPlayers[0].uMight = 30; + this->pPlayers[0].uIntelligence = 5; + this->pPlayers[0].uWillpower = 5; + this->pPlayers[0].uEndurance = 13; + this->pPlayers[0].uAccuracy = 13; + this->pPlayers[0].uSpeed = 14; + this->pPlayers[0].uLuck = 7; + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1; // armsmaster + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1; // bow + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1; // sword + this->pPlayers[1].uPrevFace = 3; + this->pPlayers[1].uCurrentFace = 3; + this->pPlayers[1].uPrevVoiceID = 3; + this->pPlayers[1].uVoiceID = 3; + strcpy(this->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic + this->pPlayers[1].uMight = 13; + this->pPlayers[1].uIntelligence = 9; + this->pPlayers[1].uWillpower = 9; + this->pPlayers[1].uEndurance = 13; + this->pPlayers[1].uAccuracy = 13; + this->pPlayers[1].uSpeed = 13; + this->pPlayers[1].uLuck = 13; + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1; // stealing + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1; // dagger + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1; // disarm trap + this->pPlayers[2].uPrevFace = 14; + this->pPlayers[2].uCurrentFace = 14; + this->pPlayers[2].uPrevVoiceID = 14; + this->pPlayers[2].uVoiceID = 14; + strcpy(this->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena + this->pPlayers[2].uMight = 12; + this->pPlayers[2].uIntelligence = 9; + this->pPlayers[2].uWillpower = 20; + this->pPlayers[2].uEndurance = 22; + this->pPlayers[2].uAccuracy = 7; + this->pPlayers[2].uSpeed = 13; + this->pPlayers[2].uLuck = 7; + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1; // alchemy + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1; // body + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1; // mace + strcpy(this->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis + this->pPlayers[3].uPrevFace = 10; + this->pPlayers[3].uCurrentFace = 10; + this->pPlayers[3].uEndurance = 13; + this->pPlayers[3].uAccuracy = 13; + this->pPlayers[3].uSpeed = 13; + this->pPlayers[3].uPrevVoiceID = 10; + this->pPlayers[3].uVoiceID = 10; + this->pPlayers[3].uMight = 5; + this->pPlayers[3].uIntelligence = 30; + this->pPlayers[3].uWillpower = 9; + this->pPlayers[3].uLuck = 7; + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1; // air + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1; // fire + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1; // staff for (uNumPlayers = 0; uNumPlayers < 4; uNumPlayers++) { pCharacter = &pParty->pPlayers[uNumPlayers]; if (pCharacter->classType == PLAYER_CLASS_KNIGHT) - pCharacter->sResMagicBase = v3; //player[i].pResMagicBase - //uSpellBookPageCount = 0; - //pMagicSkills = pPlayers[uNumPlayers].pActiveSkills[12];// Skills - //while ( !*(short *)pMagicSkills ) //player[i].skillFire + pCharacter->sResMagicBase = 10; //player[i].pResMagicBase pCharacter->lastOpenedSpellbookPage = 0; - for (int i = 0; i < 9; i++)//for Magic Book + for (int i = 0; i < 9; i++)//for Magic Book { - //++uSpellBookPageCount; - //pMagicSkills++; - //if ( uSpellBookPageCount >= 9 ) - //goto LABEL_10; if (pPlayers[uNumPlayers].pActiveSkills[12+i]) - { - pCharacter->lastOpenedSpellbookPage = i; - break; - } + { + pCharacter->lastOpenedSpellbookPage = i; + break; + } } -//LABEL_10: pCharacter->uExpressionTimePassed = 0; Dst.Reset(); if ( bGiveItems ) { pItemsTable->GenerateItem(2, 40, &Dst); //ring pCharacter->AddItem2(-1, &Dst); - //uSkillIdx = 0; - //v18 = 0; - //do - for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++) + for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++) { if ( pCharacter->pActiveSkills[uSkillIdx] ) { switch ( uSkillIdx ) { case PLAYER_SKILL_STAFF: - v15 = ITEM_STAFF_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_STAFF_1); break; case PLAYER_SKILL_SWORD: - v15 = ITEM_LONGSWORD_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_LONGSWORD_1); break; case PLAYER_SKILL_DAGGER: - v15 = ITEM_DAGGER_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_DAGGER_1); break; case PLAYER_SKILL_AXE: - v15 = ITEM_AXE_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_AXE_1); break; case PLAYER_SKILL_SPEAR: - v15 = ITEM_SPEAR_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_SPEAR_1); break; case PLAYER_SKILL_BOW: - v15 = ITEM_CROSSBOW_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_CROSSBOW_1); break; case PLAYER_SKILL_MACE: - v15 = ITEM_MACE_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_MACE_1); break; case PLAYER_SKILL_SHIELD: - v15 = ITEM_BUCKLER_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_BUCKLER_1); break; case PLAYER_SKILL_LEATHER: - v15 = ITEM_LEATHER_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_LEATHER_1); break; case PLAYER_SKILL_CHAIN: - v15 = ITEM_CHAINMAIL_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_CHAINMAIL_1); break; case PLAYER_SKILL_PLATE: - v15 = ITEM_PLATE_1; - pCharacter->WearItem(v15); + pCharacter->WearItem(ITEM_PLATE_1); break; case PLAYER_SKILL_FIRE: - v16 = ITEM_SPELLBOOK_FIRE_STRIKE; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_SPELLBOOK_FIRE_STRIKE); break; case PLAYER_SKILL_AIR: - v16 = ITEM_SPELLBOOK_AIR_FEATHER_FALL; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_SPELLBOOK_AIR_FEATHER_FALL); break; case PLAYER_SKILL_WATER: - v16 = ITEM_SPELLBOOK_WATER_POISON_SPRAY; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_SPELLBOOK_WATER_POISON_SPRAY); break; case PLAYER_SKILL_EARTH: - v16 = ITEM_SPELLBOOK_EARTH_SLOW; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_SPELLBOOK_EARTH_SLOW); break; case PLAYER_SKILL_SPIRIT: - v16 = ITEM_SPELLBOOK_SPIRIT_BLESS; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_SPELLBOOK_SPIRIT_BLESS); break; case PLAYER_SKILL_MIND: - v16 = ITEM_SPELLBOOK_MIND_MIND_BLAST; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_SPELLBOOK_MIND_MIND_BLAST); break; case PLAYER_SKILL_BODY: - v16 = ITEM_SPELLBOOK_BODY_FIRST_AID; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_SPELLBOOK_BODY_FIRST_AID); break; case PLAYER_SKILL_ITEM_ID: case PLAYER_SKILL_REPAIR: @@ -547,62 +439,30 @@ pCharacter->AddItem(-1, v16); break; case PLAYER_SKILL_DODGE: - v16 = ITEM_BOOTS_1; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_BOOTS_1); break; case PLAYER_SKILL_UNARMED: - v16 = ITEM_GAUNTLETS_1; - pCharacter->AddItem(-1, v16); + pCharacter->AddItem(-1, ITEM_GAUNTLETS_1); break; default: break; } } - //uSkillIdx = v18 + 1; - //v11 = uSkillIdx > 36; - //v9 = v18 == 35; - //v10 = uSkillIdx - 35 < 0; } - //while (uSkillIdx < 36); - pItems = pCharacter->pInventoryItemList; - //v13 = 138; for (int i = 0; i < 138; i++) { - if ( pItems->uItemID ) - pItems->uAttributes |= 1; - ++pItems; - //--v13; + if ( pCharacter->pInventoryItemList[i].uItemID != 0) + pCharacter->pInventoryItemList[i].SetIdentified(); } - //while ( v13 ); } pCharacter->sHealth = pCharacter->GetMaxHealth(); pCharacter->sMana = pCharacter->GetMaxMana(); - //pCharacter++; - //uNumPlayers--; - //if (!uNumPlayers) - //break; - //pResMagicBase = (int)pCharacter; - v3 = 10; } } //----- (004917CE) -------------------------------------------------------- int Party::Reset() -{ - //Party *v1; // esi@1 - //unsigned __int64 *pTimePlayed; // edi@1 - //bool v3; // edx@1 - //Player **v4; // eax@1 - //Player *v5; // ecx@1 - PLAYER_SEX pSex; // cl@3 - PLAYER_SEX v7; // al@6 - PLAYER_SEX v8; // al@9 - PLAYER_SEX v9; // cl@12 - //Player *v12; // edx@17 - //signed int v13; // edi@18 - SpellBuff *v14; // ebx@21 - signed int v15; // edi@21 - +{ Zero(); field_708 = 15; @@ -632,40 +492,8 @@ pPlayers[0].uPrevVoiceID = 17; pPlayers[0].uVoiceID = 17; pPlayers[0].SetInitialStats(); - - switch ( pPlayers[0].uVoiceID ) - { - case 0: - case 1: - case 2: - case 3: - case 8: - case 9: - case 12: - case 13: - case 16: - case 17: - case 20: - case 23: - default: - pSex = SEX_MALE; - break; - case 4: - case 5: - case 6: - case 7: - case 10: - case 11: - case 14: - case 15: - case 18: - case 19: - case 21: - case 24: - pSex = SEX_FEMALE; - break; - } - pPlayers[0].uSex = pSex; + + pPlayers[0].uSex = pPlayers[0].GetSexByVoice(); pPlayers[0].RandomizeName(); strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); @@ -674,128 +502,24 @@ pPlayers[1].uPrevVoiceID = 3; pPlayers[1].uVoiceID = 3; pPlayers[1].SetInitialStats(); - v7 = SEX_MALE; - switch (pPlayers[1].uVoiceID) - { - case 0: - case 1: - case 2: - case 3: - case 8: - case 9: - case 0xCu: - case 0xDu: - case 0x10u: - case 0x11u: - case 0x14u: - case 0x17u: - v7 = SEX_MALE; - break; - case 4: - case 5: - case 6: - case 7: - case 0xAu: - case 0xBu: - case 0xEu: - case 0xFu: - case 0x12u: - case 0x13u: - case 0x15u: - case 0x18u: - v7 = SEX_FEMALE; - break; - default: - break; - } - pPlayers[1].uSex = v7; + pPlayers[1].uSex = pPlayers[1].GetSexByVoice(); pPlayers[1].RandomizeName(); strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); pPlayers[2].uCurrentFace = 14; pPlayers[2].uPrevVoiceID = 14; pPlayers[2].uVoiceID = 14; pPlayers[2].SetInitialStats(); - v8 = SEX_MALE; - switch (pPlayers[2].uVoiceID) - { - case 0: - case 1: - case 2: - case 3: - case 8: - case 9: - case 0xCu: - case 0xDu: - case 0x10u: - case 0x11u: - case 0x14u: - case 0x17u: - v8 = SEX_MALE; - break; - case 4: - case 5: - case 6: - case 7: - case 0xAu: - case 0xBu: - case 0xEu: - case 0xFu: - case 0x12u: - case 0x13u: - case 0x15u: - case 0x18u: - v8 = SEX_FEMALE; - break; - default: - break; - } - pPlayers[2].uSex = v8; + pPlayers[2].uSex = pPlayers[3].GetSexByVoice(); pPlayers[2].RandomizeName(); strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); pPlayers[3].uCurrentFace = 10; pPlayers[3].uPrevVoiceID = 10; pPlayers[3].uVoiceID = 10; pPlayers[3].SetInitialStats(); - v9 = SEX_MALE; - switch (pPlayers[3].uVoiceID) - { - case 0u: - case 1u: - case 2u: - case 3u: - case 8u: - case 9u: - case 0xCu: - case 0xDu: - case 0x10u: - case 0x11u: - case 0x14u: - case 0x17u: - v9 = SEX_MALE; - break; - case 4u: - case 5u: - case 6u: - case 7u: - case 0xAu: - case 0xBu: - case 0xEu: - case 0xFu: - case 0x12u: - case 0x13u: - case 0x15u: - case 0x18u: - v9 = SEX_FEMALE; - break; - default: - break; - } - pPlayers[3].uSex = v9; + pPlayers[3].uSex = pPlayers[3].GetSexByVoice(); pPlayers[3].RandomizeName(); strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); - - - + for (uint i = 0; i < 4; ++i) { pPlayers[i].uTimeToRecovery = 0; @@ -844,30 +568,22 @@ int v1; // edi@9 int v2; // ebx@9 int v3; // eax@9 - unsigned int v4; // [sp+8h] [bp-4h]@4 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); if ( pParty->bTurnBasedModeOn != 1 ) { - v4 = 0; - if ( (signed int)uNumActors > 0 ) + for (unsigned int i = 0; i < uNumActors; i++) { - v0 = pActors.data();//[0].pMonsterInfo.uMovementType; - do + v0 = &pActors[i]; + if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long && v0->pMonsterInfo.uMovementType != 5 ) { - if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long && v0->pMonsterInfo.uMovementType != 5 ) - { - v1 = abs(v0->vPosition.x - pParty->vPosition.x); - v2 = abs(v0->vPosition.y - pParty->vPosition.y); - v3 = abs(v0->vPosition.z - pParty->vPosition.z); - if (int_get_vector_length(v1, v2, v3) < 512) - Actor::AI_Flee(v4, 4, 0, 0); - } - ++v4; - ++v0; + v1 = abs(v0->vPosition.x - pParty->vPosition.x); + v2 = abs(v0->vPosition.y - pParty->vPosition.y); + v3 = abs(v0->vPosition.z - pParty->vPosition.z); + if (int_get_vector_length(v1, v2, v3) < 512) + Actor::AI_Flee(i, 4, 0, 0); } - while ( (signed int)v4 < (signed int)uNumActors ); } } } @@ -875,15 +591,6 @@ //----- (00491BF9) -------------------------------------------------------- void Party::ResetPosMiscAndSpellBuffs() { - Party *v1; // esi@1 - Player *v2; // edi@1 - SpellBuff *v3; // ebx@2 - SpellBuff *v4; // esi@5 - signed int v5; // edi@5 - signed int v6; // [sp+8h] [bp-8h]@1 - signed int v7; // [sp+Ch] [bp-4h]@2 - - v1 = this; this->vPosition.y = 0; this->vPosition.z = 0; this->vPosition.x = 0; @@ -901,56 +608,30 @@ this->field_6FC = 0; this->field_708 = 15; this->field_0 = 25; - v2 = this->pPlayers;//[0].pPlayerBuffs; - v6 = 4; - do + + for (auto playerId = 0; playerId < 4; playerId++) { - v3 = v2->pPlayerBuffs; - v7 = 24; - do + for (auto buffId = 0; buffId < 24; buffId++) { - v3->Reset(); - ++v3; - --v7; + this->pPlayers[playerId].pPlayerBuffs[buffId].Reset(); } - while ( v7 ); - ++v2; - --v6; } - while ( v6 ); - v4 = v1->pPartyBuffs; - v5 = 20; - do + for (auto buffId = 0; buffId < 20; buffId++) { - v4->Reset(); - ++v4; - --v5; + this->pPartyBuffs[buffId].Reset(); } - while ( v5 ); } //----- (004909F4) -------------------------------------------------------- void Party::UpdatePlayersAndHirelingsEmotions() { - //Player *v1; // esi@2 - //unsigned int v2; // eax@3 - //__int16 v3; // cx@5 int v4; // edx@27 - //signed int v5; // eax@52 - //PlayerFrame *v6; // edx@53 - //NPCData *v7; // esi@60 - //signed int v8; // ebp@61 - //int v9; // ebx@62 - //unsigned int v10; // edi@62 - //signed int v11; // [sp+0h] [bp-4h]@2 - //v1 = this->pPlayers;//(char *)&this->pPlayers[0].uExpressionID; for (int i = 0; i < 4; ++i) { - auto player = pPlayers + i; + Player* player = &pPlayers[i]; player->uExpressionTimePassed += (unsigned short)pMiscTimer->uTimeElapsed; - auto condition = player->GetMajorConditionIdx(); if (condition == Condition_Good || condition == Condition_Zombie) { @@ -982,19 +663,19 @@ else player->expression = CHARACTER_EXPRESSION_30; } - for (int j = 0; j < pPlayerFrameTable->uNumFrames; ++j) + for (unsigned int j = 0; j < pPlayerFrameTable->uNumFrames; ++j) { - auto frame = pPlayerFrameTable->pFrames + j; + PlayerFrame* frame = &pPlayerFrameTable->pFrames[j]; if (frame->expression == player->expression) { - player->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[j].uAnimLength; + player->uExpressionTimeLength = 8 * frame->uAnimLength; break; } } } - else if (player->expression != 34 && - player->expression != 35 && - player->expression != 36 || + else if (player->expression != CHARACTER_EXPRESSION_DMGRECVD_MINOR && + player->expression != CHARACTER_EXPRESSION_DMGRECVD_MODERATE && + player->expression != CHARACTER_EXPRESSION_DMGRECVD_MAJOR || player->uExpressionTimePassed >= player->uExpressionTimeLength) { player->uExpressionTimeLength = 0; @@ -1025,10 +706,9 @@ } } - for (int i = 0; i < 2; ++i) { - auto hireling = pParty->pHirelings + i; + NPCData* hireling = &pParty->pHirelings[i]; if (!hireling->evt_C) continue; @@ -1053,33 +733,11 @@ void Party::RestAndHeal() { Player *pPlayer; // esi@4 - ItemGen *v7; // eax@10 - signed int v11; // ecx@26 - signed int v12; // [sp-4h] [bp-1Ch]@26 bool have_vessels_soul; // [sp+10h] [bp-8h]@10 -/* v1 = pParty->pPartyBuffs; - do - { - v1->Reset(); - ++v1; - } - while ( (signed int)v1 < (signed int)pParty->pPlayers ); - v15 = 0; - do - { - pPlayer = &pParty->pPlayers[v15]; - v3 = 20; - v4 = pPlayer->pPlayerBuffs; - do - { - v4->Reset(); - ++v4; - --v3; - } - while ( v3 );*/ for ( uint i = 0; i < 20; ++i ) pParty->pPartyBuffs[i].Reset(); + for ( int pPlayerID = 0; pPlayerID < 4; ++pPlayerID ) { pPlayer = &pParty->pPlayers[pPlayerID]; @@ -1087,25 +745,23 @@ pPlayer->pPlayerBuffs[i].Reset(); pPlayer->Zero(); - if ( pPlayer->pConditions[14] || pPlayer->pConditions[15] || pPlayer->pConditions[16] )//Dead/Petrified/Eradicated + if ( pPlayer->pConditions[Condition_Dead] || pPlayer->pConditions[Condition_Pertified] || pPlayer->pConditions[Condition_Eradicated] )//Dead/Petrified/Eradicated continue; - pPlayer->pConditions[13] = 0;//Unconcious - pPlayer->pConditions[4] = 0;//Drunk - pPlayer->pConditions[3] = 0;//Fear - pPlayer->pConditions[2] = 0;//Sleep - pPlayer->pConditions[1] = 0;//Weak + pPlayer->pConditions[Condition_Unconcious] = 0;//Unconcious + pPlayer->pConditions[Condition_Drunk] = 0;//Drunk + pPlayer->pConditions[Condition_Fear] = 0;//Fear + pPlayer->pConditions[Condition_Sleep] = 0;//Sleep + pPlayer->pConditions[Condition_Weak] = 0;//Weak pPlayer->uTimeToRecovery = 0; pPlayer->sHealth = pPlayer->GetMaxHealth(); pPlayer->sMana = pPlayer->GetMaxMana(); if ( pPlayer->classType == PLAYER_CLASS_LICH ) { have_vessels_soul = false; - v7 = pPlayer->pInventoryItemList;//[0].field_1A; - for ( uint i = 138; i; --i ) + for ( uint i = 0; i < 138; i++ ) { - if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer == pPlayerID + 1 ) + if ( pPlayer->pInventoryItemList[i].uItemID == ITEM_LICH_JAR_FULL && pPlayer->pInventoryItemList[i].uHolderPlayer == pPlayerID + 1 ) have_vessels_soul = true; - ++v7; } if ( !have_vessels_soul ) { @@ -1113,44 +769,28 @@ pPlayer->sMana = pPlayer->GetMaxMana() / 2; } } - if ( !pPlayer->pConditions[17] )// Zombie + + if (pPlayer->pConditions[Condition_Zombie]) + { + pPlayer->sMana = 0; + pPlayer->sHealth /= 2; + } + else if ( pPlayer->pConditions[Condition_Poison3] || pPlayer->pConditions[Condition_Disease3] ) { - if ( pPlayer->pConditions[10] || pPlayer->pConditions[11] ) - { - v11 = 4; - v12 = 4; - } - else - { - if ( !pPlayer->pConditions[8] && !pPlayer->pConditions[9] ) - { - if ( !pPlayer->pConditions[6] && !pPlayer->pConditions[7] ) - { - if ( pPlayer->pConditions[5] ) - pPlayer->sMana = 0; - UpdatePlayersAndHirelingsEmotions(); - continue; - } - pPlayer->sHealth /= 2; - pPlayer->sMana = pPlayer->sMana / 2; - if ( pPlayer->pConditions[5] ) - pPlayer->sMana = 0; - UpdatePlayersAndHirelingsEmotions(); - continue; - } - v11 = 3; - v12 = 3; - } - pPlayer->sHealth /= v11; - pPlayer->sMana = pPlayer->sMana / v12; - if ( pPlayer->pConditions[5] ) - pPlayer->sMana = 0; - UpdatePlayersAndHirelingsEmotions(); - continue; + pPlayer->sHealth /= 4; + pPlayer->sMana /= 4; } - pPlayer->sMana = 0; - pPlayer->sHealth = pPlayer->sHealth / 2; - if ( pPlayer->pConditions[5] ) + else if ( pPlayer->pConditions[Condition_Poison2] || pPlayer->pConditions[Condition_Disease2] ) + { + pPlayer->sHealth /= 3; + pPlayer->sMana /= 3; + } + else if ( pPlayer->pConditions[Condition_Poison1] || pPlayer->pConditions[Condition_Disease1] ) + { + pPlayer->sHealth /= 2; + pPlayer->sMana /= 2; + } + if ( pPlayer->pConditions[Condition_Insane] ) pPlayer->sMana = 0; UpdatePlayersAndHirelingsEmotions(); } @@ -1160,22 +800,16 @@ //----- (004938D1) -------------------------------------------------------- void __fastcall Rest(unsigned int uHoursToSleep) { - unsigned int v1; // esi@1 - double v2; // st7@3 - Player **v3; // esi@3 + signed __int64 v2; // st7@3 - v1 = uHoursToSleep; if ( uHoursToSleep > 240 ) InitializeActors(); - v2 = (double)(7680 * v1) * 0.033333335; - pParty->uTimePlayed += (signed __int64)v2; - v3 = &pPlayers[1]; - do + v2 = (signed __int64)((7680 * uHoursToSleep) * 0.033333335); + pParty->uTimePlayed += v2; + for (int i = 0; i < 4; i++) { - (*v3)->Recover((signed __int64)v2); - ++v3; + pPlayers[i + 1]->Recover((int)v2); } - while ( (signed int)v3 <= (signed int)&pPlayers[4] ); _494035_timed_effects__water_walking_damage__etc(); } //----- (004B1BDB) -------------------------------------------------------- @@ -1183,36 +817,33 @@ { signed __int64 v1; // ST2C_8@1 signed __int64 v2; // qax@1 - signed __int64 v3; // ST1C_8@1 unsigned __int64 v4; // qax@1 unsigned int v5; // ebx@1 - Player *v6; // ebx@1 pParty->pHirelings[0].bHasUsedTheAbility = 0; pParty->pHirelings[1].bHasUsedTheAbility = 0; pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335); v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); v2 = v1 / 60 / 60; - v3 = v2; v4 = (unsigned int)v2 / 0x18; v5 = (unsigned int)(v4 / 7) >> 2; pParty->uCurrentTimeSecond = v1 % 60; pParty->uCurrentMinute = v1 / 60 % 60; - pParty->uCurrentHour = v3 % 24; + pParty->uCurrentHour = v2 % 24; pParty->uCurrentMonthWeek = v4 / 7 & 3; pParty->uDaysPlayed = (unsigned int)v4 % 0x1C; pParty->uCurrentMonth = v5 % 0xC; pParty->uCurrentYear = v5 / 0xC + game_starting_year; pParty->RestAndHeal(); dword_507B94 = 1; - v6 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay; - do + for (int i = 0; i < 4; i++) { - v6->uTimeToRecovery = 0; - memset(&v6->uTimeToRecovery, 0, 4u); - ++v6; + pParty->pPlayers[i].uTimeToRecovery = 0; + pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; + pParty->pPlayers[i].uNumArmageddonCasts = 0; + pParty->pPlayers[i].uNumFireSpikeCasts = 0; + pParty->pPlayers[i].field_1B3B = 0; } - while ( v6 <= &pParty->pPlayers[3] ); pParty->UpdatePlayersAndHirelingsEmotions(); } //----- (0041F5BE) -------------------------------------------------------- @@ -1241,7 +872,7 @@ } //----- (0047752B) -------------------------------------------------------- -int GetPartyReputation() +int Party::GetPartyReputation() { DDM_DLV_Header *v0; // ebx@1 signed int v1; // esi@3 @@ -1263,25 +894,31 @@ return v1 + v0->uReputation; } //----- (004269A2) -------------------------------------------------------- -void __fastcall GivePartyExp(unsigned int pEXPNum) +void Party::GivePartyExp(unsigned int pEXPNum) { signed int pActivePlayerCount; // ecx@1 int pLearningPercent; // eax@13 - pActivePlayerCount = 0; - for ( uint i = 0; i < 4; ++i ) + if ( pEXPNum > 0) { - if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] ) - pActivePlayerCount ++; - } - if ( pActivePlayerCount ) - { - pEXPNum = pEXPNum / pActivePlayerCount; + pActivePlayerCount = 0; for ( uint i = 0; i < 4; ++i ) { - if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] ) + if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && + !pParty->pPlayers[i].pConditions[Condition_Dead] && + !pParty->pPlayers[i].pConditions[Condition_Pertified] && + !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) + pActivePlayerCount ++; + } + if ( pActivePlayerCount ) + { + pEXPNum = pEXPNum / pActivePlayerCount; + for ( uint i = 0; i < 4; ++i ) { - if ( pEXPNum ) + if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && + !pParty->pPlayers[i].pConditions[Condition_Dead] && + !pParty->pPlayers[i].pConditions[Condition_Pertified] && + !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) { pLearningPercent = pParty->pPlayers[i].GetLearningPercent(); pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100; @@ -1296,209 +933,215 @@ } } //----- (00420C05) -------------------------------------------------------- -void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) +void Party::PartyFindsGold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) { - unsigned int v2; // edi@1 - int v3; // ebp@1 - unsigned int v4; // esi@1 - int v5; // ecx@6 - NPCData *v6; // eax@6 - signed int v7; // edx@8 - signed int v8; // ebx@10 - char *v9; // edi@11 - signed int v10; // ecx@17 - int v11; // eax@21 + int hirelingSalaries; // ebp@1 + unsigned int goldToGain; // esi@1 NPCData *v12; // ecx@21 unsigned int v13; // ecx@23 - signed int v14; // [sp+Ch] [bp-4h]@6 + signed int hirelingCount; // [sp+Ch] [bp-4h]@6 + + hirelingSalaries = 0; + goldToGain = uNumGold; - v2 = 0; - v3 = 0; - v4 = uNumGold; - if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal ) + if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) + pTmpBuf2[0] = 0; + else if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) + { + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! + } + else { - if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) + hirelingCount = 0; + for (int i = 0; i < 2; i++) + { + if (this->pHirelings[i].pName) + { + hirelingCount++; + pTmpBuf[hirelingCount] = i; + } + } + for (uint i = 0; i < pNPCStats->uNumNewNPCs; i++) + { + if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 + && (!this->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[0].pName)) + && (!this->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[1].pName)) ) + { + hirelingCount++; + pTmpBuf[hirelingCount] = i + 2; + } + } + for (int i = 0; i < hirelingCount; i++) { - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! + uchar thisBufId = (uchar)pTmpBuf[i]; + if (thisBufId < 2) + v12 = &this->pHirelings[thisBufId]; + else + v12 = &pNPCStats->pNPCData[thisBufId + 499]; + v13 = v12->uProfession; + if ( v13 ) + hirelingSalaries += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); + } + if ( CheckHiredNPCSpeciality(Factor) ) + goldToGain += (signed int)(10 * goldToGain) / 100; + if ( CheckHiredNPCSpeciality(Banker) ) + goldToGain += (signed int)(20 * goldToGain) / 100; + if ( CheckHiredNPCSpeciality(Pirate) ) + goldToGain += (signed int)(10 * goldToGain) / 100; + if ( hirelingSalaries ) + { + hirelingSalaries = (signed int)(goldToGain * hirelingSalaries / 100) / 100; + if ( hirelingSalaries < 1 ) + hirelingSalaries = 1; + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], goldToGain, hirelingSalaries);// You found %lu gold (followers take %lu)! } else { - if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) - pTmpBuf2[0] = 0; + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], goldToGain);// You found %lu gold! } } - else - { - v14 = 0; - v5 = 0; - v6 = pParty->pHirelings; - do - { - if ( v6->pName ) - { - v7 = v14++; - pTmpBuf[v7] = v5; - } - ++v6; - ++v5; - } - while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); - v8 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v9 = (char *)pNPCStats->pNewNPCData; - do - { - if ( v9[8] & 0x80 - && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName)) - && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) ) - { - v10 = v14++; - pTmpBuf[v10] = v8 + 2; - } - ++v8; - v9 += 76; - } - while ( v8 < (signed int)pNPCStats->uNumNewNPCs ); - v2 = 0; - } - if ( v14 > 0 ) - { - do - { - v11 = (unsigned __int8)pTmpBuf[v2]; - v12 = &pNPCStats->pNPCData[v11 + 499]; - if ( (unsigned __int8)pTmpBuf[v2] < 2 ) - v12 = &pParty->pHirelings[v11]; - v13 = v12->uProfession; - if ( v13 ) - v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); - ++v2; - } - while ( (signed int)v2 < v14 ); - } - if ( CheckHiredNPCSpeciality(Factor) ) - v4 += (signed int)(10 * v4) / 100; - if ( CheckHiredNPCSpeciality(Banker) ) - v4 += (signed int)(20 * v4) / 100; - if ( CheckHiredNPCSpeciality(Pirate) ) - v4 += (signed int)(10 * v4) / 100; - if ( v3 ) - { - v3 = (signed int)(v4 * v3 / 100) / 100; - if ( v3 < 1 ) - v3 = 1; - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)! - } - else - { - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold! - } - v2 = 0; - } - pParty->uNumGold += v4 - v3; - pUIAnim_Gold->uAnimTime = v2; + this->uNumGold += goldToGain - hirelingSalaries; + pUIAnim_Gold->uAnimTime = 0; pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; if ( pTmpBuf2[0] ) ShowStatusBarString(pTmpBuf2.data(), 2u); - pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2); + pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); } //----- (00421B2C) -------------------------------------------------------- -bool sub_421B2C_PlaceInInventory_or_DropPickedItem() +void Party::sub_421B2C_PlaceInInventory_or_DropPickedItem() { unsigned int v0; // eax@2 Texture *v1; // ebx@2 int v2; // eax@3 - Player *v3; // esi@5 int v4; // eax@6 unsigned __int16 v5; // dx@11 signed int v6; // eax@11 - char *v7; // edi@12 __int16 v8; // ax@16 SpriteObject a1; // [sp+4h] [bp-78h]@11 int v11; // [sp+74h] [bp-8h]@2 int v12; // [sp+78h] [bp-4h]@5 if ( !pParty->pPickedItem.uItemID ) - return 1; + return; v0 = pIcons_LOD->LoadTexture( pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); v1 = pIcons_LOD->GetTexture(v0); v11 = areWeLoadingTexture; if ( uActiveCharacter - && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) + && (v2 = ::pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) { - memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); + memcpy(&::pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); } else { - v12 = 0; - v3 = pParty->pPlayers; - while ( v3 <= &pParty->pPlayers[3] ) + for (v12 = 0; v12 < 4; v12++) { - v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); + v4 = pParty->pPlayers[v12].AddItem(-1, pParty->pPickedItem.uItemID); if ( v4 ) - { - memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); - break; - } - ++v12; - ++v3; + { + memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, sizeof(ItemGen)); + pMouse->RemoveHoldingItem(); + break; + } } if ( v12 == 4 ) - { - v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - v6 = 0; - a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { - LOWORD(v6) = 0; - } - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - { - LOWORD(v6) = 0; - break; - } - } - } - a1.spell_caster_pid = OBJECT_Player; - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - v8 = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - a1.uSectorID = v8; - memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); - a1.Create(pParty->sRotationY, 184, 200, 0); - pMouse->RemoveHoldingItem(); - } + { + v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + for ( uint i = 0; i < pObjectList->uNumObjects; i++ ) + { + if ( v5 == pObjectList->pObjects[i].uObjectID ) + { + v6 = i; + break; + } + } + a1.spell_caster_pid = OBJECT_Player; + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + v8 = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + a1.uSectorID = v8; + memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); + a1.Create(pParty->sRotationY, 184, 200, 0); + pMouse->RemoveHoldingItem(); + } } if ( !v11 ) { v1->Release(); pIcons_LOD->SyncLoadedFilesCount(); } - return 1; + return; } +//----- (0048C6F6) -------------------------------------------------------- +bool Party::AddItemToParty(ItemGen *pItem) +{ + unsigned int v2; // eax@1 + char *v5; // eax@8 + Texture *v7; // ebx@10 + signed int v8; // esi@10 + Player *v9; // edi@11 + int v10; // eax@11 + int v21; // [sp+24h] [bp-4h]@10 + + v2 = pItem->uItemID; + if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) + pItem->SetIdentified(); + + v5 = pItemsTable->pItems[v2].pIconName; + if ( v5 ) + { + v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE); + v21 = areWeLoadingTexture; + v8 = 0; + int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0; + for (int i = 0; i < 4; i++) + { + v9 = &pPlayers[(startId + i) % 4]; //start with current active player, then cycle right if item won't fit + v10 = v9->AddItem(-1, pItem->uItemID); + if ( v10 ) + { + memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); + pItem->Reset(); + pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); + v9->PlaySound(SPEECH_60, 0); + if ( !v21 ) + { + v7->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return true; + } + } + if ( !v21 ) + { + v7->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return false; + } + else + { + MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0); + return false; + } +} +// 506128: using guessed type int areWeLoadingTexture; + bool Party::IsPartyEvil() { return _449B57_test_bit(_quest_bits, 100);
--- a/Party.h Fri Oct 11 18:55:07 2013 +0600 +++ b/Party.h Fri Oct 11 18:55:43 2013 +0600 @@ -185,7 +185,14 @@ bool AddItemToParty(ItemGen *pItem); void Yell(); void CountHirelings(); - + + void GivePartyExp(unsigned int pEXPNum); + int GetPartyReputation(); + + + void PartyFindsGold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); + void sub_421B2C_PlaceInInventory_or_DropPickedItem(); + static void SetGold(unsigned int uNumGold); static void TakeGold(unsigned int uNumGold); static void SetFood(unsigned int uNumFood);
--- a/Player.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Player.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -1184,7 +1184,7 @@ if ( SkillToMastery(v2) >= 4 ) return 10000; - v7 = GetPartyReputation(); + v7 = pParty->GetPartyReputation(); int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); v5 = multiplier * (v2 & 0x3F); if (v5 == 0) @@ -1240,7 +1240,7 @@ Player::Player() { memset(&pEquipment, 0, sizeof(PlayerEquipment)); - memset(pInventoryMatrix, 0, 126 * sizeof(int)); + memset(pInventoryMatrix.data(), 0, 126 * sizeof(int)); for (uint i = 0; i < 126; ++i) pInventoryItemList[i].Reset(); for (uint i = 0; i < 12; ++i) @@ -1260,7 +1260,7 @@ pName[0] = 0; uCurrentFace = 0; uVoiceID = 0; - memset(pConditions, 0, 20 * sizeof(__int64)); + memset(pConditions.data(), 0, 20 * sizeof(__int64)); field_BB = 0; @@ -1308,7 +1308,7 @@ _mana_related = 0; uQuickSpell = 0; - memset(pInstalledBeacons, 0, 5 * sizeof(LloydBeacon)); + memset(pInstalledBeacons.data(), 0, 5 * sizeof(LloydBeacon)); _some_attack_bonus = 0; field_1A91 = 0; @@ -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; @@ -1347,60 +1347,6 @@ lastOpenedSpellbookPage = 0; } -//----- (0048C6F6) -------------------------------------------------------- -bool Party::AddItemToParty(ItemGen *pItem) //TODO move to party.cpp -{ - unsigned int v2; // eax@1 - char *v5; // eax@8 - Texture *v7; // ebx@10 - signed int v8; // esi@10 - Player *v9; // edi@11 - int v10; // eax@11 - int v21; // [sp+24h] [bp-4h]@10 - - v2 = pItem->uItemID; - if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) - pItem->SetIdentified(); - - v5 = pItemsTable->pItems[v2].pIconName; - if ( v5 ) - { - v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE); - v21 = areWeLoadingTexture; - v8 = 0; - int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0; - for (int i = 0; i < 4; i++) - { - v9 = &pPlayers[(startId + i) % 4]; //start with current active player, then cycle right if item won't fit - v10 = v9->AddItem(-1, pItem->uItemID); - if ( v10 ) - { - memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); - pItem->Reset(); - pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); - v9->PlaySound(SPEECH_60, 0); - if ( !v21 ) - { - v7->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return true; - } - } - if ( !v21 ) - { - v7->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return false; - } - else - { - MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0); - return false; - } -} -// 506128: using guessed type int areWeLoadingTexture; //----- (0048C855) -------------------------------------------------------- int Player::GetBaseStrength() @@ -1670,6 +1616,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; @@ -2126,7 +2076,7 @@ } if ( enchBonusSum ) { - party_finds_gold(enchBonusSum, 2); + pParty->PartyFindsGold(enchBonusSum, 2); sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold } else @@ -2170,14 +2120,14 @@ } if (carriedItemId != 0) // looks odd in current context, but avoids accessing zeroth element of pItemsTable->pItems { - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); sprintf( pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message this->pName, pItemsTable->pItems[carriedItemId].pUnidentifiedName); ShowStatusBarString(pTmpBuf2.data(), 2u); - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); pMouse->SetCursorBitmapFromItemID(carriedItemId); return 2; @@ -2932,7 +2882,7 @@ v3 = (int)(dt * GetSpecialItemBonus(17) * 0.01 + dt); - Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery); + //Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery); if (uTimeToRecovery > v3) { @@ -3960,7 +3910,7 @@ uLevel = 1; uExperience = 251 + rand() % 100; uBirthYear = 1147 - rand() % 6; - memset(pActiveSkills, 0, sizeof(pActiveSkills)); + memset(pActiveSkills.data(), 0, sizeof(pActiveSkills)); memset(_achieved_awards_bits, 0, 64); memset(&spellbook, 0, sizeof(PlayerSpells)); @@ -4228,8 +4178,10 @@ break; case 6: statToChange = &this->uLuck; + break; default: Error("(%u)", eAttribute); + break; } if ( *statToChange < baseValue ) { @@ -4310,7 +4262,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 +4400,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 +4450,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 +4513,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 @@ -4870,7 +4822,7 @@ sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 7: - party_finds_gold(1000 * thisa, 0); + pParty->PartyFindsGold(1000 * thisa, 0); sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold" break; case 8: @@ -4995,7 +4947,7 @@ if ( valToCompare <= 63 ) v4 = skillValue & 0x3F; else - v4 = valToCompare & skillValue; + v4 = skillValue & skillValue; return v4 >= valToCompare; } @@ -5310,7 +5262,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 +5359,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 +5374,7 @@ if (pStorylineText->StoreLine[var_type - VAR_History_0].pText) { bFlashHistoryBook = 1; - PlayAwardSound(currPlayerId); + PlayAwardSound(); } } return; @@ -5439,14 +5382,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 +5400,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 +5411,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 +5437,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 +5473,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 +5512,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 +5520,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 +5808,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 +5980,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 +6012,7 @@ if (pStorylineText->StoreLine[var_type - VAR_History_0].pText = 0) { bFlashHistoryBook = 1; - PlayAwardSound(uPlayerIdx); + PlayAwardSound(); } } return; @@ -6073,7 +6024,7 @@ if ( val == 0 ) val = 1; v6 = rand(); - party_finds_gold(v6 % val + 1, 1); + pParty->PartyFindsGold(v6 % val + 1, 1); GameUI_DrawFoodAndGold(); return; case VAR_RandomFood: @@ -6084,19 +6035,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 +6056,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 +6065,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 +6081,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; @@ -6160,35 +6111,35 @@ pParty->SetHoldingItem(&item); return; case VAR_FixedGold: - party_finds_gold(val, 1); + pParty->PartyFindsGold(val, 1); 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 +6147,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 +6342,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 +6392,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 +6508,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 +6533,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 ) + { + dword_5B65C4_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 + { + dword_5B65C4_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 +7169,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 +7189,12 @@ return true; } } - } - return false; + return false; + } + else + { + return true; + } } //----- (0043EDB9) -------------------------------------------------------- bool ShouldLoadTexturesForRaceAndGender(unsigned int _this) @@ -7442,7 +7326,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) @@ -7467,7 +7351,7 @@ Actor::ApplyFineForKillingPeasant(uActorID); Actor::AggroSurroundingPeasants(uActorID, 1); if ( actorPtr->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); + pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); int speechToPlay = SPEECH_51; if ( rand() % 100 < 20 ) speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; @@ -7511,15 +7395,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 +7463,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 +7518,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) @@ -7656,7 +7543,7 @@ Actor::ApplyFineForKillingPeasant(uActorID); Actor::AggroSurroundingPeasants(uActorID, 1); if ( actorPtr->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); + pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); int speechToPlay = SPEECH_51; if ( rand() % 100 < 20 ) speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; @@ -7692,106 +7579,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 +7911,20 @@ 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; + else + Error("Unexpected player pointer"); + return uPlayerIdx; } \ No newline at end of file
--- a/Player.h Fri Oct 11 18:55:07 2013 +0600 +++ b/Player.h Fri Oct 11 18:55:43 2013 +0600 @@ -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 }; @@ -326,7 +327,7 @@ #pragma pack(push, 1) struct PlayerSpellbookChapter { - char bIsSpellAvailable[11]; + std::array<char, 11> bIsSpellAvailable; }; #pragma pack(pop) @@ -350,12 +351,12 @@ }; struct { - PlayerSpellbookChapter pChapters[9]; + std::array<PlayerSpellbookChapter, 9> pChapters; char _pad_1; }; struct { - char bHaveSpell[99]; + std::array<char, 99> bHaveSpell; char _pad_1; }; }; @@ -381,14 +382,14 @@ unsigned int uGlove; unsigned int uBoot; unsigned int uAmulet; - unsigned int uRings[6]; + std::array<unsigned int, 6> uRings; //unsigned int field_2C; //unsigned int field_30; //unsigned int field_34; //unsigned int field_38; //unsigned int field_3C; }; - unsigned int pIndices[16]; + std::array<unsigned int, 16> pIndices; }; }; #pragma pack(pop) @@ -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,7 +668,9 @@ ItemGen* GetNthRingItem(int ringNum); ItemGen* GetNthEquippedIndexItem(int index); ItemGen* GetItem(unsigned int PlayerEquipment::* itemPos); - __int64 pConditions[20]; + int GetPlayerIndex(); + + std::array<__int64, 20> pConditions; unsigned __int64 uExperience; char pName[16]; PLAYER_SEX uSex; @@ -742,7 +747,7 @@ unsigned __int16 skillAlchemy; unsigned __int16 skillLearning; }; - unsigned __int16 pActiveSkills[37]; + std::array<unsigned __int16, 37> pActiveSkills; }; unsigned char _achieved_awards_bits[64]; PlayerSpells spellbook; @@ -758,13 +763,13 @@ { struct { - ItemGen pInventoryItemList[126]; - ItemGen pEquippedItems[12]; + std::array<ItemGen, 126> pInventoryItemList; + std::array<ItemGen, 12> pEquippedItems; }; - ItemGen pOwnItems[138]; + std::array<ItemGen, 138> pOwnItems; }; - int pInventoryMatrix[126]; + std::array<int, 126> pInventoryMatrix; __int16 sResFireBase; __int16 sResAirBase; __int16 sResWaterBase; @@ -787,7 +792,7 @@ __int16 sResBodyBonus; __int16 sResLightBonus; __int16 sResDarkBonus; - SpellBuff pPlayerBuffs[24]; + std::array<SpellBuff, 24> pPlayerBuffs; unsigned int uVoiceID; int uPrevVoiceID; int uPrevFace; @@ -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; @@ -825,7 +830,7 @@ __int16 field_1AA2; int _expression21_animtime; int _expression21_frameset; - LloydBeacon pInstalledBeacons[5]; + std::array<LloydBeacon, 5> pInstalledBeacons; char uNumDivineInterventionCastsThisDay; char uNumArmageddonCasts; char uNumFireSpikeCasts;
--- a/Render.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Render.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -32,6 +32,7 @@ #include "mm7_data.h" #include "MM7.h" #include "Lights.h" +#include "Level/Decoration.h" #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib")
--- a/SaveLoad.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/SaveLoad.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -23,6 +23,7 @@ #include "texts.h" #include "Log.h" #include "VideoPlayer.h" +#include "Level/Decoration.h" #include "mm7_data.h"
--- a/SpriteObject.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/SpriteObject.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -13,6 +13,7 @@ #include "LOD.h" #include "Actor.h" #include "Events.h" +#include "Level/Decoration.h" #include "mm7_data.h" #include "MM7.h"
--- a/Sprites.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Sprites.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -15,6 +15,7 @@ #include "DecorationList.h" #include "MM7.h" #include "Actor.h" +#include "Level/Decoration.h"
--- a/Sprites.h Fri Oct 11 18:55:07 2013 +0600 +++ b/Sprites.h Fri Oct 11 18:55:43 2013 +0600 @@ -39,8 +39,9 @@ //__int16 _pad; }; -struct SpriteFrame: SpriteFrame_mm6 +class SpriteFrame: public SpriteFrame_mm6 { +public: __int16 uAnimLength; __int16 _pad; };
--- a/UI/Books/UIMapBook.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/UI/Books/UIMapBook.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -16,6 +16,7 @@ #include "..\..\Viewport.h" #include "..\..\Math.h" #include "..\..\texts.h" +#include "..\..\Level/Decoration.h" // #include "..\..\mm7_data.h"
--- a/UI/UICharacter.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/UI/UICharacter.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -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/UIHouses.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/UI/UIHouses.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -1223,7 +1223,7 @@ { if ( pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] > 0 )//get prize { - party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel, 0); + pParty->PartyFindsGold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel, 0); for ( uint i = 0; i < 4; ++i ) pParty->pPlayers[i].SetVariable(VAR_Award, 86); pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel; @@ -1349,7 +1349,7 @@ case HOUSE_DIALOGUE_SHOP_REPAIR: { dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); break; } case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
--- a/UI/UIShops.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/UI/UIShops.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -1649,7 +1649,7 @@ a3 = 0; if ( pMapStats->GetMapInfo(pCurrentMapName) ) a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]._steal_perm; - party_reputation = GetPartyReputation(); + party_reputation = pParty->GetPartyReputation(); if (pPlayers[uActiveCharacter]->CanSteal()) { if ( GetAsyncKeyState(VK_CONTROL) )
--- a/UI/UiGame.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/UI/UiGame.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -32,6 +32,7 @@ #include "UIHouses.h" #include "..\BSPModel.h" #include "..\Math.h" +#include "..\Level/Decoration.h" int uTextureID_GameUI_CharSelectionFrame; // 50C98C @@ -819,7 +820,7 @@ uFramesetIDa = 0; for (uint i = 0; i < 24; ++i) { - auto buff = player->pPlayerBuffs + i; + auto buff = player->pPlayerBuffs.data() + i; if (buff->uExpireTime > 0) { v36 = uFramesetIDa++ * pFontComic->uFontHeight + 134; @@ -932,9 +933,9 @@ pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pText, 84, 0); } - if ( GetPartyReputation() >= 0 ) + if ( pParty->GetPartyReputation() >= 0 ) { - if ( GetPartyReputation() <= 5 ) + if ( pParty->GetPartyReputation() <= 5 ) pTextColor = ui_character_default_text_color; else pTextColor = ui_character_bonus_text_color_neg; @@ -942,7 +943,7 @@ else pTextColor = ui_character_bonus_text_color; - sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], pTextColor, GetReputationString(GetPartyReputation()));//Reputation + sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], pTextColor, GetReputationString(pParty->GetPartyReputation()));//Reputation pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf.data(), 0, 0, 0); sprintf(pTmpBuf.data(), "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], pParty->GetPartyFame());// Fame Слава pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf.data(), 0, 0, 0); @@ -1720,7 +1721,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 +1734,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 +1761,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/Viewport.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Viewport.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -20,6 +20,7 @@ #include "TurnEngine.h" #include "stru123.h" #include "MM7.h" +#include "Level/Decoration.h" //----- (004C0262) -------------------------------------------------------- @@ -289,7 +290,7 @@ { if ( pSpriteObjects[v21].stru_24.GetItemEquipType() == 18 ) { - party_finds_gold(pSpriteObjects[v21].stru_24.uSpecEnchantmentType, 0); + pParty->PartyFindsGold(pSpriteObjects[v21].stru_24.uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; } else
--- a/Vis.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/Vis.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -11,6 +11,7 @@ #include "mm7_data.h" #include "MM7.h" +#include "Level/Decoration.h" static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8;
--- a/mm7_2.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/mm7_2.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -65,6 +65,7 @@ #include "MM7.h" #include "Lights.h" #include "NewUI/MainMenu.h" +#include "Level/Decoration.h" //----- (004BB756) -------------------------------------------------------- int UseNPCSkill(NPCProf profession) @@ -101,7 +102,7 @@ auto v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32); auto v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31); - memset(player->pConditions, 0, 0xA0u); + memset(player->pConditions.data(), 0, 0xA0u); __debugbreak(); *(int *)&player->pActiveSkills[8] = v5; @@ -260,7 +261,7 @@ { if ( pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] ) { - party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel, 0); + pParty->PartyFindsGold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel, 0); for ( uint i = 0; i < 4; ++i ) pParty->pPlayers[i].SetVariable(VAR_Award, 86); pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel; @@ -317,7 +318,7 @@ ++v4; } while ( (signed int)v4 < (signed int)pParty->pHirelings ); - party_finds_gold(gold_transaction_amount, 0); + pParty->PartyFindsGold(gold_transaction_amount, 0); pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0); pParty->field_7B5_in_arena_quest = -1; } @@ -1740,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_3.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/mm7_3.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -43,6 +43,7 @@ #include "texts.h" #include "Log.h" #include "Lights.h" +#include "Level/Decoration.h" #include "MM7.h"
--- a/mm7_4.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/mm7_4.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -40,6 +40,7 @@ #include "Log.h" #include "UI\UIHouses.h" #include "Lights.h" +#include "Level/Decoration.h" //----- (0046CC4B) -------------------------------------------------------- void check_event_triggers() @@ -794,7 +795,7 @@ if ( v48 ) { v31 = 0; - v32 = (char *)v21->pInventoryItemList; + v32 = (char *)v21->pInventoryItemList.data(); while ( *(int *)v32 != 601 || (unsigned __int8)v32[26] != v49 + 1 ) { ++v31; @@ -1888,7 +1889,7 @@ i += 2; break; case 11: - pReputation = GetPartyReputation(); + pReputation = pParty->GetPartyReputation(); if ( pReputation >= 25 ) pText = pGlobalTXT_LocalizationStrings[379]; else//v25 < 25 @@ -2907,7 +2908,7 @@ v6 = pParty->pPlayers;//[0].pInventoryItems[0].field_1A; do { - v7 = v6->pInventoryItemList; + v7 = v6->pInventoryItemList.data(); v8 = 138; do {
--- a/mm7_5.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/mm7_5.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -46,6 +46,7 @@ #include "UI\UIHouses.h" #include "Lights.h" #include "Lights.h" +#include "Level/Decoration.h" //----- (004304E7) -------------------------------------------------------- void GameUI_MsgProc()
--- a/mm7_6.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/mm7_6.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -59,7 +59,7 @@ int v13; // [sp+30h] [bp-8h]@1 int v14; // [sp+34h] [bp-4h]@1 - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); Dst.Reset(); v2 = 0; v3 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & pActor->uAttributes) == 0; @@ -77,7 +77,7 @@ while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls ); if ( v14 ) { - party_finds_gold(v14, 0); + pParty->PartyFindsGold(v14, 0); viewparams->bRedrawGameUI = 1; } } @@ -90,7 +90,7 @@ pActor->array_000234[3].Reset(); if ( v14 ) { - party_finds_gold(v14, 0); + pParty->PartyFindsGold(v14, 0); viewparams->bRedrawGameUI = 1; } } @@ -125,7 +125,7 @@ { if ( !pParty->AddItemToParty(pActor->array_000234) ) { - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); pParty->SetHoldingItem(pActor->array_000234); } pActor->array_000234[0].Reset(); @@ -134,7 +134,7 @@ { if ( !pParty->AddItemToParty(&pActor->array_000234[1]) ) { - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); pParty->SetHoldingItem(&pActor->array_000234[1]); } pActor->array_000234[1].Reset(); @@ -182,7 +182,7 @@ { if ( !v8->AddItemToParty(pActor->array_000234) ) { - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); v8->SetHoldingItem(pActor->array_000234); v13 = 1; } @@ -192,7 +192,7 @@ { if ( !v8->AddItemToParty(&pActor->array_000234[1]) ) { - sub_421B2C_PlaceInInventory_or_DropPickedItem(); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); v8->SetHoldingItem(&pActor->array_000234[1]); v13 = 1; } @@ -437,7 +437,7 @@ { v7 = pParty->pPlayers;//[0].pPlayerBuffs; v8 = 0; - v9 = v7->pPlayerBuffs; + v9 = v7->pPlayerBuffs.data(); while ( v9->uExpireTime <= 0i64 ) { ++v8; @@ -448,7 +448,7 @@ if ( v7 <= &pParty->pPlayers[3] ) { v8 = 0; - v9 = v7->pPlayerBuffs; + v9 = v7->pPlayerBuffs.data(); } else return 0;
--- a/mm7_data.cpp Fri Oct 11 18:55:07 2013 +0600 +++ b/mm7_data.cpp Fri Oct 11 18:55:43 2013 +0600 @@ -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 dword_5B65C4_cancelEventProcessing; // weak int dword_5B65C8_timers_count; // weak int npcIdToDismissAfterDialogue; // weak signed int dword_5B65D0_dialogue_actor_npc_id; // weak @@ -1316,10 +1316,6 @@ std::array<char *, 36> pClassNames; std::array<char *, 19> aCharacterConditionNames; std::array<char *, 38> pSkillNames; -std::array<char, 777> byte_AE3368; // weak -char byte_AE3369; // weak -char byte_AE336A; // weak -char byte_AE336B; // weak int dword_AE336C; // weak int dword_AE3370; // weak char byte_AE5B91; // weak
--- a/mm7_data.h Fri Oct 11 18:55:07 2013 +0600 +++ b/mm7_data.h Fri Oct 11 18:55:43 2013 +0600 @@ -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 dword_5B65C4_cancelEventProcessing; // weak extern int dword_5B65C8_timers_count; // weak extern int npcIdToDismissAfterDialogue; // weak extern int dword_5B65D0_dialogue_actor_npc_id; // weak @@ -975,10 +975,6 @@ extern std::array<char *, 36> pClassNames; extern std::array<char *, 19> aCharacterConditionNames; extern std::array<char *, 38> pSkillNames; -extern std::array<char, 777> byte_AE3368; // weak -extern char byte_AE3369; // weak -extern char byte_AE336A; // weak -extern char byte_AE336B; // weak extern int dword_AE336C; // weak extern int dword_AE3370; // weak extern char byte_AE5B91; // weak @@ -1087,10 +1083,8 @@ void LoadActualSkyFrame(); void Sleep6Hours(); void ChestUI_WritePointedObjectStatusString(); -void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); // idb void OnChestLeftClick(); void GameUI_WritePointedObjectStatusString(); -bool sub_421B2C_PlaceInInventory_or_DropPickedItem(); void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID); // idb void OnGameViewportClick(); bool PauseGameDrawing(); @@ -1100,7 +1094,6 @@ bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); int sr_424CD7(unsigned int uVertexID); // idb int BuildingVerticesClipping(unsigned int uNumVertices); -void __fastcall GivePartyExp(unsigned int pEXPNum); bool __fastcall sub_427769_spell(unsigned int uSpellID); void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6); void _42ECB5_PlayerAttacksActor(); @@ -1195,7 +1188,6 @@ void OnPaperdollLeftClick(); void OnPressSpace(); char __fastcall DoInteractionWithTopmostZObject(int a1, int a2); -int GetPartyReputation(); void OracleDialogue(); void __fastcall ClickNPCTopic(signed int uMessageParam); char * _4B254D_SkillMasteryTeacher(int _this);
--- a/stru123.h Fri Oct 11 18:55:07 2013 +0600 +++ b/stru123.h Fri Oct 11 18:55:43 2013 +0600 @@ -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