Mercurial > mm7
diff mm7_6.cpp @ 997:1c13fbaad0c5
Слияние
author | Ritor1 |
---|---|
date | Tue, 14 May 2013 10:07:33 +0600 |
parents | bdbbdfa77ea6 ada1ed5f44a1 |
children | e4383e6dfbef |
line wrap: on
line diff
--- a/mm7_6.cpp Tue May 14 10:07:21 2013 +0600 +++ b/mm7_6.cpp Tue May 14 10:07:33 2013 +0600 @@ -2485,10 +2485,10 @@ //__int16 v73; // ST1C_2@222 //__int16 v74; // ST18_2@222 //stru6 *v75; // eax@222 - int v76; // ecx@223 - int v77; // ecx@224 - int v78; // ecx@225 - int v79; // eax@227 + //int v76; // ecx@223 + //int v77; // ecx@224 + //int v78; // ecx@225 + //int v79; // eax@227 //int v80; // eax@232 //__int16 v81; // ST18_2@245 //stru6 *v82; // eax@245 @@ -2500,7 +2500,7 @@ //__int16 v88; // ST18_2@245 //stru6 *v89; // eax@245 double v90; // st7@245 - int v91; // eax@250 + //int v91; // eax@250 Player *v92; // eax@255 //__int16 v93; // ST18_2@260 //stru6 *v94; // eax@260 @@ -2510,10 +2510,10 @@ //stru6 *v98; // eax@260 //__int16 v99; // ST18_2@260 //stru6 *v100; // eax@260 - int v101; // ecx@261 - int v102; // ecx@262 - int v103; // ecx@263 - int v104; // eax@265 + //int v101; // ecx@261 + //int v102; // ecx@262 + //int v103; // ecx@263 + //int v104; // eax@265 int v105; // edi@271 //__int16 v106; // ST18_2@272 //stru6 *v107; // eax@272 @@ -2532,10 +2532,10 @@ //int v120; // eax@286 //int v121; // eax@286 signed int v122; // eax@286 - int v123; // ecx@288 - int v124; // ecx@289 - int v125; // ecx@290 - int v126; // eax@292 + //int v123; // ecx@288 + //int v124; // ecx@289 + //int v125; // ecx@290 + //int v126; // eax@292 int v127; // eax@296 //__int16 v128; // ST18_2@303 //stru6 *v129; // eax@303 @@ -2547,9 +2547,9 @@ //stru6 *v135; // eax@303 //unsigned __int64 v136; // qax@304 //char *v137; // ecx@304 - int v138; // ecx@305 + //int v138; // ecx@305 int v139; // ecx@306 - int v140; // eax@308 + //int v140; // eax@308 //__int16 v141; // ST18_2@311 //stru6 *v142; // eax@311 //__int16 v143; // ST18_2@311 @@ -2566,10 +2566,10 @@ int v154; // eax@322 int v155; // eax@323 int v156; // eax@323 - int v157; // eax@326 + //int v157; // eax@326 double v158; // st7@326 double v159; // st6@326 - signed __int64 v160; // qtt@334 + //signed __int64 v160; // qtt@334 //int v161; // eax@339 int v162; // edi@340 //int v163; // eax@340 @@ -2579,10 +2579,10 @@ //stru6 *v167; // eax@340 signed int v168; // edi@343 int v169; // eax@344 - int v170; // ecx@346 - int v171; // ecx@347 - int v172; // ecx@348 - int v173; // edi@350 + //int v170; // ecx@346 + //int v171; // ecx@347 + //int v172; // ecx@348 + //int v173; // edi@350 signed int v174; // edi@355 //__int16 v175; // ST18_2@357 //stru6 *v176; // eax@357 @@ -2602,8 +2602,8 @@ //const char *v190; // ecx@377 signed int v191; // edi@379 int v192; // ecx@382 - int v193; // ecx@383 - int v194; // ecx@384 + //int v193; // ecx@383 + //int v194; // ecx@384 int v195; // eax@386 int v196; // eax@387 //__int16 v197; // ST18_2@395 @@ -2628,13 +2628,13 @@ double v216; // st7@415 double v217; // st6@415 signed __int64 v218; // qtt@423 - int v219; // ecx@425 - int v220; // ecx@426 - int v221; // edi@428 + //int v219; // ecx@425 + //int v220; // ecx@426 + //int v221; // edi@428 Player *v222; // edi@434 char v223; // al@438 - int v224; // ecx@442 - int v225; // ecx@443 + //int v224; // ecx@442 + //int v225; // ecx@443 //int v226; // eax@451 int v227; // esi@453 unsigned int v228; // edi@454 @@ -2682,7 +2682,7 @@ char *v270; // eax@531 char v271; // al@531 char v272; // cf@534 - float v273; // esi@541 + //float v273; // esi@541 char v274; // al@541 int v275; // edx@544 int k; // esi@544 @@ -2729,9 +2729,9 @@ const char *v317; // ecx@617 Player *v318; // ecx@619 unsigned int v319; // edi@627 - int v320; // ecx@629 - int v321; // ecx@630 - int v322; // edi@632 + //int v320; // ecx@629 + //int v321; // ecx@630 + //int v322; // edi@632 int v323; // edi@635 char *v324; // eax@635 Player *v325; // ecx@640 @@ -2748,18 +2748,18 @@ //stru6 *v336; // eax@658 //__int16 v337; // ST18_2@658 //stru6 *v338; // eax@658 - int v339; // ecx@659 - int v340; // ecx@660 - int v341; // eax@663 + //int v339; // ecx@659 + //int v340; // ecx@660 + //int v341; // eax@663 signed int v342; // edi@668 signed int v343; // edi@670 unsigned __int64 v344; // ST08_8@670 //__int16 v345; // ST1C_2@671 //__int16 v346; // ST18_2@671 //stru6 *v347; // eax@671 - int v348; // ecx@672 - int v349; // ecx@673 - int v350; // edi@676 + //int v348; // ecx@672 + //int v349; // ecx@673 + //int v350; // edi@676 Player *v351; // edi@680 //__int16 v352; // ST18_2@685 //stru6 *v353; // eax@685 @@ -2784,7 +2784,7 @@ int v372; // ecx@710 int v373; // eax@715 int v374; // eax@717 - Player *v375; // edi@717 + //Player *v375; // edi@717 int v376; // eax@717 Player *v377; // ecx@719 int v378; // ecx@721 @@ -2802,27 +2802,27 @@ //__int16 v390; // ST18_2@740 //stru6 *v391; // eax@740 int v392; // ecx@742 - int v393; // ecx@743 - int v394; // ecx@744 - int v395; // edi@747 + //int v393; // ecx@743 + //int v394; // ecx@744 + //int v395; // edi@747 int v396; // eax@752 int v397; // eax@757 int v398; // eax@757 int v399; // eax@757 - char *v400; // esi@757 + //char *v400; // esi@757 //Game *v401; // ecx@759 //__int16 v402; // ST1C_2@759 //__int16 v403; // ST18_2@759 //stru6 *v404; // eax@759 - int v405; // ecx@761 - int v406; // ecx@762 - int v407; // edi@765 + //int v405; // ecx@761 + //int v406; // ecx@762 + //int v407; // edi@765 //__int16 v408; // ST1C_2@769 //__int16 v409; // ST18_2@769 //stru6 *v410; // eax@769 - int v411; // ecx@772 - int v412; // ecx@773 - int v413; // edi@775 + //int v411; // ecx@772 + //int v412; // ecx@773 + //int v413; // edi@775 //__int16 v414; // ST1C_2@781 //__int16 v415; // ST18_2@781 //stru6 *v416; // eax@781 @@ -2851,18 +2851,18 @@ //stru6 *v439; // eax@843 int v440; // eax@843 int v441; // eax@847 - int v442; // ecx@850 - int v443; // ecx@851 - int v444; // eax@853 + //int v442; // ecx@850 + //int v443; // ecx@851 + //int v444; // eax@853 signed int v445; // edi@857 int v446; // ecx@862 LevelDecoration *v447; // edi@864 __int16 v448; // ax@864 char *v449; // esi@870 int v450; // eax@870 - int v451; // ecx@875 - int v452; // ecx@876 - int v453; // edi@878 + //int v451; // ecx@875 + //int v452; // ecx@876 + //int v453; // edi@878 //__int16 v454; // ST1C_2@884 //__int16 v455; // ST18_2@884 //stru6 *v456; // eax@884 @@ -2873,16 +2873,16 @@ Actor *v461; // eax@897 unsigned __int16 v462; // cx@897 signed int v463; // edx@897 - int v464; // ecx@905 - int v465; // ecx@906 - int v466; // edi@909 + //int v464; // ecx@905 + //int v465; // ecx@906 + //int v466; // edi@909 //__int16 v467; // ST1C_2@913 //__int16 v468; // ST18_2@913 //stru6 *v469; // eax@913 int v470; // edi@913 int v471; // eax@917 int v472; // eax@917 - char *v473; // esi@918 + //char *v473; // esi@918 //__int16 v474; // ST18_2@920 //stru6 *v475; // eax@920 //__int16 v476; // ST18_2@920 @@ -2924,14 +2924,14 @@ //int v512; // eax@946 SpellBuff *v513; // edi@946 int v514; // ecx@950 - int v515; // ecx@951 + //int v515; // ecx@951 int v516; // eax@953 //int v517; // eax@956 Actor *v518; // edx@957 __int16 v519; // cx@958 - int v520; // ecx@968 - int v521; // ecx@969 - int v522; // eax@971 + //int v520; // ecx@968 + //int v521; // ecx@969 + //int v522; // eax@971 //__int16 v523; // ST18_2@975 //stru6 *v524; // eax@975 //__int16 v525; // ST18_2@975 @@ -2957,11 +2957,11 @@ //__int16 v545; // ST18_2@991 //stru6 *v546; // eax@991 //__int16 v547; // ST18_2@991 - stru6 *v548; // eax@991 + //stru6 *v548; // eax@991 double v549; // st7@991 unsigned __int16 v550; // di@991 int v551; // ecx@993 - int v552; // ecx@994 + //int v552; // ecx@994 Player *v553; // edi@1001 //__int16 v554; // ST18_2@1002 //stru6 *v555; // eax@1002 @@ -3003,7 +3003,7 @@ char v591; // al@1048 int v592; // esi@1052 int v593; // ecx@1057 - int v594; // ecx@1058 + //int v594; // ecx@1058 //int v595; // eax@1064 int v596; // esi@1066 unsigned int v597; // edi@1067 @@ -3087,7 +3087,7 @@ const char *v675; // [sp+4h] [bp-E80h]@800 int v676; // [sp+4h] [bp-E80h]@807 int v677; // [sp+4h] [bp-E80h]@861 - int v678; // [sp+4h] [bp-E80h]@997 + //int v678; // [sp+4h] [bp-E80h]@997 int v679; // [sp+14h] [bp-E70h]@515 AIDirection a3; // [sp+C94h] [bp-1F0h]@21 int v681[4]; // [sp+CB0h] [bp-1D4h]@1137 @@ -3162,8 +3162,6 @@ LODWORD(v733) = 0; v723 = 0; v727 = 0.0; - //n = 0; - //while ( 1 ) for(n = 0; n < 10; ++n) { pCastSpell = &this[n]; @@ -3219,7 +3217,7 @@ if (pCastSpell->forced_spell_skill_level) { v11 = pCastSpell->forced_spell_skill_level; - v723 = v11 & 0x3F; + v723 = v11 & 0x3F; // 6 bytes v2 = v723; } else @@ -3253,21 +3251,7 @@ v11 = pPlayer->pActiveSkills[LODWORD(v725)]; } - if ( HIBYTE(v11) & 1 ) - { - v731 = 4; - } - else - { - if ( (v11 & 0x80u) == 0 ) - { - v731 = ((v11 & 0x40) != 0) + 1; - } - else - { - v731 = 3; - } - } + v731 = SkillToMastery(v11); if (pCastSpell->forced_spell_skill_level) uRequiredMana = 0; @@ -3655,7 +3639,24 @@ pSpellSprite.vPosition.y = pParty->vPosition.y; v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; v660 = pParty->vPosition.y; - goto LABEL_153; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.z = v51; + v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.uSectorID = v52; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4u; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + break; } case SPELL_LIGHT_SUNRAY: { @@ -3678,7 +3679,23 @@ v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; v660 = pParty->vPosition.y; - goto LABEL_153; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.z = v51; + v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.uSectorID = v52; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4u; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; } break; } @@ -3701,32 +3718,33 @@ v672 = 0; *(short *)(v55 + 150) = 0; v661 = (Actor *)v55; - goto LABEL_165; + pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672); + LODWORD(v727) = 1; + break; } case SPELL_EARTH_SLOW: { if ( v731 == 2 ) { v57 = 300 * v2; - } - else - { - if ( v731 == 3 ) - { + amount = 2; + } + else if ( v731 == 3 ) + { amount = 4; v57 = 300 * v2; - goto LABEL_174; - } - if ( v731 == 4 ) - { + } + else if ( v731 == 4 ) + { v57 = 300 * v2; amount = 8; - goto LABEL_174; - } + } + else + { v57 = 180 * v2; - } - amount = 2; - LABEL_174: + amount = 2; + } +// LABEL_174: LODWORD(v733) = v57; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -3749,7 +3767,9 @@ *((char *)&pActors[0].uAttributes + v59 + 2) |= 8u; v672 = 0; v661 = (Actor *)LODWORD(v718); - goto LABEL_165; + pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672); + LODWORD(v727) = 1; + break; } case SPELL_MIND_CHARM: { @@ -3783,7 +3803,29 @@ pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); v61 = PID_ID(a2); - goto LABEL_1086; + v600 = pActors[v61].vPosition.y; + v601 = pActors[v61].vPosition.x; + pSpellSprite.uObjectDescID = v60; + pSpellSprite.vPosition.x = v601; + v602 = pActors[v61].uActorHeight; + v603 = pActors[v61].vPosition.z; + pSpellSprite.vPosition.y = v600; + v676 = v603 + v602; + v665 = v600; + pSpellSprite.vPosition.z = v603 + v602; + v657 = v601; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80u; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); + LODWORD(v727) = 1; + break; } case SPELL_DARK_SHRINKING_RAY: { @@ -3840,7 +3882,7 @@ if ( !v65 ) { amount = 12; - LABEL_195: +// LABEL_195: LODWORD(v733) = 3600 * v2; } else if ( v65 == 1 ) @@ -3850,7 +3892,7 @@ } } } - LABEL_196: +// LABEL_196: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2]; @@ -3925,36 +3967,12 @@ case SPELL_MIND_PROTECTION_FROM_MIND: case SPELL_BODY_PROTECTION_FROM_BODY: { - v76 = v731 - 1; LODWORD(v733) = 3600 * v2; - if ( v76 ) - { - v77 = v76 - 1; - if ( v77 ) - { - v78 = v77 - 1; - if ( v78 ) - { - if ( v78 != 1 ) - goto LABEL_232; - v79 = 4 * v2; - } - else - { - v79 = 3 * v2; - } - } - else - { - v79 = 2 * v2; - } - amount = v79; - } - else - { - amount = v2; - } -LABEL_232: + if ( v731 > 0 && v731 <= 4) + { + amount = v731 * v2; + } +//LABEL_232: //v80 = v3->spellnum; switch (pCastSpell->spellnum) { @@ -3993,73 +4011,56 @@ } case SPELL_FIRE_HASTE: { - if ( v731 <= 0 ) - goto LABEL_254; - if ( v731 <= 2 ) - { - v91 = 60 * (v2 + 60); - } - else - { - if ( v731 == 3 ) - { - v91 = 180 * (v2 + 20); - } - else - { - if ( v731 != 4 ) - goto LABEL_254; - v91 = 240 * (v2 + 15); - } - } - LODWORD(v733) = v91; - LABEL_254: + if ( v731 == 1 || v731 == 2 ) + { + LODWORD(v733) = 60 * (v2 + 60); + } + else if ( v731 == 3 ) + { + LODWORD(v733) = 180 * (v2 + 20); + } + else if ( v731 == 4 ) + { + LODWORD(v733) = 240 * (v2 + 15); + } if ( pPlayer->CanCastSpell(uRequiredMana) ) { v92 = pParty->pPlayers;//[0].pConditions[1]; LODWORD(v727) = 1; do { - if ( v92->pConditions ) - LODWORD(v727) = 0; - ++v92; + if ( v92->pConditions ) + LODWORD(v727) = 0; + ++v92; } while ( v92 <= &pParty->pPlayers[3] ); if (LODWORD(v727)) { - pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); + + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); } } break; } case SPELL_SPIRIT_BLESS: { - v101 = v731 - 1; - if ( v101 && (v102 = v101 - 1) != 0 ) - { - v103 = v102 - 1; - if ( v103 ) - { - if ( v103 != 1 ) - goto LABEL_269; - v104 = 3600 * (v2 + 1); - } - else - { - v104 = 900 * (v2 + 4); - } - } - else - { - v104 = 300 * (v2 + 12); - } - LODWORD(v733) = v104; - LABEL_269: + if ( v731 == 1 || v731 == 2 ) + { + LODWORD(v733) = 300 * (v2 + 12); + } + else if ( v731 == 3 ) + { + LODWORD(v733) = 900 * (v2 + 4); + } + else if ( v731 == 4 ) + { + LODWORD(v733) = 3600 * (v2 + 1); + } +// LABEL_269: amount = v2 + 5; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -4170,28 +4171,21 @@ case SPELL_AIR_SHIELD: case SPELL_EARTH_STONESKIN: case SPELL_SPIRIT_HEROISM: - { - v123 = v731 - 1; - if ( v123 && (v124 = v123 - 1) != 0 ) - { - v125 = v124 - 1; - if ( v125 ) - { - if ( v125 != 1 ) - goto LABEL_296; - v126 = 3600 * (v2 + 1); - } - else - { - v126 = 900 * (v2 + 4); - } - } - else - { - v126 = 300 * (v2 + 12); - } - LODWORD(v733) = v126; - LABEL_296: + { + if( v731 == 1 || v731 == 2 ) + { + LODWORD(v733) = 300 * (v2 + 12); + } + else if ( v731 == 3 ) + { + LODWORD(v733) = 900 * (v2 + 4); + } + else if ( v731 == 4 ) + { + LODWORD(v733) = 3600 * (v2 + 1); + } + +// LABEL_296: v127 = pCastSpell->spellnum; if ( v127 == 17 ) { @@ -4227,12 +4221,10 @@ } case SPELL_FIRE_IMMOLATION: { - v138 = v731 - 2; - if ( v138 && (v139 = v138 - 1) != 0 && v139 == 1 ) - v140 = 600 * v2; + if ( v731 == 4 && v139 == 1 ) + LODWORD(v733) = 600 * v2; else - v140 = 60 * v2; - LODWORD(v733) = v140; + LODWORD(v733) = 60 * v2; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -4301,16 +4293,18 @@ *(float *)&v721 = v159; a2 = rand() % 1000; *((float *)&v733 + 1) = (double)(rand() % 1000) + *(float *)&y - *(float *)&v732; - v725 = v159 * v159; + //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 + v725) <= 1.0 ) + if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&_this + v159 * v159) <= 1.0 ) { LODWORD(v687) = 0; HIDWORD(v687) = 0; } else { - x = (signed __int64)sqrt(*(float *)&_this + v725); + //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)); @@ -4416,24 +4410,19 @@ } case SPELL_AIR_FEATHER_FALL: { - v170 = v731 - 1; - if ( !v170 ) - { - v173 = 300 * v2; - goto LABEL_353; - } - v171 = v170 - 1; - if ( !v171 ) - { - v173 = 600 * v2; - goto LABEL_353; - } - v172 = v171 - 1; - if ( !v172 || v172 == 1 ) - { - v173 = 3600 * v2; - LABEL_353: - LODWORD(v733) = v173; + if ( v731 == 1 ) + { + LODWORD(v733) = 300 * v2; + } + else if ( v731 == 2 ) + { + LODWORD(v733) = 600 * v2; + } + else if ( v731 == 3 || v731 == 4 ) + { + LODWORD(v733) = 3600 * v2; + //LABEL_353: + //LODWORD(v733) = v173; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -4541,39 +4530,32 @@ case SPELL_AIR_INVISIBILITY: { v192 = v731 - 1; - if ( !v192 ) + if ( v731 == 1 ) { amount = v2; - //goto LABEL_391; - v195 = 600 * v2; - goto LABEL_392; - } - v193 = v192 - 1; - if ( !v193 ) + LODWORD(v733) = 600 * v2; + } + else if ( v731 == 2 ) { v196 = 2 * v2; - //LABEL_389: amount = v196; - //LABEL_391: - v195 = 600 * v2; - goto LABEL_392; - } - v194 = v193 - 1; - if ( !v194 ) + LODWORD(v733) = 600 * v2; + } + else if ( v731 == 3 ) { v196 = 3 * v2; //goto LABEL_389; amount = v196; - v195 = 600 * v2; - goto LABEL_392; - } - if ( v194 != 1 ) - goto LABEL_393; + LODWORD(v733) = 600 * v2; + } + else if ( v731 == 4 ) + { amount = 4 * v2; v195 = 3600 * v2; - LABEL_392: +// LABEL_392: LODWORD(v733) = v195; - LABEL_393: + } +// LABEL_393: if (pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW)) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! @@ -4719,31 +4701,16 @@ } case SPELL_WATER_AWAKEN: - { - v219 = v731 - 2; - if ( v219 ) - { - v220 = v219 - 1; - if ( v220 ) - { - if ( v220 == 1 ) - { - amount = 0; - goto LABEL_433; - } - v221 = 180 * v2; - } - else - { - v221 = 86400 * v2; - } - } - else - { - v221 = 3600 * v2; - } - amount = v221; - LABEL_433: + { + if ( v731 == 1 ) + amount = 180 * v2; + else if ( v731 == 2) + amount = 3600 * v2; + else if ( v731 == 3 ) + amount = 86400 * v2; + else if ( v731 == 4 ) + amount = 0; +// LABEL_433: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v222 = pParty->pPlayers; @@ -4779,27 +4746,15 @@ } } case SPELL_WATER_POISON_SPRAY: - { - v224 = v731 - 2; - if ( v224 ) - { - v225 = v224 - 1; - if ( v225 ) - { - if ( v225 == 1 ) - amount = 7; - else - amount = 1; - } - else - { + { + if ( v731 == 1 ) + amount = 1; + else if ( v731 == 2 ) + amount = 3; + else if ( v731 == 3 ) amount = 5; - } - } - else - { - amount = 3; - } + else if ( v731 == 4 ) + amount = 7; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; HIDWORD(v733) = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; @@ -4814,7 +4769,7 @@ v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; v660 = pParty->vPosition.y; - LABEL_153: +// LABEL_153: pSpellSprite.uAttributes = 0; pSpellSprite.vPosition.x = pParty->vPosition.x; pSpellSprite.vPosition.z = v51; @@ -4927,25 +4882,21 @@ { v241 = (double)v723 * 0.0099999998 + 0.5; } - else - { - if ( v731 == 3 ) - { + else if ( v731 == 3 ) + { v241 = (double)v723 * 0.0099999998 + 0.69999999; - } - else - { - if ( v731 != 4 ) - { - v241 = 0.0; - goto LABEL_484; - } + } + else if ( v731 == 4 ) + { v241 = (double)v723 * 0.0099999998 + 0.80000001; - } + } + else + { + v241 = 0.0; } if ( v241 > 1.0 ) v241 = 1.0; -LABEL_484: +//LABEL_484: v732 = (unsigned __int8)v240[25]; v242 = (signed __int64)((double)v732 * v241); v243 = y; @@ -5029,24 +4980,26 @@ v254 = rand(); v255 = 10;//pItemsTable->field_116D8[17]; v256 = 10;//pItemsTable->field_116D8[16]; -LABEL_611: +//LABEL_611: *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1); -LABEL_612: +//LABEL_612: _this->uItemID |= 0x20u; _50C9A8_item_enchantment_timer = 256; LODWORD(v727) = 1; break; } - goto LABEL_616; } -LABEL_613: + else + { +//LABEL_613: v316 = _this->uItemID; if ( !(BYTE1(v316) & 2) ) { LOBYTE(v316) = v316 | 2; _this->uItemID = v316; } + } } } } @@ -5055,17 +5008,17 @@ } } } -LABEL_616: +//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); + 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; } @@ -5073,87 +5026,125 @@ { 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) ) - goto LABEL_616; - 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) - goto LABEL_613; - 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) ) + 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) ) { - 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] ) + 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 ) { - ++*(int *)(v245 + 4); - if ( k >= v275 ) + 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; } - v254 = rand(); - v255 = 10;//pItemsTable->field_116D8[19]; - v256 = 10;//pItemsTable->field_116D8[18]; - goto LABEL_611; - } - v277 = pItemsTable->pSpecialEnchantments_count; - v278 = 0; - v725 = 0.0; - HIDWORD(v733) = 0; - if ( pItemsTable->pSpecialEnchantments_count > 0 ) + //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 ) { - v730 = (int)&v679; - do - { - v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278 + 1].pBonusStatement); - if ( !v279 || v279 == 1 ) + 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) ) { - 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); - } + 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; + + _50C9A8_item_enchantment_timer = 256; + LODWORD(v727) = 1; + break; } - ++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 ) + 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 ) { @@ -5167,112 +5158,168 @@ break; } } - ++*(int *)(v245 + 12); - goto LABEL_612; - } + ++*(int *)(v245 + 12); + _this->uItemID |= 0x20u; + + _50C9A8_item_enchantment_timer = 256; + LODWORD(v727) = 1; + break; + } } else { - __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()) ) - goto LABEL_616; - 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) - goto LABEL_613; - 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) ) + __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()) ) { - 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] ) + 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; + } + 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 ) { - ++*(int *)(v245 + 4); - if ( m >= v252 ) + 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; } - v254 = rand(); - v255 = 10;// pItemsTable->field_116D8[21]; - v256 = 10;//pItemsTable->field_116D8[20]; - goto LABEL_611; - } - v257 = pItemsTable->pSpecialEnchantments_count; - v258 = 0; - v725 = 0.0; - HIDWORD(v733) = 0; - if ( pItemsTable->pSpecialEnchantments_count > 0 ) + 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 ) { - v730 = (int)&v679; - do - { - v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement); - if ( !v259 || v259 == 1 ) + 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] ) { - v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType - + 4] - + v258 * 28); - LODWORD(v725) += v260; - if ( v260 ) + ++*(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; + if ( pItemsTable->pSpecialEnchantments_count > 0 ) { - v261 = v730; - v730 += 4; - *(int *)v261 = HIDWORD(v733); - } + v730 = (int)&v679; + do + { + v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement); + if ( !v259 || v259 == 1 ) + { + v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + + 4] + + v258 * 28); + LODWORD(v725) += v260; + if ( v260 ) + { + v261 = v730; + v730 += 4; + *(int *)v261 = HIDWORD(v733); + } + } + ++HIDWORD(v733); + ++v258; + } + while ( SHIDWORD(v733) < v257 ); } - ++HIDWORD(v733); - ++v258; - } - while ( SHIDWORD(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]; - v265 = v262 + 1; - if ( v264 < v265 ) - { - for ( ii = &v679; ; ii = (int *)v732 ) - { - v267 = (int)(ii + 1); - v732 = v267; - v268 = *(int *)v267; - *(int *)(v245 + 12) = v268; - v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType - + 4]; - if ( v264 >= v265 ) + v262 = rand() % SLODWORD(v725); + v263 = v679; + *(int *)(v245 + 12) = v679; + 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 ) + { + v267 = (int)(ii + 1); + v732 = v267; + v268 = *(int *)v267; + *(int *)(v245 + 12) = v268; + v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + + 4]; + if ( v264 >= v265 ) + break; + } + } + ++*(int *)(v245 + 12); + _this->uItemID |= 0x20u; + + _50C9A8_item_enchantment_timer = 256; + LODWORD(v727) = 1; break; } - } - ++*(int *)(v245 + 12); - goto LABEL_612; - } } //v1 = 0; - goto 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); + } + break; } v289 = (ItemGen *)&v244[36 * a2 + 532]; _this = v289; @@ -5286,7 +5333,20 @@ || v291 == 1 || v291 == 2 || _this->Broken()) - goto 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); + } + break; + } if ( _this->GetValue() < 0x1C2 ) uRequiredMana = 1; if ( rand() % 100 >= SHIDWORD(v733) ) @@ -5434,23 +5494,12 @@ } case SPELL_EARTH_STONE_TO_FLESH: { - v320 = v731 - 2; - if ( !v320 ) - goto LABEL_632; - v321 = v320 - 1; - if ( v321 ) - { - if ( v321 == 1 ) - goto LABEL_634; -LABEL_632: - v322 = 3600 * v2; - } - else - { - v322 = 86400 * v2; - } - amount = v322; -LABEL_634: + __debugbreak(); // missing GM ? + if ( v731 == 1 || v731 == 2) + amount = 3600 * v2; + if ( v731 == 3 ) + amount = 86400 * v2; +//LABEL_634: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v323 = pCastSpell->uPlayerID_2; @@ -5471,7 +5520,9 @@ v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 15; v325 = &pParty->pPlayers[v323]; - goto LABEL_641; + v325->DiscardConditionIfLastsLongerThan(v656, v663); + LODWORD(v727) = 1; + break; } case SPELL_EARTH_ROCK_BLAST: { @@ -5572,30 +5623,15 @@ case SPELL_SPIRIT_FATE: { LODWORD(v733) = 300; - v339 = v731 - 2; - if ( v339 ) - { - v340 = v339 - 1; - if ( v340 ) - { - if ( v340 != 1 ) - { - amount = v2; - goto LABEL_667; - } - v341 = 6 * v2; - } - else - { - v341 = 4 * v2; - } - } - else - { - v341 = 2 * v2; - } - amount = v341; -LABEL_667: + if ( v731 == 1 ) + amount = v2; + else if( v731 == 2 ) + amount = 2 * v2; + else if( v731 == 3 ) + amount = 4 * v2; + else if( v731 == 4) + amount = 6 * v2; +//LABEL_667: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v342 = pCastSpell->spell_target_pid; @@ -5616,7 +5652,7 @@ BYTE2(pActors[v343].uAttributes) |= 8u; v672 = 0; v661 = &pActors[v343]; -LABEL_165: +//LABEL_165: pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672); } LODWORD(v727) = 1; @@ -5624,26 +5660,13 @@ } case SPELL_SPIRIT_REMOVE_CURSE: { - v348 = v731 - 2; - if ( !v348 ) - goto LABEL_677; - v349 = v348 - 1; - if ( v349 ) - { - if ( v349 == 1 ) - { + if ( v731 == 1 || v731 == 2 ) + amount = 3600 * v2; + else if( v731 == 3) + amount = 86400 * v2; + else if ( v731 == 4 ) amount = 0; - goto LABEL_679; - } -LABEL_677: - v350 = 3600 * v2; - } - else - { - v350 = 86400 * v2; - } - amount = v350; -LABEL_679: +//LABEL_679: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v351 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; @@ -5786,7 +5809,9 @@ (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); } v377 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - goto LABEL_720; + v377->SetCondition(1, 0); + LODWORD(v727) = 1; + break; } case SPELL_SPIRIT_SHARED_LIFE: { @@ -5847,29 +5872,15 @@ case SPELL_SPIRIT_RESSURECTION: { v392 = v731 - 1; - if ( !v392 ) - { - v395 = 180 * v2; - amount = v395; - goto LABEL_751; - } - v393 = v392 - 1; - if ( !v393 ) - { - v395 = 10800 * v2; - amount = v395; - goto LABEL_751; - } - v394 = v393 - 1; - if ( !v394 ) - { - v395 = 259200 * v2; - amount = v395; - goto LABEL_751; - } - if ( v394 == 1 ) + if ( v731 == 1 ) + amount = 180 * v2; + else if ( v731 == 2 ) + amount = 10800 * v2; + else if ( v731 == 3 ) + amount = 259200 * v2; + else if ( v731 == 4 ) amount = 0; -LABEL_751: +//LABEL_751: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v396 = pCastSpell->uPlayerID_2; @@ -5911,26 +5922,13 @@ } case SPELL_MIND_CURE_PARALYSIS: { - v405 = v731 - 2; - if ( !v405 ) - goto LABEL_766; - v406 = v405 - 1; - if ( v406 ) - { - if ( v406 == 1 ) - { + if ( v731 == 1 || v731 == 2 ) + amount = 3600 * v2; + else if ( v731 == 4 ) amount = 0; - goto LABEL_768; - } -LABEL_766: - v407 = 3600 * v2; - } - else - { - v407 = 86400 * v2; - } - amount = v407; -LABEL_768: + else if( v731 == 3 ) + amount = 86400 * v2; +//LABEL_768: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -5952,35 +5950,21 @@ v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 12; v325 = &pParty->pPlayers[v323]; - goto LABEL_641; - + v325->DiscardConditionIfLastsLongerThan(v656, v663); + LODWORD(v727) = 1; + break; } case SPELL_MIND_REMOVE_FEAR: - { - v411 = v731 - 2; - if ( v411 ) - { - v412 = v411 - 1; - if ( v412 ) - { - if ( v412 == 1 ) - { + { + if( v731 == 1) + amount = 180 * v2; + else if( v731 == 2 ) + amount = 3600 * v2; + else if( v731 == 3) + amount = 86400 * v2; + else if( v731 == 4 ) amount = 0; - goto LABEL_780; - } - v413 = 180 * v2; - } - else - { - v413 = 86400 * v2; - } - } - else - { - v413 = 3600 * v2; - } - amount = v413; -LABEL_780: +//LABEL_780: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -6002,196 +5986,267 @@ v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 3; v325 = &pParty->pPlayers[v323]; - goto LABEL_641; - } + v325->DiscardConditionIfLastsLongerThan(v656, v663); + LODWORD(v727) = 1; + break; + } case SPELL_MIND_TELEPATHY: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if (PID_TYPE(a2) != OBJECT_Actor) - { + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if (PID_TYPE(a2) != OBJECT_Actor) + { + 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; + if ( pItemsTable->pItems[v418].uEquipType == 18 ) + HIDWORD(v733) = *(int *)(v417 + 684); + + //ItemGen::ItemGen(&v683); + v683.Reset(); + + v419 = *(short *)(v730 + 180); + if (v419) + { + v683.uItemID = v419; + //goto LABEL_799; + } + else + { + v420 = 0; + v421 = v730 + 564; + while ( !*(int *)v421 || pItemsTable->pItems[*(int *)v421].uEquipType == 18 ) + { + ++v420; + v421 += 36; + if ( v420 >= 4 ) + break; + } + if ( v420 < 4 ) + { + memcpy(&v683, (const void *)(v730 + 36 * v420 + 564), sizeof(v683)); + v2 = v723; + //v1 = 0; + } + } +// LABEL_799: + if ( HIDWORD(v733) != 0 ) + { + v675 = (const char *)HIDWORD(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(); + 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; + } + 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; + } + } + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80u; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); 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; - if ( pItemsTable->pItems[v418].uEquipType == 18 ) - HIDWORD(v733) = *(int *)(v417 + 684); - - //ItemGen::ItemGen(&v683); - v683.Reset(); - - v419 = *(short *)(v730 + 180); - if (v419) - { - v683.uItemID = v419; - goto LABEL_799; - } - v420 = 0; - v421 = v730 + 564; - while ( !*(int *)v421 || pItemsTable->pItems[*(int *)v421].uEquipType == 18 ) - { - ++v420; - v421 += 36; - if ( v420 >= 4 ) - goto LABEL_799; - } - memcpy(&v683, (const void *)(v730 + 36 * v420 + 564), sizeof(v683)); - v2 = v723; - //v1 = 0; -LABEL_799: - if ( HIDWORD(v733) != 0 ) - { - v675 = (const char *)HIDWORD(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; - goto LABEL_1087; - } - 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; - goto LABEL_1087; - } - if (v683.uItemID) - { - v675 = v683.GetDisplayName(); - v664 = "(%s)"; - sprintf(pTmpBuf2, v664, v675); - ShowStatusBarString(pTmpBuf2, 2u); + case SPELL_MIND_BERSERK: + { + v423 = v731 - 2; + if ( !v423 ) + v425 = 300 * v2; + else + { + v424 = v423 - 1; + if ( v424 ) + { + if ( v424 == 1 ) + v425 = 3600 * v2; + else +//LABEL_813: + v425 = 300 * v2; + } + else + { + v425 = 600 * v2; + } + } + amount = v425; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v426 = PID_ID(a2); + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + break; + } + v730 = 836 * v426; + if ( stru_50C198.GetMagicalResistance(&pActors[v426], 7u) ) + { + pActors[v426].pActorBuffs[1].Reset(); + pActors[v426].pActorBuffs[12].Reset(); + pActors[v426].pActorBuffs[9].Apply( + pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + v731, 0, 0, 0); + pActors[v426].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + } 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; - goto LABEL_1087; - } - 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; - goto LABEL_1087; - } - case SPELL_MIND_BERSERK: - { - v423 = v731 - 2; - if ( !v423 ) - goto LABEL_813; - v424 = v423 - 1; - if ( v424 ) - { - if ( v424 == 1 ) - v425 = 3600 * v2; - else -LABEL_813: - v425 = 300 * v2; - } - else - { - v425 = 600 * v2; - } - amount = v425; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - v426 = PID_ID(a2); - if (PID_TYPE(a2) != OBJECT_Actor) - { + v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + v61 = v426; + v600 = pActors[v61].vPosition.y; + v601 = pActors[v61].vPosition.x; + pSpellSprite.uObjectDescID = v60; + pSpellSprite.vPosition.x = v601; + v602 = pActors[v61].uActorHeight; + v603 = pActors[v61].vPosition.z; + pSpellSprite.vPosition.y = v600; + v676 = v603 + v602; + v665 = v600; + pSpellSprite.vPosition.z = v603 + v602; + v657 = v601; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80u; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); LODWORD(v727) = 1; break; } - v730 = 836 * v426; - if ( stru_50C198.GetMagicalResistance(&pActors[v426], 7u) ) - { - pActors[v426].pActorBuffs[1].Reset(); - pActors[v426].pActorBuffs[12].Reset(); - pActors[v426].pActorBuffs[9].Apply( - pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), - v731, 0, 0, 0); - pActors[v426].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - } - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - v61 = v426; - goto LABEL_1086; - - } case SPELL_MIND_ENSLAVE: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - amount = 600 * v2; - if (PID_TYPE(a2) != OBJECT_Actor) - { + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + amount = 600 * v2; + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + break; + } + v730 = 836 * PID_ID(a2); + if ( MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + break; + if ( stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) + { + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[1].Reset(); + pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + v731, 0, 0, 0); + } + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_level = v2; + pSpellSprite.spell_skill = v731; + v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + v61 = PID_ID(a2); + v600 = pActors[v61].vPosition.y; + v601 = pActors[v61].vPosition.x; + pSpellSprite.uObjectDescID = v60; + pSpellSprite.vPosition.x = v601; + v602 = pActors[v61].uActorHeight; + v603 = pActors[v61].vPosition.z; + pSpellSprite.vPosition.y = v600; + v676 = v603 + v602; + v665 = v600; + pSpellSprite.vPosition.z = v603 + v602; + v657 = v601; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80u; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); LODWORD(v727) = 1; break; } - v730 = 836 * PID_ID(a2); - if ( MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - break; - if ( stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) - { - pActors[PID_ID(a2)].pActorBuffs[9].Reset(); - pActors[PID_ID(a2)].pActorBuffs[1].Reset(); - pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), - v731, 0, 0, 0); - } - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - v61 = PID_ID(a2); - goto LABEL_1086; - } case SPELL_MIND_MASS_FEAR: { v428 = v731 - 2; @@ -6266,7 +6321,7 @@ (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); } v377 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; -LABEL_720: +//LABEL_720: v377->SetCondition(1, 0); } LODWORD(v727) = 1; @@ -6274,23 +6329,12 @@ } case SPELL_EARTH_TELEKINESIS: { - v442 = v731 - 2; - if ( !v442 ) - goto LABEL_855; - v443 = v442 - 1; - if ( v443 ) - { - if ( v443 == 1 ) - v444 = 4 * v2; - else -LABEL_855: - v444 = 2 * v2; - } - else - { - v444 = 3 * v2; - } - amount = v444; + if ( v731 == 1 || v731 == 2 ) + amount = 2 * v2; + else if( v731 == 3 ) + amount = 3 * v2; + else if ( v731 == 4 ) + amount = 4 * v2; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v445 = PID_ID(a2); @@ -6362,30 +6406,15 @@ } case SPELL_BODY_CURE_WEAKNESS: { - v451 = v731 - 2; - if ( v451 ) - { - v452 = v451 - 1; - if ( v452 ) - { - if ( v452 == 1 ) - { - amount = 0; - goto LABEL_883; - } - v453 = 180 * v2; - } - else - { - v453 = 86400 * v2; - } - } - else - { - v453 = 3600 * v2; - } - amount = v453; -LABEL_883: + if ( v731 == 1 ) + amount = 180 * v2; + else if( v731 == 2 ) + amount = 3600 * v2; + else if( v731 == 3 ) + amount = 86400 * v2; + else if ( v731 == 4 ) + amount = 0; +//LABEL_883: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -6407,8 +6436,10 @@ v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 1; v325 = &pParty->pPlayers[v323]; - goto LABEL_641; - } + v325->DiscardConditionIfLastsLongerThan(v656, v663); + LODWORD(v727) = 1; + break; + } case SPELL_BODY_FIRST_AID: { v457 = v731 - 2; @@ -6469,26 +6500,13 @@ } case SPELL_BODY_CURE_POISON: { - v464 = v731 - 2; - if ( !v464 ) - goto LABEL_910; - v465 = v464 - 1; - if ( v465 ) - { - if ( v465 == 1 ) - { + if ( v731 == 1 || v731 == 2 ) + amount = 3600 * v2; + else if( v731 == 3) + amount = 86400 * v2; + else if ( v731 == 4 ) amount = 0; - goto LABEL_912; - } -LABEL_910: - v466 = 3600 * v2; - } - else - { - v466 = 86400 * v2; - } - amount = v466; -LABEL_912: +//LABEL_912: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -6523,9 +6541,11 @@ (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2); v656 = 10; - goto LABEL_937; - - } + v325 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; + v325->DiscardConditionIfLastsLongerThan(v656, v663); + LODWORD(v727) = 1; + break; + } case SPELL_BODY_PROTECTION_FROM_MAGIC: { amount = v2; @@ -6611,9 +6631,9 @@ (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2); v656 = 11; -LABEL_937: +//LABEL_937: v325 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; -LABEL_641: +//LABEL_641: v325->DiscardConditionIfLastsLongerThan(v656, v663); } LODWORD(v727) = 1; @@ -6700,28 +6720,21 @@ case SPELL_LIGHT_SUMMON_ELEMENTAL: { v514 = v731 - 2; - if ( !v514 ) - goto LABEL_955; - v515 = v514 - 1; - if ( v515 ) - { - if ( v515 == 1 ) + if ( v731 == 1 || v731 == 2 ) + { + v516 = 300 * v2; + amount = 1; + } + else if( v731 == 3 ) + { + v516 = 900 * v2; + amount = 3; + } + else if ( v731 == 4 ) { v516 = 900 * v2; amount = 5; } - else - { -LABEL_955: - v516 = 300 * v2; - amount = 1; - } - } - else - { - v516 = 900 * v2; - amount = 3; - } v733 = __PAIR__(0, v516); if ( (signed int)uNumActors > 0 ) @@ -6753,30 +6766,21 @@ } case SPELL_LIGHT_DAY_OF_THE_GODS: { - v520 = v731 - 2; - if ( !v520 ) - goto LABEL_973; - v521 = v520 - 1; - if ( v521 ) - { - if ( v521 == 1 ) - { - LODWORD(v733) = 18000 * v2; - v522 = 5 * v2 + 10; - } - else - { -LABEL_973: + if ( v731 == 1 || v731 == 2 ) + { LODWORD(v733) = 10800 * v2; - v522 = 3 * v2 + 10; - } - } - else + amount = 3 * v2 + 10; + } + else if( v731 == 3 ) { LODWORD(v733) = 14400 * v2; - v522 = 4 * v2 + 10; - } - amount = v522; + amount = 4 * v2 + 10; + } + else if ( v731 == 4 ) + { + LODWORD(v733) = 18000 * v2; + amount = 5 * v2 + 10; + } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; @@ -6887,27 +6891,22 @@ case SPELL_LIGHT_HOUR_OF_POWER: { v551 = v731 - 2; - if ( !v551 ) - goto LABEL_998; - v552 = v551 - 1; - if ( v552 ) - { - if ( v552 == 1 ) - { + if ( v731 == 1 || v731 == 2 ) + { + HIDWORD(v733) = 4; + amount = 4; + } + else if( v731 == 3 ) + { + HIDWORD(v733) = 12; + amount = 12; + } + else if( v731 == 4 ) + { amount = 15; HIDWORD(v733) = 20; - goto LABEL_1000; - } -LABEL_998: - v678 = 4; - } - else - { - v678 = 12; - } - amount = v678; - HIDWORD(v733) = v678; -LABEL_1000: + } +//LABEL_1000: if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; y = (char *)(60 * (v2 * HIDWORD(v733) + 60)); @@ -7138,21 +7137,12 @@ case SPELL_DARK_SHARPMETAL: { v593 = v731 - 2; - if ( !v593 ) - goto LABEL_1062; - v594 = v593 - 1; - if ( v594 ) - { - if ( v594 == 1 ) + if( v731 == 1 || v731 == 2 ) + amount = 5; + else if( v731 == 3 ) + amount = 7; + else if( v731 == 4 ) amount = 9; - else -LABEL_1062: - amount = 5; - } - else - { - amount = 7; - } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); @@ -7200,320 +7190,316 @@ } case SPELL_DARK_CONTROL_UNDEAD: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( v731 == 1 || v731 == 2 ) - { - v598 = 180 * v2; - LODWORD(v733) = v598; - goto LABEL_1082; - } - if ( v731 == 3 ) - { - v598 = 300 * v2; - LODWORD(v733) = v598; - goto LABEL_1082; - } - if ( v731 == 4 ) - LODWORD(v733) = 29030400; -LABEL_1082: - if (PID_TYPE(a2) != OBJECT_Actor) - { + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( v731 == 1 || v731 == 2 ) + { + v598 = 180 * v2; + LODWORD(v733) = v598; + } + else if ( v731 == 3 ) + { + v598 = 300 * v2; + LODWORD(v733) = v598; + } + else if ( v731 == 4 ) + LODWORD(v733) = 29030400; +// LABEL_1082: + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + break; + } + v730 = 836 * PID_ID(a2); + if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + break; + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 0xAu) ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->spellnum = 0; + continue; + } + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[1].Reset(); + pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), + v731, 0, 0, 0); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_level = v2; + pSpellSprite.spell_skill = v731; + v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + v61 = PID_ID(a2); +// LABEL_1086: + v600 = pActors[v61].vPosition.y; + v601 = pActors[v61].vPosition.x; + pSpellSprite.uObjectDescID = v60; + pSpellSprite.vPosition.x = v601; + v602 = pActors[v61].uActorHeight; + v603 = pActors[v61].vPosition.z; + pSpellSprite.vPosition.y = v600; + v676 = v603 + v602; + v665 = v600; + pSpellSprite.vPosition.z = v603 + v602; + v657 = v601; +// LABEL_1087: + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80u; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); LODWORD(v727) = 1; break; } - v730 = 836 * PID_ID(a2); - if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - break; - if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 0xAu) ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; - continue; - } - pActors[PID_ID(a2)].pActorBuffs[9].Reset(); - pActors[PID_ID(a2)].pActorBuffs[1].Reset(); - pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), - v731, 0, 0, 0); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - v61 = PID_ID(a2); -LABEL_1086: - v600 = pActors[v61].vPosition.y; - v601 = pActors[v61].vPosition.x; - pSpellSprite.uObjectDescID = v60; - pSpellSprite.vPosition.x = v601; - v602 = pActors[v61].uActorHeight; - v603 = pActors[v61].vPosition.z; - pSpellSprite.vPosition.y = v600; - v676 = v603 + v602; - v665 = v600; - pSpellSprite.vPosition.z = v603 + v602; - v657 = v601; -LABEL_1087: - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(pSpellSprite.uAttributes) |= 0x80u; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); - LODWORD(v727) = 1; - break; - } case SPELL_DARK_SACRIFICE: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - HIDWORD(v733) = 0; - memset(&achieved_awards, 0, 4000); - _this = 0; - v605 = (char *)pParty->pHirelings; - do - { - if ( *(int *)v605) - { - v606 = HIDWORD(v733)++; - achieved_awards[v606] = (AwardType)(int)((char *)&_this->uItemID + 1); - } - _this = (ItemGen *)((char *)_this + 1); - v605 += 76; - } - while ( (signed int)v605 < (signed int)&pParty->pPickedItem ); - _this = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0) - { - v730 = (int)pNPCStats->pNewNPCData; - __debugbreak(); // data offset - HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152; + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + HIDWORD(v733) = 0; + memset(&achieved_awards, 0, 4000); + _this = 0; + v605 = (char *)pParty->pHirelings; do { - if ( *(char *)(v730 + 8) & 0x80 - && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v730, pParty->pHirelings[0].pName)) - && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v730, pParty->pHirelings[1].pName)) ) - { - v607 = HIDWORD(v733); - HIDWORD(v733) += 4; - *(int *)v607 = (int)_this + 3; - } - _this = (ItemGen *)((char *)_this + 1); - v730 += 76; - } - while ( (signed int)this < (signed int)pNPCStats->uNumNewNPCs ); - } - v608 = pCastSpell->uPlayerID_2; - if ( v608 != 4 && v608 != 5 - || (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0) - || v609 >= 3 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; - continue; - } - v610 = 76 * v609; - *((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0; - v611 = pIconsFrameTable->FindIcon("spell96"); - *(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + v610 + 4) = pIconsFrameTable->GetIconAnimLength(v611); - *(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[3].field_18 + v610) = 1; - v612 = pParty->pPlayers; - do - { - v612->sHealth = v612->GetMaxHealth(); - v612->sMana = v612->GetMaxMana(); - ++v612; - } - while ( v612 <= &pParty->pPlayers[3] ); - v613 = &pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) - v613 = &pIndoor->dlv; - v613->uReputation += 15; - if ( v613->uReputation > 10000 ) - v613->uReputation = 10000; - LODWORD(v727) = 1; - break; - } - case SPELL_DARK_PAIN_REFLECTION: - { - if ( v731 <= 0 ) - goto LABEL_1119; - if ( v731 <= 3 ) - { - v614 = 300 * (v2 + 12); - } - else - { - if ( v731 != 4 ) - goto LABEL_1119; - v614 = 900 * (v2 + 4); - } - LODWORD(v733) = v614; -LABEL_1119: - v615 = v2 + 5; - amount = v615; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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); + if ( *(int *)v605) + { + v606 = HIDWORD(v733)++; + achieved_awards[v606] = (AwardType)(int)((char *)&_this->uItemID + 1); + } + _this = (ItemGen *)((char *)_this + 1); + v605 += 76; + } + while ( (signed int)v605 < (signed int)&pParty->pPickedItem ); + _this = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0) + { + v730 = (int)pNPCStats->pNewNPCData; + __debugbreak(); // data offset + HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152; + do + { + if ( *(char *)(v730 + 8) & 0x80 + && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v730, pParty->pHirelings[0].pName)) + && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v730, pParty->pHirelings[1].pName)) ) + { + v607 = HIDWORD(v733); + HIDWORD(v733) += 4; + *(int *)v607 = (int)_this + 3; + } + _this = (ItemGen *)((char *)_this + 1); + v730 += 76; + } + while ( (signed int)this < (signed int)pNPCStats->uNumNewNPCs ); + } + v608 = pCastSpell->uPlayerID_2; + if ( v608 != 4 && v608 != 5 + || (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0) + || v609 >= 3 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->spellnum = 0; + continue; + } + v610 = 76 * v609; + *((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0; + v611 = pIconsFrameTable->FindIcon("spell96"); + *(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + v610 + 4) = pIconsFrameTable->GetIconAnimLength(v611); + *(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[3].field_18 + v610) = 1; + v612 = pParty->pPlayers; + do + { + v612->sHealth = v612->GetMaxHealth(); + v612->sMana = v612->GetMaxMana(); + ++v612; + } + while ( v612 <= &pParty->pPlayers[3] ); + v613 = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) + v613 = &pIndoor->dlv; + v613->uReputation += 15; + if ( v613->uReputation > 10000 ) + v613->uReputation = 10000; LODWORD(v727) = 1; break; } - a2 = 0; - v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); - v619 = pParty->pPlayers;//[0].pPlayerBuffs[10]; - do - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); - v619->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); - ++a2; - ++v619; - } - while ( v619 <= &pParty->pPlayers[3] ); - LODWORD(v727) = 1; - break; - } - case SPELL_DARK_SOULDRINKER: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetIndoorCamera(); - v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth(); - HIDWORD(v733) = sub_46A6AC((int)dword_50BF30, 100, v623); - v707.x = 0; - v707.y = 0; - v707.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; - pSpellSprite.spell_level = v2; - pSpellSprite.spell_skill = v731; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - a2 = 0; - int _v726 = 0; - if ( SHIDWORD(v733) > 0 ) - { - _v726 = (HIDWORD(v733) * (7 * v2 + 25)); + case SPELL_DARK_PAIN_REFLECTION: + { + if ( v731 > 0 && v731 <= 4 ) + { + if ( v731 <= 3 ) + { + v614 = 300 * (v2 + 12); + } + if ( v731 == 4 ) + { + v614 = 900 * (v2 + 4); + } + LODWORD(v733) = v614; + } + v615 = v2 + 5; + amount = v615; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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); + LODWORD(v727) = 1; + break; + } + a2 = 0; + v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); + v619 = pParty->pPlayers;//[0].pPlayerBuffs[10]; do { - v625 = dword_50BF30[a2]; - pSpellSprite.vPosition.x = pActors[v625].vPosition.x; - pSpellSprite.vPosition.y = pActors[v625].vPosition.y; - //v732 = pActors[v625].uActorHeight; - pSpellSprite.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - v627 = pSpellSprite.Create(0, 0, 0, 0); - v628 = a2; - DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707); - a2 = v628 + 1; - } - while ( v628 + 1 < SHIDWORD(v733) ); - } - v730 = 0; - v629 = 1; - do - { - v630 = pPlayers[v629]; - if ( !v630->pConditions[2] - && !v630->pConditions[12] - && !v630->pConditions[13] - && !v630->pConditions[14] - && !v630->pConditions[15] - && !v630->pConditions[16] ) - { - v631 = v730++; - v681[v631] = v629; - } - ++v629; - } - while ( v629 <= 4 ); - v732 = (signed __int64)((double)(signed int)_v726 / (double)v730); - HIDWORD(v733) = 0; - if ( v730 > 0 ) - { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); + v619->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); + ++a2; + ++v619; + } + while ( v619 <= &pParty->pPlayers[3] ); + LODWORD(v727) = 1; + break; + } + case SPELL_DARK_SOULDRINKER: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetIndoorCamera(); + v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth(); + HIDWORD(v733) = sub_46A6AC((int)dword_50BF30, 100, v623); + v707.x = 0; + v707.y = 0; + v707.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_level = v2; + pSpellSprite.spell_skill = v731; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + a2 = 0; + int _v726 = 0; + if ( SHIDWORD(v733) > 0 ) + { + _v726 = (HIDWORD(v733) * (7 * v2 + 25)); + do + { + v625 = dword_50BF30[a2]; + pSpellSprite.vPosition.x = pActors[v625].vPosition.x; + pSpellSprite.vPosition.y = pActors[v625].vPosition.y; + //v732 = pActors[v625].uActorHeight; + pSpellSprite.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + v627 = pSpellSprite.Create(0, 0, 0, 0); + v628 = a2; + DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707); + a2 = v628 + 1; + } + while ( v628 + 1 < SHIDWORD(v733) ); + } + v730 = 0; + v629 = 1; do { - //v632 = 4 * v681[HIDWORD(v733)] + 10965188; - v726 = pPlayers[v681[HIDWORD(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); - - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, WORD2(v733)); - HIDWORD(v733) = v635 + 1; - } - while ( v635 + 1 < v730 ); - } - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 0x40u); + v630 = pPlayers[v629]; + if ( !v630->pConditions[2] + && !v630->pConditions[12] + && !v630->pConditions[13] + && !v630->pConditions[14] + && !v630->pConditions[15] + && !v630->pConditions[16] ) + { + v631 = v730++; + v681[v631] = v629; + } + ++v629; + } + while ( v629 <= 4 ); + v732 = (signed __int64)((double)(signed int)_v726 / (double)v730); + HIDWORD(v733) = 0; + if ( v730 > 0 ) + { + do + { + //v632 = 4 * v681[HIDWORD(v733)] + 10965188; + v726 = pPlayers[v681[HIDWORD(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); + + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, WORD2(v733)); + HIDWORD(v733) = v635 + 1; + } + while ( v635 + 1 < v730 ); + } + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 0x40u); LODWORD(v727) = 1; break; } case SPELL_DARK_ARMAGEDDON: { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; - continue; - } - v640 = v731 - 2; - if ( !v640 || (v641 = v640 - 1) == 0 || (amount = 4, v641 != 1) ) - amount = 3; - if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pParty->armageddon_timer = 256; - pParty->field_16140 = v2; - ++pPlayer->uNumArmageddonCasts; - if ( pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - auto _v726 = 50; - do - { - v642 = rand() % 4096 - 2048; - v643 = rand(); - v721 = v642 + pParty->vPosition.x; - y = (char *)(pParty->vPosition.y + v643 % 4096 - 2048); - v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, 0); - v644 = rand(); - sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, 0, 0, 0); - --_v726; - } - while ( _v726 != 0 ); + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->spellnum = 0; + continue; + } + v640 = v731 - 2; + if ( !v640 || (v641 = v640 - 1) == 0 || (amount = 4, v641 != 1) ) + amount = 3; + if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pParty->armageddon_timer = 256; + pParty->field_16140 = v2; + ++pPlayer->uNumArmageddonCasts; + if ( pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + auto _v726 = 50; + do + { + v642 = rand() % 4096 - 2048; + v643 = rand(); + v721 = v642 + pParty->vPosition.x; + y = (char *)(pParty->vPosition.y + v643 % 4096 - 2048); + v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, 0); + v644 = rand(); + sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, 0, 0, 0); + --_v726; + } + while ( _v726 != 0 ); LODWORD(v727) = 1; break; } default: - break; + break; } if ( pCastSpell->field_8 & 0x20 ) { @@ -7542,22 +7528,13 @@ pPlayer->PlaySound(SPEECH_49, 0); if ( v727 != 0.0 ) pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); - pCastSpell->spellnum = 0; - v2 = v723; - continue; } } pCastSpell->spellnum = 0; v2 = v723; continue; - -//LABEL_1166: -// ++n; -// if ( n >= 10 ) -// return; } - } //----- (0042EB42) -------------------------------------------------------- __int16 ObjectList::ObjectIDByItemID(unsigned __int16 uItemID)