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