diff Actor.cpp @ 2291:69661f22ff03

stru319::PlayerHitOrMiss moved to Player class, cleaned up a bit, stru319::ActorHitOrMiss moved to Actor class, cleaned up a bit
author Grumpy7
date Sun, 16 Mar 2014 19:11:52 +0100
parents d8b4a36f54a4
children ab8797ea43b6
line wrap: on
line diff
--- a/Actor.cpp	Sun Mar 16 03:08:26 2014 +0100
+++ b/Actor.cpp	Sun Mar 16 19:11:52 2014 +0100
@@ -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;
@@ -4153,6 +4153,28 @@
   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);
+}
+
 //----- (00448A98) --------------------------------------------------------
 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle)
 {