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