Mercurial > mm7
changeset 890:dba25247e74f
massive cast spell clean
author | zipi |
---|---|
date | Wed, 03 Apr 2013 00:44:11 +0100 |
parents | 279a315ff122 |
children | 18f785019d36 |
files | mm7_6.cpp |
diffstat | 1 files changed, 3673 insertions(+), 3635 deletions(-) [+] |
line wrap: on
line diff
--- a/mm7_6.cpp Tue Apr 02 23:02:04 2013 +0100 +++ b/mm7_6.cpp Wed Apr 03 00:44:11 2013 +0100 @@ -2651,7 +2651,7 @@ int v219; // ecx@425 int v220; // ecx@426 int v221; // edi@428 - char *v222; // edi@434 + Player *v222; // edi@434 char v223; // al@438 int v224; // ecx@442 int v225; // ecx@443 @@ -3299,20 +3299,23 @@ LODWORD(v725) == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0) uRequiredMana = 0; - if (v3->spellnum >= SPELL_BOW_ARROW || pPlayer->sMana >= uRequiredMana) + if (v3->spellnum < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana) { - v730 = v3->spellnum; - if (pPlayer->Cursed() && v3->spellnum < SPELL_BOW_ARROW) - if (rand() % 100 < 50) - { - if (!pParty->bTurnBasedModeOn) - { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points" + v3->spellnum = 0; + continue; + } + v730 = v3->spellnum; + if (pPlayer->Cursed() && v3->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50) + { + if (!pParty->bTurnBasedModeOn) + { //v646 = pPlayer; pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); //v647 = n; - } - else - { + } + else + { //v647 = n; //v646 = pPlayer; //v648 = sRecoveryTime; @@ -3320,24 +3323,24 @@ pParty->pTurnBasedPlayerRecoveryTimes[v711[n].uPlayerID] = 100; pPlayer->SetRecoveryTime(sRecoveryTime); pTurnEngine->_40471C(); - } - - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed" - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v711[n].spellnum = 0; - pPlayer->sMana -= uRequiredMana; - return; - } - - switch ( v3->spellnum ) - { - case SPELL_101: - assert(false && "Unknown spell effect #101 (prolly flaming bow arrow"); - case SPELL_BOW_ARROW: + } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed" + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v711[n].spellnum = 0; + pPlayer->sMana -= uRequiredMana; + return; + } + + switch ( v3->spellnum ) + { + case SPELL_101: + assert(false && "Unknown spell effect #101 (prolly flaming bow arrow"); + case SPELL_BOW_ARROW: + { v17 = pPlayer; _this = (ItemGen *)1; if ( (signed int)SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 ) - _this = (ItemGen *)2; + _this = (ItemGen *)2; sRecoveryTime = v17->GetAttackRecoveryTime(true); a1.stru_24.Reset(); a1.spell_level = v2; @@ -3345,7 +3348,7 @@ a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); if ( v17->WearsItem(510, 2) ) - a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u); + a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; a1.uAttributes = 0; @@ -3360,23 +3363,24 @@ memcpy(&a1.stru_24, &v20[v20->pEquipment.uBow], sizeof(a1.stru_24)); a1.uAttributes = 256; if ( pParty->bTurnBasedModeOn == 1 ) - a1.uAttributes = 260; + a1.uAttributes = 260; for ( i = 0; i < (signed int)_this; ++i ) { - if ( i ) + if ( i ) a1.vPosition.z += 32; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - if ( a1.Create( - v715.uYawAngle, - v715.uPitchAngle, - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, - v3->uPlayerID + 1) != -1 + a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); + if ( a1.Create( + v715.uYawAngle, + v715.uPitchAngle, + pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, + v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; } - goto play_sound_and_continue; - - case SPELL_LASER_PROJECTILE: + break; + } + case SPELL_LASER_PROJECTILE: + { sRecoveryTime = pPlayer->GetAttackRecoveryTime(0); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; @@ -3394,262 +3398,264 @@ a1.uFacing = LOWORD(v715.uYawAngle); a1.uSoundID = LOWORD(v3->sound_id); memcpy( - &a1.stru_24, - &pParty->pPlayers[v3->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36 - * pParty->pPlayers[v3->uPlayerID].pEquipment.uMainHand - + 5], - sizeof(a1.stru_24)); + &a1.stru_24, + &pParty->pPlayers[v3->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36 + * pParty->pPlayers[v3->uPlayerID].pEquipment.uMainHand + + 5], + sizeof(a1.stru_24)); v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, a1.vPosition.z); HIBYTE(a1.uAttributes) |= 1u; a1.uSectorID = v23; if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; + LOBYTE(a1.uAttributes) |= 4u; if ( a1.Create( - v715.uYawAngle, - v715.uPitchAngle, - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, - v3->uPlayerID + 1) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - goto play_sound_and_continue; - - case SPELL_FIRE_TORCH_LIGHT: + v715.uYawAngle, + v715.uPitchAngle, + pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, + v3->uPlayerID + 1) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + break; + } + case SPELL_FIRE_TORCH_LIGHT: + { LODWORD(v733) = 3600 * v2; switch (v731) { - case 1: amount = 2; break; - case 2: amount = 3; break; - case 3: - case 4: amount = 4; break; - default: + case 1: amount = 2; break; + case 2: amount = 3; break; + case 3: + case 4: amount = 4; break; + default: assert(false); } if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * v2 * 4.2666669), v731, amount, 0, 0); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_FIRE_FIRE_SPIKE: - { - v29 = v731 - 2; - if ( v29 ) - { - v30 = v29 - 1; - if ( v30 ) - { - if ( v30 == 1 ) - amount = 9; - else - amount = 3; - } - else - { - amount = 7; - } + break; + } + case SPELL_FIRE_FIRE_SPIKE: + { + v29 = v731 - 2; + if ( v29 ) + { + v30 = v29 - 1; + if ( v30 ) + { + if ( v30 == 1 ) + amount = 9; + else + amount = 3; } else { - amount = 5; - } - //v31 = v3->uPlayerID; - //v32 = 8 * v31; - //LOBYTE(v32) = v32 | OBJECT_Player; - - //if ( (signed int)uNumSpriteObjects > 0 ) - int _v733 = 0; - for (uint i = 0; i < uNumSpriteObjects; ++i) - { - auto object = pSpriteObjects + i; - if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, v3->uPlayerID)) - ++_v733; - /*v33 = (char *)&pSpriteObjects[0].field_48; - v730 = uNumSpriteObjects; - do - { - if ( *((short *)v33 - 36) && *(int *)v33 == 7 && *((int *)v33 + 4) == v32 ) - ++HIDWORD(v733); - v33 += 112; - --v730; - } - while ( v730 );*/ - } - if (_v733 > amount) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.uAttributes = 0; - a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uFacing = LOWORD(v715.uYawAngle); - a1.uSoundID = LOWORD(v3->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; - v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - if ( a1.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; + amount = 7; + } + } + else + { + amount = 5; + } + //v31 = v3->uPlayerID; + //v32 = 8 * v31; + //LOBYTE(v32) = v32 | OBJECT_Player; + + //if ( (signed int)uNumSpriteObjects > 0 ) + int _v733 = 0; + for (uint i = 0; i < uNumSpriteObjects; ++i) + { + auto object = pSpriteObjects + i; + if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, v3->uPlayerID)) + ++_v733; + /*v33 = (char *)&pSpriteObjects[0].field_48; + v730 = uNumSpriteObjects; + do + { + if ( *((short *)v33 - 36) && *(int *)v33 == 7 && *((int *)v33 + 4) == v32 ) + ++HIDWORD(v733); + v33 += 112; + --v730; + } + while ( v730 );*/ + } + if (_v733 > amount) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.uAttributes = 0; + a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + a1.uSectorID = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uFacing = LOWORD(v715.uYawAngle); + a1.uSoundID = LOWORD(v3->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + if ( a1.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + break; + } + + case SPELL_AIR_IMPLOSION: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if (!a2) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + if (PID_TYPE(a2) != OBJECT_Actor) + { LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 20: - { + break; + } + v697.x = 0; + v697.y = 0; + v697.z = 0; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2)); + auto obj_id = a1.Create(0, 0, 0, 0); + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697); + LODWORD(v727) = 1; + break; + } + + case SPELL_EARTH_MASS_DISTORTION: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) ) + { + LODWORD(v727) = 1; + break; + } + pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); + v704.x = 0; + v704.y = 0; + v704.z = 0; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; + a1.spell_target_pid = PID(OBJECT_Actor, (int)v726); + + auto obj_id = a1.Create(0, 0, 0, 0); + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704); + + LODWORD(v727) = 1; + break; + } + + case SPELL_LIGHT_DESTROY_UNDEAD: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor) + break; + //v730 = a2 >> 3; + //HIDWORD(v733) = (int)&pActors[PID_ID(a2)]; + v691.x = 0; + v691.y = 0; + v691.z = 0; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; + a1.uAttributes = 0; + a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uFacing = LOWORD(v715.uYawAngle); + a1.uAttributes |= 0x80u; + a1.uSoundID = LOWORD(v3->sound_id); + + auto obj_id = a1.Create(0, 0, 0, 0); + if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); + LODWORD(v727) = 1; + break; + } + + + case SPELL_FIRE_FIRE_BOLT: + case SPELL_FIRE_FIREBALL: + case SPELL_FIRE_INCINERATE: + case SPELL_AIR_LIGHNING_BOLT: + case SPELL_WATER_ICE_BOLT: + case SPELL_WATER_ICE_BLAST: + case SPELL_EARTH_STUN: + case SPELL_EARTH_DEADLY_SWARM: + case SPELL_MIND_MIND_BLAST: + case SPELL_MIND_PSYCHIC_SHOCK: + case SPELL_BODY_HARM: + case SPELL_LIGHT_LIGHT_BOLT: + case SPELL_DARK_DRAGON_BREATH: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - if (!a2) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - if (PID_TYPE(a2) != OBJECT_Actor) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v697.x = 0; - v697.y = 0; - v697.z = 0; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; - a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; - a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; - a1.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2)); - auto obj_id = a1.Create(0, 0, 0, 0); - DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 44: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); - v704.x = 0; - v704.y = 0; - v704.z = 0; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; - a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; - a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; - a1.spell_target_pid = PID(OBJECT_Actor, (int)v726); - - auto obj_id = a1.Create(0, 0, 0, 0); - DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704); - - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 79: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor) - goto play_sound_and_continue; - //v730 = a2 >> 3; - //HIDWORD(v733) = (int)&pActors[PID_ID(a2)]; - v691.x = 0; - v691.y = 0; - v691.z = 0; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; - a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; - a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uFacing = LOWORD(v715.uYawAngle); - a1.uAttributes |= 0x80u; - a1.uSoundID = LOWORD(v3->sound_id); - - auto obj_id = a1.Create(0, 0, 0, 0); - if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - - case SPELL_FIRE_FIRE_BOLT: - case SPELL_FIRE_FIREBALL: - case SPELL_FIRE_INCINERATE: - case SPELL_AIR_LIGHNING_BOLT: - case SPELL_WATER_ICE_BOLT: - case SPELL_WATER_ICE_BLAST: - case SPELL_EARTH_STUN: - case SPELL_EARTH_DEADLY_SWARM: - case SPELL_MIND_MIND_BLAST: - case SPELL_MIND_PSYCHIC_SHOCK: - case SPELL_BODY_HARM: - case SPELL_LIGHT_LIGHT_BOLT: - case SPELL_DARK_DRAGON_BREATH: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -3660,7 +3666,7 @@ a1.uAttributes = 0; a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); else a1.uSectorID = 0; @@ -3672,24 +3678,23 @@ a1.uFacing = LOWORD(v715.uYawAngle); a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; + LOBYTE(a1.uAttributes) |= 4u; if ( v3->spellnum == SPELL_AIR_LIGHNING_BOLT ) - LOBYTE(a1.uAttributes) |= 0x40u; - - v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 0x40u; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; LODWORD(v727) = 1; - goto play_sound_and_continue; - - - - case 29: - case 39: - case 76: - case 90: + break; + } + case SPELL_WATER_ACID_BURST: + case SPELL_EARTH_BLADES: + case SPELL_BODY_FLYING_FIST: + case SPELL_DARK_TOXIC_CLOUD: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -3700,131 +3705,135 @@ v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; v660 = pParty->vPosition.y; goto LABEL_153; - case 87: + } + case SPELL_LIGHT_SUNRAY: + { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor - || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 0x15) ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; + || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 0x15) ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; } if ( pPlayer->CanCastSpell(uRequiredMana) ) - goto LABEL_152; - goto play_sound_and_continue; - - - case 81: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - if (PID_TYPE(a2) != OBJECT_Actor || - (v730 = PID_ID(a2), - v721 = (int)&pActors[PID_ID(a2)], - !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9u)) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - Actor::AI_Stand(PID_ID(a2), 4u, 0x80u, 0); - v54 = (signed __int64)((double)(23040 * v2) * 0.033333335); - v55 = v721; - ((SpellBuff *)(v721 + 308))->Apply(pParty->uTimePlayed + (signed int)v54, v731, 0, 0, 0); - *(char *)(v55 + 38) |= 8u; - *(short *)(v55 + 148) = 0; - v672 = 0; - *(short *)(v55 + 150) = 0; - v661 = (Actor *)v55; - goto LABEL_165; - } - - case 35: + goto LABEL_152; + break; + } + + case SPELL_LIGHT_PARALYZE: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + if (PID_TYPE(a2) != OBJECT_Actor || + (v730 = PID_ID(a2), + v721 = (int)&pActors[PID_ID(a2)], + !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9u)) ) + { + LODWORD(v727) = 1; + break; + } + Actor::AI_Stand(PID_ID(a2), 4u, 0x80u, 0); + v54 = (signed __int64)((double)(23040 * v2) * 0.033333335); + v55 = v721; + ((SpellBuff *)(v721 + 308))->Apply(pParty->uTimePlayed + (signed int)v54, v731, 0, 0, 0); + *(char *)(v55 + 38) |= 8u; + *(short *)(v55 + 148) = 0; + v672 = 0; + *(short *)(v55 + 150) = 0; + v661 = (Actor *)v55; + goto LABEL_165; + } + + case SPELL_EARTH_SLOW: + { if ( v731 == 2 ) { - v57 = 300 * v2; + v57 = 300 * v2; } else { - if ( v731 == 3 ) - { + if ( v731 == 3 ) + { amount = 4; v57 = 300 * v2; goto LABEL_174; - } - if ( v731 == 4 ) - { + } + if ( v731 == 4 ) + { v57 = 300 * v2; amount = 8; goto LABEL_174; - } - v57 = 180 * v2; + } + v57 = 180 * v2; } amount = 2; LABEL_174: LODWORD(v733) = v57; if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; if (PID_TYPE(a2) != OBJECT_Actor - || (v721 = 836 * PID_ID(a2), - LODWORD(v718) = (int)&pActors[PID_ID(a2)], - !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u)) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; + || (v721 = 836 * PID_ID(a2), + LODWORD(v718) = (int)&pActors[PID_ID(a2)], + !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u)) ) + { + LODWORD(v727) = 1; + break; } v58 = (signed __int64)((double)(23040 * v2) * 0.033333335); v59 = v721; //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply( pActors[PID_ID(a2)].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, - v731, - amount, - 0, - 0); + v731, + amount, + 0, + 0); *((char *)&pActors[0].uAttributes + v59 + 2) |= 8u; v672 = 0; v661 = (Actor *)LODWORD(v718); goto LABEL_165; - - - case 60: - { + } + + case SPELL_MIND_CHARM: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) + { + LODWORD(v727) = 1; + break; + } + + uint power = 300 * v2; + if ( v731 == 2 ) + { + power = 600 * v2; + } + else if ( v731 == 3 ) + power = 29030400; + + //((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset(); + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); + //((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset(); + pActors[PID_ID(a2)].pActorBuffs[12].Reset(); + //((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply( + pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), + v731, 0, 0, 0); + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + v60 = pObjectList->ObjectIDByItemID(a1.uType); + v61 = PID_ID(a2); + goto LABEL_1086; + } + + case SPELL_DARK_SHRINKING_RAY: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - uint power = 300 * v2; - if ( v731 == 2 ) - { - power = 600 * v2; - } - else if ( v731 == 3 ) - power = 29030400; - - //((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset(); - pActors[PID_ID(a2)].pActorBuffs[9].Reset(); - //((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset(); - pActors[PID_ID(a2)].pActorBuffs[12].Reset(); - //((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply( - pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), - v731, 0, 0, 0); - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = PID_ID(a2); - goto LABEL_1086; - } - - case 92: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; a1.stru_24.Reset(); a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; @@ -3832,9 +3841,9 @@ a1.uAttributes = 0; a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + pParty->vPosition.x, + pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = a2; @@ -3844,133 +3853,75 @@ a1.spell_skill = v731; a1.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE; a1.spell_level = 300 * v2; - if ( pParty->bTurnBasedModeOn == 1 ) + if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - - if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 4: - { + break; + } + case SPELL_FIRE_FIRE_AURA: + { v63 = v731 - 1; if ( !v63 ) { - amount = 10; - goto LABEL_195; - } + amount = 10; + LODWORD(v733) = 3600 * v2; + } + else + { v64 = v63 - 1; if ( !v64 ) { - amount = 11; - goto LABEL_195; - } + amount = 11; + LODWORD(v733) = 3600 * v2; + } + else + { v65 = v64 - 1; if ( !v65 ) { - amount = 12; + amount = 12; LABEL_195: - LODWORD(v733) = 3600 * v2; - goto LABEL_196; - } - if ( v65 == 1 ) - { - LODWORD(v733) = 0; - amount = 12; + LODWORD(v733) = 3600 * v2; + } + else if ( v65 == 1 ) + { + LODWORD(v733) = 0; + amount = 12; + } + } } LABEL_196: if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; v730c = &pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2]; auto _itm = &pItemsTable->pItems[v730c->uItemID]; v730c->UpdateTempBonus(pParty->uTimePlayed); - if ( v730c->uItemID < 64 || v730c->uItemID > 65 ) - { - if (!v730c->Broken()) - { - if (!v730c->uSpecEnchantmentType) + if ( v730c->uItemID < 64 || v730c->uItemID > 65 + && !v730c->Broken() + && !v730c->uSpecEnchantmentType + && !v730c->uEnchantmentType + && ( _itm->uEquipType == 0 || _itm->uEquipType == 1 || _itm->uEquipType == 2) + && !pItemsTable->IsMaterialNonCommon(v730c) ) + { + v69 = v730c; + v14 = v731 == 4; + v730c->uSpecEnchantmentType = amount; + if ( !v14 ) { - if (!v730c->uEnchantmentType) - { - v68 = _itm->uEquipType; - if ( !v68 || v68 == 1 || v68 == 2 ) - { - if ( !pItemsTable->IsMaterialNonCommon(v730c) ) - { - v69 = v730c; - v14 = v731 == 4; - *(int *)(v730 + 12) = amount; - if ( !v14 ) - { - *(_QWORD *)(v69 + 28) = pParty->uTimePlayed - + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) - * 0.033333335); - *(int *)(v69 + 20) |= 8u; - } - *(int *)(v69 + 20) |= 0x10u; - dword_50C9A8 = 256; - LODWORD(v727) = 1; - play_sound_and_continue: - if ( v3->field_8 & 0x20 ) - { - if ( v727 != 0.0 ) - pAudioPlayer->PlaySound( - (SoundID)word_4EE088_sound_ids[v3->spellnum], - 0, - 0, - -1, - 0, - v3->sound_id, - 0, - 0); - } - else - { - if ( sRecoveryTime < 0 ) - sRecoveryTime = 0; - if ( pParty->bTurnBasedModeOn ) - { - v645 = sRecoveryTime; - pParty->pTurnBasedPlayerRecoveryTimes[v3->uPlayerID] = sRecoveryTime; - pPlayer->SetRecoveryTime(v645); - if ( !some_active_character ) - pTurnEngine->_40471C(); - } - else - { - pPlayer->SetRecoveryTime( - (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333)); - } - if ( v727 != 0.0 ) - { - pPlayer->PlaySound(SPEECH_49, 0); - if ( v727 != 0.0 ) - pAudioPlayer->PlaySound( - (SoundID)word_4EE088_sound_ids[v3->spellnum], - 0, - 0, - -1, - 0, - v3->sound_id, - 0, - 0); - - v3->spellnum = 0; - v2 = v723; - continue; - } - } - v3->spellnum = 0; - v2 = v723; - continue; - } - } - } + v69->uExpireTime = pParty->uTimePlayed + + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) + * 0.033333335); + v69->uAttributes |= 8u; } - } + v69->uAttributes |= 0x10u; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + break; } dword_50C9D0 = 113; @@ -3979,104 +3930,105 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - - case SPELL_BODY_REGENERATION: - { - v70 = v731 - 1; - LODWORD(v733) = 3600 * v2; - if ( v70 && (v71 = v70 - 1) != 0 ) - { - v72 = v71 - 1; - if ( v72 ) - { - if ( v72 == 1 ) - amount = 10; - } - else - { - amount = 3; - } + v3->spellnum = 0; + continue; + } + + case SPELL_BODY_REGENERATION: + { + v70 = v731 - 1; + LODWORD(v733) = 3600 * v2; + if ( v70 && (v71 = v70 - 1) != 0 ) + { + v72 = v71 - 1; + if ( v72 ) + { + if ( v72 == 1 ) + amount = 10; } else { - amount = 1; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case SPELL_FIRE_PROTECTION_FROM_FIRE: - case SPELL_AIR_PROTECTION_FROM_AIR: - case SPELL_WATER_PROTECTION_FROM_WATER: - case SPELL_EARTH_PROTECTION_FROM_EARTH: - case SPELL_MIND_PROTECTION_FROM_MIND: - case SPELL_BODY_PROTECTION_FROM_BODY: + amount = 3; + } + } + else + { + amount = 1; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + + pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0); + LODWORD(v727) = 1; + break; + } + + case SPELL_FIRE_PROTECTION_FROM_FIRE: + case SPELL_AIR_PROTECTION_FROM_AIR: + case SPELL_WATER_PROTECTION_FROM_WATER: + case SPELL_EARTH_PROTECTION_FROM_EARTH: + 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 ) - { + v77 = v76 - 1; + if ( v77 ) + { v78 = v77 - 1; if ( v78 ) { - if ( v78 != 1 ) + if ( v78 != 1 ) goto LABEL_232; - v79 = 4 * v2; + v79 = 4 * v2; } else { - v79 = 3 * v2; + v79 = 3 * v2; + } } - } - else - { + else + { v79 = 2 * v2; - } - amount = v79; + } + amount = v79; } else { - amount = v2; + amount = v2; } LABEL_232: //v80 = v3->spellnum; switch (v3->spellnum) { - case SPELL_FIRE_PROTECTION_FROM_FIRE: + case SPELL_FIRE_PROTECTION_FROM_FIRE: LODWORD(v725) = PARTY_BUFF_RESIST_FIRE; break; - case SPELL_AIR_PROTECTION_FROM_AIR: + case SPELL_AIR_PROTECTION_FROM_AIR: LODWORD(v725) = PARTY_BUFF_RESIST_AIR; break; - case SPELL_WATER_PROTECTION_FROM_WATER: + case SPELL_WATER_PROTECTION_FROM_WATER: LODWORD(v725) = PARTY_BUFF_RESIST_WATER; break; - case SPELL_EARTH_PROTECTION_FROM_EARTH: + case SPELL_EARTH_PROTECTION_FROM_EARTH: LODWORD(v725) = PARTY_BUFF_RESIST_EARTH; break; - case SPELL_MIND_PROTECTION_FROM_MIND: + case SPELL_MIND_PROTECTION_FROM_MIND: LODWORD(v725) = PARTY_BUFF_RESIST_MIND; break; - case SPELL_BODY_PROTECTION_FROM_BODY: + case SPELL_BODY_PROTECTION_FROM_BODY: LODWORD(v725) = PARTY_BUFF_RESIST_BODY; break; - default: + default: assert(false); continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); @@ -4086,147 +4038,150 @@ v90 = (double)(signed int)v733 * 4.2666669; pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_FIRE_HASTE: + break; + } + case SPELL_FIRE_HASTE: + { if ( v731 <= 0 ) - goto LABEL_254; + goto LABEL_254; if ( v731 <= 2 ) { - v91 = 60 * (v2 + 60); + v91 = 60 * (v2 + 60); } else { - if ( v731 == 3 ) - { + if ( v731 == 3 ) + { v91 = 180 * (v2 + 20); - } - else - { + } + else + { if ( v731 != 4 ) - goto LABEL_254; + goto LABEL_254; v91 = 240 * (v2 + 15); - } + } } LODWORD(v733) = v91; LABEL_254: if ( pPlayer->CanCastSpell(uRequiredMana) ) { - v92 = pParty->pPlayers;//[0].pConditions[1]; - LODWORD(v727) = 1; - do - { + v92 = pParty->pPlayers;//[0].pConditions[1]; + LODWORD(v727) = 1; + do + { if ( v92->pConditions ) - LODWORD(v727) = 0; + LODWORD(v727) = 0; ++v92; - } - while ( v92 <= &pParty->pPlayers[3] ); - if (LODWORD(v727)) - { + } + 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(v3->spellnum, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - } - } - goto play_sound_and_continue; - - case SPELL_SPIRIT_BLESS: + } + } + break; + } + case SPELL_SPIRIT_BLESS: + { v101 = v731 - 1; if ( v101 && (v102 = v101 - 1) != 0 ) { - v103 = v102 - 1; - if ( v103 ) - { + v103 = v102 - 1; + if ( v103 ) + { if ( v103 != 1 ) - goto LABEL_269; + goto LABEL_269; v104 = 3600 * (v2 + 1); - } - else - { + } + else + { v104 = 900 * (v2 + 4); - } + } } else { - v104 = 300 * (v2 + 12); + v104 = 300 * (v2 + 12); } LODWORD(v733) = v104; LABEL_269: amount = v2 + 5; if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; if ( v731 == 1 ) { - v108 = v3->uPlayerID_2; - v109 = v3->spellnum; - v110 = pGame->GetStru6(); - pGame->GetStru6()->SetPlayerBuffAnim(v109, v108); - v111 = pOtherOverlayList->_4418B1(10000, v3->uPlayerID_2 + 310, 0, 65536); - //v668 = 0; - v716 = v111; - //v658 = v111; - //v653 = amount; - //v651 = 1; - //v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); - //v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS]; + v108 = v3->uPlayerID_2; + v109 = v3->spellnum; + v110 = pGame->GetStru6(); + pGame->GetStru6()->SetPlayerBuffAnim(v109, v108); + v111 = pOtherOverlayList->_4418B1(10000, v3->uPlayerID_2 + 310, 0, 65536); + //v668 = 0; + v716 = v111; + //v658 = v111; + //v653 = amount; + //v651 = 1; + //v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); + //v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS]; //LABEL_103: //HIDWORD(v650) = HIDWORD(v28); //LABEL_104: //LODWORD(v650) = v28; pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), 1, amount, v111, 0); LODWORD(v727) = 1; - goto play_sound_and_continue; + break; } v105 = 0; v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); v730b = pParty->pPlayers;//[0].pPlayerBuffs[1]; do { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v105); - v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, 0, 65536); - v730b->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); - ++v730b; - ++v105; + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v105); + v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, 0, 65536); + v730b->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); + ++v730b; + ++v105; } while ( v730b <= &pParty->pPlayers[3] ); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 52: + break; + } + case SPELL_SPIRIT_SPIRIT_LASH: + { if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor) { - //v730 = a2 >> 3; - v112 = &pActors[PID_ID(a2)]; - //v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z); - v721 = abs(v112->vPosition.y - pParty->vPosition.y); - v113 = abs(v112->vPosition.x - pParty->vPosition.x); - _this = (ItemGen *)v113; - v114 = v721; - v115 = (unsigned int)abs(v112->vPosition.z - pParty->vPosition.z); - if ( v113 < v721 ) - { + //v730 = a2 >> 3; + v112 = &pActors[PID_ID(a2)]; + //v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z); + v721 = abs(v112->vPosition.y - pParty->vPosition.y); + v113 = abs(v112->vPosition.x - pParty->vPosition.x); + _this = (ItemGen *)v113; + v114 = v721; + v115 = (unsigned int)abs(v112->vPosition.z - pParty->vPosition.z); + if ( v113 < v721 ) + { v116 = v113; v113 = v721; v114 = v116; - } - if ( v113 < (signed int)v115 ) - { + } + if ( v113 < (signed int)v115 ) + { v117 = v113; v113 = (int)v115; v115 = v117; - } - if ( v114 < (signed int)v115 ) - { + } + if ( v114 < (signed int)v115 ) + { v118 = v115; v115 = v114; v114 = v118; - } - _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113); - if ( (double)(signed int)this <= 307.2 ) - { + } + _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113); + if ( (double)(signed int)this <= 307.2 ) + { v701.x = 0; v701.y = 0; v701.z = 0; @@ -4250,64 +4205,65 @@ v122 = a1.Create(0, 0, 0, 0); DamageMonsterFromParty(PID(OBJECT_Item, v122), PID_ID(a2), &v701); LODWORD(v727) = 1; - } - else - { + } + else + { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); *(int *)HIDWORD(v733) = 0; - } - v3 = (stru277 *)HIDWORD(v733); - } - goto play_sound_and_continue; - - case SPELL_AIR_SHIELD: - case SPELL_EARTH_STONESKIN: - case SPELL_SPIRIT_HEROISM: + } + v3 = (stru277 *)HIDWORD(v733); + } + break; + } + 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 ) - { + v125 = v124 - 1; + if ( v125 ) + { if ( v125 != 1 ) - goto LABEL_296; + goto LABEL_296; v126 = 3600 * (v2 + 1); - } - else - { + } + else + { v126 = 900 * (v2 + 4); - } + } } else { - v126 = 300 * (v2 + 12); + v126 = 300 * (v2 + 12); } LODWORD(v733) = v126; LABEL_296: v127 = v3->spellnum; if ( v127 == 17 ) { - amount = 0; - LODWORD(v725) = 14; + amount = 0; + LODWORD(v725) = 14; } else { - if ( v127 == 38 ) - { + if ( v127 == 38 ) + { LODWORD(v725) = 15; amount = v2 + 5; - } - else - { + } + else + { if ( v127 != 51 ) - continue; + continue; LODWORD(v725) = 9; amount = v2 + 5; - } + } } if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); @@ -4316,17 +4272,18 @@ //LABEL_304: pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_FIRE_IMMOLATION: + break; + } + case SPELL_FIRE_IMMOLATION: + { v138 = v731 - 2; if ( v138 && (v139 = v138 - 1) != 0 && v139 == 1 ) - v140 = 600 * v2; + v140 = 600 * v2; else - v140 = 60 * v2; + v140 = 60 * v2; LODWORD(v733) = v140; if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); @@ -4335,43 +4292,44 @@ pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 9: + break; + } + case SPELL_FIRE_METEOR_SHOWER: + { v149 = v731 - 1; if ( v149 && (v150 = v149 - 1) != 0 && (v151 = v150 - 1) != 0 ) { - if ( v151 == 1 ) + if ( v151 == 1 ) _this = (ItemGen *)20; } else { - _this = (ItemGen *)16; + _this = (ItemGen *)16; } if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; LODWORD(v725) = PID_TYPE(a2); if (PID_TYPE(a2) == OBJECT_Actor) { - uRequiredMana = pActors[PID_ID(a2)].vPosition.x; - v153 = pActors[PID_ID(a2)].vPosition.y; - v154 = pActors[PID_ID(a2)].vPosition.z; - LODWORD(v727) = v153; + uRequiredMana = pActors[PID_ID(a2)].vPosition.x; + v153 = pActors[PID_ID(a2)].vPosition.y; + v154 = pActors[PID_ID(a2)].vPosition.z; + LODWORD(v727) = v153; } else { - v155 = stru_5C6E00->Cos(pParty->sRotationY); - uRequiredMana = pParty->vPosition.x + sub_42EBBE(2048, v155); - v156 = stru_5C6E00->Sin(pParty->sRotationY); - LODWORD(v727) = pParty->vPosition.y + sub_42EBBE(2048, v156); - v154 = pParty->vPosition.z; + v155 = stru_5C6E00->Cos(pParty->sRotationY); + uRequiredMana = pParty->vPosition.x + sub_42EBBE(2048, v155); + v156 = stru_5C6E00->Sin(pParty->sRotationY); + LODWORD(v727) = pParty->vPosition.y + sub_42EBBE(2048, v156); + v154 = pParty->vPosition.z; } HIDWORD(v733) = v154; v713 = v154 + 2500; @@ -4379,12 +4337,12 @@ LODWORD(v718) = 0; if ( (signed int)_this > 0 ) { - *(float *)&y = (double)SHIDWORD(v733); - *(float *)&v732 = (double)v713; - v730 = LODWORD(v725) == 3 ? a2 : 0; - auto _this_cpy = (int)_this; - do - { + *(float *)&y = (double)SHIDWORD(v733); + *(float *)&v732 = (double)v713; + v730 = LODWORD(v725) == 3 ? a2 : 0; + auto _this_cpy = (int)_this; + do + { v157 = rand(); v158 = (double)SLODWORD(v718); v718 = v158; @@ -4396,15 +4354,15 @@ *(float *)&_this = v158 * v158; if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&_this + v725) <= 1.0 ) { - LODWORD(v687) = 0; - HIDWORD(v687) = 0; + LODWORD(v687) = 0; + HIDWORD(v687) = 0; } else { - x = (signed __int64)sqrt(*(float *)&_this + v725); - v687 = __PAIR__( - stru_5C6E00->Atan2(x, (signed __int64)*((float *)&v733 + 1)), - stru_5C6E00->Atan2((signed __int64)v718, (signed __int64)*(float *)&v721)); + x = (signed __int64)sqrt(*(float *)&_this + v725); + v687 = __PAIR__( + stru_5C6E00->Atan2(x, (signed __int64)*((float *)&v733 + 1)), + stru_5C6E00->Atan2((signed __int64)v718, (signed __int64)*(float *)&v721)); } a1.stru_24.Reset(); a1.spell_id = v3->spellnum; @@ -4423,116 +4381,118 @@ a1.uFacing = v687; a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) - a1.uAttributes = 4; + a1.uAttributes = 4; if ( a1.Create( - v687, - SHIDWORD(v687), - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, - 0) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; + v687, + SHIDWORD(v687), + pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, + 0) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; LODWORD(v718) = rand() % 1024 - 512; v160 = rand(); v14 = _this_cpy-- == 1; v721 = (unsigned __int64)(v160 % 1024) - 512; - } - while ( !v14 ); + } + while ( !v14 ); } LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 10: - { - //v67 = 2; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); - v700.z = 0; - v700.y = 0; - v700.x = 0; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - a2 = 0; - if ( (signed int)_v726 > 0 ) - { - do - { - v162 = dword_50BF30[a2]; - a1.vPosition.x = pActors[v162].vPosition.x; - a1.vPosition.y = pActors[v162].vPosition.y; - a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - v164 = a1.Create(0, 0, 0, 0); - v165 = a2; - DamageMonsterFromParty(PID(OBJECT_Item, v164), dword_50BF30[a2], &v700); - pGame->GetStru6()->_4A81CA(&a1); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u); - a2 = v165 + 1; - } - while ( v165 + 1 < (signed int)_v726 ); - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case SPELL_AIR_WIZARD_EYE: + break; + } + case SPELL_FIRE_INFERNO: + { + //v67 = 2; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); + v700.z = 0; + v700.y = 0; + v700.x = 0; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + a2 = 0; + if ( (signed int)_v726 > 0 ) + { + do + { + v162 = dword_50BF30[a2]; + a1.vPosition.x = pActors[v162].vPosition.x; + a1.vPosition.y = pActors[v162].vPosition.y; + a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + v164 = a1.Create(0, 0, 0, 0); + v165 = a2; + DamageMonsterFromParty(PID(OBJECT_Item, v164), dword_50BF30[a2], &v700); + pGame->GetStru6()->_4A81CA(&a1); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u); + a2 = v165 + 1; + } + while ( v165 + 1 < (signed int)_v726 ); + } + LODWORD(v727) = 1; + break; + } + + case SPELL_AIR_WIZARD_EYE: + { LODWORD(v733) = 3600 * v2; if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; v168 = 0; do { - v169 = pOtherOverlayList->_4418B1(2000, v168++ + 100, 0, 65536); - v716 = v169; + v169 = pOtherOverlayList->_4418B1(2000, v168++ + 100, 0, 65536); + v716 = v169; } while ( v168 < 4 ); pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_AIR_FEATHER_FALL: + break; + } + case SPELL_AIR_FEATHER_FALL: + { v170 = v731 - 1; if ( !v170 ) { - v173 = 300 * v2; - goto LABEL_353; + v173 = 300 * v2; + goto LABEL_353; } v171 = v170 - 1; if ( !v171 ) { - v173 = 600 * v2; - goto LABEL_353; + v173 = 600 * v2; + goto LABEL_353; } v172 = v171 - 1; if ( !v172 || v172 == 1 ) { - v173 = 3600 * v2; + v173 = 3600 * v2; LABEL_353: - LODWORD(v733) = v173; + LODWORD(v733) = v173; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; v174 = 0; do - pOtherOverlayList->_4418B1(2010, v174++ + 100, 0, 65536); + pOtherOverlayList->_4418B1(2010, v174++ + 100, 0, 65536); while ( v174 < 4 ); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); @@ -4541,120 +4501,122 @@ pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_AIR_SPARKS: - { - v184 = v731 - 1; - if ( v184 ) - { - v185 = v184 - 1; - if ( v185 ) - { - v186 = v185 - 1; - if ( v186 ) - { - if ( v186 == 1 ) - amount = 9; - } - else - { - amount = 7; - } - } - else - { - amount = 5; - } + break; + } + case SPELL_AIR_SPARKS: + { + v184 = v731 - 1; + if ( v184 ) + { + v185 = v184 - 1; + if ( v185 ) + { + v186 = v185 - 1; + if ( v186 ) + { + if ( v186 == 1 ) + amount = 9; + } + else + { + amount = 7; + } } else { - amount = 3; + amount = 5; + } + } + else + { + amount = 3; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.uAttributes = 0; + a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + a1.uSectorID = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uSoundID = LOWORD(v3->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + v188 = (signed int)_v726 / -2; + v189 = (signed int)_v726 / 2; + while ( v188 <= v189 ) + { + a1.uFacing = v188 + LOWORD(v715.uYawAngle); + if ( a1.Create( + (signed __int16)(v188 + LOWORD(v715.uYawAngle)), + v715.uPitchAngle, + pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, + v3->uPlayerID + 1) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + v188 += _v726 / (amount - 1); + } + LODWORD(v727) = 1; + break; + } + + case SPELL_AIR_JUMP: + { + if ( pParty->uFlags & PARTY_FLAGS_1_FALLING) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2); // Can't cast Jump while airborne! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.uAttributes = 0; - a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uSoundID = LOWORD(v3->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; - v188 = (signed int)_v726 / -2; - v189 = (signed int)_v726 / 2; - while ( v188 <= v189 ) - { - a1.uFacing = v188 + LOWORD(v715.uYawAngle); - if ( a1.Create( - (signed __int16)(v188 + LOWORD(v715.uYawAngle)), - v715.uPitchAngle, - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, - v3->uPlayerID + 1) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - v188 += _v726 / (amount - 1); - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 16: - if ( pParty->uFlags & PARTY_FLAGS_1_FALLING) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2); // Can't cast Jump while airborne! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto play_sound_and_continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + break; v191 = 0; do - pOtherOverlayList->_4418B1(2040, v191++ + 100, 0, 65536); + pOtherOverlayList->_4418B1(2040, v191++ + 100, 0, 65536); while ( v191 < 4 ); BYTE1(pParty->uFlags) |= 1u; pParty->uFallSpeed = 1000; LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_AIR_INVISIBILITY: + break; + } + case SPELL_AIR_INVISIBILITY: + { v192 = v731 - 1; if ( !v192 ) { - amount = v2; - goto LABEL_391; + amount = v2; + goto LABEL_391; } v193 = v192 - 1; if ( !v193 ) { - v196 = 2 * v2; + v196 = 2 * v2; LABEL_389: - amount = v196; + amount = v196; LABEL_391: - v195 = 600 * v2; - goto LABEL_392; + v195 = 600 * v2; + goto LABEL_392; } v194 = v193 - 1; if ( !v194 ) { - v196 = 3 * v2; - goto LABEL_389; + v196 = 3 * v2; + goto LABEL_389; } if ( v194 != 1 ) - goto LABEL_393; + goto LABEL_393; amount = 4 * v2; v195 = 3600 * v2; LABEL_392: @@ -4662,2879 +4624,2955 @@ 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! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; } if ( pPlayer->CanCastSpell(uRequiredMana) ) { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - - pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); - LODWORD(v727) = 1; - } - goto play_sound_and_continue; - - case 21: - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto play_sound_and_continue; - } - if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto play_sound_and_continue; - } - LODWORD(v733) = 3600 * v2; - if ( v731 == 2 || v731 == 3 || (amount = 0, v731 != 4) ) - amount = 1; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v205 = 0; - do - pOtherOverlayList->_4418B1(2090, v205++ + 100, 0, 65536); - while ( v205 < 4 ); - v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); - v207 = v3->uPlayerID + 1; - v716 = v206; - - pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 22: - { - //v67 = 2; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v208 = PID_TYPE(a2); - LODWORD(v725) = PID_TYPE(a2); - if ( v208 == 3 ) - { - v209 = PID_ID(a2); - LODWORD(v718) = pActors[v209].vPosition.x; - v210 = pActors[v209].vPosition.y; - v211 = pActors[v209].vPosition.z; - v713 = v210; - } - else - { - v212 = stru_5C6E00->Cos(pParty->sRotationY); - LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212); - v213 = stru_5C6E00->Sin(pParty->sRotationY); - v214 = sub_42EBBE(2048, v213); - v211 = pParty->vPosition.z; - v713 = pParty->vPosition.y + v214; - v208 = LODWORD(v725); - } - HIDWORD(v733) = 0; - *(float *)&v732 = (double)v211; - LODWORD(v725) = v211 + 2500; - v721 = 0; - *(float *)&y = (double)(v211 + 2500); - v730 = v208 == 3 ? a2 : 0; - a2 = 20; - do - { - v215 = rand(); - v216 = (double)v721; - v217 = (double)SHIDWORD(v733); - *(float *)&uRequiredMana = v217; - _this = (ItemGen *)(v215 % 1000); - *((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y; - *(float *)&v721 = v217 * v217; - //*(float *)&v726 = v216 * v216; - if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + v216 * v216 + *(float *)&v721) <= 1.0 ) - { - LODWORD(v685) = 0; - HIDWORD(v685) = 0; - } - else - { - v684 = (signed __int64)sqrt(v216 * v216 + *(float *)&v721); - v685 = __PAIR__( - stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)), - stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana)); - } - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.vPosition.x = LODWORD(v718); - a1.vPosition.y = v713; - a1.uSectorID = 0; - a1.vPosition.z = (int)((char *)_this + LODWORD(v725)); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = v730; - __debugbreak(); - a1.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges); - a1.uFacing = v685; - a1.uSoundID = LOWORD(v3->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - a1.uAttributes = 4; - if ( a1.Create( - v685, - SHIDWORD(v685), - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, - 0) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - v721 = rand() % 1024 - 512; - v218 = rand(); - v14 = a2-- == 1; - HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512; - } - while ( !v14 ); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 23: - 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 ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v222 = (char *)pParty->pPlayers; - HIDWORD(v733) = (int)(char *)&pParty + 2508; - break; - case 24: - v224 = v731 - 2; - if ( v224 ) - { - v225 = v224 - 1; - if ( v225 ) - { - if ( v225 == 1 ) - amount = 7; - else - amount = 1; - } - else - { - amount = 5; - } - } - else - { - amount = 3; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - HIDWORD(v733) = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - if ( amount == 1 ) - { - LABEL_152: - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_skill = v731; - a1.spell_level = v2; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.y = pParty->vPosition.y; - v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v660 = pParty->vPosition.y; - LABEL_153: - a1.uAttributes = 0; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = v51; - v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671); - a1.uSpriteFrameID = 0; - a1.uSectorID = v52; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uFacing = LOWORD(v715.uYawAngle); - a1.uSoundID = LOWORD(v3->sound_id); - - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; - - v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - - if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - } - else - { - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.uAttributes = 0; - a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uSoundID = LOWORD(v3->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; - v227 = SHIDWORD(v733) / -2; - y = (char *)(SHIDWORD(v733) / 2); - if ( SHIDWORD(v733) / -2 <= SHIDWORD(v733) / 2 ) - { - v228 = v715.uYawAngle; - do - { - a1.uFacing = v227 + v228; - if ( a1.Create( - v227 + v228, - v715.uPitchAngle, - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, - v3->uPlayerID + 1) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - v227 += SHIDWORD(v733) / (amount - 1); - } - while ( v227 <= (signed int)y ); - } - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 27: - if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto play_sound_and_continue; - } - if ( v731 == 2 || v731 != 3 && v731 != 4 ) - v229 = 600 * v2; - else - v229 = 3600 * v2; - LODWORD(v733) = v229; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v716 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335), - v731, - amount, - v716, - v3->uPlayerID + 1); - if ( v731 == 4 ) - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 28: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v240 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2]; - y = v240; - if ( pItemsTable->pItems[*(int *)v240].uEquipType != 12 || v240[20] & 2 ) - { - 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); - v3->spellnum = 0; - continue; - } - if ( v731 == 1 || v731 == 2 ) - { - v241 = (double)v723 * 0.0099999998 + 0.5; + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); + + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); + LODWORD(v727) = 1; + } + break; + } + case SPELL_AIR_FLY: + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; + } + if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; + } + LODWORD(v733) = 3600 * v2; + if ( v731 == 2 || v731 == 3 || (amount = 0, v731 != 4) ) + amount = 1; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v205 = 0; + do + pOtherOverlayList->_4418B1(2090, v205++ + 100, 0, 65536); + while ( v205 < 4 ); + v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); + v207 = v3->uPlayerID + 1; + v716 = v206; + + pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207); + LODWORD(v727) = 1; + break; + } + + case SPELL_AIR_STARBURST: + { + //v67 = 2; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v208 = PID_TYPE(a2); + LODWORD(v725) = PID_TYPE(a2); + if ( v208 == 3 ) + { + v209 = PID_ID(a2); + LODWORD(v718) = pActors[v209].vPosition.x; + v210 = pActors[v209].vPosition.y; + v211 = pActors[v209].vPosition.z; + v713 = v210; + } + else + { + v212 = stru_5C6E00->Cos(pParty->sRotationY); + LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212); + v213 = stru_5C6E00->Sin(pParty->sRotationY); + v214 = sub_42EBBE(2048, v213); + v211 = pParty->vPosition.z; + v713 = pParty->vPosition.y + v214; + v208 = LODWORD(v725); + } + HIDWORD(v733) = 0; + *(float *)&v732 = (double)v211; + LODWORD(v725) = v211 + 2500; + v721 = 0; + *(float *)&y = (double)(v211 + 2500); + v730 = v208 == 3 ? a2 : 0; + a2 = 20; + do + { + v215 = rand(); + v216 = (double)v721; + v217 = (double)SHIDWORD(v733); + *(float *)&uRequiredMana = v217; + _this = (ItemGen *)(v215 % 1000); + *((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y; + *(float *)&v721 = v217 * v217; + //*(float *)&v726 = v216 * v216; + if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + v216 * v216 + *(float *)&v721) <= 1.0 ) + { + LODWORD(v685) = 0; + HIDWORD(v685) = 0; } else { - if ( v731 == 3 ) - { - v241 = (double)v723 * 0.0099999998 + 0.69999999; - } - else - { - if ( v731 != 4 ) - { - v241 = 0.0; - goto LABEL_484; - } - v241 = (double)v723 * 0.0099999998 + 0.80000001; - } - } - 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; - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 1; - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - v2 = v723; - continue; - } - *((int *)v243 + 5) |= 0x40u; - dword_50C9A8 = 256; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 30: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - uRequiredMana = 0; - HIDWORD(v733) = 10 * v2; - v730 = 1; - v244 = (char *)&pParty->pPlayers[v3->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 ) - { - 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; - - dword_50C9A8 = 256; - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - goto LABEL_615; - } - 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); - __debugbreak(); // decompilation error; most probably v318 is the caster, filled in case 54 - //v318 = v726; - v3->spellnum = 0; - v318->PlaySound(SPEECH_43, 0); - } - goto play_sound_and_continue; - } - if ( v731 != 2 ) - { - 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) ) - { - 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]; - goto LABEL_611; - } - 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; - } - } - goto LABEL_525; - } - } - 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) ) - { - 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]; - goto LABEL_611; - } - v257 = pItemsTable->pSpecialEnchantments_count; - v258 = 0; - v725 = 0.0; - HIDWORD(v733) = 0; - if ( pItemsTable->pSpecialEnchantments_count > 0 ) - { - 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 ); - } - 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; - } - } - LABEL_525: - ++*(int *)(v245 + 12); - goto LABEL_612; - } - } - LABEL_615: - //v1 = 0; - goto LABEL_616; - } - 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()) - goto LABEL_616; - 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); - v3->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) ) - { - 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); - v3->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 ) - { - v730 = (int)&v679; - do - { - 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 ) - 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; - dword_50C9A8 = 256; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_WATER_TOWN_PORTAL: - amount = 10 * v2; - if ( pPlayer->sMana < (signed int)uRequiredMana ) - goto play_sound_and_continue; - if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && v731 != 4 || rand() % 100 >= amount && v731 != 4 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - town_portal_caster_id = LOBYTE(v3->uPlayerID); - pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - case 33: - LODWORD(v733) = 604800 * v2; - if ( !_strcmpi(pCurrentMapName, "d05.blv") ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - v319 = uRequiredMana; - if ( pPlayer->sMana >= (signed int)uRequiredMana ) - { - pEventTimer->Pause(); - pMessageQueue_50CBD0->AddMessage(UIMSG_B1, 0, 0); - qword_506350 = (signed int)v733; - _506348_current_lloyd_playerid = v3->uPlayerID; - ::uRequiredMana = v319; - ::sRecoveryTime = sRecoveryTime; - dword_50633C = v3->sound_id; - dword_506338 = v3->spellnum; - LOBYTE(v3->field_8) |= 0x20u; - } - goto play_sound_and_continue; - case 40: - 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: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v323 = v3->uPlayerID_2; - v324 = (char *)&pParty->pPlayers[v323].pConditions[15]; - if ( !pParty->pPlayers[v323].pConditions[15] ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v731 == 4 ) - { - *(int *)v324 = 0; - *((int *)v324 + 1) = 0; - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v732 = amount << 7; - v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); - v656 = 15; - goto LABEL_640; - - case 41: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.uAttributes = 0; - a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uFacing = LOWORD(pParty->sRotationY); - a1.uSoundID = LOWORD(v3->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; - - v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - if ( a1.Create(pParty->sRotationY, pParty->sRotationX, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 43: - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - a1.uType = 4090; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.y = pParty->vPosition.y; - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - a1.field_60_distance_related_prolly_lod = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.uFacing = LOWORD(pParty->sRotationY); - a1.uSoundID = LOWORD(v3->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - a1.uAttributes = 4; - - v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - if ( a1.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_SPIRIT_DETECT_LIFE: - v328 = v731 - 2; - if ( v328 ) - { - v329 = v328 - 1; - if ( v329 && v329 != 1 ) - v330 = 600 * v2; - else - v330 = 3600 * v2; - } - else - { - v330 = 1800 * v2; - } - LODWORD(v733) = v330; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - - pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - 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 ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v342 = v3->spell_target_pid; - if ( v342 == 0 ) - { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if (PID_TYPE(v342) == OBJECT_Actor) - { - v343 = PID_ID(v342); - HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32); - LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280; - pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, 0, 0); - BYTE2(pActors[v343].uAttributes) |= 8u; - v672 = 0; - v661 = &pActors[v343]; - LABEL_165: - pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672); - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 49: - v348 = v731 - 2; - if ( !v348 ) - goto LABEL_677; - v349 = v348 - 1; - if ( v349 ) - { - if ( v349 == 1 ) - { - amount = 0; - goto LABEL_679; - } - LABEL_677: - v350 = 3600 * v2; - } - else - { - v350 = 86400 * v2; - } - amount = v350; - LABEL_679: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v351 = &pParty->pPlayers[v3->uPlayerID_2]; - if ( !v351->pConditions[0] ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v731 == 4 ) - { - LODWORD(v351->pConditions[0]) = 0; - HIDWORD(v351->pConditions[0]) = 0; - } - else - { - v732 = amount << 7; - v351->DiscardConditionIfLastsLongerThan(0, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - } - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_SPIRIT_PRESERVATION: - v354 = v731 - 2; - if ( v354 && (v355 = v354 - 1) != 0 && v355 == 1 ) - v356 = 900 * (v2 + 4); - else - v356 = 300 * (v2 + 12); - LODWORD(v733) = v356; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - if ( v731 == 1 || v731 == 2 ) - { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - a2 = 0; - v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); - v357 = pParty->pPlayers;//[0].pPlayerBuffs[11]; - do - { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, a2); - v357->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v717, v731, 0, 0, 0); - ++a2; - ++v357;// = (SpellBuff *)((char *)v357 + 6972); - } - while ( v357 <= &pParty->pPlayers[3] ); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 48: - { - v364 = v731 - 2; - if ( !v364 || (v365 = v364 - 1) != 0 && v365 != 1 ) - v366 = 60 * (v2 + 3); - else - v366 = 300 * v2 + 180; - LODWORD(v733) = v366; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); - ++a1.uType; + v684 = (signed __int64)sqrt(v216 * v216 + *(float *)&v721); + v685 = __PAIR__( + stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)), + stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana)); + } a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; + a1.vPosition.x = LODWORD(v718); + a1.vPosition.y = v713; a1.uSectorID = 0; + a1.vPosition.z = (int)((char *)_this + LODWORD(v725)); a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = v730; + __debugbreak(); + a1.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges); + a1.uFacing = v685; a1.uSoundID = LOWORD(v3->sound_id); - for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) - { - v369 = &pActors[dword_50BF30[a2]]; - if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - { - a1.vPosition.x = v369->vPosition.x; - a1.vPosition.y = v369->vPosition.y; - a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548); - - a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - a1.Create(0, 0, 0, 0); - v369->pActorBuffs[4].Apply( - pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), - v731, 0, 0, 0); - } - } - LODWORD(v727) = 1; - } - goto play_sound_and_continue; - - case 53: - v371 = v731 - 2; - if ( v371 && (v372 = v371 - 1) != 0 && v372 == 1 ) - amount = 0; - else - amount = 86400 * v2; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - pOtherOverlayList->_4418B1(5080, v3->uPlayerID_2 + 100, 0, 65536); - v373 = v3->uPlayerID_2; - if ( !(HIDWORD(pParty->pPlayers[v373].pConditions[14]) | LODWORD(pParty->pPlayers[v373].pConditions[14])) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v14 = v731 == 4; - pParty->pPlayers[v373].sHealth = 1; - if ( v14 ) - { - v374 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v374].pConditions[14]) = 0; - HIDWORD(pParty->pPlayers[v374].pConditions[14]) = 0; - v376 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v376].pConditions[13]) = 0; - HIDWORD(pParty->pPlayers[v376].pConditions[13]) = 0; + if ( pParty->bTurnBasedModeOn == 1 ) + a1.uAttributes = 4; + if ( a1.Create( + v685, + SHIDWORD(v685), + pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, + 0) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + v721 = rand() % 1024 - 512; + v218 = rand(); + v14 = a2-- == 1; + HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512; + } + while ( !v14 ); + LODWORD(v727) = 1; + break; + } + + 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 { - *(float *)&a2 = (double)(amount << 7) * 0.033333335; - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0xEu, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0xDu, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - } - v377 = &pParty->pPlayers[v3->uPlayerID_2]; - goto LABEL_720; - case 54: - v378 = v731 - 2; - if ( v378 && (v379 = v378 - 1) != 0 && v379 == 1 ) - v380 = 4 * v2; - else - v380 = 3 * v2; - amount = v380; + v221 = 3600 * v2; + } + amount = v221; + LABEL_433: if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v381 = 0; - HIDWORD(v733) = amount; - v730 = 0; - v382 = 1; - do - { - v383 = pPlayers[v382]; - if ( !v383->pConditions[14] && !v383->pConditions[15] && !v383->pConditions[16] ) - v682[v381++] = v382; - ++v382; - } - while ( v382 <= 4 ); - v384 = 0; - v730 = v381; - if ( v381 > 0 ) - { - do - HIDWORD(v733) += pPlayers[v682[v384++]]->sHealth; - while ( v384 < v381 ); - } - v732 = (signed __int64)((double)SHIDWORD(v733) / (double)v730); - HIDWORD(v733) = 0; - if ( v381 > 0 ) - { - do - { - //v385 = (ItemGen **)&pPlayers[v682[HIDWORD(v733)]]; - v726 = pPlayers[v682[HIDWORD(v733)]]; - v726->sHealth = v732; - //v386 = v726->GetMaxHealth(); - if ( v726->sHealth > v726->GetMaxHealth()) - v726->sHealth = v726->GetMaxHealth(); - if ( v726->sHealth > 0 ) + break; + v222 = pParty->pPlayers; + HIDWORD(v733) = (int)(char *)&pParty + 2508; + while ( 2 ) + { + if ( v731 == 4 ) + { + if ( v222->pConditions[2] ) + { + //*((int *)v222 + 4) = 0; + //*((int *)v222 + 5) = 0; + v222->pConditions[2] = 0; + v222->PlaySound(SPEECH_103, 0); + } + } + else { - v726->pConditions[Player::Condition_Unconcious] = 0; + v223 = v222->DiscardConditionIfLastsLongerThan( + 2u, + pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)); + v222 = (Player *)HIDWORD(v733); + if ( v223 ) + v222->PlaySound(SPEECH_103, 0); + } + ++v222;// += 6972; + HIDWORD(v733) = (int)v222; + if ( v222 >= &pParty->pPlayers[3] ) + { + LODWORD(v727) = 1; + break; + } + } + } + case SPELL_WATER_POISON_SPRAY: + { + v224 = v731 - 2; + if ( v224 ) + { + v225 = v224 - 1; + if ( v225 ) + { + if ( v225 == 1 ) + amount = 7; + else + amount = 1; + } + else + { + amount = 5; } - v388 = HIDWORD(v733); - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, LOWORD(v682[HIDWORD(v733)]) - 1); - HIDWORD(v733) = v388 + 1; - } - while ( v388 + 1 < v730 ); - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 55: - v392 = v731 - 1; - if ( !v392 ) - { - v395 = 180 * v2; - goto LABEL_750; - } - v393 = v392 - 1; - if ( !v393 ) - { - v395 = 10800 * v2; - goto LABEL_750; - } - v394 = v393 - 1; - if ( !v394 ) - { - v395 = 259200 * v2; - LABEL_750: - amount = v395; - goto LABEL_751; - } - if ( v394 == 1 ) - amount = 0; - LABEL_751: + } + else + { + amount = 3; + } if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v396 = v3->uPlayerID_2; - if ( HIDWORD(pParty->pPlayers[v396].pConditions[16]) | LODWORD(pParty->pPlayers[v396].pConditions[16]) - || HIDWORD(pParty->pPlayers[v396].pConditions[14]) | LODWORD(pParty->pPlayers[v396].pConditions[14]) ) - { - if ( !(HIDWORD(pParty->pPlayers[v396].pConditions[1]) | LODWORD(pParty->pPlayers[v396].pConditions[1])) ) - pParty->pPlayers[v396].PlaySound(SPEECH_25, 0); - if ( v731 == 4 ) - { - v397 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v397].pConditions[16]) = 0; - HIDWORD(pParty->pPlayers[v397].pConditions[16]) = 0; - v398 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v398].pConditions[14]) = 0; - HIDWORD(pParty->pPlayers[v398].pConditions[14]) = 0; - v399 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v399].pConditions[13]) = 0; - HIDWORD(pParty->pPlayers[v399].pConditions[13]) = 0; - } - else - { - *(float *)&a2 = (double)(amount << 7) * 0.033333335; - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0x10u, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xDu, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - } - pParty->pPlayers[v3->uPlayerID_2].SetCondition(1u, 1); - - pParty->pPlayers[v3->uPlayerID_2].sHealth = 1; - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + break; + HIDWORD(v733) = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; + if ( amount == 1 ) + { + LABEL_152: + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_skill = v731; + a1.spell_level = v2; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.y = pParty->vPosition.y; + v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + v660 = pParty->vPosition.y; + LABEL_153: + a1.uAttributes = 0; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = v51; + v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671); + a1.uSpriteFrameID = 0; + a1.uSectorID = v52; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uFacing = LOWORD(v715.uYawAngle); + a1.uSoundID = LOWORD(v3->sound_id); + + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + } + else + { + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.uAttributes = 0; + a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + a1.uSectorID = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uSoundID = LOWORD(v3->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + v227 = SHIDWORD(v733) / -2; + y = (char *)(SHIDWORD(v733) / 2); + if ( SHIDWORD(v733) / -2 <= SHIDWORD(v733) / 2 ) + { + v228 = v715.uYawAngle; + do + { + a1.uFacing = v227 + v228; + if ( a1.Create( + v227 + v228, + v715.uPitchAngle, + pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, + v3->uPlayerID + 1) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + v227 += SHIDWORD(v733) / (amount - 1); + } + while ( v227 <= (signed int)y ); + } } LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 61: - v405 = v731 - 2; - if ( !v405 ) - goto LABEL_766; - v406 = v405 - 1; - if ( v406 ) - { - if ( v406 == 1 ) - { - amount = 0; - goto LABEL_768; - } - LABEL_766: - v407 = 3600 * v2; + break; + } + case SPELL_WATER_WATER_WALK: + { + if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; + } + if ( v731 == 2 || v731 != 3 && v731 != 4 ) + v229 = 600 * v2; + else + v229 = 3600 * v2; + LODWORD(v733) = v229; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v716 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); + + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply( + pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335), + v731, + amount, + v716, + v3->uPlayerID + 1); + if ( v731 == 4 ) + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1; + LODWORD(v727) = 1; + break; + } + case SPELL_WATER_RECHARGE_ITEM: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v240 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2]; + y = v240; + if ( pItemsTable->pItems[*(int *)v240].uEquipType != 12 || v240[20] & 2 ) + { + 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); + v3->spellnum = 0; + continue; + } + if ( v731 == 1 || v731 == 2 ) + { + v241 = (double)v723 * 0.0099999998 + 0.5; + } + else + { + if ( v731 == 3 ) + { + v241 = (double)v723 * 0.0099999998 + 0.69999999; } else { - v407 = 86400 * v2; - } - amount = v407; - LABEL_768: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v323 = v3->uPlayerID_2; - v324 = (char *)&pParty->pPlayers[v323].pConditions[12]; - if ( !pParty->pPlayers[v323].pConditions[12] ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v731 == 4 ) - { - *(int *)v324 = 0; - *((int *)v324 + 1) = 0; - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); - v656 = 12; - goto LABEL_640; - - - case 56: - v411 = v731 - 2; - if ( v411 ) - { - v412 = v411 - 1; - if ( v412 ) - { - if ( v412 == 1 ) + if ( v731 != 4 ) + { + v241 = 0.0; + goto LABEL_484; + } + v241 = (double)v723 * 0.0099999998 + 0.80000001; + } + } + 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; + dword_50C9D0 = 113; + dword_50C9D4 = 0; + dword_50C9D8 = 1; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + v2 = v723; + continue; + } + *((int *)v243 + 5) |= 0x40u; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + break; + } + case SPELL_WATER_ENCHANT_ITEM: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + uRequiredMana = 0; + HIDWORD(v733) = 10 * v2; + v730 = 1; + v244 = (char *)&pParty->pPlayers[v3->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 ) + { + if ( *(int *)&v244[36 * a2 + 544] == 0 ) + { + if ( *(int *)&v244[36 * a2 + 536] == 0 ) + { + if ( *(int *)&v244[36 * a2 + 540] == 0 ) { - amount = 0; - goto LABEL_780; + 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; + + dword_50C9A8 = 256; + LODWORD(v727) = 1; + break; + } + goto LABEL_615; + } +LABEL_613: + v316 = _this->uItemID; + if ( !(BYTE1(v316) & 2) ) + { + LOBYTE(v316) = v316 | 2; + _this->uItemID = v316; + } + } + } + } + } + } } - v413 = 180 * v2; - } - else - { - v413 = 86400 * v2; - } + } + } +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); + __debugbreak(); // decompilation error; most probably v318 is the caster, filled in case 54 + //v318 = v726; + v3->spellnum = 0; + v318->PlaySound(SPEECH_43, 0); + } + break; + } + if ( v731 != 2 ) + { + 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) ) + { + 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]; + goto LABEL_611; + } + 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; + } + } + goto LABEL_525; + } } else { - v413 = 3600 * v2; - } - amount = v413; - LABEL_780: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v323 = v3->uPlayerID_2; - v324 = (char *)&pParty->pPlayers[v323].pConditions[3]; - if ( !pParty->pPlayers[v323].pConditions[3] ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v731 == 4 ) - { - *(int *)v324 = 0; - *((int *)v324 + 1) = 0; - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); - v656 = 3; - goto LABEL_640; - - case 59: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - if (PID_TYPE(a2) != OBJECT_Actor) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - 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)); + __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) ) + { + 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]; + goto LABEL_611; + } + v257 = pItemsTable->pSpecialEnchantments_count; + v258 = 0; + v725 = 0.0; + HIDWORD(v733) = 0; + if ( pItemsTable->pSpecialEnchantments_count > 0 ) + { + 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 ); + } + 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; + } + } +LABEL_525: + ++*(int *)(v245 + 12); + goto LABEL_612; + } + } +LABEL_615: + //v1 = 0; + goto LABEL_616; + } + 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()) + goto LABEL_616; + 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); + v3->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) ) + { 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); - goto LABEL_807; - } - v664 = "%d gold"; - goto LABEL_803; - } - if (v683.uItemID) - { - v675 = v683.GetDisplayName(); - v664 = "(%s)"; - LABEL_803: - sprintf(pTmpBuf2, v664, v675); - goto LABEL_807; - } - strcpy(pTmpBuf2, "nothing"); - LABEL_807: - ShowStatusBarString(pTmpBuf2, 2u); - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.x = *(short *)(v730 + 142); - a1.vPosition.y = *(short *)(v730 + 144); - v676 = *(short *)(v730 + 138); - v665 = a1.vPosition.y; - a1.vPosition.z = *(short *)(v730 + 138); - v657 = a1.vPosition.x; - goto LABEL_1087; - case 62: - 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; + + 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); + v3->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 ) + { + v730 = (int)&v679; + do + { + 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 ) + 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; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + break; + } + case SPELL_WATER_TOWN_PORTAL: + { + amount = 10 * v2; + if ( pPlayer->sMana < (signed int)uRequiredMana ) + break; + if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && v731 != 4 || rand() % 100 >= amount && v731 != 4 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + town_portal_caster_id = LOBYTE(v3->uPlayerID); + pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0); + LODWORD(v727) = 1; + break; + } + case SPELL_WATER_LLOYDS_BEACON: + { + LODWORD(v733) = 604800 * v2; + if ( !_strcmpi(pCurrentMapName, "d05.blv") ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + v319 = uRequiredMana; + if ( pPlayer->sMana >= (signed int)uRequiredMana ) + { + pEventTimer->Pause(); + pMessageQueue_50CBD0->AddMessage(UIMSG_B1, 0, 0); + qword_506350 = (signed int)v733; + _506348_current_lloyd_playerid = v3->uPlayerID; + ::uRequiredMana = v319; + ::sRecoveryTime = sRecoveryTime; + dword_50633C = v3->sound_id; + dword_506338 = v3->spellnum; + LOBYTE(v3->field_8) |= 0x20u; + } + break; + } + 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: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v323 = v3->uPlayerID_2; + v324 = (char *)&pParty->pPlayers[v323].pConditions[15]; + if ( !pParty->pPlayers[v323].pConditions[15] ) + { + LODWORD(v727) = 1; + break; + } + if ( v731 == 4 ) + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + break; + } + v732 = amount << 7; + v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); + v656 = 15; + goto LABEL_640; + } + case SPELL_EARTH_ROCK_BLAST: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.uAttributes = 0; + a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + a1.uSectorID = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uFacing = LOWORD(pParty->sRotationY); + a1.uSoundID = LOWORD(v3->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + if ( a1.Create(pParty->sRotationY, pParty->sRotationX, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + break; + } + case SPELL_EARTH_DEATH_BLOSSOM: + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + a1.uType = 4090; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.y = pParty->vPosition.y; + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + a1.field_60_distance_related_prolly_lod = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.uFacing = LOWORD(pParty->sRotationY); + a1.uSoundID = LOWORD(v3->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + a1.uAttributes = 4; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + if ( a1.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + break; + } + case SPELL_SPIRIT_DETECT_LIFE: + { + v328 = v731 - 2; + if ( v328 ) + { + v329 = v328 - 1; + if ( v329 && v329 != 1 ) + v330 = 600 * v2; + else + v330 = 3600 * v2; + } + else + { + v330 = 1800 * v2; + } + LODWORD(v733) = v330; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); + + pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); + LODWORD(v727) = 1; + break; + } + 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 { - v425 = 600 * v2; - } - amount = v425; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v426 = PID_ID(a2); - if (PID_TYPE(a2) != OBJECT_Actor) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - 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; - } - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = v426; - goto LABEL_1086; - - - case 66: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - amount = 600 * v2; - if (PID_TYPE(a2) != OBJECT_Actor) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v730 = 836 * PID_ID(a2); - if ( MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - goto play_sound_and_continue; - 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), + v341 = 4 * v2; + } + } + else + { + v341 = 2 * v2; + } + amount = v341; +LABEL_667: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v342 = v3->spell_target_pid; + if ( v342 == 0 ) + { + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + + pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0); + LODWORD(v727) = 1; + break; + } + if (PID_TYPE(v342) == OBJECT_Actor) + { + v343 = PID_ID(v342); + HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32); + LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280; + pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, 0, 0); + BYTE2(pActors[v343].uAttributes) |= 8u; + v672 = 0; + v661 = &pActors[v343]; +LABEL_165: + pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672); + } + LODWORD(v727) = 1; + break; + } + case SPELL_SPIRIT_REMOVE_CURSE: + { + v348 = v731 - 2; + if ( !v348 ) + goto LABEL_677; + v349 = v348 - 1; + if ( v349 ) + { + if ( v349 == 1 ) + { + amount = 0; + goto LABEL_679; + } +LABEL_677: + v350 = 3600 * v2; + } + else + { + v350 = 86400 * v2; + } + amount = v350; +LABEL_679: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v351 = &pParty->pPlayers[v3->uPlayerID_2]; + if ( !v351->pConditions[0] ) + { + LODWORD(v727) = 1; + break; + } + if ( v731 == 4 ) + { + LODWORD(v351->pConditions[0]) = 0; + HIDWORD(v351->pConditions[0]) = 0; + } + else + { + v732 = amount << 7; + v351->DiscardConditionIfLastsLongerThan(0, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) ) + { + LODWORD(v727) = 1; + break; + } + } + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + LODWORD(v727) = 1; + break; + } + case SPELL_SPIRIT_PRESERVATION: + { + v354 = v731 - 2; + if ( v354 && (v355 = v354 - 1) != 0 && v355 == 1 ) + v356 = 900 * (v2 + 4); + else + v356 = 300 * (v2 + 12); + LODWORD(v733) = v356; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( v731 == 1 || v731 == 2 ) + { + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + + pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); + LODWORD(v727) = 1; + break; + } + a2 = 0; + v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); + v357 = pParty->pPlayers;//[0].pPlayerBuffs[11]; + do + { + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, a2); + v357->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v717, v731, 0, 0, 0); + ++a2; + ++v357;// = (SpellBuff *)((char *)v357 + 6972); + } + while ( v357 <= &pParty->pPlayers[3] ); + LODWORD(v727) = 1; + break; + } + case SPELL_SPIRIT_TURN_UNDEAD: + { + v364 = v731 - 2; + if ( !v364 || (v365 = v364 - 1) != 0 && v365 != 1 ) + v366 = 60 * (v2 + 3); + else + v366 = 300 * v2 + 180; + LODWORD(v733) = v366; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); + ++a1.uType; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) + { + v369 = &pActors[dword_50BF30[a2]]; + if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + { + a1.vPosition.x = v369->vPosition.x; + a1.vPosition.y = v369->vPosition.y; + a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548); + + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + a1.Create(0, 0, 0, 0); + v369->pActorBuffs[4].Apply( + pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); } - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = PID_ID(a2); - goto LABEL_1086; - - case 63: - { - v428 = v731 - 2; - if ( v428 && (v429 = v428 - 1) != 0 && v429 == 1 ) - v430 = 300 * v2; + } + LODWORD(v727) = 1; + } + break; + + case SPELL_SPIRIT_RAISE_DEAD: + { + v371 = v731 - 2; + if ( v371 && (v372 = v371 - 1) != 0 && v372 == 1 ) + amount = 0; + else + amount = 86400 * v2; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pOtherOverlayList->_4418B1(5080, v3->uPlayerID_2 + 100, 0, 65536); + v373 = v3->uPlayerID_2; + if ( !(HIDWORD(pParty->pPlayers[v373].pConditions[14]) | LODWORD(pParty->pPlayers[v373].pConditions[14])) ) + { + LODWORD(v727) = 1; + break; + } + v14 = v731 == 4; + pParty->pPlayers[v373].sHealth = 1; + if ( v14 ) + { + v374 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v374].pConditions[14]) = 0; + HIDWORD(pParty->pPlayers[v374].pConditions[14]) = 0; + v376 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v376].pConditions[13]) = 0; + HIDWORD(pParty->pPlayers[v376].pConditions[13]) = 0; + } + else + { + *(float *)&a2 = (double)(amount << 7) * 0.033333335; + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( + 0xEu, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( + 0xDu, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + } + v377 = &pParty->pPlayers[v3->uPlayerID_2]; + goto LABEL_720; + } + case SPELL_SPIRIT_SHARED_LIFE: + { + v378 = v731 - 2; + if ( v378 && (v379 = v378 - 1) != 0 && v379 == 1 ) + v380 = 4 * v2; + else + v380 = 3 * v2; + amount = v380; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v381 = 0; + HIDWORD(v733) = amount; + v730 = 0; + v382 = 1; + do + { + v383 = pPlayers[v382]; + if ( !v383->pConditions[14] && !v383->pConditions[15] && !v383->pConditions[16] ) + v682[v381++] = v382; + ++v382; + } + while ( v382 <= 4 ); + v384 = 0; + v730 = v381; + if ( v381 > 0 ) + { + do + HIDWORD(v733) += pPlayers[v682[v384++]]->sHealth; + while ( v384 < v381 ); + } + v732 = (signed __int64)((double)SHIDWORD(v733) / (double)v730); + HIDWORD(v733) = 0; + if ( v381 > 0 ) + { + do + { + //v385 = (ItemGen **)&pPlayers[v682[HIDWORD(v733)]]; + v726 = pPlayers[v682[HIDWORD(v733)]]; + v726->sHealth = v732; + //v386 = v726->GetMaxHealth(); + if ( v726->sHealth > v726->GetMaxHealth()) + v726->sHealth = v726->GetMaxHealth(); + if ( v726->sHealth > 0 ) + { + v726->pConditions[Player::Condition_Unconcious] = 0; + } + v388 = HIDWORD(v733); + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, LOWORD(v682[HIDWORD(v733)]) - 1); + HIDWORD(v733) = v388 + 1; + } + while ( v388 + 1 < v730 ); + } + LODWORD(v727) = 1; + break; + } + case SPELL_SPIRIT_RESSURECTION: + { + v392 = v731 - 1; + if ( !v392 ) + { + v395 = 180 * v2; + goto LABEL_750; + } + v393 = v392 - 1; + if ( !v393 ) + { + v395 = 10800 * v2; + goto LABEL_750; + } + v394 = v393 - 1; + if ( !v394 ) + { + v395 = 259200 * v2; +LABEL_750: + amount = v395; + goto LABEL_751; + } + if ( v394 == 1 ) + amount = 0; +LABEL_751: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v396 = v3->uPlayerID_2; + if ( HIDWORD(pParty->pPlayers[v396].pConditions[16]) | LODWORD(pParty->pPlayers[v396].pConditions[16]) + || HIDWORD(pParty->pPlayers[v396].pConditions[14]) | LODWORD(pParty->pPlayers[v396].pConditions[14]) ) + { + if ( !(HIDWORD(pParty->pPlayers[v396].pConditions[1]) | LODWORD(pParty->pPlayers[v396].pConditions[1])) ) + pParty->pPlayers[v396].PlaySound(SPEECH_25, 0); + if ( v731 == 4 ) + { + v397 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v397].pConditions[16]) = 0; + HIDWORD(pParty->pPlayers[v397].pConditions[16]) = 0; + v398 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v398].pConditions[14]) = 0; + HIDWORD(pParty->pPlayers[v398].pConditions[14]) = 0; + v399 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v399].pConditions[13]) = 0; + HIDWORD(pParty->pPlayers[v399].pConditions[13]) = 0; + } else - v430 = 180 * v2; - amount = v430; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); - ++a1.uType; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) - { - v433 = &pActors[dword_50BF30[a2]]; - if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - break; - a1.vPosition.x = v433->vPosition.x; - a1.vPosition.y = v433->vPosition.y; - a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548); - - a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - a1.Create(0, 0, 0, 0); - if ( stru_50C198.GetMagicalResistance(v433, 7u) ) - { - v433->pActorBuffs[4].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), - v731, 0, 0, 0); - } - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 64: - v435 = v731 - 2; - if ( v435 && (v436 = v435 - 1) != 0 && v436 == 1 ) - amount = 0; - else - amount = 86400 * v2; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; + { + *(float *)&a2 = (double)(amount << 7) * 0.033333335; + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0x10u, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xDu, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + } + pParty->pPlayers[v3->uPlayerID_2].SetCondition(1u, 1); + + pParty->pPlayers[v3->uPlayerID_2].sHealth = 1; pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v440 = v3->uPlayerID_2; - if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) ) - { - if ( !(HIDWORD(pParty->pPlayers[v440].pConditions[1]) | LODWORD(pParty->pPlayers[v440].pConditions[1])) ) - pParty->pPlayers[v440].PlaySound(SPEECH_25, 0); - if ( v731 == 4 ) - { - v441 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v441].pConditions[5]) = 0; - HIDWORD(pParty->pPlayers[v441].pConditions[5]) = 0; - } - else - { - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(5u, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - } - v377 = &pParty->pPlayers[v3->uPlayerID_2]; - LABEL_720: - v377->SetCondition(1, 0); - } + } + LODWORD(v727) = 1; + break; + } + case SPELL_MIND_CURE_PARALYSIS: + { + v405 = v731 - 2; + if ( !v405 ) + goto LABEL_766; + v406 = v405 - 1; + if ( v406 ) + { + if ( v406 == 1 ) + { + amount = 0; + goto LABEL_768; + } +LABEL_766: + v407 = 3600 * v2; + } + else + { + v407 = 86400 * v2; + } + amount = v407; +LABEL_768: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + v323 = v3->uPlayerID_2; + v324 = (char *)&pParty->pPlayers[v323].pConditions[12]; + if ( !pParty->pPlayers[v323].pConditions[12] ) + { + LODWORD(v727) = 1; + break; + } + if ( v731 == 4 ) + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 42: - 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 ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v445 = PID_ID(a2); - if (PID_TYPE(a2) == OBJECT_Item) - { - v449 = (char *)&pSpriteObjects[v445].stru_24; - v450 = *(int *)v449; - if ( pItemsTable->pItems[v450].uEquipType == 18 ) - { - party_finds_gold(*((int *)v449 + 3), 0); - viewparams->bRedrawGameUI = 1; - } - else - { - sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); - ShowStatusBarString(pTmpBuf2, 2u); - if ( !pParty->AddItem(&pSpriteObjects[v445].stru_24) ) - pParty->SetHoldingItem(&pSpriteObjects[v445].stru_24); - } - SpriteObject::OnInteraction(v445); + break; + } + v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); + v656 = 12; + goto LABEL_640; + + } + case SPELL_MIND_REMOVE_FEAR: + { + v411 = v731 - 2; + if ( v411 ) + { + v412 = v411 - 1; + if ( v412 ) + { + if ( v412 == 1 ) + { + amount = 0; + goto LABEL_780; + } + v413 = 180 * v2; } else { - if (PID_TYPE(a2) == OBJECT_Actor) - { - stru_50C198.LootActor(&pActors[v445]); - } - else - { - if (PID_TYPE(a2) != OBJECT_Decoration) - { - if (PID_TYPE(a2) != OBJECT_BModel) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - dword_507CD8 = 1; - v677 = 1; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; - else - v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; - - EventProcessor(v446, a2, v677); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v447 = &pLevelDecorations[v445]; - dword_507CD8 = 1; - v448 = v447->field_16_event_id; - if (v448) - { - v677 = 1; - v446 = v448; - EventProcessor(v446, a2, v677); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v447->IsInteractive() ) - { - activeLevelDecoration = v447; - EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1); - activeLevelDecoration = NULL; - } - } - } + v413 = 86400 * v2; + } + } + else + { + v413 = 3600 * v2; + } + amount = v413; +LABEL_780: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + v323 = v3->uPlayerID_2; + v324 = (char *)&pParty->pPlayers[v323].pConditions[3]; + if ( !pParty->pPlayers[v323].pConditions[3] ) + { + LODWORD(v727) = 1; + break; + } + if ( v731 == 4 ) + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + break; + } + v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); + v656 = 3; + goto LABEL_640; + } + case SPELL_MIND_TELEPATHY: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if (PID_TYPE(a2) != OBJECT_Actor) + { LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 67: - 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; - } + 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); + goto LABEL_807; + } + v664 = "%d gold"; + goto LABEL_803; + } + if (v683.uItemID) + { + v675 = v683.GetDisplayName(); + v664 = "(%s)"; +LABEL_803: + sprintf(pTmpBuf2, v664, v675); + goto LABEL_807; + } + strcpy(pTmpBuf2, "nothing"); +LABEL_807: + ShowStatusBarString(pTmpBuf2, 2u); + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.x = *(short *)(v730 + 142); + a1.vPosition.y = *(short *)(v730 + 144); + v676 = *(short *)(v730 + 138); + v665 = a1.vPosition.y; + a1.vPosition.z = *(short *)(v730 + 138); + v657 = a1.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) + { + 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; + } + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + v60 = pObjectList->ObjectIDByItemID(a1.uType); + v61 = v426; + goto LABEL_1086; + + } + case SPELL_MIND_ENSLAVE: + { + 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); + } + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + v60 = pObjectList->ObjectIDByItemID(a1.uType); + v61 = PID_ID(a2); + goto LABEL_1086; + } + case SPELL_MIND_MASS_FEAR: + { + v428 = v731 - 2; + if ( v428 && (v429 = v428 - 1) != 0 && v429 == 1 ) + v430 = 300 * v2; + else + v430 = 180 * v2; + amount = v430; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); + ++a1.uType; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) + { + v433 = &pActors[dword_50BF30[a2]]; + if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + break; + a1.vPosition.x = v433->vPosition.x; + a1.vPosition.y = v433->vPosition.y; + a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548); + + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + a1.Create(0, 0, 0, 0); + if ( stru_50C198.GetMagicalResistance(v433, 7u) ) + { + v433->pActorBuffs[4].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + v731, 0, 0, 0); + } + } + LODWORD(v727) = 1; + break; + } + + case SPELL_MIND_CURE_INSANITY: + { + v435 = v731 - 2; + if ( v435 && (v436 = v435 - 1) != 0 && v436 == 1 ) + amount = 0; + else + amount = 86400 * v2; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + v440 = v3->uPlayerID_2; + if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) ) + { + if ( !(HIDWORD(pParty->pPlayers[v440].pConditions[1]) | LODWORD(pParty->pPlayers[v440].pConditions[1])) ) + pParty->pPlayers[v440].PlaySound(SPEECH_25, 0); + if ( v731 == 4 ) + { + v441 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v441].pConditions[5]) = 0; + HIDWORD(pParty->pPlayers[v441].pConditions[5]) = 0; } else { - v453 = 3600 * v2; - } - amount = v453; - LABEL_883: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v323 = v3->uPlayerID_2; - v324 = (char *)&pParty->pPlayers[v323].pConditions[1]; - if ( !pParty->pPlayers[v323].pConditions[1] ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v731 == 4 ) - { - *(int *)v324 = 0; - *((int *)v324 + 1) = 0; - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); - v656 = 1; - LABEL_640: - v325 = &pParty->pPlayers[v323]; - goto LABEL_641; - - case 68: - v457 = v731 - 2; - if ( v457 ) - { - v458 = v457 - 1; - if ( v458 ) - { - if ( v458 == 1 ) - v459 = 5 * v2 + 5; - else - v459 = 2 * v2 + 5; - } - else - { - v459 = 4 * v2 + 5; - } + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(5u, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + } + v377 = &pParty->pPlayers[v3->uPlayerID_2]; +LABEL_720: + v377->SetCondition(1, 0); + } + LODWORD(v727) = 1; + break; + } + 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 ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v445 = PID_ID(a2); + if (PID_TYPE(a2) == OBJECT_Item) + { + v449 = (char *)&pSpriteObjects[v445].stru_24; + v450 = *(int *)v449; + if ( pItemsTable->pItems[v450].uEquipType == 18 ) + { + party_finds_gold(*((int *)v449 + 3), 0); + viewparams->bRedrawGameUI = 1; } else { - v459 = 3 * v2 + 5; - } - amount = v459; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v460 = v3->spell_target_pid; - if (!v460) - { - pParty->pPlayers[v3->uPlayerID_2].Heal(amount); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); + ShowStatusBarString(pTmpBuf2, 2u); + if ( !pParty->AddItem(&pSpriteObjects[v445].stru_24) ) + pParty->SetHoldingItem(&pSpriteObjects[v445].stru_24); + } + SpriteObject::OnInteraction(v445); + } + else + { + if (PID_TYPE(a2) == OBJECT_Actor) + { + stru_50C198.LootActor(&pActors[v445]); + } + else + { + if (PID_TYPE(a2) != OBJECT_Decoration) + { + if (PID_TYPE(a2) != OBJECT_BModel) + { + LODWORD(v727) = 1; + break; + } + dword_507CD8 = 1; + v677 = 1; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; + else + v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; + + EventProcessor(v446, a2, v677); + LODWORD(v727) = 1; + break; + } + v447 = &pLevelDecorations[v445]; + dword_507CD8 = 1; + v448 = v447->field_16_event_id; + if (v448) + { + v677 = 1; + v446 = v448; + EventProcessor(v446, a2, v677); + LODWORD(v727) = 1; + break; + } + if ( v447->IsInteractive() ) + { + activeLevelDecoration = v447; + EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1); + activeLevelDecoration = NULL; + } + } + } + LODWORD(v727) = 1; + break; + } + 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 { - if (PID_TYPE(v460) == OBJECT_Actor) - { - v461 = &pActors[PID_ID(v460)]; - v462 = v461->uAIState; - v463 = v461->pMonsterInfo.uHP; - if ( v462 != 5 ) - { - if ( v462 != 4 ) - { - if ( v462 != 19 ) - { - if ( v462 != 11 ) - { - v461->sCurrentHP += amount; - if ( v461->sCurrentHP > v463 ) - v461->sCurrentHP = v463; - } - } - } - } - } - } + v453 = 86400 * v2; + } + } + else + { + v453 = 3600 * v2; + } + amount = v453; +LABEL_883: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + v323 = v3->uPlayerID_2; + v324 = (char *)&pParty->pPlayers[v323].pConditions[1]; + if ( !pParty->pPlayers[v323].pConditions[1] ) + { LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 72: - v464 = v731 - 2; - if ( !v464 ) - goto LABEL_910; - v465 = v464 - 1; - if ( v465 ) - { - if ( v465 == 1 ) - { - amount = 0; - goto LABEL_912; - } - LABEL_910: - v466 = 3600 * v2; + break; + } + if ( v731 == 4 ) + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + break; + } + v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); + v656 = 1; +LABEL_640: + v325 = &pParty->pPlayers[v323]; + goto LABEL_641; + } + case SPELL_BODY_FIRST_AID: + { + v457 = v731 - 2; + if ( v457 ) + { + v458 = v457 - 1; + if ( v458 ) + { + if ( v458 == 1 ) + v459 = 5 * v2 + 5; + else + v459 = 2 * v2 + 5; } else { - v466 = 86400 * v2; - } - amount = v466; - LABEL_912: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - + v459 = 4 * v2 + 5; + } + } + else + { + v459 = 3 * v2 + 5; + } + amount = v459; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v460 = v3->spell_target_pid; + if (!v460) + { + pParty->pPlayers[v3->uPlayerID_2].Heal(amount); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v470 = v3->uPlayerID_2; - if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6])) - && !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8])) - && !(HIDWORD(pParty->pPlayers[v470].pConditions[10]) | LODWORD(pParty->pPlayers[v470].pConditions[10])) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v731 == 4 ) - { - LODWORD(pParty->pPlayers[v470].pConditions[6]) = 0; - HIDWORD(pParty->pPlayers[v470].pConditions[6]) = 0; - v471 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v471].pConditions[8]) = 0; - HIDWORD(pParty->pPlayers[v471].pConditions[8]) = 0; - v472 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v472].pConditions[10]) = 0; - HIDWORD(pParty->pPlayers[v472].pConditions[10]) = 0; - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - *(float *)&a2 = (double)(amount << 7) * 0.033333335; - pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan( - 6u, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 8u, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2); - v656 = 10; - goto LABEL_937; - - - case 75: - amount = v2; - LODWORD(v733) = 3600 * v2; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - + } + else + { + if (PID_TYPE(v460) == OBJECT_Actor) + { + v461 = &pActors[PID_ID(v460)]; + v462 = v461->uAIState; + v463 = v461->pMonsterInfo.uHP; + if ( v462 != 5 ) + { + if ( v462 != 4 ) + { + if ( v462 != 19 ) + { + if ( v462 != 11 ) + { + v461->sCurrentHP += amount; + if ( v461->sCurrentHP > v463 ) + v461->sCurrentHP = v463; + } + } + } + } + } + } + LODWORD(v727) = 1; + break; + } + case SPELL_BODY_CURE_POISON: + { + v464 = v731 - 2; + if ( !v464 ) + goto LABEL_910; + v465 = v464 - 1; + if ( v465 ) + { + if ( v465 == 1 ) + { + amount = 0; + goto LABEL_912; + } +LABEL_910: + v466 = 3600 * v2; + } + else + { + v466 = 86400 * v2; + } + amount = v466; +LABEL_912: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + v470 = v3->uPlayerID_2; + if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6])) + && !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8])) + && !(HIDWORD(pParty->pPlayers[v470].pConditions[10]) | LODWORD(pParty->pPlayers[v470].pConditions[10])) ) + { + LODWORD(v727) = 1; + break; + } + if ( v731 == 4 ) + { + LODWORD(pParty->pPlayers[v470].pConditions[6]) = 0; + HIDWORD(pParty->pPlayers[v470].pConditions[6]) = 0; + v471 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v471].pConditions[8]) = 0; + HIDWORD(pParty->pPlayers[v471].pConditions[8]) = 0; + v472 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v472].pConditions[10]) = 0; + HIDWORD(pParty->pPlayers[v472].pConditions[10]) = 0; + LODWORD(v727) = 1; + break; + } + *(float *)&a2 = (double)(amount << 7) * 0.033333335; + pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan( + 6u, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( + 8u, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2); + v656 = 10; + goto LABEL_937; + + } + case SPELL_BODY_PROTECTION_FROM_MAGIC: + { + amount = v2; + LODWORD(v733) = 3600 * v2; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); + + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); + LODWORD(v727) = 1; + break; + } + case SPELL_BODY_HAMMERHANDS: + { + LODWORD(v733) = 3600 * v2; + amount = v2; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( v731 == 4 ) + { pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 73: - LODWORD(v733) = 3600 * v2; - amount = v2; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - if ( v731 == 4 ) - { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v732 = (int)v733 << 7; - v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); - pParty->pPlayers[0].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); - pParty->pPlayers[1].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); - pParty->pPlayers[2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); - - pParty->pPlayers[3].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4, v2, v2, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 74: - v493 = v731 - 2; - if ( v493 && (v494 = v493 - 1) != 0 && v494 == 1 ) - amount = 0; - else - amount = 86400 * v2; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v498 = v3->uPlayerID_2; - if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7])) - && !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9])) - && !(HIDWORD(pParty->pPlayers[v498].pConditions[11]) | LODWORD(pParty->pPlayers[v498].pConditions[11])) ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - if ( v731 == 4 ) - { - LODWORD(pParty->pPlayers[v498].pConditions[7]) = 0; - HIDWORD(pParty->pPlayers[v498].pConditions[7]) = 0; - v499 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v499].pConditions[9]) = 0; - HIDWORD(pParty->pPlayers[v499].pConditions[9]) = 0; - v500 = v3->uPlayerID_2; - LODWORD(pParty->pPlayers[v500].pConditions[11]) = 0; - HIDWORD(pParty->pPlayers[v500].pConditions[11]) = 0; + v732 = (int)v733 << 7; + v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); + pParty->pPlayers[0].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); + pParty->pPlayers[1].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); + pParty->pPlayers[2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); + + pParty->pPlayers[3].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4, v2, v2, 0); + LODWORD(v727) = 1; + break; + } + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + + pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0); + LODWORD(v727) = 1; + break; + } + case SPELL_BODY_CURE_DISEASE: + { + v493 = v731 - 2; + if ( v493 && (v494 = v493 - 1) != 0 && v494 == 1 ) + amount = 0; + else + amount = 86400 * v2; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + v498 = v3->uPlayerID_2; + if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7])) + && !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9])) + && !(HIDWORD(pParty->pPlayers[v498].pConditions[11]) | LODWORD(pParty->pPlayers[v498].pConditions[11])) ) + { + LODWORD(v727) = 1; + break; + } + if ( v731 == 4 ) + { + LODWORD(pParty->pPlayers[v498].pConditions[7]) = 0; + HIDWORD(pParty->pPlayers[v498].pConditions[7]) = 0; + v499 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v499].pConditions[9]) = 0; + HIDWORD(pParty->pPlayers[v499].pConditions[9]) = 0; + v500 = v3->uPlayerID_2; + LODWORD(pParty->pPlayers[v500].pConditions[11]) = 0; + HIDWORD(pParty->pPlayers[v500].pConditions[11]) = 0; + } + else + { + *(float *)&a2 = (double)(amount << 7) * 0.033333335; + pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan( + 7u, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( + 9u, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); + v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2); + v656 = 11; +LABEL_937: + v325 = &pParty->pPlayers[v3->uPlayerID_2]; +LABEL_641: + v325->DiscardConditionIfLastsLongerThan(v656, v663); + } + LODWORD(v727) = 1; + break; + } + case SPELL_BODY_POWER_CURE: + { + amount = 5 * v2 + 10; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v501 = pParty->pPlayers; + int v1 = 0; + do + { + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v1); + v501->Heal(amount); + ++v501; + ++v1; + } + while ( (signed int)v501 < (signed int)pParty->pHirelings ); + LODWORD(v727) = 1; + break; + } + case SPELL_LIGHT_DISPEL_MAGIC: + { + sRecoveryTime -= v2; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u); + v505 = sub_46A6AC((int)dword_50BF30, 100, 4096); + ++a1.uType; + HIDWORD(v733) = v505; + v688.x = 0; + v688.y = 0; + v688.z = 0; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + a2 = 0; + if ( SHIDWORD(v733) > 0 ) + { + do + { + v507 = dword_50BF30[a2]; + a1.vPosition.x = pActors[v507].vPosition.x; + a1.vPosition.y = pActors[v507].vPosition.y; + a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + v509 = a1.Create(0, 0, 0, 0); + v510 = a2; + DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], (Vec3_int_ *)&v688); + a2 = v510 + 1; + } + while ( v510 + 1 < SHIDWORD(v733) ); + } + for ( a2 = 0; a2 < SHIDWORD(v733); ++a2 ) + { + v511 = &pActors[dword_50BF30[a2]]; + a1.vPosition.x = v511->vPosition.x; + a1.vPosition.y = v511->vPosition.y; + a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v511->uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + a1.Create(0, 0, 0, 0); + v513 = v511->pActorBuffs; + for (int _v726 = 22; _v726 != 0; --_v726) + { + v513->Reset(); + ++v513; + } + } + LODWORD(v727) = 1; + break; + } + case SPELL_LIGHT_SUMMON_ELEMENTAL: + { + v514 = v731 - 2; + if ( !v514 ) + goto LABEL_955; + v515 = v514 - 1; + if ( v515 ) + { + if ( v515 == 1 ) + { + v516 = 900 * v2; + amount = 5; } else { - *(float *)&a2 = (double)(amount << 7) * 0.033333335; - pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan( - 7u, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 9u, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2); - v656 = 11; - LABEL_937: - v325 = &pParty->pPlayers[v3->uPlayerID_2]; - LABEL_641: - v325->DiscardConditionIfLastsLongerThan(v656, v663); - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 77: - { - amount = 5 * v2 + 10; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v501 = pParty->pPlayers; - int v1 = 0; +LABEL_955: + v516 = 300 * v2; + amount = 1; + } + } + else + { + v516 = 900 * v2; + amount = 3; + } + v733 = __PAIR__(0, v516); + + if ( (signed int)uNumActors > 0 ) + { + v518 = pActors;//[0].uAIState; + auto _v726 = uNumActors; do { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v1); - v501->Heal(amount); - ++v501; - ++v1; - } - while ( (signed int)v501 < (signed int)pParty->pHirelings ); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - case 80: - sRecoveryTime -= v2; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u); - v505 = sub_46A6AC((int)dword_50BF30, 100, 4096); - ++a1.uType; - HIDWORD(v733) = v505; - v688.x = 0; - v688.y = 0; - v688.z = 0; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - a2 = 0; - if ( SHIDWORD(v733) > 0 ) - { - do - { - v507 = dword_50BF30[a2]; - a1.vPosition.x = pActors[v507].vPosition.x; - a1.vPosition.y = pActors[v507].vPosition.y; - a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - v509 = a1.Create(0, 0, 0, 0); - v510 = a2; - DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], (Vec3_int_ *)&v688); - a2 = v510 + 1; - } - while ( v510 + 1 < SHIDWORD(v733) ); - } - for ( a2 = 0; a2 < SHIDWORD(v733); ++a2 ) - { - v511 = &pActors[dword_50BF30[a2]]; - a1.vPosition.x = v511->vPosition.x; - a1.vPosition.y = v511->vPosition.y; - a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v511->uActorHeight * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - a1.Create(0, 0, 0, 0); - v513 = v511->pActorBuffs; - for (int _v726 = 22; _v726 != 0; --_v726) - { - v513->Reset(); - ++v513; - } - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 82: - v514 = v731 - 2; - if ( !v514 ) - goto LABEL_955; - v515 = v514 - 1; - if ( v515 ) - { - if ( v515 == 1 ) - { - v516 = 900 * v2; - amount = 5; - } - else - { - LABEL_955: - v516 = 300 * v2; - amount = 1; - } + v519 = v518->uAIState; + if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, v3->uPlayerID) == v518->uSummonerID ) + ++HIDWORD(v733); + ++v518; + --_v726; + } + while ( _v726 != 0 ); + } + if ( SHIDWORD(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); + v3->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + sub_44FA4C_spawn_light_elemental(v3->uPlayerID, v731, v733); + LODWORD(v727) = 1; + break; + } + 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 { - v516 = 900 * v2; - amount = 3; - } - v733 = __PAIR__(0, v516); - - if ( (signed int)uNumActors > 0 ) - { - v518 = pActors;//[0].uAIState; - auto _v726 = uNumActors; - do - { - v519 = v518->uAIState; - if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, v3->uPlayerID) == v518->uSummonerID ) - ++HIDWORD(v733); - ++v518; - --_v726; - } - while ( _v726 != 0 ); - } - if ( SHIDWORD(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); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - sub_44FA4C_spawn_light_elemental(v3->uPlayerID, v731, v733); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 83: - 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: - LODWORD(v733) = 10800 * v2; - v522 = 3 * v2 + 10; - } - } - else - { - LODWORD(v733) = 14400 * v2; - v522 = 4 * v2 + 10; - } - amount = v522; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - - pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); +LABEL_973: + LODWORD(v733) = 10800 * v2; + v522 = 3 * v2 + 10; + } + } + else + { + LODWORD(v733) = 14400 * v2; + v522 = 4 * v2 + 10; + } + amount = v522; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); + + pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); + LODWORD(v727) = 1; + break; + } + case SPELL_LIGHT_PRISMATIC_LIGHT: + { + //v67 = 2; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v531 = sub_46A6AC((int)dword_50BF30, 100, 4096); + ++a1.uType; + v694.x = 0; + v694.y = 0; + v694.z = 0; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + a2 = 0; + if ( (signed int)v531 > 0 ) + { + do + { + v533 = dword_50BF30[a2]; + a1.vPosition.x = pActors[v533].vPosition.x; + a1.vPosition.y = pActors[v533].vPosition.y; + a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + v535 = a1.Create(0, 0, 0, 0); + v536 = a2; + DamageMonsterFromParty(PID(OBJECT_Item, v535), dword_50BF30[a2], &v694); + a2 = v536 + 1; + } + while ( v536 + 1 < (signed int)v531 ); + } + v537 = pGame->GetStru6(); + pGame->GetStru6()->_4A8BFC(); LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 84: - //v67 = 2; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v531 = sub_46A6AC((int)dword_50BF30, 100, 4096); - ++a1.uType; - v694.x = 0; - v694.y = 0; - v694.z = 0; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - a2 = 0; - if ( (signed int)v531 > 0 ) - { - do - { - v533 = dword_50BF30[a2]; - a1.vPosition.x = pActors[v533].vPosition.x; - a1.vPosition.y = pActors[v533].vPosition.y; - a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - v535 = a1.Create(0, 0, 0, 0); - v536 = a2; - DamageMonsterFromParty(PID(OBJECT_Item, v535), dword_50BF30[a2], &v694); - a2 = v536 + 1; - } - while ( v536 + 1 < (signed int)v531 ); - } - v537 = pGame->GetStru6(); - pGame->GetStru6()->_4A8BFC(); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case SPELL_LIGHT_DAY_OF_PROTECTION: - { - v538 = v731 - 2; - if ( v538 && (v539 = v538 - 1) != 0 && v539 == 1 ) - { - amount = 5 * v2; - v540 = 18000 * v2; - } - else - { - amount = 4 * v2; - v540 = 14400 * v2; - } - v730 = v540; - LODWORD(v733) = v540; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - + break; + } + case SPELL_LIGHT_DAY_OF_PROTECTION: + { + v538 = v731 - 2; + if ( v538 && (v539 = v538 - 1) != 0 && v539 == 1 ) + { + amount = 5 * v2; + v540 = 18000 * v2; + } + else + { + amount = 4 * v2; + v540 = 14400 * v2; + } + v730 = v540; + LODWORD(v733) = v540; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); + + v732 = v730 << 7; + v549 = (double)(v730 << 7) * 0.033333335; + *((float *)&v733 + 1) = v549; + v712 = (signed __int64)v549; + pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].Apply(pParty->uTimePlayed + (signed __int64)v549, v731, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); + v550 = v2 + 5; + pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply( + (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), + v731, + v550, 0, 0); + + pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v550, 0, 0); + LODWORD(v727) = 1; + break; + } + + case SPELL_LIGHT_HOUR_OF_POWER: + { + v551 = v731 - 2; + if ( !v551 ) + goto LABEL_998; + v552 = v551 - 1; + if ( v552 ) + { + if ( v552 == 1 ) + { + amount = 15; + HIDWORD(v733) = 20; + goto LABEL_1000; + } +LABEL_998: + v678 = 4; + } + else + { + v678 = 12; + } + amount = v678; + HIDWORD(v733) = v678; +LABEL_1000: + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + y = (char *)(60 * (v2 * HIDWORD(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; + do + { pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v732 = v730 << 7; - v549 = (double)(v730 << 7) * 0.033333335; - *((float *)&v733 + 1) = v549; - v712 = (signed __int64)v549; - pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].Apply(pParty->uTimePlayed + (signed __int64)v549, v731, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0); - v550 = v2 + 5; - pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply( - (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), - v731, - v550, 0, 0); - - pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v550, 0, 0); - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 86: - { - v551 = v731 - 2; - if ( !v551 ) - goto LABEL_998; - v552 = v551 - 1; - if ( v552 ) - { - if ( v552 == 1 ) - { - amount = 15; - HIDWORD(v733) = 20; - goto LABEL_1000; - } - LABEL_998: - v678 = 4; - } - else - { - v678 = 12; - } - amount = v678; - HIDWORD(v733) = v678; - LABEL_1000: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - y = (char *)(60 * (v2 * HIDWORD(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; + //((SpellBuff *)(v553 + 6056))->Apply( + v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), 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); + 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); + } + LODWORD(v727) = 1; + break; + } + + + case SPELL_LIGHT_DIVINE_INTERVENTION: + { + amount = 3; + if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3u ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + a2 = 0; + _this = (ItemGen *)&pPlayers[1]; + do + { + v563 = 0; do { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - - //((SpellBuff *)(v553 + 6056))->Apply( - v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), 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); - 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); - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - - case 88: - amount = 3; - if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3u ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - a2 = 0; - _this = (ItemGen *)&pPlayers[1]; - do - { - v563 = 0; - do - { - v564 = _this->uItemID; - *(int *)(v563 + _this->uItemID) = 0; - v563 += 8; - *(int *)(v563 + v564 - 4) = 0; - } - while ( v563 <= 128 ); - v565 = ((Player *)_this->uItemID)->GetMaxHealth(); - v566 = (Player **)_this; - *(int *)(_this->uItemID + 6460) = v565; - v567 = (*v566)->GetMaxMana(); - *(int *)(_this->uItemID + 6464) = v567; - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, a2); - ++a2; - _this = (ItemGen *)((char *)_this + 4); - } - while ( (signed int)this < (signed int)&qword_A750D8 ); - v571 = pPlayer; - v572 = (char *)&pPlayer->sAgeModifier; - if ( pPlayer->sAgeModifier + 10 >= 120 ) - *(short *)v572 = 120; + v564 = _this->uItemID; + *(int *)(v563 + _this->uItemID) = 0; + v563 += 8; + *(int *)(v563 + v564 - 4) = 0; + } + while ( v563 <= 128 ); + v565 = ((Player *)_this->uItemID)->GetMaxHealth(); + v566 = (Player **)_this; + *(int *)(_this->uItemID + 6460) = v565; + v567 = (*v566)->GetMaxMana(); + *(int *)(_this->uItemID + 6464) = v567; + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, a2); + ++a2; + _this = (ItemGen *)((char *)_this + 4); + } + while ( (signed int)this < (signed int)&qword_A750D8 ); + v571 = pPlayer; + v572 = (char *)&pPlayer->sAgeModifier; + if ( pPlayer->sAgeModifier + 10 >= 120 ) + *(short *)v572 = 120; + else + *(short *)v572 = pPlayer->sAgeModifier + 10; + sRecoveryTime += -5 * v2; + ++v571->uNumDivineInterventionCastsThisDay; + LODWORD(v727) = 1; + break; + } + case SPELL_DARK_REANIMATE: + { + v573 = v731 - 2; + if ( v573 ) + { + v574 = v573 - 1; + if ( v574 ) + { + if ( v574 == 1 ) + v575 = 5 * v2; else - *(short *)v572 = pPlayer->sAgeModifier + 10; - sRecoveryTime += -5 * v2; - ++v571->uNumDivineInterventionCastsThisDay; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 89: - v573 = v731 - 2; - if ( v573 ) - { - v574 = v573 - 1; - if ( v574 ) - { - if ( v574 == 1 ) - v575 = 5 * v2; - else - v575 = 2 * v2; - } - else - { - v575 = 4 * v2; - } - } - else - { - v575 = 3 * v2; - } - amount = v575; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - v576 = v3->spell_target_pid; - if (!v576) - { - v585 = (char *)&pParty->pPlayers[v3->uPlayerID_2]; - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - if ( *((_QWORD *)v585 + 14) ) - { - ((Player *)v585)->SetCondition(0x11u, 1); - v587 = ((Player *)v585)->GetSexByVoice(); - ReloadPlayerPortraits(v3->uPlayerID_2, (v587 != 0) + 23); - *((_QWORD *)v585 + 17) = pParty->uTimePlayed; - } - goto play_sound_and_continue; - } - v577 = (Player *)(PID_ID(v576)); - //v726 = v577; - if ( v577 == (Player *)-1 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - v578 = (int)&pActors[(int)v577]; - v721 = v578; - if ( *(short *)(v578 + 40) > 0 || (v579 = *(short *)(v578 + 176), v579 != 5) && v579 != 4 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v3->spellnum = 0; - continue; - } - ++a1.uType; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - v581 = v721; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - a1.vPosition.x = *(short *)(v721 + 142); - a1.vPosition.y = *(short *)(v721 + 144); - v732 = *(short *)(v721 + 138); - a1.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, (int)v577); - a1.Create(0, 0, 0, 0); - if ( *(char *)(v581 + 52) > amount ) - goto play_sound_and_continue; - Actor::Resurrect((unsigned int)v577); - *(char *)(v581 + 61) = 0; - *(char *)(v581 + 53) = 0; - *(char *)(v581 + 54) = 0; - *(char *)(v581 + 55) = 0; - *(char *)(v581 + 56) = 0; - *(char *)(v581 + 57) = 0; - *(int *)(v581 + 712) = 9999; - *(char *)(v581 + 38) &= 0xF7u; - *(int *)(v581 + 708) = 0; - ((SpellBuff *)(v581 + 356))->Reset(); - ((SpellBuff *)(v581 + 228))->Reset(); - ((SpellBuff *)(v581 + 404))->Reset(); - if ( *(short *)(v581 + 40) > 10 * amount ) - *(short *)(v581 + 40) = 10 * amount; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 91: - v588 = v731 - 1; - amount = 16; - if ( v588 && (v589 = v588 - 1) != 0 && (v590 = v589 - 1) != 0 ) - { - if ( v590 == 1 ) - LODWORD(v733) = 0; - } - else - { - LODWORD(v733) = 3600 * v2; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - __debugbreak(); - HIDWORD(v733) = (int)(char *)&pParty + 6972 * v3->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)) ) - { - 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); - v3->spellnum = 0; - continue; - } - v592 = HIDWORD(v733); - v14 = v731 == 4; - *(int *)(HIDWORD(v733) + 12) = 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; - dword_50C9A8 = 256; - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 93: - { - v593 = v731 - 2; - if ( !v593 ) - goto LABEL_1062; - v594 = v593 - 1; - if ( v594 ) - { - if ( v594 == 1 ) - amount = 9; - else - LABEL_1062: - amount = 5; + v575 = 2 * v2; } else { - amount = 7; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.y = pParty->vPosition.y; - a1.uAttributes = 0; - a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uSoundID = LOWORD(v3->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(a1.uAttributes) |= 4u; - v596 = (signed int)_v726 / -2; - y = (char *)((signed int)_v726 / 2); - if ( (signed int)_v726 / -2 <= (signed int)_v726 / 2 ) - { - v597 = v715.uYawAngle; - do - { - a1.uFacing = v596 + v597; - if ( a1.Create( - v596 + v597, - v715.uPitchAngle, - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, - v3->uPlayerID + 1) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - v596 += _v726 / (amount - 1); - } - while ( v596 <= (signed int)y ); - } - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - - case 94: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - if ( v731 == 1 || v731 == 2 ) - { - v598 = 180 * v2; - goto LABEL_1081; - } - if ( v731 == 3 ) - { - v598 = 300 * v2; - LABEL_1081: - LODWORD(v733) = v598; - goto LABEL_1082; - } - if ( v731 == 4 ) - LODWORD(v733) = 29030400; - LABEL_1082: - if (PID_TYPE(a2) != OBJECT_Actor) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - v730 = 836 * PID_ID(a2); - if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - goto play_sound_and_continue; - 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); - v3->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); - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = PID_ID(a2); - LABEL_1086: - v600 = pActors[v61].vPosition.y; - v601 = pActors[v61].vPosition.x; - a1.uObjectDescID = v60; - a1.vPosition.x = v601; - v602 = pActors[v61].uActorHeight; - v603 = pActors[v61].vPosition.z; - a1.vPosition.y = v600; - v676 = v603 + v602; - v665 = v600; - a1.vPosition.z = v603 + v602; - v657 = v601; - LABEL_1087: - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(v657, v665, v676); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.spell_target_pid = a2; - a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - a1.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(a1.uAttributes) |= 0x80u; - a1.uSoundID = LOWORD(v3->sound_id); - a1.Create(0, 0, 0, v3->uPlayerID + 1); - LODWORD(v727) = 1; - goto play_sound_and_continue; - - case 96: - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - HIDWORD(v733) = 0; - memset(&achievedAwardsIndex, 0, 4000); - _this = 0; - v605 = (char *)pParty->pHirelings; - do - { - if ( *(int *)v605) - { - v606 = HIDWORD(v733)++; - achievedAwardsIndex[v606] = (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; - 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 = v3->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); - v3->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; + v575 = 4 * v2; + } + } + else + { + v575 = 3 * v2; + } + amount = v575; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v576 = v3->spell_target_pid; + if (!v576) + { + v585 = (char *)&pParty->pPlayers[v3->uPlayerID_2]; + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + if ( *((_QWORD *)v585 + 14) ) + { + ((Player *)v585)->SetCondition(0x11u, 1); + v587 = ((Player *)v585)->GetSexByVoice(); + ReloadPlayerPortraits(v3->uPlayerID_2, (v587 != 0) + 23); + *((_QWORD *)v585 + 17) = pParty->uTimePlayed; + } + break; + } + v577 = (Player *)(PID_ID(v576)); + //v726 = v577; + if ( v577 == (Player *)-1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + v578 = (int)&pActors[(int)v577]; + v721 = v578; + if ( *(short *)(v578 + 40) > 0 || (v579 = *(short *)(v578 + 176), v579 != 5) && v579 != 4 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + v3->spellnum = 0; + continue; + } + ++a1.uType; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + v581 = v721; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + a1.vPosition.x = *(short *)(v721 + 142); + a1.vPosition.y = *(short *)(v721 + 144); + v732 = *(short *)(v721 + 138); + a1.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, (int)v577); + a1.Create(0, 0, 0, 0); + if ( *(char *)(v581 + 52) > amount ) + break; + Actor::Resurrect((unsigned int)v577); + *(char *)(v581 + 61) = 0; + *(char *)(v581 + 53) = 0; + *(char *)(v581 + 54) = 0; + *(char *)(v581 + 55) = 0; + *(char *)(v581 + 56) = 0; + *(char *)(v581 + 57) = 0; + *(int *)(v581 + 712) = 9999; + *(char *)(v581 + 38) &= 0xF7u; + *(int *)(v581 + 708) = 0; + ((SpellBuff *)(v581 + 356))->Reset(); + ((SpellBuff *)(v581 + 228))->Reset(); + ((SpellBuff *)(v581 + 404))->Reset(); + if ( *(short *)(v581 + 40) > 10 * amount ) + *(short *)(v581 + 40) = 10 * amount; LODWORD(v727) = 1; - goto play_sound_and_continue; - case 95: - if ( v731 <= 0 ) - goto LABEL_1119; - if ( v731 <= 3 ) - { - v614 = 300 * (v2 + 12); - } + break; + } + case SPELL_DARK_VAMPIRIC_WEAPON: + { + v588 = v731 - 1; + amount = 16; + if ( v588 && (v589 = v588 - 1) != 0 && (v590 = v589 - 1) != 0 ) + { + if ( v590 == 1 ) + LODWORD(v733) = 0; + } + else + { + LODWORD(v733) = 3600 * v2; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + __debugbreak(); + HIDWORD(v733) = (int)(char *)&pParty + 6972 * v3->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)) ) + { + 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); + v3->spellnum = 0; + continue; + } + v592 = HIDWORD(v733); + v14 = v731 == 4; + *(int *)(HIDWORD(v733) + 12) = 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; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + break; + } + case SPELL_DARK_SHARPMETAL: + { + v593 = v731 - 2; + if ( !v593 ) + goto LABEL_1062; + v594 = v593 - 1; + if ( v594 ) + { + if ( v594 == 1 ) + amount = 9; 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) ) - goto play_sound_and_continue; - if ( v731 != 3 && v731 != 4 ) - { - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - - pParty->pPlayers[v3->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; - goto play_sound_and_continue; - } - a2 = 0; - v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); - v619 = pParty->pPlayers;//[0].pPlayerBuffs[10]; +LABEL_1062: + amount = 5; + } + else + { + amount = 7; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.y = pParty->vPosition.y; + a1.uAttributes = 0; + a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; + a1.uSectorID = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2); + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uSoundID = LOWORD(v3->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + v596 = (signed int)_v726 / -2; + y = (char *)((signed int)_v726 / 2); + if ( (signed int)_v726 / -2 <= (signed int)_v726 / 2 ) + { + v597 = v715.uYawAngle; do { - pGame->GetStru6()->SetPlayerBuffAnim(v3->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; - goto play_sound_and_continue; - - case 99: - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - 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; - a1.stru_24.Reset(); - a1.spell_id = v3->spellnum; - a1.spell_level = v2; - a1.spell_skill = v731; - a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.field_60_distance_related_prolly_lod = 0; - a1.uFacing = 0; - a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - a1.uSoundID = LOWORD(v3->sound_id); - a2 = 0; - int _v726 = 0; - if ( SHIDWORD(v733) > 0 ) - { - _v726 = (HIDWORD(v733) * (7 * v2 + 25)); - do - { - v625 = dword_50BF30[a2]; - a1.vPosition.x = pActors[v625].vPosition.x; - a1.vPosition.y = pActors[v625].vPosition.y; - //v732 = pActors[v625].uActorHeight; - a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); - v627 = a1.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; + a1.uFacing = v596 + v597; + if ( a1.Create( + v596 + v597, + v715.uPitchAngle, + pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, + v3->uPlayerID + 1) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + v596 += _v726 / (amount - 1); + } + while ( v596 <= (signed int)y ); + } + LODWORD(v727) = 1; + break; + } + + case SPELL_DARK_CONTROL_UNDEAD: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( v731 == 1 || v731 == 2 ) + { + v598 = 180 * v2; + goto LABEL_1081; + } + if ( v731 == 3 ) + { + v598 = 300 * v2; +LABEL_1081: + LODWORD(v733) = v598; + goto LABEL_1082; + } + 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); + v3->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); + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + v60 = pObjectList->ObjectIDByItemID(a1.uType); + v61 = PID_ID(a2); +LABEL_1086: + v600 = pActors[v61].vPosition.y; + v601 = pActors[v61].vPosition.x; + a1.uObjectDescID = v60; + a1.vPosition.x = v601; + v602 = pActors[v61].uActorHeight; + v603 = pActors[v61].vPosition.z; + a1.vPosition.y = v600; + v676 = v603 + v602; + v665 = v600; + a1.vPosition.z = v603 + v602; + v657 = v601; +LABEL_1087: + a1.uAttributes = 0; + a1.uSectorID = pIndoor->GetSector(v657, v665, v676); + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; + a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + a1.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(a1.uAttributes) |= 0x80u; + a1.uSoundID = LOWORD(v3->sound_id); + a1.Create(0, 0, 0, v3->uPlayerID + 1); + LODWORD(v727) = 1; + break; + } + case SPELL_DARK_SACRIFICE: + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + HIDWORD(v733) = 0; + memset(&achievedAwardsIndex, 0, 4000); + _this = 0; + v605 = (char *)pParty->pHirelings; + do + { + if ( *(int *)v605) + { + v606 = HIDWORD(v733)++; + achievedAwardsIndex[v606] = (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; + HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152; 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 ) - { - 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(v3->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; - goto play_sound_and_continue; - } - - case 98: - { - 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); - v3->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); - v3->spellnum = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - goto play_sound_and_continue; - pParty->armageddon_timer = 256; - pParty->field_16140 = v2; - ++pPlayer->uNumArmageddonCasts; - if ( pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->field_1C; - auto _v726 = 50; + 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 = v3->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); + v3->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(v3->spellnum, v3->uPlayerID_2); + + pParty->pPlayers[v3->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 + { + pGame->GetStru6()->SetPlayerBuffAnim(v3->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; + a1.stru_24.Reset(); + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; + a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.field_60_distance_related_prolly_lod = 0; + a1.uFacing = 0; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + a2 = 0; + int _v726 = 0; + if ( SHIDWORD(v733) > 0 ) + { + _v726 = (HIDWORD(v733) * (7 * v2 + 25)); 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; - goto play_sound_and_continue; - } - - default: - goto play_sound_and_continue; - } - while ( 2 ) - { - if ( v731 == 4 ) - { - if ( *((_QWORD *)v222 + 2) ) - { - *((int *)v222 + 4) = 0; - *((int *)v222 + 5) = 0; - goto LABEL_439; - } - } - else - { - v223 = ((Player *)v222)->DiscardConditionIfLastsLongerThan( - 2u, - pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)); - v222 = (char *)HIDWORD(v733); - if ( v223 ) - LABEL_439: - ((Player *)v222)->PlaySound(SPEECH_103, 0); - } - v222 += 6972; - HIDWORD(v733) = (int)v222; - if ( (signed int)v222 >= (signed int)pParty->pHirelings ) - { - LODWORD(v727) = 1; - goto play_sound_and_continue; - } - continue; + v625 = dword_50BF30[a2]; + a1.vPosition.x = pActors[v625].vPosition.x; + a1.vPosition.y = pActors[v625].vPosition.y; + //v732 = pActors[v625].uActorHeight; + a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); + v627 = a1.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 ) + { + 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(v3->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); + v3->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); + v3->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; + } + if ( v3->field_8 & 0x20 ) + { + if ( v727 != 0.0 ) + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[v3->spellnum], 0, 0, -1, 0, v3->sound_id, 0, 0); + } + else + { + if ( sRecoveryTime < 0 ) + sRecoveryTime = 0; + if ( pParty->bTurnBasedModeOn ) + { + v645 = sRecoveryTime; + pParty->pTurnBasedPlayerRecoveryTimes[v3->uPlayerID] = sRecoveryTime; + pPlayer->SetRecoveryTime(v645); + if ( !some_active_character ) + pTurnEngine->_40471C(); + } + else + { + pPlayer->SetRecoveryTime( + (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333)); + } + if ( v727 != 0.0 ) + { + pPlayer->PlaySound(SPEECH_49, 0); + if ( v727 != 0.0 ) + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[v3->spellnum], 0, 0, -1, 0, v3->sound_id, 0, 0); + v3->spellnum = 0; + v2 = v723; + continue; } } - - ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points" - v3->spellnum = 0; + v3->spellnum = 0; + v2 = v723; + continue; + //LABEL_1166: // ++n; // if ( n >= 10 )