Mercurial > mm7
changeset 2292:ab8797ea43b6
stru319::CalcMagicalDamageToActor small cleanups
author | Grumpy7 |
---|---|
date | Sun, 16 Mar 2014 19:37:28 +0100 |
parents | 69661f22ff03 |
children | b0f10ef66e00 |
files | Actor.cpp Actor.h Player.cpp mm7_5.cpp mm7_6.cpp |
diffstat | 5 files changed, 26 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sun Mar 16 19:11:52 2014 +0100 +++ b/Actor.cpp Sun Mar 16 19:37: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 = stru_50C198.CalcMagicalDamageToActor(pActor, (DAMAGE_TYPE)5, v4); + pActor->sCurrentHP -= stru_50C198.CalcMagicalDamageToActor(pActor, (DAMAGE_TYPE)5, v4); if ( sDmg ) { if ( pActor->sCurrentHP >= 0 ) @@ -3554,7 +3554,7 @@ v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, 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 += stru_50C198.CalcMagicalDamageToActor(pMonster, (DAMAGE_TYPE)8, player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uPower); } uDamageAmount = v61; if ( IsAdditionalDamagePossible )
--- a/Actor.h Sun Mar 16 19:11:52 2014 +0100 +++ b/Actor.h Sun Mar 16 19:37:28 2014 +0100 @@ -14,7 +14,7 @@ { int which_player_to_attack(struct Actor *pActor); int _427546(int a2); - int CalcMagicalDamageToActor(struct Actor *pActor, int a2, signed int a3); + 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);
--- a/Player.cpp Sun Mar 16 19:11:52 2014 +0100 +++ b/Player.cpp Sun Mar 16 19:37:28 2014 +0100 @@ -7311,7 +7311,7 @@ int actorState = actorPtr->uAIState; if ( actorState != Dying && actorState != Dead) { - int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, dmgToReceive); + int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, (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, damageType, reflectedDmg); + recvdMagicDmg = stru_50C198.CalcMagicalDamageToActor(actorPtr, (DAMAGE_TYPE)damageType, reflectedDmg); actorPtr->sCurrentHP -= recvdMagicDmg; if ( recvdMagicDmg >= 0 ) {
--- a/mm7_5.cpp Sun Mar 16 19:11:52 2014 +0100 +++ b/mm7_5.cpp Sun Mar 16 19:37: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 = stru_50C198.CalcMagicalDamageToActor(&pActors[uActorID], (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 = stru_50C198.CalcMagicalDamageToActor(&pActors[actor_id], (DAMAGE_TYPE)v12, v10); pActors[actor_id].sCurrentHP -= v14; if ( v14 ) {
--- a/mm7_6.cpp Sun Mar 16 19:11:52 2014 +0100 +++ b/mm7_6.cpp Sun Mar 16 19:37:28 2014 +0100 @@ -60,7 +60,7 @@ } //----- (0042756B) -------------------------------------------------------- -int stru319::CalcMagicalDamageToActor(Actor *pActor, int a2, signed int a3) +int stru319::CalcMagicalDamageToActor(Actor *pActor, DAMAGE_TYPE dmgType, signed int incomingDmg) { int v4; // edx@1 int v5; // ecx@1 @@ -70,44 +70,44 @@ v4 = 0; v5 = 0; - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) + if ( pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) v5 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - switch ( a2 ) + switch ( dmgType ) { - case 0: + case DMGT_FIRE: v6 = pActor->pMonsterInfo.uResFire; v4 = v5; break; - case 1: + case DMGT_ELECTR: v6 = pActor->pMonsterInfo.uResAir; v4 = v5; break; - case 2: + case DMGT_COLD: v6 = pActor->pMonsterInfo.uResWater; v4 = v5; break; - case 3: + case DMGT_EARTH: v6 = pActor->pMonsterInfo.uResEarth; v4 = v5; break; - case 4: + case DMGT_PHISYCAL: v6 = pActor->pMonsterInfo.uResPhysical; break; - case 6: + case DMGT_SPIRIT: v6 = pActor->pMonsterInfo.uResSpirit; break; - case 7: + case DMGT_MIND: v6 = pActor->pMonsterInfo.uResMind; v4 = v5; break; - case 8: + case DMGT_BODY: v6 = pActor->pMonsterInfo.uResBody; v4 = v5; break; - case 9: + case DMGT_LIGHT: v6 = pActor->pMonsterInfo.uResLight; break; - case 10: + case DMGT_DARK: v6 = pActor->pMonsterInfo.uResDark; break; default: @@ -117,21 +117,13 @@ if ( v6 < 200 ) { v8 = v4 + v6 + 30; - if ( rand() % v8 >= 30 ) + for (int i = 0; i < 4; i++) { - a3 >>= 1; - if ( rand() % v8 >= 30 ) - { - a3 >>= 1; - if ( rand() % v8 >= 30 ) - { - a3 >>= 1; - if ( rand() % v8 >= 30 ) - a3 >>= 1; - } - } + if ( rand() % v8 < 30 ) + break; + incomingDmg /= 2; } - result = a3; + result = incomingDmg; } else result = 0;