Mercurial > mm7
changeset 2294:815d9ecf9881
Merge
author | Grumpy7 |
---|---|
date | Sun, 16 Mar 2014 19:43:28 +0100 |
parents | b0f10ef66e00 (diff) d65414f65bd4 (current diff) |
children | 37568c981629 4c3f91554be8 |
files | |
diffstat | 6 files changed, 160 insertions(+), 179 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sun Mar 16 19:34:51 2014 +0600 +++ b/Actor.cpp Sun Mar 16 19:43:28 2014 +0100 @@ -2807,8 +2807,8 @@ pActor=&pActors[i]; if ( pActor->CanAct() ) { - sDmg = stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4); - pActor->sCurrentHP -= stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4); + sDmg = pActor->CalcMagicalDamageToActor((DAMAGE_TYPE)5, v4); + pActor->sCurrentHP -= sDmg; if ( sDmg ) { if ( pActor->sCurrentHP >= 0 ) @@ -3448,7 +3448,7 @@ } attackElement = DMGT_PHISYCAL; uDamageAmount = player->CalculateMeleeDamageTo(false, false, pMonster->pMonsterInfo.uID); - if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) + if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); return; @@ -3477,11 +3477,11 @@ case SPELL_LASER_PROJECTILE: v16 = player->pActiveSkills[PLAYER_SKILL_BLASTER]; v61 = 1; - if ( (signed int)SkillToMastery(v16) >= 3 ) + if ( SkillToMastery(v16) >= 3 ) a4 = player->pActiveSkills[PLAYER_SKILL_BLASTER] & 0x3F; attackElement = DMGT_PHISYCAL; uDamageAmount = player->CalculateMeleeDamageTo(true, true, 0); - if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) + if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); return; @@ -3493,7 +3493,7 @@ if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) uDamageAmount >>= 1; IsAdditionalDamagePossible = true; - if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) + if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); return; @@ -3506,7 +3506,7 @@ if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) uDamageAmount >>= 1; IsAdditionalDamagePossible = false; - if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) + if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); return; @@ -3516,7 +3516,7 @@ uDamageAmount = 0; attackElement = DMGT_PHISYCAL; hit_will_stun = 1; - if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) + if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); return; @@ -3532,7 +3532,7 @@ { attackElement = DMGT_FIRE; } - else if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) + else if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) { player->PlaySound(SPEECH_52, 0); return; @@ -3551,10 +3551,10 @@ uDamageAmount /= 2; if ( pMonster->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 ) uDamageAmount = 0; - v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, attackElement, uDamageAmount); + v61 = pMonster->CalcMagicalDamageToActor(attackElement, uDamageAmount); if ( !projectileSprite && player->IsUnarmed() && player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime > 0 ) { - v61 += stru_50C198.CalcMagicalDamageToActor(pMonster, 8, player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uPower); + v61 += pMonster->CalcMagicalDamageToActor((DAMAGE_TYPE)8, player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uPower); } uDamageAmount = v61; if ( IsAdditionalDamagePossible ) @@ -3568,7 +3568,7 @@ if ( player->sHealth > player->GetMaxHealth() ) player->sHealth = player->GetMaxHealth(); } - uDamageAmount += stru_50C198.CalcMagicalDamageToActor(pMonster, attackElement, a4); + uDamageAmount += pMonster->CalcMagicalDamageToActor(attackElement, a4); } else { @@ -3588,7 +3588,7 @@ if ( player->sHealth > player->GetMaxHealth() ) player->sHealth = player->GetMaxHealth(); } - uDamageAmount += stru_50C198.CalcMagicalDamageToActor(pMonster, attackElement, a4); + uDamageAmount += pMonster->CalcMagicalDamageToActor(attackElement, a4); } } } @@ -4153,6 +4153,99 @@ return rand() % (armorSum + 2 * this->pMonsterInfo.uLevel + 10) + a2a + 1 > armorSum + 5; } +//----- (004274AD) -------------------------------------------------------- +bool Actor::ActorHitOrMiss(Player *pPlayer) +{ + signed int v3; // edi@1 + signed int v4; // esi@8 + int v5; // esi@8 + + v3 = 0; + if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) + v3 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; + if ( this->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime > 0 && this->pActorBuffs[ACTOR_BUFF_BLESS].uPower > v3 ) + v3 = this->pActorBuffs[ACTOR_BUFF_BLESS].uPower; + if ( this->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) + { + v3 += this->pActorBuffs[ACTOR_BUFF_FATE].uPower; + this->pActorBuffs[ACTOR_BUFF_FATE].Reset(); + } + v4 = pPlayer->GetActualAC() + 2 * this->pMonsterInfo.uLevel + 10; + v5 = rand() % v4 + 1; + return (v3 + v5 > pPlayer->GetActualAC() + 5); +} + + +//----- (0042756B) -------------------------------------------------------- +int Actor::CalcMagicalDamageToActor(DAMAGE_TYPE dmgType, signed int incomingDmg) +{ + int v4; // edx@1 + int v5; // ecx@1 + signed int v6; // eax@4 + signed int result; // eax@17 + signed int v8; // esi@18 + + v4 = 0; + v5 = 0; + if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) + v5 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; + switch ( dmgType ) + { + case DMGT_FIRE: + v6 = this->pMonsterInfo.uResFire; + v4 = v5; + break; + case DMGT_ELECTR: + v6 = this->pMonsterInfo.uResAir; + v4 = v5; + break; + case DMGT_COLD: + v6 = this->pMonsterInfo.uResWater; + v4 = v5; + break; + case DMGT_EARTH: + v6 = this->pMonsterInfo.uResEarth; + v4 = v5; + break; + case DMGT_PHISYCAL: + v6 = this->pMonsterInfo.uResPhysical; + break; + case DMGT_SPIRIT: + v6 = this->pMonsterInfo.uResSpirit; + break; + case DMGT_MIND: + v6 = this->pMonsterInfo.uResMind; + v4 = v5; + break; + case DMGT_BODY: + v6 = this->pMonsterInfo.uResBody; + v4 = v5; + break; + case DMGT_LIGHT: + v6 = this->pMonsterInfo.uResLight; + break; + case DMGT_DARK: + v6 = this->pMonsterInfo.uResDark; + break; + default: + v6 = 0; + break; + } + if ( v6 < 200 ) + { + v8 = v4 + v6 + 30; + for (int i = 0; i < 4; i++) + { + if ( rand() % v8 < 30 ) + break; + incomingDmg /= 2; + } + result = incomingDmg; + } + else + result = 0; + return result; +} //----- (00448A98) -------------------------------------------------------- void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle) {
--- a/Actor.h Sun Mar 16 19:34:51 2014 +0600 +++ b/Actor.h Sun Mar 16 19:43:28 2014 +0100 @@ -13,10 +13,7 @@ struct stru319 { int which_player_to_attack(struct Actor *pActor); - int PlayerHitOrMiss(struct Player *pPlayer, struct Actor *pActor, int a3, int a4); - bool ActorHitOrMiss(struct Actor *pActor, struct Player *pPlayer); int _427546(int a2); - int CalcMagicalDamageToActor(struct Actor *pActor, int a2, signed int a3); bool GetMagicalResistance(struct Actor *pActor, unsigned int uType); int FindClosestActor(int a2, int a3, int a4); @@ -238,6 +235,8 @@ bool _427102_IsOkToCastSpell(signed int a2); ABILITY_INDEX special_ability_use_check(int a2); bool _4273BB_DoesHitOtherActor(Actor *defender, int a3, int a4); + bool ActorHitOrMiss(Player *pPlayer); + int CalcMagicalDamageToActor(DAMAGE_TYPE dmgType, signed int incomingDmg); char pActorName[32]; signed __int16 sNPC_ID;
--- a/Player.cpp Sun Mar 16 19:34:51 2014 +0600 +++ b/Player.cpp Sun Mar 16 19:43:28 2014 +0100 @@ -7242,7 +7242,7 @@ playerPtr = &pParty->pPlayers[a4]; actorPtr = &pActors[uActorID]; healthBeforeRecvdDamage = playerPtr->sHealth; - if ( PID_TYPE(uObjID) != 3 || !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) + if ( PID_TYPE(uObjID) != 3 || !actorPtr->ActorHitOrMiss(playerPtr) ) return; ItemGen* equippedArmor = playerPtr->GetArmorItem(); SoundID soundToPlay; @@ -7311,7 +7311,7 @@ int actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) { - int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, dmgToReceive); + int reflectedDamage = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, dmgToReceive); actorPtr->sCurrentHP -= reflectedDamage; if ( reflectedDamage >= 0 ) { @@ -7441,7 +7441,7 @@ || spriteType == 535 || spriteType == 540 ) { - if ( !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) + if ( !actorPtr->ActorHitOrMiss(playerPtr) ) return; if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime > 0 ) dmgToReceive >>= 1; @@ -7503,7 +7503,7 @@ unsigned __int16 actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) { - recvdMagicDmg = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, reflectedDmg); + recvdMagicDmg = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, reflectedDmg); actorPtr->sCurrentHP -= recvdMagicDmg; if ( recvdMagicDmg >= 0 ) { @@ -7913,4 +7913,48 @@ else Error("Unexpected player pointer"); return uPlayerIdx; +} + +//----- (004272F5) -------------------------------------------------------- +bool Player::PlayerHitOrMiss(Actor *pActor, int a3, int a4) +{ + signed int naturalArmor; // esi@1 + signed int armorBuff; // edi@1 + int effectiveActorArmor; // esi@8 + int attBonus; // eax@9 + int v9; // edx@11 + unsigned __int8 v12; // sf@13 + unsigned __int8 v13; // of@13 + int attPositiveMod; // edx@14 + int attNegativeMod; // eax@14 + signed int result; // eax@17 + + naturalArmor = pActor->pMonsterInfo.uAC; + armorBuff = 0; + if ( pActor->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) + naturalArmor /= 2; + if ( pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) + armorBuff = pActor->pActorBuffs[ACTOR_BUFF_SHIELD].uPower; + if ( pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime > 0 && pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower > armorBuff ) + armorBuff = pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower; + effectiveActorArmor = armorBuff + naturalArmor; + if ( a3 ) + attBonus = this->GetRangedAttack(); + else + attBonus = this->GetActualAttack(false); + v9 = rand() % (effectiveActorArmor + 2 * attBonus + 30); + attPositiveMod = a4 + v9; + if ( a3 == 2 ) + { + attNegativeMod = ((effectiveActorArmor + 15) / 2) + effectiveActorArmor + 15; + } + else if ( a3 == 3 ) + { + attNegativeMod = 2 * effectiveActorArmor + 30; + } + else + { + attNegativeMod = effectiveActorArmor + 15; + } + return (attPositiveMod > attNegativeMod); } \ No newline at end of file
--- a/Player.h Sun Mar 16 19:34:51 2014 +0600 +++ b/Player.h Sun Mar 16 19:43:28 2014 +0100 @@ -602,6 +602,8 @@ bool HasItem(unsigned int uItemID, bool checkHeldItem); void OnInventoryLeftClick(); + bool PlayerHitOrMiss(Actor *pActor, int a3, int a4); + unsigned int GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4); int CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice); bool WearsItemAnyWhere(int item_id);
--- a/mm7_5.cpp Sun Mar 16 19:34:51 2014 +0600 +++ b/mm7_5.cpp Sun Mar 16 19:43:28 2014 +0100 @@ -275,7 +275,7 @@ if ( pSpriteObjects[PID_ID(uObjID)].spell_id ) { v6 = _43AFE3_calc_spell_damage(pSpriteObjects[PID_ID(uObjID)].spell_id, pSpriteObjects[PID_ID(uObjID)].spell_level, pSpriteObjects[PID_ID(uObjID)].spell_skill, pActors[uActorID].sCurrentHP); - damage = stru_50C198.CalcMagicalDamageToActor(&pActors[uActorID], 0, v6); + damage = pActors[uActorID].CalcMagicalDamageToActor((DAMAGE_TYPE)0, v6); pActors[uActorID].sCurrentHP -= damage; if ( damage ) { @@ -361,7 +361,7 @@ v12 = pActors[PID_ID(v17)].pMonsterInfo.field_3C_some_special_attack; else v12 = 4; - v14 = stru_50C198.CalcMagicalDamageToActor(&pActors[actor_id], v12, v10); + v14 = pActors[actor_id].CalcMagicalDamageToActor((DAMAGE_TYPE)v12, v10); pActors[actor_id].sCurrentHP -= v14; if ( v14 ) {
--- a/mm7_6.cpp Sun Mar 16 19:34:51 2014 +0600 +++ b/mm7_6.cpp Sun Mar 16 19:43:28 2014 +0100 @@ -39,84 +39,6 @@ -//----- (004272F5) -------------------------------------------------------- -int stru319::PlayerHitOrMiss(Player *pPlayer, Actor *pActor, int a3, int a4) -{ - signed int v5; // esi@1 - signed int v6; // edi@1 - int v7; // esi@8 - int v8; // eax@9 - int v9; // edx@11 - unsigned __int8 v12; // sf@13 - unsigned __int8 v13; // of@13 - int v14; // edx@14 - int v15; // eax@14 - signed int result; // eax@17 - - v5 = pActor->pMonsterInfo.uAC; - v6 = 0; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) - v5 /= 2; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v6 = pActor->pActorBuffs[ACTOR_BUFF_SHIELD].uPower; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime > 0 && pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower > v6 ) - v6 = pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower; - v7 = v6 + v5; - if ( a3 ) - v8 = pPlayer->GetRangedAttack(); - else - v8 = pPlayer->GetActualAttack(false); - v9 = rand() % (v7 + 2 * v8 + 30); - if ( a3 == 2 ) - { - v14 = a4 + v9; - v15 = ((v7 + 15) / 2) + v7 + 15; - v13 = __OFSUB__(v14, v15); - v12 = v14 - v15 < 0; - } - else if ( a3 == 3 ) - { - v14 = a4 + v9; - v15 = 2 * v7 + 30; - v13 = __OFSUB__(v14, v15); - v12 = v14 - v15 < 0; - } - else - { - v14 = a4 + v9; - v15 = v7 + 15; - v13 = __OFSUB__(v14, v15); - v12 = v14 - v15 < 0; - } - - if ( v12 ^ v13 ) - result = 0; - else - result = 1; - return result; -} - -//----- (004274AD) -------------------------------------------------------- -bool stru319::ActorHitOrMiss(Actor *pActor, Player *pPlayer) -{ - signed int v3; // edi@1 - signed int v4; // esi@8 - int v5; // esi@8 - - v3 = 0; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v3 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime > 0 && pActor->pActorBuffs[ACTOR_BUFF_BLESS].uPower > v3 ) - v3 = pActor->pActorBuffs[ACTOR_BUFF_BLESS].uPower; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) - { - v3 += pActor->pActorBuffs[ACTOR_BUFF_FATE].uPower; - pActor->pActorBuffs[ACTOR_BUFF_FATE].Reset(); - } - v4 = pPlayer->GetActualAC() + 2 * pActor->pMonsterInfo.uLevel + 10; - v5 = rand() % v4 + 1; - return v3 + v5 > pPlayer->GetActualAC() + 5; -} //----- (00427546) -------------------------------------------------------- int stru319::_427546(int a2) @@ -137,85 +59,6 @@ return result; } -//----- (0042756B) -------------------------------------------------------- -int stru319::CalcMagicalDamageToActor(Actor *pActor, int a2, signed int a3) -{ - int v4; // edx@1 - int v5; // ecx@1 - signed int v6; // eax@4 - signed int result; // eax@17 - signed int v8; // esi@18 - - v4 = 0; - v5 = 0; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v5 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - switch ( a2 ) - { - case 0: - v6 = pActor->pMonsterInfo.uResFire; - v4 = v5; - break; - case 1: - v6 = pActor->pMonsterInfo.uResAir; - v4 = v5; - break; - case 2: - v6 = pActor->pMonsterInfo.uResWater; - v4 = v5; - break; - case 3: - v6 = pActor->pMonsterInfo.uResEarth; - v4 = v5; - break; - case 4: - v6 = pActor->pMonsterInfo.uResPhysical; - break; - case 6: - v6 = pActor->pMonsterInfo.uResSpirit; - break; - case 7: - v6 = pActor->pMonsterInfo.uResMind; - v4 = v5; - break; - case 8: - v6 = pActor->pMonsterInfo.uResBody; - v4 = v5; - break; - case 9: - v6 = pActor->pMonsterInfo.uResLight; - break; - case 10: - v6 = pActor->pMonsterInfo.uResDark; - break; - default: - v6 = 0; - break; - } - if ( v6 < 200 ) - { - v8 = v4 + v6 + 30; - if ( rand() % v8 >= 30 ) - { - a3 >>= 1; - if ( rand() % v8 >= 30 ) - { - a3 >>= 1; - if ( rand() % v8 >= 30 ) - { - a3 >>= 1; - if ( rand() % v8 >= 30 ) - a3 >>= 1; - } - } - } - result = a3; - } - else - result = 0; - return result; -} - //----- (00427662) -------------------------------------------------------- bool stru319::GetMagicalResistance(Actor *pActor, unsigned int uType) {