changeset 613:5bf285f56fa8

Слияние
author Ritor1
date Thu, 07 Mar 2013 22:45:43 +0600
parents 346dc5fc2969 (current diff) 975a231bb4ec (diff)
children 7cb26ceb7107
files Chest.cpp mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp
diffstat 18 files changed, 657 insertions(+), 493 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/Actor.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -46,7 +46,7 @@
   v3 = 0;
   if ( (signed int)uNumActors > 0 )
   {
-    v4 = (int *)&pActors[0].uNPC_ID;
+    v4 = (int *)&pActors[0].sNPC_ID;
     while ( *(short *)v4 != npc )
     {
       ++v3;
@@ -147,7 +147,7 @@
 void Actor::InitializeDialogue(int bPlayerSaysHello)
 {
   Actor *v2; // esi@1
-  unsigned int v3; // ecx@1
+  signed int v3; // ecx@1
   NPCData *v4; // eax@1
   NPCData *v5; // ebp@1
   unsigned int v6; // eax@1
@@ -173,8 +173,8 @@
   pMiscTimer->Pause();
   pAudioPlayer->StopChannels(-1, -1);
   uDialogueType = 0;
-  v3 = v2->uNPC_ID;
-  uDialogue_SpeakingActorNPC_ID = v2->uNPC_ID;
+  v3 = v2->sNPC_ID;
+  sDialogue_SpeakingActorNPC_ID = v2->sNPC_ID;
   pDialogue_SpeakingActor = v2;
   v4 = GetNPCData(v3);
   v5 = v4;
@@ -247,7 +247,7 @@
 		}
 	}
   }
-  if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
+  if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
     v9 = 4;
   v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0);
   pDialogueWindow = v11;
@@ -3895,7 +3895,7 @@
 {
   this->pActorName[0] = 0;
   this->word_000086_some_monster_id = 0;
-  this->uNPC_ID = 0;
+  this->sNPC_ID = 0;
   this->vPosition.z = 0;
   this->vPosition.y = 0;
   this->vPosition.x = 0;
--- a/Actor.h	Thu Mar 07 22:45:23 2013 +0600
+++ b/Actor.h	Thu Mar 07 22:45:43 2013 +0600
@@ -238,7 +238,7 @@
 
 
   char pActorName[32];
-  unsigned __int16 uNPC_ID;
+  signed __int16 sNPC_ID;
   __int16 field_22;
   unsigned int uAttributes;
   __int16 sCurrentHP;
--- a/Chest.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/Chest.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -302,9 +302,9 @@
             v13 = v12 + 32;
             if ( itemPixelHeght < 14 )
                 itemPixelHeght = 14;
-            itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((v13 - itemPixelWidth) >> 1);
+            itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((signed int)(v13 - itemPixelWidth)/2);
             itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) +
-                ((((itemPixelHeght - 14) & 0xFFFFFFE0) - item_texture->uTextureHeight + 32) >> 1);
+                ((signed int)(((itemPixelHeght - 14) & 0xFFFFFFE0) + 32- item_texture->uTextureHeight ) /2);
             pRenderer->DrawTextureTransparent(  itemPixelPosX,   itemPixelPosY,  item_texture);
             sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
             }
--- a/Events.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/Events.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -121,6 +121,17 @@
 //----- (00443EF8) --------------------------------------------------------
 void  LoadLevel_InitializeLevelEvt()
 	{
+    struct raw_event_header
+        { 
+        unsigned char evt_size;
+        unsigned char evt_id_l;
+        unsigned char evt_id_h;
+        unsigned char evt_sequence_num;
+        } ;
+    uint events_count;
+    unsigned int offset_in; 
+    raw_event_header *current_hdr; 
+
 	if (!uLevelEVT_Size)
 		return;
 
@@ -130,6 +141,19 @@
 	uLevelEVT_NumEvents = 0;
 	dword_5B65C8_timers_count = 0;
 
+    current_hdr=(raw_event_header *)pLevelEVT;
+    offset_in=0;
+    for (events_count = 0, offset_in = 0; offset_in < uLevelEVT_Size; ++events_count)
+        {
+        pLevelEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8);
+        pLevelEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num;
+        pLevelEVT_Index[events_count].uEventOffsetInEVT=offset_in;			
+        offset_in+=current_hdr->evt_size+1;
+        current_hdr=(raw_event_header *)&pLevelEVT[offset_in];
+        }
+    uLevelEVT_NumEvents = events_count;
+
+/*
 	for (uint i = 0, j = 0; j < uLevelEVT_Size; ++i)
 		{
 		pLevelEVT_Index[i].uEventID = pLevelEVT[j + 1] + ((unsigned short)pLevelEVT[j + 2] << 8);
@@ -137,7 +161,7 @@
 		pLevelEVT_Index[i].uEventOffsetInEVT = j;
 		j += pLevelEVT[j] + 1;
 		uLevelEVT_NumEvents++;
-		}
+		}*/
 	}
 
 
@@ -507,7 +531,7 @@
 					//Actor::Actor(&Dst);
 					memset(&Dst, 0, 0x344u);
 					dword_5B65D0_dialogue_actor_npc_id = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8);
-					Dst.uNPC_ID = dword_5B65D0_dialogue_actor_npc_id;
+					Dst.sNPC_ID = dword_5B65D0_dialogue_actor_npc_id;
 					Dst.InitializeDialogue(0);
 					}
 				else
@@ -921,7 +945,7 @@
 				else 	if ( player_choose == 5 )//all
 				{
 					v130 = 0;
-					for(int i = 0; i < 4; ++i)
+					for(int i = 0; i < 5; ++i)
 					{
 						if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
 							break;
--- a/GUIWindow.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/GUIWindow.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -1796,8 +1796,8 @@
           {
             num_menu_buttons = 0;
             v11 = LOBYTE(pFontArrus->uFontHeight) - 3;
-            speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID);
-            if ( sub_445C8B(uDialogue_SpeakingActorNPC_ID) == 1 )
+            speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
+            if ( sub_445C8B(sDialogue_SpeakingActorNPC_ID) == 1 )
             {
               if ( speakingNPC->joins )
               {
--- a/Game.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/Game.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -180,7 +180,6 @@
   pParty->uFlags &= ~2;
 }
 
-
 //----- (0047A815) --------------------------------------------------------
 void Game::DrawParticles()
 {
--- a/Items.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/Items.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -925,7 +925,7 @@
 	memset(&uChanceByTreasureLvlSumm, 0, 24);
 	for(i=0;i<6;++i)
 		{
-		for (j=0;j<800;++j)
+		for (j=1;j<item_counter;++j)
 			uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i];
 		}
 
@@ -1723,7 +1723,10 @@
         if ( v18 > 0 )
             {
             do
-            v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6];
+                {      
+            v57 += pItems[out_item->uItemID + 1].uChanceByTreasureLvl[v6];
+            ++out_item->uItemID;
+                }
             while ( v57 < v18 );
             }
 
@@ -2019,204 +2022,162 @@
 
 
 //----- (00450218) --------------------------------------------------------
-void sub_450218_prolly_generate_chests_loot()
+void GenerateItemsInChest()
     {
-	unsigned int v0; // eax@1
-	Chest *v1; // ebx@1
-	MapInfo *v2; // esi@1
-	ItemGen *v3; // ebx@2
-	int v4; // ebp@4
-	int v5; // edi@4
-	int v6; // esi@4
-	int v7; // eax@4
-	signed int v8; // esi@4
-	int v9; // edx@4
-	int v10; // esi@8
-	int v11; // ebp@25
-	int v12; // esi@25
-	signed int v13; // ebp@27
-	ItemGen *v14; // edi@28
-	signed int v15; // edx@32
-	signed __int64 v16; // qtt@32
-	int v17; // esi@34
-	signed int v18; // [sp+10h] [bp-18h]@1
-	int v19; // [sp+14h] [bp-14h]@4
-	MapInfo *v20; // [sp+18h] [bp-10h]@1
-	Chest *v21; // [sp+1Ch] [bp-Ch]@1
-	int v22; // [sp+20h] [bp-8h]@26
-	signed int v23; // [sp+24h] [bp-4h]@2
+    unsigned int v0; // eax@1
+    Chest *v1; // ebx@1
+    MapInfo *v2; // esi@1
+    ItemGen *v3; // ebx@2
+    int v4; // ebp@4
+    int v5; // edi@4
+    int v6; // esi@4
+    int v7; // eax@4
+    signed int v8; // esi@4
+    int v9; // edx@4
+    int v10; // esi@8
+    int v11; // ebp@25
+    int v12; // esi@25
+    signed int v13; // ebp@27
+    ItemGen *v14; // edi@28
+    signed int v15; // edx@32
+    signed __int64 v16; // qtt@32
+    int v17; // esi@34
+    signed int v18; // [sp+10h] [bp-18h]@1
+    int v19; // [sp+14h] [bp-14h]@4
+    MapInfo *v20; // [sp+18h] [bp-10h]@1
+    Chest *v21; // [sp+1Ch] [bp-Ch]@1
+    int v22; // [sp+20h] [bp-8h]@26
+    signed int v23; // [sp+24h] [bp-4h]@2
 
-	v18 = rand() % 100;
-	v0 = pMapStats->GetMapInfo(pCurrentMapName);
-	v1 = pChests;
-	v2 = &pMapStats->pInfos[v0];
-	v21 = pChests;
-	v20 = &pMapStats->pInfos[v0];
-    for(int i=0; i<20;++i)
-		{
-		for(int j=0; j<140;++j)
-			{
-            v3 = &pChests[i].igChestItems[j];
-			if ( v3->uItemID < 0 )
-                {
-			v4 = rand() % 5 + 1;
-			v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2];
-			v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3];
-			v7 = rand();
-			v8 = v6 - v5 + 1;
-			v9 = v5 + v7 % v8;
-			v19 = v5 + v7 % v8;
-           /* switch (v9)
-                {
-            default:
-
-                }*/
-
+    v18 = rand() % 100;  //main random
+    v0 = pMapStats->GetMapInfo(pCurrentMapName);
+    //	v1 = pChests;
+    v2 = &pMapStats->pInfos[v0];
+    //v21 = pChests;
+    //v20 = &pMapStats->pInfos[v0];
+    for(int i=1; i<20;++i)
+        {
+        for(int j=0; j<140;++j)
+            {
 
-			if ( v9 < 7 )
-				{
-				if ( v18 < 20 )
-					{
-					v3->Reset();
-					goto LABEL_25;
-					}
-				if ( v18 < 60 )
-					{
-					v10 = 0;
-					v3->Reset();
-					if ( v19 == 1 )
-						{
-						v10 = rand() % 51 + 50;
-						}
-					else
-						{
-						if ( v19 != 2 )
-							{
-							if ( v19 == 3 )
-								{
-								v10 = rand() % 301 + 200;
-								}
-							else
-								{
-								if ( v19 != 4 )
-									{
-									if ( v19 == 5 )
-										{
-										v10 = rand() % 1001 + 1000;
-LABEL_15:
-										v3->uItemID = 199;
-										}
-									else
-										{
-										if ( v19 == 6 )
-											{
-											v10 = rand() % 3001 + 2000;
-											goto LABEL_15;
-											}
-										}
-LABEL_23:
-									v3->SetIdentified();
-									v3->uSpecEnchantmentType = v10;
-LABEL_25:
-									v11 = v4 - 1;
-									v12 = 0;
-									if ( v11 > 0 )
-										{
-										v22 = v11;
-										while ( 1 )
-											{
-											v13 = v12;
-											if ( v12 >= 140 )
-												goto LABEL_52;
-											v14 = &v21->igChestItems[v12];
-											while ( v14->uItemID )
-												{
-												++v13;
-												++v14;
-												if ( v13 >= 140 )
-													goto LABEL_52;
-												}
-											v16 = rand();
-											v15 = v16 % 100;
-											v18 = v16 % 100;
-											if ( v15 < 20 )
-												goto LABEL_52;
-											if ( v15 >= 60 )
-												{
-												pItemsTable->GenerateItem(v19, 0, v14);
-												goto LABEL_51;
-												}
-											v17 = 0;
-											v14->Reset();
-											if ( v19 == 1 )
-												{
-												v17 = rand() % 51 + 50;
-												goto LABEL_48;
-												}
-											if ( v19 == 2 )
-												{
-												v17 = rand() % 101 + 100;
-LABEL_48:
-												v14->uItemID = 197;
-												goto LABEL_49;
-												}
-											if ( v19 == 3 )
-												{
-												v17 = rand() % 301 + 200;
-												goto LABEL_44;
-												}
-											if ( v19 == 4 )
-												{
-												v17 = rand() % 501 + 500;
-LABEL_44:
-												v14->uItemID = 198;
-												goto LABEL_49;
-												}
-											if ( v19 == 5 )
-												break;
-											if ( v19 == 6 )
-												{
-												v17 = rand() % 3001 + 2000;
-LABEL_41:
-												v14->uItemID = 199;
-												}
-LABEL_49:
-											v14->uSpecEnchantmentType = v17;
-LABEL_51:
-											v12 = v13 + 1;
-LABEL_52:
-											--v22;
-											if ( !v22 )
-												goto LABEL_55;
-											}
-										v17 = rand() % 1001 + 1000;
-										goto LABEL_41;
-										}
-									goto LABEL_55;
-									}
-								v10 = rand() % 501 + 500;
-								}
-							v3->uItemID = 198;
-							goto LABEL_23;
-							}
-						v10 = rand() % 101 + 100;
-						}
-					v3->uItemID = 197;
-					goto LABEL_23;
-					}
-				pItemsTable->GenerateItem(v9, 0, v3);
-				goto LABEL_25;
-				}
-			v3->GenerateArtifact();
-            
-LABEL_55:
-			v2 = v20;
-LABEL_56: ;
+            v3 = &pChests[i].igChestItems[j];
+            if ( v3->uItemID < 0 )
+                {
+                v4 = rand() % 5; //additional items in chect
+                v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];
+                v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];
+                v8 = v6 - v5 + 1;
+                v9 = v5 + rand() % v8;  //treasure level 
+                if (v9<7)
+                    {
+                    if (v18<20)
+                        {
+                        v3->Reset();
+                        }
+                    else if (v18<60) //generate gold
+                        {
+                        v10=0;
+                        v3->Reset();
+                        switch (v9)
+                            {
+                        case 1: //small gold
+                            v10 = rand() % 51 + 50;
+                            v3->uItemID = 197;
+                            break;
+                        case 2://small gold
+                            v10 = rand() % 101 + 100;
+                            v3->uItemID = 197;
+                            break;
+                        case 3:  //medium
+                            v10 = rand() % 301 + 200;
+                            v3->uItemID = 198;
+                            break;
+                        case 4: //medium
+                            v10 = rand() % 501 + 500;
+                            v3->uItemID = 198;
+                            break;
+                        case 5: //big
+                            v10 = rand() % 1001 + 1000;
+                            v3->uItemID = 199;
+                            break;
+                        case 6: //big
+                            v10 = rand() % 3001 + 2000;
+                            v3->uItemID = 199;
+                            break;
+                            }
+                        v3->SetIdentified();
+                        v3->uSpecEnchantmentType = v10;
+                        }
+                    else
+                        {
+                        pItemsTable->GenerateItem(v9, 0, v3);
+                        }
+
+                    v12 = 0;
+                    //generate more items
+                    for (v11=0; v11<v4; ++v11)
+                        {
+
+                        if ( v12 >= 140 )
+                            break;
+                        while ( !(pChests[i].igChestItems[v12].uItemID==0) &&(v12<140))
+                            {
+                            ++v12;
+                            }
+                        v14=&pChests[i].igChestItems[v12];
+                        v18 = rand() % 100;
+                        if (v18<20)
+                            {
+                            v3->Reset();
+                            }
+                        else if (v18<60) //generate gold
+                            {
+                            v10=0;
+                            v3->Reset();
+                            switch (v9)
+                                {
+                            case 1: //small gold
+                                v10 = rand() % 51 + 50;
+                                v14->uItemID = 197;
+                                break;
+                            case 2://small gold
+                                v10 = rand() % 101 + 100;
+                                v14->uItemID = 197;
+                                break;
+                            case 3:  //medium
+                                v10 = rand() % 301 + 200;
+                                v14->uItemID = 198;
+                                break;
+                            case 4: //medium
+                                v10 = rand() % 501 + 500;
+                                v14->uItemID = 198;
+                                break;
+                            case 5: //big
+                                v10 = rand() % 1001 + 1000;
+                                v14->uItemID = 199;
+                                break;
+                            case 6: //big
+                                v10 = rand() % 3001 + 2000;
+                                v14->uItemID = 199;
+                                break;
+                                }
+                            v14->SetIdentified();
+                            v14->uSpecEnchantmentType = v10;
+                            }
+                        else
+                            {
+                            pItemsTable->GenerateItem(v9, 0, v14);
+                            }                       
+                        ++v12;
+                        }
+                    }
+                else
+                    v3->GenerateArtifact();
                 }
-			}			
-		}
-		
-	}
+            }			
+        }
+
+    }
 
 
 	
--- a/Items.h	Thu Mar 07 22:45:23 2013 +0600
+++ b/Items.h	Thu Mar 07 22:45:43 2013 +0600
@@ -289,6 +289,7 @@
 
 void GenerateStandartShopItems();
 void GenerateSpecialShopItems();
+void GenerateItemsInChest();
 
 extern const char uItemsAmountPerShopType[]; // weak
 extern ItemGen *ptr_50C9A4;
--- a/Party.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/Party.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -745,6 +745,7 @@
   uFlags = 0;
   memset(_autonote_bits, 0, 12);
   memset(_quest_bits, 0, 64);
+  memset(pIsArtifactFound, 0, 29);
   _449B7E_toggle_bit(_quest_bits, 1, 1);
   _449B7E_toggle_bit(_quest_bits, 2, 1);
   _449B7E_toggle_bit(_quest_bits, 3, 1);
--- a/Player.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/Player.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -9345,24 +9345,7 @@
   int v25; // [sp-4h] [bp-10h]@45
 
   v3 = 0;
-  v4 = 0;
-  if ( this == pPlayers[2] )
-  {
-    v4 = 1;
-    goto LABEL_8;
-  }
-  if ( this == pPlayers[3] )
-  {
-    v24 = 2;
-  }
-  else
-  {
-    if ( this != pPlayers[4] )
-      goto LABEL_8;
-    v24 = 3;
-  }
-  v4 = v24;
-LABEL_8:
+  v4 = uActiveCharacter - 1;
   result = false;
   if ( (signed int)VarNum > 222 )
   {
@@ -9386,7 +9369,7 @@
           {
             case 232:
               VarNum = (VariableType)0;
-              GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&VarNum);
+              GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&VarNum);
               result = (bool) pValue;
 			  dword_5B65CC = 0;
               if ( (int)VarNum == pValue )
@@ -9402,14 +9385,12 @@
               }
               break;
             case 241:
-              v18 = pValue;
-              v19 = 0;
               if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
               {
                 v20 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
-                do
+                for ( v19 = 0; v19 < (signed int)pNPCStats->uNumNewNPCs; ++v19 )
                 {
-                  if ( *((void **)v20 + 4) == (void *)v18 )
+                  if ( *((void **)v20 + 4) == (void *)pValue )
                   {
                     v21 = *(int *)v20;
                     if ( (char)*(int *)v20 < 0 )
@@ -9418,14 +9399,12 @@
                       *(int *)v20 = v21;
                     }
                   }
-                  ++v19;
                   v20 += 76;
                 }
-                while ( v19 < (signed int)pNPCStats->uNumNewNPCs );
               }
-              if ( pParty->pHirelings[0].uProfession == v18 )
+              if ( pParty->pHirelings[0].uProfession == pValue )
                 memset(pParty->pHirelings, 0, 0x4Cu);
-              if ( pParty->pHirelings[1].uProfession == v18 )
+              if ( pParty->pHirelings[1].uProfession == pValue )
                 memset(&pParty->pHirelings[1], 0, 0x4Cu);
               pParty->field_709 = 0;
               sub_44A56A();
@@ -9455,7 +9434,7 @@
 			  {
 				result = (bool)pValue;
                 pParty->uNumGoldInBank -= (unsigned int)pValue;
-			  }
+              }
               else
 LABEL_88:
                 dword_5B65C4 = 1;
@@ -9464,7 +9443,6 @@
           return result;
         }
         v11 = this->field_1A50;
-LABEL_112:
         v22 = (signed __int16)pValue;
       }
       _449B7E_toggle_bit((unsigned char *)v11, v22, 0);
@@ -9514,7 +9492,7 @@
             v6 = pParty->uNumGold;
           Party::TakeGold(v6);
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[503], v6);
-          ShowStatusBarString(pTmpBuf, 2u);
+          ShowStatusBarString(pTmpBuf, 2);
           GameUI_DrawFoodAndGold();
           return result;
         case VAR_RandomFood:
@@ -9525,41 +9503,67 @@
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[504], v7);
           ShowStatusBarString(pTmpBuf, 2u);
           GameUI_DrawFoodAndGold();
-          goto LABEL_17;
-        default:
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
           return result;
         case VAR_CurrentHP:
           ReceiveDamage((signed int)pValue, 4);
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_CurrentSP:
           v9 = (char *)&this->sMana;
           v10 = this->sMana - (signed int)pValue < 0;
           *(int *)v9 -= (int)pValue;
           if ( v10 )
             *(int *)v9 = 0;
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_ACModifier:
           this->sACModifier -= (unsigned __int8)pValue;
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BaseLevel:
           this->uLevel -= (unsigned __int8)pValue;
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_LevelModifier:
           this->sLevelModifier -= (unsigned __int8)pValue;
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_Age:
           this->sAgeModifier -= (signed __int16)pValue;
           return result;
         case VAR_Award:
-          v11 = this->_guilds_member_bits;
-          goto LABEL_112;
+          _449B7E_toggle_bit((unsigned char *)this->_guilds_member_bits, (signed __int16)pValue, 0);
+          return result;
         case VAR_Experience:
           v12 = (char *)&this->uExperience;
           v13 = (signed int)pValue;
           v14 = *(int *)v12 < (unsigned int)pValue;
           *(int *)v12 -= (int)pValue;
           *((int *)v12 + 1) -= v14 + HIDWORD(v13);
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_QBits_QuestsDone:
           _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0);
           pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0);
@@ -9575,123 +9579,291 @@
         case VAR_MightBonus:
         case VAR_ActualMight:
           this->uMightBonus -= (unsigned __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_IntellectBonus:
         case VAR_ActualIntellect:
           this->uIntelligenceBonus -= (unsigned __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_PersonalityBonus:
         case VAR_ActualPersonality:
           this->uWillpowerBonus -= (unsigned __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_EnduranceBonus:
         case VAR_ActualEndurance:
           this->uEnduranceBonus -= (unsigned __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_SpeedBonus:
         case VAR_ActualSpeed:
           this->uSpeedBonus -= (unsigned __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_AccuracyBonus:
         case VAR_ActualAccuracy:
           this->uAccuracyBonus -= (unsigned __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_LuckBonus:
         case VAR_ActualLuck:
           this->uLuckBonus -= (unsigned __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BaseMight:
           this->uMight -= (unsigned __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BaseIntellect:
           this->uIntelligence -= (unsigned __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BasePersonality:
           this->uWillpower -= (unsigned __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BaseEndurance:
           this->uEndurance -= (unsigned __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BaseSpeed:
           this->uSpeed -= (unsigned __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BaseAccuracy:
           this->uAccuracy -= (unsigned __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BaseLuck:
           this->uLuck -= (unsigned __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_FireResistance:
           this->sResFireBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_AirResistance:
           this->sResAirBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_WaterResistance:
           this->sResWaterBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_EarthResistance:
           this->sResEarthBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_SpiritResistance:
           this->sResSpiritBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_MindResistance:
           this->sResMindBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BodyResistance:
           this->sResBodyBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_LightResistance:
           this->sResLightBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_DarkResistance:
           this->sResDarkBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_MagicResistance:
           this->sResMagicBase -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_FireResistanceBonus:
           this->sResFireBonus -= (signed __int16)pValue;
-          goto LABEL_45;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_AirResistanceBonus:
           this->sResAirBonus -= (signed __int16)pValue;
-LABEL_45:
-          v25 = 0;
-          v23 = 92;
-          goto LABEL_73;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_WaterResistanceBonus:
           this->sResWaterBonus -= (signed __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_EarthResistanceBonus:
           this->sResEarthBonus -= (signed __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_SpiritResistanceBonus:
           this->sResSpiritBonus -= (signed __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_MindResistanceBonus:
           this->sResMindBonus -= (signed __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_BodyResistanceBonus:
           this->sResBodyBonus -= (signed __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_LightResistanceBonus:
           this->sResLightBonus -= (signed __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_DarkResistanceBonus:
           this->sResDarkBonus -= (signed __int16)pValue;
-          goto LABEL_72;
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0);
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_MagicResistanceBonus:
           this->sResMagicBonus -= (signed __int16)pValue;
-LABEL_72:
           v25 = 0;
           v23 = SPEECH_91;
-LABEL_73:
           pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25);
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_FixedFood:
           Party::TakeFood((unsigned int)pValue);
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_StaffSkill:
         case VAR_SwordSkill:
         case VAR_DaggerSkill:
@@ -9723,7 +9895,11 @@
         case VAR_DisarmTrapSkill:
         case VAR_LearningSkill:
           *((short *)&this->pConditions[16] + VarNum) -= (unsigned __int8)pValue;
-          goto LABEL_17;
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
+          v8 = 8 * v4 + 400;
+          LOBYTE(v8) = (8 * v4 - 112) | 4;
+          pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
+          return result;
         case VAR_Cursed:
         case VAR_Weak:
         case VAR_Asleep:
@@ -9743,31 +9919,28 @@
         case VAR_Eradicated:
           *((int *)this + 2 * VarNum - 210) = 0;
           *((int *)this + 2 * result - 209) = 0;
-LABEL_17:
           pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
           v8 = 8 * v4 + 400;
           LOBYTE(v8) = (8 * v4 - 112) | 4;
           pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
           return result;
-      }
-      //do
-	  for (v3 = 1; v3 < 126; v3++)
-      {
-		  if ( *(&this->pInventoryItems[pInventoryIndices[v3] - 1].uItemID) == pValue )//pValue = ItemID, pInventoryItems[3] = 222
+        default:
+          return result;
+      }
+      for (v3 = 1; v3 < 126; v3++)
+      {
+        if ( *(&this->pInventoryItems[pInventoryIndices[v3] - 1].uItemID) == pValue )
         {
-          RemoveItemAtInventoryIndex(v3);// &this->pInventoryIndices[puSlot], pInventoryIndices[1] = 4
+          RemoveItemAtInventoryIndex(v3);
           return true;
         }
-        //++v3;
-        //v15 ++;
-      }
-      //while ( (signed int)v3 < 126 );
+      }
       if ( pParty->pPickedItem.uItemID == pValue )
       {
-         pMouse->RemoveHoldingItem();
-		 return true;
-	  }
-	  return false;
+        pMouse->RemoveHoldingItem();
+        return true;
+      }
+      return false;
     }
   }
 }
--- a/mm7_1.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_1.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -2510,19 +2510,22 @@
         if (item_desc->uDamageDice) //"Armor"	
           sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod);
       break;
-      case EQUIP_POTION:
-          if ( inspect_item->uEnchantmentType )
-              sprintf(out_text + 200,  "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power"
-          break;
-      case EQUIP_REAGENT:
-         sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power"
-         break;
+      
     }
 
     if ( !v77 )
 	{
-    //v23 = item_desc->uEquipType;
-		if ( inspect_item->uEnchantmentType )
+       if (item_desc->uEquipType ==EQUIP_POTION)  //this is CORRECT! do not move to switch!
+           {
+           if ( inspect_item->uEnchantmentType )
+              sprintf(out_text + 200,  "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power"
+          }
+       else if (item_desc->uEquipType == EQUIP_REAGENT)
+          {
+          sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power"
+          }
+
+		else if ( inspect_item->uEnchantmentType )
 		 {
 			sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210],
 				 pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->_bonus_strength); //"Special"
@@ -2828,7 +2831,7 @@
   v3 = &pActors[v2];
   v121 = v3;
   v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xFFu, 0x9Bu);
-  v5 = v3->uNPC_ID;
+  v5 = v3->sNPC_ID;
   a5 = v4;
   v6 = GetNPCData(v5);
   v7 = v3->pMonsterInfo.uID;
@@ -3043,7 +3046,7 @@
     if ( v36 >= 0 )
       pSprites_LOD->pSpriteHeaders[v36]._4ACC38(&v106, 0);
   }
-  if ( v121->uNPC_ID )
+  if ( v121->sNPC_ID )
   {
     v37 = v112[6];
     if ( v37 )
@@ -3065,7 +3068,7 @@
     else
       v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName;
   }
-  if(!v121->uNPC_ID || (v121->uNPC_ID && !v37))
+  if(!v121->sNPC_ID || (v121->sNPC_ID && !v37))
     strncpy(pTmpBuf, v72, v77);
   v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u);
@@ -3984,9 +3987,9 @@
       else
         v3 = -1;
       v4 = pChests[chest_id].pInventoryIndices[v3] - 1;
-      if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == 18 )
+      if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == EQUIP_GOLD )
       {
-        party_finds_gold(pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uValue, 0); //recheck
+        party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); 
         viewparams->bRedrawGameUI = 1;
       }
       else
@@ -5311,7 +5314,7 @@
         return;
       v18 = a2.y;
       Actor::FaceObject(a2.y, 4u, 0, 0);
-      if ( !v17->uNPC_ID )
+      if ( !v17->sNPC_ID )
       {
         v19 = pNPCStats->pGroups_copy[v17->uGroup];
         if ( v19 )
--- a/mm7_2.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_2.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -3172,7 +3172,7 @@
           ++pMessageQueue_50CBD0->uNumMessages;
         }*/
         dword_50C9DC = 195;
-        ptr_50C9E0 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
+        ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID);
         return 0;
       }
       if ( a1 == 42 )
@@ -11297,7 +11297,7 @@
   signed int v20; // [sp+18h] [bp-44h]@14
   int v21[16]; // [sp+1Ch] [bp-40h]@17
 
-  sub_450218_prolly_generate_chests_loot();
+  GenerateItemsInChest();
   //v0 = pGameLoadingUI_ProgressBar;
   pGameLoadingUI_ProgressBar->Progress();
   pParty->uFlags |= 2u;
@@ -11323,30 +11323,30 @@
       v4 = (v3 - 1) % 3;
       if ( 2 == v4 )
       {
-        if ( pActor->uNPC_ID && pActor->uNPC_ID < 5000 )
+        if ( pActor->sNPC_ID && pActor->sNPC_ID < 5000 )
           continue;
       }
       else
       {
         if ( v4 != 1 )
         {
-          if ( v4 != 0 || pActor->uNPC_ID )
+          if ( v4 != 0 || pActor->sNPC_ID )
             continue;
           goto LABEL_12;
         }
       }
-      if ( pActor->uNPC_ID > 0 && pActor->uNPC_ID < 5000 )
+      if ( pActor->sNPC_ID > 0 && pActor->sNPC_ID < 5000 )
         continue;
       if ( v17 )
       {
         pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], v3, 0, v19);
         v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000;
         ++pNPCStats->uNewlNPCBufPos;
-        pActor->uNPC_ID = v14;
+        pActor->sNPC_ID = v14;
         continue;
       }
 LABEL_12:
-      pActor->uNPC_ID = 0;
+      pActor->sNPC_ID = 0;
 //LABEL_13:
       //++v15;
       //v2 += 836;
@@ -15453,7 +15453,7 @@
         if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() )
         {
           Actor::FaceObject(v12, 4u, 0, 0);
-          if ( v13->uNPC_ID )
+          if ( v13->sNPC_ID )
           {
             pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0);
             /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
--- a/mm7_3.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_3.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -13310,8 +13310,8 @@
 
 
 //----- (00443E31) --------------------------------------------------------
-void __cdecl LoadLevel_InitializeLevelStr()
-{
+void LoadLevel_InitializeLevelStr()
+    {
   
   char Args[100]; 
   int string_num;
@@ -13417,10 +13417,7 @@
 
 		if (_evt->_e_type == EVENT_PlaySound)
 			{
-			pSoundList->LoadSound(
-				_evt->v5 +
-				((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8),
-				0);
+			pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
 			}
 		else if (_evt->_e_type == EVENT_OnMapReload)
 			{
@@ -14125,8 +14122,8 @@
   if ( !pDialogueWindow )
     return;
   memcpy(&v51, pDialogueWindow, sizeof(v51));
-  pNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID);
-  v1 = sub_445C8B(uDialogue_SpeakingActorNPC_ID);
+  pNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
+  v1 = sub_445C8B(sDialogue_SpeakingActorNPC_ID);
   v51.uFrameWidth -= 10;
   v51.uFrameZ -= 10;
   //v54 = v1;
@@ -14426,7 +14423,7 @@
 }
 
 //----- (004459F9) --------------------------------------------------------
-NPCData *__fastcall GetNPCData(unsigned int npcid)
+NPCData *__fastcall GetNPCData(signed int npcid)
 {
   unsigned int v1; // esi@1
   NPCData *result; // eax@5
@@ -14463,13 +14460,13 @@
   }
   if ( (signed int)npcid >= 5000 )
     return &pNPCStats->array_13EF4[npcid - 5000];
-  if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+  if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
   {
     result = 0;
   }
   else
   {
-    v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
+    v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1;
     v4 = 0;
     v5 = 0;
     v6 = pParty->pHirelings;
@@ -14521,16 +14518,16 @@
 
   if ( npcid >= 5000 )
     return &pNPCStats->pAdditionalNPC[npcid - 5000];
-  if (uDialogue_SpeakingActorNPC_ID >= 0)
+  if (sDialogue_SpeakingActorNPC_ID >= 0)
   {
     result = 0;
   }
   else
   {
-    v3 = uDialogue_SpeakingActorNPC_ID - 1;
+    v3 = abs(sDialogue_SpeakingActorNPC_ID) - 1;
     v4 = 0;
 
-    for (i = 0; i < 4; ++i)
+    for (i = 0; i < 2; ++i)
     {
       if (pParty->pHirelings[i].pName)
         pTmpBuf[v4++] = i;
@@ -14600,14 +14597,14 @@
   }
   if ( npcid >= 5000 )
     goto LABEL_7;
-  if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+  if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
   {
     *(int *)a2 = 0;
     result = 0;
   }
   else
   {
-    v5 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
+    v5 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1;
     v6 = 0;
     v7 = 0;
     v8 = pParty->pHirelings;
@@ -14674,7 +14671,7 @@
   }
   if ( a1 >= 5000 )
     return 2;
-  v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1;
+  v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1;
   v4 = 0;
   v5 = 0;
   v6 = pParty->pHirelings;
@@ -14709,7 +14706,7 @@
 //----- (0044603D) --------------------------------------------------------
 void __cdecl sub_44603D()
 {
-  uDialogue_SpeakingActorNPC_ID = 0;
+  sDialogue_SpeakingActorNPC_ID = 0;
   pDialogueWindow->Release();
   pDialogueWindow = 0;
   pMiscTimer->Resume();
--- a/mm7_4.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_4.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -4904,7 +4904,7 @@
     npc = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
   }
   else
-    npc = GetNPCData(uDialogue_SpeakingActorNPC_ID);
+    npc = GetNPCData(sDialogue_SpeakingActorNPC_ID);
   //v65 = v9;
   //v10 = 0;
   //v64 = 0;
@@ -10589,7 +10589,7 @@
   //GUIWindow *v2; // ecx@1
 
   __debugbreak();
-  v0 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
+  v0 = GetNPCData(sDialogue_SpeakingActorNPC_ID);
   v1 = 0;
   pDialogueWindow->eWindowType = WINDOW_MainMenu;
   pDialogueWindow->Release();
@@ -11943,7 +11943,7 @@
     const char *v15; // [sp-4h] [bp-14h]@60
 
     //v1 = _this;
-    speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID);
+    speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
     //v3 = v1;
     uDialogueType = newDialogueType;
     if ( !speakingNPC->uFlags )
@@ -12050,7 +12050,7 @@
 
         pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
 
-        if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+        if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
             pDialogue_SpeakingActor->uAIState = Removed;
         if ( uActiveCharacter )
             pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
@@ -13853,7 +13853,6 @@
       || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) )
       continue;
     pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6);
-
     v0 = &pBillboardRenderList[uNumBillboardsToDraw];
     if (uNumBillboardsToDraw >= 500)
       break;
--- a/mm7_5.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_5.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -299,7 +299,7 @@
     //Actor::Actor(&actor);
     memset(&actor, 0, 0x344u);
     dword_5B65D0_dialogue_actor_npc_id = bDialogueUI_InitializeActor_NPC_ID;
-    actor.uNPC_ID = bDialogueUI_InitializeActor_NPC_ID;
+    actor.sNPC_ID = bDialogueUI_InitializeActor_NPC_ID;
     actor.InitializeDialogue(0);
     bDialogueUI_InitializeActor_NPC_ID = 0;
   }
@@ -329,7 +329,7 @@
           viewparams->field_48 = v0;
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].uNPC_ID;
+          dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].sNPC_ID;
           pActor = &pActors[uMessageParam];
           //goto _actor_init_dlg;
           pActor->InitializeDialogue(v0);
@@ -383,7 +383,7 @@
             {
               //Actor::Actor(&actor);
               memset(&actor, 0, 0x344u);
-              actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx;
+              actor.sNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx;
               pActor = &actor;
               pActor->InitializeDialogue(v0);
             }
@@ -15811,8 +15811,8 @@
     }
     if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 )
     {
-      uDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17;
-      v5 = GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&a2);
+      sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17;
+      v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&a2);
       v6 = v5;
       if ( v5 )
       {
@@ -15979,9 +15979,11 @@
 			if ( pRenderer->pActiveZBuffer[v9] & 0xFFFF )
 			{
 
-              __debugbreak(); // invalid indexing will result in invalid object ptr
-				v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime
-								+ (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
+            //  __debugbreak(); // invalid indexing will result in invalid object ptr
+			//	v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime
+			//					+ (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
+                v10=pChests[pChestWindow->par1C].pInventoryIndices[(pRenderer->pActiveZBuffer[v9] & 0xFFFF)-1];
+                v8 =&pChests[pChestWindow->par1C].igChestItems[v10-1];
 				GameUI_DrawItemInfo(v8);
 			}
 		}
--- a/mm7_6.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_6.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -1735,148 +1735,152 @@
   signed int v8; // edx@50
   SpellBuff *v9; // ecx@50
 
-  if ( a2 > 73 )
+  switch(a2)
   {
-    if ( a2 == 77 )
-    {
-      if ( pActor->sCurrentHP >= (signed int)pActor->pMonsterInfo.uHP )
-        return 0;
-      return 1;
-    }
-    if ( a2 == 80 )
-    {
-      v6 = pParty->pPartyBuffs;
-      while ( (signed __int64)v6->uExpireTime <= 0 )
-      {
-        ++v6;
-        if ( v6 > &pParty->pPartyBuffs[19] )
-        {
-          v7 = pParty->pPlayers;//[0].pPlayerBuffs;
-          v8 = 0;
-		  v9 = v7->pPlayerBuffs;
-		  while ( v9->uExpireTime <= 0i64 )
-          {
-            ++v8;
-            ++v9;
-            if ( v8 >= 24 )
-            {
-              ++v7;
-              if ( v7 <= &pParty->pPlayers[3] )
-			  {
-			      v8 = 0;
-				  v9 = v7->pPlayerBuffs;
-			  }
-			  else
-	              return 0;
-            }
-          }
-          return 1;
-        }
-      }
-      return 1;
-    }
-    if ( a2 == 85 )
-    {
-      if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) < 0 )
-        return 1;
-      if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) > 0 )
-        return 0;
-      v3 = 0;
-      v4 = LODWORD(pActor->pActorBuffs[13].uExpireTime) == 0;
-    }
-    else
-    {
-      if ( a2 == 86 )
-      {
+	case 77:
+		{
+		if ( pActor->sCurrentHP >= (signed int)pActor->pMonsterInfo.uHP )
+			return 0;
+		return 1;
+		}
+	case 80:
+		{
+		v6 = pParty->pPartyBuffs;
+		while ( (signed __int64)v6->uExpireTime <= 0 )
+		{
+			++v6;
+			if ( v6 > &pParty->pPartyBuffs[19] )
+			{
+				v7 = pParty->pPlayers;//[0].pPlayerBuffs;
+				v8 = 0;
+				v9 = v7->pPlayerBuffs;
+				while ( v9->uExpireTime <= 0i64 )
+				{
+					++v8;
+					++v9;
+					if ( v8 >= 24 )
+					{
+						++v7;
+						if ( v7 <= &pParty->pPlayers[3] )
+						{
+							v8 = 0;
+							v9 = v7->pPlayerBuffs;
+						}
+						else
+							return 0;
+					}
+				}
+				return 1;
+			}
+		}
+		return 1;
+		}
+	case 85:
+		{
+		if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) < 0 )
+			return 1;
+		if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) > 0 )
+			return 0;
+		v3 = 0;
+		v4 = LODWORD(pActor->pActorBuffs[13].uExpireTime) == 0;
+		break;
+		}
+	case 86:
+		{
         if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) < 0 )
-          return 1;
+			return 1;
         if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) > 0 )
-          return 0;
+			return 0;
         v3 = 0;
         v4 = LODWORD(pActor->pActorBuffs[14].uExpireTime) == 0;
-      }
-      else
-      {
-        if ( a2 != 95 || SHIDWORD(pActor->pActorBuffs[20].uExpireTime) < 0 )
-          return 1;
+		break;
+		}
+	case 95:
+		{
+        if ( SHIDWORD(pActor->pActorBuffs[20].uExpireTime) < 0 )
+			return 1;
         if ( SHIDWORD(pActor->pActorBuffs[20].uExpireTime) > 0 )
-          return 0;
+			return 0;
         v3 = 0;
         v4 = LODWORD(pActor->pActorBuffs[20].uExpireTime) == 0;
-      }
-    }
-  }
-  else
-  {
-    if ( a2 == 73 )
-    {
-      if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) < 0 )
-        return 1;
-      if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) > 0 )
-        return 0;
-      v3 = 0;
-      v4 = LODWORD(pActor->pActorBuffs[21].uExpireTime) == 0;
-    }
-    else if ( a2 == 5 )
-    {
-      if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) < 0 )
-        return 1;
-      if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) > 0 )
-        return 0;
-      v3 = 0;
-      v4 = LODWORD(pActor->pActorBuffs[19].uExpireTime) == 0;
-    }
-    else if ( a2 == 17 )
-    {
-      if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) < 0 )
-        return 1;
-      if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) > 0 )
-        return 0;
-      v3 = 0;
-      v4 = LODWORD(pActor->pActorBuffs[15].uExpireTime) == 0;
-    }
-    else if ( a2 == 38 )
-    {
-      if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) < 0 )
-        return 1;
-      if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) > 0 )
-        return 0;
-      v3 = 0;
-      v4 = LODWORD(pActor->pActorBuffs[16].uExpireTime) == 0;
-    }
-    else if ( a2 == 46 )
-    {
-      if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) < 0 )
-        return 1;
-      if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) > 0 )
-        return 0;
-      v3 = 0;
-      v4 = LODWORD(pActor->pActorBuffs[17].uExpireTime) == 0;
-    }
-    else
-	{
-		if ( a2 != 47 )
+		break;
+		}
+	case 73:
+		{
+		if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) < 0 )
+			return 1;
+		if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) > 0 )
+			return 0;
+		v3 = 0;
+		v4 = LODWORD(pActor->pActorBuffs[21].uExpireTime) == 0;
+		break;
+		}
+	case 5:
+		{
+		if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) < 0 )
+			return 1;
+		if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) > 0 )
+			return 0;
+		v3 = 0;
+		v4 = LODWORD(pActor->pActorBuffs[19].uExpireTime) == 0;
+		break;
+		}
+	case 17:
+		{
+		if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) < 0 )
+			return 1;
+		if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) > 0 )
+			return 0;
+		v3 = 0;
+		v4 = LODWORD(pActor->pActorBuffs[15].uExpireTime) == 0;
+		break;
+		}
+	case 38:
 		{
-		  if ( a2 != 51 || SHIDWORD(pActor->pActorBuffs[18].uExpireTime) < 0 )
+		if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) < 0 )
+			return 1;
+		if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) > 0 )
+			return 0;
+		v3 = 0;
+		v4 = LODWORD(pActor->pActorBuffs[16].uExpireTime) == 0;
+		}
+	case 46:
+		{
+		if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) < 0 )
 			return 1;
-		  if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) <= 0 )
-		  {
+		if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) > 0 )
+			return 0;
+		v3 = 0;
+		v4 = LODWORD(pActor->pActorBuffs[17].uExpireTime) == 0;
+		break;
+		}
+	case 47:
+		{
+		if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) < 0 )
+			return 1;
+		if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) > 0 )
+			return 0;
+		v3 = 0;
+		v4 = LODWORD(pActor->pActorBuffs[11].uExpireTime) == 0;
+		break;
+		}
+	case 51:
+		{
+		if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) < 0 )
+			return 1;
+		if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) <= 0 )
+		{
 			v3 = 0;
 			v4 = LODWORD(pActor->pActorBuffs[18].uExpireTime) == 0;
-		  }
-		  else
-			return 0;
 		}
 		else
+			return 0;
+		break;
+		}
+	default:
 		{
-			if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) < 0 )
-			  return 1;
-			if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) > 0 )
-			  return 0;
-			v3 = 0;
-			v4 = LODWORD(pActor->pActorBuffs[11].uExpireTime) == 0;
+		return 1;
 		}
-	}
   }
   if ( !(v3 | v4) )
     return 0;
--- a/mm7_data.cpp	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_data.cpp	Thu Mar 07 22:45:43 2013 +0600
@@ -2005,7 +2005,7 @@
 int dword_591084; // weak
 struct Actor *pDialogue_SpeakingActor;
 unsigned int uDialogueType;
-unsigned int uDialogue_SpeakingActorNPC_ID;
+signed int sDialogue_SpeakingActorNPC_ID;
 struct LevelDecoration *_591094_decoration;
 char sHouseName[200]; // idb
 int uCurrentHouse_Animation; // weak
@@ -2039,7 +2039,7 @@
 int dword_5B65C4; // weak
 int dword_5B65C8_timers_count; // weak
 int dword_5B65CC; // weak
-int dword_5B65D0_dialogue_actor_npc_id; // weak
+signed int dword_5B65D0_dialogue_actor_npc_id; // weak
 int dword_5C3418; // weak
 int dword_5C341C; // weak
 int _5C3420_pDecoration;
--- a/mm7_data.h	Thu Mar 07 22:45:23 2013 +0600
+++ b/mm7_data.h	Thu Mar 07 22:45:43 2013 +0600
@@ -1320,7 +1320,7 @@
 extern int dword_591084; // weak
 extern struct Actor *pDialogue_SpeakingActor;
 extern unsigned int uDialogueType;
-extern unsigned int uDialogue_SpeakingActorNPC_ID;
+extern signed int sDialogue_SpeakingActorNPC_ID;
 extern struct LevelDecoration *_591094_decoration;
 extern char sHouseName[200]; // idb
 extern int uCurrentHouse_Animation; // weak
@@ -2002,7 +2002,7 @@
 int __fastcall DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
 void Initialize2DA();
 
-void __cdecl LoadLevel_InitializeLevelStr();
+void  LoadLevel_InitializeLevelStr();
 
 void __cdecl OnMapLeave();
 void /*__usercall*/ OnMapLoad();
@@ -2020,7 +2020,7 @@
 void __cdecl sub_4452BB();
 const char *GetProfessionActionText(int a1);
 void __cdecl DrawDialogueUI();
-struct NPCData *__fastcall GetNPCData(unsigned int npcid);
+struct NPCData *__fastcall GetNPCData(signed int npcid);
 struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2);
 int __fastcall sub_445C8B(signed int a1);
 void __cdecl sub_44603D();
@@ -2053,7 +2053,7 @@
 // int __cdecl crt_deconstruct_44C42C();
 void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5);
 int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3);
-void  sub_450218_prolly_generate_chests_loot();
+
 signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6);
 int __fastcall sub_45063B(struct MapInfo *a1, int a2);
 void RespawnGlobalDecorations();