# HG changeset patch # User Grumpy7 # Date 1394995349 -3600 # Node ID b0f10ef66e00c16a145d868381e0a32c417ddf88 # Parent ab8797ea43b6d9d97c04affa16a304bd7b69781b stru319::CalcMagicalDamageToActor moved to Actor class diff -r ab8797ea43b6 -r b0f10ef66e00 Actor.cpp --- a/Actor.cpp Sun Mar 16 19:37:28 2014 +0100 +++ b/Actor.cpp Sun Mar 16 19:42:29 2014 +0100 @@ -2807,8 +2807,8 @@ pActor=&pActors[i]; if ( pActor->CanAct() ) { - sDmg = stru_50C198.CalcMagicalDamageToActor(pActor, (DAMAGE_TYPE)5, v4); - pActor->sCurrentHP -= stru_50C198.CalcMagicalDamageToActor(pActor, (DAMAGE_TYPE)5, v4); + sDmg = pActor->CalcMagicalDamageToActor((DAMAGE_TYPE)5, v4); + pActor->sCurrentHP -= sDmg; if ( sDmg ) { if ( pActor->sCurrentHP >= 0 ) @@ -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, (DAMAGE_TYPE)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); } } } @@ -4175,6 +4175,77 @@ 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) { diff -r ab8797ea43b6 -r b0f10ef66e00 Actor.h --- a/Actor.h Sun Mar 16 19:37:28 2014 +0100 +++ b/Actor.h Sun Mar 16 19:42:29 2014 +0100 @@ -14,7 +14,6 @@ { int which_player_to_attack(struct Actor *pActor); int _427546(int a2); - int CalcMagicalDamageToActor(Actor *pActor, DAMAGE_TYPE dmgType, signed int incomingDmg); bool GetMagicalResistance(struct Actor *pActor, unsigned int uType); int FindClosestActor(int a2, int a3, int a4); @@ -237,6 +236,7 @@ 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; diff -r ab8797ea43b6 -r b0f10ef66e00 Player.cpp --- a/Player.cpp Sun Mar 16 19:37:28 2014 +0100 +++ b/Player.cpp Sun Mar 16 19:42:29 2014 +0100 @@ -7311,7 +7311,7 @@ int actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) { - int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, (DAMAGE_TYPE)damageType, dmgToReceive); + int reflectedDamage = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, dmgToReceive); actorPtr->sCurrentHP -= reflectedDamage; if ( reflectedDamage >= 0 ) { @@ -7503,7 +7503,7 @@ unsigned __int16 actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) { - recvdMagicDmg = stru_50C198.CalcMagicalDamageToActor(actorPtr, (DAMAGE_TYPE)damageType, reflectedDmg); + recvdMagicDmg = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, reflectedDmg); actorPtr->sCurrentHP -= recvdMagicDmg; if ( recvdMagicDmg >= 0 ) { diff -r ab8797ea43b6 -r b0f10ef66e00 mm7_5.cpp --- a/mm7_5.cpp Sun Mar 16 19:37:28 2014 +0100 +++ b/mm7_5.cpp Sun Mar 16 19:42:29 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], (DAMAGE_TYPE)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], (DAMAGE_TYPE)v12, v10); + v14 = pActors[actor_id].CalcMagicalDamageToActor((DAMAGE_TYPE)v12, v10); pActors[actor_id].sCurrentHP -= v14; if ( v14 ) { diff -r ab8797ea43b6 -r b0f10ef66e00 mm7_6.cpp --- a/mm7_6.cpp Sun Mar 16 19:37:28 2014 +0100 +++ b/mm7_6.cpp Sun Mar 16 19:42:29 2014 +0100 @@ -59,77 +59,6 @@ return result; } -//----- (0042756B) -------------------------------------------------------- -int stru319::CalcMagicalDamageToActor(Actor *pActor, 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 ( pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v5 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - switch ( dmgType ) - { - case DMGT_FIRE: - v6 = pActor->pMonsterInfo.uResFire; - v4 = v5; - break; - case DMGT_ELECTR: - v6 = pActor->pMonsterInfo.uResAir; - v4 = v5; - break; - case DMGT_COLD: - v6 = pActor->pMonsterInfo.uResWater; - v4 = v5; - break; - case DMGT_EARTH: - v6 = pActor->pMonsterInfo.uResEarth; - v4 = v5; - break; - case DMGT_PHISYCAL: - v6 = pActor->pMonsterInfo.uResPhysical; - break; - case DMGT_SPIRIT: - v6 = pActor->pMonsterInfo.uResSpirit; - break; - case DMGT_MIND: - v6 = pActor->pMonsterInfo.uResMind; - v4 = v5; - break; - case DMGT_BODY: - v6 = pActor->pMonsterInfo.uResBody; - v4 = v5; - break; - case DMGT_LIGHT: - v6 = pActor->pMonsterInfo.uResLight; - break; - case DMGT_DARK: - v6 = pActor->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; -} - //----- (00427662) -------------------------------------------------------- bool stru319::GetMagicalResistance(Actor *pActor, unsigned int uType) {