changeset 1362:d6cf8ead9242

Condition checking functions slightly renamed, some final changes in Player::SetCondition
author Grumpy7
date Mon, 15 Jul 2013 00:42:50 +0200
parents b3ac17fd12de
children fd661c9e7f97
files Actor.cpp CastSpellInfo.cpp Player.cpp Player.h Spells.cpp UI/UIRest.cpp UI/UiGame.cpp mm7_4.cpp
diffstat 8 files changed, 52 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sun Jul 14 23:22:43 2013 +0200
+++ b/Actor.cpp	Mon Jul 15 00:42:50 2013 +0200
@@ -5225,7 +5225,7 @@
   if ( !v57 )
     goto LABEL_67;
 LABEL_69:
-  if (player->Weak())
+  if (player->IsWeak())
     uDamageAmount /= 1;
   if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 )
     uDamageAmount = 0;
--- a/CastSpellInfo.cpp	Sun Jul 14 23:22:43 2013 +0200
+++ b/CastSpellInfo.cpp	Mon Jul 15 00:42:50 2013 +0200
@@ -414,7 +414,7 @@
       continue;
     }
     v730 = pCastSpell->spellnum;
-    if (pPlayer->Cursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50)
+    if (pPlayer->IsCursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50)
     {
       if (!pParty->bTurnBasedModeOn)
       {
--- a/Player.cpp	Sun Jul 14 23:22:43 2013 +0200
+++ b/Player.cpp	Mon Jul 15 00:42:50 2013 +0200
@@ -663,9 +663,9 @@
 //----- (00492C0B) --------------------------------------------------------
 bool Player::CanAct()
 {
-  if ( this->pConditions[Condition_Sleep] || this->pConditions[Condition_Paralyzed] || 
-       this->pConditions[Condition_Unconcious] || this->pConditions[Condition_Dead] || 
-       this->pConditions[Condition_Pertified] || this->pConditions[Condition_Eradicated] )
+  if ( this->IsAsleep() || this->IsParalyzed() || 
+       this->IsUnconcious() || this->IsDead() || 
+       this->IsPertified() || this->IsEradicated() )
     return false;
   else
     return true;
@@ -708,14 +708,6 @@
 
   if ( pConditions[uConditionIdx] )
       return;
-
-  players_before = 0;
-
-  for (int i = 1; i < 5; ++i)
-  {
-      if ( pPlayers[i]->CanAct() )
-          ++players_before;
-  }
   
   if (!ConditionProcessor::IsPlayerAffected(this, uConditionIdx, a3))
   {
@@ -750,7 +742,7 @@
         sMana = 0;
     break;
     case Condition_Pertified:
-      PlaySound((PlayerSpeech)34, 0);
+      PlaySound(SPEECH_34, 0);
     break;
     case Condition_Eradicated:
       PlaySound(SPEECH_35, 0);
@@ -760,7 +752,7 @@
         sMana = 0;
     break;
     case Condition_Zombie:
-      if ( classType == PLAYER_CLASS_LICH || Eradicated() || Zombie() || !Dead())
+      if ( classType == PLAYER_CLASS_LICH || IsEradicated() || IsZombie() || !IsDead())
         return;
       memset(&pConditions[0], 0, sizeof(pConditions));
       sHealth = GetMaxHealth();
@@ -782,8 +774,16 @@
     break;
   }
 
+  players_before = 0;
+  for (int i = 1; i < 5; ++i)
+  {
+    if ( pPlayers[i]->CanAct() )
+      ++players_before;
+  }
+
+  pConditions[uConditionIdx] = 1;
+
   remainig_player = 0;
-  pConditions[uConditionIdx] = 1;
   players_after = 0;
   for (int i = 1; i < 5; ++i)
   {
@@ -9780,41 +9780,51 @@
 }
 
 
-bool Player::Weak()
+bool Player::IsWeak()
 {
   return pConditions[Condition_Weak] != 0;
 }
 
-bool Player::Dead()
+bool Player::IsDead()
 {
   return pConditions[Condition_Dead] != 0;
 }
 
-bool Player::Eradicated()
+bool Player::IsEradicated()
 {
   return pConditions[Condition_Eradicated] != 0;
 }
 
-bool Player::Zombie()
+bool Player::IsZombie()
 {
   return pConditions[Condition_Zombie] != 0;
 }
 
-bool Player::Cursed()
+bool Player::IsCursed()
 {
   return pConditions[Condition_Cursed] != 0;
 }
 
-bool Player::Pertified()
+bool Player::IsPertified()
 {
   return pConditions[Condition_Pertified] != 0;
 }
 
-bool Player::Unconcious()
+bool Player::IsUnconcious()
 {
   return pConditions[Condition_Unconcious] != 0;
 }
 
+bool Player::IsAsleep()
+{
+  return pConditions[Condition_Sleep] != 0;
+}
+
+bool Player::IsParalyzed()
+{
+  return pConditions[Condition_Paralyzed] != 0;
+}
+
 void Player::SetCursed( bool state )
 {
   pConditions[Condition_Cursed] = state;
@@ -9918,4 +9928,4 @@
 void Player::SetCondDeadWithBlockCheck( int blockable )
 {
   SetCondition(Condition_Dead, blockable);
-}
\ No newline at end of file
+}
--- a/Player.h	Sun Jul 14 23:22:43 2013 +0200
+++ b/Player.h	Mon Jul 15 00:42:50 2013 +0200
@@ -574,13 +574,15 @@
   void DrawPlayerBuffAnimBasedOnCondition(int currPlayerId);
   void EquipBody(ITEM_EQUIP_TYPE uEquipType);
 
-  bool Weak();
-  bool Dead();
-  bool Eradicated();
-  bool Zombie();
-  bool Cursed();
-  bool Pertified();
-  bool Unconcious();
+  bool IsWeak();
+  bool IsDead();
+  bool IsEradicated();
+  bool IsZombie();
+  bool IsCursed();
+  bool IsPertified();
+  bool IsUnconcious();
+  bool IsAsleep();
+  bool IsParalyzed();
 
   void SetCursed(bool state);
   void SetWeak(bool state);
@@ -612,7 +614,6 @@
 
   inline bool IsMale() { return GetSexByVoice() == SEX_MALE;}
   inline bool IsFemale() { return !IsMale();}
-
   __int64 pConditions[20];
   unsigned __int64 uExperience;
   char pName[16];
--- a/Spells.cpp	Sun Jul 14 23:22:43 2013 +0200
+++ b/Spells.cpp	Mon Jul 15 00:42:50 2013 +0200
@@ -974,7 +974,7 @@
         //v32 = pParty->pPlayers;//[0].pConditions[1];
         //do
         for (uint i = 0; i < 4; ++i)
-          if (pParty->pPlayers[i].Weak())
+          if (pParty->pPlayers[i].IsWeak())
             return;
 		//while ( v32 <= &pParty->pPlayers[3] );
         //if ( !levela )
--- a/UI/UIRest.cpp	Sun Jul 14 23:22:43 2013 +0200
+++ b/UI/UIRest.cpp	Mon Jul 15 00:42:50 2013 +0200
@@ -105,7 +105,7 @@
     text_color =   TargetColor(10, 0, 0);
     shadow_color = TargetColor(230, 214, 193);
     for(int i=1; i<5; ++i)
-        if ( !pPlayers[i]->Dead() && !pPlayers[i]->Eradicated() && pPlayers[i]->sHealth > 0 )
+        if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 )
             ++live_characters;
 
     if ( live_characters )
--- a/UI/UiGame.cpp	Sun Jul 14 23:22:43 2013 +0200
+++ b/UI/UiGame.cpp	Mon Jul 15 00:42:50 2013 +0200
@@ -968,9 +968,9 @@
   window->uFrameW = v9 + window->uFrameY - 1;
   window->DrawMessageBox(0);
 
-  if (player->Eradicated())
+  if (player->IsEradicated())
     v13 = pTexture_PlayerFaceEradicated;
-  else if (player->Dead())
+  else if (player->IsDead())
     v13 = pTexture_PlayerFaceDead;
   else
   {
@@ -2210,9 +2210,9 @@
 
     for (uint i = 0; i < 4; ++i)
         {
-        auto pPlayer = pParty->pPlayers + i;
+        Player* pPlayer = pParty->pPlayers + i;
 
-        if (pPlayer->Eradicated())
+        if (pPlayer->IsEradicated())
             {
             pFace = pTexture_PlayerFaceEradicated;
             pPortrait = pFace;
@@ -2232,7 +2232,7 @@
                 sub_441A4E(i);
             continue;
             }
-        if (pPlayer->Dead())
+        if (pPlayer->IsDead())
             {
             pFace = pTexture_PlayerFaceDead;
             pPortrait = pFace;
--- a/mm7_4.cpp	Sun Jul 14 23:22:43 2013 +0200
+++ b/mm7_4.cpp	Mon Jul 15 00:42:50 2013 +0200
@@ -1617,11 +1617,11 @@
       if (pParty->days_played_without_rest > 3)
         for (uint i = 0; i < 4; ++i)
         {
-          auto player = pParty->pPlayers + i;
+          Player* player = pParty->pPlayers + i;
 
           player->Zero();
 
-          if (!player->Pertified() && !player->Eradicated() && !player->Dead())
+          if (!player->IsPertified() && !player->IsEradicated() && !player->IsDead())
           {
             if (rand() % 100 < 5 * pParty->days_played_without_rest)
               player->SetCondDeadWithBlockCheck(0);