Mercurial > mm7
annotate NPC.cpp @ 1794:3f1e09a71726
Merge
author | Grumpy7 |
---|---|
date | Sun, 06 Oct 2013 09:21:09 +0200 |
parents | 4dee76d79c78 |
children | 35c1e4ff6ba7 |
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 | 4 |
5 #include "texts.h" | |
6 #include "LOD.h" | |
7 #include "Autonotes.h" | |
8 #include "Awards.h" | |
9 #include "mm7_data.h" | |
10 #include "MM7.h" | |
1016 | 11 #include "Party.h" |
251 | 12 #include "NPC.h" |
1295 | 13 #include "GUIWindow.h" |
14 #include "VideoPlayer.h" | |
15 #include "Events.h" | |
1299 | 16 #include "UI\UIHouses.h" |
1295 | 17 #include "Indoor.h" |
18 #include "MapInfo.h" | |
251 | 19 |
629 | 20 int pDialogueNPCCount; |
1206
ab6560001f5b
arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents:
1165
diff
changeset
|
21 std::array<struct Texture *, 6> pDialogueNPCPortraits; |
629 | 22 int uNumDialogueNPCPortraits; // weak |
23 struct NPCStats *pNPCStats = nullptr; | |
24 | |
251 | 25 void InitializeAwards(); |
26 void InitializeScrolls(); | |
27 void InitializeMerchants(); | |
28 void InitializeTransitions(); | |
29 void InitializeAutonotes(); | |
30 void InitializeQuests(); | |
307 | 31 bool CheckPortretAgainstSex(int portret_num, int sex); |
251 | 32 |
781 | 33 //----- (004459F9) -------------------------------------------------------- |
34 NPCData *__fastcall GetNPCData(signed int npcid) | |
35 { | |
36 unsigned int v1; // esi@1 | |
37 NPCData *result; // eax@5 | |
38 int v3; // esi@9 | |
39 int v4; // ecx@9 | |
40 //int v5; // edx@9 | |
41 //NPCData *v6; // eax@9 | |
42 char *v7; // ebx@14 | |
43 NPCData *v8; // edi@14 | |
44 char v9; // al@22 | |
45 char v10; | |
46 //std::string v10; // [sp-18h] [bp-2Ch]@4 | |
47 int v11; | |
48 //const char *v11; // [sp-8h] [bp-1Ch]@4 | |
49 int v12; // [sp-4h] [bp-18h]@4 | |
50 int v13; | |
51 char *v14; | |
52 //std::string *v13; // [sp+Ch] [bp-8h]@4 | |
53 int a3; // [sp+13h] [bp-1h]@4 | |
54 int i; | |
55 | |
56 /*v1 = npcid; | |
57 if ( (npcid & 0x80000000u) == 0 ) | |
58 { | |
59 if ( (signed int)npcid < 5000 ) | |
60 { | |
61 if ( (signed int)npcid >= 501 ) | |
62 { | |
63 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0); | |
64 } | |
65 return &pNPCStats->pNewNPCData[v1]; | |
66 } | |
67 return &pNPCStats->array_13EF4[npcid - 5000]; | |
68 } | |
69 if ( (signed int)npcid >= 5000 ) | |
70 return &pNPCStats->array_13EF4[npcid - 5000]; | |
71 if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) | |
72 { | |
73 result = 0; | |
74 } | |
75 else | |
76 { | |
77 v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; | |
78 v4 = 0; | |
79 v5 = 0; | |
80 v6 = pParty->pHirelings; | |
81 do | |
82 { | |
83 if ( v6->pName ) | |
84 pTmpBuf[v4++] = v5; | |
85 ++v6; | |
86 ++v5; | |
87 } | |
88 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
89 v13 = 0; | |
90 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
91 { | |
92 v7 = &pTmpBuf[v4]; | |
93 v8 = pNPCStats->pNewNPCData; | |
94 do | |
95 { | |
96 if ( v8->uFlags & 0x80 | |
97 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) | |
98 && (!pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName)) ) | |
99 *v7++ = (char)v13 + 2; | |
100 v13 = (std::string *)((char *)v13 + 1); | |
101 ++v8; | |
102 } | |
103 while ( (signed int)v13 < (signed int)pNPCStats->uNumNewNPCs ); | |
104 } | |
105 v9 = pTmpBuf[v3]; | |
106 if ( (unsigned __int8)v9 >= 2u ) | |
107 result = &pNPCStats->pNPCData[(unsigned __int8)v9 + 499]; | |
108 else | |
109 result = &pParty->pHirelings[(unsigned __int8)v9]; | |
110 } | |
111 return result;*/ | |
112 v1 = npcid; | |
113 if ( npcid >= 0 ) | |
114 { | |
115 if ( npcid < 5000 ) | |
116 { | |
117 if ( npcid >= 501 ) | |
118 { | |
119 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0); | |
120 } | |
121 return &pNPCStats->pNewNPCData[v1];// - 1]; | |
122 } | |
123 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
124 } | |
125 | |
126 | |
127 if ( npcid >= 5000 ) | |
128 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
129 if (sDialogue_SpeakingActorNPC_ID >= 0) | |
130 { | |
131 result = 0; | |
132 } | |
133 else | |
134 { | |
135 v3 = abs(sDialogue_SpeakingActorNPC_ID) - 1; | |
136 v4 = 0; | |
137 | |
138 for (i = 0; i < 2; ++i) | |
139 { | |
140 if (pParty->pHirelings[i].pName) | |
141 pTmpBuf[v4++] = i; | |
142 } | |
143 | |
144 if (pNPCStats->uNumNewNPCs > 0) | |
145 { | |
146 for (i = 0; i < pNPCStats->uNumNewNPCs; ++i) | |
147 { | |
148 if (pNPCStats->pNewNPCData[i].Hired()) | |
149 { | |
150 if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) | |
151 { | |
152 if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName)) | |
153 pTmpBuf[v4++] = i + 2; | |
154 } | |
155 } | |
156 } | |
157 } | |
158 | |
159 v9 = pTmpBuf[v3]; | |
160 if ( v9 >= 2 ) | |
161 result = &pNPCStats->pNPCData[499 + v9]; | |
162 else | |
163 result = &pParty->pHirelings[v9]; | |
164 } | |
1099 | 165 return result; |
781 | 166 } |
167 | |
168 //----- (00445B2C) -------------------------------------------------------- | |
1094 | 169 struct NPCData * GetNewNPCData( signed int npcid, int* npc_indx ) |
170 { | |
171 | |
172 int* v3; // edi@1 | |
781 | 173 NPCData *result; // eax@5 |
174 int v5; // esi@9 | |
175 int v6; // ecx@9 | |
176 char v11; // al@23 | |
177 | |
1094 | 178 v3 = npc_indx; |
781 | 179 if ( npcid >= 0 ) |
180 { | |
181 if ( npcid < 5000 ) | |
182 { | |
183 if ( npcid >= 501 ) | |
184 { | |
1094 | 185 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0); |
781 | 186 } |
1094 | 187 *v3 = npcid; |
188 return &pNPCStats->pNewNPCData[npcid]; | |
781 | 189 } |
1094 | 190 *npc_indx = npcid - 5000; |
781 | 191 return &pNPCStats->pAdditionalNPC[npcid - 5000]; |
192 } | |
193 if ( npcid >= 5000 ) | |
1094 | 194 { |
195 *npc_indx = npcid - 5000; | |
196 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
197 } | |
781 | 198 if ( sDialogue_SpeakingActorNPC_ID >= 0 ) |
199 { | |
1094 | 200 *npc_indx = 0; |
201 result = NULL; | |
781 | 202 } |
203 else | |
204 { | |
1094 | 205 v5 = abs(sDialogue_SpeakingActorNPC_ID) - 1; |
781 | 206 v6 = 0; |
1094 | 207 for (int i=0; i<2; ++i) |
781 | 208 { |
1094 | 209 if ( pParty->pHirelings[i].pName ) |
210 pTmpBuf[v6++] = i; | |
211 | |
212 } | |
213 for (int i=0; i< pNPCStats->uNumNewNPCs; ++i) | |
781 | 214 { |
1094 | 215 if ( pNPCStats->pNewNPCData[i].Hired() |
216 && (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName)) | |
217 && (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) ) | |
218 { | |
219 pTmpBuf[v6++]=i+2; | |
220 } | |
781 | 221 } |
222 v11 = pTmpBuf[v5]; | |
1094 | 223 |
224 if ( v11 >= 2u ) | |
781 | 225 { |
1094 | 226 *v3 = v11 - 2; |
227 result = &pNPCStats->pNewNPCData[v11 - 2]; | |
781 | 228 } |
229 else | |
230 { | |
1094 | 231 *v3 = v11; |
232 result = &pParty->pHirelings[v11]; | |
781 | 233 } |
234 } | |
235 return result; | |
236 } | |
237 | |
251 | 238 //----- (00476977) -------------------------------------------------------- |
291 | 239 void NPCStats::InitializeNPCText() |
251 | 240 { |
241 int i; | |
242 char* test_string; | |
243 unsigned char c; | |
244 bool break_loop; | |
245 unsigned int temp_str_len; | |
246 char* tmp_pos; | |
247 int decode_step; | |
248 | |
249 if (pNPCTextTXT_Raw) | |
1583 | 250 free(pNPCTextTXT_Raw); |
251 | 251 pNPCTextTXT_Raw =NULL; |
252 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); | |
253 strtok(pNPCTextTXT_Raw, "\r"); | |
254 | |
255 for (i=0; i<789; ++i) | |
256 { | |
257 test_string = strtok(NULL, "\r") + 1; | |
258 break_loop = false; | |
259 decode_step=0; | |
260 do | |
261 { | |
262 c = *(unsigned char*)test_string; | |
263 temp_str_len = 0; | |
264 while((c!='\t')&&(c>0)) | |
265 { | |
266 ++temp_str_len; | |
267 c=test_string[temp_str_len]; | |
268 } | |
269 tmp_pos=test_string+temp_str_len; | |
270 if (*tmp_pos == 0) | |
271 break_loop = true; | |
272 *tmp_pos = 0; | |
273 if (temp_str_len) | |
274 { | |
275 if ( decode_step == 1) | |
276 pNPCTopics[i].pText =RemoveQuotes(test_string); | |
277 } | |
278 else | |
279 { | |
280 break_loop = true; | |
281 } | |
282 ++decode_step; | |
283 test_string=tmp_pos+1; | |
284 } while ((decode_step<2)&&!break_loop); | |
285 } | |
286 | |
287 if (pNPCTopicTXT_Raw) | |
1583 | 288 free(pNPCTopicTXT_Raw); |
251 | 289 pNPCTopicTXT_Raw =NULL; |
290 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); | |
291 strtok(pNPCTopicTXT_Raw, "\r"); | |
292 | |
1661 | 293 for ( i = 1; i <= 579; ++i )//NPC topics count limit |
251 | 294 { |
295 test_string = strtok(NULL, "\r") + 1; | |
296 break_loop = false; | |
297 decode_step=0; | |
298 do | |
299 { | |
300 c = *(unsigned char*)test_string; | |
301 temp_str_len = 0; | |
302 while((c!='\t')&&(c>0)) | |
303 { | |
304 ++temp_str_len; | |
305 c=test_string[temp_str_len]; | |
306 } | |
307 tmp_pos=test_string+temp_str_len; | |
308 if (*tmp_pos == 0) | |
309 break_loop = true; | |
310 *tmp_pos = 0; | |
311 if (temp_str_len) | |
312 { | |
313 if ( decode_step == 1) | |
314 pNPCTopics[i].pTopic = RemoveQuotes(test_string); | |
315 } | |
316 else | |
317 { | |
318 break_loop = true; | |
319 } | |
320 ++decode_step; | |
321 test_string=tmp_pos+1; | |
322 } while ((decode_step<2)&&!break_loop); | |
323 } | |
324 | |
325 if (pNPCDistTXT_Raw) | |
1583 | 326 free(pNPCDistTXT_Raw); |
251 | 327 pNPCDistTXT_Raw = NULL; |
328 pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0); | |
329 strtok(pNPCDistTXT_Raw, "\r"); | |
330 strtok(NULL, "\r"); | |
331 | |
332 for (i=1; i<59; ++i) | |
333 { | |
334 test_string = strtok(NULL, "\r") + 1; | |
335 break_loop = false; | |
336 decode_step=0; | |
337 do | |
338 { | |
339 c = *(unsigned char*)test_string; | |
340 temp_str_len = 0; | |
341 while((c!='\t')&&(c>0)) | |
342 { | |
343 ++temp_str_len; | |
344 c=test_string[temp_str_len]; | |
345 } | |
346 tmp_pos=test_string+temp_str_len; | |
347 if (*tmp_pos == 0) | |
348 break_loop = true; | |
349 *tmp_pos = 0; | |
350 if (temp_str_len) | |
351 { | |
352 if ((decode_step>0)&&(decode_step<77)) | |
353 { | |
291 | 354 pProfessionChance[decode_step].professionChancePerArea[i]=atoi(test_string); |
251 | 355 } |
356 else if (decode_step==0) | |
357 { | |
291 | 358 pProfessionChance[0].professionChancePerArea[i]=10; |
251 | 359 } |
360 } | |
361 else | |
362 { | |
363 break_loop = true; | |
364 } | |
365 ++decode_step; | |
366 test_string=tmp_pos+1; | |
367 } while ((decode_step<78)&&!break_loop); | |
368 } | |
369 | |
825 | 370 for ( i = 0; i < 77; ++i ) |
251 | 371 { |
291 | 372 pProfessionChance[i].uTotalprofChance=0; |
825 | 373 for ( int ii = 1; ii < 59; ++ii ) |
251 | 374 { |
291 | 375 pProfessionChance[i].uTotalprofChance+=pProfessionChance[i].professionChancePerArea[ii]; |
251 | 376 } |
293 | 377 pProfessionChance[i].professionChancePerArea[0]=0; |
378 pProfessionChance[i].professionChancePerArea[59]=0; | |
251 | 379 } |
380 | |
381 if (pNPCDistTXT_Raw) | |
382 { | |
1583 | 383 free(pNPCDistTXT_Raw); |
251 | 384 pNPCDistTXT_Raw = NULL; |
385 } | |
386 } | |
387 | |
388 //----- (00476C60) -------------------------------------------------------- | |
389 void NPCStats::_476C60() | |
390 { | |
391 for (unsigned int i = 1; i < uNumNewNPCs; ++i) | |
291 | 392 pNewNPCData[i].pName = pNPCUnicNames[i - 1]; |
251 | 393 |
394 if (pParty->pHirelings[0].pName) | |
395 pParty->pHirelings[0].pName = pParty->pHireling1Name; | |
396 if (pParty->pHirelings[1].pName) | |
397 pParty->pHirelings[1].pName = pParty->pHireling2Name; | |
398 } | |
399 | |
400 //----- (00476CB5) -------------------------------------------------------- | |
291 | 401 void NPCStats::InitializeNPCData() |
251 | 402 { |
291 | 403 int i; |
404 char* test_string; | |
405 unsigned char c; | |
406 bool break_loop; | |
407 unsigned int temp_str_len; | |
408 char* tmp_pos; | |
409 int decode_step; | |
410 | |
411 pNPCDataTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0); | |
412 strtok(pNPCDataTXT_Raw, "\r"); | |
413 strtok(NULL, "\r"); | |
251 | 414 |
291 | 415 for (i=0; i<500; ++i) |
251 | 416 { |
291 | 417 test_string = strtok(NULL, "\r") + 1; |
418 break_loop = false; | |
419 decode_step=0; | |
420 do | |
251 | 421 { |
291 | 422 c = *(unsigned char*)test_string; |
423 temp_str_len = 0; | |
424 while((c!='\t')&&(c>0)) | |
251 | 425 { |
291 | 426 ++temp_str_len; |
427 c=test_string[temp_str_len]; | |
428 } | |
429 tmp_pos=test_string+temp_str_len; | |
430 if (*tmp_pos == 0) | |
431 break_loop = true; | |
432 *tmp_pos = 0; | |
433 if (temp_str_len) | |
434 { //i+1 | |
435 switch (decode_step) | |
251 | 436 { |
291 | 437 case 1: |
438 pNPCUnicNames[i] = RemoveQuotes(test_string); | |
439 pNPCData[i+1].pName=pNPCUnicNames[i]; | |
251 | 440 break; |
291 | 441 case 2: |
442 pNPCData[i+1].uPortraitID = atoi(test_string); | |
251 | 443 break; |
444 case 6: | |
291 | 445 pNPCData[i+1].Location2D = atoi(test_string); |
251 | 446 break; |
447 case 7: | |
291 | 448 pNPCData[i+1].uProfession = atoi(test_string); |
251 | 449 break; |
450 case 8: | |
291 | 451 pNPCData[i+1].greet = atoi(test_string); |
251 | 452 break; |
453 case 9: | |
291 | 454 pNPCData[i+1].joins = (*test_string == 'y')?1:0; |
251 | 455 break; |
456 case 10: | |
291 | 457 pNPCData[i+1].evt_A = atoi(test_string); |
251 | 458 break; |
459 case 11: | |
291 | 460 pNPCData[i+1].evt_B = atoi(test_string); |
251 | 461 break; |
462 case 12: | |
291 | 463 pNPCData[i+1].evt_C = atoi(test_string); |
251 | 464 break; |
465 case 13: | |
291 | 466 pNPCData[i+1].evt_D = atoi(test_string); |
251 | 467 break; |
468 case 14: | |
291 | 469 pNPCData[i+1].evt_E = atoi(test_string); |
251 | 470 break; |
291 | 471 case 15: |
472 pNPCData[i+1].evt_F = atoi(test_string); | |
251 | 473 break; |
474 } | |
475 } | |
291 | 476 ++decode_step; |
477 test_string=tmp_pos+1; | |
478 } while ((decode_step<16)&&!break_loop); | |
251 | 479 } |
291 | 480 uNumNewNPCs = 501; |
481 pNPCGreetTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgreet.txt", 0); | |
482 strtok(pNPCGreetTXT_Raw, "\r"); | |
1653 | 483 for ( i = 1; i <= 205; ++i ) |
291 | 484 { |
485 test_string = strtok(NULL, "\r") + 1; | |
486 break_loop = false; | |
487 decode_step=0; | |
488 do | |
251 | 489 { |
291 | 490 c = *(unsigned char*)test_string; |
491 temp_str_len = 0; | |
492 while((c!='\t')&&(c>0)) | |
251 | 493 { |
291 | 494 ++temp_str_len; |
495 c=test_string[temp_str_len]; | |
496 } | |
497 tmp_pos=test_string+temp_str_len; | |
498 if (*tmp_pos == 0) | |
499 break_loop = true; | |
500 *tmp_pos = 0; | |
501 if (temp_str_len) | |
502 { //i+1 | |
503 switch (decode_step) | |
251 | 504 { |
291 | 505 case 1: |
1655 | 506 pNPCGreetings[i].pGreetings[0] = RemoveQuotes(test_string); |
291 | 507 break; |
508 case 2: | |
1655 | 509 pNPCGreetings[i].pGreetings[1] = RemoveQuotes(test_string); |
291 | 510 break; |
251 | 511 } |
512 } | |
291 | 513 ++decode_step; |
514 test_string=tmp_pos+1; | |
515 } while ((decode_step<3)&&!break_loop); | |
516 } | |
517 | |
518 pNCPGroupTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgroup.txt", 0); | |
519 strtok(pNCPGroupTXT_Raw, "\r"); | |
520 | |
521 for (i=0; i<51; ++i) | |
522 { | |
523 test_string = strtok(NULL, "\r") + 1; | |
524 break_loop = false; | |
525 decode_step=0; | |
526 do | |
527 { | |
528 c = *(unsigned char*)test_string; | |
529 temp_str_len = 0; | |
530 while((c!='\t')&&(c>0)) | |
531 { | |
532 ++temp_str_len; | |
533 c=test_string[temp_str_len]; | |
534 } | |
535 tmp_pos=test_string+temp_str_len; | |
536 if (*tmp_pos == 0) | |
537 break_loop = true; | |
538 *tmp_pos = 0; | |
539 if (temp_str_len) | |
540 { //i+1 | |
541 if (decode_step==1) | |
251 | 542 { |
291 | 543 pGroups[i] = atoi(test_string); |
251 | 544 } |
291 | 545 } |
546 ++decode_step; | |
547 test_string=tmp_pos+1; | |
548 } while ((decode_step<2)&&!break_loop); | |
549 } | |
550 | |
551 pNPCNewsTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcnews.txt", 0); | |
552 strtok(pNPCNewsTXT_Raw, "\r"); | |
553 | |
554 | |
555 for (i=0; i<51; ++i) | |
556 { | |
557 test_string = strtok(NULL, "\r") + 1; | |
558 break_loop = false; | |
559 decode_step=0; | |
560 do | |
561 { | |
562 c = *(unsigned char*)test_string; | |
563 temp_str_len = 0; | |
564 while((c!='\t')&&(c>0)) | |
565 { | |
566 ++temp_str_len; | |
567 c=test_string[temp_str_len]; | |
568 } | |
569 tmp_pos=test_string+temp_str_len; | |
570 if (*tmp_pos == 0) | |
571 break_loop = true; | |
572 *tmp_pos = 0; | |
573 if (temp_str_len) | |
574 { //i+1 | |
575 if (decode_step==1) | |
576 pCatchPhrases[i] = RemoveQuotes(test_string); | |
577 } | |
578 ++decode_step; | |
579 test_string=tmp_pos+1; | |
580 } while ((decode_step<2)&&!break_loop); | |
581 } | |
251 | 582 } |
583 | |
584 //----- (0047702F) -------------------------------------------------------- | |
585 void NPCStats::Initialize() | |
291 | 586 { |
587 int i; | |
588 char* test_string; | |
589 unsigned char c; | |
590 bool break_loop; | |
591 unsigned int temp_str_len; | |
592 char* tmp_pos; | |
593 int decode_step; | |
251 | 594 |
291 | 595 InitializeNPCData(); |
596 InitializeNPCText(); | |
597 InitializeQuests(); | |
598 InitializeAutonotes(); | |
599 InitializeAwards(); | |
600 InitializeTransitions(); | |
601 InitializeMerchants(); | |
602 InitializeScrolls(); | |
251 | 603 |
291 | 604 pNPCNamesTXT_Raw = NULL; |
605 pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); | |
606 strtok(pNPCNamesTXT_Raw, "\r"); | |
607 | |
608 uNewlNPCBufPos = 0; | |
609 | |
610 for (i=0; i<540; ++i) | |
251 | 611 { |
291 | 612 test_string = strtok(NULL, "\r") + 1; |
613 break_loop = false; | |
614 decode_step=0; | |
615 do | |
251 | 616 { |
291 | 617 c = *(unsigned char*)test_string; |
618 temp_str_len = 0; | |
619 if (c=='\t') | |
251 | 620 { |
291 | 621 if ( (decode_step == 1)&&(!uNumNPCNames[1])) |
622 uNumNPCNames[1]=i; | |
251 | 623 } |
624 else | |
625 { | |
291 | 626 while((c!='\n')&&(c!='\t')&&(c>0)) |
627 { | |
628 ++temp_str_len; | |
629 c=test_string[temp_str_len]; | |
630 } | |
631 tmp_pos=test_string+temp_str_len; | |
632 if (*tmp_pos == 0) | |
633 break_loop = true; | |
634 | |
635 if (temp_str_len) | |
636 { | |
637 *tmp_pos = 0; | |
638 if ( decode_step == 0) | |
639 pNPCNames[i][0] =RemoveQuotes(test_string); | |
640 else if ( decode_step == 1) | |
641 pNPCNames[i][1] =RemoveQuotes(test_string); | |
642 } | |
643 else | |
644 { | |
645 if ( (decode_step == 1)&&(!uNumNPCNames[1])) | |
646 uNumNPCNames[1]=i; | |
647 } | |
251 | 648 } |
291 | 649 ++decode_step; |
650 test_string=tmp_pos+1; | |
651 } while ((decode_step<2)&&!break_loop); | |
652 } | |
653 uNumNPCNames[0] = i; | |
654 | |
655 pNPCProfTXT_Raw = NULL; | |
656 pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); | |
657 strtok(pNPCProfTXT_Raw, "\r"); | |
658 strtok(NULL, "\r"); | |
659 strtok(NULL, "\r"); | |
660 strtok(NULL, "\r"); | |
661 | |
662 for (i=1; i<59; ++i) | |
663 { | |
664 test_string = strtok(NULL, "\r") + 1; | |
665 break_loop = false; | |
666 decode_step=0; | |
667 do | |
251 | 668 { |
667 | 669 //while (*test_string == '\t') // some steps are separated by multiple \t's |
670 //++test_string; | |
652 | 671 |
291 | 672 c = *(unsigned char*)test_string; |
673 temp_str_len = 0; | |
674 while((c!='\t')&&(c>0)) | |
251 | 675 { |
291 | 676 ++temp_str_len; |
677 c=test_string[temp_str_len]; | |
678 } | |
679 tmp_pos=test_string+temp_str_len; | |
680 if (*tmp_pos == 0) | |
681 break_loop = true; | |
682 *tmp_pos = 0; | |
683 if (temp_str_len) | |
684 { | |
685 switch(decode_step) | |
686 { | |
687 case 2: | |
688 pProfessions[i].uHirePrice = atoi(test_string); | |
689 break; | |
690 case 3: | |
691 pProfessions[i].pActionText = RemoveQuotes(test_string); | |
692 break; | |
693 case 4: | |
694 pProfessions[i].pBenefits= RemoveQuotes(test_string); | |
695 break; | |
696 case 5: | |
697 pProfessions[i].pJoinText = RemoveQuotes(test_string); | |
698 break; | |
699 case 6: | |
700 pProfessions[i].pDismissText = RemoveQuotes(test_string); | |
701 } | |
251 | 702 } |
291 | 703 else |
704 { | |
667 | 705 if (!decode_step) |
291 | 706 break_loop = true; |
707 } | |
708 ++decode_step; | |
709 test_string=tmp_pos+1; | |
710 } while ((decode_step<7)&&!break_loop); | |
251 | 711 } |
291 | 712 uNumNPCProfessions = 59; |
251 | 713 } |
714 | |
715 //----- (00477266) -------------------------------------------------------- | |
716 void NPCStats::Release() | |
717 { | |
1583 | 718 free(pNPCTopicTXT_Raw); |
291 | 719 pNPCTopicTXT_Raw = NULL; |
1583 | 720 free(pNPCTextTXT_Raw); |
291 | 721 pNPCTextTXT_Raw = NULL; |
1583 | 722 free(pNPCNewsTXT_Raw); |
291 | 723 pNPCNewsTXT_Raw = NULL; |
1583 | 724 free(pNPCProfTXT_Raw); |
291 | 725 pNPCProfTXT_Raw = NULL; |
1583 | 726 free(pNPCNamesTXT_Raw); |
291 | 727 pNPCNamesTXT_Raw = NULL; |
1583 | 728 free(pNPCDataTXT_Raw); |
291 | 729 pNPCDataTXT_Raw = NULL; |
1583 | 730 free(pNPCDistTXT_Raw); |
291 | 731 pNPCDistTXT_Raw = NULL; |
1583 | 732 free(pNPCGreetTXT_Raw); |
291 | 733 pNPCGreetTXT_Raw = NULL; |
1583 | 734 free(pNCPGroupTXT_Raw); |
291 | 735 pNCPGroupTXT_Raw = NULL; |
251 | 736 } |
737 | |
738 //----- (0047730C) -------------------------------------------------------- | |
307 | 739 bool CheckPortretAgainstSex(int a1, int) |
251 | 740 { |
291 | 741 return true; |
251 | 742 } |
743 // 47730C: using guessed type int __stdcall const_1(int); | |
744 | |
745 //----- (0047732C) -------------------------------------------------------- | |
291 | 746 void NPCStats::InitializeAdditionalNPCs(NPCData *pNPCDataBuff, int npc_uid, int uLocation2D, int uMapId) |
251 | 747 { |
292 | 748 int rep_gen; |
291 | 749 int uNPCSex; // esi@1 |
750 int uGeneratedPortret; // ecx@23 | |
751 int test_prof_summ; // ecx@37 | |
752 int gen_profession; // eax@37 | |
753 int max_prof_cap; // edx@37 | |
251 | 754 signed int result; // eax@39 |
291 | 755 int uRace; // [sp+Ch] [bp-Ch]@1 |
756 bool break_gen; // [sp+10h] [bp-8h]@1 | |
757 signed int gen_attempts; // [sp+14h] [bp-4h]@1 | |
758 int uPortretMin; // [sp+24h] [bp+Ch]@1 | |
759 int uPortretMax; | |
760 | |
761 static const unsigned __int8 NPCSexGenTable[86] ={ | |
293 | 762 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
763 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, | |
764 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, | |
765 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
766 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }; | |
767 static const unsigned __int8 NPCRaceGenTable[86] ={ | |
768 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, | |
769 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
770 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, | |
771 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
772 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0}; | |
251 | 773 |
307 | 774 unsigned __int8 seed = (unsigned __int8)((double)(npc_uid - 1)/3.0); |
291 | 775 uNPCSex = NPCSexGenTable[seed]; |
776 uRace = NPCRaceGenTable[seed]; | |
777 pNPCDataBuff->uSex = uNPCSex; | |
778 pNPCDataBuff->pName = pNPCNames[rand() % uNumNPCNames[uNPCSex]][uNPCSex]; | |
779 | |
780 gen_attempts = 0; | |
781 break_gen = false; | |
251 | 782 |
291 | 783 do |
251 | 784 { |
293 | 785 switch ( uRace ) |
786 { | |
787 case 0: | |
788 if ( uNPCSex == 0 ) | |
291 | 789 { |
790 uPortretMin = 2; | |
791 uPortretMax = 100; | |
251 | 792 } |
793 else | |
794 { | |
293 | 795 uPortretMin = 201; |
796 uPortretMax = 250; | |
797 } | |
798 case 1: | |
799 if ( uNPCSex == 0 ) | |
800 { | |
801 uPortretMin = 400; | |
802 uPortretMax = 430; | |
803 } | |
804 else | |
805 { | |
806 uPortretMin = 460; | |
807 uPortretMax = 490; | |
808 } | |
809 break; | |
810 case 2: | |
811 if ( uNPCSex == 0 ) | |
812 { | |
813 uPortretMin = 500; | |
814 uPortretMax = 520; | |
815 } | |
816 else | |
817 { | |
818 uPortretMin = 530; | |
819 uPortretMax = 550; | |
820 } | |
821 break; | |
822 case 3: | |
823 if ( uNPCSex == 0 ) | |
824 { | |
825 uPortretMin = 300; | |
826 uPortretMax = 330; | |
827 } | |
828 else | |
829 { | |
830 uPortretMin = 360; | |
831 uPortretMax = 387; | |
251 | 832 } |
291 | 833 |
293 | 834 break; |
835 } | |
836 | |
291 | 837 uGeneratedPortret = uPortretMin + rand() % (uPortretMax - uPortretMin + 1); |
307 | 838 if ( CheckPortretAgainstSex(uGeneratedPortret, uNPCSex)) |
291 | 839 break_gen = true; |
840 ++gen_attempts; | |
841 if ( gen_attempts >= 4 ) | |
251 | 842 { |
291 | 843 uGeneratedPortret = uPortretMin; |
844 break_gen = true; | |
251 | 845 } |
846 } | |
291 | 847 while(!break_gen); |
251 | 848 |
293 | 849 pNPCDataBuff->uPortraitID = uGeneratedPortret; |
850 pNPCDataBuff->uFlags = 0; | |
851 pNPCDataBuff->fame = 0; | |
852 //generate reputation | |
853 rep_gen = rand() % 100 + 1; | |
251 | 854 |
293 | 855 if ( rep_gen >= 60 ) |
251 | 856 { |
293 | 857 if ( rep_gen >= 90 ) |
251 | 858 { |
293 | 859 if ( rep_gen >= 95 ) |
860 { | |
861 if ( rep_gen >= 98 ) | |
862 pNPCDataBuff->rep = -600; | |
863 else | |
864 pNPCDataBuff->rep = 400; | |
865 } | |
251 | 866 else |
293 | 867 pNPCDataBuff->rep = -300; |
251 | 868 } |
869 else | |
293 | 870 pNPCDataBuff->rep = 200; |
251 | 871 } |
872 else | |
293 | 873 pNPCDataBuff->rep = 0; |
291 | 874 |
293 | 875 max_prof_cap = rand() % pProfessionChance[uMapId].uTotalprofChance+1; |
876 test_prof_summ = 0; | |
877 gen_profession = 0; | |
251 | 878 |
293 | 879 if ( max_prof_cap > 0 ) |
880 { | |
881 do | |
882 test_prof_summ += pProfessionChance[uMapId].professionChancePerArea[gen_profession++]; | |
883 while ( test_prof_summ < max_prof_cap ); | |
884 } | |
885 pNPCDataBuff->uProfession = gen_profession - 1; | |
886 pNPCDataBuff->Location2D = uLocation2D; | |
887 pNPCDataBuff->field_24 = 1; | |
888 pNPCDataBuff->joins = 1; | |
659 | 889 pNPCDataBuff->evt_A = 0; |
890 pNPCDataBuff->evt_B = 0; | |
891 pNPCDataBuff->evt_C = 0; | |
892 pNPCDataBuff->evt_D = 0; | |
893 pNPCDataBuff->evt_E = 0; | |
894 pNPCDataBuff->evt_F = 0; | |
251 | 895 } |
896 | |
257 | 897 //----- (00476387) -------------------------------------------------------- |
898 bool PartyHasDragon() | |
899 { | |
900 return pNPCStats->pNewNPCData[57].Hired(); | |
901 } | |
251 | 902 |
903 //----- (00476395) -------------------------------------------------------- | |
904 //0x26 Wizard eye at skill level 2 | |
1458 | 905 bool CheckHiredNPCSpeciality(unsigned int uProfession) |
1094 | 906 { |
907 | |
908 if ( bNoNPCHiring == 1 ) | |
909 return 0; | |
251 | 910 |
1094 | 911 for (int i=0; i<pNPCStats->uNumNewNPCs; ++i ) |
912 { | |
913 if ( pNPCStats->pNewNPCData[i].uProfession == uProfession && | |
914 (pNPCStats->pNewNPCData[i].uFlags & 0x80) ) | |
915 return true; | |
916 } | |
917 if ( pParty->pHirelings[0].uProfession == uProfession || | |
918 pParty->pHirelings[1].uProfession == uProfession) | |
919 return true; | |
920 else | |
921 return false; | |
922 | |
923 } | |
251 | 924 // 6BE3C5: using guessed type char bNoNPCHiring; |
925 | |
926 //----- (004763E0) -------------------------------------------------------- | |
927 void InitializeAwards() | |
949 | 928 { |
251 | 929 int i; |
930 char* test_string; | |
931 unsigned char c; | |
932 bool break_loop; | |
933 unsigned int temp_str_len; | |
934 char* tmp_pos; | |
935 int decode_step; | |
936 | |
937 if ( pAwardsTXT_Raw ) | |
1583 | 938 free(pAwardsTXT_Raw); |
251 | 939 pAwardsTXT_Raw = NULL; |
940 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); | |
941 strtok(pAwardsTXT_Raw, "\r"); | |
942 | |
949 | 943 for (i=1; i<105; ++i) |
251 | 944 { |
945 test_string = strtok(NULL, "\r") + 1; | |
946 break_loop = false; | |
947 decode_step=0; | |
948 do | |
949 { | |
950 c = *(unsigned char*)test_string; | |
951 temp_str_len = 0; | |
952 while((c!='\t')&&(c>0)) | |
953 { | |
954 ++temp_str_len; | |
955 c=test_string[temp_str_len]; | |
956 } | |
957 tmp_pos=test_string+temp_str_len; | |
958 if (*tmp_pos == 0) | |
959 break_loop = true; | |
960 *tmp_pos = 0; | |
961 if (temp_str_len) | |
962 { | |
963 if (decode_step==1) | |
964 pAwards[i].pText=RemoveQuotes(test_string); | |
965 else if (decode_step==2) | |
949 | 966 pAwards[i].uPriority = atoi(test_string); |
251 | 967 } |
968 else | |
969 { | |
970 break_loop = true; | |
971 } | |
972 ++decode_step; | |
973 test_string=tmp_pos+1; | |
974 } while ((decode_step<3)&&!break_loop); | |
975 } | |
976 } | |
977 // 7241C8: using guessed type int dword_7241C8; | |
978 | |
979 //----- (004764C2) -------------------------------------------------------- | |
980 void InitializeScrolls() | |
981 { | |
982 | |
983 int i; | |
984 char* test_string; | |
985 unsigned char c; | |
986 bool break_loop; | |
987 unsigned int temp_str_len; | |
988 char* tmp_pos; | |
989 int decode_step; | |
990 | |
991 if ( pScrollsTXT_Raw ) | |
1583 | 992 free(pScrollsTXT_Raw); |
251 | 993 pScrollsTXT_Raw = NULL; |
994 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); | |
995 strtok(pScrollsTXT_Raw, "\r"); | |
996 for (i=0; i<82; ++i) | |
997 { | |
998 test_string = strtok(NULL, "\r") + 1; | |
999 break_loop = false; | |
1000 decode_step=0; | |
1001 do | |
1002 { | |
1003 c = *(unsigned char*)test_string; | |
1004 temp_str_len = 0; | |
1005 while((c!='\t')&&(c>0)) | |
1006 { | |
1007 ++temp_str_len; | |
1008 c=test_string[temp_str_len]; | |
1009 } | |
1010 tmp_pos=test_string+temp_str_len; | |
1011 if (*tmp_pos == 0) | |
1012 break_loop = true; | |
1013 *tmp_pos = 0; | |
1014 if (temp_str_len) | |
1015 { | |
1016 if ( decode_step == 1) | |
1017 pScrolls[i]=RemoveQuotes(test_string); | |
1018 } | |
1019 else | |
1020 { | |
1021 break_loop = true; | |
1022 } | |
1023 ++decode_step; | |
1024 test_string=tmp_pos+1; | |
1025 } while ((decode_step<2)&&!break_loop); | |
1026 } | |
1027 } | |
1028 | |
1029 //----- (00476590) -------------------------------------------------------- | |
1030 void InitializeMerchants() | |
1031 { | |
1032 int i; | |
1033 char* test_string; | |
1034 unsigned char c; | |
1035 bool break_loop; | |
1036 unsigned int temp_str_len; | |
1037 char* tmp_pos; | |
1038 int decode_step; | |
1039 | |
1040 if ( pMerchantsTXT_Raw ) | |
1583 | 1041 free(pMerchantsTXT_Raw); |
251 | 1042 pMerchantsTXT_Raw = NULL; |
1043 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); | |
1044 strtok(pMerchantsTXT_Raw, "\r"); | |
1045 | |
1046 for (i=0; i<7; ++i) | |
1047 { | |
1048 test_string = strtok(NULL, "\r") + 1; | |
1049 break_loop = false; | |
1050 decode_step=0; | |
1051 do | |
1052 { | |
1053 c = *(unsigned char*)test_string; | |
1054 temp_str_len = 0; | |
1055 while((c!='\t')&&(c>0)) | |
1056 { | |
1057 ++temp_str_len; | |
1058 c=test_string[temp_str_len]; | |
1059 } | |
1060 tmp_pos=test_string+temp_str_len; | |
1061 if (*tmp_pos == 0) | |
1062 break_loop = true; | |
1063 *tmp_pos = 0; | |
1064 if (temp_str_len) | |
1065 { | |
1066 switch (decode_step) | |
1067 { | |
1068 case 1: | |
1069 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string); | |
1070 break; | |
1071 case 2: | |
1072 pMerchantsSellPhrases[i]=RemoveQuotes(test_string); | |
1073 break; | |
1074 case 3: | |
1075 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); | |
1076 break; | |
1077 case 4: | |
1078 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); | |
1079 break; | |
1080 } | |
1081 } | |
1082 else | |
1083 { | |
1084 break_loop = true; | |
1085 } | |
1086 ++decode_step; | |
1087 test_string=tmp_pos+1; | |
1088 } while ((decode_step<5)&&!break_loop); | |
1089 } | |
1090 | |
1091 } | |
1092 | |
1093 //----- (00476682) -------------------------------------------------------- | |
1094 void InitializeTransitions() | |
1095 { | |
1096 int i; | |
1097 char* test_string; | |
1098 unsigned char c; | |
1099 bool break_loop; | |
1100 unsigned int temp_str_len; | |
1101 char* tmp_pos; | |
1102 int decode_step; | |
1103 | |
1104 if ( pTransitionsTXT_Raw ) | |
1583 | 1105 free(pTransitionsTXT_Raw); |
251 | 1106 pTransitionsTXT_Raw = NULL; |
1107 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); | |
1108 strtok(pTransitionsTXT_Raw, "\r"); | |
1109 | |
1110 for (i=0; i<464; ++i) | |
1111 { | |
1112 test_string = strtok(NULL, "\r") + 1; | |
1113 break_loop = false; | |
1114 decode_step=0; | |
1115 do | |
1116 { | |
1117 c = *(unsigned char*)test_string; | |
1118 temp_str_len = 0; | |
1119 while((c!='\t')&&(c>0)) | |
1120 { | |
1121 ++temp_str_len; | |
1122 c=test_string[temp_str_len]; | |
1123 } | |
1124 tmp_pos=test_string+temp_str_len; | |
1125 if (*tmp_pos == 0) | |
1126 break_loop = true; | |
1127 *tmp_pos = 0; | |
1128 if (temp_str_len) | |
1129 { | |
1130 if ( decode_step == 1) | |
434 | 1131 pTransitionStrings[i + 1]=RemoveQuotes(test_string); |
251 | 1132 } |
1133 else | |
1134 { | |
1135 break_loop = true; | |
1136 } | |
1137 ++decode_step; | |
1138 test_string=tmp_pos+1; | |
1139 } while ((decode_step<2)&&!break_loop); | |
1140 } | |
1141 } | |
1142 | |
1143 //----- (00476750) -------------------------------------------------------- | |
1458 | 1144 void InitializeAutonotes() |
251 | 1145 { |
1146 int i; | |
1147 char* test_string; | |
1148 unsigned char c; | |
1149 bool break_loop; | |
1150 unsigned int temp_str_len; | |
1151 char* tmp_pos; | |
1152 int decode_step; | |
1153 | |
1154 if ( pAutonoteTXT_Raw ) | |
1583 | 1155 free(pAutonoteTXT_Raw); |
251 | 1156 pAutonoteTXT_Raw = 0; |
1157 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); | |
1158 strtok(pAutonoteTXT_Raw, "\r"); | |
1159 | |
1160 for (i=0; i<195; ++i) | |
1161 { | |
1162 test_string = strtok(NULL, "\r") + 1; | |
1163 break_loop = false; | |
1164 decode_step=0; | |
1165 do | |
1166 { | |
1167 c = *(unsigned char*)test_string; | |
1168 temp_str_len = 0; | |
1169 while((c!='\t')&&(c>0)) | |
1170 { | |
1171 ++temp_str_len; | |
1172 c=test_string[temp_str_len]; | |
1173 } | |
1174 tmp_pos=test_string+temp_str_len; | |
1175 if (*tmp_pos == 0) | |
1176 break_loop = true; | |
1177 *tmp_pos = 0; | |
1178 if (temp_str_len) | |
1179 { | |
1180 switch (decode_step) | |
1181 { | |
1182 case 1: | |
1310 | 1183 pAutonoteTxt[i+1].pText=RemoveQuotes(test_string); |
251 | 1184 break; |
1185 case 2: | |
1186 { | |
1104 | 1187 if ( !_stricmp(test_string, "potion")) |
251 | 1188 { |
1310 | 1189 pAutonoteTxt[i+1].eType = AUTONOTE_POTION_RECEPIE; |
251 | 1190 break; |
1191 } | |
1104 | 1192 if ( !_stricmp(test_string, "stat") ) |
251 | 1193 { |
1310 | 1194 pAutonoteTxt[i+1].eType = AUTONOTE_STAT_HINT; |
251 | 1195 break; |
1196 } | |
1104 | 1197 if ( !_stricmp(test_string, "seer") ) |
251 | 1198 { |
1310 | 1199 pAutonoteTxt[i+1].eType = AUTONOTE_SEER; |
251 | 1200 break; |
1201 } | |
1104 | 1202 if ( !_stricmp(test_string, "obelisk") ) |
251 | 1203 { |
1310 | 1204 pAutonoteTxt[i+1].eType = AUTONOTE_OBELISK; |
251 | 1205 break; |
1206 } | |
1104 | 1207 if ( !_stricmp(test_string, "teacher") ) |
251 | 1208 { |
1310 | 1209 pAutonoteTxt[i+1].eType = AUTONOTE_TEACHER; |
251 | 1210 break; |
1211 } | |
1310 | 1212 pAutonoteTxt[i+1].eType =AUTONOTE_MISC; |
251 | 1213 break; |
1214 } | |
1215 } | |
1216 } | |
1217 else | |
1218 { | |
1219 break_loop = true; | |
1220 } | |
1221 ++decode_step; | |
1222 test_string=tmp_pos+1; | |
1223 } while ((decode_step<3)&&!break_loop); | |
1224 } | |
1225 } | |
1226 | |
1227 | |
1228 //----- (004768A9) -------------------------------------------------------- | |
1458 | 1229 void InitializeQuests() |
251 | 1230 { |
1231 int i; | |
1232 char* test_string; | |
1233 unsigned char c; | |
1234 bool break_loop; | |
1235 unsigned int temp_str_len; | |
1236 char* tmp_pos; | |
1237 int decode_step; | |
1238 | |
1239 if ( pQuestsTXT_Raw ) | |
1583 | 1240 free(pQuestsTXT_Raw); |
251 | 1241 pQuestsTXT_Raw = NULL; |
1242 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); | |
1243 strtok(pQuestsTXT_Raw, "\r"); | |
1310 | 1244 memset(pQuestTable.data(),0, sizeof(pQuestTable)); |
251 | 1245 for (i=0; i<512; ++i) |
1246 { | |
1247 test_string = strtok(NULL, "\r") + 1; | |
1248 break_loop = false; | |
1249 decode_step=0; | |
1250 do | |
1251 { | |
1252 c = *(unsigned char*)test_string; | |
1253 temp_str_len = 0; | |
1254 while((c!='\t')&&(c>0)) | |
1255 { | |
1256 ++temp_str_len; | |
1257 c=test_string[temp_str_len]; | |
1258 } | |
1259 tmp_pos=test_string+temp_str_len; | |
1260 if (*tmp_pos == 0) | |
1261 break_loop = true; | |
1262 *tmp_pos = 0; | |
1263 if (temp_str_len) | |
1264 { | |
1265 if ( decode_step == 1) | |
1310 | 1266 pQuestTable[i+1] =RemoveQuotes(test_string); |
251 | 1267 } |
1268 else | |
1269 { | |
1270 break_loop = true; | |
1271 } | |
1272 ++decode_step; | |
1273 test_string=tmp_pos+1; | |
1274 } while ((decode_step<2)&&!break_loop); | |
1275 } | |
1276 } | |
1277 | |
1295 | 1278 //----- (004B2001) -------------------------------------------------------- |
1279 void __fastcall ClickNPCTopic(signed int uMessageParam) | |
1280 { | |
1281 //signed int v1; // eax@1 | |
1282 NPCData *pCurrentNPCInfo; // ebp@1 | |
1283 int pEventNumber; // ecx@8 | |
1284 Player *v4; // esi@20 | |
1285 //int v5; // eax@28 | |
1286 //int v6; // eax@31 | |
1287 //int v7; // eax@34 | |
1288 //int v8; // eax@37 | |
1289 //int v9; // eax@40 | |
1290 //unsigned int v10; // eax@43 | |
1291 char *v12; // eax@53 | |
1292 char *v13; // eax@56 | |
1293 char *v14; // eax@57 | |
1294 char *v15; // eax@58 | |
1295 //unsigned int v16; // ebp@62 | |
1296 char *v17; // ecx@63 | |
1297 char *v18; // eax@65 | |
1298 const char *v19; // ecx@68 | |
1299 //unsigned int v20; // eax@69 | |
1300 signed int pPrice; // ecx@70 | |
1301 char *v22; // [sp-Ch] [bp-18h]@73 | |
1302 //int v23; // [sp-8h] [bp-14h]@49 | |
1303 char *v24; // [sp-8h] [bp-14h]@73 | |
1304 //int v25; // [sp-4h] [bp-10h]@49 | |
1305 | |
1306 uDialogueType = uMessageParam + 1; | |
1313 | 1307 pCurrentNPCInfo = HouseNPCData[pDialogueNPCCount -((dword_591080 != 0)?1:0 )];//- 1 |
1295 | 1308 if ( uMessageParam <= 24 ) |
1309 { | |
1310 switch ( uMessageParam ) | |
1311 { | |
1312 case 13: | |
1313 current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1313
diff
changeset
|
1314 current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); |
1295 | 1315 NPCHireableDialogPrepare(); |
1316 dialogue_show_profession_details = false; | |
1317 goto _return; | |
1318 case 19: | |
1319 pEventNumber = pCurrentNPCInfo->evt_A; | |
1320 break; | |
1321 case 20: | |
1322 pEventNumber = pCurrentNPCInfo->evt_B; | |
1323 break; | |
1324 case 21: | |
1325 pEventNumber = pCurrentNPCInfo->evt_C; | |
1326 break; | |
1327 case 22: | |
1328 pEventNumber = pCurrentNPCInfo->evt_D; | |
1329 break; | |
1330 case 23: | |
1331 pEventNumber = pCurrentNPCInfo->evt_E; | |
1332 break; | |
1333 case 24: | |
1334 pEventNumber = pCurrentNPCInfo->evt_F; | |
1335 break; | |
1336 default: | |
1337 goto _return; | |
1338 } | |
1339 /*switch ( pEventNumber ) | |
1340 { | |
1341 case 139: | |
1459 | 1342 OracleDialogue(); |
1295 | 1343 goto _return; |
1344 case 311: | |
1529 | 1345 CheckBountyRespawnAndAward(); |
1295 | 1346 goto _return; |
1347 }*/ | |
1348 if ( pEventNumber < 200 || pEventNumber > 310 ) | |
1349 { | |
1350 if ( pEventNumber < 400 || pEventNumber > 410 ) | |
1351 { | |
1352 if ( pEventNumber == 139 ) | |
1353 { | |
1459 | 1354 OracleDialogue(); |
1295 | 1355 } |
1356 else | |
1357 { | |
1358 if ( pEventNumber == 311 ) | |
1359 { | |
1529 | 1360 CheckBountyRespawnAndAward(); |
1295 | 1361 } |
1362 else | |
1363 { | |
1364 current_npc_text = 0; | |
1365 activeLevelDecoration = (LevelDecoration*)1; | |
1366 EventProcessor(pEventNumber, 0, 1); | |
1367 activeLevelDecoration = NULL; | |
1368 } | |
1369 } | |
1370 } | |
1371 else | |
1372 { | |
1373 dword_F8B1D8 = uMessageParam; | |
1374 DrawJoinGuildWindow(pEventNumber - 400); | |
1375 } | |
1376 } | |
1377 else | |
1378 { | |
1582 | 1379 _4B3FE5_training_dialogue(pEventNumber); |
1295 | 1380 } |
1381 goto _return; | |
1382 } | |
1383 if ( uMessageParam != 76 ) | |
1384 { | |
1385 if ( uMessageParam == 77 ) | |
1386 { | |
1387 //v16 = pCurrentNPCInfo->uProfession; | |
1388 if (dialogue_show_profession_details) | |
1389 v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; | |
1390 else | |
1391 v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits; | |
1392 current_npc_text = v17; | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1313
diff
changeset
|
1393 v18 = BuildDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); |
1295 | 1394 dialogue_show_profession_details = ~dialogue_show_profession_details; |
1395 current_npc_text = v18; | |
1396 } | |
1397 else | |
1398 { | |
1399 if ( uMessageParam == 79 ) | |
1400 { | |
1401 if ( contract_approved ) | |
1402 { | |
1403 Party::TakeGold(gold_transaction_amount); | |
1404 if ( uActiveCharacter ) | |
1405 { | |
1406 v12 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1407 *(short *)v12 &= 0x3Fu; | |
1408 switch ( dword_F8B1B0 ) | |
1409 { | |
1410 case 2: | |
1411 v15 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1412 *v15 |= 0x40u; | |
1413 break; | |
1414 case 3: | |
1415 v14 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1416 *v14 |= 0x80u; | |
1417 break; | |
1418 case 4: | |
1419 v13 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1420 v13[1] |= 1u; | |
1421 break; | |
1422 } | |
1423 pPlayers[uActiveCharacter]->PlaySound(SPEECH_85, 0); | |
1424 } | |
1425 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
1426 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1427 { | |
1428 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
1429 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
1430 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1431 ++pMessageQueue_50CBD0->uNumMessages; | |
1432 }*/ | |
1433 } | |
1434 } | |
1435 else | |
1436 { | |
1437 if ( uMessageParam == 82 && contract_approved ) //join guild | |
1438 { | |
1439 Party::TakeGold(gold_transaction_amount); | |
1440 v4 = pParty->pPlayers; | |
1441 do | |
1442 { | |
1443 v4->SetVariable(VAR_Award, dword_F8B1AC_award_bit_number); | |
1444 ++v4; | |
1445 } | |
1446 while ( (signed int)v4 < (signed int)pParty->pHirelings ); | |
1447 switch ( dword_F8B1D8 ) | |
1448 { | |
1449 case 19: | |
1450 pEventNumber = pCurrentNPCInfo->evt_A; | |
1451 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1452 pCurrentNPCInfo->evt_A = 0; | |
1453 break; | |
1454 case 20: | |
1455 pEventNumber = pCurrentNPCInfo->evt_B; | |
1456 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1457 pCurrentNPCInfo->evt_B = 0; | |
1458 break; | |
1459 case 21: | |
1460 pEventNumber = pCurrentNPCInfo->evt_C; | |
1461 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1462 pCurrentNPCInfo->evt_C = 0; | |
1463 break; | |
1464 case 22: | |
1465 pEventNumber = pCurrentNPCInfo->evt_D; | |
1466 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1467 pCurrentNPCInfo->evt_D = 0; | |
1468 break; | |
1469 case 23: | |
1470 pEventNumber = pCurrentNPCInfo->evt_E; | |
1471 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1472 pCurrentNPCInfo->evt_E = 0; | |
1473 break; | |
1474 case 24: | |
1475 pEventNumber = pCurrentNPCInfo->evt_F; | |
1476 if ( pEventNumber >= 400 && pEventNumber <= 416) | |
1477 pCurrentNPCInfo->evt_F = 0; | |
1478 break; | |
1479 } | |
1480 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
1481 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1482 { | |
1483 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
1484 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
1485 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1486 ++pMessageQueue_50CBD0->uNumMessages; | |
1487 }*/ | |
1488 //v11 = uActiveCharacter; | |
1489 if ( uActiveCharacter ) | |
1490 { | |
1491 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_86, 0); | |
1492 goto _return; | |
1493 } | |
1494 } | |
1495 } | |
1496 } | |
1497 goto _return; | |
1498 } | |
1499 if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) | |
1500 { | |
1501 ShowStatusBarString(pGlobalTXT_LocalizationStrings[533], 2);// ""I cannot join you, you're party is full"" | |
1502 goto _return; | |
1503 } | |
1504 if ( pCurrentNPCInfo->uProfession != 51 ) | |
1505 { | |
1506 pPrice = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].uHirePrice; | |
1507 if ( pParty->uNumGold < pPrice ) | |
1508 { | |
1509 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); | |
1510 dialogue_show_profession_details = false; | |
1511 uDialogueType = 13; | |
1512 current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1313
diff
changeset
|
1513 current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); |
1295 | 1514 if ( uActiveCharacter ) |
1515 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); | |
1516 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); | |
1517 goto _return; | |
1518 } | |
1519 Party::TakeGold(pPrice); | |
1520 } | |
1521 //LOBYTE(v2->uFlags) |= 0x80u; | |
1522 pCurrentNPCInfo->uFlags |= 128; | |
1793
4dee76d79c78
dword_5B65CC to npcIdToDismissAfterDialogue, Party::field_709 to Party::hirelingScrollPosition
Grumpy7
parents:
1662
diff
changeset
|
1523 pParty->hirelingScrollPosition = 0; |
1295 | 1524 pParty->CountHirelings(); |
1525 if ( pParty->pHirelings[0].pName ) | |
1526 { | |
1527 memcpy(&pParty->pHirelings[1], pCurrentNPCInfo, sizeof(pParty->pHirelings[1])); | |
1528 v24 = pCurrentNPCInfo->pName; | |
1529 v22 = pParty->pHireling2Name; | |
1530 } | |
1531 else | |
1532 { | |
1533 memcpy(pParty->pHirelings, pCurrentNPCInfo, 0x4Cu); | |
1534 v24 = pCurrentNPCInfo->pName; | |
1535 v22 = pParty->pHireling1Name; | |
1536 } | |
1537 strcpy(v22, v24); | |
1793
4dee76d79c78
dword_5B65CC to npcIdToDismissAfterDialogue, Party::field_709 to Party::hirelingScrollPosition
Grumpy7
parents:
1662
diff
changeset
|
1538 pParty->hirelingScrollPosition = 0; |
1295 | 1539 pParty->CountHirelings(); |
1540 PrepareHouse((HOUSE_ID)(int)window_SpeakInHouse->ptr_1C); | |
1541 dialog_menu_id = HOUSE_DIALOGUE_MAIN; | |
1542 | |
1543 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
1544 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1545 { | |
1546 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
1547 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
1548 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1549 ++pMessageQueue_50CBD0->uNumMessages; | |
1550 }*/ | |
1551 if ( uActiveCharacter ) | |
1552 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)61, 0); | |
1553 _return: | |
1554 pVideoPlayer->_4BF5B2();//HouseVideo | |
1555 } | |
1556 //----- (004B29F2) -------------------------------------------------------- | |
1557 const char * ContractSelectText( int pEventCode ) | |
1558 { | |
1559 static const int dialogue_base=110; | |
1560 contract_approved = 0; | |
1561 dword_F8B1AC_award_bit_number = pEventCode + 50; | |
1562 gold_transaction_amount = price_for_membership[pEventCode]; | |
1563 if ( pPlayers[uActiveCharacter]->CanAct() ) | |
1564 { | |
1460
ff2118028c71
renaming _guilds_member_bits to _achieved_awards_bits
Gloval
parents:
1411
diff
changeset
|
1565 if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits, dword_F8B1AC_award_bit_number) ) |
1295 | 1566 { |
1567 return pNPCTopics[dialogue_base+13].pText; | |
1568 } | |
1569 else | |
1570 { | |
1571 if ( gold_transaction_amount <= pParty->uNumGold ) | |
1572 { | |
1573 contract_approved = 1; | |
1574 return pNPCTopics[pEventCode + dialogue_base].pText; | |
1575 } | |
1576 else | |
1577 { | |
1578 return pNPCTopics[dialogue_base+14].pText; | |
1579 } | |
1580 } | |
1581 } | |
1582 else | |
1583 { | |
1584 return pNPCTopics[dialogue_base+12].pText; | |
1585 } | |
1586 } | |
1587 //----- (004B40E6) -------------------------------------------------------- | |
1588 void NPCHireableDialogPrepare() | |
1589 { | |
1590 signed int v0; // ebx@1 | |
1591 NPCData *v1; // edi@1 | |
1592 | |
1593 v0 = 0; | |
1594 v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 | |
1595 pDialogueWindow->Release(); | |
1596 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0); | |
1597 pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, | |
1598 pGlobalTXT_LocalizationStrings[34], //"Cancel" | |
1599 pIcons_LOD->GetTexture(uExitCancelTextureId), | |
1600 0); | |
1601 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); | |
1602 if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) ) | |
1603 { | |
1604 pDialogueWindow->CreateButton( 0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Du, 0, | |
1605 pGlobalTXT_LocalizationStrings[407], 0);//"More Information" | |
1606 v0 = 1; | |
1607 } | |
1608 pDialogueWindow->CreateButton( 0x1E0u, 30 * v0 + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Cu, 0, | |
1609 pGlobalTXT_LocalizationStrings[406], 0); //"Hire" | |
1610 pDialogueWindow->_41D08F_set_keyboard_control_group(v0 + 1, 1, 0, 2); | |
1611 dialog_menu_id = HOUSE_DIALOGUE_OTHER; | |
1612 } | |
1613 | |
1614 //----- (004B4224) -------------------------------------------------------- | |
1615 void _4B4224_UpdateNPCTopics( int _this ) | |
1616 { | |
1617 int num_menu_buttons; // ebx@1 | |
1618 int i; // ebp@5 | |
1619 // signed int v4; // ebp@9 | |
1620 int v6; // eax@16 | |
1621 int v8; // eax@21 | |
1622 int v10; // eax@26 | |
1623 int v12; // eax@31 | |
1624 int v14; // eax@36 | |
1625 int v16; // eax@41 | |
1626 NPCData *v17; // [sp+10h] [bp-4h]@4 | |
1627 | |
1628 num_menu_buttons = 0; | |
1629 pDialogueNPCCount = (_this + 1); | |
1630 if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) | |
1631 { | |
1632 pDialogueWindow->Release(); | |
1633 pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); | |
1634 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName); | |
1635 pBtn_ExitCancel = pDialogueWindow->CreateButton(566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// "Cancel" | |
1636 pBtn_YES = pDialogueWindow->CreateButton(486, 445, 75, 33, 1, 0, UIMSG_BF, 1, 'Y', sHouseName.data(), pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0); | |
1637 pDialogueWindow->CreateButton( pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63u, 73u, 1, 0, UIMSG_BF, 1u, 0x20u, sHouseName.data(), 0); | |
1638 pDialogueWindow->CreateButton(8, 8, 460, 344, 1, 0, UIMSG_BF, 1, 0x59u, sHouseName.data(), 0); | |
1639 } | |
1640 else | |
1641 { | |
1313 | 1642 v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0)?1:0 )];//+ 1 |
1295 | 1643 if ( dialog_menu_id == HOUSE_DIALOGUE_OTHER ) |
1644 { | |
1645 pDialogueWindow->Release(); | |
1646 } | |
1647 else | |
1648 { | |
1649 for ( i = 0; i < uNumDialogueNPCPortraits; ++i ) | |
1589 | 1650 HouseNPCPortraitsButtonsList[i]->Release(); |
1295 | 1651 } |
1652 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); | |
1653 pBtn_ExitCancel = pDialogueWindow->CreateButton( 471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, | |
1654 pGlobalTXT_LocalizationStrings[74],// "End Conversation" | |
1655 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); | |
1656 pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); | |
1657 if ( pDialogueNPCCount == 1 && dword_591080 ) | |
1658 { | |
1411 | 1659 InitializaDialogueOptions(in_current_building_type); |
1295 | 1660 } |
1661 else | |
1662 { | |
1663 if ( v17->joins ) | |
1664 { | |
1665 num_menu_buttons = 1; | |
1666 pDialogueWindow->CreateButton(480u, 160u, 140u, 30, 1, 0, UIMSG_ClickNPCTopic, 0xDu, 0, "", 0); | |
1667 } | |
1668 if ( v17->evt_A) | |
1669 { | |
1670 if ( num_menu_buttons < 4 ) | |
1671 { | |
1672 v6 = NPC_EventProcessor(v17->evt_A); | |
1673 if ( v6 == 1 || v6 == 2 ) | |
1674 pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x13u, 0, "", 0); | |
1675 } | |
1676 } | |
1677 if ( v17->evt_B ) | |
1678 { | |
1679 if ( num_menu_buttons < 4 ) | |
1680 { | |
1681 v8 = NPC_EventProcessor(v17->evt_B); | |
1682 if ( v8 == 1 || v8 == 2 ) | |
1683 pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x14u, 0, "", 0); | |
1684 } | |
1685 } | |
1686 if ( v17->evt_C ) | |
1687 { | |
1688 if ( num_menu_buttons < 4 ) | |
1689 { | |
1690 v10 = NPC_EventProcessor(v17->evt_C); | |
1691 if ( v10 == 1 || v10 == 2 ) | |
1692 pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x15u, 0, "", 0); | |
1693 } | |
1694 } | |
1695 | |
1696 if ( v17->evt_D ) | |
1697 { | |
1698 if ( num_menu_buttons < 4 ) | |
1699 { | |
1700 v12 = NPC_EventProcessor(v17->evt_D); | |
1701 if ( v12 == 1 || v12 == 2 ) | |
1702 pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x16u, 0, "", 0); | |
1703 } | |
1704 } | |
1705 if ( v17->evt_E ) | |
1706 { | |
1707 if ( num_menu_buttons < 4 ) | |
1708 { | |
1709 v14 = NPC_EventProcessor(v17->evt_E); | |
1710 if ( v14 == 1 || v14 == 2 ) | |
1711 pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x17u, 0, "", 0); | |
1712 } | |
1713 } | |
1714 if ( v17->evt_F ) | |
1715 { | |
1716 if ( num_menu_buttons < 4 ) | |
1717 { | |
1718 v16 = NPC_EventProcessor(v17->evt_F); | |
1719 if ( v16 == 1 || v16 == 2 ) | |
1720 pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x18u, 0, "", 0); | |
1721 } | |
1722 } | |
1723 pDialogueWindow->_41D08F_set_keyboard_control_group(num_menu_buttons, 1, 0, 2); | |
1724 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; | |
1725 } | |
1726 dialog_menu_id = HOUSE_DIALOGUE_MAIN; | |
1727 } | |
1728 | |
1729 } | |
1730 //----- (004466C4) -------------------------------------------------------- | |
1731 int NPC_EventProcessor(int npc_event_id, int entry_line) | |
1732 { | |
1733 signed int event_index; // ebp@1 | |
1734 int evt_seq_num; // esi@3 | |
1735 bool ready_to_exit; // [sp+Ch] [bp-Ch]@3 | |
1736 signed int npc_activity; // [sp+10h] [bp-8h]@3 | |
1737 int result; | |
1738 | |
1739 event_index = 0; | |
1740 if ( !npc_event_id ) | |
1741 return 0; | |
1742 evt_seq_num = entry_line; | |
1743 pSomeOtherEVT = pGlobalEVT.data(); | |
1744 uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents; | |
1745 memcpy(pSomeOtherEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); | |
1746 npc_activity = 1; | |
1747 ready_to_exit = false; | |
1748 if ( uSomeOtherEVT_NumEvents <= 0 ) | |
1749 return 2; | |
1750 do | |
1751 { | |
1752 if ( (pSomeOtherEVT_Events[event_index].uEventID == npc_event_id) && (pSomeOtherEVT_Events[event_index].event_sequence_num == evt_seq_num) ) | |
1753 { | |
1754 _evt_raw *_evt = (_evt_raw *)&pSomeOtherEVT[pSomeOtherEVT_Events[event_index].uEventOffsetInEVT]; | |
1755 switch(_evt->_e_type) | |
1756 { | |
1757 case EVENT_Exit: | |
1758 //exit | |
1759 if ( ready_to_exit ) | |
1760 result = npc_activity != 0; | |
1761 else | |
1762 result = 2; | |
1763 return result; | |
1764 break; | |
1765 case EVENT_OnCanShowDialogItemCmp: | |
1766 ready_to_exit = true; | |
1767 //v8 = (unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8); | |
1768 for(int i=0; i<4; ++i) | |
1769 { | |
1770 // if (pParty->pPlayers[i].CompareVariable((enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5] + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)), | |
1771 // v8)) | |
1772 if (pParty->pPlayers[i].CompareVariable((enum VariableType)EVT_WORD(_evt->v5), EVT_DWORD(_evt->v7))) | |
1773 { | |
1774 event_index = -1; | |
1775 evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; | |
1776 break; | |
1777 } | |
1778 } | |
1779 break; | |
1780 case EVENT_EndCanShowDialogItem : | |
1781 if ( ready_to_exit ) | |
1782 result = npc_activity != 0; | |
1783 else | |
1784 result = 2; | |
1785 return result; | |
1786 break; | |
1787 case EVENT_SetCanShowDialogItem : | |
1788 ready_to_exit = true; | |
1789 npc_activity = EVT_BYTE(_evt->v5); //(unsigned __int8)v7[5]; | |
1790 break; | |
1791 case EVENT_IsActorAssasinated : | |
1792 // if (IsActorAlive( (unsigned __int8)v7[5], | |
1793 // (unsigned __int8)v7[6] + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8), | |
1794 // (unsigned __int8)v7[10]) ) | |
1795 if (IsActorAlive( EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) | |
1796 { // drop linear sequense, going to new seq | |
1797 event_index = -1; | |
1798 evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; | |
1799 } | |
1800 break; | |
1801 } | |
1802 ++evt_seq_num; | |
1803 } | |
1804 ++event_index; | |
1805 } | |
1806 while ( event_index < uSomeOtherEVT_NumEvents ); | |
1807 if ( ready_to_exit ) | |
1808 result = npc_activity != 0; | |
1809 else | |
1810 result = 2; | |
1811 return result; | |
1812 } | |
1813 //----- (00445C8B) -------------------------------------------------------- | |
1814 int __fastcall GetGreetType(signed int SpeakingNPC_ID) | |
1815 { | |
1816 signed int v1; // ebx@1 | |
1817 int v3; // edi@6 | |
1818 int v4; // ecx@6 | |
1819 int v5; // edx@6 | |
1820 NPCData *v6; // eax@6 | |
1821 char *v7; // ebp@11 | |
1822 NPCData *v8; // esi@11 | |
1823 | |
1824 v1 = 0; | |
1825 if ( SpeakingNPC_ID >= 0 ) | |
1826 { | |
1827 if ( SpeakingNPC_ID < 5000 ) | |
1828 return 1;//QuestNPC_greet | |
1829 return 2;//HiredNPC_greet | |
1830 } | |
1831 if ( SpeakingNPC_ID >= 5000 ) | |
1832 return 2; | |
1833 v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; | |
1834 v4 = 0; | |
1835 v5 = 0; | |
1836 v6 = pParty->pHirelings; | |
1837 do | |
1838 { | |
1839 if ( v6->pName ) | |
1840 pTmpBuf[v4++] = v5; | |
1841 ++v6; | |
1842 ++v5; | |
1843 } | |
1844 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
1845 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
1846 { | |
1847 v7 = &pTmpBuf[v4]; | |
1848 v8 = pNPCStats->pNewNPCData; | |
1849 do | |
1850 { | |
1851 if (v8->Hired() && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) ) | |
1852 { | |
1853 if ( !pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName) ) | |
1854 *v7++ = v1 + 2; | |
1855 } | |
1856 ++v1; | |
1857 ++v8; | |
1858 } | |
1859 while ( v1 < (signed int)pNPCStats->uNumNewNPCs ); | |
1860 } | |
1861 return ((unsigned __int8)pTmpBuf[v3] < 2) + 1; | |
1862 } | |
1863 //----- (00445308) -------------------------------------------------------- | |
1864 const char *GetProfessionActionText(int a1) | |
1865 { | |
1866 if ( a1 == 10 | |
1867 || a1 == 11 | |
1868 || a1 == 12 | |
1869 || a1 == 33 | |
1870 || a1 == 34 | |
1871 || a1 == 39 | |
1872 || a1 == 40 | |
1873 || a1 == 41 | |
1874 || a1 == 42 | |
1875 || a1 == 43 | |
1876 || a1 == 52 ) | |
1877 return pNPCStats->pProfessions[a1 - 1].pActionText; | |
1878 else | |
1879 return pNPCTopics[407].pTopic; | |
1880 } |