diff Player.cpp @ 1567:9f8b3e904e14

Player::ReceiveDamage, very small edits; prepended "Is" to item functions returning bool values (broken, indetified, stolen)
author Grumpy7
date Sun, 08 Sep 2013 05:22:33 +0200
parents 58420268d87d
children addae48bc203
line wrap: on
line diff
--- a/Player.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/Player.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -242,7 +242,7 @@
   item_value =pOwnItems[item_index].GetValue();
   v6 = p2DEvents[ _2devent_idx - 1].fPriceMultiplier;
   sell_price = GetPriceSell(item_value, v6);
-  if ( pOwnItems[item_index].Broken() )
+  if ( pOwnItems[item_index].IsBroken() )
     sell_price = 1;
   if ( sell_price < 1 )
     sell_price = 1;
@@ -1073,7 +1073,7 @@
       Error("(%u)", building_type);
     break;
   }
-  if (pItem->Stolen())
+  if (pItem->IsStolen())
     return 6;
 
   multiplier = p2DEvents[BuildID_2Events - 1].fPriceMultiplier;
@@ -1083,7 +1083,7 @@
       price = GetBuyingPrice(itemValue, multiplier);
     break;
     case 3:
-      if (pItem->Broken())
+      if (pItem->IsBroken())
         price = 1;
       else
         price = this->GetPriceSell(itemValue, multiplier);
@@ -1935,7 +1935,7 @@
   }
   if (( dmg_type == DMGT_PHISYCAL ) && ( pEquipment.uArmor ))
   {
-      if (!pOwnItems[pEquipment.uArmor - 1].Broken()) 
+      if (!pOwnItems[pEquipment.uArmor - 1].IsBroken()) 
       {
         armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR);
         if ( armor_skill==PLAYER_SKILL_PLATE )
@@ -2013,17 +2013,17 @@
 }
 
 //----- (0048D76C) --------------------------------------------------------
-bool Player::StealFromShop(ItemGen *a2, int a3, int reputation, int a5, int *a6)
+bool Player::StealFromShop(ItemGen *itemToSteal, int a3, int reputation, int a5, int *a6)   //check stealing in IDA pro once I get home. The whole thing looks odd, dword_4EDEB4 and dword_4EDEA0 are never filled, might be a bug, might me on purpose
 {
   unsigned __int16 v6; // cx@8
   int v7; // edi@8
   unsigned int v8; // ebx@8
-  unsigned int v9; // esi@8
+  unsigned int itemvalue; // esi@8
   int v10; // eax@8
   int v11; // edi@12
   bool result; // eax@13
 
-  if ( !a2
+  if ( !itemToSteal
     || this->pConditions[16]
     || this->pConditions[14]
     || this->pConditions[15]
@@ -2038,12 +2038,12 @@
     v6 = this->pActiveSkills[34];
     v7 = v6 & 0x3F;
     v8 = SkillToMastery(v6);
-    v9 = a2->GetValue();
-    v10 = pItemsTable->pItems[a2->uItemID].uEquipType;
-    if ( !pItemsTable->pItems[a2->uItemID].uEquipType || v10 == 1 || v10 == 2 )
-      v9 *= 3;
+    itemvalue = itemToSteal->GetValue();
+    v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType;
+    if ( !pItemsTable->pItems[itemToSteal->uItemID].uEquipType || v10 == 1 || v10 == 2 )
+      itemvalue *= 3;
     v11 = dword_4EDEB4[rand() % 100 / 20] + v7 * dword_4EDEA0[v8];
-    *a6 = 100 * (reputation + a3) + v9 + (a5 != 0 ? 0x1F4 : 0);
+    *a6 = 100 * (reputation + a3) + itemvalue + (a5 != 0 ? 0x1F4 : 0);
     if ( rand() % 100 >= 5 )
     {
       if ( *a6 > v11 )
@@ -2230,19 +2230,19 @@
 {
   signed int max_health; // eax@3
 
-  if ( !pConditions[Condition_Eradicated] && !pConditions[Condition_Dead] )
+  if ( !IsEradicated() && !IsDead() )
   {
     max_health = GetMaxHealth();
-    if ( pConditions[Condition_Zombie] )
+    if ( IsZombie() )
       max_health /= 2;
     sHealth += amount;
     if ( sHealth > max_health )
         sHealth = max_health;
-    if ( pConditions[Condition_Unconcious] )
+    if ( IsUnconcious() )
     {
       if ( sHealth > 0 )
       {
-        pConditions[Condition_Unconcious] = 0i64;
+        SetUnconcious(false);
       }
     }
   }
@@ -2255,21 +2255,20 @@
   unsigned int armor_indx; // eax@8
   bool broke_armor;
  
-  pConditions[Condition_Sleep] = 0i64;
+  SetAsleep(false);
   recieved_dmg = CalculateIncommingDamage(dmg_type, amount);
   sHealth -= recieved_dmg;
   broke_armor = sHealth <= -10;
   if ( sHealth < 1 ) //
   {
     if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1)
-      || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0i64 )
-    {
-      SetCondition(Condition_Unconcious, 0);
+      || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 )
+    {
+      SetCondUnconsciousWithBlockCheck(false);
     }
     else
     {
-      SetCondition(Condition_Dead, 0);
-      //v6 = LODWORD(pParty->uTimePlayed); ???? if equals 0 do not broke armor?
+      SetCondDeadWithBlockCheck(false);
       if ( sHealth > 0 )
         sHealth = 0;
     }
@@ -2280,7 +2279,7 @@
       {
         if ( !pOwnItems[armor_indx-1].uAttributes & ITEM_ENCHANTED)
         {
-          pOwnItems[armor_indx-1].uAttributes|=ITEM_BROKEN;
+          pOwnItems[armor_indx-1].SetBroken();
         }
       }
     }
@@ -2387,7 +2386,7 @@
       v13 = this->pInventoryItemList;
       do
       {
-        if ( (signed int)v13->uItemID > 0 && (signed int)v13->uItemID <= 134 && !v13->Broken())
+        if ( (signed int)v13->uItemID > 0 && (signed int)v13->uItemID <= 134 && !v13->IsBroken())
           v46[v4++] = v12;
         ++v12;
         ++v13;
@@ -4390,7 +4389,7 @@
 
       for (int j = 0; j < 16; ++j) 
       {
-        if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken()))
+        if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].IsBroken()))
         {
           int curr_item = pOwnItems[pEquipment.pIndices[j] - 1].uItemID;
           PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType;
@@ -8988,3 +8987,8 @@
 {
   SetCondition(Condition_Dead, blockable);
 }
+
+void Player::SetCondUnconsciousWithBlockCheck( int blockable )
+{
+  SetCondition(Condition_Dead, blockable);
+}
\ No newline at end of file