comparison Player.cpp @ 1657:51a74615d956

DamagePlayerFromMonster continuing cleanup, part 3
author Grumpy7
date Wed, 18 Sep 2013 10:22:16 +0200
parents 56847118d50c
children 406872881eb6
comparison
equal deleted inserted replaced
1656:56847118d50c 1657:51a74615d956
7472 signed int v4; // esi@1 7472 signed int v4; // esi@1
7473 unsigned int v5; // ecx@1 7473 unsigned int v5; // ecx@1
7474 Player *playerPtr; // ebx@3 7474 Player *playerPtr; // ebx@3
7475 Actor *actorPtr; // esi@3 7475 Actor *actorPtr; // esi@3
7476 unsigned int v8; // eax@4 7476 unsigned int v8; // eax@4
7477 char *v9; // eax@5
7478 signed int v10; // eax@6
7479 int v11; // edx@8 7477 int v11; // edx@8
7480 int v12; // edx@9
7481 int v13; // edx@10
7482 int v14; // edx@16 7478 int v14; // edx@16
7483 int v15; // edx@17
7484 int v16; // edx@18
7485 enum SoundID v17; // eax@24 7479 enum SoundID v17; // eax@24
7486 int v18; // eax@26
7487 unsigned __int8 v19; // zf@26
7488 unsigned __int8 v20; // sf@26
7489 unsigned __int16 v21; // ax@29 7480 unsigned __int16 v21; // ax@29
7490 signed int v22; // edi@36 7481 signed int v22; // edi@36
7491 int v23; // eax@38 7482 int v23; // eax@38
7492 signed int v24; // eax@44 7483 signed int v24; // eax@44
7493 AIState v25; // cx@47 7484 AIState v25; // cx@47
7494 signed int v26; // eax@49 7485 signed int v26; // eax@49
7495 int v27; // eax@54 7486 int v27; // eax@54
7496 float v28; // ST18_4@58
7497 double v29; // st7@58
7498 float v30; // ST08_4@58
7499 double v31; // st7@58
7500 float v32; // ST04_4@58
7501 float v33; // ST00_4@58
7502 int v34; // edi@61 7487 int v34; // edi@61
7503 int v35; // eax@70 7488 int v35; // eax@70
7504 double v36; // st7@70 7489 int v36; // st7@70
7505 SpriteObject *v37; // ebx@77 7490 SpriteObject *v37; // ebx@77
7506 int v38; // edi@77 7491 int v38; // edi@77
7507 int v39; // esi@77 7492 int v39; // esi@77
7508 int v40; // eax@77 7493 int v40; // eax@77
7509 int v41; // eax@77 7494 int v41; // eax@77
7510 int v42; // eax@78
7511 Player *v43; // eax@81 7495 Player *v43; // eax@81
7512 //Actor *actorPtr; // esi@82 7496 //Actor *actorPtr; // esi@82
7513 Player *v45; // edi@84 7497 Player *v45; // edi@84
7514 unsigned __int16 v46; // ax@84 7498 unsigned __int16 v46; // ax@84
7515 int v47; // ebx@105
7516 int v48; // eax@107 7499 int v48; // eax@107
7517 unsigned __int16 v49; // ax@116 7500 unsigned __int16 v49; // ax@116
7518 int v50; // ebx@123 7501 int v50; // ebx@123
7519 unsigned __int16 v51; // ax@124 7502 unsigned __int16 v51; // ax@124
7520 char v52; // bl@124
7521 int v53; // eax@128 7503 int v53; // eax@128
7522 signed int v54; // eax@134 7504 signed int v54; // eax@134
7523 unsigned __int16 v55; // cx@137 7505 unsigned __int16 v55; // cx@137
7524 signed int recvdMagicDmg; // eax@139 7506 signed int recvdMagicDmg; // eax@139
7525 int v57; // eax@144 7507 int v57; // eax@144
7526 float v58; // ST18_4@148
7527 double v59; // st7@148
7528 float v60; // ST08_4@148
7529 double v61; // st7@148
7530 float v62; // ST04_4@148
7531 float v63; // ST00_4@148
7532 int v64; // ebx@151 7508 int v64; // ebx@151
7533 int v65; // eax@161 7509 int v65; // eax@161
7534 double v66; // st7@161 7510 int v66; // st7@161
7535 signed int v67; // ecx@164
7536 signed int v68; // eax@170 7511 signed int v68; // eax@170
7537 int v69; // ecx@170 7512 int v69; // ecx@170
7538 int v70; // eax@171 7513 int v70; // eax@171
7539 enum SoundID v71; // [sp+20h] [bp-34h]@12
7540 int v72[4]; // [sp+30h] [bp-24h]@164 7514 int v72[4]; // [sp+30h] [bp-24h]@164
7541 double v73; // [sp+40h] [bp-14h]@72
7542 signed int v74; // [sp+44h] [bp-10h]@1 7515 signed int v74; // [sp+44h] [bp-10h]@1
7543 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 7516 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3
7544 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 7517 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1
7545 int dmgToReceive; // [sp+50h] [bp-4h]@26 7518 int dmgToReceive; // [sp+50h] [bp-4h]@26
7546 signed int a4a; // [sp+60h] [bp+Ch]@162
7547 Player *a4b; // [sp+60h] [bp+Ch]@168
7548 7519
7549 v4 = PID_ID(uObjID); 7520 v4 = PID_ID(uObjID);
7550 v5 = PID_TYPE(uObjID) - 2; 7521 v5 = PID_TYPE(uObjID) - 2;
7551 v74 = a2; 7522 v74 = a2;
7552 uActorID = v4; 7523 uActorID = v4;
7632 else 7603 else
7633 { 7604 {
7634 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) 7605 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS)
7635 { 7606 {
7636 v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; 7607 v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius;
7637 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, v27, 0, 0); 7608 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)v27, 0, 0);
7638 } 7609 }
7639 Actor::Die(uActorID); 7610 Actor::Die(uActorID);
7640 Actor::ApplyFineForKillingPeasant(uActorID); 7611 Actor::ApplyFineForKillingPeasant(uActorID);
7641 Actor::AggroSurroundingPeasants(uActorID, 1); 7612 Actor::AggroSurroundingPeasants(uActorID, 1);
7642 if ( actorPtr->pMonsterInfo.uExp ) 7613 if ( actorPtr->pMonsterInfo.uExp )
7657 } 7628 }
7658 } 7629 }
7659 if ( !pParty->bTurnBasedModeOn ) 7630 if ( !pParty->bTurnBasedModeOn )
7660 { 7631 {
7661 v35 = playerPtr->GetActualEndurance(); 7632 v35 = playerPtr->GetActualEndurance();
7662 v36 = (20 - playerPtr->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; 7633 v36 = (int)((20 - playerPtr->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333);
7663 playerPtr->SetRecoveryTime(v36); 7634 playerPtr->SetRecoveryTime(v36);
7664 } 7635 }
7665 int yellThreshold = playerPtr->GetMaxHealth() * 0.25; 7636 int yellThreshold = playerPtr->GetMaxHealth() / 4;
7666 if ( yellThreshold < playerPtr->sHealth && yellThreshold >= healthBeforeRecvdDamage && playerPtr->sHealth > 0 ) 7637 if ( yellThreshold < playerPtr->sHealth && yellThreshold >= healthBeforeRecvdDamage && playerPtr->sHealth > 0 )
7667 { 7638 {
7668 playerPtr->PlaySound(SPEECH_48, 0); 7639 playerPtr->PlaySound(SPEECH_48, 0);
7669 } 7640 }
7670 viewparams->bRedrawGameUI = 1; 7641 viewparams->bRedrawGameUI = 1;
7676 v38 = PID_TYPE(v37->spell_caster_pid); 7647 v38 = PID_TYPE(v37->spell_caster_pid);
7677 v39 = PID_ID(v37->spell_caster_pid); 7648 v39 = PID_ID(v37->spell_caster_pid);
7678 v40 = PID_TYPE(v37->spell_caster_pid); 7649 v40 = PID_TYPE(v37->spell_caster_pid);
7679 uActorID = PID_ID(v37->spell_caster_pid); 7650 uActorID = PID_ID(v37->spell_caster_pid);
7680 v41 = v40 - 2; 7651 v41 = v40 - 2;
7681 if ( !v41 ) 7652 if ( v40 == 2 )
7682 goto LABEL_80; 7653 {
7683 v42 = v41 - 1; 7654 if ( a4 != -1 )
7684 if ( !v42 ) 7655 {
7656 v43 = &pParty->pPlayers[a4];
7657 }
7658 else
7659 {
7660 v74 = 0;
7661 for (int i = 1; i <= 4; i++)
7662 {
7663 v72[v74] = i;
7664 v74++;
7665 }
7666 if ( v74 )
7667 {
7668 v43 = &pParty->pPlayers[v72[rand() % v74]];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
7669 }
7670 }
7671 if ( v38 != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW)
7672 {
7673 v70 = v43->GetMaxHealth();
7674 v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, v70);
7675 v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool);
7676 }
7677 else
7678 {
7679 v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
7680 v69 = 0;
7681 }
7682 v43->ReceiveDamage(v68, (DAMAGE_TYPE)v69);
7683 if ( v38 == OBJECT_Player && !qword_A750D8 )
7684 {
7685 qword_A750D8 = 256i64;
7686 PlayerSpeechID = SPEECH_44;
7687 uSpeakingCharacter = uActorID + 1;
7688 }
7689 return;
7690 }
7691 else if ( v40 == 3 )
7685 { 7692 {
7686 actorPtr = &pActors[v39]; 7693 actorPtr = &pActors[v39];
7687 if ( a4 == -1 ) 7694 if ( a4 == -1 )
7688 a4 = stru_50C198.which_player_would_attack(actorPtr); 7695 a4 = stru_50C198.which_player_would_attack(actorPtr);
7689 v45 = &pParty->pPlayers[a4]; 7696 v45 = &pParty->pPlayers[a4];
7698 ShowStatusBarString(pTmpBuf.data(), 2u); 7705 ShowStatusBarString(pTmpBuf.data(), 2u);
7699 v45->PlaySound(SPEECH_6, 0); 7706 v45->PlaySound(SPEECH_6, 0);
7700 return; 7707 return;
7701 } 7708 }
7702 } 7709 }
7703 else 7710 else if ( v46 == 555
7704 { 7711 || v46 == 510
7705 if ( v46 != 555 7712 || v46 == 500
7706 && v46 != 510 7713 || v46 == 515
7707 && v46 != 500 7714 || v46 == 505
7708 && v46 != 515 7715 || v46 == 530
7709 && v46 != 505 7716 || v46 == 525
7710 && v46 != 530 7717 || v46 == 520
7711 && v46 != 525 7718 || v46 == 535
7712 && v46 != 520 7719 || v46 == 540 )
7713 && v46 != 535 7720 {
7714 && v46 != 540 ) 7721 if ( !stru_50C198.ActorHitOrMiss(actorPtr, v45) )
7715 goto LABEL_115; 7722 return;
7716 } 7723 if ( (signed __int64)v45->pPlayerBuffs[13].uExpireTime > 0 )
7717 if ( !stru_50C198.ActorHitOrMiss(actorPtr, v45) )
7718 return;
7719 if ( (signed __int64)v45->pPlayerBuffs[13].uExpireTime > 0 )
7720 dmgToReceive >>= 1;
7721 if ( v45->HasEnchantedItemEquipped(36) )
7722 dmgToReceive >>= 1;
7723 if ( v45->HasEnchantedItemEquipped(69) )
7724 dmgToReceive >>= 1;
7725 if ( v45->HasItemEquipped(EQUIP_ARMOUR)
7726 && v45->pInventoryItemList[v45->pEquipment.uArmor-1].uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR )
7727 dmgToReceive >>= 1;
7728 if ( v45->HasItemEquipped(EQUIP_MAIN_HAND))
7729 {
7730 v48 = v45->pInventoryItemList[v45->pEquipment.uMainHand - 1].uItemID;
7731 if ( v48 == ITEM_RELIC_KELEBRIM || v48 == ITEM_ARTIFACT_ELFBANE || (v45->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4))
7732 dmgToReceive >>= 1; 7724 dmgToReceive >>= 1;
7733 } 7725 if ( v45->HasEnchantedItemEquipped(36) )
7734 if ( v45->HasItemEquipped(EQUIP_OFF_HAND))
7735 {
7736 v48 = v45->pInventoryItemList[v45->pEquipment.uShield - 1].uItemID;
7737 if ( v48 == ITEM_RELIC_KELEBRIM || v48 == ITEM_ARTIFACT_ELFBANE || (v45->GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4))
7738 dmgToReceive >>= 1; 7726 dmgToReceive >>= 1;
7739 } 7727 if ( v45->HasEnchantedItemEquipped(69) )
7740 LABEL_115: 7728 dmgToReceive >>= 1;
7729 if ( v45->HasItemEquipped(EQUIP_ARMOUR)
7730 && v45->pInventoryItemList[v45->pEquipment.uArmor-1].uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR )
7731 dmgToReceive >>= 1;
7732 if ( v45->HasItemEquipped(EQUIP_MAIN_HAND))
7733 {
7734 v48 = v45->pInventoryItemList[v45->pEquipment.uMainHand - 1].uItemID;
7735 if ( v48 == ITEM_RELIC_KELEBRIM || v48 == ITEM_ARTIFACT_ELFBANE || (v45->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4))
7736 dmgToReceive >>= 1;
7737 }
7738 if ( v45->HasItemEquipped(EQUIP_OFF_HAND))
7739 {
7740 v48 = v45->pInventoryItemList[v45->pEquipment.uShield - 1].uItemID;
7741 if ( v48 == ITEM_RELIC_KELEBRIM || v48 == ITEM_ARTIFACT_ELFBANE || (v45->GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4))
7742 dmgToReceive >>= 1;
7743 }
7744 }
7741 if ( actorPtr->pActorBuffs[3].uExpireTime > 0 ) 7745 if ( actorPtr->pActorBuffs[3].uExpireTime > 0 )
7742 { 7746 {
7743 v49 = actorPtr->pActorBuffs[3].uPower; 7747 v49 = actorPtr->pActorBuffs[3].uPower;
7744 if ( v49 ) 7748 if ( v49 )
7745 dmgToReceive /= (signed int)v49; 7749 dmgToReceive /= (signed int)v49;
7746 } 7750 }
7747 switch(v47) 7751 switch(v74)
7748 { 7752 {
7749 case 0: 7753 case 0:
7750 v50 = actorPtr->pMonsterInfo.uAttack1Type; 7754 v50 = actorPtr->pMonsterInfo.uAttack1Type;
7751 break; 7755 break;
7752 case 1: 7756 case 1:
7787 else 7791 else
7788 { 7792 {
7789 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) 7793 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
7790 { 7794 {
7791 v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; 7795 v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius;
7792 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, v57, 0, 0); 7796 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)v57, 0, 0);
7793 } 7797 }
7794 Actor::Die(uActorID); 7798 Actor::Die(uActorID);
7795 Actor::ApplyFineForKillingPeasant(uActorID); 7799 Actor::ApplyFineForKillingPeasant(uActorID);
7796 Actor::AggroSurroundingPeasants(uActorID, 1); 7800 Actor::AggroSurroundingPeasants(uActorID, 1);
7797 if ( actorPtr->pMonsterInfo.uExp ) 7801 if ( actorPtr->pMonsterInfo.uExp )
7807 } 7811 }
7808 if ( !v74 7812 if ( !v74
7809 && !(dword_6BE368_debug_settings_2 & 0x10) 7813 && !(dword_6BE368_debug_settings_2 & 0x10)
7810 && actorPtr->pMonsterInfo.uSpecialAttack 7814 && actorPtr->pMonsterInfo.uSpecialAttack
7811 && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackType ) 7815 && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackType )
7816 {
7812 v45->_48DCF6(actorPtr->pMonsterInfo.uSpecialAttack, actorPtr); 7817 v45->_48DCF6(actorPtr->pMonsterInfo.uSpecialAttack, actorPtr);
7818 }
7813 if ( !pParty->bTurnBasedModeOn ) 7819 if ( !pParty->bTurnBasedModeOn )
7814 { 7820 {
7815 v65 = v45->GetActualEndurance(); 7821 v65 = v45->GetActualEndurance();
7816 v66 = (double)(20 - v45->GetParameterBonus(v65)) 7822 v66 = (int)((20 - v45->GetParameterBonus(v65))
7817 * flt_6BE3A4_debug_recmod1 7823 * flt_6BE3A4_debug_recmod1
7818 * 2.133333333333333; 7824 * 2.133333333333333);
7819 v45->SetRecoveryTime((signed __int64)v66); 7825 v45->SetRecoveryTime(v66);
7820 } 7826 }
7821 return; 7827 return;
7822 } 7828 }
7823 if ( v42 != 1 )
7824 return;
7825 LABEL_80:
7826 if ( a4 != -1 )
7827 {
7828 v43 = &pParty->pPlayers[a4];
7829 }
7830 else 7829 else
7831 { 7830 {
7832 v74 = 0;
7833 for (int i = 1; i <= 4; i++)
7834 {
7835 v72[v74] = i;
7836 v74++;
7837 }
7838 if ( v74 )
7839 {
7840 v43 = &pParty->pPlayers[v72[rand() % v74]];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
7841 }
7842 }
7843 a4b = v43;
7844 if ( v38 != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW)
7845 {
7846 v70 = v43->GetMaxHealth();
7847 v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, v70);
7848 v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool);
7849 }
7850 else
7851 {
7852 v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
7853 v69 = 0;
7854 }
7855 a4b->ReceiveDamage(v68, (DAMAGE_TYPE)v69);
7856 if ( v38 == OBJECT_Player && !qword_A750D8 )
7857 {
7858 qword_A750D8 = 256i64;
7859 PlayerSpeechID = SPEECH_44;
7860 uSpeakingCharacter = uActorID + 1;
7861 }
7862 return; 7831 return;
7863 } 7832 }
7864 } 7833 }
7865 } 7834 }
7866 //----- (00421EA6) -------------------------------------------------------- 7835 //----- (00421EA6) --------------------------------------------------------