annotate NPC.cpp @ 1187:02e2a5c1ebc0

BspRernderer refactoring continued
author Ritor1
date Fri, 07 Jun 2013 11:30:29 +0600
parents 29a8defbad9e
children ab6560001f5b
rev   line source
1165
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
1 #ifdef _MSC_VER
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
3 #endif
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
4
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
5 #include "Allocator.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
6 #include "texts.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
7 #include "LOD.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
8 #include "Autonotes.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
9 #include "Awards.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
10 #include "mm7_data.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
11 #include "MM7.h"
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 949
diff changeset
12 #include "Party.h"
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
13 #include "NPC.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
14
629
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
15 int pDialogueNPCCount;
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
16 struct Texture *pDialogueNPCPortraits[6];
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
17 int uNumDialogueNPCPortraits; // weak
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
18 struct NPCStats *pNPCStats = nullptr;
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
19
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
20 void InitializeAwards();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
21 void InitializeScrolls();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
22 void InitializeMerchants();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
23 void InitializeTransitions();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
24 void InitializeAutonotes();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
25 void InitializeQuests();
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
26 bool CheckPortretAgainstSex(int portret_num, int sex);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
27
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
28 //----- (004459F9) --------------------------------------------------------
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
29 NPCData *__fastcall GetNPCData(signed int npcid)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
30 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
31 unsigned int v1; // esi@1
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
32 NPCData *result; // eax@5
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
33 int v3; // esi@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
34 int v4; // ecx@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
35 //int v5; // edx@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
36 //NPCData *v6; // eax@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
37 char *v7; // ebx@14
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
38 NPCData *v8; // edi@14
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
39 char v9; // al@22
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
40 char v10;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
41 //std::string v10; // [sp-18h] [bp-2Ch]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
42 int v11;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
43 //const char *v11; // [sp-8h] [bp-1Ch]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
44 int v12; // [sp-4h] [bp-18h]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
45 int v13;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
46 char *v14;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
47 //std::string *v13; // [sp+Ch] [bp-8h]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
48 int a3; // [sp+13h] [bp-1h]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
49 int i;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
50
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
51 /*v1 = npcid;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
52 if ( (npcid & 0x80000000u) == 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
53 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
54 if ( (signed int)npcid < 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
55 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
56 if ( (signed int)npcid >= 501 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
57 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
58 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0);
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
59 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
60 return &pNPCStats->pNewNPCData[v1];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
61 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
62 return &pNPCStats->array_13EF4[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
63 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
64 if ( (signed int)npcid >= 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
65 return &pNPCStats->array_13EF4[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
66 if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
67 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
68 result = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
69 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
70 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
71 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
72 v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
73 v4 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
74 v5 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
75 v6 = pParty->pHirelings;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
76 do
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
77 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
78 if ( v6->pName )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
79 pTmpBuf[v4++] = v5;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
80 ++v6;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
81 ++v5;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
82 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
83 while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
84 v13 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
85 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
86 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
87 v7 = &pTmpBuf[v4];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
88 v8 = pNPCStats->pNewNPCData;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
89 do
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
90 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
91 if ( v8->uFlags & 0x80
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
92 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName))
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
93 && (!pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName)) )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
94 *v7++ = (char)v13 + 2;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
95 v13 = (std::string *)((char *)v13 + 1);
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
96 ++v8;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
97 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
98 while ( (signed int)v13 < (signed int)pNPCStats->uNumNewNPCs );
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
99 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
100 v9 = pTmpBuf[v3];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
101 if ( (unsigned __int8)v9 >= 2u )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
102 result = &pNPCStats->pNPCData[(unsigned __int8)v9 + 499];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
103 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
104 result = &pParty->pHirelings[(unsigned __int8)v9];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
105 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
106 return result;*/
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
107 v1 = npcid;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
108 if ( npcid >= 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
109 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
110 if ( npcid < 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
111 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
112 if ( npcid >= 501 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
113 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
114 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0);
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
115 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
116 return &pNPCStats->pNewNPCData[v1];// - 1];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
117 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
118 return &pNPCStats->pAdditionalNPC[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
119 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
120
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
121
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
122 if ( npcid >= 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
123 return &pNPCStats->pAdditionalNPC[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
124 if (sDialogue_SpeakingActorNPC_ID >= 0)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
125 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
126 result = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
127 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
128 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
129 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
130 v3 = abs(sDialogue_SpeakingActorNPC_ID) - 1;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
131 v4 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
132
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
133 for (i = 0; i < 2; ++i)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
134 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
135 if (pParty->pHirelings[i].pName)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
136 pTmpBuf[v4++] = i;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
137 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
138
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
139 if (pNPCStats->uNumNewNPCs > 0)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
140 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
141 for (i = 0; i < pNPCStats->uNumNewNPCs; ++i)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
142 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
143 if (pNPCStats->pNewNPCData[i].Hired())
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
144 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
145 if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName))
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
146 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
147 if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName))
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
148 pTmpBuf[v4++] = i + 2;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
149 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
150 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
151 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
152 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
153
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
154 v9 = pTmpBuf[v3];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
155 if ( v9 >= 2 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
156 result = &pNPCStats->pNPCData[499 + v9];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
157 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
158 result = &pParty->pHirelings[v9];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
159 }
1099
94aff285558e Right click NPC fix
Grumpy7
parents: 1094
diff changeset
160 return result;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
161 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
162
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
163 //----- (00445B2C) --------------------------------------------------------
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
164 struct NPCData * GetNewNPCData( signed int npcid, int* npc_indx )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
165 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
166
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
167 int* v3; // edi@1
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
168 NPCData *result; // eax@5
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
169 int v5; // esi@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
170 int v6; // ecx@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
171 char v11; // al@23
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
172
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
173 v3 = npc_indx;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
174 if ( npcid >= 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
175 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
176 if ( npcid < 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
177 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
178 if ( npcid >= 501 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
179 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
180 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0);
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
181 }
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
182 *v3 = npcid;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
183 return &pNPCStats->pNewNPCData[npcid];
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
184 }
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
185 *npc_indx = npcid - 5000;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
186 return &pNPCStats->pAdditionalNPC[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
187 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
188 if ( npcid >= 5000 )
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
189 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
190 *npc_indx = npcid - 5000;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
191 return &pNPCStats->pAdditionalNPC[npcid - 5000];
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
192 }
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
193 if ( sDialogue_SpeakingActorNPC_ID >= 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
194 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
195 *npc_indx = 0;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
196 result = NULL;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
197 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
198 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
199 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
200 v5 = abs(sDialogue_SpeakingActorNPC_ID) - 1;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
201 v6 = 0;
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
202 for (int i=0; i<2; ++i)
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
203 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
204 if ( pParty->pHirelings[i].pName )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
205 pTmpBuf[v6++] = i;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
206
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
207 }
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
208 for (int i=0; i< pNPCStats->uNumNewNPCs; ++i)
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
209 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
210 if ( pNPCStats->pNewNPCData[i].Hired()
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
211 && (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
212 && (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
213 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
214 pTmpBuf[v6++]=i+2;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
215 }
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
216 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
217 v11 = pTmpBuf[v5];
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
218
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
219 if ( v11 >= 2u )
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
220 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
221 *v3 = v11 - 2;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
222 result = &pNPCStats->pNewNPCData[v11 - 2];
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
223 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
224 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
225 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
226 *v3 = v11;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
227 result = &pParty->pHirelings[v11];
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
228 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
229 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
230 return result;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
231 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
232
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
233 //----- (00476977) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
234 void NPCStats::InitializeNPCText()
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
235 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
236 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
237 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
238 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
239 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
240 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
241 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
242 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
243
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
244 if (pNPCTextTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
245 pAllocator->FreeChunk(pNPCTextTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
246 pNPCTextTXT_Raw =NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
247 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
248 strtok(pNPCTextTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
249
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
250 for (i=0; i<789; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
251 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
252 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
253 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
254 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
255 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
256 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
257 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
258 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
259 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
260 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
261 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
262 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
263 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
264 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
265 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
266 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
267 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
268 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
269 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
270 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
271 pNPCTopics[i].pText =RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
272 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
273 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
274 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
275 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
276 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
277 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
278 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
279 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
280 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
281
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
282 if (pNPCTopicTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
283 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
284 pNPCTopicTXT_Raw =NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
285 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
286 strtok(pNPCTopicTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
287
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
288 for (i=0; i<579; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
289 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
290 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
291 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
292 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
293 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
294 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
295 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
296 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
297 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
298 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
299 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
300 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
301 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
302 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
303 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
304 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
305 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
306 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
307 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
308 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
309 pNPCTopics[i].pTopic = RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
310 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
311 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
312 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
313 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
314 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
315 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
316 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
317 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
318 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
319
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
320 if (pNPCDistTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
321 pAllocator->FreeChunk(pNPCDistTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
322 pNPCDistTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
323 pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
324 strtok(pNPCDistTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
325 strtok(NULL, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
326
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
327 for (i=1; i<59; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
328 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
329 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
330 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
331 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
332 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
333 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
334 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
335 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
336 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
337 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
338 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
339 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
340 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
341 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
342 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
343 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
344 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
345 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
346 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
347 if ((decode_step>0)&&(decode_step<77))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
348 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
349 pProfessionChance[decode_step].professionChancePerArea[i]=atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
350 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
351 else if (decode_step==0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
352 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
353 pProfessionChance[0].professionChancePerArea[i]=10;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
354 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
355 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
356 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
357 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
358 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
359 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
360 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
361 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
362 } while ((decode_step<78)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
363 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
364
825
Ritor1
parents: 781
diff changeset
365 for ( i = 0; i < 77; ++i )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
366 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
367 pProfessionChance[i].uTotalprofChance=0;
825
Ritor1
parents: 781
diff changeset
368 for ( int ii = 1; ii < 59; ++ii )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
369 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
370 pProfessionChance[i].uTotalprofChance+=pProfessionChance[i].professionChancePerArea[ii];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
371 }
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
372 pProfessionChance[i].professionChancePerArea[0]=0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
373 pProfessionChance[i].professionChancePerArea[59]=0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
374 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
375
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
376 if (pNPCDistTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
377 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
378 pAllocator->FreeChunk(pNPCDistTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
379 pNPCDistTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
380 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
381 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
382
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
383 //----- (00476C60) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
384 void NPCStats::_476C60()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
385 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
386 for (unsigned int i = 1; i < uNumNewNPCs; ++i)
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
387 pNewNPCData[i].pName = pNPCUnicNames[i - 1];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
388
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
389 if (pParty->pHirelings[0].pName)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
390 pParty->pHirelings[0].pName = pParty->pHireling1Name;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
391 if (pParty->pHirelings[1].pName)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
392 pParty->pHirelings[1].pName = pParty->pHireling2Name;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
393 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
394
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
395 //----- (00476CB5) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
396 void NPCStats::InitializeNPCData()
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
397 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
398 int i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
399 char* test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
400 unsigned char c;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
401 bool break_loop;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
402 unsigned int temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
403 char* tmp_pos;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
404 int decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
405
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
406 pNPCDataTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
407 strtok(pNPCDataTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
408 strtok(NULL, "\r");
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
409
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
410 for (i=0; i<500; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
411 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
412 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
413 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
414 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
415 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
416 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
417 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
418 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
419 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
420 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
421 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
422 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
423 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
424 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
425 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
426 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
427 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
428 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
429 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
430 switch (decode_step)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
431 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
432 case 1:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
433 pNPCUnicNames[i] = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
434 pNPCData[i+1].pName=pNPCUnicNames[i];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
435 break;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
436 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
437 pNPCData[i+1].uPortraitID = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
438 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
439 case 6:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
440 pNPCData[i+1].Location2D = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
441 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
442 case 7:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
443 pNPCData[i+1].uProfession = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
444 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
445 case 8:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
446 pNPCData[i+1].greet = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
447 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
448 case 9:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
449 pNPCData[i+1].joins = (*test_string == 'y')?1:0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
450 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
451 case 10:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
452 pNPCData[i+1].evt_A = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
453 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
454 case 11:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
455 pNPCData[i+1].evt_B = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
456 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
457 case 12:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
458 pNPCData[i+1].evt_C = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
459 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
460 case 13:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
461 pNPCData[i+1].evt_D = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
462 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
463 case 14:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
464 pNPCData[i+1].evt_E = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
465 break;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
466 case 15:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
467 pNPCData[i+1].evt_F = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
468 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
469 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
470 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
471 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
472 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
473 } while ((decode_step<16)&&!break_loop);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
474 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
475 uNumNewNPCs = 501;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
476 pNPCGreetTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
477 strtok(pNPCGreetTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
478 for (i=0; i<205; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
479 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
480 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
481 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
482 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
483 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
484 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
485 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
486 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
487 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
488 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
489 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
490 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
491 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
492 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
493 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
494 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
495 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
496 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
497 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
498 switch (decode_step)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
499 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
500 case 1:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
501 pNPCGreetings[i].pGreeting1 = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
502 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
503 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
504 pNPCGreetings[i].pGreeting2 = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
505 break;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
506 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
507 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
508 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
509 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
510 } while ((decode_step<3)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
511 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
512
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
513 pNCPGroupTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
514 strtok(pNCPGroupTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
515
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
516 for (i=0; i<51; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
517 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
518 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
519 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
520 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
521 do
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
522 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
523 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
524 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
525 while((c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
526 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
527 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
528 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
529 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
530 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
531 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
532 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
533 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
534 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
535 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
536 if (decode_step==1)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
537 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
538 pGroups[i] = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
539 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
540 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
541 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
542 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
543 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
544 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
545
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
546 pNPCNewsTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcnews.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
547 strtok(pNPCNewsTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
548
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
549
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
550 for (i=0; i<51; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
551 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
552 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
553 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
554 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
555 do
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
556 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
557 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
558 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
559 while((c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
560 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
561 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
562 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
563 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
564 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
565 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
566 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
567 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
568 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
569 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
570 if (decode_step==1)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
571 pCatchPhrases[i] = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
572 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
573 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
574 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
575 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
576 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
577 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
578
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
579 //----- (0047702F) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
580 void NPCStats::Initialize()
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
581 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
582 int i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
583 char* test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
584 unsigned char c;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
585 bool break_loop;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
586 unsigned int temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
587 char* tmp_pos;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
588 int decode_step;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
589
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
590 InitializeNPCData();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
591 InitializeNPCText();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
592 InitializeQuests();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
593 InitializeAutonotes();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
594 InitializeAwards();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
595 InitializeTransitions();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
596 InitializeMerchants();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
597 InitializeScrolls();
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
598
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
599 pNPCNamesTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
600 pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
601 strtok(pNPCNamesTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
602
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
603 uNewlNPCBufPos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
604
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
605 for (i=0; i<540; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
606 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
607 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
608 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
609 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
610 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
611 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
612 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
613 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
614 if (c=='\t')
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
615 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
616 if ( (decode_step == 1)&&(!uNumNPCNames[1]))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
617 uNumNPCNames[1]=i;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
618 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
619 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
620 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
621 while((c!='\n')&&(c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
622 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
623 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
624 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
625 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
626 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
627 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
628 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
629
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
630 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
631 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
632 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
633 if ( decode_step == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
634 pNPCNames[i][0] =RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
635 else if ( decode_step == 1)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
636 pNPCNames[i][1] =RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
637 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
638 else
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
639 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
640 if ( (decode_step == 1)&&(!uNumNPCNames[1]))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
641 uNumNPCNames[1]=i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
642 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
643 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
644 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
645 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
646 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
647 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
648 uNumNPCNames[0] = i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
649
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
650 pNPCProfTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
651 pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
652 strtok(pNPCProfTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
653 strtok(NULL, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
654 strtok(NULL, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
655 strtok(NULL, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
656
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
657 for (i=1; i<59; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
658 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
659 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
660 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
661 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
662 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
663 {
667
8c6c41037c39 profession NPC dialogue fixed
zipi
parents: 659
diff changeset
664 //while (*test_string == '\t') // some steps are separated by multiple \t's
8c6c41037c39 profession NPC dialogue fixed
zipi
parents: 659
diff changeset
665 //++test_string;
652
1ff57450f090 * Some fixes to TravelByTransport
Nomad
parents: 629
diff changeset
666
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
667 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
668 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
669 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
670 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
671 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
672 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
673 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
674 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
675 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
676 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
677 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
678 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
679 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
680 switch(decode_step)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
681 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
682 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
683 pProfessions[i].uHirePrice = atoi(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
684 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
685 case 3:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
686 pProfessions[i].pActionText = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
687 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
688 case 4:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
689 pProfessions[i].pBenefits= RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
690 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
691 case 5:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
692 pProfessions[i].pJoinText = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
693 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
694 case 6:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
695 pProfessions[i].pDismissText = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
696 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
697 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
698 else
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
699 {
667
8c6c41037c39 profession NPC dialogue fixed
zipi
parents: 659
diff changeset
700 if (!decode_step)
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
701 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
702 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
703 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
704 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
705 } while ((decode_step<7)&&!break_loop);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
706 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
707 uNumNPCProfessions = 59;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
708 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
709
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
710 //----- (00477266) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
711 void NPCStats::Release()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
712 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
713 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
714 pNPCTopicTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
715 pAllocator->FreeChunk(pNPCTextTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
716 pNPCTextTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
717 pAllocator->FreeChunk(pNPCNewsTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
718 pNPCNewsTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
719 pAllocator->FreeChunk(pNPCProfTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
720 pNPCProfTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
721 pAllocator->FreeChunk(pNPCNamesTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
722 pNPCNamesTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
723 pAllocator->FreeChunk(pNPCDataTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
724 pNPCDataTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
725 pAllocator->FreeChunk(pNPCDistTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
726 pNPCDistTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
727 pAllocator->FreeChunk(pNPCGreetTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
728 pNPCGreetTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
729 pAllocator->FreeChunk(pNCPGroupTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
730 pNCPGroupTXT_Raw = NULL;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
731 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
732
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
733 //----- (0047730C) --------------------------------------------------------
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
734 bool CheckPortretAgainstSex(int a1, int)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
735 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
736 return true;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
737 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
738 // 47730C: using guessed type int __stdcall const_1(int);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
739
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
740 //----- (0047732C) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
741 void NPCStats::InitializeAdditionalNPCs(NPCData *pNPCDataBuff, int npc_uid, int uLocation2D, int uMapId)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
742 {
292
5586bb4e8395 build fix
Gloval
parents: 291
diff changeset
743 int rep_gen;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
744 int uNPCSex; // esi@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
745 int uGeneratedPortret; // ecx@23
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
746 int test_prof_summ; // ecx@37
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
747 int gen_profession; // eax@37
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
748 int max_prof_cap; // edx@37
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
749 signed int result; // eax@39
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
750 int uRace; // [sp+Ch] [bp-Ch]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
751 bool break_gen; // [sp+10h] [bp-8h]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
752 signed int gen_attempts; // [sp+14h] [bp-4h]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
753 int uPortretMin; // [sp+24h] [bp+Ch]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
754 int uPortretMax;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
755
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
756 static const unsigned __int8 NPCSexGenTable[86] ={
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
757 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
758 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
759 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
760 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
761 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 };
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
762 static const unsigned __int8 NPCRaceGenTable[86] ={
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
763 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
764 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
765 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
766 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
767 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0};
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
768
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
769 unsigned __int8 seed = (unsigned __int8)((double)(npc_uid - 1)/3.0);
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
770 uNPCSex = NPCSexGenTable[seed];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
771 uRace = NPCRaceGenTable[seed];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
772 pNPCDataBuff->uSex = uNPCSex;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
773 pNPCDataBuff->pName = pNPCNames[rand() % uNumNPCNames[uNPCSex]][uNPCSex];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
774
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
775 gen_attempts = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
776 break_gen = false;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
777
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
778 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
779 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
780 switch ( uRace )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
781 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
782 case 0:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
783 if ( uNPCSex == 0 )
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
784 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
785 uPortretMin = 2;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
786 uPortretMax = 100;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
787 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
788 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
789 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
790 uPortretMin = 201;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
791 uPortretMax = 250;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
792 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
793 case 1:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
794 if ( uNPCSex == 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
795 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
796 uPortretMin = 400;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
797 uPortretMax = 430;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
798 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
799 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
800 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
801 uPortretMin = 460;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
802 uPortretMax = 490;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
803 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
804 break;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
805 case 2:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
806 if ( uNPCSex == 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
807 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
808 uPortretMin = 500;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
809 uPortretMax = 520;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
810 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
811 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
812 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
813 uPortretMin = 530;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
814 uPortretMax = 550;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
815 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
816 break;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
817 case 3:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
818 if ( uNPCSex == 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
819 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
820 uPortretMin = 300;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
821 uPortretMax = 330;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
822 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
823 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
824 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
825 uPortretMin = 360;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
826 uPortretMax = 387;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
827 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
828
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
829 break;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
830 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
831
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
832 uGeneratedPortret = uPortretMin + rand() % (uPortretMax - uPortretMin + 1);
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
833 if ( CheckPortretAgainstSex(uGeneratedPortret, uNPCSex))
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
834 break_gen = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
835 ++gen_attempts;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
836 if ( gen_attempts >= 4 )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
837 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
838 uGeneratedPortret = uPortretMin;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
839 break_gen = true;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
840 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
841 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
842 while(!break_gen);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
843
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
844 pNPCDataBuff->uPortraitID = uGeneratedPortret;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
845 pNPCDataBuff->uFlags = 0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
846 pNPCDataBuff->fame = 0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
847 //generate reputation
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
848 rep_gen = rand() % 100 + 1;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
849
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
850 if ( rep_gen >= 60 )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
851 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
852 if ( rep_gen >= 90 )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
853 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
854 if ( rep_gen >= 95 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
855 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
856 if ( rep_gen >= 98 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
857 pNPCDataBuff->rep = -600;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
858 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
859 pNPCDataBuff->rep = 400;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
860 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
861 else
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
862 pNPCDataBuff->rep = -300;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
863 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
864 else
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
865 pNPCDataBuff->rep = 200;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
866 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
867 else
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
868 pNPCDataBuff->rep = 0;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
869
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
870 max_prof_cap = rand() % pProfessionChance[uMapId].uTotalprofChance+1;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
871 test_prof_summ = 0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
872 gen_profession = 0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
873
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
874 if ( max_prof_cap > 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
875 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
876 do
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
877 test_prof_summ += pProfessionChance[uMapId].professionChancePerArea[gen_profession++];
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
878 while ( test_prof_summ < max_prof_cap );
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
879 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
880 pNPCDataBuff->uProfession = gen_profession - 1;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
881 pNPCDataBuff->Location2D = uLocation2D;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
882 pNPCDataBuff->field_24 = 1;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
883 pNPCDataBuff->joins = 1;
659
c10163a6d946 NPC hiring fixed
zipi
parents: 652
diff changeset
884 pNPCDataBuff->evt_A = 0;
c10163a6d946 NPC hiring fixed
zipi
parents: 652
diff changeset
885 pNPCDataBuff->evt_B = 0;
c10163a6d946 NPC hiring fixed
zipi
parents: 652
diff changeset
886 pNPCDataBuff->evt_C = 0;
c10163a6d946 NPC hiring fixed
zipi
parents: 652
diff changeset
887 pNPCDataBuff->evt_D = 0;
c10163a6d946 NPC hiring fixed
zipi
parents: 652
diff changeset
888 pNPCDataBuff->evt_E = 0;
c10163a6d946 NPC hiring fixed
zipi
parents: 652
diff changeset
889 pNPCDataBuff->evt_F = 0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
890 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
891
257
Nomad
parents: 253
diff changeset
892 //----- (00476387) --------------------------------------------------------
Nomad
parents: 253
diff changeset
893 bool PartyHasDragon()
Nomad
parents: 253
diff changeset
894 {
Nomad
parents: 253
diff changeset
895 return pNPCStats->pNewNPCData[57].Hired();
Nomad
parents: 253
diff changeset
896 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
897
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
898 //----- (00476395) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
899 //0x26 Wizard eye at skill level 2
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
900 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
901 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
902
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
903 if ( bNoNPCHiring == 1 )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
904 return 0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
905
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
906 for (int i=0; i<pNPCStats->uNumNewNPCs; ++i )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
907 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
908 if ( pNPCStats->pNewNPCData[i].uProfession == uProfession &&
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
909 (pNPCStats->pNewNPCData[i].uFlags & 0x80) )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
910 return true;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
911 }
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
912 if ( pParty->pHirelings[0].uProfession == uProfession ||
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
913 pParty->pHirelings[1].uProfession == uProfession)
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
914 return true;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
915 else
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
916 return false;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
917
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
918 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
919 // 6BE3C5: using guessed type char bNoNPCHiring;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
920
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
921 //----- (004763E0) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
922 void InitializeAwards()
949
Nomad
parents: 825
diff changeset
923 {
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
924 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
925 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
926 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
927 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
928 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
929 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
930 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
931
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
932 if ( pAwardsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
933 pAllocator->FreeChunk(pAwardsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
934 pAwardsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
935 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
936 strtok(pAwardsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
937
949
Nomad
parents: 825
diff changeset
938 for (i=1; i<105; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
939 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
940 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
941 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
942 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
943 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
944 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
945 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
946 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
947 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
948 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
949 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
950 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
951 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
952 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
953 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
954 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
955 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
956 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
957 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
958 if (decode_step==1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
959 pAwards[i].pText=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
960 else if (decode_step==2)
949
Nomad
parents: 825
diff changeset
961 pAwards[i].uPriority = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
962 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
963 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
964 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
965 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
966 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
967 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
968 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
969 } while ((decode_step<3)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
970 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
971 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
972 // 7241C8: using guessed type int dword_7241C8;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
973
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
974 //----- (004764C2) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
975 void InitializeScrolls()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
976 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
977
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
978 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
979 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
980 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
981 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
982 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
983 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
984 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
985
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
986 if ( pScrollsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
987 pAllocator->FreeChunk(pScrollsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
988 pScrollsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
989 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
990 strtok(pScrollsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
991 for (i=0; i<82; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
992 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
993 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
994 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
995 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
996 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
997 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
998 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
999 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1000 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1001 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1002 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1003 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1004 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1005 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1006 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1007 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1008 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1009 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1010 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1011 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1012 pScrolls[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1013 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1014 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1015 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1016 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1017 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1018 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1019 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1020 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1021 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1022 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1023
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1024 //----- (00476590) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1025 void InitializeMerchants()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1026 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1027 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1028 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1029 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1030 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1031 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1032 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1033 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1034
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1035 if ( pMerchantsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1036 pAllocator->FreeChunk(pMerchantsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1037 pMerchantsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1038 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1039 strtok(pMerchantsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1040
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1041 for (i=0; i<7; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1042 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1043 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1044 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1045 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1046 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1047 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1048 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1049 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1050 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1051 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1052 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1053 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1054 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1055 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1056 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1057 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1058 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1059 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1060 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1061 switch (decode_step)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1062 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1063 case 1:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1064 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1065 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1066 case 2:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1067 pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1068 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1069 case 3:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1070 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1071 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1072 case 4:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1073 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1074 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1075 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1076 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1077 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1078 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1079 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1080 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1081 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1082 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1083 } while ((decode_step<5)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1084 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1085
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1086 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1087
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1088 //----- (00476682) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1089 void InitializeTransitions()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1090 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1091 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1092 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1093 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1094 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1095 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1096 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1097 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1098
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1099 if ( pTransitionsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1100 pAllocator->FreeChunk(pTransitionsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1101 pTransitionsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1102 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1103 strtok(pTransitionsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1104
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1105 for (i=0; i<464; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1106 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1107 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1108 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1109 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1110 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1111 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1112 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1113 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1114 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1115 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1116 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1117 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1118 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1119 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1120 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1121 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1122 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1123 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1124 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1125 if ( decode_step == 1)
434
137c59c3dbc4 Temple of Moon and Dragon Lair can now be entered.
Nomad
parents: 353
diff changeset
1126 pTransitionStrings[i + 1]=RemoveQuotes(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1127 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1128 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1129 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1130 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1131 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1132 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1133 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1134 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1135 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1136 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1137
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1138 //----- (00476750) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1139 void __cdecl InitializeAutonotes()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1140 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1141 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1142 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1143 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1144 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1145 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1146 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1147 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1148
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1149 if ( pAutonoteTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1150 pAllocator->FreeChunk(pAutonoteTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1151 pAutonoteTXT_Raw = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1152 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1153 strtok(pAutonoteTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1154
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1155 for (i=0; i<195; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1156 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1157 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1158 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1159 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1160 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1161 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1162 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1163 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1164 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1165 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1166 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1167 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1168 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1169 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1170 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1171 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1172 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1173 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1174 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1175 switch (decode_step)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1176 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1177 case 1:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1178 pAutonoteTxt[i].pText=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1179 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1180 case 2:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1181 {
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1182 if ( !_stricmp(test_string, "potion"))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1183 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1184 pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1185 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1186 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1187 if ( !_stricmp(test_string, "stat") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1188 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1189 pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1190 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1191 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1192 if ( !_stricmp(test_string, "seer") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1193 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1194 pAutonoteTxt[i].eType = AUTONOTE_SEER;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1195 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1196 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1197 if ( !_stricmp(test_string, "obelisk") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1198 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1199 pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1200 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1201 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1202 if ( !_stricmp(test_string, "teacher") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1203 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1204 pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1205 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1206 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1207 pAutonoteTxt[i].eType =AUTONOTE_MISC;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1208 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1209 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1210 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1211 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1212 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1213 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1214 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1215 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1216 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1217 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1218 } while ((decode_step<3)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1219 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1220 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1221
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1222
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1223 //----- (004768A9) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1224 void __cdecl InitializeQuests()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1225 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1226 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1227 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1228 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1229 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1230 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1231 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1232 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1233
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1234 if ( pQuestsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1235 pAllocator->FreeChunk(pQuestsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1236 pQuestsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1237 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1238 strtok(pQuestsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1239
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1240 for (i=0; i<512; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1241 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1242 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1243 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1244 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1245 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1246 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1247 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1248 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1249 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1250 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1251 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1252 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1253 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1254 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1255 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1256 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1257 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1258 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1259 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1260 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1261 pQuestTable[i] =RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1262 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1263 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1264 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1265 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1266 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1267 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1268 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1269 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1270 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1271 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1272