Mercurial > mm7
changeset 1931:2e3d08ff3309
DamageMonsterFromParty renaming vars, deleting unused ones, values to enums, etc.
author | Grumpy7 |
---|---|
date | Wed, 23 Oct 2013 20:36:19 -0700 |
parents | df4e27f2a541 |
children | 28b8ecb5dac6 |
files | Actor.cpp |
diffstat | 1 files changed, 83 insertions(+), 111 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Wed Oct 23 19:13:07 2013 -0700 +++ b/Actor.cpp Wed Oct 23 20:36:19 2013 -0700 @@ -3560,7 +3560,7 @@ void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) { //signed int v3; // eax@1 - SpriteObject *v4; // ebx@1 + SpriteObject *projectileSprite; // ebx@1 //int v5; // edx@3 //bool uPlayerID; // eax@3 //Player *pPlayer; // edi@4 @@ -3615,34 +3615,34 @@ signed int a4; // [sp+44h] [bp-28h]@1 PlayerEquipment *v57; // [sp+48h] [bp-24h]@10 //int v58; // [sp+4Ch] [bp-20h]@10 - int v59; // [sp+50h] [bp-1Ch]@1 + bool IsAdditionalDamagePossible; // [sp+50h] [bp-1Ch]@1 unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1 int v61; // [sp+58h] [bp-14h]@1 bool v62; // [sp+5Ch] [bp-10h]@1 int uDamageAmount; // [sp+60h] [bp-Ch]@1 - int a2; // [sp+64h] [bp-8h]@27 + DAMAGE_TYPE attackElement; // [sp+64h] [bp-8h]@27 int a3; // [sp+6Bh] [bp-1h]@6 //v3 = a1; - v4 = 0; + projectileSprite = 0; uActorID_Monster_ = uActorID_Monster; //v54 = a1; uDamageAmount = 0; a4 = 0; v61 = 0; - v59 = 0; + IsAdditionalDamagePossible = false; v62 = 0; if ( PID_TYPE(a1) == OBJECT_Item) { - v4 = &pSpriteObjects[PID_ID(a1)]; - v61 = v4->field_60_distance_related_prolly_lod; - a1 = v4->spell_caster_pid; + projectileSprite = &pSpriteObjects[PID_ID(a1)]; + v61 = projectileSprite->field_60_distance_related_prolly_lod; + a1 = projectileSprite->spell_caster_pid; } if (PID_TYPE(a1) != OBJECT_Player) return; assert(PID_ID(abs(a1)) < 4); - auto player = &pParty->pPlayers[PID_ID(a1)]; + Player* player = &pParty->pPlayers[PID_ID(a1)]; pMonster = &pActors[uActorID_Monster_]; if (pMonster->IsNotAlive()) return; @@ -3652,14 +3652,14 @@ pMonster->uAttributes |= 0x20000u; bool hit_will_stun = false, hit_will_paralyze = false; - if ( !v4 ) + if ( !projectileSprite ) { int main_hand_idx = player->pEquipment.uMainHand; - v59 = 1; + IsAdditionalDamagePossible = true; if ( player->HasItemEquipped(EQUIP_MAIN_HAND) ) { - auto main_hand_skill = player->GetMainHandItem()->GetPlayerSkillType(); - auto main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]); + uint main_hand_skill = player->GetMainHandItem()->GetPlayerSkillType(); + uint main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]); switch (main_hand_skill) { case PLAYER_SKILL_STAFF: @@ -3684,9 +3684,8 @@ break; } } - v50 = pMonster->pMonsterInfo.uID; - a2 = 4; - uDamageAmount = player->CalculateMeleeDamageTo(false, false, v50); + attackElement = DMGT_PHISYCAL; + uDamageAmount = player->CalculateMeleeDamageTo(false, false, pMonster->pMonsterInfo.uID); if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); @@ -3695,13 +3694,12 @@ } else { - v19 = v4->spell_id == SPELL_DARK_SOULDRINKER; - v61 = v4->field_60_distance_related_prolly_lod; - if ( !v19 ) + v61 = projectileSprite->field_60_distance_related_prolly_lod; + if ( projectileSprite->spell_id != SPELL_DARK_SOULDRINKER ) { - v50 = pParty->vPosition.x - v4->vPosition.x; - pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y); - pPlayerName = (char *)(pParty->vPosition.z - v4->vPosition.z); + v50 = pParty->vPosition.x - projectileSprite->vPosition.x; + pMonsterName = (char *)(pParty->vPosition.y - projectileSprite->vPosition.y); + pPlayerName = (char *)(pParty->vPosition.z - projectileSprite->vPosition.z); v52 = abs((int)pPlayerName); v61 = abs(v50); v10 = abs(v50); @@ -3712,10 +3710,10 @@ v10 = (int)v11; v11 = v10; } - if ( v10 < v52 ) + if ( v10 < v12 ) { v13 = v10; - v10 = v52; + v10 = v12; v12 = v13; } if ( v11 < (signed int)v12 ) @@ -3725,10 +3723,12 @@ v11 = v14; } v61 = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10; - if ( v61 >= 2560 ) + if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) ) { - if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) ) - return; + return; + } + else if ( v61 >= 2560 ) + { v61 = 2; } else @@ -3737,14 +3737,14 @@ } } - switch (v4->spell_id) + switch (projectileSprite->spell_id) { case SPELL_LASER_PROJECTILE: v16 = player->pActiveSkills[7]; v61 = 1; if ( (signed int)SkillToMastery(v16) >= 3 ) a4 = player->pActiveSkills[7] & 0x3F; - a2 = 4; + attackElement = DMGT_PHISYCAL; uDamageAmount = player->CalculateMeleeDamageTo(true, true, 0); if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) { @@ -3753,14 +3753,11 @@ } break; case SPELL_101: - a2 = 0; - v18 = player->CalculateRangedDamageTo(0); - v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; - v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; - uDamageAmount = v18; - if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) + attackElement = DMGT_FIRE; + uDamageAmount = player->CalculateRangedDamageTo(0); + if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) uDamageAmount >>= 1; - v59 = 1; + IsAdditionalDamagePossible = true; if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); @@ -3768,18 +3765,12 @@ } break; case SPELL_EARTH_BLADES: - a4 = 5 * v4->spell_level; - a2 = player->GetSpellSchool(0x27u); - v21 = v4->spell_level; - v50 = pMonster->sCurrentHP; - pMonsterName = (char *)v4->spell_skill; - v22 = _43AFE3_calc_spell_damage(39, v21, v4->spell_skill, v50); - v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; - v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; - uDamageAmount = v22; - if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) + a4 = 5 * projectileSprite->spell_level; + attackElement = (DAMAGE_TYPE)player->GetSpellSchool(SPELL_EARTH_BLADES); + uDamageAmount = _43AFE3_calc_spell_damage(39, projectileSprite->spell_level, projectileSprite->spell_skill, pMonster->sCurrentHP); + if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) uDamageAmount >>= 1; - v59 = 0; + IsAdditionalDamagePossible = false; if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); @@ -3788,7 +3779,7 @@ break; case SPELL_EARTH_STUN: uDamageAmount = 0; - a2 = 4; + attackElement = DMGT_PHISYCAL; hit_will_stun = 1; if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) { @@ -3798,14 +3789,14 @@ break; case SPELL_BOW_ARROW: v50 = pMonster->word_000086_some_monster_id; - a2 = 4; + attackElement = DMGT_PHISYCAL; uDamageAmount = player->CalculateRangedDamageTo(v50); if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) uDamageAmount /= 2; - v59 = 1; - if ( v4->stru_24.uItemID != 0 && v4->stru_24.uSpecEnchantmentType == 3 ) //of carnage + IsAdditionalDamagePossible = true; + if ( projectileSprite->stru_24.uItemID != 0 && projectileSprite->stru_24.uSpecEnchantmentType == 3 ) //of carnage { - a2 = 0; + attackElement = DMGT_FIRE; } else if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) { @@ -3815,13 +3806,9 @@ break; default: - a2 = player->GetSpellSchool(v4->spell_id); - v25 = v4->spell_level; - v26 = v4->spell_id; - v50 = pMonster->sCurrentHP; - pMonsterName = (char *)v4->spell_skill; - v59 = 0; - uDamageAmount = _43AFE3_calc_spell_damage(v26, v25, v4->spell_skill, v50); + attackElement = (DAMAGE_TYPE)player->GetSpellSchool(projectileSprite->spell_id); + IsAdditionalDamagePossible = false; + uDamageAmount = _43AFE3_calc_spell_damage(projectileSprite->spell_id, projectileSprite->spell_level, projectileSprite->spell_skill, pMonster->sCurrentHP); break; } } @@ -3830,19 +3817,19 @@ uDamageAmount /= 2; if ( pMonster->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 ) uDamageAmount = 0; - v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount); - if ( !v4 && player->IsUnarmed() && player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime > 0 ) + v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, attackElement, uDamageAmount); + if ( !projectileSprite && player->IsUnarmed() && player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime > 0 ) { v50 = player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uPower; v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50); v61 += v29; } uDamageAmount = v61; - if ( v59 ) + if ( IsAdditionalDamagePossible ) { - if ( v4 ) + if ( projectileSprite ) { - a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62); + a4 = projectileSprite->stru_24._439DF3_get_additional_damage((int*)&attackElement, &v62); if ( v62 && pMonster->sCurrentHP > 0 ) { player->sHealth += v61 / 5; @@ -3850,19 +3837,21 @@ player->sHealth = player->GetMaxHealth(); v62 = 0; } - v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); - uDamageAmount = v61 + v30; + v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, attackElement, a4); + uDamageAmount += v30; } else { - v59 = 0; - v57 = &player->pEquipment; - do + for (int i = 0; i < 2; i++) { - if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)v59) ) + if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { - auto _s = (ItemGen *)&player->pInventoryItemList[v57->uShield - 1]; - a4 = _s->_439DF3_get_additional_damage(&a2, &v62); + ItemGen* item; + if (i == 0) + item = player->GetMainHandItem(); + else + item = player->GetOffHandItem(); + a4 = item->_439DF3_get_additional_damage((int*)&attackElement, &v62); if ( v62 && pMonster->sCurrentHP > 0 ) { player->sHealth += v61 / 5; @@ -3870,13 +3859,10 @@ player->sHealth = player->GetMaxHealth(); v62 = 0; } - v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); + v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, attackElement, a4); uDamageAmount += v31; } - ++v59; - v57 = (PlayerEquipment *)((char *)v57 + 4); } - while ( v59 <= 1 ); } } v32 = uDamageAmount; @@ -3892,29 +3878,24 @@ Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); if ( bShowDamage ) { - v50 = uDamageAmount; - pMonsterName = (char *)pMonster; - pPlayerName = player->pName; - if ( v4 ) + if ( projectileSprite ) v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points" else v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage" - sprintfex(pTmpBuf.data(), v47, pPlayerName, pMonsterName, v50); + sprintfex(pTmpBuf.data(), v47, player->pName, pMonster->pActorName, uDamageAmount); ShowStatusBarString(pTmpBuf.data(), 2u); } - v41 = 0; } else { if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) { - v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; + v33 = byte_4D864C && pGame->uFlags & 80000 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; //v55 = v33; if ( pRenderer->pRenderD3D ) { if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) { - v50 = 0; pMonsterName = 0; v34 = pMonster->vPosition.z; *(float *)&pPlayerName = (double)v33; @@ -3942,54 +3923,45 @@ if ( rand() % 100 < 20 ) v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1; player->PlaySound((PlayerSpeech)v40, 0); - v41 = 0; if ( bShowDamage ) { - v50 = (int)pMonster; pMonsterName = (char *)uDamageAmount; pPlayerName = player->pName; // "%s inflicts %lu points killing %s" sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); ShowStatusBarString(pTmpBuf.data(), 2u); } } - if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41 - && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41 - || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41) - && uDamageAmount != v41 ) - player->ReceiveDamage(uDamageAmount, (DAMAGE_TYPE)a2); - v50 = 24; - v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; - if ( (player->GetSpecialItemBonus(24) || hit_will_stun != v41) - && stru_50C198.GetMagicalResistance(pMonster, 3u) ) + if ( pMonster->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].uExpireTime > 0 + && uDamageAmount != 0 ) + player->ReceiveDamage(uDamageAmount, attackElement); + int knockbackValue = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; + if ( (player->GetSpecialItemBonus(24) || hit_will_stun) + && stru_50C198.GetMagicalResistance(pMonster, DMGT_EARTH) ) { - LODWORD(v42) = 20; - v59 = 10; - if ( pParty->bTurnBasedModeOn == v41 ) + v42 = 20; + knockbackValue = 10; + if ( !pParty->bTurnBasedModeOn ) v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666); pMonster->pMonsterInfo.uRecoveryTime += v42; - if ( bShowDamage != v41 ) + if ( bShowDamage ) { - v50 = (int)pMonster; pMonsterName = player->pName; // "%s stuns %s" sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[635], player->pName, pMonster); ShowStatusBarString(pTmpBuf.data(), 2u); } } - if ( hit_will_paralyze != v41 ) + if ( hit_will_paralyze ) { if ( pMonster->CanAct() ) { - if ( stru_50C198.GetMagicalResistance(pMonster, 3) ) + if ( stru_50C198.GetMagicalResistance(pMonster, DMGT_EARTH) ) { LOBYTE(v43) = player->GetActualSkillLevel(PLAYER_SKILL_MACE); - v44 = v43; v45 = SkillToMastery(v43); - //v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F)); - v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v44 & 0x3F)) * 0.033333335); + v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v43 & 0x3F)) * 0.033333335); pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0); if ( bShowDamage ) { - v50 = (int)pMonster; pMonsterName = player->pName; // "%s paralyzes %s" sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[636], player->pName, pMonster); ShowStatusBarString(pTmpBuf.data(), 2u); @@ -3997,13 +3969,13 @@ } } } - if ( v59 > 10 ) - v59 = 10; + if ( knockbackValue > 10 ) + knockbackValue = 10; if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { - pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16; - pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16; - pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16; + pVelocity->x = (unsigned __int64)(knockbackValue * (signed __int64)pVelocity->x) >> 16; + pVelocity->y = (unsigned __int64)(knockbackValue * (signed __int64)pVelocity->y) >> 16; + pVelocity->z = (unsigned __int64)(knockbackValue * (signed __int64)pVelocity->z) >> 16; pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x); pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y); pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);