Mercurial > mm7
changeset 1013:0cef8c6aa893
case SPELL_WATER_ENCHANT_ITEM refactor
author | zipi |
---|---|
date | Sun, 19 May 2013 16:18:09 +0100 |
parents | 9e823ad5eaa6 |
children | c8c5224164da |
files | mm7_6.cpp |
diffstat | 1 files changed, 260 insertions(+), 734 deletions(-) [+] |
line wrap: on
line diff
--- a/mm7_6.cpp Sun May 19 12:13:42 2013 +0400 +++ b/mm7_6.cpp Sun May 19 16:18:09 2013 +0100 @@ -2425,10 +2425,7 @@ Actor *pActor; // edi@177 unsigned __int16 v60; // ax@184 int v61; // ecx@184 - int v65; // ecx@189 ItemGen *v69; // esi@211 - int v70; // ecx@214 - int v71; // ecx@215 double v90; // st7@245 Player *v92; // eax@255 int v105; // edi@271 @@ -2443,17 +2440,12 @@ int v116; // edx@279 int v117; // edx@281 int v118; // edx@283 - int v119; // edi@286 signed int v122; // eax@286 int v127; // eax@296 - int v139; // ecx@306 - int v151; // ecx@314 int v153; // ecx@322 int v154; // eax@322 int v155; // eax@323 int v156; // eax@323 - double v158; // st7@326 - double v159; // st6@326 int v162; // edi@340 signed int v164; // eax@340 signed int v165; // edi@340 @@ -2477,27 +2469,15 @@ double v216; // st7@415 double v217; // st6@415 signed __int64 v218; // qtt@423 - Player *v222; // edi@434 char v223; // al@438 int v227; // esi@453 unsigned int v228; // edi@454 int v229; // edi@466 - char *v240; // ecx@472 + ItemGen *v240; // ecx@472 double v241; // st7@478 - signed __int64 v242; // qax@484 - char *v243; // ecx@484 - char *v244; // eax@488 - int v245; // edi@492 - int v246; // eax@492 - char *v247; // eax@497 - char v248; // al@497 - char v249; // cf@500 - float v250; // esi@507 - char v251; // al@507 - int v252; // edx@510 - int m; // esi@510 + ItemGen *v245; // edi@492 int v254; // eax@513 int v255; // esi@513 int v256; // ecx@513 @@ -2507,59 +2487,27 @@ int v260; // eax@518 int v261; // esi@519 int v262; // edx@521 - int v263; // ecx@521 + int *v263; // ecx@521 int v264; // esi@521 int v265; // edx@521 int *ii; // eax@522 int v267; // eax@524 int v268; // eax@524 - int v269; // eax@526 - char *v270; // eax@531 char v271; // al@531 - char v272; // cf@534 - char v274; // al@541 - int v275; // edx@544 - int k; // esi@544 int v277; // edx@548 int v278; // ecx@548 char v279; // al@550 int v280; // eax@552 - int v281; // esi@553 + int *v281; // esi@553 int v282; // edx@555 - int v283; // ecx@555 + int *v283; // ecx@555 int v284; // esi@555 int v285; // edx@555 int *l; // eax@556 - int v287; // eax@558 - int v288; // eax@558 - ItemGen *v289; // eax@560 - signed int v290; // eax@560 - unsigned __int8 v291; // al@564 - char v292; // al@573 - int v293; // eax@575 ItemGen *v294; // esi@575 int v295; // edx@575 int kk; // edi@575 - int v297; // edx@579 - int v298; // ecx@579 - char v299; // al@581 - int v300; // eax@583 - int v301; // edi@584 - int v302; // edx@586 - int v303; // ecx@586 - int v304; // edi@586 - int v305; // edx@586 - int *jj; // eax@587 - int v307; // eax@589 - int v308; // eax@589 - char *v309; // ecx@593 - char v310; // sf@593 - unsigned __int8 v311; // of@593 - char v312; // cl@597 char v313; // al@606pGame->GetStru6() - int v314; // edx@607 - int j; // esi@607 - unsigned int v316; // eax@613 const char *v317; // ecx@617 Player *v318; // ecx@619 unsigned int v319; // edi@627 @@ -2588,11 +2536,11 @@ int v397; // eax@757 int v398; // eax@757 int v399; // eax@757 - int v417; // eax@787 + Actor *v417; // eax@787 int v418; // ecx@789 __int16 v419; // ax@791 signed int v420; // eax@793 - int v421; // edx@793 + ItemGen *v421; // edx@793 const char *v422; // eax@801 signed int v426; // eax@815 Actor *v433; // edi@832 @@ -2620,8 +2568,6 @@ int v507; // edi@944 signed int v509; // eax@944 signed int v510; // edi@944 - Actor *v511; // edi@946 - SpellBuff *v513; // edi@946 Actor *v518; // edx@957 __int16 v519; // cx@958 int v531; // eax@982 @@ -2648,7 +2594,7 @@ char *v585; // esi@1034 signed int v587; // eax@1035 char v591; // al@1048 - int v592; // esi@1052 + ItemGen *v592; // esi@1052 int v596; // esi@1066 unsigned int v597; // edi@1067 int v600; // edi@1086 @@ -2657,7 +2603,7 @@ int v603; // ecx@1086 NPCData *pNPCData; // eax@1089 int v606; // edx@1091 - int v607; // ecx@1100 + AwardType *v607; // ecx@1100 __int16 v608; // ax@1102 signed int v609; // eax@1104 int v610; // edi@1106 @@ -2689,17 +2635,16 @@ int v666; // [sp+4h] [bp-E80h]@12 PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25 int v671; // [sp+4h] [bp-E80h]@146 - const char *v675; // [sp+4h] [bp-E80h]@800 + int v675; // [sp+4h] [bp-E80h]@800 int v676; // [sp+4h] [bp-E80h]@807 int v677; // [sp+4h] [bp-E80h]@861 - int v679; // [sp+14h] [bp-E70h]@515 + int v679[800]; // [sp+14h] [bp-E70h]@515 AIDirection a3; // [sp+C94h] [bp-1F0h]@21 int v681[4]; // [sp+CB0h] [bp-1D4h]@1137 int v682[4]; // [sp+CC0h] [bp-1C4h]@731 ItemGen v683; // [sp+CD0h] [bp-1B4h]@791 int v684; // [sp+D04h] [bp-180h]@416 unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416 - int x; // [sp+D20h] [bp-164h]@327 unsigned __int64 v687; // [sp+D24h] [bp-160h]@327 Vec3_int_ v688; // [sp+D2Ch] [bp-158h]@943 Vec3_int_ v691; // [sp+D38h] [bp-14Ch]@137 @@ -3136,7 +3081,7 @@ pSpellSprite.uAttributes |= 0x80u; pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); auto obj_id = pSpellSprite.Create(0, 0, 0, 0); - if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) ) + if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); @@ -3657,8 +3602,7 @@ v701.y = 0; v701.z = 0; pSpellSprite.stru_24.Reset(); - v119 = HIDWORD(v733); - pSpellSprite.spell_id = *(int *)HIDWORD(v733); + pSpellSprite.spell_id = pCastSpell->spellnum; pSpellSprite.spell_level = v723; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3666,9 +3610,9 @@ pSpellSprite.uSectorID = 0; pSpellSprite.uSpriteFrameID = 0; pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, *(short *)(v119 + 2)); + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); pSpellSprite.uFacing = 0; - pSpellSprite.uSoundID = *(short *)(v119 + 16); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); pSpellSprite.vPosition.x = v112->vPosition.x; pSpellSprite.vPosition.y = v112->vPosition.y; pSpellSprite.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v112->uActorHeight * unk_4D8548); @@ -3681,9 +3625,9 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - *(int *)HIDWORD(v733) = 0; + pCastSpell->spellnum = 0; } - pCastSpell = (CastSpellInfo *)HIDWORD(v733); + //pCastSpell = (CastSpellInfo *)HIDWORD(v733); } break; } @@ -3735,7 +3679,7 @@ } case SPELL_FIRE_IMMOLATION: { - if ( v731 == 4 && v139 == 1 ) + if ( v731 == 4 ) LODWORD(v733) = 600 * v2; else LODWORD(v733) = 60 * v2; @@ -3755,14 +3699,14 @@ { //v149 = v731 - 1; //if ( v149 && (v150 = v149 - 1) != 0 && (v151 = v150 - 1) != 0 ) + int i; if ( v731 == 4 ) { - if ( v151 == 1 ) - _this = (ItemGen *)20; + i = 20; } else { - _this = (ItemGen *)16; + i = 16; } if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { @@ -3789,40 +3733,27 @@ LODWORD(v727) = pParty->vPosition.y + sub_42EBBE(2048, v156); v154 = pParty->vPosition.z; } - HIDWORD(v733) = v154; - v713 = v154 + 2500; - v721 = 0; - LODWORD(v718) = 0; - if ( (signed int)_this > 0 ) - { - *(float *)&y = (double)SHIDWORD(v733); - *(float *)&v732 = (double)v713; + unsigned __int64 k = 0; + int j = 0; + if ( (signed int)i > 0 ) + { v730 = LODWORD(v725) == 3 ? a2 : 0; - auto _this_cpy = (int)_this; do { - //v157 = rand(); - v158 = (double)SLODWORD(v718); - v718 = v158; - v159 = (double)v721; - *(float *)&v721 = v159; a2 = rand() % 1000; - *((float *)&v733 + 1) = (double)(rand() % 1000) + *(float *)&y - *(float *)&v732; - //v725 = v159 * v159; - *(float *)&_this = v158 * v158; - //if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&_this + v725) <= 1.0 ) - if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&_this + v159 * v159) <= 1.0 ) + if ( sqrt((double)(rand() % 1000) - 2500 * + (double)(rand() % 1000) - 2500 + + j * j + k * k) <= 1.0 ) { LODWORD(v687) = 0; HIDWORD(v687) = 0; } else { - //x = (signed __int64)sqrt(*(float *)&_this + v725); - x = (signed __int64)sqrt(*(float *)&_this + v159 * v159); v687 = __PAIR__( - stru_5C6E00->Atan2(x, (signed __int64)*((float *)&v733 + 1)), - stru_5C6E00->Atan2((signed __int64)v718, (signed __int64)*(float *)&v721)); + stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), + (double)(rand() % 1000) - 2500), + stru_5C6E00->Atan2(j, k)); } pSpellSprite.stru_24.Reset(); pSpellSprite.spell_id = pCastSpell->spellnum; @@ -3845,12 +3776,10 @@ if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - LODWORD(v718) = rand() % 1024 - 512; - //v160 = rand(); - v14 = _this_cpy-- == 1; - v721 = (unsigned __int64)(rand() % 1024) - 512; + j = rand() % 1024 - 512; + k = rand() % 1024 - 512; } - while ( !v14 ); + while ( i-- != 1 ); } LODWORD(v727) = 1; break; @@ -4113,7 +4042,7 @@ v713 = pParty->vPosition.y + v214; v208 = LODWORD(v725); } - HIDWORD(v733) = 0; + signed int _v733 = 0; *(float *)&v732 = (double)v211; LODWORD(v725) = v211 + 2500; v721 = 0; @@ -4124,7 +4053,7 @@ { v215 = rand(); v216 = (double)v721; - v217 = (double)SHIDWORD(v733); + v217 = (double)_v733; *(float *)&uRequiredMana = v217; _this = (ItemGen *)(v215 % 1000); *((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y; @@ -4167,7 +4096,7 @@ v721 = rand() % 1024 - 512; v218 = rand(); v14 = a2-- == 1; - HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512; + _v733 = (unsigned __int64)(v218 % 1024) - 512; } while ( !v14 ); LODWORD(v727) = 1; @@ -4186,9 +4115,6 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - v222 = pParty->pPlayers; - HIDWORD(v733) = (int)pParty->pPlayers;//(int)(char *)&pParty + 2508; - //while ( 2 ) for( int i=0; i < 4; i++ ) { pPlayer = &pParty->pPlayers[i]; @@ -4227,7 +4153,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - HIDWORD(v733) = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; + signed int _v733 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; if ( amount == 1 ) { pSpellSprite.stru_24.Reset(); @@ -4277,8 +4203,8 @@ if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(pSpellSprite.uAttributes) |= 4u; v227 = SHIDWORD(v733) / -2; - y = (char *)(SHIDWORD(v733) / 2); - if ( SHIDWORD(v733) / -2 <= SHIDWORD(v733) / 2 ) + signed int _y = _v733 / 2; + if ( _v733 / -2 <= _v733 / 2 ) { v228 = v715.uYawAngle; do @@ -4291,9 +4217,9 @@ pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v227 += SHIDWORD(v733) / (amount - 1); + v227 += _v733 / (amount - 1); } - while ( v227 <= (signed int)y ); + while ( v227 <= _y ); } } LODWORD(v727) = 1; @@ -4335,9 +4261,9 @@ { if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - v240 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2]; - y = v240; - if ( pItemsTable->pItems[*(int *)v240].uEquipType != 12 || v240[20] & 2 ) + v240 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2]; + + if ( pItemsTable->pItems[v240->uItemID].uEquipType != 12 || v240->uAttributes & 2 ) { dword_50C9D0 = 113; dword_50C9D4 = 0; @@ -4366,15 +4292,12 @@ } if ( v241 > 1.0 ) v241 = 1.0; - //LABEL_484: - v732 = (unsigned __int8)v240[25]; - v242 = (signed __int64)((double)v732 * v241); - v243 = y; - y[25] = v242; - *((int *)v243 + 4) = (unsigned __int8)v242; - if ( (unsigned __int8)v242 <= 0 ) - { - *(int *)v243 = 0; + int uNewCharges = v240->uMaxCharges * v241; + v240->uMaxCharges = uNewCharges; + v240->uNumCharges = uNewCharges; + if ( uNewCharges <= 0 ) + { + v240 = 0; dword_50C9D0 = 113; dword_50C9D4 = 0; dword_50C9D8 = 1; @@ -4384,7 +4307,7 @@ v2 = v723; continue; } - *((int *)v243 + 5) |= 0x40u; + v240->uAttributes |= 0x40u; _50C9A8_item_enchantment_timer = 256; LODWORD(v727) = 1; break; @@ -4394,465 +4317,59 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; uRequiredMana = 0; - HIDWORD(v733) = 10 * v2; + amount = 10 * v2; v730 = 1; - v244 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2]; - if ( v731 == 1 ) - { - v245 = (int)&v244[36 * a2 + 532]; - v309 = (char *)&pItemsTable->pItems[*(int *)v245].pIconName; - v311 = __OFSUB__(*(int *)v245, 134); - v14 = *(int *)v245 == 134; - v310 = *(int *)v245 - 134 < 0; - LODWORD(v725) = (int)(char *)&pItemsTable + 48 * *(int *)v245 + 4; - if ( (unsigned __int8)(v310 ^ v311) | v14 ) + pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2]; + v245 = &pPlayer->pInventoryItems[a2]; + ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID]; + if ( + v731 == 1 || v731 == 2 && _v725->uEquipType > 2 || + v731 == 3 || v731 == 4 && + v245->uItemID <= 134 && + v245->uSpecEnchantmentType == 0 && + v245->uEnchantmentType == 0 && + v245->_bonus_strength== 0 && + !v245->Broken() ) + { + if ( v245->GetValue() < 450 || + (v245->GetValue() < 250 && (v731 == 3 || v731 == 4) && _v725->uEquipType >= 0 && _v725->uEquipType <= 2) + ) { - if ( *(int *)&v244[36 * a2 + 544] == 0 ) - { - if ( *(int *)&v244[36 * a2 + 536] == 0 ) - { - if ( *(int *)&v244[36 * a2 + 540] == 0 ) - { - v312 = v309[28]; - if ( v312 ) - { - if ( v312 != 1 ) - { - if ( v312 != 2 ) - { - _this = (ItemGen *)&v244[36 * a2 + 552]; - if ( !(v244[36 * a2 + 552] & 2) ) - { - if ( ((ItemGen *)v245)->GetValue() < 0x1C2 ) - { - uRequiredMana = 1; - v730 = 0; - } - if ( rand() % 100 >= SHIDWORD(v733) ) - uRequiredMana = 1; - if (!uRequiredMana) - { - v313 = *(char *)(LODWORD(v725) + 28); - if ( v313 == 3 | v313 == 4 | v313 == 5 | v313 == 6 | v313 == 7 | v313 == 8 | v313 == 9 | v313 == 10 | v313 == 11 ) - { - v314 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType]; - *(int *)(v245 + 4) = 0; - for ( j = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType - + 1]; - ; - j += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType - + 1] ) - { - ++*(int *)(v245 + 4); - if ( j >= v314 ) - break; - } - v254 = rand(); - v255 = 10;//pItemsTable->field_116D8[17]; - v256 = 10;//pItemsTable->field_116D8[16]; - //LABEL_611: - *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1); - //LABEL_612: - _this->uItemID |= 0x20u; - - _50C9A8_item_enchantment_timer = 256; - LODWORD(v727) = 1; - break; - } - } - else - { - //LABEL_613: - v316 = _this->uItemID; - if ( !(BYTE1(v316) & 2) ) - { - LOBYTE(v316) = v316 | 2; - _this->uItemID = v316; - } - } - } - } - } - } - } - } - } - } - //LABEL_616: - if ( LODWORD(v727) == 0 ) - { - v317 = pGlobalTXT_LocalizationStrings[428]; - if ( v730 == 0 ) - v317 = pGlobalTXT_LocalizationStrings[585]; - ShowStatusBarString(v317, 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); + v730 = 0; } - } - else if ( v731 == 2 ) - { - v289 = (ItemGen *)&v244[36 * a2 + 532]; - _this = v289; - v290 = v289->uItemID; - LODWORD(v725) = (int)(char *)&pItemsTable + 48 * v290 + 4; - if ( v290 > 134 - || _this->uSpecEnchantmentType != 0 - || _this->uEnchantmentType != 0 - || _this->_bonus_strength != 0 - || (v291 = pItemsTable->pItems[v290].uEquipType) == 0 - || v291 == 1 - || v291 == 2 - || _this->Broken()) - { - if ( LODWORD(v727) == 0 ) - { - v317 = pGlobalTXT_LocalizationStrings[428]; - if ( v730 == 0 ) - v317 = pGlobalTXT_LocalizationStrings[585]; - ShowStatusBarString(v317, 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); - } - break; - } - if ( _this->GetValue() < 0x1C2 ) - uRequiredMana = 1; - if ( rand() % 100 >= SHIDWORD(v733) ) - uRequiredMana = 1; - if ( uRequiredMana != 0 ) - { - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 1; - - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; - continue; - } - v292 = *(char *)(LODWORD(v725) + 28); - if ( !(v292 == 3 | v292 == 4 | v292 == 5 | v292 == 6 | v292 == 7 | v292 == 8 | v292 == 9 | v292 == 10 | v292 == 11) ) + if ( rand() % 100 < 10 * v2 || + (rand() % 100 < 80 && (v731 == 3 || v731 == 4 )) || + v245->GetValue() < 450 || + (v245->GetValue() < 250 && (v731 == 3 || v731 == 4) && v271 >= 0 && v271 <= 2) + ) { - v2 = v723; - //v1 = 0; - - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 1; - - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; - continue; - } - if ( rand() % 100 >= 80 ) - { - v297 = pItemsTable->pSpecialEnchantments_count; - v294 = _this; - v298 = 0; - v725 = 0.0; - HIDWORD(v733) = 0; - if ( pItemsTable->pSpecialEnchantments_count > 0 ) + v313 = _v725->uEquipType; + if ( _v725->uEquipType >= 3 && _v725->uEquipType <= 11 ) { - v730 = (int)&v679; - do + v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; + v245->uEnchantmentType = 0; + for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1]; + ; + kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1] ) { - v299 = LOBYTE(pItemsTable->pSpecialEnchantments[v298 + 1].pBonusStatement); - if ( !v299 || v299 == 1 ) - { - v300 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4] - + v298 * 28); - LODWORD(v725) += v300; - if ( v300 ) - { - v301 = v730; - v730 += 4; - *(int *)v301 = HIDWORD(v733); - } - } - ++HIDWORD(v733); - ++v298; - } - while ( SHIDWORD(v733) < v297 ); - } - v302 = rand() % SLODWORD(v725); - v303 = v679; - v294->uSpecEnchantmentType = v679; - v304 = pItemsTable->pSpecialEnchantments[v303].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; - v305 = v302 + 1; - if ( v304 < v305 ) - { - for ( jj = &v679; ; jj = (int *)v732 ) - { - v307 = (int)(jj + 1); - v732 = v307; - v308 = *(int *)v307; - v294->uSpecEnchantmentType = v308; - v304 += pItemsTable->pSpecialEnchantments[v308].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; - if ( v304 >= v305 ) + ++v245->uEnchantmentType; + if ( kk >= v295 ) break; } - } - ++v294->uSpecEnchantmentType; - } - else - { - v293 = rand(); - v294 = _this; - v295 = v293 % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; - _this->uEnchantmentType = 0; - for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + 1]; - ; - kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[pItemsTable->pItems[v294->uItemID].uEquipType - + 1] ) - { - ++v294->uEnchantmentType; - if ( kk >= v295 ) - break; - } - v294->_bonus_strength = 10//pItemsTable->field_116D8[18] - + rand() % 10;//(pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1); - } - v294->uAttributes |= 0x20u; - _50C9A8_item_enchantment_timer = 256; - LODWORD(v727) = 1; - } - else if ( v731 == 3 ) - { - v245 = (int)&v244[36 * a2 + 532]; - v269 = *(int *)v245; - if ( *(int *)v245 > 134 - || *(int *)(v245 + 12) != 0 - || *(int *)(v245 + 4) != 0 - || *(int *)(v245 + 8) != 0 - || (_this = (ItemGen *)(v245 + 20), *(char *)(v245 + 20) & 2) ) - { - if ( LODWORD(v727) == 0 ) - { - v317 = pGlobalTXT_LocalizationStrings[428]; - if ( v730 == 0 ) - v317 = pGlobalTXT_LocalizationStrings[585]; - ShowStatusBarString(v317, 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); - } - break; - } - v270 = (char *)&pItemsTable->pItems[v269].pIconName; - LODWORD(v725) = (int)v270; - v271 = v270[28]; - if ( v271 && v271 != 1 && v271 != 2 ) - v272 = ((ItemGen *)v245)->GetValue() < 0x1C2; - else - v272 = ((ItemGen *)v245)->GetValue() < 0xFA; - if ( v272 ) - { - uRequiredMana = 1; - v730 = 0; - } - if ( rand() % 100 >= SHIDWORD(v733) ) - uRequiredMana = 1; - if (uRequiredMana) - { - v316 = _this->uItemID; - if ( !(BYTE1(v316) & 2) ) - { - LOBYTE(v316) = v316 | 2; - _this->uItemID = v316; - } - if ( LODWORD(v727) == 0 ) - { - v317 = pGlobalTXT_LocalizationStrings[428]; - if ( v730 == 0 ) - v317 = pGlobalTXT_LocalizationStrings[585]; - ShowStatusBarString(v317, 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); - } - break; - } - //v273 = v725; - v274 = *(char *)(LODWORD(v725) + 28); - if ( v274 == 0 | v274 == 1 | v274 == 2 | v274 == 3 | v274 == 4 | v274 == 5 | v274 == 6 | v274 == 7 | v274 == 8 | v274 == 9 | v274 == 10 | v274 == 11 ) - { - if ( rand() % 100 < 80 - //&& !(*(char *)(LODWORD(v273) + 28) == 0 | *(char *)(LODWORD(v273) + 28) == 1 | *(char *)(LODWORD(v273) + 28) == 2) ) - && !(*(char *)(LODWORD(v725) + 28) == 0 | *(char *)(LODWORD(v725) + 28) == 1 | *(char *)(LODWORD(v725) + 28) == 2) ) - { - v275 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType]; - *(int *)(v245 + 4) = 0; - for ( k = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1]; - ; - k += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType - + 1] ) - { - ++*(int *)(v245 + 4); - if ( k >= v275 ) - break; - } - v254 = rand(); - v255 = 10;//pItemsTable->field_116D8[19]; - v256 = 10;//pItemsTable->field_116D8[18]; - *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1); - _this->uItemID |= 0x20u; - + v255 = 10;//pItemsTable->field_116D8[17]; + v256 = 10;//pItemsTable->field_116D8[16]; + v245->_bonus_strength = v256 + rand() % (v255 - v256 + 1); + v245->uAttributes |= 0x20u; _50C9A8_item_enchantment_timer = 256; LODWORD(v727) = 1; break; } - v277 = pItemsTable->pSpecialEnchantments_count; - v278 = 0; - v725 = 0.0; - HIDWORD(v733) = 0; - if ( pItemsTable->pSpecialEnchantments_count > 0 ) - { - v730 = (int)&v679; - do - { - v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278 + 1].pBonusStatement); - if ( !v279 || v279 == 1 ) - { - v280 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType - + 4] - + v278 * 28); - LODWORD(v725) += v280; - if ( v280 ) - { - v281 = v730; - v730 += 4; - *(int *)v281 = HIDWORD(v733); - } - } - ++HIDWORD(v733); - ++v278; - } - while ( SHIDWORD(v733) < v277 ); - } - v282 = rand() % SLODWORD(v725); - v283 = v679; - *(int *)(v245 + 12) = v679; - v284 = pItemsTable->pSpecialEnchantments[v283].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; - v285 = v282 + 1; - if ( v284 < v285 ) - { - for ( l = &v679; ; l = (int *)v732 ) - { - v287 = (int)(l + 1); - v732 = v287; - v288 = *(int *)v287; - *(int *)(v245 + 12) = v288; - v284 += pItemsTable->pSpecialEnchantments[v288].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType - + 4]; - if ( v284 >= v285 ) - break; - } - } - ++*(int *)(v245 + 12); - _this->uItemID |= 0x20u; - - _50C9A8_item_enchantment_timer = 256; - LODWORD(v727) = 1; - break; - } - } - else if ( v731 == 4 ) - { - __debugbreak(); // v726 is most probably the caster, filled in case 54 - if ( v731 != 4 - || (v245 = (int)&v726->pInventoryItems[a2], v246 = *(int *)v245, *(int *)v245 > 134) - || v726->pInventoryItems[a2].uSpecEnchantmentType != 0 - || v726->pInventoryItems[a2].uEnchantmentType != 0 - || v726->pInventoryItems[a2]._bonus_strength != 0 - || (_this = (ItemGen *)((char *)&v726->pInventoryItems[a2] + 20), v726->pInventoryItems[a2].Broken()) ) - { - if ( LODWORD(v727) == 0 ) + else if ( v731 == 3 || v731 == 4) { - v317 = pGlobalTXT_LocalizationStrings[428]; - if ( v730 == 0 ) - v317 = pGlobalTXT_LocalizationStrings[585]; - ShowStatusBarString(v317, 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); - } - break; - } - v247 = (char *)&pItemsTable->pItems[v246].pIconName; - LODWORD(v725) = (int)v247; - v248 = v247[28]; - if ( v248 && v248 != 1 && v248 != 2 ) - v249 = v726->pInventoryItems[a2].GetValue() < 0x1C2; - else - v249 = v726->pInventoryItems[a2].GetValue() < 0xFA; - if ( v249 ) - { - uRequiredMana = 1; - v730 = 0; - } - if ( rand() % 100 >= SHIDWORD(v733) ) - uRequiredMana = 1; - if (uRequiredMana) - { - v316 = _this->uItemID; - if ( !(BYTE1(v316) & 2) ) - { - LOBYTE(v316) = v316 | 2; - _this->uItemID = v316; - } - if ( LODWORD(v727) == 0 ) - { - v317 = pGlobalTXT_LocalizationStrings[428]; - if ( v730 == 0 ) - v317 = pGlobalTXT_LocalizationStrings[585]; - ShowStatusBarString(v317, 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); - } - break; - } - v250 = v725; - v251 = *(char *)(LODWORD(v725) + 28); - if ( v251 == 0 | v251 == 1 | v251 == 2 | v251 == 3 | v251 == 4 | v251 == 5 | v251 == 6 | v251 == 7 | v251 == 8 | v251 == 9 | v251 == 10 | v251 == 11 ) - { - if ( rand() % 100 < 80 - && !(*(char *)(LODWORD(v250) + 28) == 0 | *(char *)(LODWORD(v250) + 28) == 1 | *(char *)(LODWORD(v250) + 28) == 2) ) - { - v252 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType]; - *(int *)(v245 + 4) = 0; - for ( m = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1]; - ; - m += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType - + 1] ) - { - ++*(int *)(v245 + 4); - if ( m >= v252 ) - break; - } - v254 = rand(); - v255 = 10;// pItemsTable->field_116D8[21]; - v256 = 10;//pItemsTable->field_116D8[20]; - *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1); - _this->uItemID |= 0x20u; - - _50C9A8_item_enchantment_timer = 256; - LODWORD(v727) = 1; - break; - } v257 = pItemsTable->pSpecialEnchantments_count; v258 = 0; v725 = 0.0; - HIDWORD(v733) = 0; + int _v733 = 0; if ( pItemsTable->pSpecialEnchantments_count > 0 ) { v730 = (int)&v679; @@ -4869,22 +4386,22 @@ { v261 = v730; v730 += 4; - *(int *)v261 = HIDWORD(v733); + *(int *)v261 = _v733; } } - ++HIDWORD(v733); + ++_v733; ++v258; } - while ( SHIDWORD(v733) < v257 ); + while ( _v733 < v257 ); } v262 = rand() % SLODWORD(v725); v263 = v679; - *(int *)(v245 + 12) = v679; - v264 = pItemsTable->pSpecialEnchantments[v263].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; + v245->uSpecEnchantmentType = v679[0]; + v264 = pItemsTable->pSpecialEnchantments[*v263].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; v265 = v262 + 1; if ( v264 < v265 ) { - for ( ii = &v679; ; ii = (int *)v732 ) + for ( ii = v679; ; ii = (int *)v732 ) { v267 = (int)(ii + 1); v732 = v267; @@ -4896,28 +4413,72 @@ break; } } - ++*(int *)(v245 + 12); - _this->uItemID |= 0x20u; - - _50C9A8_item_enchantment_timer = 256; - LODWORD(v727) = 1; - break; + + v277 = pItemsTable->pSpecialEnchantments_count; + v278 = 0; + v725 = 0.0; + _v733 = 0; + if ( pItemsTable->pSpecialEnchantments_count > 0 ) + { + int *_v730 = v679; + do + { + v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278].pBonusStatement); + if ( !v279 || v279 == 1 ) + { + v280 = *(&pItemsTable->pSpecialEnchantments[v278].to_item_apply[pItemsTable->pItems[v245->uItemID].uEquipType]); + _v733 += v280; + if ( v280 ) + { + v281 = _v730; + ++_v730; + *v281 = _v733; + } + } + ++_v733; + ++v278; + } + while ( _v733 < v277 ); + } + v282 = rand() % _v733; + v283 = v679; + v245->uSpecEnchantmentType = v679[0]; + v284 = pItemsTable->pSpecialEnchantments[*v283].to_item_apply[pItemsTable->pItems[v245->uItemID].uEquipType ]; + v285 = v282 + 1; + for ( l = v679; v284 < v285; ++l ) + { + v245->uSpecEnchantmentType = *(l+1); + v284 += pItemsTable->pSpecialEnchantments[*(l+1)].to_item_apply[pItemsTable->pItems[v245->uItemID].uEquipType]; + } + ++v245->uSpecEnchantmentType; + v245->uAttributes |= 0x20u; + _50C9A8_item_enchantment_timer = 256; + LODWORD(v727) = 1; + break; + } } - } - else - { - if ( LODWORD(v727) == 0 ) + else { - v317 = pGlobalTXT_LocalizationStrings[428]; - if ( v730 == 0 ) - v317 = pGlobalTXT_LocalizationStrings[585]; - ShowStatusBarString(v317, 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); + if ( !(BYTE1(v245->uAttributes) & 2) ) + { + v245->uAttributes |= 2; + } } - } + + } + + if ( LODWORD(v727) == 0 ) + { + v317 = pGlobalTXT_LocalizationStrings[428]; + if ( v730 == 0 ) + v317 = pGlobalTXT_LocalizationStrings[585]; + ShowStatusBarString(v317, 2u); + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; + pCastSpell->spellnum = 0; + v318->PlaySound(SPEECH_43, 0); + } + break; } case SPELL_WATER_TOWN_PORTAL: @@ -5291,7 +4852,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v381 = 0; - HIDWORD(v733) = amount; + signed int _v733 = amount; v730 = 0; v382 = 1; do @@ -5307,17 +4868,17 @@ if ( v381 > 0 ) { do - HIDWORD(v733) += pPlayers[v682[v384++]]->sHealth; + _v733 += pPlayers[v682[v384++]]->sHealth; while ( v384 < v381 ); } - v732 = (signed __int64)((double)SHIDWORD(v733) / (double)v730); - HIDWORD(v733) = 0; + v732 = (signed __int64)((double)_v733 / (double)v730); + _v733 = 0; if ( v381 > 0 ) { do { //v385 = (ItemGen **)&pPlayers[v682[HIDWORD(v733)]]; - v726 = pPlayers[v682[HIDWORD(v733)]]; + v726 = pPlayers[v682[_v733]]; v726->sHealth = v732; //v386 = v726->GetMaxHealth(); if ( v726->sHealth > v726->GetMaxHealth()) @@ -5326,10 +4887,10 @@ { v726->pConditions[Player::Condition_Unconcious] = 0; } - v388 = HIDWORD(v733); - - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, LOWORD(v682[HIDWORD(v733)]) - 1); - HIDWORD(v733) = v388 + 1; + v388 = _v733; + + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, LOWORD(v682[_v733]) - 1); + _v733 = v388 + 1; } while ( v388 + 1 < v730 ); } @@ -5466,22 +5027,22 @@ LODWORD(v727) = 1; break; } - v417 = (int)&pActors[PID_ID(a2)]; - v730 = v417; - if ( !(*(char *)(v417 + 38) & 0x80) ) - { - ((Actor *)v417)->SetRandomGoldIfTheresNoItem(); - v417 = v730; - } - v418 = *(int *)(v417 + 672); - HIDWORD(v733) = 0; + v417 = &pActors[PID_ID(a2)]; + Actor * _v730 = v417; + if ( !(BYTE2(v417->uAttributes) & 0x80) ) + { + v417->SetRandomGoldIfTheresNoItem(); + v417 = _v730; + } + v418 = v417->array_000234[3].uItemID; + signed int _v733 = 0; if ( pItemsTable->pItems[v418].uEquipType == 18 ) - HIDWORD(v733) = *(int *)(v417 + 684); + _v733 = v417->array_000234[3].uSpecEnchantmentType; //ItemGen::ItemGen(&v683); v683.Reset(); - v419 = *(short *)(v730 + 180); + v419 = _v730->uCarriedItemID; if (v419) { v683.uItemID = v419; @@ -5490,97 +5051,63 @@ else { v420 = 0; - v421 = v730 + 564; - while ( !*(int *)v421 || pItemsTable->pItems[*(int *)v421].uEquipType == 18 ) + v421 = _v730->array_000234; + while ( !v421->uItemID || pItemsTable->pItems[v421->uItemID].uEquipType == 18 ) { ++v420; - v421 += 36; + ++v421; if ( v420 >= 4 ) break; } if ( v420 < 4 ) { - memcpy(&v683, (const void *)(v730 + 36 * v420 + 564), sizeof(v683)); + memcpy(&v683, &_v730->array_000234[v420], sizeof(v683)); v2 = v723; //v1 = 0; } } // LABEL_799: - if ( HIDWORD(v733) != 0 ) - { - v675 = (const char *)HIDWORD(v733); + if ( _v733 != 0 ) + { + v675 = _v733; if (v683.uItemID) { v422 = v683.GetDisplayName(); sprintf(pTmpBuf2, "(%s), and %d gold", v422, v675); - ShowStatusBarString(pTmpBuf2, 2u); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = *(short *)(v730 + 142); - pSpellSprite.vPosition.y = *(short *)(v730 + 144); - v676 = *(short *)(v730 + 138); - v665 = pSpellSprite.vPosition.y; - pSpellSprite.vPosition.z = *(short *)(v730 + 138); - v657 = pSpellSprite.vPosition.x; + } else { v664 = "%d gold"; sprintf(pTmpBuf2, v664, v675); - ShowStatusBarString(pTmpBuf2, 2u); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = *(short *)(v730 + 142); - pSpellSprite.vPosition.y = *(short *)(v730 + 144); - v676 = *(short *)(v730 + 138); - v665 = pSpellSprite.vPosition.y; - pSpellSprite.vPosition.z = *(short *)(v730 + 138); - v657 = pSpellSprite.vPosition.x; } } else { if (v683.uItemID) { - v675 = v683.GetDisplayName(); + const char *_v675 = v683.GetDisplayName(); v664 = "(%s)"; - sprintf(pTmpBuf2, v664, v675); - ShowStatusBarString(pTmpBuf2, 2u); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = *(short *)(v730 + 142); - pSpellSprite.vPosition.y = *(short *)(v730 + 144); - v676 = *(short *)(v730 + 138); - v665 = pSpellSprite.vPosition.y; - pSpellSprite.vPosition.z = *(short *)(v730 + 138); - v657 = pSpellSprite.vPosition.x; + sprintf(pTmpBuf2, v664, _v675); } else { strcpy(pTmpBuf2, "nothing"); ShowStatusBarString(pTmpBuf2, 2u); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = *(short *)(v730 + 142); - pSpellSprite.vPosition.y = *(short *)(v730 + 144); - v676 = *(short *)(v730 + 138); - v665 = pSpellSprite.vPosition.y; - pSpellSprite.vPosition.z = *(short *)(v730 + 138); - v657 = pSpellSprite.vPosition.x; } } + ShowStatusBarString(pTmpBuf2, 2u); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_level = v2; + pSpellSprite.spell_skill = v731; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = _v730->vPosition.x; + pSpellSprite.vPosition.y = _v730->vPosition.y; + v676 = _v730->uActorHeight; + v665 = pSpellSprite.vPosition.y; + pSpellSprite.vPosition.z = _v730->uActorHeight; + v657 = pSpellSprite.vPosition.x; pSpellSprite.uAttributes = 0; pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676); pSpellSprite.uSpriteFrameID = 0; @@ -6107,7 +5634,7 @@ pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u); v505 = sub_46A6AC((int)dword_50BF30, 100, 4096); ++pSpellSprite.uType; - HIDWORD(v733) = v505; + signed int _v733 = v505; v688.x = 0; v688.y = 0; v688.z = 0; @@ -6124,7 +5651,7 @@ pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); a2 = 0; - if ( SHIDWORD(v733) > 0 ) + if ( _v733 > 0 ) { do { @@ -6135,24 +5662,22 @@ pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v509 = pSpellSprite.Create(0, 0, 0, 0); v510 = a2; - DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], (Vec3_int_ *)&v688); + DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], &v688); a2 = v510 + 1; } - while ( v510 + 1 < SHIDWORD(v733) ); - } - for ( a2 = 0; a2 < SHIDWORD(v733); ++a2 ) - { - v511 = &pActors[dword_50BF30[a2]]; - pSpellSprite.vPosition.x = v511->vPosition.x; - pSpellSprite.vPosition.y = v511->vPosition.y; - pSpellSprite.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v511->uActorHeight * unk_4D8548); + while ( v510 + 1 < _v733 ); + } + for ( a2 = 0; a2 < _v733; ++a2 ) + { + pActor = &pActors[dword_50BF30[a2]]; + pSpellSprite.vPosition.x = pActor->vPosition.x; + pSpellSprite.vPosition.y = pActor->vPosition.y; + pSpellSprite.vPosition.z = pActor->vPosition.z - (unsigned int)(signed __int64)((double)pActor->uActorHeight * unk_4D8548); pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); pSpellSprite.Create(0, 0, 0, 0); - v513 = v511->pActorBuffs; - for (int _v726 = 22; _v726 != 0; --_v726) + for (int i = 0; i < 22; ++i) { - v513->Reset(); - ++v513; + pActor->pActorBuffs[i].Reset(); } } LODWORD(v727) = 1; @@ -6170,7 +5695,7 @@ assert(false); } //v733 = __PAIR__(0, v516); - + signed int _v733 = 0; if ( (signed int)uNumActors > 0 ) { v518 = pActors;//[0].uAIState; @@ -6179,13 +5704,13 @@ { v519 = v518->uAIState; if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, pCastSpell->uPlayerID) == v518->uSummonerID ) - ++HIDWORD(v733); + ++_v733; ++v518; --_v726; } while ( _v726 != 0 ); } - if ( SHIDWORD(v733) >= amount ) + if ( _v733 >= amount ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); @@ -6325,12 +5850,12 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - y = (char *)(60 * (v2 * HIDWORD(v733) + 60)); + y = (char *)(60 * (v2 * LODWORD(v733) + 60)); v732 = (300 * amount * v2 + 60) << 7; v730 = v2 + 5; int _v726 = 0; v553 = pParty->pPlayers;//[0].pConditions[1]; - *((float *)&v733 + 1) = (double)v732 * 0.033333335; + *((float *)&v733) = (double)v732 * 0.033333335; do { pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); @@ -6339,16 +5864,16 @@ pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); //((SpellBuff *)(v553 + 6056))->Apply( - v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v730, 0, 0); + v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v731, v730, 0, 0); if ( *(_QWORD *)v553 ) _v726 = 1; ++v553; } while ( v553 <= &pParty->pPlayers[3] ); v562 = v731; - pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v730, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v562, 0, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v562, v730, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v731, v730, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v562, 0, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v562, v730, 0, 0); if (!_v726) { pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply((signed __int64)((double)(signed int)((int)y << 7) * 0.033333335 + (double)(signed __int64)pParty->uTimePlayed), v562, v730, 0, 0); @@ -6501,15 +6026,16 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; __debugbreak(); - HIDWORD(v733) = (int)(char *)&pParty + 6972 * pCastSpell->uPlayerID_2 + 36 * a2 + 3040; - v732 = (signed int)&pItemsTable->pItems[*(int *)HIDWORD(v733)].pIconName; - ((ItemGen *)HIDWORD(v733))->UpdateTempBonus(pParty->uTimePlayed); - if ( *(int *)HIDWORD(v733) >= 64 && *(int *)HIDWORD(v733) <= 65 - || *(char *)(HIDWORD(v733) + 20) & 2 - || *(int *)(HIDWORD(v733) + 12) != 0 - || *(int *)(HIDWORD(v733) + 4) != 0 - || (v591 = *(char *)(v732 + 28)) != 0 && v591 != 1 && v591 != 2 - || pItemsTable->IsMaterialNonCommon((ItemGen *)HIDWORD(v733)) ) + //HIDWORD(v733) = (int)(char *)&pParty + 6972 * pCastSpell->uPlayerID_2 + 36 * a2 + 3040; + ItemGen *_v733 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2]; + ItemDesc *_v732 = &pItemsTable->pItems[_v733->uItemID]; + _v733->UpdateTempBonus(pParty->uTimePlayed); + if ( _v733->uItemID >= 64 && _v733->uItemID <= 65 + || LOBYTE(_v733->uAttributes) & 2 + || _v733->uSpecEnchantmentType != 0 + || _v733->uEnchantmentType != 0 + || (v591 = _v732->uEquipType) != 0 && v591 != 1 && v591 != 2 + || pItemsTable->IsMaterialNonCommon(_v733) ) { dword_50C9D0 = 113; dword_50C9D4 = 0; @@ -6520,16 +6046,16 @@ pCastSpell->spellnum = 0; continue; } - v592 = HIDWORD(v733); + v592 = _v733; v14 = v731 == 4; - *(int *)(HIDWORD(v733) + 12) = 16; + _v733->uSpecEnchantmentType = 16; if ( !v14 ) { v732 = (int)v733 << 7; - *(_QWORD *)(v592 + 28) = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); - *(int *)(v592 + 20) |= 8u; - } - *(char *)(v592 + 20) |= 0x80u; + v592->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); + v592->uAttributes |= 8u; + } + LOBYTE(v592->uAttributes) |= 0x80u; _50C9A8_item_enchantment_timer = 256; LODWORD(v727) = 1; break; @@ -6656,41 +6182,41 @@ { if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - HIDWORD(v733) = 0; + int _v733 = 0; memset(&achieved_awards, 0, 4000); - _this = 0; + int i = 0; pNPCData = pParty->pHirelings; do { if ( pNPCData->pName != 0) { - v606 = HIDWORD(v733)++; - achieved_awards[v606] = (AwardType)(int)((char *)&_this->uItemID + 1); + v606 = _v733++; + achieved_awards[v606] = (AwardType)(i + 1); } - _this = (ItemGen *)((char *)_this + 1); + ++i; ++pNPCData; } while ( pNPCData <= &pParty->pHirelings[1] ); - _this = 0; + i = 0; if ( (signed int)pNPCStats->uNumNewNPCs > 0) { pNPCData = pNPCStats->pNewNPCData; __debugbreak(); // data offset - HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152; + AwardType *_v734 = &achieved_awards[_v733]; do { if ( pNPCData->uFlags & 0x80 && (!pParty->pHirelings[0].pName || strcmp(pNPCData->pName, pParty->pHirelings[0].pName)) && (!pParty->pHirelings[1].pName || strcmp(pNPCData->pName, pParty->pHirelings[1].pName)) ) { - v607 = HIDWORD(v733); - HIDWORD(v733) += 4; - *(int *)v607 = (int)_this + 3; + v607 = _v734; + ++_v734; + *v607 = (AwardType)(i + 3); } - _this = (ItemGen *)((char *)_this + 1); + ++i; ++pNPCData; } - while ( (signed int)_this < (signed int)pNPCStats->uNumNewNPCs ); + while ( (signed int)i < (signed int)pNPCStats->uNumNewNPCs ); } v608 = pCastSpell->uPlayerID_2; if ( v608 != 4 && v608 != 5 @@ -6744,7 +6270,7 @@ if ( v731 != 3 && v731 != 4 ) { pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); - pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v615, v716, 0); + pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v716, 0); LODWORD(v727) = 1; break; } @@ -6768,7 +6294,7 @@ break; pGame->GetIndoorCamera(); v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth(); - HIDWORD(v733) = sub_46A6AC((int)dword_50BF30, 100, v623); + signed int _v733 = sub_46A6AC((int)dword_50BF30, 100, v623); v707.x = 0; v707.y = 0; v707.z = 0; @@ -6786,9 +6312,9 @@ pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); a2 = 0; int _v726 = 0; - if ( SHIDWORD(v733) > 0 ) - { - _v726 = (HIDWORD(v733) * (7 * v2 + 25)); + if ( _v733 > 0 ) + { + _v726 = (_v733 * (7 * v2 + 25)); do { v625 = dword_50BF30[a2]; @@ -6802,7 +6328,7 @@ DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707); a2 = v628 + 1; } - while ( v628 + 1 < SHIDWORD(v733) ); + while ( v628 + 1 < _v733 ); } v730 = 0; v629 = 1; @@ -6823,23 +6349,23 @@ } while ( v629 <= 4 ); v732 = (signed __int64)((double)(signed int)_v726 / (double)v730); - HIDWORD(v733) = 0; + _v733 = 0; if ( v730 > 0 ) { do { //v632 = 4 * v681[HIDWORD(v733)] + 10965188; - v726 = pPlayers[v681[HIDWORD(v733)]]; + v726 = pPlayers[v681[_v733]]; //v633 = pPlayers[v681[HIDWORD(v733)]]; v726->sHealth += v732; //v726 = *(Player **)v632; //v634 = v726->GetMaxHealth(); if ( v726->sHealth > v726->GetMaxHealth()) v726->sHealth = v726->GetMaxHealth(); - v635 = HIDWORD(v733); + v635 = _v733; pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, WORD2(v733)); - HIDWORD(v733) = v635 + 1; + _v733 = v635 + 1; } while ( v635 + 1 < v730 ); }