changeset 251:48f21f569328

Npc related stuff separated
author Gloval
date Mon, 18 Feb 2013 08:47:21 +0400
parents fb8a876f41e1
children e22e2357c8b3
files NPC.cpp NPC.h mm7_2.cpp mm7_3.cpp mm7_data.h
diffstat 5 files changed, 1209 insertions(+), 1191 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NPC.cpp	Mon Feb 18 08:47:21 2013 +0400
@@ -0,0 +1,1202 @@
+#include <string.h>
+#include <stdlib.h>
+
+#include "Allocator.h"
+#include "texts.h"
+#include "Party.h"
+#include "LOD.h"
+#include "Autonotes.h"
+#include "Awards.h"
+#include "mm7_data.h"
+#include "MM7.h"
+#include "NPC.h"
+
+
+void  InitializeAwards();
+void  InitializeScrolls();
+void  InitializeMerchants();
+void  InitializeTransitions();
+void  InitializeAutonotes();
+void  InitializeQuests();
+
+
+//----- (00476977) --------------------------------------------------------
+void NPCStats::Initialize2()
+	{
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+
+	if (pNPCTextTXT_Raw)
+		pAllocator->FreeChunk(pNPCTextTXT_Raw);
+	pNPCTextTXT_Raw =NULL;
+	pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
+	strtok(pNPCTextTXT_Raw, "\r");
+
+	for (i=0; i<789; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if ( decode_step == 1)
+					pNPCTopics[i].pText =RemoveQuotes(test_string);
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
+
+	if (pNPCTopicTXT_Raw)
+		pAllocator->FreeChunk(pNPCTopicTXT_Raw);
+	pNPCTopicTXT_Raw =NULL;
+	pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
+	strtok(pNPCTopicTXT_Raw, "\r");
+
+	for (i=0; i<579; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if ( decode_step == 1)
+					pNPCTopics[i].pTopic = RemoveQuotes(test_string);
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
+
+	if (pNPCDistTXT_Raw)
+		pAllocator->FreeChunk(pNPCDistTXT_Raw);
+	pNPCDistTXT_Raw = NULL;
+	pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
+	strtok(pNPCDistTXT_Raw, "\r");
+	strtok(NULL, "\r");
+
+	for (i=1; i<59; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if ((decode_step>0)&&(decode_step<77))
+					{
+					array_16544[decode_step].field_4[i]=atoi(test_string);
+					}
+				else if (decode_step==0)
+					{
+					array_16544[0].field_4[i]=10;
+					}
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<78)&&!break_loop);
+		}
+
+	for (i=0; i<78; ++i)
+		{
+		array_16544[i].field_0=0;
+		for (int ii=1; ii<59; ++ii)
+			{
+			array_16544[i].field_0+=array_16544[i].field_4[ii];
+			}
+		}
+
+	if (pNPCDistTXT_Raw)
+		{
+		pAllocator->FreeChunk(pNPCDistTXT_Raw);
+		pNPCDistTXT_Raw = NULL;
+		}
+	}
+
+//----- (00476C60) --------------------------------------------------------
+void NPCStats::_476C60()
+	{
+	for (unsigned int i = 1; i < uNumNewNPCs; ++i)
+		pNewNPCData[i].pName = pNPCNames2[i - 1];
+
+	if (pParty->pHirelings[0].pName)
+		pParty->pHirelings[0].pName = pParty->pHireling1Name;
+	if (pParty->pHirelings[1].pName)
+		pParty->pHirelings[1].pName = pParty->pHireling2Name;
+	}
+
+//----- (00476CB5) --------------------------------------------------------
+void NPCStats::Initialize1()
+	{
+	NPCStats *pNPCStats; // esi@1
+	char *pRaw; // eax@1
+	char *pHouse; // edi@1
+	char *v4; // eax@2
+	char v5; // dl@3
+	int v6; // ecx@3
+	char *v7; // eax@11
+	char *v8; // eax@26
+	char *v9; // ecx@27
+	char v10; // dl@28
+	int v11; // eax@28
+	int v12; // edi@32
+	char *v13; // eax@42
+	char *v14; // eax@43
+	char v15; // dl@44
+	int v16; // ecx@44
+	int v17; // edi@48
+	char *v18; // eax@56
+	char *v19; // eax@57
+	char v20; // cl@58
+	int v21; // edi@58
+	int v22; // esi@62
+	int v23; // [sp+Ch] [bp-14h]@7
+	signed int v24; // [sp+10h] [bp-10h]@1
+	signed int v25; // [sp+10h] [bp-10h]@26
+	signed int v26; // [sp+10h] [bp-10h]@42
+	signed int v27; // [sp+10h] [bp-10h]@56
+	char *Str; // [sp+14h] [bp-Ch]@1
+	NPCGreeting *pGreetings; // [sp+14h] [bp-Ch]@26
+	unsigned __int16 *pGroups; // [sp+14h] [bp-Ch]@42
+	char **pCatchPhrase; // [sp+14h] [bp-Ch]@56
+	signed int v32; // [sp+18h] [bp-8h]@2
+	signed int v33; // [sp+18h] [bp-8h]@27
+	signed int v34; // [sp+18h] [bp-8h]@43
+	signed int v35; // [sp+18h] [bp-8h]@57
+	signed int v36; // [sp+1Ch] [bp-4h]@2
+	signed int v37; // [sp+1Ch] [bp-4h]@27
+	signed int v38; // [sp+1Ch] [bp-4h]@43
+	signed int v39; // [sp+1Ch] [bp-4h]@57
+
+	pNPCStats = this;
+	pRaw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
+	pNPCStats->pNPCDataTXT_Raw = pRaw;
+	strtok(pRaw, "\r");
+	strtok(0, "\r");
+	pHouse = (char *)&pNPCStats->pNPCData[1].house;
+	Str = (char *)pNPCStats->pNPCNames2;
+	v24 = 500;
+	do
+		{
+		v32 = 0;
+		v4 = strtok(0, "\r") + 1;
+		v36 = -1;
+		do
+			{
+			v5 = *v4;
+			v6 = 0;
+			while ( v5 != 9 && v5 )
+				{
+				++v6;
+				v5 = v4[v6];
+				}
+			v23 = (int)&v4[v6];
+			if ( !v4[v6] )
+				v32 = 1;
+			v4[v6] = 0;
+			if ( v6 )
+				{
+				switch ( v36 )
+					{
+				case 0:
+					v7 = RemoveQuotes(v4);
+					*((int *)pHouse - 5) = (int)v7;
+					*(int *)Str = (int)v7;
+					break;
+				case 1:
+					*((int *)pHouse - 4) = atoi(v4);
+					break;
+				case 5:
+					*(int *)pHouse = atoi(v4);
+					break;
+				case 6:
+					*((int *)pHouse + 1) = atoi(v4);
+					break;
+				case 7:
+					*((int *)pHouse + 2) = atoi(v4);
+					break;
+				case 8:
+					*((int *)pHouse + 3) = *v4 == 121;
+					break;
+				case 9:
+					*((int *)pHouse + 5) = atoi(v4);
+					break;
+				case 10:
+					*((int *)pHouse + 6) = atoi(v4);
+					break;
+				case 11:
+					*((int *)pHouse + 7) = atoi(v4);
+					break;
+				case 12:
+					*((int *)pHouse + 8) = atoi(v4);
+					break;
+				case 13:
+					*((int *)pHouse + 9) = atoi(v4);
+					break;
+				case 14:
+					*((int *)pHouse + 10) = atoi(v4);
+					break;
+				default:
+					break;
+					}
+				}
+			++v36;
+			v4 = (char *)(v23 + 1);
+			}
+			while ( v36 + 1 <= 15 && !v32 );
+			Str += 4;
+			pHouse += 76;
+			--v24;
+		}
+		while ( v24 );
+		pNPCStats->uNumNewNPCs = 501;
+		v8 = (char *)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
+		pNPCStats->pNPCGreetTXT_Raw = v8;
+		strtok(v8, "\r");
+		pGreetings = pNPCStats->pNPCGreetings;
+		v25 = 205;
+		do
+			{
+			v37 = 0;
+			v33 = 0;
+			v9 = strtok(0, "\r") + 1;
+			do
+				{
+				v10 = *v9;
+				v11 = 0;
+				while ( v10 != 9 && v10 )
+					{
+					++v11;
+					v10 = v9[v11];
+					}
+				v12 = (int)&v9[v11];
+				if ( !v9[v11] )
+					v33 = 1;
+				*(char *)v12 = 0;
+				if ( v11 )
+					{
+					if ( v37 == 1 )
+						{
+						pGreetings->pGreeting1 = (char *)RemoveQuotes(v9);
+						}
+					else
+						{
+						if ( v37 == 2 )
+							pGreetings->pGreeting2 = (char *)RemoveQuotes(v9);
+						}
+					}
+				++v37;
+				v9 = (char *)(v12 + 1);
+				}
+				while ( v37 <= 2 && !v33 );
+				++pGreetings;
+				--v25;
+			}
+			while ( v25 );
+			v13 = (char *)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
+			pNPCStats->pNCPGroupTXT_Raw = v13;
+			strtok(v13, "\r");
+			pGroups = pNPCStats->pGroups;
+			v26 = 51;
+			do
+				{
+				v14 = strtok(0, "\r") + 1;
+				v38 = 0;
+				v34 = 0;
+				do
+					{
+					v15 = *v14;
+					v16 = 0;
+					while ( v15 != 9 && v15 )
+						{
+						++v16;
+						v15 = v14[v16];
+						}
+					v17 = (int)&v14[v16];
+					if ( !v14[v16] )
+						v34 = 1;
+					*(char *)v17 = 0;
+					if ( v16 && v38 == 1 )
+						*pGroups = atoi(v14);
+					++v38;
+					v14 = (char *)(v17 + 1);
+					}
+					while ( v38 <= 1 && !v34 );
+					++pGroups;
+					--v26;
+				}
+				while ( v26 );
+				v18 = (char *)pEvents_LOD->LoadRaw("npcnews.txt", 0);
+				pNPCStats->pNPCNewsTXT_Raw = v18;
+				strtok(v18, "\r");
+				pCatchPhrase = pNPCStats->pCatchPhrases;
+				v27 = 51;
+				do
+					{
+					v19 = strtok(0, "\r") + 1;
+					v39 = 0;
+					v35 = 0;
+					do
+						{
+						v20 = *v19;
+						v21 = 0;
+						while ( v20 != 9 && v20 )
+							{
+							++v21;
+							v20 = v19[v21];
+							}
+						v22 = (int)&v19[v21];
+						if ( !v19[v21] )
+							v35 = 1;
+						*(char *)v22 = 0;
+						if ( v21 && v39 == 1 )
+							*pCatchPhrase = (char *)RemoveQuotes(v19);
+						++v39;
+						v19 = (char *)(v22 + 1);
+						}
+						while ( v39 <= 1 && !v35 );
+						++pCatchPhrase;
+						--v27;
+					}
+					while ( v27 );
+	}
+
+//----- (0047702F) --------------------------------------------------------
+void NPCStats::Initialize()
+	{
+	//NPCStats *v1; // edi@1
+	char *v2; // ebx@1
+	//char *v3; // eax@1
+	char *v4; // ebx@3
+	char v5; // al@4
+	int v6; // ecx@4
+	//char *v7; // eax@18
+	char *v8; // ebx@18
+	char *v9; // ecx@19
+	char v10; // dl@20
+	int v11; // eax@20
+	char v12; // zf@41
+	signed int v13; // [sp+Ch] [bp-14h]@18
+	int v14; // [sp+10h] [bp-10h]@4
+	int v15; // [sp+10h] [bp-10h]@24
+	char *v16; // [sp+14h] [bp-Ch]@1
+	signed int v17; // [sp+14h] [bp-Ch]@19
+	unsigned int v18; // [sp+18h] [bp-8h]@1
+	char *v19; // [sp+18h] [bp-8h]@18
+	signed int v20; // [sp+1Ch] [bp-4h]@3
+	signed int v21; // [sp+1Ch] [bp-4h]@19
+	//v1 = this;
+
+	Initialize1();
+	Initialize2();
+
+	InitializeQuests();
+	InitializeAutonotes();
+	InitializeAwards();
+	InitializeTransitions();
+	InitializeMerchants();
+	InitializeScrolls();
+	v2 = 0;
+	field_17FC0 = 0;
+	pNPCNamesTXT_Raw = 0;
+	//v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
+	pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
+	strtok(pNPCNamesTXT_Raw, "\r");
+	v18 = 0;
+	v16 = (char *)pNPCNames;
+	while ( 1 )
+		{
+		v4 = strtok(v2, "\r") + 1;
+		v20 = 0;
+		do
+			{
+			v5 = *v4;
+			v6 = 0;
+			v14 = 0;
+			if ( *v4 == 9 )
+				goto LABEL_45;
+			do
+				{
+				if ( !v5 )
+					break;
+				if ( v5 == 10 )
+					break;
+				++v6;
+				v14 = v6;
+				v5 = v4[v6];
+				}
+				while ( v5 != 9 );
+				if ( v6 )
+					{
+					v4[v6] = 0;
+					if ( v20 )
+						{
+						if ( v20 == 1 )
+							*((int *)v16 + 1) = (int)RemoveQuotes(v4);
+						}
+					else
+						{
+						*(int *)v16 = (int)RemoveQuotes(v4);
+						}
+					}
+				else
+					{
+LABEL_45:
+					if ( v20 == 1 && !uNumNPCNames[1] )
+						uNumNPCNames[1] = v18;
+					}
+				++v20;
+				v4 += v14 + 1;
+			}
+			while ( v20 <= 1 );
+			++v18;
+			v16 += 8;
+			if ( (signed int)v18 >= 540 )
+				break;
+			v2 = 0;
+		}
+	pNPCProfTXT_Raw = 0;
+	uNumNPCNames[0] = v18;
+	//v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
+	pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
+	strtok(pNPCProfTXT_Raw, "\r");
+	strtok(0, "\r");
+	strtok(0, "\r");
+	strtok(0, "\r");
+	v8 = (char *)&pProfessions[0].pJoinText;
+	v19 = (char *)&pProfessions[0].pJoinText;
+	v13 = 58;
+	do
+		{
+		v21 = 0;
+		v9 = strtok(0, "\r") + 1;
+		v17 = 0;
+		do
+			{
+			v10 = *v9;
+			v11 = 0;
+			if ( *v9 != 9 )
+				{
+				do
+					{
+					if ( !v10 )
+						break;
+					++v11;
+					v10 = v9[v11];
+					}
+					while ( v10 != 9 );
+					v8 = v19;
+				}
+			v15 = (int)&v9[v11];
+			if ( !v9[v11] )
+				v17 = 1;
+			*(char *)v15 = 0;
+			if ( v11 )
+				{
+				switch ( v21 )
+					{
+				case 2:
+					*((int *)v8 - 3) = atoi(v9);
+					break;
+				case 3:
+					*((int *)v8 - 1) = (int)RemoveQuotes(v9);
+					break;
+				case 4:
+					*((int *)v8 - 2) = (int)RemoveQuotes(v9);
+					break;
+				case 5:
+					*(int *)v8 = (int)RemoveQuotes(v9);
+					break;
+				case 6:
+					*((int *)v8 + 1) = (int)RemoveQuotes(v9);
+					break;
+					}
+				}
+			else
+				{
+				if ( !v21 )
+					v17 = 1;
+				}
+			++v21;
+			v9 = (char *)(v15 + 1);
+			}
+			while ( v21 <= 6 && !v17 );
+			v8 += 20;
+			v12 = v13-- == 1;
+			v19 = v8;
+		}
+		while ( !v12 );
+		uNumNPCProfessions = 59;
+	}
+
+//----- (00477266) --------------------------------------------------------
+void NPCStats::Release()
+	{
+	NPCStats *v1; // esi@1
+	void *v2; // ST00_4@1
+	int v3; // ebx@1
+
+	v1 = this;
+	pAllocator->FreeChunk(this->pNPCTopicTXT_Raw);
+	v2 = v1->pNPCTextTXT_Raw;
+	v1->pNPCNewsTXT_Raw = 0;
+	pAllocator->FreeChunk(v2);
+	v1->pNPCNewsTXT_Raw = 0;
+	pAllocator->FreeChunk(0);
+	v1->pNPCNewsTXT_Raw = 0;
+	pAllocator->FreeChunk(v1->pNPCProfTXT_Raw);
+	v1->pNPCProfTXT_Raw = 0;
+	pAllocator->FreeChunk(v1->pNPCNamesTXT_Raw);
+	v1->pNPCNamesTXT_Raw = 0;
+	pAllocator->FreeChunk(v1->pNPCDataTXT_Raw);
+	v1->pNPCDataTXT_Raw = 0;
+	pAllocator->FreeChunk(v1->pNPCDistTXT_Raw);
+	v1->pNPCDistTXT_Raw = 0;
+	v3 = (int)&v1->pNPCGreetTXT_Raw;
+	pAllocator->FreeChunk(v1->pNPCGreetTXT_Raw);
+	v1 = (NPCStats *)((char *)v1 + 98296);
+	*(int *)v3 = 0;
+	pAllocator->FreeChunk(v1->pNPCData[0].pName);
+	v1->pNPCData[0].pName = 0;
+	}
+
+//----- (0047730C) --------------------------------------------------------
+int __fastcall const_1(int a1, int)
+	{
+	return 1;
+	}
+// 47730C: using guessed type int __stdcall const_1(int);
+
+//----- (0047732C) --------------------------------------------------------
+bool NPCStats::InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5)
+	{
+	//NPCStats *v5; // ebx@1
+	signed __int64 v6; // qax@1
+	int v7; // esi@1
+	int v8; // edx@1
+	NPCData *v9; // edi@1
+	int v10; // eax@1
+	//int v11; // eax@23
+	int v12; // ecx@23
+	int v13; // edx@28
+	int v14; // esi@37
+	int v15; // edx@37
+	int v16; // ecx@37
+	int v17; // eax@37
+	int v18; // edx@37
+	signed int result; // eax@39
+	int v20; // [sp+Ch] [bp-Ch]@1
+	signed int v21; // [sp+10h] [bp-8h]@1
+	signed int v22; // [sp+14h] [bp-4h]@1
+	int v23; // [sp+24h] [bp+Ch]@1
+
+
+	v23 = a3 - 1;
+	//v5 = this;
+	v6 = (signed __int64)((double)v23 * -0.33333334);
+	v7 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 28];
+	v20 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 116];
+	v8 = rand() % uNumNPCNames[v7];
+	v9 = a2;
+	a2->uSex = v7;
+	a2->pName = pNPCNames[v8][v7];
+	v10 = 0;
+	v22 = 0;
+	v21 = 0;
+
+	while ( 1 )
+		{
+		if ( v20 == v10 )
+			{
+			if ( v7 == v10 )
+				{
+				v23 = 2;
+				a2 = (NPCData *)100;
+				}
+			else
+				{
+				if ( v7 - v10 == 1 )
+					{
+					v23 = 201;
+					a2 = (NPCData *)250;
+					}
+				}
+			}
+		else
+			{
+			switch ( v20 - v10 )
+				{
+			case 1:
+				if ( v7 == v10 )
+					{
+					v23 = 400;
+					a2 = (NPCData *)430;
+					}
+				else
+					{
+					if ( v7 - v10 == 1 )
+						{
+						v23 = 460;
+						a2 = (NPCData *)490;
+						}
+					}
+				break;
+			case 2:
+				if ( v7 == v10 )
+					{
+					v23 = 500;
+					a2 = (NPCData *)520;
+					}
+				else
+					{
+					if ( v7 - v10 == 1 )
+						{
+						v23 = 530;
+						a2 = (NPCData *)550;
+						}
+					}
+				break;
+			case 3:
+				if ( v7 == v10 )
+					{
+					v23 = 300;
+					a2 = (NPCData *)330;
+					}
+				else
+					{
+					if ( v7 - v10 == 1 )
+						{
+						v23 = 360;
+						a2 = (NPCData *)387;
+						}
+					}
+				break;
+				}
+			}
+		v12 = v23 + rand() % ((int)a2 - v23 + 1);
+		if ( const_1(v12, v7) == 1 )
+			v21 = 1;
+		++v22;
+		if ( v22 >= 4 )
+			{
+			v12 = v23;
+			v21 = 1;
+			}
+		if ( v21 )
+			break;
+		v10 = 0;
+		}
+
+	v9->uPortraitID = v12;
+	v9->uFlags = 0;
+	v9->fame = 0;
+	v13 = rand() % 100 + 1;
+
+	if ( v13 >= 60 )
+		{
+		if ( v13 >= 90 )
+			{
+			if ( v13 >= 95 )
+				{
+				if ( v13 >= 98 )
+					v9->rep = -600;
+				else
+					v9->rep = 400;
+				}
+			else
+				{
+				v9->rep = -300;
+				}
+			}
+		else
+			{
+			v9->rep = 200;
+			}
+		}
+	else
+		{
+		v9->rep = 0;
+		}
+
+	//v14 = (int)((char *)v5 + 64 * a5);
+	//v15 = rand() % *(_DWORD *)(v14 + 91460);
+	v15 = rand() % array_16544[a5].field_0;
+	v16 = 0;
+	v17 = 0;
+	v18 = v15 + 1;
+
+	if ( v18 > 0 )
+		{
+		do
+		//v14 += *(char *)(v14 + v17++ + 0x16548);
+		v16 += array_16544[a5].field_4[v17++];
+		while ( v16 < v18 );
+		}
+	v9->uProfession = v17 - 1;
+	v9->house = a4;
+	v9->field_24 = 1;
+	v9->joins = 1;
+	return true;
+	}
+
+
+//----- (00476387) --------------------------------------------------------
+bool __cdecl sub_476387()
+	{
+	return (pNPCStats->pNewNPCData[57].uFlags & 0x80) != 0;
+	}
+
+//----- (00476395) --------------------------------------------------------
+//0x26 Wizard eye at skill level 2
+bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
+	{
+	bool result; // eax@2
+	signed int v2; // esi@3
+	char *v3; // eax@4
+
+	if ( bNoNPCHiring == 1 )
+		return 0;
+	v2 = 0;
+	if ( (signed int)pNPCStats->uNumNewNPCs <= 0 )
+		{
+LABEL_8:
+		result = 0;
+		if ( pParty->pHirelings[0].uProfession != uProfession )
+			{
+			LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession;
+			return result;
+			}
+		}
+	else
+		{
+		v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
+		while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) )
+			{
+			++v2;
+			v3 += 76;
+			if ( v2 >= (signed int)pNPCStats->uNumNewNPCs )
+				goto LABEL_8;
+			}
+		result = 0;
+		}
+	++result;
+	return result;
+	}
+// 6BE3C5: using guessed type char bNoNPCHiring;
+
+//----- (004763E0) --------------------------------------------------------
+void  InitializeAwards()
+	{
+
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	if ( pAwardsTXT_Raw )
+		pAllocator->FreeChunk(pAwardsTXT_Raw);
+	pAwardsTXT_Raw = NULL;
+	pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
+	strtok(pAwardsTXT_Raw, "\r");
+
+	for (i=1; i<104; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if (decode_step==1)
+					pAwards[i].pText=RemoveQuotes(test_string);
+				else if (decode_step==2)
+					pAwards[i].uSort=atoi(test_string);
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<3)&&!break_loop);
+		}
+
+	}
+// 7241C8: using guessed type int dword_7241C8;
+
+//----- (004764C2) --------------------------------------------------------
+void  InitializeScrolls()
+	{
+
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	if ( pScrollsTXT_Raw )
+		pAllocator->FreeChunk(pScrollsTXT_Raw);
+	pScrollsTXT_Raw = NULL;
+	pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
+	strtok(pScrollsTXT_Raw, "\r");
+	for (i=0; i<82; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if ( decode_step == 1)
+					pScrolls[i]=RemoveQuotes(test_string);
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
+	}
+
+
+//----- (00476590) --------------------------------------------------------
+void  InitializeMerchants()
+	{
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	if ( pMerchantsTXT_Raw )
+		pAllocator->FreeChunk(pMerchantsTXT_Raw);
+	pMerchantsTXT_Raw = NULL;
+	pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
+	strtok(pMerchantsTXT_Raw, "\r");
+
+	for (i=0; i<7; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 1:
+					pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
+					break;
+				case 2:
+					pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
+					break;
+				case 3:
+					pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); 
+					break;
+				case 4:
+					pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); 
+					break;
+					}
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<5)&&!break_loop);
+		}
+
+	}
+
+//----- (00476682) --------------------------------------------------------
+void InitializeTransitions()
+	{
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	if ( pTransitionsTXT_Raw )
+		pAllocator->FreeChunk(pTransitionsTXT_Raw);
+	pTransitionsTXT_Raw = NULL;
+	pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
+	strtok(pTransitionsTXT_Raw, "\r");
+
+	for (i=0; i<464; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if ( decode_step == 1)
+					pTransitionStrings[i]=RemoveQuotes(test_string);
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
+	}
+
+//----- (00476750) --------------------------------------------------------
+void __cdecl InitializeAutonotes()
+	{
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	if ( pAutonoteTXT_Raw )
+		pAllocator->FreeChunk(pAutonoteTXT_Raw);
+	pAutonoteTXT_Raw = 0;
+	pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
+	strtok(pAutonoteTXT_Raw, "\r");
+
+	for (i=0; i<195; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case  1:
+					pAutonoteTxt[i].pText=RemoveQuotes(test_string);
+					break;
+				case  2:
+					{
+					if ( !_strcmpi(test_string, "potion"))
+						{
+						pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
+						break;
+						}
+					if ( !_strcmpi(test_string, "stat") )
+						{
+						pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
+						break;
+						}
+					if ( !_strcmpi(test_string, "seer") )
+						{
+						pAutonoteTxt[i].eType = AUTONOTE_SEER;
+						break;
+						}
+					if ( !_strcmpi(test_string, "obelisk") )
+						{
+						pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
+						break;
+						}
+					if ( !_strcmpi(test_string, "teacher") )
+						{
+						pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
+						break;
+						}
+					pAutonoteTxt[i].eType =AUTONOTE_MISC;
+					break;
+					}
+					}
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<3)&&!break_loop);
+		}
+	}
+
+
+//----- (004768A9) --------------------------------------------------------
+void __cdecl InitializeQuests()
+	{
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	if ( pQuestsTXT_Raw )
+		pAllocator->FreeChunk(pQuestsTXT_Raw);
+	pQuestsTXT_Raw = NULL;
+	pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
+	strtok(pQuestsTXT_Raw, "\r");
+
+	for (i=0; i<512; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if ( decode_step == 1)
+					pQuestTable[i] =RemoveQuotes(test_string);
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
+	}
+
--- a/NPC.h	Mon Feb 18 03:59:31 2013 +0200
+++ b/NPC.h	Mon Feb 18 08:47:21 2013 +0400
@@ -126,3 +126,5 @@
 };
 #pragma pack(pop)
 
+bool __cdecl sub_476387();
+bool CheckHiredNPCSpeciality(unsigned int uProfession);
--- a/mm7_2.cpp	Mon Feb 18 03:59:31 2013 +0200
+++ b/mm7_2.cpp	Mon Feb 18 08:47:21 2013 +0400
@@ -13392,7 +13392,7 @@
   int a2[4]; // [sp+1Ch] [bp-10h]@15
 
   char test[1024];
-  sprintfex(test, "^Pi[%s]: çíàõàð^R[ü;êà;]", "Çîëòàí");
+  //sprintfex(test, "^Pi[%s]: çíàõàð^R[ü;êà;]", "Çîëòàí");
 
   if (pCmdLine && *pCmdLine)
   {
--- a/mm7_3.cpp	Mon Feb 18 03:59:31 2013 +0200
+++ b/mm7_3.cpp	Mon Feb 18 08:47:21 2013 +0400
@@ -4703,1188 +4703,8 @@
   return result;
 }
 
-//----- (00476387) --------------------------------------------------------
-bool __cdecl sub_476387()
-{
-  return (pNPCStats->pNewNPCData[57].uFlags & 0x80) != 0;
-}
-
-//----- (00476395) --------------------------------------------------------
-//0x26 Wizard eye at skill level 2
-bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
-{
-  bool result; // eax@2
-  signed int v2; // esi@3
-  char *v3; // eax@4
-
-  if ( bNoNPCHiring == 1 )
-    return 0;
-  v2 = 0;
-  if ( (signed int)pNPCStats->uNumNewNPCs <= 0 )
-  {
-LABEL_8:
-    result = 0;
-    if ( pParty->pHirelings[0].uProfession != uProfession )
-    {
-      LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession;
-      return result;
-    }
-  }
-  else
-  {
-    v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
-    while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) )
-    {
-      ++v2;
-      v3 += 76;
-      if ( v2 >= (signed int)pNPCStats->uNumNewNPCs )
-        goto LABEL_8;
-    }
-    result = 0;
-  }
-  ++result;
-  return result;
-}
-// 6BE3C5: using guessed type char bNoNPCHiring;
-
-//----- (004763E0) --------------------------------------------------------
-void  InitializeAwards()
-{
-  
-  int i;
-  char* test_string;
-  unsigned char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-
-  if ( pAwardsTXT_Raw )
-    pAllocator->FreeChunk(pAwardsTXT_Raw);
-  pAwardsTXT_Raw = NULL;
-  pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
-  strtok(pAwardsTXT_Raw, "\r");
-
-  for (i=1; i<104; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			   if (decode_step==1)
-				  pAwards[i].pText=RemoveQuotes(test_string);
-			   else if (decode_step==2)
-				  pAwards[i].uSort=atoi(test_string);
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<3)&&!break_loop);
-	  }
-
-}
-// 7241C8: using guessed type int dword_7241C8;
-
-//----- (004764C2) --------------------------------------------------------
-void  InitializeScrolls()
-{
-  
-  int i;
-  char* test_string;
-  unsigned char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-
-  if ( pScrollsTXT_Raw )
-    pAllocator->FreeChunk(pScrollsTXT_Raw);
-  pScrollsTXT_Raw = NULL;
-  pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
-  strtok(pScrollsTXT_Raw, "\r");
-  for (i=0; i<82; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  if ( decode_step == 1)
-				 pScrolls[i]=RemoveQuotes(test_string);
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<2)&&!break_loop);
-	  }
-}
-
-
-//----- (00476590) --------------------------------------------------------
-void  InitializeMerchants()
-{
-  int i;
-  char* test_string;
-  unsigned char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-
-  if ( pMerchantsTXT_Raw )
-    pAllocator->FreeChunk(pMerchantsTXT_Raw);
-  pMerchantsTXT_Raw = NULL;
-  pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
-  strtok(pMerchantsTXT_Raw, "\r");
-
-  for (i=0; i<7; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-				switch (decode_step)
-					{
-					case 1:
-						pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
-						break;
-					case 2:
-						pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
-						break;
-					case 3:
-						pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); 
-						break;
-					case 4:
-						pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); 
-						break;
-					}
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<5)&&!break_loop);
-	  }
-
-}
-
-//----- (00476682) --------------------------------------------------------
-void InitializeTransitions()
-{
-  int i;
-  char* test_string;
-  unsigned char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-
-  if ( pTransitionsTXT_Raw )
-    pAllocator->FreeChunk(pTransitionsTXT_Raw);
-  pTransitionsTXT_Raw = NULL;
-  pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
-  strtok(pTransitionsTXT_Raw, "\r");
-
-  for (i=0; i<464; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  if ( decode_step == 1)
-				 pTransitionStrings[i]=RemoveQuotes(test_string);
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<2)&&!break_loop);
-	  }
-}
-
-//----- (00476750) --------------------------------------------------------
-void __cdecl InitializeAutonotes()
-{
-  int i;
-  char* test_string;
-  unsigned char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-
-  if ( pAutonoteTXT_Raw )
-    pAllocator->FreeChunk(pAutonoteTXT_Raw);
-  pAutonoteTXT_Raw = 0;
-  pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
-  strtok(pAutonoteTXT_Raw, "\r");
-
-  for (i=0; i<195; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  switch (decode_step)
-				  {
-			  case  1:
-				  pAutonoteTxt[i].pText=RemoveQuotes(test_string);
-				  break;
-			  case  2:
-				  {
-				  if ( !_strcmpi(test_string, "potion"))
-					  {
-					  pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
-					  break;
-					  }
-				  if ( !_strcmpi(test_string, "stat") )
-					  {
-					  pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
-					  break;
-					  }
-				  if ( !_strcmpi(test_string, "seer") )
-					  {
-					  pAutonoteTxt[i].eType = AUTONOTE_SEER;
-					  break;
-					  }
-				  if ( !_strcmpi(test_string, "obelisk") )
-					  {
-					  pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
-					  break;
-					  }
-				  if ( !_strcmpi(test_string, "teacher") )
-					  {
-					  pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
-					  break;
-					  }
-				  pAutonoteTxt[i].eType =AUTONOTE_MISC;
-				  break;
-				  }
-				  }
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<3)&&!break_loop);
-	  }
-}
-
-
-//----- (004768A9) --------------------------------------------------------
-void __cdecl InitializeQuests()
-{
-   int i;
-  char* test_string;
-  unsigned char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-
-  if ( pQuestsTXT_Raw )
-    pAllocator->FreeChunk(pQuestsTXT_Raw);
-  pQuestsTXT_Raw = NULL;
-  pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
-  strtok(pQuestsTXT_Raw, "\r");
-
-  for (i=0; i<512; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  if ( decode_step == 1)
-				 pQuestTable[i] =RemoveQuotes(test_string);
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<2)&&!break_loop);
-	  }
-}
-
-
-
-//----- (00476977) --------------------------------------------------------
-void NPCStats::Initialize2()
-{
-  int i;
-  char* test_string;
-  unsigned char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-
-
-  if (pNPCTextTXT_Raw)
-    pAllocator->FreeChunk(pNPCTextTXT_Raw);
-  pNPCTextTXT_Raw =NULL;
-  pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
-  strtok(pNPCTextTXT_Raw, "\r");
-
-  for (i=0; i<789; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  if ( decode_step == 1)
-				 pNPCTopics[i].pText =RemoveQuotes(test_string);
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<2)&&!break_loop);
-	  }
-
-  if (pNPCTopicTXT_Raw)
-    pAllocator->FreeChunk(pNPCTopicTXT_Raw);
-  pNPCTopicTXT_Raw =NULL;
-  pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
-  strtok(pNPCTopicTXT_Raw, "\r");
-
-   for (i=0; i<579; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  if ( decode_step == 1)
-				 pNPCTopics[i].pTopic = RemoveQuotes(test_string);
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<2)&&!break_loop);
-	  }
-
-  if (pNPCDistTXT_Raw)
-    pAllocator->FreeChunk(pNPCDistTXT_Raw);
-  pNPCDistTXT_Raw = NULL;
-  pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
-  strtok(pNPCDistTXT_Raw, "\r");
-  strtok(NULL, "\r");
-
-   for (i=1; i<59; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			   if ((decode_step>0)&&(decode_step<77))
-				   {
-				   array_16544[decode_step].field_4[i]=atoi(test_string);
-				   }
-			   else if (decode_step==0)
-				   {
-				  array_16544[0].field_4[i]=10;
-				   }
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<78)&&!break_loop);
-	  }
-
-  for (i=0; i<78; ++i)
-	  {
-	  array_16544[i].field_0=0;
-	  for (int ii=1; ii<59; ++ii)
-		  {
-		  array_16544[i].field_0+=array_16544[i].field_4[ii];
-		  }
-	  }
-
-  if (pNPCDistTXT_Raw)
-  {
-    pAllocator->FreeChunk(pNPCDistTXT_Raw);
-    pNPCDistTXT_Raw = NULL;
-  }
-}
-
-//----- (00476C60) --------------------------------------------------------
-void NPCStats::_476C60()
-{
-  for (uint i = 1; i < uNumNewNPCs; ++i)
-    pNewNPCData[i].pName = pNPCNames2[i - 1];
-
-  if (pParty->pHirelings[0].pName)
-    pParty->pHirelings[0].pName = pParty->pHireling1Name;
-  if (pParty->pHirelings[1].pName)
-    pParty->pHirelings[1].pName = pParty->pHireling2Name;
-}
-
-//----- (00476CB5) --------------------------------------------------------
-void NPCStats::Initialize1()
-{
-  NPCStats *pNPCStats; // esi@1
-  char *pRaw; // eax@1
-  char *pHouse; // edi@1
-  char *v4; // eax@2
-  char v5; // dl@3
-  int v6; // ecx@3
-  char *v7; // eax@11
-  char *v8; // eax@26
-  char *v9; // ecx@27
-  char v10; // dl@28
-  int v11; // eax@28
-  int v12; // edi@32
-  char *v13; // eax@42
-  char *v14; // eax@43
-  char v15; // dl@44
-  int v16; // ecx@44
-  int v17; // edi@48
-  char *v18; // eax@56
-  char *v19; // eax@57
-  char v20; // cl@58
-  int v21; // edi@58
-  int v22; // esi@62
-  int v23; // [sp+Ch] [bp-14h]@7
-  signed int v24; // [sp+10h] [bp-10h]@1
-  signed int v25; // [sp+10h] [bp-10h]@26
-  signed int v26; // [sp+10h] [bp-10h]@42
-  signed int v27; // [sp+10h] [bp-10h]@56
-  char *Str; // [sp+14h] [bp-Ch]@1
-  NPCGreeting *pGreetings; // [sp+14h] [bp-Ch]@26
-  unsigned __int16 *pGroups; // [sp+14h] [bp-Ch]@42
-  char **pCatchPhrase; // [sp+14h] [bp-Ch]@56
-  signed int v32; // [sp+18h] [bp-8h]@2
-  signed int v33; // [sp+18h] [bp-8h]@27
-  signed int v34; // [sp+18h] [bp-8h]@43
-  signed int v35; // [sp+18h] [bp-8h]@57
-  signed int v36; // [sp+1Ch] [bp-4h]@2
-  signed int v37; // [sp+1Ch] [bp-4h]@27
-  signed int v38; // [sp+1Ch] [bp-4h]@43
-  signed int v39; // [sp+1Ch] [bp-4h]@57
-
-  pNPCStats = this;
-  pRaw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
-  pNPCStats->pNPCDataTXT_Raw = pRaw;
-  strtok(pRaw, "\r");
-  strtok(0, "\r");
-  pHouse = (char *)&pNPCStats->pNPCData[1].house;
-  Str = (char *)pNPCStats->pNPCNames2;
-  v24 = 500;
-  do
-  {
-    v32 = 0;
-    v4 = strtok(0, "\r") + 1;
-    v36 = -1;
-    do
-    {
-      v5 = *v4;
-      v6 = 0;
-      while ( v5 != 9 && v5 )
-      {
-        ++v6;
-        v5 = v4[v6];
-      }
-      v23 = (int)&v4[v6];
-      if ( !v4[v6] )
-        v32 = 1;
-      v4[v6] = 0;
-      if ( v6 )
-      {
-        switch ( v36 )
-        {
-          case 0:
-            v7 = RemoveQuotes(v4);
-            *((int *)pHouse - 5) = (int)v7;
-            *(int *)Str = (int)v7;
-            break;
-          case 1:
-            *((int *)pHouse - 4) = atoi(v4);
-            break;
-          case 5:
-            *(int *)pHouse = atoi(v4);
-            break;
-          case 6:
-            *((int *)pHouse + 1) = atoi(v4);
-            break;
-          case 7:
-            *((int *)pHouse + 2) = atoi(v4);
-            break;
-          case 8:
-            *((int *)pHouse + 3) = *v4 == 121;
-            break;
-          case 9:
-            *((int *)pHouse + 5) = atoi(v4);
-            break;
-          case 10:
-            *((int *)pHouse + 6) = atoi(v4);
-            break;
-          case 11:
-            *((int *)pHouse + 7) = atoi(v4);
-            break;
-          case 12:
-            *((int *)pHouse + 8) = atoi(v4);
-            break;
-          case 13:
-            *((int *)pHouse + 9) = atoi(v4);
-            break;
-          case 14:
-            *((int *)pHouse + 10) = atoi(v4);
-            break;
-          default:
-            break;
-        }
-      }
-      ++v36;
-      v4 = (char *)(v23 + 1);
-    }
-    while ( v36 + 1 <= 15 && !v32 );
-    Str += 4;
-    pHouse += 76;
-    --v24;
-  }
-  while ( v24 );
-  pNPCStats->uNumNewNPCs = 501;
-  v8 = (char *)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
-  pNPCStats->pNPCGreetTXT_Raw = v8;
-  strtok(v8, "\r");
-  pGreetings = pNPCStats->pNPCGreetings;
-  v25 = 205;
-  do
-  {
-    v37 = 0;
-    v33 = 0;
-    v9 = strtok(0, "\r") + 1;
-    do
-    {
-      v10 = *v9;
-      v11 = 0;
-      while ( v10 != 9 && v10 )
-      {
-        ++v11;
-        v10 = v9[v11];
-      }
-      v12 = (int)&v9[v11];
-      if ( !v9[v11] )
-        v33 = 1;
-      *(char *)v12 = 0;
-      if ( v11 )
-      {
-        if ( v37 == 1 )
-        {
-          pGreetings->pGreeting1 = (char *)RemoveQuotes(v9);
-        }
-        else
-        {
-          if ( v37 == 2 )
-            pGreetings->pGreeting2 = (char *)RemoveQuotes(v9);
-        }
-      }
-      ++v37;
-      v9 = (char *)(v12 + 1);
-    }
-    while ( v37 <= 2 && !v33 );
-    ++pGreetings;
-    --v25;
-  }
-  while ( v25 );
-  v13 = (char *)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
-  pNPCStats->pNCPGroupTXT_Raw = v13;
-  strtok(v13, "\r");
-  pGroups = pNPCStats->pGroups;
-  v26 = 51;
-  do
-  {
-    v14 = strtok(0, "\r") + 1;
-    v38 = 0;
-    v34 = 0;
-    do
-    {
-      v15 = *v14;
-      v16 = 0;
-      while ( v15 != 9 && v15 )
-      {
-        ++v16;
-        v15 = v14[v16];
-      }
-      v17 = (int)&v14[v16];
-      if ( !v14[v16] )
-        v34 = 1;
-      *(char *)v17 = 0;
-      if ( v16 && v38 == 1 )
-        *pGroups = atoi(v14);
-      ++v38;
-      v14 = (char *)(v17 + 1);
-    }
-    while ( v38 <= 1 && !v34 );
-    ++pGroups;
-    --v26;
-  }
-  while ( v26 );
-  v18 = (char *)pEvents_LOD->LoadRaw("npcnews.txt", 0);
-  pNPCStats->pNPCNewsTXT_Raw = v18;
-  strtok(v18, "\r");
-  pCatchPhrase = pNPCStats->pCatchPhrases;
-  v27 = 51;
-  do
-  {
-    v19 = strtok(0, "\r") + 1;
-    v39 = 0;
-    v35 = 0;
-    do
-    {
-      v20 = *v19;
-      v21 = 0;
-      while ( v20 != 9 && v20 )
-      {
-        ++v21;
-        v20 = v19[v21];
-      }
-      v22 = (int)&v19[v21];
-      if ( !v19[v21] )
-        v35 = 1;
-      *(char *)v22 = 0;
-      if ( v21 && v39 == 1 )
-        *pCatchPhrase = (char *)RemoveQuotes(v19);
-      ++v39;
-      v19 = (char *)(v22 + 1);
-    }
-    while ( v39 <= 1 && !v35 );
-    ++pCatchPhrase;
-    --v27;
-  }
-  while ( v27 );
-}
-
-//----- (0047702F) --------------------------------------------------------
-void NPCStats::Initialize()
-{
-  //NPCStats *v1; // edi@1
-  char *v2; // ebx@1
-  //char *v3; // eax@1
-  char *v4; // ebx@3
-  char v5; // al@4
-  int v6; // ecx@4
-  //char *v7; // eax@18
-  char *v8; // ebx@18
-  char *v9; // ecx@19
-  char v10; // dl@20
-  int v11; // eax@20
-  char v12; // zf@41
-  signed int v13; // [sp+Ch] [bp-14h]@18
-  int v14; // [sp+10h] [bp-10h]@4
-  int v15; // [sp+10h] [bp-10h]@24
-  char *v16; // [sp+14h] [bp-Ch]@1
-  signed int v17; // [sp+14h] [bp-Ch]@19
-  unsigned int v18; // [sp+18h] [bp-8h]@1
-  char *v19; // [sp+18h] [bp-8h]@18
-  signed int v20; // [sp+1Ch] [bp-4h]@3
-  signed int v21; // [sp+1Ch] [bp-4h]@19
-  //v1 = this;
-
-  Initialize1();
-  Initialize2();
-
-  InitializeQuests();
-  InitializeAutonotes();
-  InitializeAwards();
-  InitializeTransitions();
-  InitializeMerchants();
-  InitializeScrolls();
-  v2 = 0;
-  field_17FC0 = 0;
-  pNPCNamesTXT_Raw = 0;
-  //v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
-  pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
-  strtok(pNPCNamesTXT_Raw, "\r");
-  v18 = 0;
-  v16 = (char *)pNPCNames;
-  while ( 1 )
-  {
-    v4 = strtok(v2, "\r") + 1;
-    v20 = 0;
-    do
-    {
-      v5 = *v4;
-      v6 = 0;
-      v14 = 0;
-      if ( *v4 == 9 )
-        goto LABEL_45;
-      do
-      {
-        if ( !v5 )
-          break;
-        if ( v5 == 10 )
-          break;
-        ++v6;
-        v14 = v6;
-        v5 = v4[v6];
-      }
-      while ( v5 != 9 );
-      if ( v6 )
-      {
-        v4[v6] = 0;
-        if ( v20 )
-        {
-          if ( v20 == 1 )
-            *((int *)v16 + 1) = (int)RemoveQuotes(v4);
-        }
-        else
-        {
-          *(int *)v16 = (int)RemoveQuotes(v4);
-        }
-      }
-      else
-      {
-LABEL_45:
-        if ( v20 == 1 && !uNumNPCNames[1] )
-          uNumNPCNames[1] = v18;
-      }
-      ++v20;
-      v4 += v14 + 1;
-    }
-    while ( v20 <= 1 );
-    ++v18;
-    v16 += 8;
-    if ( (signed int)v18 >= 540 )
-      break;
-    v2 = 0;
-  }
-  pNPCProfTXT_Raw = 0;
-  uNumNPCNames[0] = v18;
-  //v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
-  pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
-  strtok(pNPCProfTXT_Raw, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  v8 = (char *)&pProfessions[0].pJoinText;
-  v19 = (char *)&pProfessions[0].pJoinText;
-  v13 = 58;
-  do
-  {
-    v21 = 0;
-    v9 = strtok(0, "\r") + 1;
-    v17 = 0;
-    do
-    {
-      v10 = *v9;
-      v11 = 0;
-      if ( *v9 != 9 )
-      {
-        do
-        {
-          if ( !v10 )
-            break;
-          ++v11;
-          v10 = v9[v11];
-        }
-        while ( v10 != 9 );
-        v8 = v19;
-      }
-      v15 = (int)&v9[v11];
-      if ( !v9[v11] )
-        v17 = 1;
-      *(char *)v15 = 0;
-      if ( v11 )
-      {
-        switch ( v21 )
-        {
-          case 2:
-            *((int *)v8 - 3) = atoi(v9);
-            break;
-          case 3:
-            *((int *)v8 - 1) = (int)RemoveQuotes(v9);
-            break;
-          case 4:
-            *((int *)v8 - 2) = (int)RemoveQuotes(v9);
-            break;
-          case 5:
-            *(int *)v8 = (int)RemoveQuotes(v9);
-            break;
-          case 6:
-            *((int *)v8 + 1) = (int)RemoveQuotes(v9);
-            break;
-        }
-      }
-      else
-      {
-        if ( !v21 )
-          v17 = 1;
-      }
-      ++v21;
-      v9 = (char *)(v15 + 1);
-    }
-    while ( v21 <= 6 && !v17 );
-    v8 += 20;
-    v12 = v13-- == 1;
-    v19 = v8;
-  }
-  while ( !v12 );
-  uNumNPCProfessions = 59;
-}
-
-//----- (00477266) --------------------------------------------------------
-void NPCStats::Release()
-{
-  NPCStats *v1; // esi@1
-  void *v2; // ST00_4@1
-  int v3; // ebx@1
-
-  v1 = this;
-  pAllocator->FreeChunk(this->pNPCTopicTXT_Raw);
-  v2 = v1->pNPCTextTXT_Raw;
-  v1->pNPCNewsTXT_Raw = 0;
-  pAllocator->FreeChunk(v2);
-  v1->pNPCNewsTXT_Raw = 0;
-  pAllocator->FreeChunk(0);
-  v1->pNPCNewsTXT_Raw = 0;
-  pAllocator->FreeChunk(v1->pNPCProfTXT_Raw);
-  v1->pNPCProfTXT_Raw = 0;
-  pAllocator->FreeChunk(v1->pNPCNamesTXT_Raw);
-  v1->pNPCNamesTXT_Raw = 0;
-  pAllocator->FreeChunk(v1->pNPCDataTXT_Raw);
-  v1->pNPCDataTXT_Raw = 0;
-  pAllocator->FreeChunk(v1->pNPCDistTXT_Raw);
-  v1->pNPCDistTXT_Raw = 0;
-  v3 = (int)&v1->pNPCGreetTXT_Raw;
-  pAllocator->FreeChunk(v1->pNPCGreetTXT_Raw);
-  v1 = (NPCStats *)((char *)v1 + 98296);
-  *(int *)v3 = 0;
-  pAllocator->FreeChunk(v1->pNPCData[0].pName);
-  v1->pNPCData[0].pName = 0;
-}
-
-//----- (0047730C) --------------------------------------------------------
-int __fastcall const_1(int a1, int)
-{
-  return 1;
-}
-// 47730C: using guessed type int __stdcall const_1(int);
-
-//----- (0047732C) --------------------------------------------------------
-bool NPCStats::InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5)
-{
-  //NPCStats *v5; // ebx@1
-  signed __int64 v6; // qax@1
-  int v7; // esi@1
-  int v8; // edx@1
-  NPCData *v9; // edi@1
-  int v10; // eax@1
-  //int v11; // eax@23
-  int v12; // ecx@23
-  int v13; // edx@28
-  int v14; // esi@37
-  int v15; // edx@37
-  int v16; // ecx@37
-  int v17; // eax@37
-  int v18; // edx@37
-  signed int result; // eax@39
-  int v20; // [sp+Ch] [bp-Ch]@1
-  signed int v21; // [sp+10h] [bp-8h]@1
-  signed int v22; // [sp+14h] [bp-4h]@1
-  int v23; // [sp+24h] [bp+Ch]@1
-
-
-  v23 = a3 - 1;
-  //v5 = this;
-  v6 = (signed __int64)((double)v23 * -0.33333334);
-  v7 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 28];
-  v20 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 116];
-  v8 = rand() % uNumNPCNames[v7];
-  v9 = a2;
-  a2->uSex = v7;
-  a2->pName = pNPCNames[v8][v7];
-  v10 = 0;
-  v22 = 0;
-  v21 = 0;
-
-  while ( 1 )
-  {
-    if ( v20 == v10 )
-    {
-      if ( v7 == v10 )
-      {
-        v23 = 2;
-        a2 = (NPCData *)100;
-      }
-      else
-      {
-        if ( v7 - v10 == 1 )
-        {
-          v23 = 201;
-          a2 = (NPCData *)250;
-        }
-      }
-    }
-    else
-    {
-      switch ( v20 - v10 )
-      {
-        case 1:
-          if ( v7 == v10 )
-          {
-            v23 = 400;
-            a2 = (NPCData *)430;
-          }
-          else
-          {
-            if ( v7 - v10 == 1 )
-            {
-              v23 = 460;
-              a2 = (NPCData *)490;
-            }
-          }
-          break;
-        case 2:
-          if ( v7 == v10 )
-          {
-            v23 = 500;
-            a2 = (NPCData *)520;
-          }
-          else
-          {
-            if ( v7 - v10 == 1 )
-            {
-              v23 = 530;
-              a2 = (NPCData *)550;
-            }
-          }
-          break;
-        case 3:
-          if ( v7 == v10 )
-          {
-            v23 = 300;
-            a2 = (NPCData *)330;
-          }
-          else
-          {
-            if ( v7 - v10 == 1 )
-            {
-              v23 = 360;
-              a2 = (NPCData *)387;
-            }
-          }
-          break;
-      }
-    }
-    v12 = v23 + rand() % ((int)a2 - v23 + 1);
-    if ( const_1(v12, v7) == 1 )
-      v21 = 1;
-    ++v22;
-    if ( v22 >= 4 )
-    {
-      v12 = v23;
-      v21 = 1;
-    }
-    if ( v21 )
-      break;
-    v10 = 0;
-  }
-
-  v9->uPortraitID = v12;
-  v9->uFlags = 0;
-  v9->fame = 0;
-  v13 = rand() % 100 + 1;
-
-  if ( v13 >= 60 )
-  {
-    if ( v13 >= 90 )
-    {
-      if ( v13 >= 95 )
-      {
-        if ( v13 >= 98 )
-          v9->rep = -600;
-        else
-          v9->rep = 400;
-      }
-      else
-      {
-        v9->rep = -300;
-      }
-    }
-    else
-    {
-      v9->rep = 200;
-    }
-  }
-  else
-  {
-    v9->rep = 0;
-  }
-
-  //v14 = (int)((char *)v5 + 64 * a5);
-  //v15 = rand() % *(_DWORD *)(v14 + 91460);
-  v15 = rand() % array_16544[a5].field_0;
-  v16 = 0;
-  v17 = 0;
-  v18 = v15 + 1;
-  
-  if ( v18 > 0 )
-  {
-    do
-      //v14 += *(char *)(v14 + v17++ + 0x16548);
-      v16 += array_16544[a5].field_4[v17++];
-    while ( v16 < v18 );
-  }
-  v9->uProfession = v17 - 1;
-  v9->house = a4;
-  v9->field_24 = 1;
-  v9->joins = 1;
-  return true;
-}
+
+
 // 47730C: using guessed type int __stdcall const_1(int);
 
 //----- (0047752B) --------------------------------------------------------
--- a/mm7_data.h	Mon Feb 18 03:59:31 2013 +0200
+++ b/mm7_data.h	Mon Feb 18 08:47:21 2013 +0400
@@ -2183,14 +2183,8 @@
 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4);
 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4);
 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9);
-bool __cdecl sub_476387();
-bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession);
-void __cdecl InitializeAwards();
-void __cdecl InitializeScrolls();
-void __cdecl InitializeMerchants();
-void __cdecl InitializeTransitions();
-void __cdecl InitializeAutonotes();
-void __cdecl InitializeQuests();
+
+
 int __fastcall const_1(int, int); // weak
 int __cdecl GetPartyReputation();
 void __cdecl sub_4783FA_construct_global_73D150();