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