Mercurial > mm7
view Player.cpp @ 1767:3ee4a4d592af
Player::SetVariable removing label_84
author | Grumpy7 |
---|---|
date | Tue, 01 Oct 2013 07:30:46 +0200 |
parents | 110727780974 |
children | 3601186b4c26 |
line wrap: on
line source
#ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include "stru6.h" #include "Player.h" #include "PlayerFrameTable.h" #include "AudioPlayer.h" #include "Party.h" #include "Log.h" #include "LOD.h" #include "GUIWindow.h" #include "Viewport.h" #include "Actor.h" #include "Game.h" #include "Mouse.h" #include "TurnEngine.h" #include "Events.h" #include "Events2D.h" #include "Outdoor.h" #include "StorylineTextTable.h" #include "Autonotes.h" #include "Awards.h" #include "texts.h" #include "stru123.h" #include "mm7_data.h" #include "MM7.h" #include "SpriteObject.h" #include "DecalBuilder.h" /* 381 */ #pragma pack(push, 1) struct PlayerCreation_AttributeProps { unsigned __int8 uBaseValue; char uMaxValue; char uDroppedStep; char uBaseStep; }; #pragma pack(pop) #pragma pack(push, 1) #pragma pack(pop) PlayerCreation_AttributeProps StatTable[4][7] = //0x4ED7B0 { {{11, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, { 9, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {9, 25, 1, 1},}, {{ 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, { 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, {9, 20, 1, 1},}, {{14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, {9, 20, 1, 1},}, {{14, 30, 1, 2}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {9, 20, 1, 1}} }; std::array<int, 5> StealingMasteryBonuses = {0, 100, 200, 300, 500}; //dword_4EDEA0 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one std::array<int, 5> StealingRandomBonuses = {-200, -100, 0, 100, 200}; //dword_4EDEB4 std::array<int, 5> StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10}; //dword_4EDEC4 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one // available skills per class ( 9 classes X 37 skills ) // 0 - not available // 1 - available // 2 - primary skill unsigned char pSkillAvailabilityPerClass[9][37] = // byte[] @ MM7.exe::004ED820 { {0, 2, 0, 1, 1, 1, 1, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, {0, 1, 2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 2, 1, 0}, {1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0}, {0, 1, 1, 1, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, {0, 1, 0, 1, 1, 2, 0, 0, 0, 1, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1}, {0, 1, 1, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, {0, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, {2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0} // some of these are started at 4ED94C, but needs to be here }; unsigned char pEquipTypeToBodyAnchor[21] = // 4E8398 { 1, // EQUIP_OFF_HAND 1, // EQUIP_MAIN_HAND 2, // EQUIP_BOW 3, // EQUIP_ARMOUR 0, // EQUIP_SHIELD 4, // EQUIP_HELMET 5, // EQUIP_BELT 6, // EQUIP_CLOAK 7, // EQUIP_GAUNTLETS 8, // EQUIP_BOOTS 10, // EQUIP_RING 9, // EQUIP_AMULET 1, // EQUIP_WAND 0, // EQUIP_REAGENT 0, // EQUIP_POTION 0, // EQUIP_SPELL_SCROLL 0, // EQUIP_BOOK 0, // EQUIP_MESSAGE_SCROLL 0, // EQUIP_GOLD 0, // EQUIP_GEM 0 // EQUIP_NONE }; unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0}; unsigned char pBaseManaByClass[12] = { 0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0}; unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3}; unsigned char pBaseManaPerLevelByClass[36] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2, 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6}; unsigned char pConditionAttributeModifier[7][19] = {{100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Might {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Intelligence {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Willpower {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Endurance {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Accuracy {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Speed {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}}; //Luck unsigned char pAgingAttributeModifier[7][4] = {{100, 75, 40, 10}, //Might {100, 150, 100, 10}, //Intelligence {100, 150, 100, 10}, //Willpower {100, 75, 40, 10}, //Endurance {100, 100, 40, 10}, //Accuracy {100, 100, 40, 10}, //Speed {100, 100, 100, 100}}; //Luck unsigned int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; std::array<unsigned int, 18> pConditionImportancyTable = {{16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}}; short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175, 150, 125, 100, 75, 50, 40, 35, 30, 25, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 0}; signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6}; unsigned short base_recovery_times_per_weapon_type[12] = { 100, // PLAYER_SKILL_STAFF && Unarmed withoud skill 90, // PLAYER_SKILL_SWORD && Unarmed with skill 60, // PLAYER_SKILL_DAGGER 100, // PLAYER_SKILL_AXE 80, // PLAYER_SKILL_SPEAR 100, // PLAYER_SKILL_BOW 80, // PLAYER_SKILL_MACE 30, // PLAYER_SKILL_BLASTER 10, // PLAYER_SKILL_SHIELD 10, // PLAYER_SKILL_LEATHER 20, // PLAYER_SKILL_CHAIN 30 // PLAYER_SKILL_PLATE }; //----- (00490913) -------------------------------------------------------- int PlayerCreation_GetUnspentAttributePointCount() { signed int v0; // edi@1 int raceId; // ebx@2 signed int v4; // eax@17 int v5; // edx@18 signed int v6; // ecx@18 signed int remainingStatPoints; // [sp+Ch] [bp-8h]@1 remainingStatPoints = 50; v0 = 50; for (int playerNum = 0; playerNum < 4; playerNum++) { raceId = pParty->pPlayers[playerNum].GetRace(); for (int statNum = 0; statNum <= 6; statNum++) { switch ( statNum ) { case 0: v0 = pParty->pPlayers[playerNum].uMight; break; case 1: v0 = pParty->pPlayers[playerNum].uIntelligence; break; case 2: v0 = pParty->pPlayers[playerNum].uWillpower; break; case 3: v0 = pParty->pPlayers[playerNum].uEndurance; break; case 4: v0 = pParty->pPlayers[playerNum].uAccuracy; break; case 5: v0 = pParty->pPlayers[playerNum].uSpeed; break; case 6: v0 = pParty->pPlayers[playerNum].uLuck; break; } v4 = StatTable[raceId][statNum].uBaseValue; if ( v0 >= v4 ) { v5 = StatTable[raceId][statNum].uDroppedStep; v6 = StatTable[raceId][statNum].uBaseStep; } else { v5 = StatTable[raceId][statNum].uBaseStep; v6 = StatTable[raceId][statNum].uDroppedStep; } remainingStatPoints += v5 * (v4 - v0) / v6; } } return remainingStatPoints; } //----- (00427730) -------------------------------------------------------- bool Player::CanCastSpell(unsigned int uRequiredMana) { if (sMana >= (signed int)uRequiredMana) { sMana -= (signed int)uRequiredMana; return true; } pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); return false; } //----- (004BE2DD) -------------------------------------------------------- void Player::SalesProcess( unsigned int inventory_idnx, int item_index, int _2devent_idx ) { float v6; // ST04_4@1 signed int item_value; // eax@1 signed int sell_price; // ebx@1 item_value =pOwnItems[item_index].GetValue(); v6 = p2DEvents[ _2devent_idx - 1].fPriceMultiplier; sell_price = GetPriceSell(item_value, v6); if ( pOwnItems[item_index].IsBroken() ) sell_price = 1; if ( sell_price < 1 ) sell_price = 1; RemoveItemAtInventoryIndex(inventory_idnx); Party::SetGold(pParty->uNumGold + sell_price); } //----- (0043EEF3) -------------------------------------------------------- bool Player::NothingOrJustBlastersEquipped() { signed int item_idx; // esi@1 signed int item_id; // esi@1 for (int i = 0; i < 16; ++i) { item_idx = pEquipment.pIndices[i]; if (item_idx) { item_id = pOwnItems[item_idx - 1].uItemID; if ( item_id != ITEM_BLASTER && item_id != ITEM_LASER_RIFLE ) //blaster& blaster rifle return false; } } return true; } //----- (004B8040) -------------------------------------------------------- int Player::GetConditionDayOfWeek( unsigned int uCondition ) { return (unsigned int)(((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 24) % 7 + 1; } //----- (004B807C) -------------------------------------------------------- int Player::GetTempleHealCostModifier(float a2) { unsigned int conditionIdx; // eax@1 int conditionTimeMultiplier; // esi@1 int v6; // eax@8 signed int result; // qax@13 signed int baseConditionMultiplier; // [sp+8h] [bp-8h]@4 conditionIdx = GetMajorConditionIdx(); if ( conditionIdx >= 14 && conditionIdx <= 16) { if ( conditionIdx <= 15 ) { baseConditionMultiplier = 5; } if ( conditionIdx == 16 ) { baseConditionMultiplier = 10; } conditionTimeMultiplier = GetConditionDayOfWeek(conditionIdx); } else { conditionTimeMultiplier = 1; baseConditionMultiplier = 1; if (conditionIdx < 14) { for (int i = 0; i <= 13; i++) { v6 = GetConditionDayOfWeek(i); if ( v6 > conditionTimeMultiplier ) conditionTimeMultiplier = v6; } } } result = (int)((double)conditionTimeMultiplier * (double)baseConditionMultiplier * a2); if ( result < 1 ) result = 1; return result; } //----- (004B8102) -------------------------------------------------------- int Player::GetPriceSell(int uRealValue, float price_multiplier) { signed int v3; // esi@1 signed int result; // eax@3 v3 = (signed int)((signed __int64)((double)uRealValue / (price_multiplier + 2.0)) + uRealValue * GetMerchant() / 100); if ( v3 > uRealValue ) v3 = uRealValue; result = 1; if ( v3 >= 1 ) result = v3; return result; } //----- (004B8142) -------------------------------------------------------- int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier) { uint price = (uint)(((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100); if (price < uRealValue) price = uRealValue; return price; } //----- (004B8179) -------------------------------------------------------- int Player::GetPriceIdentification(float a2) { signed int v2; // esi@1 int v3; // ecx@1 signed int result; // eax@3 v2 = (signed int)(a2 * 50.0); v3 = v2 * (100 - GetMerchant()) / 100; if ( v3 < v2 / 3 ) v3 = v2 / 3; result = 1; if ( v3 >= 1 ) result = v3; return result; } //----- (004B81C3) -------------------------------------------------------- int Player::GetPriceRepair(int a2, float a3) { signed int v3; // esi@1 int v4; // ecx@1 signed int result; // eax@3 v3 = (signed int)((double)a2 / (6.0 - a3)); v4 = v3 * (100 - GetMerchant()) / 100; if ( v4 < v3 / 3 ) v4 = v3 / 3; result = 1; if ( v4 >= 1 ) result = v4; return result; } //----- (004B8213) -------------------------------------------------------- int Player::GetBaseSellingPrice(int a2, float a3) { signed int v3; // qax@1 v3 = (signed int)((double)a2 / (a3 + 2.0)); if ( v3 < 1 ) v3 = 1; return v3; } //----- (004B8233) -------------------------------------------------------- int Player::GetBaseBuyingPrice(int a2, float a3) { signed int v3; // qax@1 v3 = (signed int)((double)a2 * a3); if ( v3 < 1 ) v3 = 1; return v3; } //----- (004B824B) -------------------------------------------------------- int Player::GetBaseIdentifyPrice(float a2) { signed int v2; // qax@1 v2 = (signed int)(a2 * 50.0); if ( v2 < 1 ) v2 = 1; return v2; } //----- (004B8265) -------------------------------------------------------- int Player::GetBaseRepairPrice(int a2, float a3) { signed int v3; // qax@1 v3 = (signed int)((double)a2 / (6.0 - a3)); if ( v3 < 1 ) v3 = 1; return v3; } //----- (004B6FF9) -------------------------------------------------------- bool Player::IsPlayerHealableByTemple() { signed int v2; // eax@1 v2 = (signed int)window_SpeakInHouse->ptr_1C; if (this->sHealth >= GetMaxHealth() && this->sMana >= GetMaxMana() && GetMajorConditionIdx() == Condition_Good) { return false; } else { if (GetMajorConditionIdx() == Condition_Zombie) { if ((v2 == 78 || v2 == 81 || v2 == 82)) { return false; } else { return true; } } else { return true; } } } //----- (00421E75) -------------------------------------------------------- unsigned int Player::GetItemIDAtInventoryIndex(int *pitem_index) { int item_idx; // eax@1 int inv_index; // eax@3 item_idx = *pitem_index; if ( item_idx >125 || item_idx < 0 ) { return 0; } inv_index = this->pInventoryMatrix[item_idx]; if ( inv_index < 0 ) { *pitem_index = -1 - inv_index; inv_index = this->pInventoryMatrix[-1 - inv_index]; } return inv_index; } //----- (004160CA) -------------------------------------------------------- void Player::ItemsEnchant( int enchant_count ) { int avalible_items; // ebx@1 int i; // edx@8 __int16 item_index_tabl[138]; // [sp+Ch] [bp-118h]@1 avalible_items = 0; memset (item_index_tabl,0,sizeof(item_index_tabl)); for (i = 0; i < 138; ++i) { if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID <= 134)) item_index_tabl[avalible_items++] = i; } if ( avalible_items ) { if ( enchant_count ) { for ( i = 0; i < enchant_count; ++i ) { if (!(pInventoryItemList[item_index_tabl[i]].uAttributes&ITEM_HARDENED)) pInventoryItemList[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_HARDENED; } } else { for ( i = 0; i < avalible_items; ++i ) { pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_HARDENED; } } } } //----- (004948B1) -------------------------------------------------------- void Player::PlaySound(PlayerSpeech speech, int a3) { signed int speechCount = 0; // esi@4 signed int expressionCount = 0; // esi@4 int pickedVariant; // esi@10 CHARACTER_EXPRESSION_ID expression; // ebx@17 signed int pSoundID; // ecx@19 int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7 int expressionVariantArray[5]; unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4 unsigned int expressionDuration = 0; pickedSoundID = 0; if (uVoicesVolumeMultiplier) { for (int i = 0; i < 2; i++) { if ( SoundSetAction[speech][i] ) { speechVariantArray[speechCount] = SoundSetAction[speech][i]; speechCount++; } } if ( speechCount ) { pickedVariant = speechVariantArray[rand() % speechCount]; int numberOfSubvariants = byte_4ECF08[pickedVariant - 1][uVoiceID]; if (numberOfSubvariants > 0) { pickedSoundID = rand() % numberOfSubvariants + 2 * (pickedVariant + 50 * uVoiceID) + 4998; pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, uActiveCharacter + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); } } } for (int i = 0; i < 5; i++) { if ( SoundSetAction[speech][i + 3] ) { expressionVariantArray[expressionCount] = SoundSetAction[speech][i + 3]; expressionCount++; } } if ( expressionCount ) { expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount]; if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID ) { pSoundID = 0; if ( pSoundList->sNumSounds ) { for (int i = 0; i < pSoundList->sNumSounds; i++) { if (pSoundList->pSounds[i].uSoundID == pickedSoundID) pSoundID = i; } } if ( pSoundList->pSounds[pSoundID].pSoundData[0] ) expressionDuration = (sLastTrackLengthMS << 7) / 1000; } PlayEmotion(expression, expressionDuration); } } // 4948B1: using guessed type int var_1C[5]; //----- (00494A25) -------------------------------------------------------- void Player::PlayEmotion(CHARACTER_EXPRESSION_ID new_expression, int a3) { unsigned int v3 = expression; if (expression == CHARACTER_EXPRESSION_DEAD || expression == CHARACTER_EXPRESSION_ERADICATED) { return; } else if (expression == CHARACTER_EXPRESSION_PERTIFIED && new_expression != CHARACTER_EXPRESSION_FALLING) { return; } else { if (expression != CHARACTER_EXPRESSION_SLEEP || new_expression != CHARACTER_EXPRESSION_FALLING) { if (v3 >= 2 && v3 <= 11 && v3 != 8 && !(new_expression == CHARACTER_EXPRESSION_DMGRECVD_MINOR || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MODERATE || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MAJOR)) { return; } } } this->uExpressionTimePassed = 0; if ( !a3 ) { this->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[a3].uAnimLength; } else { this->uExpressionTimeLength = 0; } expression = new_expression; viewparams->bRedrawGameUI = 1; } //----- (0049327B) -------------------------------------------------------- bool Player::ProfessionOrGuildFlagsCorrect( unsigned int uClass, int a3 ) { if ( this->classType == uClass ) { return true; } else { if (!a3) { return false; } switch ( uClass ) { case 0x1Au: return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 65)); case 0x1Bu: return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 67)); case 0x22u: return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 77)); case 0x23u: return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 79)); break; default: Error("Should not be able to get here (%u)", uClass); break; } return false; } } //----- (00492C0B) -------------------------------------------------------- bool Player::CanAct() { if ( this->IsAsleep() || this->IsParalyzed() || this->IsUnconcious() || this->IsDead() || this->IsPertified() || this->IsEradicated() ) return false; else return true; } //----- (00492C40) -------------------------------------------------------- bool Player::CanSteal() { return GetActualSkillLevel(PLAYER_SKILL_STEALING) != 0; } //----- (00492C4E) -------------------------------------------------------- bool Player::CanEquip_RaceAndAlignmentCheck(unsigned int uItemID) { switch (uItemID) { case ITEM_RELIC_ETHRICS_STAFF: case ITEM_RELIC_OLD_NICK: case ITEM_RELIC_TWILIGHT: return pParty->IsPartyEvil(); break; case ITEM_RELIC_TALEDONS_HELM: case ITEM_RELIC_JUSTICE: return pParty->IsPartyGood(); break; case ITEM_ARTIFACT_ELFBANE: return IsRaceGoblin(); break; case ITEM_ARTIFACT_MINDS_EYE: return IsRaceHuman(); break; case ITEM_ELVEN_CHAINMAIL: return IsRaceElf(); break; case ITEM_FORGE_GAUNTLETS: return IsRaceDwarf(); break; case ITEM_ARTIFACT_HEROS_BELT: return IsMale(); break; case ITEM_ARTIFACT_LADYS_ESCORT: return IsFemale(); break; case ITEM_WETSUIT: return NothingOrJustBlastersEquipped(); break; default: return 1; break; } } //----- (00492D65) -------------------------------------------------------- void Player::SetCondition( unsigned int uConditionIdx, int a3 ) { signed int player_sex; // ecx@77 signed int remainig_player; // ebx@82 int players_before; // [sp+10h] [bp-4h]@2 int players_after; // [sp+20h] [bp+Ch]@82 if ( pConditions[uConditionIdx] ) return; if (!ConditionProcessor::IsPlayerAffected(this, uConditionIdx, a3)) { return; } switch ( uConditionIdx ) { case Condition_Cursed: PlaySound(SPEECH_30, 0); break; case Condition_Weak: PlaySound(SPEECH_25, 0); break; case Condition_Sleep: break; //nosound case Condition_Fear: PlaySound(SPEECH_26, 0); break; case Condition_Drunk: PlaySound(SPEECH_31, 0); break; case Condition_Insane: PlaySound(SPEECH_29, 0); break; case Condition_Poison1: case Condition_Poison2: case Condition_Poison3: PlaySound(SPEECH_27, 0); break; case Condition_Disease1: case Condition_Disease2: case Condition_Disease3: PlaySound(SPEECH_28, 0);break; case Condition_Paralyzed: break; //nosound case Condition_Unconcious: PlaySound(SPEECH_32, 0); if ( sHealth > 0 ) sHealth = 0; break; case Condition_Dead: PlaySound(SPEECH_33, 0); if ( sHealth > 0 ) sHealth = 0; if ( sMana > 0 ) sMana = 0; break; case Condition_Pertified: PlaySound(SPEECH_34, 0); break; case Condition_Eradicated: PlaySound(SPEECH_35, 0); if (sHealth > 0 ) sHealth = 0; if ( sMana > 0 ) sMana = 0; break; case Condition_Zombie: if ( classType == PLAYER_CLASS_LICH || IsEradicated() || IsZombie() || !IsDead()) return; memset(&pConditions[0], 0, sizeof(pConditions)); sHealth = GetMaxHealth(); sMana = 0; player_sex = 0; uPrevFace = uCurrentFace; uPrevVoiceID = uVoiceID; if (IsMale()) { uCurrentFace = 23; uVoiceID = 23; } else { uCurrentFace = 24; uVoiceID = 24; } PlaySound(SPEECH_99, 0); break; } players_before = 0; for (int i = 1; i < 5; ++i) { if ( pPlayers[i]->CanAct() ) ++players_before; } pConditions[uConditionIdx] = 1; remainig_player = 0; players_after = 0; for (int i = 1; i < 5; ++i) { if ( pPlayers[i]->CanAct() ) { remainig_player = i; ++players_after; } } if (( players_before == 2 ) && ( players_after == 1 )) { pPlayers[remainig_player]->PlaySound(SPEECH_107, 0); } return; } //----- (00492528) -------------------------------------------------------- bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) { Texture *texture; // esi@1 unsigned int slotWidth; // ebx@1 unsigned int slotHeight; // [sp+1Ch] [bp+Ch]@1 texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); slotWidth = GetSizeInInventorySlots(texture->uTextureWidth); slotHeight = GetSizeInInventorySlots(texture->uTextureHeight); if ( !areWeLoadingTexture ) { texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } Assert(slotHeight > 0 && slotWidth > 0, "Items should have nonzero dimensions"); if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT ) { for (unsigned int x = 0; x < slotWidth; x++) { for (unsigned int y = 0; y < slotHeight; y++) { if (pInventoryMatrix[y * INVETORYSLOTSWIDTH + x + uSlot] != 0) { return false; } } } return true; } return false; } // 506128: using guessed type int areWeLoadingTexture; //----- (004925E6) -------------------------------------------------------- int Player::FindFreeInventoryListSlot() { for (int i = 0; i < 126; i++ ) { if (pInventoryItemList[i].uItemID == 0) { return i; } } return -1; } //----- (00492600) -------------------------------------------------------- int Player::CreateItemInInventory(unsigned int uSlot, unsigned int uItemID) { int result; // eax@8 signed int freeSlot; // [sp+8h] [bp-4h]@4 freeSlot = FindFreeInventoryListSlot(); if ( freeSlot == -1 ) { if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); return 0; } else { PutItemArInventoryIndex(uItemID, freeSlot, uSlot); result = freeSlot + 1; this->pInventoryItemList[freeSlot].uItemID = uItemID; } return result; } // 506128: using guessed type int areWeLoadingTexture; //----- (00492700) -------------------------------------------------------- int Player::HasSkill(unsigned int uSkillType) { if ( uSkillType >= 37 || this->pActiveSkills[uSkillType] ) { return 1; } else { sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[67], this->pName); ShowStatusBarString(pTmpBuf.data(), 2u); return 0; } } //----- (00492745) -------------------------------------------------------- void Player::WearItem( unsigned int uItemID ) { int item_body_anch; // edi@6 int item_indx; item_indx = FindFreeInventoryListSlot(); if ( item_indx != -1 ) { pInventoryItemList[item_indx].uItemID = uItemID; item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; pEquipment.pIndices[item_body_anch] = item_indx + 1; pInventoryItemList[item_indx].uBodyAnchor = item_body_anch + 1; } } //----- (004927A8) -------------------------------------------------------- int Player::AddItem(int index, unsigned int uItemID) { int xStartValue = 0; if ( index == -1 ) { for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) { for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) { if ( CanFitItem(ycoord * INVETORYSLOTSWIDTH + xcoord, uItemID) ) { return CreateItemInInventory(ycoord * INVETORYSLOTSWIDTH + xcoord, uItemID); } } } return 0; } if ( !CanFitItem(index, uItemID) ) { pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); return 0; } return CreateItemInInventory(index, uItemID); } //----- (00492826) -------------------------------------------------------- int Player::AddItem2(int index, ItemGen *Src) { pItemsTable->SetSpecialBonus(Src); if ( index == -1 ) { for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) { for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) //TODO: change pInventoryMatrix to 2 dimensional array. { if ( CanFitItem(ycoord * INVETORYSLOTSWIDTH + xcoord, Src->uItemID) ) { return CreateItemInInventory2(ycoord * INVETORYSLOTSWIDTH + xcoord, Src); } } } return 0; } if ( !CanFitItem(index, Src->uItemID) ) return 0; return CreateItemInInventory2(index, Src); } //----- (0049289C) -------------------------------------------------------- int Player::CreateItemInInventory2( unsigned int index, ItemGen *Src ) { signed int freeSlot; // ebx@1 int result; // eax@6 freeSlot = FindFreeInventoryListSlot(); if ( freeSlot == -1 ) { result = 0; } else { PutItemArInventoryIndex(Src->uItemID, freeSlot, index); memcpy(&pInventoryItemList[freeSlot], Src, sizeof(ItemGen)); result = freeSlot + 1; } return result; } // 506128: using guessed type int areWeLoadingTexture; //----- (0049298B) -------------------------------------------------------- void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) //originally accepted ItemGen* but needed only its uItemID { Texture *item_texture; // esi@1 int *pInvPos; // esi@4 unsigned int slot_width; // [sp+Ch] [bp-4h]@1 unsigned int slot_height; // [sp+18h] [bp+8h]@1 item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); if ( !areWeLoadingTexture ) { item_texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } if ( slot_width > 0 ) { pInvPos = &pInventoryMatrix[index]; for (unsigned int i = 0; i < slot_height; i++) { memset32(pInvPos, -1 - index, slot_width);//TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn pInvPos += INVETORYSLOTSWIDTH; } } pInventoryMatrix[index] = itemListPos + 1; } // 506128: using guessed type int areWeLoadingTexture; //----- (00492A36) -------------------------------------------------------- void Player::RemoveItemAtInventoryIndex( unsigned int index ) { ItemGen *item_in_slot; // ecx@1 Texture *item_texture; // esi@1 unsigned int slot_height; // ebp@1 int *pInvPos; // edx@4 unsigned int slot_width; // [sp+14h] [bp+4h]@1 item_in_slot = &this->pInventoryItemList[pInventoryMatrix[index]-1]; item_texture = pIcons_LOD->LoadTexturePtr(item_in_slot->GetIconName(), TEXTURE_16BIT_PALETTE); item_in_slot->Reset(); slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); if ( !areWeLoadingTexture ) { item_texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } if ( slot_width > 0 ) { pInvPos = &pInventoryMatrix[index]; for (unsigned int i = 0; i < slot_height; i++) { memset32(pInvPos, 0, slot_width); pInvPos += INVETORYSLOTSWIDTH; } } } // 506128: using guessed type int areWeLoadingTexture; //----- (00490EEE) -------------------------------------------------------- int Player::SelectPhrasesTransaction(ItemGen *pItem, int building_type, int BuildID_2Events, int ShopMenuType) //TODO: probably move this somewhere else, not really Player:: stuff { unsigned int idemId; // edx@1 signed int equipType; // esi@1 float multiplier; // ST04_4@26 int price; // edi@26 int merchantLevel; // [sp+10h] [bp-8h]@1 int itemValue; merchantLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); idemId = pItem->uItemID; equipType = pItem->GetItemEquipType(); itemValue = pItem->GetValue(); switch (building_type) { case BuildingType_WeaponShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if (equipType > EQUIP_BOW) return 4; break; case BuildingType_ArmorShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if ( equipType < EQUIP_ARMOUR || equipType > EQUIP_BOOTS) return 4; break; case BuildingType_MagicShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if ( pItemsTable->pItems[idemId].uSkillType != PLAYER_SKILL_MISC ) return 4; break; case BuildingType_AlchemistShop: if ((idemId >= ITEM_ARTIFACT_HERMES_SANDALS && idemId < ITEM_RECIPE_REJUVENATION) || idemId > ITEM_RECIPE_BODY_RESISTANCE) return 5; if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL)) return 4; break; default: Error("(%u)", building_type); break; } if (pItem->IsStolen()) return 6; multiplier = p2DEvents[BuildID_2Events - 1].fPriceMultiplier; switch (ShopMenuType) { case 2: price = GetBuyingPrice(itemValue, multiplier); break; case 3: if (pItem->IsBroken()) price = 1; else price = this->GetPriceSell(itemValue, multiplier); break; case 4: price = this->GetPriceIdentification(multiplier); break; case 5: price = this->GetPriceRepair(itemValue, multiplier); break; default: Error("(%u)", ShopMenuType); break; } if ( merchantLevel ) { if (price == itemValue) { return 3; } else { return 2; } } else { return 1; } } //----- (0049107D) -------------------------------------------------------- int Player::GetBodybuilding() { int v1; // al@1 v1 = GetActualSkillLevel(PLAYER_SKILL_BODYBUILDING); int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5); return multiplier * (v1 & 0x3F); } //----- (004910A8) -------------------------------------------------------- int Player::GetMeditation() { int v1; // al@1 v1 = GetActualSkillLevel(PLAYER_SKILL_MEDITATION); int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5); return multiplier * (v1 & 0x3F); } //----- (004910D3) -------------------------------------------------------- bool Player::CanIdentify( ItemGen *pItem ) { unsigned __int16 v2; // ax@1 int v5; // edi@7 return true; if (CheckHiredNPCSpeciality(Scholar)) return true; v2 = GetActualSkillLevel(PLAYER_SKILL_ITEM_ID); if ( (signed int)SkillToMastery(v2) >= 4 ) return true; int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); v5 = multiplier * (v2 & 0x3F); return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St; } //----- (00491151) -------------------------------------------------------- bool Player::CanRepair( ItemGen *pItem ) { unsigned __int16 v2; // ax@1 int v5; // edi@7 ITEM_EQUIP_TYPE equipType = pItem->GetItemEquipType(); if (CheckHiredNPCSpeciality(Smith) && equipType <= 2 || CheckHiredNPCSpeciality(Armorer) && equipType >= 3 && equipType <= 9 || CheckHiredNPCSpeciality(Alchemist) && equipType >= 9 ) return true; v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR); if ( (signed int)SkillToMastery(v2) >= 4 ) return true; int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); v5 = multiplier * (v2 & 0x3F); return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St; } //----- (004911F3) -------------------------------------------------------- int Player::GetMerchant() { unsigned __int16 v2; // ax@1 int v5; // edi@1 int v7; // eax@3 v2 = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); if ( SkillToMastery(v2) >= 4 ) return 10000; v7 = GetPartyReputation(); int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); v5 = multiplier * (v2 & 0x3F); if (v5 == 0) { return -v7; } return v5 - v7 + 7; } //----- (0049125A) -------------------------------------------------------- int Player::GetPerception() { unsigned __int16 v2; // ax@1 int v5; // edi@1 v2 = GetActualSkillLevel(PLAYER_SKILL_PERCEPTION); if ( SkillToMastery(v2) >= 4 ) return 10000; int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); v5 = multiplier * (v2 & 0x3F); return v5; } //----- (004912B0) -------------------------------------------------------- int Player::GetDisarmTrap() { unsigned __int16 v2; // ax@1 int v5; // edi@1 v2 = GetActualSkillLevel(PLAYER_SKILL_TRAP_DISARM); if ( (signed int)SkillToMastery(v2) >= 4 ) return 10000; int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); if ( HasEnchantedItemEquipped(35) ) //only the real skill level is supposed to be added again, not the multiplied value multiplier++; v5 = multiplier * (v2 & 0x3F); return v5; } //----- (00491317) -------------------------------------------------------- char Player::GetLearningPercent() { int v2; // eax@1 v2 = GetActualSkillLevel(PLAYER_SKILL_LEARNING); int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); return multiplier * v2 + 9; } //----- (0048C6AF) -------------------------------------------------------- Player::Player() { memset(&pEquipment, 0, sizeof(PlayerEquipment)); memset(pInventoryMatrix, 0, 126 * sizeof(int)); for (uint i = 0; i < 126; ++i) pInventoryItemList[i].Reset(); for (uint i = 0; i < 12; ++i) pEquippedItems[i].Reset(); for (uint i = 0; i < 24; ++i) { pPlayerBuffs[i].uSkill = 0; pPlayerBuffs[i].uSkill = 0; pPlayerBuffs[i].uPower = 0; pPlayerBuffs[i].uExpireTime = 0; pPlayerBuffs[i].uCaster = 0; pPlayerBuffs[i].uFlags = 0; } pName[0] = 0; uCurrentFace = 0; uVoiceID = 0; memset(pConditions, 0, 20 * sizeof(__int64)); field_BB = 0; uMight = uMightBonus = 0; uIntelligence = uIntelligenceBonus = 0; uWillpower = uWillpowerBonus = 0; uEndurance = uEnduranceBonus = 0; uSpeed = uSpeedBonus = 0; uAccuracy = uAccuracyBonus = 0; uLuck = uLuckBonus = 0; uLevel = sLevelModifier = 0; sAgeModifier = 0; sACModifier = 0; // memset(field_1F5, 0, 30); pure_luck_used=0; pure_speed_used=0; pure_intellect_used=0; pure_endurance_used=0; pure_willpower_used=0; pure_accuracy_used=0; pure_might_used=0; sResFireBase = sResFireBonus = 0; sResAirBase = sResAirBonus = 0; sResWaterBase = sResWaterBonus = 0; sResEarthBase = sResEarthBonus = 0; sResMagicBase = sResMagicBonus = 0; sResSpiritBase = sResSpiritBonus = 0; sResMindBase = sResMindBonus = 0; sResBodyBase = sResBodyBonus = 0; sResLightBase = sResLightBonus = 0; sResDarkBase = sResDarkBonus = 0; uTimeToRecovery = 0; uSkillPoints = 0; sHealth = 0; uFullHealthBonus = 0; _health_related = 0; sMana = 0; uFullManaBonus = 0; _mana_related = 0; uQuickSpell = 0; memset(pInstalledBeacons, 0, 5 * sizeof(LloydBeacon)); _some_attack_bonus = 0; field_1A91 = 0; _melee_dmg_bonus = 0; field_1A93 = 0; _ranged_atk_bonus = 0; field_1A95 = 0; _ranged_dmg_bonus = 0; field_1A97 = 0; expression = CHARACTER_EXPRESSION_INVALID; uExpressionTimePassed = 0; uExpressionTimeLength = 0; uNumDivineInterventionCastsThisDay = 0; uNumArmageddonCasts = 0; uNumFireSpikeCasts = 0; memset(field_1988, 0, 49 * sizeof(int)); memset(field_1A50, 0, 64 * sizeof(char)); field_E0 = 0; field_E4 = 0; field_E8 = 0; field_EC = 0; field_F0 = 0; field_F4 = 0; field_F8 = 0; field_FC = 0; field_100 = 0; field_104 = 0; _expression21_animtime = 0; _expression21_frameset = 0; 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() { return this->uMight + GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH); } //----- (0048C86C) -------------------------------------------------------- int Player::GetBaseIntelligence() { return this->uIntelligence + GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE); } //----- (0048C883) -------------------------------------------------------- int Player::GetBaseWillpower() { return this->uWillpower + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER); } //----- (0048C89A) -------------------------------------------------------- int Player::GetBaseEndurance() { return this->uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE); } //----- (0048C8B1) -------------------------------------------------------- int Player::GetBaseAccuracy() { return this->uAccuracy + GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY); } //----- (0048C8C8) -------------------------------------------------------- int Player::GetBaseSpeed() { return this->uSpeed + GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED); } //----- (0048C8DF) -------------------------------------------------------- int Player::GetBaseLuck() { return this->uLuck + GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK); } //----- (0048C8F6) -------------------------------------------------------- int Player::GetBaseLevel() { return this->uLevel + GetItemsBonus(CHARACTER_ATTRIBUTE_LEVEL); } //----- (0048C90D) -------------------------------------------------------- int Player::GetActualLevel() { return uLevel + sLevelModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_LEVEL) + GetItemsBonus(CHARACTER_ATTRIBUTE_LEVEL); } //----- (0048C93C) -------------------------------------------------------- int Player::GetActualMight() { return GetActualAttribute(CHARACTER_ATTRIBUTE_STRENGTH, &Player::uMight, &Player::uMightBonus); } //----- (0048C9C2) -------------------------------------------------------- int Player::GetActualIntelligence() { return GetActualAttribute(CHARACTER_ATTRIBUTE_INTELLIGENCE, &Player::uIntelligence, &Player::uIntelligenceBonus); } //----- (0048CA3F) -------------------------------------------------------- int Player::GetActualWillpower() { return GetActualAttribute(CHARACTER_ATTRIBUTE_WILLPOWER, &Player::uWillpower, &Player::uWillpowerBonus); } //----- (0048CABC) -------------------------------------------------------- int Player::GetActualEndurance() { return GetActualAttribute(CHARACTER_ATTRIBUTE_ENDURANCE, &Player::uEndurance, &Player::uEnduranceBonus); } //----- (0048CB39) -------------------------------------------------------- int Player::GetActualAccuracy() { return GetActualAttribute(CHARACTER_ATTRIBUTE_ACCURACY, &Player::uAccuracy, &Player::uAccuracyBonus); } //----- (0048CBB6) -------------------------------------------------------- int Player::GetActualSpeed() { return GetActualAttribute(CHARACTER_ATTRIBUTE_SPEED, &Player::uSpeed, &Player::uSpeedBonus); } //----- (0048CC33) -------------------------------------------------------- int Player::GetActualLuck() { signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1 npc_luck_bonus = 0; if ( CheckHiredNPCSpeciality(Fool) ) npc_luck_bonus = 5; if ( CheckHiredNPCSpeciality(ChimneySweep) ) npc_luck_bonus += 20; if ( CheckHiredNPCSpeciality(Psychic) ) npc_luck_bonus += 10; return GetActualAttribute(CHARACTER_ATTRIBUTE_LUCK, &Player::uLuck, &Player::uLuckBonus) + npc_luck_bonus; } //----- (new function) -------------------------------------------------------- int Player::GetActualAttribute( CHARACTER_ATTRIBUTE_TYPE attrId, unsigned short Player::* attrValue, unsigned short Player::* attrBonus ) { uint uActualAge = this->sAgeModifier + GetBaseAge(); uint uAgeingMultiplier = 100; for (uint i = 0; i < 4; ++i) { if (uActualAge >= pAgeingTable[i]) uAgeingMultiplier = pAgingAttributeModifier[attrId][i]; else break; } auto uConditionMult = pConditionAttributeModifier[attrId][GetMajorConditionIdx()]; int magicBonus = GetMagicalBonus(attrId); int itemBonus = GetItemsBonus(attrId); return uConditionMult * uAgeingMultiplier * this->*attrValue / 100 / 100 + magicBonus + itemBonus + this->*attrBonus; } //----- (0048CCF5) -------------------------------------------------------- int Player::GetActualAttack( bool a2 ) { int v3; // eax@1 int v4; // edi@1 int v5; // ebx@1 int v6; // ebp@1 v3 = GetActualAccuracy(); v4 = GetParameterBonus(v3); v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK); v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2); return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + this->_some_attack_bonus; } //----- (0048CD45) -------------------------------------------------------- int Player::GetMeleeDamageMinimal() { int v2; // eax@1 int v3; // esi@1 int v4; // esi@1 int v5; // esi@1 signed int result; // eax@1 v2 = GetActualMight(); v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; result = _melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; if ( result < 1 ) result = 1; return result; } //----- (0048CD90) -------------------------------------------------------- int Player::GetMeleeDamageMaximal() { int v2; // eax@1 int v3; // esi@1 int v4; // esi@1 int v5; // esi@1 int v6; // esi@1 signed int result; // eax@1 v2 = GetActualMight(); v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; v6 = this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; result = 1; if ( v6 >= 1 ) result = v6; return result; } //----- (0048CDDB) -------------------------------------------------------- int Player::CalculateMeleeDamageTo( bool ignoreSkillBonus, bool ignoreOffhand, unsigned int uTargetActorID ) { int dmgSum; // esi@62 signed int result; // eax@64 int mainWpnDmg; // [sp+18h] [bp-8h]@1 int offHndWpnDmg; // [sp+1Ch] [bp-4h]@1 offHndWpnDmg = 0; mainWpnDmg = 0; if ( IsUnarmed() ) { mainWpnDmg = rand() % 3 + 1; } else { if ( HasItemEquipped(EQUIP_MAIN_HAND) ) { ItemGen *mainHandItemGen = this->GetMainHandItem(); int itemId = mainHandItemGen->uItemID; bool addOneDice = false; if ( pItemsTable->pItems[itemId].uSkillType == PLAYER_SKILL_SPEAR && !this->pEquipment.uShield ) addOneDice = true; mainWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(mainHandItemGen, uTargetActorID, addOneDice); } if ( !ignoreOffhand ) { if ( this->HasItemEquipped(EQUIP_OFF_HAND) ) { ItemGen *offHandItemGen = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uShield - 1]; if ( offHandItemGen->GetItemEquipType() != EQUIP_SHIELD ) { offHndWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(offHandItemGen, uTargetActorID, false); } } } } dmgSum = mainWpnDmg + offHndWpnDmg; if ( !ignoreSkillBonus ) { int might = GetActualMight(); int mightBonus = GetParameterBonus(might); int mightAndSkillbonus = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + mightBonus; dmgSum += this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + mightAndSkillbonus; } result = 1; if ( dmgSum >= 1 ) result = dmgSum; return result; } int Player::CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice ) { int itemId = weapon->uItemID; int diceCount = pItemsTable->pItems[itemId].uDamageDice; if (addOneDice) { diceCount++; } int diceSides = pItemsTable->pItems[itemId].uDamageRoll; int diceResult = 0; for (int i = 0; i < diceCount; i++) { diceResult += rand() % diceSides + 1; } int totalDmg = pItemsTable->pItems[itemId].uDamageMod + diceResult; if ( uTargetActorID > 0) { int enchType = weapon->uSpecEnchantmentType; if ( MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_UNDEAD) && (enchType == 64 || itemId == ITEM_ARTIFACT_GHOULSBANE || itemId == ITEM_ARTIFACT_GIBBET || itemId == ITEM_RELIC_JUSTICE) ) { totalDmg *= 2; } else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_KREEGAN) && ( enchType == 39 || itemId == ITEM_ARTIFACT_GIBBET)) { totalDmg *= 2; } else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_DRAGON) && ( enchType == 40 || itemId == ITEM_ARTIFACT_GIBBET)) { totalDmg *= 2; } else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_TITAN) && ( enchType == 65 )) { totalDmg *= 2; } } if ( (signed int)SkillToMastery(this->pActiveSkills[2]) >= 3 && pItemsTable->pItems[itemId].uSkillType == 2 && rand() % 100 < 10 ) totalDmg *= 3; return totalDmg; } //----- (0048D0B9) -------------------------------------------------------- int Player::GetRangedAttack() { int v3; // edi@3 int v4; // eax@4 int v5; // edi@4 int v6; // edi@4 int v7; // edi@4 ItemGen* mainHandItem = GetMainHandItem(); if ( mainHandItem != nullptr && ( mainHandItem->uItemID < ITEM_BLASTER || mainHandItem->uItemID > ITEM_LASER_RIFLE )) { v4 = GetActualAccuracy(); v5 = GetParameterBonus(v4); v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v5; v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; v3 = this->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7; } else { v3 = GetActualAttack(true); } return v3; } //----- (0048D124) -------------------------------------------------------- int Player::GetRangedDamageMin() { int v2; // edi@1 int v3; // edi@1 int v4; // edi@1 int result; // eax@6 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN); v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; if ( v4 >= 1 ) result = v4; else result = 0; return result; } //----- (0048D191) -------------------------------------------------------- int Player::GetRangedDamageMax() { int v2; // edi@1 int v3; // edi@1 int v4; // edi@1 int result; // eax@6 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX); v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; if ( v4 >= 1 ) result = v4; else result = 0; return result; } //----- (0048D1FE) -------------------------------------------------------- int Player::CalculateRangedDamageTo( int a2 ) { ItemGen *v4; // ebx@2 unsigned int v5; // edi@2 int v9; // esi@5 int v10; // ebx@6 signed int v15; // [sp+8h] [bp-Ch]@2 int v17; // [sp+10h] [bp-4h]@1 v17 = 0; if ( !HasItemEquipped(EQUIP_BOW) ) return 0; v4 = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uBow-1]; v5 = v4->uItemID; v15 = pItemsTable->pItems[v5].uDamageRoll; for( int i = 0; i < pItemsTable->pItems[v5].uDamageDice; i++ ) { int v7 = rand() % v15; v17 += v7 + 1; } v9 = pItemsTable->pItems[v5].uDamageMod + v17; if ( a2 ) { v10 = v4->uSpecEnchantmentType; if ( v10 == 64 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_UNDEAD)) { v9 *= 2; } else if ( v10 == 39 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_KREEGAN)) { v9 *= 2; } else if ( v10 == 40 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_DRAGON)) { v9 *= 2; } else if ( v10 == 63 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_ELF)) { v9 *= 2; } } return v9 + this->GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS); } //----- (0048D2EA) -------------------------------------------------------- char *Player::GetMeleeDamageString() { int min_damage; // edi@3 int max_damage; // eax@3 static char player__getmeleedamagestring_static_buff[40]; // idb ItemGen* mainHandItem = GetMainHandItem(); if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 )) { strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" return player__getmeleedamagestring_static_buff; } else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE)) { min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); } else { min_damage = GetMeleeDamageMinimal(); max_damage = GetMeleeDamageMaximal(); } if ( min_damage == max_damage ) { sprintf(player__getmeleedamagestring_static_buff, "%d", min_damage); } else { sprintf(player__getmeleedamagestring_static_buff, "%d - %d", min_damage, max_damage); } return player__getmeleedamagestring_static_buff; } //----- (0048D396) -------------------------------------------------------- char *Player::GetRangedDamageString() { int min_damage; // edi@3 int max_damage; // eax@3 static char player__getrangeddamagestring_static_buff[40]; // idb ItemGen* mainHandItem = GetMainHandItem(); if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 )) { strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" return player__getrangeddamagestring_static_buff; } else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE)) { min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); } else { min_damage = GetRangedDamageMin(); max_damage = GetRangedDamageMax(); } if ( max_damage > 0) { if ( min_damage == max_damage ) { sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage); } else { sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage); } } else { strcpy(player__getrangeddamagestring_static_buff, "N/A"); } return player__getrangeddamagestring_static_buff; } //----- (0048D45A) -------------------------------------------------------- bool Player::CanTrainToNextLevel() { int lvl = this->uLevel + 1; int neededExp = ((lvl * (lvl - 1)) / 2 * 1000); return this->uExperience >= neededExp; } //----- (0048D498) -------------------------------------------------------- unsigned int Player::GetExperienceDisplayColor() { if ( CanTrainToNextLevel() ) return ui_character_bonus_text_color; else return ui_character_default_text_color; } //----- (0048D4B3) -------------------------------------------------------- int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int dmg ) { int resist_value; // edi@8 int player_luck; // eax@21 signed int res_rand_divider; // ebx@2 int armor_skill; // eax@29 if ( classType == PLAYER_CLASS_LICH && (dmg_type == CHARACTER_ATTRIBUTE_RESIST_MIND || dmg_type == CHARACTER_ATTRIBUTE_RESIST_BODY || dmg_type == CHARACTER_ATTRIBUTE_RESIST_SPIRIT )) //TODO: determine if spirit resistance should be handled by body res. modifier return 0; resist_value = 0; switch(dmg_type) { case DMGT_FIRE: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE); break; case DMGT_ELECTR: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR); break; case DMGT_COLD: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER); break; case DMGT_EARTH: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); break; case DMGT_SPIRIT: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_SPIRIT);break; case DMGT_MIND: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); break; case DMGT_BODY: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); break; } player_luck = GetActualLuck(); res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30; if ( GetParameterBonus(player_luck) + resist_value > 0 ) { for (int i = 0; i < 4; i++) { if ( rand() % res_rand_divider >= 30 ) dmg >>= 1; else break; } } ItemGen* equippedArmor = GetArmorItem(); if (( dmg_type == DMGT_PHISYCAL ) && ( equippedArmor != nullptr )) { if (!equippedArmor->IsBroken()) { armor_skill = equippedArmor->GetPlayerSkillType(); if ( armor_skill==PLAYER_SKILL_PLATE ) { if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 ) return dmg / 2; } if (armor_skill==PLAYER_SKILL_CHAIN ) { if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4) return dmg * 2 / 3; } } } return dmg; } //----- (0048D62C) -------------------------------------------------------- ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) { return GetNthEquippedIndexItem(uEquipSlot)->GetItemEquipType(); } //----- (0048D651) -------------------------------------------------------- PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) { return (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(uEquipSlot)->GetPlayerSkillType(); } //----- (0048D676) -------------------------------------------------------- bool Player::IsUnarmed() { return !HasItemEquipped(EQUIP_MAIN_HAND) && (!HasItemEquipped(EQUIP_OFF_HAND) || GetOffHandItem()->GetItemEquipType() == EQUIP_SHIELD); } //----- (0048D6AA) -------------------------------------------------------- bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex) { auto i = pEquipment.pIndices[uEquipIndex]; if (i) return !pOwnItems[i - 1].IsBroken(); else return false; } //----- (0048D6D0) -------------------------------------------------------- bool Player::HasEnchantedItemEquipped(int uEnchantment) { for (uint i = 0; i < 16; ++i) { if (HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uSpecEnchantmentType == uEnchantment) return true; } return false; } //----- (0048D709) -------------------------------------------------------- bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type ) { return ( HasItemEquipped(equip_type) && GetNthEquippedIndexItem(equip_type)->uItemID == item_id ); } bool Player::WearsItemAnyWhere(int item_id) { for (int i = 0; i < 16; i++) { if (WearsItem(item_id, (ITEM_EQUIP_TYPE) i)) { return true; } } return false; } //----- (0048D76C) -------------------------------------------------------- int Player::StealFromShop( ItemGen *itemToSteal, int extraStealDifficulty, int reputation, int a5, int *fineIfFailed ) //returns an int, but is the return value is compared to zero, so might change to bool { unsigned __int16 v6; // cx@8 int v7; // edi@8 unsigned int v8; // ebx@8 unsigned int itemvalue; // esi@8 int v10; // eax@8 int currMaxItemValue; // edi@12 if ( !itemToSteal || this->IsEradicated() || this->IsDead() || this->IsPertified() || this->IsDrunk() || this->IsUnconcious() || this->IsAsleep() ) { return 0; } else { v6 = this->pActiveSkills[34]; v7 = v6 & 0x3F; v8 = SkillToMastery(v6); itemvalue = itemToSteal->GetValue(); v10 = itemToSteal->GetItemEquipType(); if ( v10 == EQUIP_OFF_HAND || v10 == EQUIP_MAIN_HAND || v10 == EQUIP_BOW ) itemvalue *= 3; currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; if (a5) { *fineIfFailed += 500; } if ( rand() % 100 >= 5 ) { if ( *fineIfFailed > currMaxItemValue ) if (*fineIfFailed - currMaxItemValue < 500) { return 1; } else { return 0; } else return 2; } else { return 0; } } } //----- (0048D88B) -------------------------------------------------------- int Player::StealFromActor(unsigned int uActorID, int _steal_perm, int reputation) { Actor *actroPtr; // edi@1 int v7; // ebx@10 unsigned int stealingMastery; // esi@10 int fineIfFailed; // esi@10 int v11; // eax@13 bool HasFullItemSlots; // ebx@15 unsigned __int16 carriedItemId; // si@21 unsigned int enchBonusSum; // esi@31 int *enchTypePtr; // eax@34 ItemGen tempItem; // [sp+8h] [bp-34h]@15 int currMaxItemValue; actroPtr = &pActors[uActorID]; if ( !actroPtr || this->IsEradicated() || this->IsDead() || this->IsPertified() || this->IsDrunk() || this->IsUnconcious() || this->IsAsleep() ) { return 0; } pGlobalTXT_LocalizationStrings[1]; if ( !(BYTE2(actroPtr->uAttributes) & 0x80) ) actroPtr->SetRandomGoldIfTheresNoItem(); unsigned __int16 v6 = this->pActiveSkills[34]; v7 = v6 & 0x3F; stealingMastery = SkillToMastery(v6); int v30 = StealingMasteryBonuses[stealingMastery]; int v29 = StealingRandomBonuses[rand() % 5]; fineIfFailed = actroPtr->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); currMaxItemValue = v29 + v7 * v30; pGlobalTXT_LocalizationStrings[200]; if ( false && (rand() % 100 < 5 || fineIfFailed > currMaxItemValue || BYTE2(actroPtr->uAttributes) & 8) ) { Actor::AggroSurroundingPeasants(uActorID, 1); sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[376], this->pName); ShowStatusBarString(pTmpBuf2.data(), 2u); return 0; } else { v11 = rand(); if ( v11 % 100 >= 70 ) //stealing gold { enchBonusSum = 0; for (int i = 0; i < v7; i++) { enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; } if ( actroPtr->array_000234[3].GetItemEquipType() != EQUIP_GOLD ) return 2; enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; if ( (int)enchBonusSum >= *enchTypePtr ) { actroPtr->array_000234[3].uItemID = 0; *enchTypePtr = 0; } else { *enchTypePtr -= enchBonusSum; } if ( enchBonusSum ) { party_finds_gold(enchBonusSum, 2); sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold } else { sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything } ShowStatusBarString(pTmpBuf2.data(), 2u); return 2; } else if ( v11 % 100 >= 40 ) //stealing an item { tempItem.Reset(); HasFullItemSlots = false; int i; for (i = 0; i < 4; i++) { if ( actroPtr->array_000234[i].uItemID != 0 && actroPtr->array_000234[i].GetItemEquipType() != EQUIP_GOLD ) break; } if (i == 4) HasFullItemSlots = true; carriedItemId = actroPtr->uCarriedItemID; if ( carriedItemId != 0 || HasFullItemSlots ) { tempItem.Reset(); if ( carriedItemId != 0 ) { actroPtr->uCarriedItemID = 0; tempItem.uItemID = carriedItemId; if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1; else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) tempItem.uEnchantmentType = 2 * rand() % 4 + 2; } else { ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; memcpy(&tempItem, itemToSteal, sizeof(tempItem)); itemToSteal->Reset(); carriedItemId = tempItem.uItemID; } if (carriedItemId != 0) // looks odd in current context, but avoids accessing zeroth element of pItemsTable->pItems { 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(); memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); pMouse->SetCursorBitmapFromItemID(carriedItemId); return 2; } } } sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything ShowStatusBarString(pTmpBuf2.data(), 2u); return 2; } } // 4EDEA0: using guessed type int dword_4EDEA0[]; // 4EDEB4: using guessed type int dword_4EDEB4[]; // 4EDEC4: using guessed type int dword_4EDEC4[]; //----- (0048DBB9) -------------------------------------------------------- void Player::Heal(int amount) { signed int max_health; // eax@3 if ( !IsEradicated() && !IsDead() ) { max_health = GetMaxHealth(); if ( IsZombie() ) max_health /= 2; sHealth += amount; if ( sHealth > max_health ) sHealth = max_health; if ( IsUnconcious() ) { if ( sHealth > 0 ) { SetUnconcious(false); } } } } //----- (0048DC1E) -------------------------------------------------------- int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type ) { signed int recieved_dmg; // eax@1 bool broke_armor; SetAsleep(false); recieved_dmg = CalculateIncommingDamage(dmg_type, amount); sHealth -= recieved_dmg; broke_armor = sHealth <= -10; if ( sHealth < 1 ) // { if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1) || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 ) { SetCondUnconsciousWithBlockCheck(false); } else { SetCondDeadWithBlockCheck(false); if ( sHealth > 0 ) sHealth = 0; } if (broke_armor ) { ItemGen* equippedArmor = GetArmorItem(); if ( equippedArmor != nullptr ) { if ( !(equippedArmor->uAttributes & ITEM_HARDENED)) { equippedArmor->SetBroken(); } } } } if ( recieved_dmg && CanAct() ) PlaySound(SPEECH_24, 0); return recieved_dmg; } //----- (0048DCF6) -------------------------------------------------------- int Player::ReceiveSpecialAttackEffect( int attType, struct Actor *pActor ) { SPECIAL_ATTACK_TYPE attTypeCast = (SPECIAL_ATTACK_TYPE) attType; signed int v3; // edi@1 signed int v4; // ebx@1 int v6; // eax@2 int v8; // eax@8 int v10; // eax@8 int v11; // ebx@8 ItemGen *v13; // eax@9 int v22; // eax@49 signed int v23; // ebx@49 void *v27; // ecx@76 char v46[140]; // [sp+Ch] [bp-94h]@13 unsigned int v47; // [sp+98h] [bp-8h]@1 ItemGen* v48; // [sp+9Ch] [bp-4h]@1 v4 = 0; v47 = 0; switch ( attTypeCast ) { case SPECIAL_ATTACK_CURSE: v6 = GetActualWillpower(); v11 = GetParameterBonus(v6); break; case SPECIAL_ATTACK_WEAK: case SPECIAL_ATTACK_SLEEP: case SPECIAL_ATTACK_DRUNK: case SPECIAL_ATTACK_DISEASE1: case SPECIAL_ATTACK_DISEASE2: case SPECIAL_ATTACK_DISEASE3: case SPECIAL_ATTACK_UNCONSCIOUS: case SPECIAL_ATTACK_AGING: v6 = GetActualEndurance(); v11 = GetParameterBonus(v6); break; case SPECIAL_ATTACK_INSANE: case SPECIAL_ATTACK_PARALYZED: case SPECIAL_ATTACK_FEAR: v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); break; case SPECIAL_ATTACK_PETRIFIED: v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); break; case SPECIAL_ATTACK_POISON1: case SPECIAL_ATTACK_POISON2: case SPECIAL_ATTACK_POISON3: case SPECIAL_ATTACK_DEAD: case SPECIAL_ATTACK_ERADICATED: v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); break; case SPECIAL_ATTACK_MANA_DRAIN: v8 = GetActualWillpower(); v10 = GetActualIntelligence(); v11 = (GetParameterBonus(v10) + GetParameterBonus(v8)) / 2; break; case SPECIAL_ATTACK_BREAK_ANY: for (int i = 0; i < 138; i++) { v13 = &this->pInventoryItemList[i]; if ( v13->uItemID > 0 && v13->uItemID <= 134 && !v13->IsBroken()) v46[v4++] = i; } if ( !v4 ) return 0; v48 = &this->pInventoryItemList[v46[rand() % v4]]; v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); break; case SPECIAL_ATTACK_BREAK_ARMOR: for (int i = 0; i < 16; i++ ) { if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { if ( i == EQUIP_ARMOUR ) v46[v4++] = this->pEquipment.uArmor - 1; if ( (i == EQUIP_OFF_HAND || i == EQUIP_MAIN_HAND) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_SHIELD ) v46[v4++] = this->pEquipment.pIndices[i] - 1; } } if ( !v4 ) return 0; v48 = &this->pInventoryItemList[v46[rand() % v4]]; v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); break; case SPECIAL_ATTACK_BREAK_WEAPON: for (int i = 0; i < 16; i++ ) { if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { if ( i == EQUIP_BOW ) v46[v4++] = LOBYTE(this->pEquipment.uBow) - 1; if ( (i == EQUIP_OFF_HAND || i == EQUIP_MAIN_HAND) && (GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_OFF_HAND || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_MAIN_HAND) ) v46[v4++] = this->pEquipment.pIndices[i] - 1; } } if ( !v4 ) return 0; v48 = &this->pInventoryItemList[v46[rand() % v4]]; v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); break; case SPECIAL_ATTACK_STEAL: for ( int i = 0; i < 126; i++ ) { int ItemPosInList = this->pInventoryMatrix[i]; if (ItemPosInList > 0) { ItemGen* v21 = &this->pInventoryItemList[ItemPosInList - 1]; if ( v21->uItemID > 0 && v21->uItemID <= 134 ) { v46[v4++] = i; } } } if ( !v4 ) return 0; v47 = v46[rand() % v4]; v6 = GetActualAccuracy(); v11 = GetParameterBonus(v6); break; default: v11 = 0; break; } v22 = GetActualLuck(); v23 = GetParameterBonus(v22) + v11 + 30; if ( rand() % v23 >= 30 ) { return 0; } else { for ( v3 = 0; v3 < 4; v3++ ) { if ( this == pPlayers[v3 + 1] ) break; } switch ( attTypeCast ) { case SPECIAL_ATTACK_CURSE: SetCondition(Condition_Cursed, 1); pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_WEAK: SetCondition(Condition_Weak, 1); pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_SLEEP: SetCondition(Condition_Sleep, 1); pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_DRUNK: SetCondition(Condition_Drunk, 1); pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_INSANE: SetCondition(Condition_Insane, 1); pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_POISON1: SetCondition(Condition_Poison1, 1); pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_POISON2: SetCondition(Condition_Poison2, 1); pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_POISON3: SetCondition(Condition_Poison3, 1); pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_DISEASE1: SetCondition(Condition_Disease1, 1); pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_DISEASE2: SetCondition(Condition_Disease2, 1); pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_DISEASE3: SetCondition(Condition_Disease3, 1); pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_PARALYZED: SetCondition(Condition_Paralyzed, 1); pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_UNCONSCIOUS: SetCondition(Condition_Unconcious, 1); pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_DEAD: SetCondition(Condition_Dead, 1); pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_PETRIFIED: SetCondition(Condition_Pertified, 1); pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_ERADICATED: SetCondition(Condition_Eradicated, 1); pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_BREAK_ANY: case SPECIAL_ATTACK_BREAK_ARMOR: case SPECIAL_ATTACK_BREAK_WEAPON: if ( !(v48->uAttributes & ITEM_HARDENED) ) { PlaySound(SPEECH_40, 0); v48->SetBroken(); pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); } pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_STEAL: PlaySound(SPEECH_40, 0); v27 = pActor->array_000234; if ( pActor->array_000234[0].uItemID ) { v27 = &pActor->array_000234[1]; if ( pActor->array_000234[1].uItemID ) { pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; } } memcpy(v27, &this->pInventoryItemList[this->pInventoryMatrix[v47]-1], 0x24u); RemoveItemAtInventoryIndex(v47); pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_AGING: PlaySound(SPEECH_42, 0); ++this->sAgeModifier; pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_MANA_DRAIN: PlaySound(SPEECH_41, 0); this->sMana = 0; pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; case SPECIAL_ATTACK_FEAR: SetCondition(Condition_Fear, 1); pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); return 1; break; default: return 0; } } } // 48DCF6: using guessed type char var_94[140]; //----- (0048E1A3) -------------------------------------------------------- unsigned int Player::GetSpellSchool(unsigned int uSpellID) { return pSpellStats->pInfos[uSpellID].uSchool; } //----- (0048E1B5) -------------------------------------------------------- int Player::GetAttackRecoveryTime(bool bRangedAttack) { ItemGen *weapon = nullptr; uint weapon_recovery = base_recovery_times_per_weapon_type[0]; if (bRangedAttack) { if ( HasItemEquipped(EQUIP_BOW) ) { weapon = GetBowItem(); weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; } } else if ( IsUnarmed() == 1 && GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) { weapon_recovery = base_recovery_times_per_weapon_type[1]; } else if ( HasItemEquipped(EQUIP_MAIN_HAND) ) { weapon = GetMainHandItem(); if (weapon->GetItemEquipType() == EQUIP_WAND) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 __debugbreak(); // looks like wands were two-handed weapons once, or supposed to be. should not get here now weapon_recovery = pSpellDatas[wand_spell_ids[weapon->uItemID - ITEM_WAND_FIRE]].uExpertLevelRecovery; } else weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; } if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) // ADD: shield check because shield recovery is added later and can be accidentally doubled { if (base_recovery_times_per_weapon_type[GetOffHandItem()->GetPlayerSkillType()] > weapon_recovery) { weapon = GetOffHandItem(); weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; } } uint armour_recovery = 0; if ( HasItemEquipped(EQUIP_ARMOUR) ) { auto armour_skill_type = GetArmorItem()->GetPlayerSkillType(); uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; float multiplier; if (armour_skill_type == PLAYER_SKILL_LEATHER) { multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0, 0, 0); } else if (armour_skill_type == PLAYER_SKILL_CHAIN) { multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0.5f, 0, 0); } else if (armour_skill_type == PLAYER_SKILL_PLATE) { multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0.5f, 0.5f, 0); } else { Error("Unknown armour type"); // what kind of armour is that? multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 1.0f, 1.0f, 1.0f); } armour_recovery = (uint)(base_armour_recovery * multiplier); } uint shield_recovery = 0; if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD) { auto skill_type = GetOffHandItem()->GetPlayerSkillType(); uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0); shield_recovery = (uint)(shield_base_recovery * multiplier); } uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()), sword_axe_bow_recovery_reduction = 0; bool shooting_laser = false; if (weapon != nullptr) { if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon->GetPlayerSkillType()) && (weapon->GetPlayerSkillType() == PLAYER_SKILL_SWORD || weapon->GetPlayerSkillType() == PLAYER_SKILL_AXE || weapon->GetPlayerSkillType() == PLAYER_SKILL_BOW) ) { if (SkillToMastery(pActiveSkills[weapon->GetPlayerSkillType()]) >= 2 ) // Expert Sword, Axe & Bow reduce recovery sword_axe_bow_recovery_reduction = pActiveSkills[weapon->GetPlayerSkillType()] & 0x3F; } if (weapon->GetPlayerSkillType() == PLAYER_SKILL_BLASTER) shooting_laser = true; } uint armsmaster_recovery_reduction = 0; if (!bRangedAttack && !shooting_laser) { if (uint armsmaster_level = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER)) { armsmaster_recovery_reduction = armsmaster_level & 0x3F; if (SkillToMastery(armsmaster_level) >= 4) armsmaster_recovery_reduction *= 2; } } uint hasteRecoveryReduction = 0; if (pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0 || pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0 ) hasteRecoveryReduction = 25; uint weapon_enchantment_recovery_reduction = 0; if ( weapon ) { if (weapon->uSpecEnchantmentType == 59 || weapon->uSpecEnchantmentType == 41 || weapon->uSpecEnchantmentType == 500) weapon_enchantment_recovery_reduction = 20; } int recovery = weapon_recovery + armour_recovery + shield_recovery - armsmaster_recovery_reduction - weapon_enchantment_recovery_reduction - hasteRecoveryReduction - sword_axe_bow_recovery_reduction - player_speed_recovery_reduction; if (recovery < 0) recovery = 0; return recovery; } //----- new -------------------------------------------------------- float Player::GetArmorRecoveryMultiplierFromSkillLevel( unsigned char armour_skill_type, float mult1, float mult2, float mult3, float mult4 ) { uint skill_mastery = SkillToMastery(pActiveSkills[armour_skill_type]); switch (skill_mastery) { case 1: return mult1; break; case 2: return mult2; break; case 3: return mult3; break; case 4: return mult4; break; } Error("Unexpected input value: %d", armour_skill_type); return 0; } //----- (0048E4F8) -------------------------------------------------------- int Player::GetMaxHealth() { int v3; // esi@1 int v4; // esi@1 int v6; // esi@1 v3 = GetParameterBonus(GetActualEndurance()); v4 = pBaseHealthPerLevelByClass[classType] * (GetActualLevel() + v3); v6 = uFullHealthBonus + pBaseHealthByClass[classType / 4] + GetSkillBonus(CHARACTER_ATTRIBUTE_HEALTH) + GetItemsBonus(CHARACTER_ATTRIBUTE_HEALTH) + v4; return max(1, v6); } //----- (0048E565) -------------------------------------------------------- int Player::GetMaxMana() { int v2; // eax@2 int v3; // esi@4 int v4; // eax@5 int v5; // esi@5 int v6; // eax@5 int v7; // esi@6 int v8; // esi@6 int v9; // esi@6 switch (classType) { case PLAYER_CLASS_ROGUE: case PLAYER_CLASS_SPY: case PLAYER_CLASS_ASSASSIN: case PLAYER_CLASS_ARCHER: case PLAYER_CLASS_WARRIOR_MAGE: case PLAYER_CLASS_MASTER_ARCHER: case PLAYER_CLASS_SNIPER: case PLAYER_CLASS_SORCERER: case PLAYER_CLASS_WIZARD: case PLAYER_CLASS_ARCHMAGE: case PLAYER_CLASS_LICH: v2 = GetActualIntelligence(); v3 = GetParameterBonus(v2); break; case PLAYER_CLASS_INITIATE: case PLAYER_CLASS_MASTER: case PLAYER_CLASS_NINJA: case PLAYER_CLASS_PALADIN: case PLAYER_CLASS_CRUSADER: case PLAYER_CLASS_HERO: case PLAYER_CLASS_VILLIAN: case PLAYER_CLASS_CLERIC: case PLAYER_CLASS_PRIEST: case PLAYER_CLASS_PRIEST_OF_SUN: case PLAYER_CLASS_PRIEST_OF_MOON: v2 = GetActualWillpower(); v3 = GetParameterBonus(v2); break; case PLAYER_CLASS_HUNTER: case PLAYER_CLASS_RANGER_LORD: case PLAYER_CLASS_BOUNTY_HUNTER: case PLAYER_CLASS_DRUID: case PLAYER_CLASS_GREAT_DRUID: case PLAYER_CLASS_ARCH_DRUID: case PLAYER_CLASS_WARLOCK: v4 = GetActualWillpower(); v5 = GetParameterBonus(v4); v6 = GetActualIntelligence(); v3 = GetParameterBonus(v6) + v5; break; default: return 0; break; } v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3); v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA) + v7; v9 = uFullManaBonus + pBaseManaByClass[classType / 4] + GetSkillBonus(CHARACTER_ATTRIBUTE_MANA) + v8; return max(0,v9); } //----- (0048E656) -------------------------------------------------------- int Player::GetBaseAC() { int v2; // eax@1 int v3; // esi@1 int v4; // esi@1 int v5; // esi@1 v2 = GetActualSpeed(); v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; return max(0, v5); } //----- (0048E68F) -------------------------------------------------------- int Player::GetActualAC() { int v2; // eax@1 int v3; // esi@1 int v4; // esi@1 int v5; // esi@1 int v6; // esi@1 v2 = GetActualSpeed(); v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; v6 = this->sACModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v5; return max(0, v6); } //----- (0048E6DC) -------------------------------------------------------- unsigned int Player::GetBaseAge() { return (unsigned int)(((__int64)(pParty->uTimePlayed * 0.234375) / 60 / 60 / 24) / 7 / 4 / 12 - uBirthYear + game_starting_year); } //----- (0048E72C) -------------------------------------------------------- unsigned int Player::GetActualAge() { return this->sAgeModifier + GetBaseAge(); } //----- (0048E73F) -------------------------------------------------------- int Player::GetBaseResistance(enum CHARACTER_ATTRIBUTE_TYPE a2) { int v7; // esi@20 int racialBonus = 0; __int16* resStat; switch (a2) { case CHARACTER_ATTRIBUTE_RESIST_FIRE: resStat = &sResFireBase; if (IsRaceGoblin()) racialBonus = 5; break; case CHARACTER_ATTRIBUTE_RESIST_AIR: resStat = &sResAirBase; if (IsRaceGoblin()) racialBonus = 5; break; case CHARACTER_ATTRIBUTE_RESIST_WATER: resStat = &sResWaterBase; if (IsRaceDwarf()) racialBonus = 5; break; case CHARACTER_ATTRIBUTE_RESIST_EARTH: resStat = &sResEarthBase; if (IsRaceDwarf()) racialBonus = 5; break; case CHARACTER_ATTRIBUTE_RESIST_MIND: resStat = &sResMindBase; if (IsRaceElf()) racialBonus = 10; break; case CHARACTER_ATTRIBUTE_RESIST_BODY: case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: resStat = &sResBodyBase; if (IsRaceHuman()) racialBonus = 5; break; } v7 = GetItemsBonus(a2) + racialBonus; return v7 + *resStat; } //----- (0048E7D0) -------------------------------------------------------- int Player::GetActualResistance(enum CHARACTER_ATTRIBUTE_TYPE a2) { signed int v10 = 0; // [sp+14h] [bp-4h]@1 __int16* resStat; int result; int baseRes; int leatherArmorSkillLevel = GetActualSkillLevel(PLAYER_SKILL_LEATHER); if ( CheckHiredNPCSpeciality(Enchanter) ) v10 = 20; if ( (a2 == CHARACTER_ATTRIBUTE_RESIST_FIRE || a2 == CHARACTER_ATTRIBUTE_RESIST_AIR || a2 == CHARACTER_ATTRIBUTE_RESIST_WATER || a2 == CHARACTER_ATTRIBUTE_RESIST_EARTH) && SkillToMastery(leatherArmorSkillLevel) == 4 && HasItemEquipped(EQUIP_ARMOUR) && GetEquippedItemSkillType(EQUIP_ARMOUR) == PLAYER_SKILL_LEATHER ) v10 += leatherArmorSkillLevel & 0x3F; switch (a2) { case CHARACTER_ATTRIBUTE_RESIST_FIRE: resStat = &sResFireBonus; break; case CHARACTER_ATTRIBUTE_RESIST_AIR: resStat = &sResAirBonus; break; case CHARACTER_ATTRIBUTE_RESIST_WATER: resStat = &sResWaterBonus; break; case CHARACTER_ATTRIBUTE_RESIST_EARTH: resStat = &sResEarthBonus; break; case CHARACTER_ATTRIBUTE_RESIST_MIND: resStat = &sResMindBonus; break; case CHARACTER_ATTRIBUTE_RESIST_BODY: case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: resStat = &sResBodyBonus; break; } baseRes = GetBaseResistance(a2); result = v10 + GetMagicalBonus(a2) + baseRes + *(resStat); return result; } //----- (0048E8F5) -------------------------------------------------------- bool Player::Recover(int dt) { int v3; // qax@1 v3 = (int)(dt * GetSpecialItemBonus(17) * 0.01 + dt); Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery); if (uTimeToRecovery > v3) { uTimeToRecovery -= v3; return true; } else { uTimeToRecovery = 0; viewparams->bRedrawGameUI = true; if (!uActiveCharacter) uActiveCharacter = pParty->GetNextActiveCharacter(); return false; } } //----- (0048E96A) -------------------------------------------------------- void Player::SetRecoveryTime(signed int rec) { Assert(rec >= 0); if (rec > uTimeToRecovery) uTimeToRecovery = rec; if (uActiveCharacter != 0 && pPlayers[uActiveCharacter] == this && !some_active_character) uActiveCharacter = pParty->GetNextActiveCharacter(); viewparams->bRedrawGameUI = true; } // 50C0C4: using guessed type int some_active_character; //----- (0048E9B7) -------------------------------------------------------- void Player::RandomizeName() { if (!uExpressionTimePassed) strcpy(pName, pNPCStats->pNPCNames[rand() % pNPCStats->uNumNPCNames[uSex]][uSex]); } //----- (0048E9F4) -------------------------------------------------------- unsigned int Player::GetMajorConditionIdx() { for (uint i = 0; i < 18; ++i) if (pConditions[pConditionImportancyTable[i]] != 0) return pConditionImportancyTable[i]; return 18; } //----- (0048EA1B) -------------------------------------------------------- int Player::GetParameterBonus( int player_parameter ) { int i; // eax@1 i = 0; while (param_to_bonus_table[i]) { if (player_parameter >= param_to_bonus_table[i]) break; ++i; } return parameter_to_bonus_value[i]; } //----- (0048EA46) -------------------------------------------------------- int Player::GetSpecialItemBonus( int enchantmentId ) { for (int i = EQUIP_OFF_HAND; i < EQUIP_BOOK; ++i ) { if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { if (enchantmentId == 17) { if ((GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 17) || (GetNthEquippedIndexItem(i)->uItemID == 533)) //Elven Chainmail+Increases rate of Recovery return 50; } if (enchantmentId == 24) { if (GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 24) //Increased Knockback. return 5; } } } return 0; } //----- (0048EAAE) -------------------------------------------------------- int Player::GetItemsBonus( enum CHARACTER_ATTRIBUTE_TYPE attr, bool getOnlyMainHandDmg /*= false*/ ) { int v5; // edi@1 int v9; // eax@49 int v14; // ecx@58 int v15; // eax@58 int v17; // eax@62 int v22; // eax@76 int v25; // ecx@80 int v26; // edi@80 int v32; // eax@98 int v56; // eax@365 signed int v58; // [sp-4h] [bp-20h]@10 int v61; // [sp+10h] [bp-Ch]@1 int v62; // [sp+14h] [bp-8h]@1 ItemGen *currEquippedItem; // [sp+20h] [bp+4h]@101 bool no_skills; v5 = 0; v62 = 0; v61 = 0; no_skills=false; switch (attr) { case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: v58 = PLAYER_SKILL_ALCHEMY; break; case CHARACTER_ATTRIBUTE_SKILL_STEALING: v58 = PLAYER_SKILL_STEALING; break; case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM: v58 = PLAYER_SKILL_TRAP_DISARM; break; case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID: v58 = PLAYER_SKILL_ITEM_ID; break; case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID: v58 = PLAYER_SKILL_MONSTER_ID; break; case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER: v58 = PLAYER_SKILL_ARMSMASTER; break; case CHARACTER_ATTRIBUTE_SKILL_DODGE: v58 = PLAYER_SKILL_DODGE; break; case CHARACTER_ATTRIBUTE_SKILL_UNARMED: v58 = PLAYER_SKILL_UNARMED; break; case CHARACTER_ATTRIBUTE_SKILL_FIRE: v58 = PLAYER_SKILL_FIRE; break; case CHARACTER_ATTRIBUTE_SKILL_AIR: v58 = PLAYER_SKILL_AIR; break; case CHARACTER_ATTRIBUTE_SKILL_WATER: v58 = PLAYER_SKILL_WATER; break; case CHARACTER_ATTRIBUTE_SKILL_EARTH: v58 = PLAYER_SKILL_EARTH; break; case CHARACTER_ATTRIBUTE_SKILL_SPIRIT: v58 = PLAYER_SKILL_SPIRIT; break; case CHARACTER_ATTRIBUTE_SKILL_MIND: v58 = PLAYER_SKILL_MIND; break; case CHARACTER_ATTRIBUTE_SKILL_BODY: v58 = PLAYER_SKILL_BODY; break; case CHARACTER_ATTRIBUTE_SKILL_LIGHT: v58 = PLAYER_SKILL_LIGHT; break; case CHARACTER_ATTRIBUTE_SKILL_DARK: v58 = PLAYER_SKILL_DARK; break; case CHARACTER_ATTRIBUTE_SKILL_MEDITATION: v58 = PLAYER_SKILL_MEDITATION; break; case CHARACTER_ATTRIBUTE_SKILL_BOW: v58 = PLAYER_SKILL_BOW; break; case CHARACTER_ATTRIBUTE_SKILL_SHIELD: v58 = PLAYER_SKILL_SHIELD; break; case CHARACTER_ATTRIBUTE_SKILL_LEARNING: v58 = PLAYER_SKILL_LEARNING; break; default: no_skills=true; } if (!no_skills) { if ( !this->pActiveSkills[v58] ) return 0; } switch(attr) //TODO would be nice to move these into separate functions { case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: case CHARACTER_ATTRIBUTE_RANGED_ATTACK: if ( HasItemEquipped(EQUIP_BOW) ) v5 = GetBowItem()->GetDamageMod(); return v5; break; case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN: if ( !HasItemEquipped(EQUIP_BOW) ) return 0; v5 = GetBowItem()->GetDamageMod(); v56 = GetBowItem()->GetDamageDice(); return v5 + v56; break; case CHARACTER_ATTRIBUTE_RANGED_DMG_MAX: if ( !HasItemEquipped(EQUIP_BOW) ) return 0; v5 = GetBowItem()->GetDamageDice() * GetBowItem()->GetDamageRoll(); v56 = GetBowItem()->GetDamageMod(); return v5 + v56; case CHARACTER_ATTRIBUTE_LEVEL: if ( !Player::HasEnchantedItemEquipped(25) ) return 0; return 5; break; case CHARACTER_ATTRIBUTE_MELEE_DMG_MAX: if ( IsUnarmed() ) { return 3; } else { if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) { v22 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); if ( v22 >= 0 && v22 <= 2) { ItemGen* mainHandItem = GetMainHandItem(); v26 = mainHandItem->GetDamageRoll(); if ( GetOffHandItem() != nullptr || mainHandItem->GetPlayerSkillType() != 4 ) { v25 = mainHandItem->GetDamageDice(); } else { v25 = mainHandItem->GetDamageDice() + 1; } v5 = mainHandItem->GetDamageMod() + v25 * v26; } } if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0 || GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2)) { return v5; } else { ItemGen* offHandItem = GetOffHandItem(); v15 = offHandItem->GetDamageMod(); v14 = offHandItem->GetDamageDice() * offHandItem->GetDamageRoll(); return v5 + v15 + v14; } } break; case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: case CHARACTER_ATTRIBUTE_ATTACK: if ( IsUnarmed() ) { return 0; } if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) { v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); if ( v17 >= 0 && v17 <= 2) { v5 = GetMainHandItem()->GetDamageMod(); } } if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 ) return v5; else { v56 = GetOffHandItem()->GetDamageMod(); return v5 + v56; } break; case CHARACTER_ATTRIBUTE_MELEE_DMG_MIN: if ( IsUnarmed() ) { return 1; } if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) { v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); if ( v9 >= 0 && v9 <= 2) { ItemGen* mainHandItem = GetMainHandItem(); v5 = mainHandItem->GetDamageDice() + mainHandItem->GetDamageMod(); if ( GetOffHandItem() == nullptr && mainHandItem->GetPlayerSkillType() == 4) { ++v5; } } } if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 ) { return v5; } else { ItemGen* offHandItem = GetOffHandItem(); v14 = offHandItem->GetDamageMod(); v15 = offHandItem->GetDamageDice(); return v5 + v15 + v14; } break; case CHARACTER_ATTRIBUTE_STRENGTH: case CHARACTER_ATTRIBUTE_INTELLIGENCE: case CHARACTER_ATTRIBUTE_WILLPOWER: case CHARACTER_ATTRIBUTE_ENDURANCE: case CHARACTER_ATTRIBUTE_ACCURACY: case CHARACTER_ATTRIBUTE_SPEED: case CHARACTER_ATTRIBUTE_LUCK: case CHARACTER_ATTRIBUTE_HEALTH: case CHARACTER_ATTRIBUTE_MANA: case CHARACTER_ATTRIBUTE_AC_BONUS: case CHARACTER_ATTRIBUTE_RESIST_FIRE: case CHARACTER_ATTRIBUTE_RESIST_AIR: case CHARACTER_ATTRIBUTE_RESIST_WATER: case CHARACTER_ATTRIBUTE_RESIST_EARTH: case CHARACTER_ATTRIBUTE_RESIST_MIND: case CHARACTER_ATTRIBUTE_RESIST_BODY: case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: case CHARACTER_ATTRIBUTE_SKILL_STEALING: case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM: case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID: case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID: case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER: case CHARACTER_ATTRIBUTE_SKILL_DODGE: case CHARACTER_ATTRIBUTE_SKILL_UNARMED: case CHARACTER_ATTRIBUTE_SKILL_FIRE: case CHARACTER_ATTRIBUTE_SKILL_AIR: case CHARACTER_ATTRIBUTE_SKILL_WATER: case CHARACTER_ATTRIBUTE_SKILL_EARTH: case CHARACTER_ATTRIBUTE_SKILL_SPIRIT: case CHARACTER_ATTRIBUTE_SKILL_MIND: case CHARACTER_ATTRIBUTE_SKILL_BODY: case CHARACTER_ATTRIBUTE_SKILL_LIGHT: case CHARACTER_ATTRIBUTE_SKILL_DARK: case CHARACTER_ATTRIBUTE_SKILL_MEDITATION: case CHARACTER_ATTRIBUTE_SKILL_BOW: case CHARACTER_ATTRIBUTE_SKILL_SHIELD: case CHARACTER_ATTRIBUTE_SKILL_LEARNING: for (int i = 0; i < 16; i++) { if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { currEquippedItem = GetNthEquippedIndexItem(i); if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS ) { v32 = currEquippedItem->GetItemEquipType(); if ( v32 >= 3 && v32 <= 11 ) { v5 += currEquippedItem->GetDamageDice() + currEquippedItem->GetDamageMod(); } } if ( pItemsTable->IsMaterialNonCommon(currEquippedItem) && !pItemsTable->IsMaterialSpecial(currEquippedItem) ) { currEquippedItem->GetItemBonusArtifact(this, attr, &v62); } else if ( currEquippedItem->uEnchantmentType != 0 ) { if (currEquippedItem->IsRegularEnchanmentForAttribute(attr)) { if ( attr > CHARACTER_ATTRIBUTE_RESIST_BODY && v5 < currEquippedItem->m_enchantmentStrength ) v5 = currEquippedItem->m_enchantmentStrength; else v5 += currEquippedItem->m_enchantmentStrength; } } else { currEquippedItem->GetItemBonusSpecialEnchantment(this, attr, &v5, &v61); } } } return v5 + v62 + v61; break; default: return 0; } } //----- (0048F73C) -------------------------------------------------------- int Player::GetMagicalBonus(enum CHARACTER_ATTRIBUTE_TYPE a2) { int v3 = 0; // eax@4 int v4 = 0; // ecx@5 switch ( a2 ) { case CHARACTER_ATTRIBUTE_RESIST_FIRE: v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_FIRE].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_AIR: v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_AIR].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_BODY: v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_BODY].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_WATER: v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_WATER].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_EARTH: v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_EARTH].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_MIND: v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_MIND].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].uPower; break; case CHARACTER_ATTRIBUTE_ATTACK: case CHARACTER_ATTRIBUTE_RANGED_ATTACK: v3 = this->pPlayerBuffs[PLAYER_BUFF_BLESS].uPower; //only player effect spell in both VI and VII break; case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: v3 = this->pPlayerBuffs[PLAYER_BUFF_HEROISM].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_HEROISM].uPower; break; case CHARACTER_ATTRIBUTE_STRENGTH: v3 = pPlayerBuffs[PLAYER_BUFF_STRENGTH].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; break; case CHARACTER_ATTRIBUTE_INTELLIGENCE: v3 = pPlayerBuffs[PLAYER_BUFF_INTELLIGENCE].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; break; case CHARACTER_ATTRIBUTE_WILLPOWER: v3 = pPlayerBuffs[PLAYER_BUFF_WILLPOWER].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; break; case CHARACTER_ATTRIBUTE_ENDURANCE: v3 = pPlayerBuffs[PLAYER_BUFF_ENDURANCE].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; break; case CHARACTER_ATTRIBUTE_ACCURACY: v3 = pPlayerBuffs[PLAYER_BUFF_ACCURACY].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; break; case CHARACTER_ATTRIBUTE_SPEED: v3 = pPlayerBuffs[PLAYER_BUFF_SPEED].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; break; case CHARACTER_ATTRIBUTE_LUCK: v3 = pPlayerBuffs[PLAYER_BUFF_LUCK].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; break; case CHARACTER_ATTRIBUTE_AC_BONUS: v3 = this->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uPower; v4 = pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].uPower; break; } return v3 + v4; } //----- (0048F882) -------------------------------------------------------- int Player::GetActualSkillLevel( PLAYER_SKILL_TYPE uSkillType ) { signed int bonus_value; // esi@1 unsigned __int16 skill_value; // ax@126 int result; // al@127 bonus_value = 0; switch (uSkillType) { case PLAYER_SKILL_MONSTER_ID: { if ( CheckHiredNPCSpeciality(Hunter) ) bonus_value = 6; if ( CheckHiredNPCSpeciality(Sage) ) bonus_value += 6; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID); } break; case PLAYER_SKILL_ARMSMASTER: { if ( CheckHiredNPCSpeciality(Armsmaster) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Weaponsmaster) ) bonus_value += 3; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER); } break; case PLAYER_SKILL_STEALING: { if (CheckHiredNPCSpeciality(Burglar)) bonus_value = 8; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING); } break; case PLAYER_SKILL_ALCHEMY: { if ( CheckHiredNPCSpeciality(Herbalist) ) bonus_value = 4; if ( CheckHiredNPCSpeciality(Apothecary) ) bonus_value += 8; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY); } break; case PLAYER_SKILL_LEARNING: { if ( CheckHiredNPCSpeciality(Teacher) ) bonus_value = 10; if ( CheckHiredNPCSpeciality(Instructor) ) bonus_value += 15; if ( CheckHiredNPCSpeciality(Scholar) ) bonus_value += 5; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING); } break; case PLAYER_SKILL_UNARMED: { if (CheckHiredNPCSpeciality(Monk) ) bonus_value = 2; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED); } break; case PLAYER_SKILL_DODGE: { if ( CheckHiredNPCSpeciality(Monk) ) bonus_value = 2; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE); } break; case PLAYER_SKILL_BOW: bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW); break; case PLAYER_SKILL_SHIELD: bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD); break; case PLAYER_SKILL_EARTH: if ( CheckHiredNPCSpeciality(Apprentice) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) bonus_value += 3; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH); break; case PLAYER_SKILL_FIRE: if ( CheckHiredNPCSpeciality(Apprentice) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) bonus_value += 3; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE); break; case PLAYER_SKILL_AIR: if ( CheckHiredNPCSpeciality(Apprentice) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) bonus_value += 3; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR); break; case PLAYER_SKILL_WATER: if ( CheckHiredNPCSpeciality(Apprentice) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) bonus_value += 3; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER); break; case PLAYER_SKILL_SPIRIT: if ( CheckHiredNPCSpeciality(Acolyte2) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Initiate) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Prelate) ) bonus_value += 4; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT); break; case PLAYER_SKILL_MIND: if ( CheckHiredNPCSpeciality(Acolyte2) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Initiate) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Prelate) ) bonus_value += 4; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND); break; case PLAYER_SKILL_BODY: if ( CheckHiredNPCSpeciality(Acolyte2) ) bonus_value = 2; if ( CheckHiredNPCSpeciality(Initiate) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Prelate) ) bonus_value += 4; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY); break; case PLAYER_SKILL_LIGHT: bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT); break; case PLAYER_SKILL_DARK: { bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK); } break; case PLAYER_SKILL_MERCHANT: { if ( CheckHiredNPCSpeciality(Trader) ) bonus_value = 4; if ( CheckHiredNPCSpeciality(Merchant) ) bonus_value += 6; if ( CheckHiredNPCSpeciality(Gypsy) ) bonus_value += 3; if ( CheckHiredNPCSpeciality(Duper) ) bonus_value += 8; } break; case PLAYER_SKILL_PERCEPTION: { if ( CheckHiredNPCSpeciality(Scout) ) bonus_value = 6; if ( CheckHiredNPCSpeciality(Psychic) ) bonus_value += 5; } break; case PLAYER_SKILL_ITEM_ID: bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID); break; case PLAYER_SKILL_MEDITATION: bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION); break; case PLAYER_SKILL_TRAP_DISARM: { if ( CheckHiredNPCSpeciality(Tinker) ) bonus_value = 4; if ( CheckHiredNPCSpeciality(Locksmith) ) bonus_value += 6; if ( CheckHiredNPCSpeciality(Burglar) ) bonus_value += 8; bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM); } break; } skill_value = pActiveSkills[uSkillType]; if ( bonus_value + (skill_value & 0x3F) < 60 ) result = bonus_value + skill_value; else result = skill_value & 0xFFFC | 0x3C; //al return result; } //----- (0048FC00) -------------------------------------------------------- int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill) //TODO: move the individual implementations to attribute classes once possible { int armsMasterBonus; armsMasterBonus = 0; int armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); if ( armmaster_skill > 0 ) { int multiplier = 0; if ( inSkill == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) { multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 0, 1, 2); } else if ( inSkill == CHARACTER_ATTRIBUTE_ATTACK ) { multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 1, 1, 2); } armsMasterBonus = multiplier * (armmaster_skill & 0x3F); } switch(inSkill) { case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: if (HasItemEquipped(EQUIP_BOW)) { int bowSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); int multiplier = GetMultiplierForSkillLevel(bowSkillLevel, 0, 0, 0, 1); return multiplier * (bowSkillLevel & 0x3F); } return 0; break; case CHARACTER_ATTRIBUTE_HEALTH: { int base_value = pBaseHealthPerLevelByClass[classType]; int attrib_modif = GetBodybuilding(); return base_value * attrib_modif; } break; case CHARACTER_ATTRIBUTE_MANA: { int base_value = pBaseManaPerLevelByClass[classType]; int attrib_modif = GetMeditation(); return base_value * attrib_modif; } break; case CHARACTER_ATTRIBUTE_AC_BONUS: { bool wearingArmor = false; bool wearingLeather = false; unsigned int ACSum = 0; for (int j = 0; j < 16; ++j) { ItemGen* currItem = GetNthEquippedIndexItem(j); if (currItem != nullptr && (!currItem->IsBroken())) { PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType(); int currArmorSkillLevel = GetActualSkillLevel(itemSkillType); int multiplier = 0; switch (itemSkillType) { case PLAYER_SKILL_STAFF: multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 1, 1, 1); break; case PLAYER_SKILL_SWORD: case PLAYER_SKILL_SPEAR: multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 0, 0, 1); break; case PLAYER_SKILL_SHIELD: wearingArmor = true; multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2); break; case PLAYER_SKILL_LEATHER: wearingLeather = true; multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2); break; case PLAYER_SKILL_CHAIN: wearingArmor = true; multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1); break; case PLAYER_SKILL_PLATE: wearingArmor = true; multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1); break; } ACSum += multiplier * (currArmorSkillLevel & 0x3F); } } int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); int dodgeMastery = SkillToMastery(dodgeSkillLevel); int multiplier = GetMultiplierForSkillLevel(dodgeSkillLevel, 1, 2, 3, 3); if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) ) { ACSum += multiplier * (dodgeSkillLevel & 0x3F); } return ACSum; } break; case CHARACTER_ATTRIBUTE_ATTACK: if ( this->IsUnarmed() ) { int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); if (!unarmedSkill) { return 0; } int multiplier = GetMultiplierForSkillLevel(unarmedSkill, 0, 1, 2, 2); return armsMasterBonus + multiplier * (unarmedSkill & 0x3F); } for (int i = 0; i < 16; ++i) { if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { ItemGen* currItem = GetNthEquippedIndexItem(i); if ( currItem->GetItemEquipType() <= EQUIP_MAIN_HAND) { PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType(); int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); if (currItemSkillType == PLAYER_SKILL_BLASTER) { int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5); return multiplier * (currentItemSkillLevel & 0x3F); } else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) { int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 2, 2); return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F); } else { return armsMasterBonus + (currentItemSkillLevel & 0x3F); } } } } return 0; break; case CHARACTER_ATTRIBUTE_RANGED_ATTACK: for (int i = 0; i < 16; i++) { if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(i)->GetPlayerSkillType(); int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); if ( currentItemSkillType == PLAYER_SKILL_BOW ) { int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1); return multiplier * (currentItemSkillLevel & 0x3F); } else if ( currentItemSkillType == PLAYER_SKILL_BLASTER ) { int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5); return multiplier * (currentItemSkillLevel & 0x3F); } } } return 0; break; case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: if ( this->IsUnarmed() ) { int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); if ( !unarmedSkillLevel ) { return 0; } int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2); return multiplier * (unarmedSkillLevel & 0x3F); } for (int i = 0; i < 16; i++) { if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { ItemGen* currItemPtr = GetNthEquippedIndexItem(i); if ( currItemPtr->GetItemEquipType() == EQUIP_MAIN_HAND || currItemPtr->GetItemEquipType() == EQUIP_OFF_HAND ) { PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItemPtr->GetPlayerSkillType(); int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); int baseSkillBonus; int multiplier; switch (currItemSkillType) { case PLAYER_SKILL_STAFF: if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) { int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2); return multiplier * (unarmedSkillLevel & 0x3F); } else { return armsMasterBonus; } break; case PLAYER_SKILL_DAGGER: multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 1); baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); return armsMasterBonus + baseSkillBonus; break; case PLAYER_SKILL_SWORD: multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 0); baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); return armsMasterBonus + baseSkillBonus; break; case PLAYER_SKILL_MACE: case PLAYER_SKILL_SPEAR: multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 1, 1, 1); baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); return armsMasterBonus + baseSkillBonus; break; case PLAYER_SKILL_AXE: multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 1, 1); baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); return armsMasterBonus + baseSkillBonus; break; } } } } return 0; break; default: return 0; } } unsigned int Player::GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4) { int masteryLvl = SkillToMastery(skillValue); switch (masteryLvl) { case 1: return mult1; case 2: return mult2; case 3: return mult3; case 4: return mult4; } Error("(%u)", masteryLvl); return 0; } //----- (00490109) -------------------------------------------------------- // faces are: 0 1 2 3 human males // 4 5 6 7 human females // 8 9 elf males // 10 11 elf females // 12 13 dwarf males // 14 15 dwarf females // 16 17 goblin males // 18 19 goblin females // 20 lich male // 21 lich female // 22 underwater suits (unused) // 23 zombie male // 24 zombie female enum CHARACTER_RACE Player::GetRace() { if ( uCurrentFace <= 7 ) { return CHARACTER_RACE_HUMAN; } else if ( uCurrentFace <= 11 ) { return CHARACTER_RACE_ELF; } else if ( uCurrentFace <= 15 ) { return CHARACTER_RACE_DWARF; } else if ( uCurrentFace <= 19 ) { return CHARACTER_RACE_GOBLIN; } else { return CHARACTER_RACE_HUMAN; } } //----- (00490141) -------------------------------------------------------- PLAYER_SEX Player::GetSexByVoice() { switch ( this->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: return SEX_MALE; case 4u: case 5u: case 6u: case 7u: case 0xAu: case 0xBu: case 0xEu: case 0xFu: case 0x12u: case 0x13u: case 0x15u: case 0x18u: return SEX_FEMALE; } Error("(%u)", this->uVoiceID); return SEX_MALE; } //----- (00490188) -------------------------------------------------------- void Player::SetInitialStats() { auto v1 = GetRace(); uMight = StatTable[v1][0].uBaseValue; uIntelligence = StatTable[v1][1].uBaseValue; uWillpower = StatTable[v1][2].uBaseValue; uEndurance = StatTable[v1][3].uBaseValue; uAccuracy = StatTable[v1][4].uBaseValue; uSpeed = StatTable[v1][5].uBaseValue; uLuck = StatTable[v1][6].uBaseValue; } //----- (004901FC) -------------------------------------------------------- void Player::SetSexByVoice() { switch ( this->uVoiceID) { case 0: case 1: case 2: case 3: case 8: case 9: case 0xC: case 0xD: case 0x10: case 0x11: case 0x14: case 0x17: this->uSex = SEX_MALE; break; case 4: case 5: case 6: case 7: case 0xA: case 0xB: case 0xE: case 0xF: case 0x12: case 0x13: case 0x15: case 0x18: this->uSex = SEX_FEMALE; break; default: Error("(%u)", this->uVoiceID); break; } } //----- (0049024A) -------------------------------------------------------- void Player::Reset(PLAYER_CLASS_TYPE cls) { sLevelModifier = 0; sAgeModifier = 0; classType = cls; uLuckBonus = 0; uSpeedBonus = 0; uAccuracyBonus = 0; uEnduranceBonus = 0; uWillpowerBonus = 0; uIntelligenceBonus = 0; uMightBonus = 0; uLevel = 1; uExperience = 251 + rand() % 100; uBirthYear = 1147 - rand() % 6; memset(pActiveSkills, 0, sizeof(pActiveSkills)); memset(_achieved_awards_bits, 0, 64); memset(&spellbook, 0, sizeof(PlayerSpells)); for (uint i = 0; i < 37; ++i) { if (pSkillAvailabilityPerClass[classType / 4][i] != 2) continue; pActiveSkills[i] = 1; switch (i) { case PLAYER_SKILL_FIRE: spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;//its temporary, for test spells extern bool all_magic; if ( all_magic == true ) { pActiveSkills[PLAYER_SKILL_AIR] = 1; pActiveSkills[PLAYER_SKILL_WATER] = 1; pActiveSkills[PLAYER_SKILL_EARTH] = 1; spellbook.pFireSpellbook.bIsSpellAvailable[1] = true; spellbook.pFireSpellbook.bIsSpellAvailable[2] = true; spellbook.pFireSpellbook.bIsSpellAvailable[3] = true; spellbook.pFireSpellbook.bIsSpellAvailable[4] = true; spellbook.pFireSpellbook.bIsSpellAvailable[5] = true; spellbook.pFireSpellbook.bIsSpellAvailable[6] = true; spellbook.pFireSpellbook.bIsSpellAvailable[7] = true; spellbook.pFireSpellbook.bIsSpellAvailable[8] = true; spellbook.pFireSpellbook.bIsSpellAvailable[9] = true; spellbook.pFireSpellbook.bIsSpellAvailable[10] = true; spellbook.pAirSpellbook.bIsSpellAvailable[0] = true; spellbook.pAirSpellbook.bIsSpellAvailable[1] = true; spellbook.pAirSpellbook.bIsSpellAvailable[2] = true; spellbook.pAirSpellbook.bIsSpellAvailable[3] = true; spellbook.pAirSpellbook.bIsSpellAvailable[4] = true; spellbook.pAirSpellbook.bIsSpellAvailable[5] = true; spellbook.pAirSpellbook.bIsSpellAvailable[6] = true; spellbook.pAirSpellbook.bIsSpellAvailable[7] = true; spellbook.pAirSpellbook.bIsSpellAvailable[8] = true; spellbook.pAirSpellbook.bIsSpellAvailable[9] = true; spellbook.pAirSpellbook.bIsSpellAvailable[10] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[1] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[2] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[3] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[4] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[5] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[6] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[7] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[8] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[9] = true; spellbook.pWaterSpellbook.bIsSpellAvailable[10] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[1] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[2] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[3] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[4] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[5] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[6] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[7] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[8] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[9] = true; spellbook.pEarthSpellbook.bIsSpellAvailable[10] = true; } break; case PLAYER_SKILL_AIR: spellbook.pAirSpellbook.bIsSpellAvailable[0] = true; break; case PLAYER_SKILL_WATER: spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true; break; case PLAYER_SKILL_EARTH: spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true; break; case PLAYER_SKILL_SPIRIT: spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; break; case PLAYER_SKILL_MIND: spellbook.pMindSpellbook.bIsSpellAvailable[0] = true; break; case PLAYER_SKILL_BODY: spellbook.pBodySpellbook.bIsSpellAvailable[0] = true; if ( all_magic == true ) { pActiveSkills[PLAYER_SKILL_MIND] = 1; pActiveSkills[PLAYER_SKILL_SPIRIT] = 1; spellbook.pBodySpellbook.bIsSpellAvailable[1] = true; spellbook.pBodySpellbook.bIsSpellAvailable[2] = true; spellbook.pBodySpellbook.bIsSpellAvailable[3] = true; spellbook.pBodySpellbook.bIsSpellAvailable[4] = true; spellbook.pBodySpellbook.bIsSpellAvailable[5] = true; spellbook.pBodySpellbook.bIsSpellAvailable[6] = true; spellbook.pBodySpellbook.bIsSpellAvailable[7] = true; spellbook.pBodySpellbook.bIsSpellAvailable[8] = true; spellbook.pBodySpellbook.bIsSpellAvailable[9] = true; spellbook.pBodySpellbook.bIsSpellAvailable[10] = true; spellbook.pMindSpellbook.bIsSpellAvailable[0] = true; spellbook.pMindSpellbook.bIsSpellAvailable[1] = true; spellbook.pMindSpellbook.bIsSpellAvailable[2] = true; spellbook.pMindSpellbook.bIsSpellAvailable[3] = true; spellbook.pMindSpellbook.bIsSpellAvailable[4] = true; spellbook.pMindSpellbook.bIsSpellAvailable[5] = true; spellbook.pMindSpellbook.bIsSpellAvailable[6] = true; spellbook.pMindSpellbook.bIsSpellAvailable[7] = true; spellbook.pMindSpellbook.bIsSpellAvailable[8] = true; spellbook.pMindSpellbook.bIsSpellAvailable[9] = true; spellbook.pMindSpellbook.bIsSpellAvailable[10] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[1] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[2] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[3] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[4] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[5] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[6] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[7] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[8] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[9] = true; spellbook.pSpiritSpellbook.bIsSpellAvailable[10] = true; } break; case PLAYER_SKILL_LIGHT: spellbook.pLightSpellbook.bIsSpellAvailable[0] = true; break; case PLAYER_SKILL_DARK: spellbook.pDarkSpellbook.bIsSpellAvailable[0] = true; break; } } sHealth = GetMaxHealth(); sMana = GetMaxMana(); } //----- (004903C9) -------------------------------------------------------- PLAYER_SKILL_TYPE Player::GetSkillIdxByOrder(signed int order) { int counter; // edx@5 bool canBeInactive; unsigned char requiredValue; signed int offset; if ( order <= 1 ) { canBeInactive = false; requiredValue = 2; // 2 - primary skill offset = 0; } else if ( order <= 3 ) { canBeInactive = false; requiredValue = 1; // 1 - available offset = 2; } else if ( order <= 12 ) { canBeInactive = true; requiredValue = 1; // 1 - available offset = 4; } else { return (PLAYER_SKILL_TYPE)37; } counter = 0; for (int i = 0; i < 37; i++) { if ( (this->pActiveSkills[i] || canBeInactive) && pSkillAvailabilityPerClass[classType / 4][i] == requiredValue ) { if ( counter == order - offset ) return (PLAYER_SKILL_TYPE)i; ++counter; } } return (PLAYER_SKILL_TYPE)37; } //----- (0049048D) -------------------------------------------------------- //unsigned __int16 PartyCreation_BtnMinusClick(Player *_this, int eAttribute) void Player::DecreaseAttribute(int eAttribute) { int pBaseValue; // ecx@1 int pDroppedStep; // ebx@1 int pStep; // esi@1 int uMinValue; // [sp+Ch] [bp-4h]@1 int raceId = GetRace(); pBaseValue = StatTable[raceId][eAttribute].uBaseValue; pDroppedStep = StatTable[raceId][eAttribute].uDroppedStep; uMinValue = pBaseValue - 2; pStep = StatTable[raceId][eAttribute].uBaseStep; unsigned short* AttrToChange = nullptr; switch ( eAttribute ) { case CHARACTER_ATTRIBUTE_STRENGTH: AttrToChange = &this->uMight; break; case CHARACTER_ATTRIBUTE_INTELLIGENCE: AttrToChange = &this->uIntelligence; break; case CHARACTER_ATTRIBUTE_WILLPOWER: AttrToChange = &this->uWillpower; break; case CHARACTER_ATTRIBUTE_ENDURANCE: AttrToChange = &this->uEndurance; break; case CHARACTER_ATTRIBUTE_ACCURACY: AttrToChange = &this->uAccuracy; break; case CHARACTER_ATTRIBUTE_SPEED: AttrToChange = &this->uSpeed; break; case CHARACTER_ATTRIBUTE_LUCK: AttrToChange = &this->uLuck; break; } if ( *AttrToChange <= pBaseValue ) pStep = pDroppedStep; if ( *AttrToChange - pStep >= uMinValue ) *AttrToChange -= pStep; } //----- (004905F5) -------------------------------------------------------- //signed int PartyCreation_BtnPlusClick(Player *this, int eAttribute) void Player::IncreaseAttribute( int eAttribute ) { int raceId; // eax@1 int maxValue; // ebx@1 signed int baseStep; // edi@1 signed int tmp; // eax@17 signed int result; // eax@18 int baseValue; // [sp+Ch] [bp-8h]@1 signed int droppedStep; // [sp+10h] [bp-4h]@1 unsigned short* statToChange; raceId = GetRace(); maxValue = StatTable[raceId][eAttribute].uMaxValue; baseStep = StatTable[raceId][eAttribute].uBaseStep; baseValue = StatTable[raceId][eAttribute].uBaseValue; droppedStep = StatTable[raceId][eAttribute].uDroppedStep; PlayerCreation_GetUnspentAttributePointCount(); switch ( eAttribute ) { case 0: statToChange = &this->uMight; break; case 1: statToChange = &this->uIntelligence; break; case 2: statToChange = &this->uWillpower; break; case 3: statToChange = &this->uEndurance; break; case 4: statToChange = &this->uAccuracy; break; case 5: statToChange = &this->uSpeed; break; case 6: statToChange = &this->uLuck; default: Error("(%u)", eAttribute); } if ( *statToChange < baseValue ) { tmp = baseStep; baseStep = droppedStep; droppedStep = tmp; } result = PlayerCreation_GetUnspentAttributePointCount(); if ( result >= droppedStep ) { if ( baseStep + *statToChange <= maxValue ) *statToChange += baseStep; } } //----- (0049070F) -------------------------------------------------------- void Player::Zero() { this->sLevelModifier = 0; this->sACModifier = 0; this->uLuckBonus = 0; this->uAccuracyBonus = 0; this->uSpeedBonus = 0; this->uEnduranceBonus = 0; this->uWillpowerBonus = 0; this->uIntelligenceBonus = 0; this->uMightBonus = 0; this->field_100 = 0; this->field_FC = 0; this->field_F8 = 0; this->field_F4 = 0; this->field_F0 = 0; this->field_EC = 0; this->field_E8 = 0; this->field_E4 = 0; this->field_E0 = 0; memset(&this->sResFireBonus, 0, 0x16u); this->field_1A97 = 0; this->_ranged_dmg_bonus = 0; this->field_1A95 = 0; this->_ranged_atk_bonus = 0; this->field_1A93 = 0; this->_melee_dmg_bonus = 0; this->field_1A91 = 0; this->_some_attack_bonus = 0; this->_mana_related = 0; this->uFullManaBonus = 0; this->_health_related = 0; this->uFullHealthBonus = 0; } //----- (004907E7) -------------------------------------------------------- unsigned int Player::GetStatColor(int uStat) { int attribute_value; // edx@1 int base_attribute_value = StatTable[GetRace()][uStat].uBaseValue; switch (uStat) { case 0: attribute_value = uMight; break; case 1: attribute_value = uIntelligence; break; case 2: attribute_value = uWillpower; break; case 3: attribute_value = uEndurance; break; case 4: attribute_value = uAccuracy; break; case 5: attribute_value = uSpeed; break; case 6: attribute_value = uLuck; break; }; if (attribute_value == base_attribute_value) return ui_character_stat_default_color; else if (attribute_value > base_attribute_value) return ui_character_stat_buffed_color; else return ui_character_stat_debuffed_color; } //----- (004908A8) -------------------------------------------------------- bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime) { if ( pConditions[uCondition] && (uTime < (signed long long)pConditions[uCondition]) ) { pConditions[uCondition] = 0i64; return true; } else return false; } //----- (004680ED) -------------------------------------------------------- void Player::UseItem_DrinkPotion_etc(signed int player_num, int a3) { Player *playerAffected; // esi@1 signed int v5; // eax@17 int v8; // edx@39 char *v13; // eax@45 signed int v15; // edi@68 int v16; // edx@73 unsigned __int16 v17; // edi@73 unsigned int v18; // eax@73 const char *v22; // eax@84 int scroll_id; // esi@96 int v25; // eax@109 int v26; // eax@113 int new_mana_val; // edi@114 signed __int64 v28; // qax@120 __int64 v30; // edi@137 __int64 v32; // ST3C_4@137 __int64 v34; // ST34_4@137 unsigned __int16 v50; // [sp-Ch] [bp-38h]@120 const char *v66; // [sp-4h] [bp-30h]@69 signed int v67; // [sp-4h] [bp-30h]@77 const char *v68; // [sp-4h] [bp-30h]@89 char v72; // [sp+20h] [bp-Ch]@68 signed int v73; // [sp+24h] [bp-8h]@1 char* v74; // [sp+24h] [bp-8h]@23 Player *thisb; // [sp+28h] [bp-4h]@1 unsigned int thisa; // [sp+28h] [bp-4h]@22 thisb = this; playerAffected = &pParty->pPlayers[player_num-1]; v73 = 1; if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) ) return; if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_REAGENT ) { if ( pParty->pPickedItem.uItemID == 160 ) { playerAffected->SetCondition(Condition_Poison1, 1); } else if ( pParty->pPickedItem.uItemID == 161 ) { new_mana_val = playerAffected->sMana; new_mana_val += 2; if ( new_mana_val > playerAffected->GetMaxMana() ) new_mana_val = playerAffected->GetMaxMana(); playerAffected->PlaySound(SPEECH_36, 0); } else if ( pParty->pPickedItem.uItemID == 162 ) { playerAffected->Heal(2); playerAffected->PlaySound(SPEECH_36, 0); } else { v68 = pParty->pPickedItem.GetDisplayName(); sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" ShowStatusBarString(pTmpBuf.data(), 2); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } pAudioPlayer->PlaySound((SoundID)211, 0, 0, -1, 0, 0, 0, 0); if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) { pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } if ( v73 ) { if ( pParty->bTurnBasedModeOn ) { pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; thisb->SetRecoveryTime(100); pTurnEngine->ApplyPlayerAction(); } else { thisb->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); } } pMouse->RemoveHoldingItem(); return; } if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_POTION ) { switch ( pParty->pPickedItem.uItemID ) { case 221: //Catalyst playerAffected->SetCondition(Condition_Poison1, 1); break; case 222: //Cure Wounds v25 = pParty->pPickedItem.uEnchantmentType + 10; playerAffected->Heal(v25); playerAffected->PlaySound(SPEECH_36, 0); break; case 223: //Magic Potion v26 = pParty->pPickedItem.uEnchantmentType + 10; new_mana_val = playerAffected->sMana; new_mana_val += v26; if ( new_mana_val > playerAffected->GetMaxMana() ) new_mana_val = playerAffected->GetMaxMana(); playerAffected->PlaySound(SPEECH_36, 0); break; case 224: //Cure Weakness playerAffected->pConditions[Condition_Weak] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 225: //Cure Disease playerAffected->pConditions[Condition_Disease3] = 0i64; playerAffected->pConditions[Condition_Disease2] = 0i64; playerAffected->pConditions[Condition_Disease1] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 226: //Cure Poison playerAffected->pConditions[Condition_Poison3] = 0i64; playerAffected->pConditions[Condition_Poison2] = 0i64; playerAffected->pConditions[Condition_Poison1] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 227: //Awaken playerAffected->pConditions[Condition_Sleep] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 228: //Haste 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->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->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->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->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->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->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); break; case 237: //Remove Fear playerAffected->pConditions[Condition_Fear] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 238: //Remove Curse playerAffected->pConditions[Condition_Cursed] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 239: //Cure Insanity playerAffected->pConditions[Condition_Insane] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; 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->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->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->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->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->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->PlaySound(SPEECH_36, 0); break; case 251: //Cure Paralysis playerAffected->pConditions[Condition_Paralyzed] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 252://Divine Restoration v30 = playerAffected->pConditions[Condition_Dead]; v32 = playerAffected->pConditions[Condition_Pertified]; v34 = playerAffected->pConditions[Condition_Eradicated]; memset(&playerAffected->pConditions,0,sizeof(pConditions)); playerAffected->pConditions[Condition_Dead] = v30; playerAffected->pConditions[Condition_Pertified] = v32; playerAffected->pConditions[Condition_Eradicated] = v34; playerAffected->PlaySound(SPEECH_36, 0); break; case 253: //Divine Cure v25 = 5 * pParty->pPickedItem.uEnchantmentType; playerAffected->Heal(v25); playerAffected->PlaySound(SPEECH_36, 0); break; case 254: //Divine Power v26 = 5 * pParty->pPickedItem.uEnchantmentType; new_mana_val = playerAffected->sMana; new_mana_val += v26; if ( new_mana_val > playerAffected->GetMaxMana() ) new_mana_val = playerAffected->GetMaxMana(); playerAffected->PlaySound(SPEECH_36, 0); break; 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->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->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->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->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->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->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->PlaySound(SPEECH_36, 0); break; case 262: //Stone to Flesh playerAffected->pConditions[Condition_Pertified] = 0i64; playerAffected->PlaySound(SPEECH_36, 0); break; case 264: //Pure Luck if ( !playerAffected->pure_luck_used ) { playerAffected->uLuck += 50; playerAffected->pure_luck_used = 1; } playerAffected->PlaySound(SPEECH_36, 0); break; case 265: //Pure Speed if ( !playerAffected->pure_speed_used ) { playerAffected->uSpeed += 50; playerAffected->pure_speed_used = 1; } playerAffected->PlaySound(SPEECH_36, 0); break; case 266: //Pure Intellect if ( !playerAffected->pure_intellect_used ) { playerAffected->uIntelligence += 50; playerAffected->pure_intellect_used = 1; } playerAffected->PlaySound(SPEECH_36, 0); break; case 267: //Pure Endurance if ( !playerAffected->pure_endurance_used ) { playerAffected->uEndurance += 50; playerAffected->pure_endurance_used = 1; } playerAffected->PlaySound(SPEECH_36, 0); break; case 268: //Pure Personality if ( !playerAffected->pure_willpower_used ) { playerAffected->uWillpower += 50; playerAffected->pure_willpower_used = 1; } playerAffected->PlaySound(SPEECH_36, 0); break; case 269: //Pure Accuracy if ( !playerAffected->pure_accuracy_used ) { playerAffected->uAccuracy += 50; playerAffected->pure_accuracy_used = 1; } playerAffected->PlaySound(SPEECH_36, 0); break; case 270: //Pure Might if ( !playerAffected->pure_might_used ) { playerAffected->uMight += 50; playerAffected->pure_might_used = 1; } playerAffected->PlaySound(SPEECH_36, 0); break; case 271: //Rejuvenation playerAffected->sAgeModifier = 0; playerAffected->PlaySound(SPEECH_36, 0); break; default: v68 = pParty->pPickedItem.GetDisplayName(); sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } pAudioPlayer->PlaySound((SoundID)210, 0, 0, -1, 0, 0, 0, 0); if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) { // if ( !v73 ) v73 is always 1 at this point // { // pMouse->RemoveHoldingItem(); // return; // } pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } if ( v73 ) { if ( pParty->bTurnBasedModeOn ) { pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; thisb->SetRecoveryTime(100); pTurnEngine->ApplyPlayerAction(); } else { thisb->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); } } pMouse->RemoveHoldingItem(); return; } if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_SPELL_SCROLL ) { if ( pCurrentScreen == SCREEN_CASTING ) return; if ( !playerAffected->CanAct() ) { v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68); ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } if ( bUnderwater == 1 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!" pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } dword_50C9AC = 1; scroll_id = pParty->pPickedItem.uItemID - 299; if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura { pMouse->RemoveHoldingItem(); pGUIWindow_CurrentMenu->Release(); pIcons_LOD->RemoveTexturesPackFromTextureList(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0); } else { _720984_unused = pParty->pPickedItem.uItemID; pMouse->RemoveHoldingItem(); pMessageQueue_50C9E8->AddMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1); if ( pCurrentScreen && pGUIWindow_CurrentMenu && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)) { pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } } return; } if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_BOOK ) { v15 = pParty->pPickedItem.uItemID - 400; v72 = playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2; if ( v72 ) { v66 = pParty->pPickedItem.GetDisplayName(); sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell" ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } if ( !playerAffected->CanAct() ) { v66 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s" ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } v16 = v15 % 11 + 1; v17 = playerAffected->pActiveSkills[v15 / 11 + 12]; v18 = SkillToMastery(v17) - 1; switch (v18) { case 0: v67 = 4; break; case 1: v67 = 7; break; case 2: v67 = 10; break; case 3: v67 = 11; break; default: v67 = player_num; } if ( v16 > v67 || !v17 ) { v22 = pParty->pPickedItem.GetDisplayName(); sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s" ShowStatusBarString(pTmpBuf.data(), 2u); playerAffected->PlaySound((PlayerSpeech)20, 0); return; } // v72 = 1; playerAffected->PlaySound(SPEECH_21, 0); v73 = 0; if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) { if ( !v73 ) { pMouse->RemoveHoldingItem(); return; } pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } // if ( v73 ) v73 is always 0 at this point // { // if ( pParty->bTurnBasedModeOn ) // { // pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; // thisb->SetRecoveryTime(100); // pTurnEngine->ApplyPlayerAction(); // } // else // { // thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333); // } // } pMouse->RemoveHoldingItem(); return; } if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_MESSAGE_SCROLL ) { if ( playerAffected->CanAct() ) { CreateMsgScrollWindow(pParty->pPickedItem.uItemID); playerAffected->PlaySound(SPEECH_37, 0); return; } v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68); ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } else { if (pParty->pPickedItem.uItemID == 616) //Genie Lamp { thisa = pParty->uCurrentMonthWeek + 1; if ( pParty->uCurrentMonth >= 7 ) v74 = NULL; else v74 = aAttributeNames[pParty->uCurrentMonth]; switch ( pParty->uCurrentMonth ) { case 0: playerAffected->uMight += thisa; sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 1: playerAffected->uIntelligence += thisa; sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 2: playerAffected->uWillpower += thisa; sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 3: playerAffected->uEndurance += thisa; sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 4: playerAffected->uAccuracy += thisa; sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 5: playerAffected->uSpeed += thisa; sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 6: playerAffected->uLuck += thisa; sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 7: party_finds_gold(1000 * thisa, 0); sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold" break; case 8: Party::GiveFood(5 * thisa); sprintf(pTmpBuf.data(), "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food" break; case 9u: playerAffected->uSkillPoints += 2 * thisa; sprintf(pTmpBuf.data(), "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]); break; case 10: playerAffected->uExperience += 2500 * thisa; sprintf(pTmpBuf.data(), "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]); break; case 11: v8 = rand() % 6; switch (v8) { case 0: playerAffected->sResFireBase += thisa; v13 = pGlobalTXT_LocalizationStrings[87]; break; case 1: playerAffected->sResAirBase += thisa; v13 = pGlobalTXT_LocalizationStrings[6]; break; case 2: playerAffected->sResWaterBase += thisa; v13 = pGlobalTXT_LocalizationStrings[240]; break; case 3: playerAffected->sResEarthBase += thisa; v13 = pGlobalTXT_LocalizationStrings[70]; break; case 4: playerAffected->sResMindBase += thisa; v13 = pGlobalTXT_LocalizationStrings[142]; break; case 5: playerAffected->sResBodyBase += thisa; v13 = pGlobalTXT_LocalizationStrings[29]; break; } sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]); break; } ShowStatusBarString(pTmpBuf.data(), 2u); pMouse->RemoveHoldingItem(); pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); playerAffected->PlaySound(SPEECH_93, 0); pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 ) { playerAffected->SetCondition(Condition_Eradicated, 0); pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); } else if ( pParty->uDaysPlayed == 12 || pParty->uDaysPlayed == 26 ) { playerAffected->SetCondition(Condition_Dead, 0); pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); } else if ( pParty->uDaysPlayed == 4 || pParty->uDaysPlayed == 25 ) { playerAffected->SetCondition(Condition_Pertified, 0); pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); } return; } else if ( pParty->pPickedItem.uItemID == 630 ) //Red Apple { Party::GiveFood(1u); pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0); } else if ( pParty->pPickedItem.uItemID == 632 ) //Lute { pAudioPlayer->PlaySound(SOUND_PlayLute, 0, 0, -1, 0, 0, 0, 0); return; } else if ( pParty->pPickedItem.uItemID == 633 ) //Faerie Pipes { pAudioPlayer->PlaySound(SOUND_PlayFaeriePipes, 0, 0, -1, 0, 0, 0, 0); return; } else if ( pParty->pPickedItem.uItemID == 634 ) //Gryphonheart's Trumpet { pAudioPlayer->PlaySound(SOUND_PlayGryphonheartsTrumpet, 0, 0, -1, 0, 0, 0, 0); return; } else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe { pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); v5 = PID(OBJECT_Player, player_num + 49); pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0); playerAffected->AddVariable(VAR_NumSkillPoints, 2); } else if ( pParty->pPickedItem.uItemID == 650 ) //Temple in a Bottle { TeleportToNWCDungeon(); return; } else { v68 = pParty->pPickedItem.GetDisplayName(); sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way" ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } pMouse->RemoveHoldingItem(); return; } } bool CmpSkillValue(int valToCompare, int skillValue) { int v4; if ( valToCompare <= 63 ) v4 = skillValue & 0x3F; else v4 = valToCompare & skillValue; return v4 >= valToCompare; } //----- (00449BB4) -------------------------------------------------------- bool Player::CompareVariable( enum VariableType VarNum, signed int pValue ) // in some cases this calls only calls v4 >= pValue, which i've changed to return false, since these values are supposed to be positive and v4 was -1 by default { Assert(pValue >= 0, "Compare variable shouldn't have negative arguments"); signed int v4; // edi@1 unsigned __int8 test_bit_value; // eax@25 unsigned __int8 byteWithRequestedBit; // cl@25 DDM_DLV_Header *v19; // eax@122 DDM_DLV_Header *v21; // eax@126 int actStat; // ebx@161 int baseStat; // eax@161 if ( VarNum > VAR_AutoNotes ) { switch ( VarNum ) { case VAR_AutoNotes : //TODO: find out why the double subtraction. or whether this is even used test_bit_value = 0x80u >> (pValue - 2) % 8; byteWithRequestedBit = pParty->_autonote_bits[(pValue - 2) /8]; return (test_bit_value & byteWithRequestedBit) != 0; case VAR_IsMightMoreThanBase: actStat = GetActualMight(); baseStat = GetBaseStrength(); return (actStat >= baseStat); case VAR_IsIntellectMoreThanBase: actStat = GetActualIntelligence(); baseStat = GetBaseIntelligence(); return (actStat >= baseStat); case VAR_IsPersonalityMoreThanBase: actStat = GetActualWillpower(); baseStat = GetBaseWillpower(); return (actStat >= baseStat); case VAR_IsEnduranceMoreThanBase: actStat = GetActualEndurance(); baseStat = GetBaseEndurance(); return (actStat >= baseStat); case VAR_IsSpeedMoreThanBase: actStat = GetActualSpeed(); baseStat = GetBaseSpeed(); return (actStat >= baseStat); case VAR_IsAccuracyMoreThanBase: actStat = GetActualAccuracy(); baseStat = GetBaseAccuracy(); return (actStat >= baseStat); case VAR_IsLuckMoreThanBase: actStat = GetActualLuck(); baseStat = GetBaseLuck(); return (actStat >= baseStat); case VAR_PlayerBits: test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; byteWithRequestedBit = this->field_1A50[((signed __int16)pValue - 1)/8]; return ( test_bit_value & byteWithRequestedBit ) != 0; case VAR_NPCs2: return pNPCStats->pNewNPCData[pValue].Hired(); case VAR_IsFlying: if ( pParty->bFlying && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) ) return true; return false; case VAR_HiredNPCHasSpeciality: return CheckHiredNPCSpeciality(pValue); case VAR_CircusPrises: //isn't used in MM6 since 0x1D6u is a book of regeneration v4 = 0; for (int playerNum = 0; playerNum < 4; playerNum++) { for (int invPos = 0; invPos < 138; invPos++) { int itemId = pParty->pPlayers[playerNum].pInventoryItemList[invPos].uItemID; switch ( itemId ) { case 0x1D6u: ++v4; break; case 0x1D7u: v4 += 3; break; case 0x1DDu: v4 += 5; break; } } } return v4 >= pValue; case VAR_NumSkillPoints: return this->uSkillPoints >= (unsigned int)pValue; case VAR_MonthIs: return (pParty->uCurrentMonth == (unsigned int)pValue); case VAR_Counter1: case VAR_Counter2: case VAR_Counter3: case VAR_Counter4: case VAR_Counter5: case VAR_Counter6: case VAR_Counter7: case VAR_Counter8: case VAR_Counter9: case VAR_Counter10: if (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1]) //originally (signed __int64)(__PAIR__(*(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44304], *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44300]) { return (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1] + 460800 * pValue * 0.033333335) <= pParty->uTimePlayed ; } case VAR_ReputationInCurrentLocation: v19 = &pOutdoor->ddm; if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) v19 = &pIndoor->dlv; return (v19->uReputation >= pValue); case VAR_Unknown1: v21 = &pOutdoor->ddm; if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) v21 = &pIndoor->dlv; return (v21->field_C_alert == pValue); //yes, equality, not >= case VAR_GoldInBank: return pParty->uNumGoldInBank >= (unsigned int)pValue; case VAR_NumDeaths: return pParty->uNumDeaths >= (unsigned int)pValue; case VAR_NumBounties: return pParty->uNumBountiesCollected >= (unsigned int)pValue; case VAR_PrisonTerms: return pParty->uNumPrisonTerms >= pValue; case VAR_ArenaWinsPage: return (unsigned __int8)pParty->uNumArenaPageWins >= pValue; case VAR_ArenaWinsSquire: return (unsigned __int8)pParty->uNumArenaSquireWins >= pValue; case VAR_ArenaWinsKnight: return (unsigned __int8)pParty->uNumArenaKnightWins >= pValue; case VAR_ArenaWinsLord: return pParty->uNumArenaLordWins >= pValue; case VAR_Invisible: return ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ); case VAR_ItemEquipped: for (int i = 0; i < 16; i++) { if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uItemID == pValue ) { return true; } } return false; default: return false; } } if ( VarNum <= VAR_MajorCondition ) { switch ( VarNum ) { case VAR_Sex: return ( pValue == this->uSex ); case VAR_Class: return ( pValue == this->classType ); case VAR_Race: return pValue == GetRace(); case VAR_CurrentHP: return this->sHealth >= pValue; case VAR_MaxHP: return (this->sHealth >= GetMaxHealth()); case VAR_CurrentSP: return this->sMana >= pValue; case VAR_MaxSP: return (this->sMana >= GetMaxMana()); case VAR_ActualAC: return GetActualAC() >= pValue; case VAR_ACModifier: return this->sACModifier >= pValue; case VAR_BaseLevel: return this->uLevel >= pValue; case VAR_LevelModifier: return this->sLevelModifier >= pValue; case VAR_Age: return GetActualAge() >= (unsigned int)pValue; case VAR_Award: test_bit_value = 0x80u >> (pValue - 1) % 8; byteWithRequestedBit = this->_achieved_awards_bits[(pValue - 1) /8]; return ( test_bit_value & byteWithRequestedBit ) != 0; case VAR_Experience: return this->uExperience >= pValue; //TODO change pValue to long long case VAR_QBits_QuestsDone: test_bit_value = 0x80u >> (pValue - 1) % 8; byteWithRequestedBit = pParty->_quest_bits[(pValue - 1)/8]; return ( test_bit_value & byteWithRequestedBit ) != 0; case VAR_PlayerItemInHands: for (int i = 0; i < 138; i++) { if (pInventoryItemList[i].uItemID == pValue) { return true; } } return pParty->pPickedItem.uItemID == pValue; case VAR_Hour: if ( (long long)(pParty->uTimePlayed * 0.234375) / 60 / 60 % 24 == pValue ) return true; return false; case VAR_DayOfYear: if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 336 + 1 == pValue) return true; return false; case VAR_DayOfWeek: if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 7) return true; return false; case VAR_FixedGold: return pParty->uNumGold >= (unsigned int)pValue; case VAR_FixedFood: return pParty->uNumFoodRations >= (unsigned int)pValue; case VAR_MightBonus: return this->uMightBonus >= pValue; case VAR_IntellectBonus: return this->uIntelligenceBonus >= pValue; case VAR_PersonalityBonus: return this->uWillpowerBonus >= pValue; case VAR_EnduranceBonus: return this->uEnduranceBonus >= pValue; case VAR_SpeedBonus: return this->uSpeedBonus >= pValue; case VAR_AccuracyBonus: return this->uAccuracyBonus >= pValue; case VAR_LuckBonus: return this->uLuckBonus >= pValue; case VAR_BaseMight: return this->uMight >= pValue; case VAR_BaseIntellect: return this->uIntelligence >= pValue; case VAR_BasePersonality: return this->uWillpower >= pValue; case VAR_BaseEndurance: return this->uEndurance >= pValue; case VAR_BaseSpeed: return this->uSpeed >= pValue; case VAR_BaseAccuracy: return this->uAccuracy >= pValue; case VAR_BaseLuck: return this->uLuck >= pValue; case VAR_ActualMight: return GetActualMight() >= pValue; case VAR_ActualIntellect: return GetActualIntelligence() >= pValue; case VAR_ActualPersonality: return GetActualWillpower() >= pValue; case VAR_ActualEndurance: return GetActualEndurance() >= pValue; case VAR_ActualSpeed: return GetActualSpeed() >= pValue; case VAR_ActualAccuracy: return GetActualAccuracy() >= pValue; case VAR_ActualLuck: return GetActualLuck() >= pValue; case VAR_FireResistance: return this->sResFireBase >= pValue; case VAR_AirResistance: return this->sResAirBase >= pValue; case VAR_WaterResistance: return this->sResWaterBase >= pValue; case VAR_EarthResistance: return this->sResEarthBase >= pValue; case VAR_SpiritResistance: return this->sResSpiritBase >= pValue; case VAR_MindResistance: return this->sResMindBase >= pValue; case VAR_BodyResistance: return this->sResBodyBase >= pValue; case VAR_LightResistance: return this->sResLightBase >= pValue; case VAR_DarkResistance: return this->sResDarkBase >= pValue; case VAR_PhysicalResistance: Error("Physical resistance isn't used in events"); return false; case VAR_MagicResistance: return this->sResMagicBase >= pValue; case VAR_FireResistanceBonus: return this->sResFireBonus >= pValue; case VAR_AirResistanceBonus: return this->sResAirBonus >= pValue; case VAR_WaterResistanceBonus: return this->sResWaterBonus >= pValue; case VAR_EarthResistanceBonus: return this->sResEarthBonus >= pValue; case VAR_SpiritResistanceBonus: return this->sResSpiritBonus >= pValue; case VAR_MindResistanceBonus: return this->sResMindBonus >= pValue; case VAR_BodyResistanceBonus: return this->sResBodyBonus >= pValue; case VAR_LightResistanceBonus: return this->sResLightBonus >= pValue; case VAR_DarkResistanceBonus: return this->sResDarkBonus >= pValue; case VAR_MagicResistanceBonus: return this->sResMagicBonus >= pValue; case VAR_StaffSkill: return CmpSkillValue(pValue, this->skillStaff); case VAR_SwordSkill: return CmpSkillValue(pValue, this->skillSword); case VAR_DaggerSkill: return CmpSkillValue(pValue, this->skillDagger); case VAR_AxeSkill: return CmpSkillValue(pValue, this->skillAxe); case VAR_SpearSkill: return CmpSkillValue(pValue, this->skillSpear); case VAR_BowSkill: return CmpSkillValue(pValue, this->skillBow); case VAR_MaceSkill: return CmpSkillValue(pValue, this->skillMace); case VAR_BlasterSkill: return CmpSkillValue(pValue, this->skillBlaster); case VAR_ShieldSkill: return CmpSkillValue(pValue, this->skillShield); case VAR_LeatherSkill: return CmpSkillValue(pValue, this->skillLeather); case VAR_SkillChain: return CmpSkillValue(pValue, this->skillChain); case VAR_PlateSkill: return CmpSkillValue(pValue, this->skillPlate); case VAR_FireSkill: return CmpSkillValue(pValue, this->skillFire); case VAR_AirSkill: return CmpSkillValue(pValue, this->skillAir); case VAR_WaterSkill: return CmpSkillValue(pValue, this->skillWater); case VAR_EarthSkill: return CmpSkillValue(pValue, this->skillEarth); case VAR_SpiritSkill: return CmpSkillValue(pValue, this->skillSpirit); case VAR_MindSkill: return CmpSkillValue(pValue, this->skillMind); case VAR_BodySkill: return CmpSkillValue(pValue, this->skillBody); case VAR_LightSkill: return CmpSkillValue(pValue, this->skillLight); case VAR_DarkSkill: return CmpSkillValue(pValue, this->skillDark); case VAR_IdentifyItemSkill: return CmpSkillValue(pValue, this->skillItemId); case VAR_MerchantSkill: return CmpSkillValue(pValue, this->skillMerchant); case VAR_RepairSkill: return CmpSkillValue(pValue, this->skillRepair); case VAR_BodybuildingSkill: return CmpSkillValue(pValue, this->skillBodybuilding); case VAR_MeditationSkill: return CmpSkillValue(pValue, this->skillMeditation); case VAR_PerceptionSkill: return CmpSkillValue(pValue, this->skillPerception); case VAR_DiplomacySkill: return CmpSkillValue(pValue, this->skillDiplomacy); case VAR_ThieverySkill: Error("Thievery isn't used in events"); return false; case VAR_DisarmTrapSkill: //wasn't in the original return CmpSkillValue(pValue, this->skillDisarmTrap); case VAR_DodgeSkill: //wasn't in the original return CmpSkillValue(pValue, this->skillDodge); case VAR_UnarmedSkill: //wasn't in the original return CmpSkillValue(pValue, this->skillUnarmed); case VAR_IdentifyMonsterSkill: //wasn't in the original return CmpSkillValue(pValue, this->skillMonsterId); case VAR_ArmsmasterSkill: //wasn't in the original return CmpSkillValue(pValue, this->skillArmsmaster); case VAR_StealingSkill: //wasn't in the original return CmpSkillValue(pValue, this->skillStealing); case VAR_AlchemySkill: //wasn't in the original return CmpSkillValue(pValue, this->skillAlchemy); case VAR_LearningSkill: return CmpSkillValue(pValue, this->skillLearning); case VAR_Cursed: return pConditions[Condition_Cursed] > 0; case VAR_Weak: return pConditions[Condition_Weak] > 0; case VAR_Asleep: return pConditions[Condition_Sleep] > 0; case VAR_Afraid: return pConditions[Condition_Fear] > 0; case VAR_Drunk: return pConditions[Condition_Drunk] > 0; case VAR_Insane: return pConditions[Condition_Insane] > 0; case VAR_PoisonedGreen: return pConditions[Condition_Poison1] > 0; case VAR_DiseasedGreen: return pConditions[Condition_Disease1] > 0; case VAR_PoisonedYellow: return pConditions[Condition_Poison2] > 0; case VAR_DiseasedYellow: return pConditions[Condition_Disease2] > 0; case VAR_PoisonedRed: return pConditions[Condition_Poison3] > 0; case VAR_DiseasedRed: return pConditions[Condition_Disease3] > 0; case VAR_Paralyzed: return pConditions[Condition_Paralyzed] > 0; case VAR_Unconsious: return pConditions[Condition_Unconcious] > 0; case VAR_Dead: return pConditions[Condition_Dead] > 0; case VAR_Stoned: return pConditions[Condition_Pertified] > 0; case VAR_Eradicated: return pConditions[Condition_Eradicated] > 0; case VAR_MajorCondition: v4 = GetMajorConditionIdx(); if ( v4 != 18 ) { return v4 >= pValue; } return true; } } if ( (signed int)VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 ) return (unsigned __int8)stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] > 0; // originally (unsigned __int8)byte_5E4C15[VarNum]; if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 ) return (unsigned __int8)stru_5E4C90_MapPersistVars._decor_events[VarNum - VAR_MapPersistentVariable_75] > 0; //not really sure whether the number gets up to 99, but can't ignore the possibility return false; } //----- (0044A5CB) -------------------------------------------------------- void Player::SetVariable(enum VariableType var_type, signed int var_value) { signed int currPlayerId; // ebx@1 Player *v4; // esi@1 unsigned int v5; // edi@1 unsigned int v6; // esi@13 unsigned int v7; // esi@14 signed int v8; // eax@17 ItemGen *v9; // ecx@17 int v10; // eax@21 signed int v11; // eax@30 Player *v12; // ecx@44 char *v13; // ecx@45 Player *v14; // ecx@49 int v15; // ecx@86 int v16; // esi@106 char v17; // al@106 int v18; // eax@107 Player *v19; // ecx@112 Player *v20; // ecx@127 int v21; // eax@127 int v22; // eax@145 char v23; // zf@146 DDM_DLV_Header *v24; // ecx@148 signed int v25; // eax@172 int v26; // [sp-8h] [bp-3Ch]@84 signed int v27; // [sp-4h] [bp-38h]@4 int v28; // [sp-4h] [bp-38h]@84 ItemGen item; // [sp+Ch] [bp-28h]@52 char v30; // [sp+32h] [bp-2h]@1 char v31; // [sp+33h] [bp-1h]@1 currPlayerId = 0; v30 = 0; v31 = 0; v4 = this; v5 = 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_AutoNotes ) { if ( var_type <= VAR_GoldInBank ) { if ( var_type == VAR_GoldInBank ) { pParty->uNumGoldInBank = var_value; return; } if ( var_type <= VAR_Counter10 ) { if ( (signed int)var_type >= 0xF5 ) { pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; // *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed);*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed); } else { switch ( var_type ) { case VAR_PlayerBits: _449B7E_toggle_bit((unsigned char *)field_1A50, var_value, 1u); break; case VAR_NPCs2: pParty->field_709 = 0; LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u; pParty->CountHirelings(); viewparams->bRedrawGameUI = true; break; case VAR_NumSkillPoints: this->uSkillPoints = var_value; break; } } return; } if ( var_type <= VAR_Counter10 ) return; if ( (signed int)var_type <= VAR_UnknownTimeEvent19 ) { pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; //*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed);, *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed); } else { if ( var_type == VAR_ReputationInCurrentLocation ) { v24 = &pOutdoor->ddm; if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) v24 = &pIndoor->dlv; v24->uReputation = var_value; if ( var_value > 10000 ) v24->uReputation = 10000; return; } if ( var_type <= VAR_ReputationInCurrentLocation || var_type > VAR_History_28 || (v22 = var_type - VAR_History_0, pParty->PartyTimes.HistoryEventTimes[v22]) || (pParty->PartyTimes.HistoryEventTimes[v22] = pParty->uTimePlayed, pStorylineText->StoreLine[v22].pText == 0) )//*(&pStorylineText->field_0 + 3 * v22) == 0, return; bFlashHistoryBook = 1; } LABEL_172: v25 = 8 * currPlayerId + 400; LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, v5, -1, v5, v5, v5, v5); return; } if ( var_type != 307 ) { switch ( var_type ) { case 308: pParty->uNumBountiesCollected = var_value; break; case 309: pParty->uNumPrisonTerms = var_value; break; case 310: pParty->uNumArenaPageWins = var_value; break; case 311: pParty->uNumArenaSquireWins = var_value; break; case 312: pParty->uNumArenaKnightWins = var_value; break; case 313: pParty->uNumArenaLordWins = var_value; break; } return; } pParty->uNumDeaths = var_value; LABEL_168: if ( v30 != 1 ) { LABEL_170: if ( v31 != 1 ) return; v5 = 0; goto LABEL_172; } LABEL_169: pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); goto LABEL_170; } if ( var_type == VAR_AutoNotes ) { if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_autonote_bits[((signed __int16)var_value - 1) >> 3]) //&& (&dword_723718_autonote_related)[8 * a3] ) && pAutonoteTxt[var_value-1].pText ) { v20 = pPlayers[currPlayerId + 1]; v30 = 1; v20->PlaySound(SPEECH_96, 0); v21 = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3]; bFlashAutonotesBook = 1; _506568_autonote_type = v21; } _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u); v31 = 1; goto LABEL_168; } if ( var_type <= VAR_ActualMight ) { if ( var_type != VAR_ActualMight ) { switch ( var_type ) { case VAR_RandomGold: v6 = rand() % var_value + 1; Party::SetGold(v6); sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold ShowStatusBarString(pTmpBuf.data(), 2u); GameUI_DrawFoodAndGold(); return; case VAR_RandomFood: v7 = rand() % var_value + 1; Party::SetFood(v7); sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food ShowStatusBarString(pTmpBuf.data(), 2u); GameUI_DrawFoodAndGold(); goto LABEL_124; case VAR_Sex: this->uSex = (PLAYER_SEX)var_value; goto LABEL_124; case VAR_Class: this->classType = (PLAYER_CLASS_TYPE)var_value; if ( (char)var_value != 35 ) goto LABEL_124; v8 = 0; v9 = this->pInventoryItemList; break; case VAR_CurrentHP: this->sHealth = var_value; goto LABEL_124; case VAR_MaxHP: this->sHealth = GetMaxHealth(); return; case VAR_CurrentSP: this->sMana = var_value; goto LABEL_124; case VAR_MaxSP: this->sMana = GetMaxMana(); return; case VAR_ACModifier: this->sACModifier = (unsigned __int8)var_value; goto LABEL_124; case VAR_BaseLevel: this->uLevel = (unsigned __int8)var_value; goto LABEL_124; case VAR_LevelModifier: this->sLevelModifier = (unsigned __int8)var_value; goto LABEL_124; case VAR_Age: this->sAgeModifier = var_value; return; case VAR_Award: if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pPlayers[currPlayerId + 1]->_achieved_awards_bits[((signed __int16)var_value - 1)/ 8]) //&& dword_723E80_award_related[2 * a3] ) && pAwards[var_value].pText ) { v30 = 1; v31 = 1; pPlayers[currPlayerId + 1]->PlaySound(SPEECH_96, 0); } _449B7E_toggle_bit((unsigned char *)v4->_achieved_awards_bits, var_value, 1u); goto LABEL_168; case VAR_Experience: this->uExperience = var_value; goto LABEL_124; case VAR_QBits_QuestsDone: if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_quest_bits[((signed __int16)var_value - 1) >> 3]) // && (&dword_722F10)[4 * a3] ) && pQuestTable[var_value-1] ) { v14 = pPlayers[currPlayerId + 1]; bFlashQuestBook = 1; v30 = 1; v31 = 1; v14->PlaySound(SPEECH_93, 0); } v13 = (char *)pParty->_quest_bits; LABEL_51: _449B7E_toggle_bit((unsigned char *)v13, var_value, 1u); if (( v30 != 1 )&&( v31 != 1 )) return; else pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); if ( v31 != 1 ) return; v25 = 8 * currPlayerId + 400; LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); return; case VAR_PlayerItemInHands: item.Reset(); item.Reset(); item.uItemID = var_value; item.uAttributes = 1; pParty->SetHoldingItem(&item); if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER ) pParty->pIsArtifactFound[var_value-500] = 1; return; case VAR_FixedGold: Party::SetGold(var_value); return; case VAR_BaseMight: this->uMight = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_BaseIntellect: this->uIntelligence = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_BasePersonality: this->uWillpower = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_BaseEndurance: this->uEndurance = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_BaseSpeed: this->uSpeed = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_BaseAccuracy: this->uAccuracy = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_BaseLuck: this->uLuck = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_FixedFood: Party::SetFood(var_value); goto LABEL_124; case VAR_MightBonus: goto LABEL_64; case VAR_IntellectBonus: goto LABEL_68; case VAR_PersonalityBonus: goto LABEL_69; case VAR_EnduranceBonus: goto LABEL_70; case VAR_SpeedBonus: goto LABEL_71; case VAR_AccuracyBonus: goto LABEL_72; case VAR_LuckBonus: goto LABEL_73; default: return; } while ( v9->uItemID != 615 ) { ++v8; ++v9; if ( v8 >= 138 ) goto LABEL_22; } v10 = (int)((char *)v4 + 36 * v8); *(int *)(v10 + 532) = 601; *(char *)(v10 + 558) = currPlayerId + 1; LABEL_22: if ( v4->sResFireBase < 20 ) v4->sResFireBase = 20; if ( v4->sResAirBase < 20 ) v4->sResAirBase = 20; if ( v4->sResWaterBase < 20 ) v4->sResWaterBase = 20; if ( v4->sResEarthBase < 20 ) v4->sResEarthBase = 20; v4->sResMindBase = 200; v4->sResBodyBase = 200; v11 = v4->GetSexByVoice(); v4->uPrevVoiceID = v4->uVoiceID; v4->uPrevFace = v4->uCurrentFace; if ( v11 ) { v4->uCurrentFace = 21; v4->uVoiceID = 21; } else { v4->uCurrentFace = 20; v4->uVoiceID = 20; } ReloadPlayerPortraits(currPlayerId, v4->uCurrentFace); goto LABEL_124; } LABEL_64: this->uMightBonus = (unsigned __int8)var_value; LABEL_111: v28 = 0; v26 = SPEECH_91; LABEL_112: v19 = pPlayers[currPlayerId + 1]; v31 = 1; v19->PlaySound((PlayerSpeech)v26, v28); goto LABEL_169; } if ( var_type <= VAR_FireResistanceBonus ) { if ( var_type == VAR_FireResistanceBonus ) { this->sResFireBonus = (unsigned __int8)var_value; goto LABEL_111; } switch ( var_type ) { case VAR_ActualIntellect: LABEL_68: this->uIntelligenceBonus = (unsigned __int8)var_value; goto LABEL_111; case VAR_ActualPersonality: LABEL_69: this->uWillpowerBonus = (unsigned __int8)var_value; goto LABEL_111; case VAR_ActualEndurance: LABEL_70: this->uEnduranceBonus = (unsigned __int8)var_value; goto LABEL_111; case VAR_ActualSpeed: LABEL_71: this->uSpeedBonus = (unsigned __int8)var_value; goto LABEL_111; case VAR_ActualAccuracy: LABEL_72: this->uAccuracyBonus = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_ActualLuck: LABEL_73: this->uLuckBonus = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_FireResistance: this->sResFireBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_AirResistance: this->sResAirBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_WaterResistance: this->sResWaterBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_EarthResistance: this->sResEarthBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_SpiritResistance: this->sResSpiritBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_MindResistance: this->sResMindBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_BodyResistance: this->sResBodyBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_LightResistance: this->sResLightBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_DarkResistance: this->sResDarkBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; case VAR_MagicResistance: this->sResMagicBase = (unsigned __int8)var_value; v28 = 0; v26 = 92; goto LABEL_112; default: return; } return; } HIWORD(v15) = 0; if ( var_type > VAR_DisarmTrapSkill ) { if ( var_type != VAR_LearningSkill ) { if ( var_type <= VAR_LearningSkill ) return; if ( var_type <= VAR_Eradicated ) { v4->SetCondition(var_type - 105, 1); } else { if ( var_type != VAR_MajorCondition ) { if ( var_type > VAR_MajorCondition && var_type <= VAR_MapPersistentVariable_99 ) byte_5E4C15[var_type] = var_value; return; } memset(v4, 0, 0xA0u); } LABEL_124: v31 = 1; goto LABEL_169; } LABEL_106: v16 = (int)((char *)&v4->pConditions[16] + 2 * var_type); v17 = *(char *)v16; if ( var_value <= VAR_BodyResistanceBonus ) { LOWORD(v15) = (unsigned __int8)var_value; v18 = v15 | v17 & VAR_BodyResistanceBonus; } else { LOWORD(v18) = (unsigned __int8)(var_value | v17 & 0xC0); } *(short *)v16 = v18; goto LABEL_124; } if ( var_type == VAR_DisarmTrapSkill ) if ( v30 != 1 ) { if ( v31 != 1 ) return; v5 = 0; goto LABEL_172; } pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); goto LABEL_170; if ( var_type <= VAR_BodyResistanceBonus ) { switch ( var_type ) { case VAR_BodyResistanceBonus: v4->sResBodyBonus = (unsigned __int8)var_value; break; case VAR_AirResistanceBonus: v4->sResAirBonus = (unsigned __int8)var_value; break; case VAR_WaterResistanceBonus: v4->sResWaterBonus = (unsigned __int8)var_value; break; case VAR_EarthResistanceBonus: v4->sResEarthBonus = (unsigned __int8)var_value; break; case VAR_SpiritResistanceBonus: v4->sResSpiritBonus = (unsigned __int8)var_value; break; default: if ( var_type != 62 ) return; v4->sResMindBonus = (unsigned __int8)var_value; break; } goto LABEL_111; } if ( var_type == VAR_LightResistanceBonus ) { v4->sResLightBonus = (unsigned __int8)var_value; goto LABEL_111; } if ( var_type == VAR_DarkResistanceBonus ) { v4->sResDarkBonus = (unsigned __int8)var_value; goto LABEL_111; } if ( var_type == VAR_MagicResistanceBonus ) { v4->sResMagicBonus = (unsigned __int8)var_value; goto LABEL_111; } if ( var_type > VAR_MagicResistanceBonus && var_type <= VAR_DiplomacySkill ) if ( v30 != 1 ) { if ( v31 != 1 ) return; v5 = 0; v25 = 8 * currPlayerId + 400; LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); return; } pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); goto LABEL_170; } //----- (new function) -------------------------------------------------------- void Player::PlaySoundBasedOnCondition(int currPlayerId) { signed int v25 = 8 * currPlayerId + 400; LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); } //----- (new function) -------------------------------------------------------- void Player::DrawPlayerBuffAnimBasedOnCondition(int currPlayerId) { pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId); } //----- (0044AFFB) -------------------------------------------------------- void Player::AddVariable(enum VariableType var_type, signed int val) { char v3; // bl@1 Player *v4; // esi@1 signed int uPlayerIdx; // edi@1 int v6; // eax@15 unsigned int v7; // esi@18 int *v8; // ebx@21 int v9; // eax@22 signed int v10; // eax@24 int v11; // eax@27 __int16 *v12; // esi@28 Player *v13; // ecx@34 Player *v14; // ecx@36 char *v15; // ecx@37 unsigned __int8 v16; // cf@38 Player *v17; // ecx@42 __int16 *v18; // esi@53 __int16 *v19; // esi@62 char *v20; // esi@107 __int16 v21; // dx@107 int v22; // ecx@107 Player *v23; // ecx@132 int v24; // eax@132 int v25; // eax@150 char v26; // zf@151 DDM_DLV_Header *v27; // eax@153 signed int v28; // eax@176 int v29; // [sp-8h] [bp-40h]@84 // signed int v30; // [sp-4h] [bp-3Ch]@4 int v31; // [sp-4h] [bp-3Ch]@84 ItemGen item; // [sp+Ch] [bp-2Ch]@45 unsigned int v33; // [sp+30h] [bp-8h]@34 char v34; // [sp+37h] [bp-1h]@1 auto Dst = this; v3 = 0; v34 = 0; v4 = Dst; uPlayerIdx = 0; if ( Dst == pPlayers[2] ) uPlayerIdx = 1; else if ( Dst == pPlayers[3] ) uPlayerIdx = 2; else if ( Dst == pPlayers[4] ) uPlayerIdx = 3; if ( var_type <= VAR_AutoNotes ) { if ( var_type != VAR_AutoNotes ) { if ( var_type <= VAR_ActualMight ) { if ( var_type != VAR_ActualMight ) { switch ( var_type ) { case VAR_RandomGold: if ( !val ) val = 1; v6 = rand(); party_finds_gold(v6 % val + 1, 1); GameUI_DrawFoodAndGold(); return; case VAR_RandomFood: if ( !val ) val = 1; v7 = rand() % val + 1; Party::GiveFood(v7); sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], v7);// You find %lu food ShowStatusBarString(pTmpBuf.data(), 2u); GameUI_DrawFoodAndGold(); goto _play_sound; case VAR_Sex: Dst->uSex = (PLAYER_SEX)val; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; case VAR_Class: Dst->classType = (PLAYER_CLASS_TYPE)val; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; case VAR_CurrentHP: v8 = &Dst->sHealth; *v8 += val; if ( Dst->sHealth <= Dst->GetMaxHealth() ) { pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; } v9 = v4->GetMaxHealth(); goto LABEL_23; case VAR_MaxHP: v10 = Dst->GetMaxHealth(); v4->_health_related = 0; v4->uFullHealthBonus = 0; v4->sHealth = v10; return; case VAR_CurrentSP: v8 = &Dst->sMana; *v8 += val; if ( Dst->sMana > GetMaxMana() ) { v9 = v4->GetMaxMana(); LABEL_23: *v8 = v9; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; case VAR_MaxSP: v11 = GetMaxMana(); v4->_mana_related = 0; v4->uFullManaBonus = 0; v4->sMana = v11; return; case VAR_ACModifier: v12 = &Dst->sACModifier; goto LABEL_29; case VAR_BaseLevel: v12 = (__int16 *)&Dst->uLevel; goto LABEL_29; case VAR_LevelModifier: v12 = &Dst->sLevelModifier; LABEL_29: *v12 += val; if ( *v12 > 255 ) *v12 = 255; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; case VAR_Age: Dst->sAgeModifier += val; return; case VAR_Award: v13 = pPlayers[uPlayerIdx + 1]; if (_449B57_test_bit((unsigned __int8 *)pPlayers[uPlayerIdx + 1]->_achieved_awards_bits, val) && pAwards[val].pText ) { v14 = pPlayers[uPlayerIdx + 1]; v34 = 1; v3 = 1; v14->PlaySound(SPEECH_96, 0); } v15 = (char *)v4->_achieved_awards_bits; _449B7E_toggle_bit((unsigned char *)v15, val, 1); if ( v34 != 1 ) { if ( v3 != 1 ) return; goto _play_sound; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; goto _play_sound; case VAR_Experience: v16 = __CFADD__(val, LODWORD(Dst->uExperience)); LODWORD(Dst->uExperience) += val; HIDWORD(Dst->uExperience) += ((unsigned __int64)val >> 32) + v16; if ( (signed __int64)Dst->uExperience > 4000000000i64 ) Dst->uExperience = 4000000000i64; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; case VAR_QBits_QuestsDone: if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_quest_bits[((signed __int16)val - 1) >> 3]) //&& (&dword_722F10)[4 * val] ) && pQuestTable[val] ) { //v17 = pPlayers[uPlayerIdx + 1]; bFlashQuestBook = 1; v34 = 1; v3 = 1; pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_93, 0); } v15 = (char *)pParty->_quest_bits; _449B7E_toggle_bit((unsigned char *)v15, val, 1); if ( v34 != 1 ) { if ( v3 != 1 ) return; goto _play_sound; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; goto _play_sound; case VAR_PlayerItemInHands: item.Reset(); item.Reset(); item.uAttributes = 1; item.uItemID = val; if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER ) pParty->pIsArtifactFound[val-500] = 1; if ( val >= ITEM_WAND_FIRE && val <= ITEM_WAND_INCENERATION ) { item.uNumCharges = rand() % 6 + item.GetDamageMod() + 1; item.uMaxCharges = LOBYTE(item.uNumCharges); } pParty->SetHoldingItem(&item); return; case VAR_FixedGold: party_finds_gold(val, 1); return; case VAR_BaseMight: v18 = (__int16 *)&Dst->uMight; goto LABEL_82; case VAR_BaseIntellect: v18 = (__int16 *)&Dst->uIntelligence; goto LABEL_82; case VAR_BasePersonality: v18 = (__int16 *)&Dst->uWillpower; goto LABEL_82; case VAR_BaseEndurance: v18 = (__int16 *)&Dst->uEndurance; goto LABEL_82; case VAR_BaseSpeed: v18 = (__int16 *)&Dst->uSpeed; goto LABEL_82; case VAR_BaseAccuracy: v18 = (__int16 *)&Dst->uAccuracy; goto LABEL_82; case VAR_BaseLuck: v18 = (__int16 *)&Dst->uLuck; goto LABEL_82; case VAR_FixedFood: Party::GiveFood(val); sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], val); ShowStatusBarString(pTmpBuf.data(), 2u); if ( pParty->uNumFoodRations > 0xFFFF ) Party::SetFood(0xFFFFu); goto _play_sound; case VAR_MightBonus: goto LABEL_62; case VAR_IntellectBonus: goto LABEL_66; case VAR_PersonalityBonus: goto LABEL_67; case VAR_EnduranceBonus: goto LABEL_68; case VAR_SpeedBonus: goto LABEL_69; case VAR_AccuracyBonus: goto LABEL_70; case VAR_LuckBonus: goto LABEL_71; default: return; } return; } LABEL_62: v19 = (__int16 *)&Dst->uMightBonus; goto LABEL_113; } if ( var_type <= VAR_FireResistanceBonus ) { if ( var_type != VAR_FireResistanceBonus ) { switch ( var_type ) { case VAR_ActualIntellect: LABEL_66: v19 = (__int16 *)&Dst->uIntelligenceBonus; goto LABEL_113; case VAR_ActualPersonality: LABEL_67: v19 = (__int16 *)&Dst->uWillpowerBonus; goto LABEL_113; case VAR_ActualEndurance: LABEL_68: v19 = (__int16 *)&Dst->uEnduranceBonus; goto LABEL_113; case VAR_ActualSpeed: LABEL_69: v19 = (__int16 *)&Dst->uSpeedBonus; goto LABEL_113; case VAR_ActualAccuracy: LABEL_70: v19 = (__int16 *)&Dst->uAccuracyBonus; goto LABEL_113; case VAR_ActualLuck: LABEL_71: v19 = (__int16 *)&Dst->uLuckBonus; goto LABEL_113; case VAR_FireResistance: v18 = &Dst->sResFireBase; goto LABEL_82; case VAR_AirResistance: v18 = &Dst->sResAirBase; goto LABEL_82; case VAR_WaterResistance: v18 = &Dst->sResWaterBase; goto LABEL_82; case VAR_EarthResistance: v18 = &Dst->sResEarthBase; goto LABEL_82; case VAR_SpiritResistance: v18 = &Dst->sResSpiritBase; goto LABEL_82; case VAR_MindResistance: v18 = &Dst->sResMindBase; goto LABEL_82; case VAR_BodyResistance: v18 = &Dst->sResBodyBase; goto LABEL_82; case VAR_LightResistance: v18 = &Dst->sResLightBase; goto LABEL_82; case VAR_DarkResistance: v18 = &Dst->sResDarkBase; goto LABEL_82; case VAR_MagicResistance: v18 = &Dst->sResMagicBase; LABEL_82: *v18 += val; if ( *v18 > 255 ) *v18 = 255; pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; default: return; } return; } v19 = &Dst->sResFireBonus; LABEL_113: *v19 += val; if ( *v19 > 255 ) *v19 = 255; v31 = 0; v29 = SPEECH_91; pPlayers[uPlayerIdx + 1]->PlaySound((PlayerSpeech)v29, v31); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; } if ( var_type <= VAR_DisarmTrapSkill ) { if ( var_type != VAR_DisarmTrapSkill ) { if ( var_type <= VAR_BodyResistanceBonus ) { switch ( var_type ) { case VAR_BodyResistanceBonus: v19 = &Dst->sResBodyBonus; break; case VAR_AirResistanceBonus: v19 = &Dst->sResAirBonus; break; case VAR_WaterResistanceBonus: v19 = &Dst->sResWaterBonus; break; case VAR_EarthResistanceBonus: v19 = &Dst->sResEarthBonus; break; case VAR_SpiritResistanceBonus: v19 = &Dst->sResSpiritBonus; break; default: if ( var_type != 62 ) return; v19 = &Dst->sResMindBonus; break; } goto LABEL_113; } if ( var_type == VAR_LightResistanceBonus ) { v19 = &Dst->sResLightBonus; goto LABEL_113; } if ( var_type == VAR_DarkResistanceBonus ) { v19 = &Dst->sResDarkBonus; goto LABEL_113; } if ( var_type == VAR_MagicResistanceBonus ) { v19 = &Dst->sResMagicBonus; goto LABEL_113; } if ( var_type <= VAR_MagicResistanceBonus || var_type > VAR_DiplomacySkill ) return; } goto LABEL_106; } if ( var_type == VAR_LearningSkill ) { LABEL_106: if ( val <= VAR_BodyResistanceBonus ) { *((short *)&Dst->pConditions[16] + var_type) = (unsigned __int8)val | *((char *)&Dst->pConditions[16] + 2 * var_type) & VAR_BodyResistanceBonus; } else { v20 = (char *)&Dst->pConditions[16] + 2 * var_type; v21 = *(short *)v20; v22 = (unsigned __int8)val + (v21 & VAR_BodyResistanceBonus); if ( v22 > 60 ) LOWORD(v22) = 60; LOBYTE(v21) = v21 & 0xC0; *(short *)v20 = v22 | v21; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; } if ( var_type <= VAR_LearningSkill ) return; if ( var_type <= VAR_Eradicated ) { Dst->SetCondition(var_type - 105, 0); } else { if ( var_type != VAR_MajorCondition ) { if ( var_type > VAR_MajorCondition && 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; } return; } memset(Dst, 0, 0xA0u); } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); goto _play_sound; } if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_autonote_bits[((signed __int16)val - 1) >> 3]) //&& (&dword_723718_autonote_related)[8 * val] ) && pAutonoteTxt[val].pText ) { v23 = pPlayers[uPlayerIdx + 1]; v34 = 1; v23->PlaySound(SPEECH_96, 0); //v24 = pAutonoteTxt[val].eType;//dword_72371C[2 * val]; bFlashAutonotesBook = 1; _506568_autonote_type = pAutonoteTxt[val].eType; } _449B7E_toggle_bit(pParty->_autonote_bits, val, 1); v3 = 1; if ( v34 != 1 ) { if ( v3 != 1 ) return; goto _play_sound; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; goto _play_sound; } if ( var_type > VAR_GoldInBank ) { if ( var_type == 307 ) { pParty->uNumDeaths += val; if ( v34 != 1 ) { if ( v3 != 1 ) return; goto _play_sound; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; goto _play_sound; } switch ( var_type ) { case 308: pParty->uNumBountiesCollected += val; break; case 309: pParty->uNumPrisonTerms += val; break; case 310: pParty->uNumArenaPageWins += val; break; case 311: pParty->uNumArenaSquireWins += val; break; case 312: pParty->uNumArenaKnightWins += val; break; case 313: pParty->uNumArenaLordWins += val; break; } } else { if ( var_type == VAR_GoldInBank ) { pParty->uNumGoldInBank += val; return; } if ( var_type <= VAR_Counter8 ) { if ( (signed int)var_type >= 245 ) { *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed); *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed); } else { switch ( var_type ) { case VAR_PlayerBits: _449B7E_toggle_bit((unsigned char *)Dst->field_1A50, val, 1u); break; case VAR_NPCs2: pParty->field_709 = 0; LOBYTE(pNPCStats->pNewNPCData[val].uFlags) |= 0x80u; pParty->CountHirelings(); viewparams->bRedrawGameUI = true; break; case VAR_NumSkillPoints: Dst->uSkillPoints += val; break; } } return; } if ( var_type < VAR_Counter9 ) return; if ( (signed int)var_type <= 274 ) { *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed); *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed); goto _play_sound; } if ( var_type != VAR_ReputationInCurrentLocation ) { if ( var_type <= VAR_ReputationInCurrentLocation || var_type > VAR_History_28 || (v25 = var_type - 276, pParty->PartyTimes.HistoryEventTimes[v25]) || (pParty->PartyTimes.HistoryEventTimes[var_type - 276] = pParty->uTimePlayed, v26 = pStorylineText->StoreLine[v25].pText==0,//*(&pStorylineText->field_0 + 3 * v25) == 0, v26) ) return; bFlashHistoryBook = 1; _play_sound: v28 = 8 * uPlayerIdx + 400; LOBYTE(v28) = PID(OBJECT_Player,uPlayerIdx - 112); pAudioPlayer->PlaySound(SOUND_20001, v28, 0, -1, 0, 0, 0, 0); return; } v27 = &pOutdoor->ddm; if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) v27 = &pIndoor->dlv; v27->uReputation += val; if ( v27->uReputation > 10000 ) v27->uReputation = 10000; } } //----- (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 ) { 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; dword_5B65CC = 0; if ( (int)VarNum == pValue ) { dword_5B65CC = (int)pValue; } else { pParty->field_709 = 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->field_709 = 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; } 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 ) { 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 ) { RemoveItemAtInventoryIndex(v3); return true; } } if ( pParty->pPickedItem.uItemID == pValue ) { pMouse->RemoveHoldingItem(); return true; } return false; } } //assert(false); return false; } // 5B65C4: using guessed type int dword_5B65C4; // 5B65CC: using guessed type int dword_5B65CC; //----- (00467E7F) -------------------------------------------------------- void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType) { int v2; // ebx@1 Player *v3; // eax@1 int v4; // edx@1 int v7; // eax@3 ItemGen tempPickedItem; // [sp+Ch] [bp-30h]@1 unsigned int *v11; // [sp+38h] [bp-4h]@1 tempPickedItem.Reset(); v2 = pEquipTypeToBodyAnchor[uEquipType]; v3 = pPlayers[uActiveCharacter]; v11 = &v3->pEquipment.pIndices[v2]; v4 = *v11; if ( v4 ) { memcpy(&tempPickedItem, &pParty->pPickedItem, sizeof(tempPickedItem)); v3->pInventoryItemList[v4 - 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; } else { v7 = v3->FindFreeInventoryListSlot(); if (v7 >= 0) { pParty->pPickedItem.uBodyAnchor = v2 + 1; memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(ItemGen)); *v11 = v7 + 1; pMouse->RemoveHoldingItem(); } } } //----- (0049387A) -------------------------------------------------------- int CycleCharacter(bool backwards) { const int PARTYSIZE = 4; int valToAdd = backwards ? (PARTYSIZE - 2) : 0; int mult = backwards ? -1 : 1; for (int i = 0; i < (PARTYSIZE - 1); i++) { int currCharId = ((uActiveCharacter + mult * i + valToAdd) % PARTYSIZE) + 1; if ( pPlayers[currCharId]->uTimeToRecovery == 0 ) { return currCharId; } } return uActiveCharacter; } //----- (0043EE77) -------------------------------------------------------- bool Player::HasUnderwaterSuitEquipped() //the original function took the player number as a parameter. if it was 0, the whole party was checked. calls with the parameter 0 have been changed to calls to this for every player { if (GetArmorItem() == nullptr || GetArmorItem()->uItemID != 604) { return false; } return true; } //----- (0043EE15) -------------------------------------------------------- bool Player::HasItem( unsigned int uItemID, char a3 ) { if ( !a3 || pParty->pPickedItem.uItemID != uItemID ) { for ( uint i = 0; i < 126; ++i ) { if ( this->pInventoryMatrix[i] > 0 ) { if ( (unsigned int)this->pInventoryItemList[this->pInventoryMatrix[i] - 1].uItemID == uItemID ) return true; } } for ( uint i = 0; i < 16; ++i ) { if ( this->pEquipment.pIndices[i] ) { if ( (unsigned int)this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == uItemID ) return true; } } } return false; } //----- (0043EDB9) -------------------------------------------------------- bool ShouldLoadTexturesForRaceAndGender(unsigned int _this) { CHARACTER_RACE race; // edi@2 PLAYER_SEX sex; // eax@2 for (int i = 1; i <= 4; i++) { race = pPlayers[i]->GetRace(); sex = pPlayers[i]->GetSexByVoice(); switch(_this) { case 0: if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_MALE ) return true; break; case 1: if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_FEMALE ) return true; break; case 2: if ( race == CHARACTER_RACE_DWARF && sex == SEX_MALE ) return true; break; case 3: if ( race == CHARACTER_RACE_DWARF && sex == SEX_FEMALE ) return true; break; } } return false; } //----- (0043ED6F) -------------------------------------------------------- bool IsDwarfPresentInParty(bool a1) { for (uint i = 0; i < 4; ++i) { CHARACTER_RACE race = pParty->pPlayers[i].GetRace(); if (race == CHARACTER_RACE_DWARF && a1) return true; else if (race != CHARACTER_RACE_DWARF && !a1) return true; } return false; } //----- (00439FCB) -------------------------------------------------------- void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int element, Vec3_int_ *pPos, unsigned int a4) { Player *playerPtr; // ebx@3 Actor *actorPtr; // esi@3 int spellId; // eax@38 signed int recvdMagicDmg; // eax@139 int v72[4]; // [sp+30h] [bp-24h]@164 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 uActorID = PID_ID(uObjID); if ( PID_TYPE(uObjID) != 2) { playerPtr = &pParty->pPlayers[a4]; actorPtr = &pActors[uActorID]; healthBeforeRecvdDamage = playerPtr->sHealth; if ( PID_TYPE(uObjID) != 3 || !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) return; ItemGen* equippedArmor = playerPtr->GetArmorItem(); SoundID soundToPlay; if ( !equippedArmor || equippedArmor->IsBroken() || (equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_CHAIN && equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_PLATE ) ) { int randVal = rand() % 4; switch (randVal) { case 0 : soundToPlay = (SoundID)108; break; case 1 : soundToPlay = (SoundID)109; break; case 2 : soundToPlay = (SoundID)110; break; case 3 : soundToPlay = (SoundID)44; break; } } else { int randVal = rand() % 4; switch (randVal) { case 0 : soundToPlay = (SoundID)105; break; case 1 : soundToPlay = (SoundID)106; break; case 2 : soundToPlay = (SoundID)107; break; case 3 : soundToPlay = (SoundID)45; break; } } pAudioPlayer->PlaySound(soundToPlay, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0); int dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, element); if ( actorPtr->pActorBuffs[3].uExpireTime > 0 ) { __int16 spellPower = actorPtr->pActorBuffs[3].uPower; if ( spellPower ) dmgToReceive /= (signed int)spellPower; } int damageType; switch (element) { case 0: damageType = actorPtr->pMonsterInfo.uAttack1Type; break; case 1: damageType = actorPtr->pMonsterInfo.uAttack2Type; break; case 2: spellId = actorPtr->pMonsterInfo.uSpell1ID; damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; case 3: spellId = actorPtr->pMonsterInfo.uSpell2ID; damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; case 4: damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack; break; default: case 5: damageType = 4; //yes, the original just assigned the value 4 break; } if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { dmgToReceive = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) { int actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) { int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, dmgToReceive); actorPtr->sCurrentHP -= reflectedDamage; if ( reflectedDamage >= 0 ) { if ( actorPtr->sCurrentHP >= 1 ) { Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); //todo extract this branch to a function once Actor::functions are changed to nonstatic actor functions Actor::AggroSurroundingPeasants(uActorID, 1); } else { if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) { int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0); } Actor::Die(uActorID); Actor::ApplyFineForKillingPeasant(uActorID); Actor::AggroSurroundingPeasants(uActorID, 1); if ( actorPtr->pMonsterInfo.uExp ) GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); int speechToPlay = SPEECH_51; if ( rand() % 100 < 20 ) speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0); } } } } if ( !(dword_6BE368_debug_settings_2 & 0x10) && actorPtr->pMonsterInfo.uSpecialAttackType && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel ) { playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr); } } if ( !pParty->bTurnBasedModeOn ) { int actEndurance = playerPtr->GetActualEndurance(); int recoveryTime = (int)((20 - playerPtr->GetParameterBonus(actEndurance)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333); playerPtr->SetRecoveryTime(recoveryTime); } int yellThreshold = playerPtr->GetMaxHealth() / 4; if ( yellThreshold < playerPtr->sHealth && yellThreshold >= healthBeforeRecvdDamage && playerPtr->sHealth > 0 ) { playerPtr->PlaySound(SPEECH_48, 0); } viewparams->bRedrawGameUI = 1; return; } else { SpriteObject* v37 = &pSpriteObjects[uActorID]; int uActorType = PID_TYPE(v37->spell_caster_pid); int uActorID = PID_ID(v37->spell_caster_pid); if ( uActorType == 2 ) { Player *playerPtr; // eax@81 if ( a4 != -1 ) { playerPtr = &pParty->pPlayers[a4]; } else { element = 0; for (int i = 1; i <= 4; i++) { v72[element] = i; element++; } if ( element ) { playerPtr = &pParty->pPlayers[v72[rand() % element]];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; } } int v68; int v69; if ( uActorType != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW) { int playerMaxHp = playerPtr->GetMaxHealth(); v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, playerMaxHp); v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool); } else { v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0); v69 = 0; } playerPtr->ReceiveDamage(v68, (DAMAGE_TYPE)v69); if ( uActorType == OBJECT_Player && !qword_A750D8 ) { qword_A750D8 = 256i64; PlayerSpeechID = SPEECH_44; uSpeakingCharacter = uActorID + 1; } return; } else if ( uActorType == 3 ) { Actor *actorPtr = &pActors[uActorID]; if ( a4 == -1 ) a4 = stru_50C198.which_player_would_attack(actorPtr); Player *playerPtr = &pParty->pPlayers[a4]; int dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, element); unsigned __int16 spriteType = v37->uType; if ( v37->uType == 545 ) { __int16 skillLevel = playerPtr->GetActualSkillLevel(PLAYER_SKILL_UNARMED); if ( SkillToMastery(skillLevel) >= 4 && rand() % 100 < (skillLevel & 0x3F) ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], playerPtr->pName); ShowStatusBarString(pTmpBuf.data(), 2u); playerPtr->PlaySound(SPEECH_6, 0); return; } } else if ( spriteType == 555 || spriteType == 510 || spriteType == 500 || spriteType == 515 || spriteType == 505 || spriteType == 530 || spriteType == 525 || spriteType == 520 || spriteType == 535 || spriteType == 540 ) { if ( !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) return; if ( playerPtr->pPlayerBuffs[13].uExpireTime > 0 ) dmgToReceive >>= 1; if ( playerPtr->HasEnchantedItemEquipped(36) ) dmgToReceive >>= 1; if ( playerPtr->HasEnchantedItemEquipped(69) ) dmgToReceive >>= 1; if ( playerPtr->HasItemEquipped(EQUIP_ARMOUR) && playerPtr->GetArmorItem()->uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR ) dmgToReceive >>= 1; if ( playerPtr->HasItemEquipped(EQUIP_MAIN_HAND)) { ItemGen* mainHandItem = playerPtr->GetMainHandItem(); if ( mainHandItem->uItemID == ITEM_RELIC_KELEBRIM || mainHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (mainHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) dmgToReceive >>= 1; } if ( playerPtr->HasItemEquipped(EQUIP_OFF_HAND)) { ItemGen* offHandItem = playerPtr->GetOffHandItem(); if ( offHandItem->uItemID == ITEM_RELIC_KELEBRIM || offHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (offHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) dmgToReceive >>= 1; } } if ( actorPtr->pActorBuffs[3].uExpireTime > 0 ) { int spellPower = actorPtr->pActorBuffs[3].uPower; if ( spellPower ) dmgToReceive /= (signed int)spellPower; } int damageType; switch(element) { case 0: damageType = actorPtr->pMonsterInfo.uAttack1Type; break; case 1: damageType = actorPtr->pMonsterInfo.uAttack2Type; break; case 2: spellId = actorPtr->pMonsterInfo.uSpell1ID; damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; case 3: spellId = actorPtr->pMonsterInfo.uSpell2ID; damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; case 4: damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack; break; case 5: damageType = 4; break; } if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { int reflectedDmg = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) { unsigned __int16 actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) { recvdMagicDmg = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, reflectedDmg); actorPtr->sCurrentHP -= recvdMagicDmg; if ( recvdMagicDmg >= 0 ) { if ( actorPtr->sCurrentHP >= 1 ) { Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); Actor::AggroSurroundingPeasants(uActorID, 1); } else { if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) { int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0); } Actor::Die(uActorID); Actor::ApplyFineForKillingPeasant(uActorID); Actor::AggroSurroundingPeasants(uActorID, 1); if ( actorPtr->pMonsterInfo.uExp ) GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); int speechToPlay = SPEECH_51; if ( rand() % 100 < 20 ) speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0); } } } } } if ( !element && !(dword_6BE368_debug_settings_2 & 0x10) && actorPtr->pMonsterInfo.uSpecialAttackType && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel ) { playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr); } if ( !pParty->bTurnBasedModeOn ) { int actEnd = playerPtr->GetActualEndurance(); int recTime = (int)((20 - playerPtr->GetParameterBonus(actEnd)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333); playerPtr->SetRecoveryTime(recTime); } return; } else { return; } } } //----- (00421EA6) -------------------------------------------------------- void Player::OnInventoryLeftClick() { signed int v2; // ecx@2 int v3; // eax@2 int invMatrixIndex; // eax@2 unsigned int v6; // eax@7 unsigned int pickedItemId; // esi@12 unsigned int invItemIndex; // eax@12 unsigned int v9; // eax@16 unsigned int v10; // 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 ) { if ( invMatrixIndex <= 126 && pMouse->GetCursorPos(&a2)->x < 462 && pMouse->GetCursorPos(&a2)->x >= 14 ) { if ( _50C9A0_IsEnchantingInProgress ) { 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; } 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); v9 = pParty->pPickedItem.uItemID; pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); return; } } else { if ( invItemIndex ) { 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()); return; } else { 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; } } } } } } } bool Player::IsWeak() { return pConditions[Condition_Weak] != 0; } bool Player::IsDead() { return pConditions[Condition_Dead] != 0; } bool Player::IsEradicated() { return pConditions[Condition_Eradicated] != 0; } bool Player::IsZombie() { return pConditions[Condition_Zombie] != 0; } bool Player::IsCursed() { return pConditions[Condition_Cursed] != 0; } bool Player::IsPertified() { return pConditions[Condition_Pertified] != 0; } bool Player::IsUnconcious() { return pConditions[Condition_Unconcious] != 0; } bool Player::IsAsleep() { return pConditions[Condition_Sleep] != 0; } bool Player::IsParalyzed() { return pConditions[Condition_Paralyzed] != 0; } bool Player::IsDrunk() { return pConditions[Condition_Drunk] != 0; } void Player::SetCursed( bool state ) { pConditions[Condition_Cursed] = state; } void Player::SetWeak( bool state ) { pConditions[Condition_Weak] = state; } void Player::SetAsleep( bool state ) { pConditions[Condition_Sleep] = state; } void Player::SetAfraid( bool state ) { pConditions[Condition_Fear] = state; } void Player::SetDrunk( bool state ) { pConditions[Condition_Drunk] = state; } void Player::SetInsane( bool state ) { pConditions[Condition_Insane] = state; } void Player::SetPoison1( bool state ) { pConditions[Condition_Poison1] = state; } void Player::SetDisease1( bool state ) { pConditions[Condition_Disease1] = state; } void Player::SetPoison2( bool state ) { pConditions[Condition_Poison2] = state; } void Player::SetDisease2( bool state ) { pConditions[Condition_Disease2] = state; } void Player::SetPoison3( bool state ) { pConditions[Condition_Poison3] = state; } void Player::SetDisease3( bool state ) { pConditions[Condition_Disease3] = state; } void Player::SetParalyzed( bool state ) { pConditions[Condition_Paralyzed] = state; } void Player::SetUnconcious( bool state ) { pConditions[Condition_Unconcious] = state; } void Player::SetDead( bool state ) { pConditions[Condition_Dead] = state; } void Player::SetPertified( bool state ) { pConditions[Condition_Pertified] = state; } void Player::SetEradicated( bool state ) { pConditions[Condition_Eradicated] = state; } void Player::SetZombie( bool state ) { pConditions[Condition_Zombie] = state; } void Player::SetCondWeakWithBlockCheck( int blockable ) { SetCondition(Condition_Weak, blockable); } void Player::SetCondInsaneWithBlockCheck( int blockable ) { SetCondition(Condition_Insane, blockable); } void Player::SetCondDeadWithBlockCheck( int blockable ) { SetCondition(Condition_Dead, blockable); } void Player::SetCondUnconsciousWithBlockCheck( int blockable ) { SetCondition(Condition_Dead, blockable); } ItemGen* Player::GetOffHandItem() { return GetItem(&PlayerEquipment::uShield); } ItemGen* Player::GetMainHandItem() { return GetItem(&PlayerEquipment::uMainHand); } ItemGen* Player::GetBowItem() { return GetItem(&PlayerEquipment::uBow); } ItemGen* Player::GetArmorItem() { return GetItem(&PlayerEquipment::uArmor); } ItemGen* Player::GetHelmItem() { return GetItem(&PlayerEquipment::uHelm); } ItemGen* Player::GetBeltItem() { return GetItem(&PlayerEquipment::uBelt); } ItemGen* Player::GetCloakItem() { return GetItem(&PlayerEquipment::uCloak); } ItemGen* Player::GetGloveItem() { return GetItem(&PlayerEquipment::uGlove); } ItemGen* Player::GetBootItem() { return GetItem(&PlayerEquipment::uBoot); } ItemGen* Player::GetAmuletItem() { return GetItem(&PlayerEquipment::uAmulet); } ItemGen* Player::GetNthRingItem(int ringNum) { return GetNthEquippedIndexItem(ringNum + 10); } ItemGen* Player::GetNthEquippedIndexItem(int index) { if (this->pEquipment.pIndices[index] == 0) { return nullptr; } return &this->pInventoryItemList[this->pEquipment.pIndices[index] - 1]; } ItemGen* Player::GetItem(unsigned int PlayerEquipment::* itemPos) { if (this->pEquipment.*itemPos == 0) { return nullptr; } return &this->pInventoryItemList[this->pEquipment.*itemPos - 1]; }