changeset 1966:7840fe323f67

stru319::LootActor(struct Actor *pActor) to Actor::LootActor
author Grumpy7
date Fri, 25 Oct 2013 13:03:08 -0700
parents 182d49f28170
children 05787232b571
files Actor.cpp Actor.h CastSpellInfo.cpp Game.cpp Indoor.cpp Items.h Viewport.cpp mm7_6.cpp
diffstat 8 files changed, 175 insertions(+), 169 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Oct 25 11:23:34 2013 -0700
+++ b/Actor.cpp	Fri Oct 25 13:03:08 2013 -0700
@@ -33,6 +33,7 @@
 #include "Log.h"
 #include "Texts.h"
 #include "Level/Decoration.h"
+#include "Viewport.h"
 
 
 
@@ -2956,7 +2957,7 @@
 				{
 					pPlayer = pPlayers[i];
 					if ( !pPlayer->pConditions[Condition_Dead] && !pPlayer->pConditions[Condition_Pertified] && !pPlayer->pConditions[Condition_Eradicated] )
-						pPlayer->ReceiveDamage(v4, DMGT_5);
+						pPlayer->ReceiveDamage(v4, DMGT_MAGICAL);
 				}
 			}
 			if (pTurnEngine->pending_actions)
@@ -4116,3 +4117,166 @@
   }
   return false;
 }
+
+
+//----- (00426A5A) --------------------------------------------------------
+void Actor::LootActor()
+{
+  signed int v2; // edi@1
+  char v3; // zf@1
+  unsigned int v4; // eax@13
+  unsigned int v5; // esi@13
+  int v6; // eax@14
+  unsigned __int8 v7; // al@30
+  Party *v8; // esi@34
+  char *v9; // [sp-4h] [bp-3Ch]@10
+  char *v10; // [sp-4h] [bp-3Ch]@31
+  char *v11; // [sp-4h] [bp-3Ch]@38
+  ItemGen Dst; // [sp+Ch] [bp-2Ch]@1
+  int v13; // [sp+30h] [bp-8h]@1
+  int v14; // [sp+34h] [bp-4h]@1
+
+  pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
+  Dst.Reset();
+  v2 = 0;
+  v3 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & this->uAttributes) == 0;
+  v13 = 0;
+  v14 = 0;
+  if ( v3 )
+  {
+    if ( this->pMonsterInfo.uTreasureDiceRolls )
+    {
+      do
+      {
+        ++v2;
+        v14 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1;
+      }
+      while ( v2 < this->pMonsterInfo.uTreasureDiceRolls );
+      if ( v14 )
+      {
+        pParty->PartyFindsGold(v14, 0);
+        viewparams->bRedrawGameUI = 1;
+      }
+    }
+  }
+  else
+  {
+    if ( this->array_000234[3].uItemID != 0 &&  this->array_000234[3].GetItemEquipType() == 18 )
+    {
+      v14 = this->array_000234[3].uSpecEnchantmentType;
+      this->array_000234[3].Reset();
+      if ( v14 )
+      {
+        pParty->PartyFindsGold(v14, 0);
+        viewparams->bRedrawGameUI = 1;
+      }
+    }
+  }
+  if ( this->uCarriedItemID )
+  {
+    Dst.Reset();
+    Dst.uItemID = this->uCarriedItemID;
+    v9 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
+    if ( v14 )
+      sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v9);
+    else
+      sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v9);
+    ShowStatusBarString(pTmpBuf2.data(), 2u);
+    v4 = Dst.uItemID;
+    v5 = Dst.uItemID;
+    if ( Dst.GetItemEquipType() == 12 )
+    {
+      v5 = Dst.uItemID;
+      v6 = rand() % 6 + Dst.GetDamageMod() + 1;
+      Dst.uNumCharges = v6;
+      Dst.uMaxCharges = v6;
+      v4 = Dst.uItemID;
+    }
+    if ( pItemsTable->pItems[v5].uEquipType == 14 && v4 != 220 )
+      Dst.uEnchantmentType = 2 * rand() % 4 + 2;
+    pItemsTable->SetSpecialBonus(&Dst);
+    if ( !pParty->AddItemToParty(&Dst) )
+      pParty->SetHoldingItem(&Dst);
+    this->uCarriedItemID = 0;
+    if ( this->array_000234[0].uItemID )
+    {
+      if ( !pParty->AddItemToParty(this->array_000234) )
+      {
+        pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
+        pParty->SetHoldingItem(this->array_000234);
+      }
+      this->array_000234[0].Reset();
+    }
+    if ( this->array_000234[1].uItemID )
+    {
+      if ( !pParty->AddItemToParty(&this->array_000234[1]) )
+      {
+        pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
+        pParty->SetHoldingItem(&this->array_000234[1]);
+      }
+      this->array_000234[1].Reset();
+    }
+    this->Remove();
+    return;
+  }
+  if ( (unsigned int)&array_77EC08[1975].pEdgeList1[1] & this->uAttributes )
+  {
+    if ( this->array_000234[3].uItemID )
+    {
+      memcpy(&Dst, &this->array_000234[3], sizeof(Dst));
+      this->array_000234[3].Reset();
+      v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
+      if ( v14 )
+        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v11);
+      else
+        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v11);
+      ShowStatusBarString(pTmpBuf2.data(), 2u);
+      if ( !pParty->AddItemToParty(&Dst) )
+        pParty->SetHoldingItem(&Dst);
+      v13 = 1;
+    }
+    v8 = pParty;
+    goto LABEL_45;
+  }
+  if ( rand() % 100 >= this->pMonsterInfo.uTreasureDropChance || (v7 = this->pMonsterInfo.uTreasureLevel) == 0 )
+  {
+    v8 = pParty;
+    goto LABEL_45;
+  }
+  pItemsTable->GenerateItem(v7, this->pMonsterInfo.uTreasureType, &Dst);
+  v10 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
+  if ( v14 )
+    sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v10);//Вы нашли ^I[%d] золот^L[ой;ых;ых] и предмет (%s)!
+  else
+    sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v10);//Вы нашли ^Pv[%s]!
+  ShowStatusBarString(pTmpBuf2.data(), 2);
+  v8 = pParty;
+  if ( !pParty->AddItemToParty(&Dst) )
+    pParty->SetHoldingItem(&Dst);
+  v13 = 1;
+LABEL_45:
+  if ( this->array_000234[0].uItemID )
+  {
+    if ( !v8->AddItemToParty(this->array_000234) )
+    {
+      pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
+      v8->SetHoldingItem(this->array_000234);
+      v13 = 1;
+    }
+    this->array_000234[0].Reset();
+  }
+  if ( this->array_000234[1].uItemID )
+  {
+    if ( !v8->AddItemToParty(&this->array_000234[1]) )
+    {
+      pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
+      v8->SetHoldingItem(&this->array_000234[1]);
+      v13 = 1;
+    }
+    this->array_000234[1].Reset();
+  }
+  if ( !v13 || rand() % 100 < 90 )
+  {
+    this->Remove();
+  }
+}
\ No newline at end of file
--- a/Actor.h	Fri Oct 25 11:23:34 2013 -0700
+++ b/Actor.h	Fri Oct 25 13:03:08 2013 -0700
@@ -12,7 +12,6 @@
 #pragma pack(push, 1)
 struct stru319
 {
-  void LootActor(struct Actor *pActor);
   int which_player_to_attack(struct Actor *pActor);
   int  special_ability_use_check(struct Actor *pActor, int a2);
   int _427102(struct Actor *pActor, signed int a2);
@@ -248,6 +247,9 @@
   static bool _46DF1A_collide_against_actor(int a1, int a2);
   static void _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb
 
+
+  void LootActor();
+
   char pActorName[32];
   signed __int16 sNPC_ID;
   __int16 field_22;
--- a/CastSpellInfo.cpp	Fri Oct 25 11:23:34 2013 -0700
+++ b/CastSpellInfo.cpp	Fri Oct 25 13:03:08 2013 -0700
@@ -2967,7 +2967,7 @@
 			{
 				if (PID_TYPE(a2) == OBJECT_Actor)
 				{
-					stru_50C198.LootActor(&pActors[v445]);
+					pActors[v445].LootActor();
 				}
 				else
 				{
--- a/Game.cpp	Fri Oct 25 11:23:34 2013 -0700
+++ b/Game.cpp	Fri Oct 25 13:03:08 2013 -0700
@@ -3542,7 +3542,7 @@
           if ( pParty->bTurnBasedModeOn != 1 )
           {
             if ( pActors[uMessageParam].uAIState == 5 )
-              stru_50C198.LootActor(&pActors[uMessageParam]);
+              pActors[uMessageParam].LootActor();
             else
               Actor::StealFrom(uMessageParam);
             continue;
@@ -3552,7 +3552,7 @@
           if ( !(pTurnEngine->field_18 & TE_HAVE_PENDING_ACTIONS) )
           {
             if ( pActors[uMessageParam].uAIState == 5 )
-              stru_50C198.LootActor(&pActors[uMessageParam]);
+              pActors[uMessageParam].LootActor();
             else
               Actor::StealFrom(uMessageParam);
           }
--- a/Indoor.cpp	Fri Oct 25 11:23:34 2013 -0700
+++ b/Indoor.cpp	Fri Oct 25 13:03:08 2013 -0700
@@ -6090,7 +6090,7 @@
         return 1;
       if ( v14 == 5 )
       {
-        stru_50C198.LootActor(&pActors[PID_ID(a1)]);
+        pActors[PID_ID(a1)].LootActor();
       }
       else
       {
--- a/Items.h	Fri Oct 25 11:23:34 2013 -0700
+++ b/Items.h	Fri Oct 25 13:03:08 2013 -0700
@@ -10,10 +10,11 @@
     DMGT_COLD   = 2,
     DMGT_EARTH      = 3,
     DMGT_PHISYCAL= 4,
-    DMGT_5      = 5,
+    DMGT_MAGICAL = 5,
     DMGT_SPIRIT = 6,
     DMGT_MIND   = 7,
     DMGT_BODY   = 8,
+    DMGT_LIGHT  = 9,
     DMGT_DARK   =10
     };
 
--- a/Viewport.cpp	Fri Oct 25 11:23:34 2013 -0700
+++ b/Viewport.cpp	Fri Oct 25 13:03:08 2013 -0700
@@ -358,7 +358,7 @@
     {
       if ( (unsigned int)v0 < 0x2000000 )
       {
-        stru_50C198.LootActor(&pActors[v16]);
+        pActors[v16].LootActor();
         return;
       }
       if ( !pParty->pPickedItem.uItemID )
--- a/mm7_6.cpp	Fri Oct 25 11:23:34 2013 -0700
+++ b/mm7_6.cpp	Fri Oct 25 13:03:08 2013 -0700
@@ -42,167 +42,6 @@
 
 
 
-//----- (00426A5A) --------------------------------------------------------
-void stru319::LootActor(Actor *pActor)
-{
-  signed int v2; // edi@1
-  char v3; // zf@1
-  unsigned int v4; // eax@13
-  unsigned int v5; // esi@13
-  int v6; // eax@14
-  unsigned __int8 v7; // al@30
-  Party *v8; // esi@34
-  char *v9; // [sp-4h] [bp-3Ch]@10
-  char *v10; // [sp-4h] [bp-3Ch]@31
-  char *v11; // [sp-4h] [bp-3Ch]@38
-  ItemGen Dst; // [sp+Ch] [bp-2Ch]@1
-  int v13; // [sp+30h] [bp-8h]@1
-  int v14; // [sp+34h] [bp-4h]@1
-
-  pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
-  Dst.Reset();
-  v2 = 0;
-  v3 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & pActor->uAttributes) == 0;
-  v13 = 0;
-  v14 = 0;
-  if ( v3 )
-  {
-    if ( pActor->pMonsterInfo.uTreasureDiceRolls )
-    {
-		do
-		{
-		  ++v2;
-		  v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1;
-		}
-		while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls );
-		if ( v14 )
-		{
-		  pParty->PartyFindsGold(v14, 0);
-		  viewparams->bRedrawGameUI = 1;
-		}
-	}
-  }
-  else
-  {
-    if ( pActor->array_000234[3].uItemID != 0 &&  pActor->array_000234[3].GetItemEquipType() == 18 )
-	{
-		v14 = pActor->array_000234[3].uSpecEnchantmentType;
-		pActor->array_000234[3].Reset();
-		if ( v14 )
-		{
-		  pParty->PartyFindsGold(v14, 0);
-		  viewparams->bRedrawGameUI = 1;
-		}
-	}
-  }
-  if ( pActor->uCarriedItemID )
-  {
-    Dst.Reset();
-    Dst.uItemID = pActor->uCarriedItemID;
-    v9 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
-    if ( v14 )
-      sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v9);
-    else
-      sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v9);
-    ShowStatusBarString(pTmpBuf2.data(), 2u);
-    v4 = Dst.uItemID;
-    v5 = Dst.uItemID;
-    if ( Dst.GetItemEquipType() == 12 )
-    {
-      v5 = Dst.uItemID;
-      v6 = rand() % 6 + Dst.GetDamageMod() + 1;
-      Dst.uNumCharges = v6;
-      Dst.uMaxCharges = v6;
-      v4 = Dst.uItemID;
-    }
-    if ( pItemsTable->pItems[v5].uEquipType == 14 && v4 != 220 )
-      Dst.uEnchantmentType = 2 * rand() % 4 + 2;
-    pItemsTable->SetSpecialBonus(&Dst);
-    if ( !pParty->AddItemToParty(&Dst) )
-      pParty->SetHoldingItem(&Dst);
-    pActor->uCarriedItemID = 0;
-    if ( pActor->array_000234[0].uItemID )
-    {
-      if ( !pParty->AddItemToParty(pActor->array_000234) )
-      {
-        pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
-        pParty->SetHoldingItem(pActor->array_000234);
-      }
-      pActor->array_000234[0].Reset();
-    }
-    if ( pActor->array_000234[1].uItemID )
-    {
-      if ( !pParty->AddItemToParty(&pActor->array_000234[1]) )
-      {
-        pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
-        pParty->SetHoldingItem(&pActor->array_000234[1]);
-      }
-      pActor->array_000234[1].Reset();
-    }
-    pActor->Remove();
-    return;
-  }
-  if ( (unsigned int)&array_77EC08[1975].pEdgeList1[1] & pActor->uAttributes )
-  {
-    if ( pActor->array_000234[3].uItemID )
-    {
-      memcpy(&Dst, &pActor->array_000234[3], sizeof(Dst));
-      pActor->array_000234[3].Reset();
-      v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
-      if ( v14 )
-        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v11);
-      else
-        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v11);
-      ShowStatusBarString(pTmpBuf2.data(), 2u);
-      if ( !pParty->AddItemToParty(&Dst) )
-        pParty->SetHoldingItem(&Dst);
-      v13 = 1;
-    }
-    v8 = pParty;
-    goto LABEL_45;
-  }
-  if ( rand() % 100 >= pActor->pMonsterInfo.uTreasureDropChance || (v7 = pActor->pMonsterInfo.uTreasureLevel) == 0 )
-  {
-    v8 = pParty;
-    goto LABEL_45;
-  }
-  pItemsTable->GenerateItem(v7, pActor->pMonsterInfo.uTreasureType, &Dst);
-  v10 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
-  if ( v14 )
-    sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v10);//Вы нашли ^I[%d] золот^L[ой;ых;ых] и предмет (%s)!
-  else
-    sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v10);//Вы нашли ^Pv[%s]!
-  ShowStatusBarString(pTmpBuf2.data(), 2);
-  v8 = pParty;
-  if ( !pParty->AddItemToParty(&Dst) )
-    pParty->SetHoldingItem(&Dst);
-  v13 = 1;
-LABEL_45:
-  if ( pActor->array_000234[0].uItemID )
-  {
-    if ( !v8->AddItemToParty(pActor->array_000234) )
-    {
-      pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
-      v8->SetHoldingItem(pActor->array_000234);
-      v13 = 1;
-    }
-    pActor->array_000234[0].Reset();
-  }
-  if ( pActor->array_000234[1].uItemID )
-  {
-    if ( !v8->AddItemToParty(&pActor->array_000234[1]) )
-    {
-      pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
-      v8->SetHoldingItem(&pActor->array_000234[1]);
-      v13 = 1;
-    }
-    pActor->array_000234[1].Reset();
-  }
-  if ( !v13 || rand() % 100 < 90 )
-  {
-    pActor->Remove();
-  }
-}
 //----- (0042704B) --------------------------------------------------------
 int stru319::special_ability_use_check( struct Actor *pActor, int a2 )
     {