Mercurial > mm7
annotate NPC.cpp @ 2400:ecd1dd95ec49
fixing 2 polishing bugs in GameUI_WritePointedObjectStatusString
author | Grumpy7 |
---|---|
date | Thu, 10 Jul 2014 01:48:39 +0200 |
parents | 802460e60eee |
children | 8cee51ce4382 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2239
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
2336 | 2 #include "mm7_unsorted_subs.h" |
251 | 3 #include "texts.h" |
4 #include "LOD.h" | |
5 #include "Autonotes.h" | |
6 #include "Awards.h" | |
7 #include "mm7_data.h" | |
8 #include "MM7.h" | |
1016 | 9 #include "Party.h" |
251 | 10 #include "NPC.h" |
1295 | 11 #include "GUIWindow.h" |
12 #include "VideoPlayer.h" | |
13 #include "Events.h" | |
1299 | 14 #include "UI\UIHouses.h" |
1295 | 15 #include "Indoor.h" |
16 #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
|
17 #include "Level/Decoration.h" |
2344 | 18 #include "Actor.h" |
2374 | 19 #include "AudioPlayer.h" |
20 #include "CastSpellInfo.h" | |
21 #include "Overlays.h" | |
251 | 22 |
629 | 23 int pDialogueNPCCount; |
1206
ab6560001f5b
arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents:
1165
diff
changeset
|
24 std::array<struct Texture *, 6> pDialogueNPCPortraits; |
629 | 25 int uNumDialogueNPCPortraits; // weak |
26 struct NPCStats *pNPCStats = nullptr; | |
27 | |
2229
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
28 int NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter = -1; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
29 int NPCStats::dword_AE3370_LastMispronouncedNameResult = -1; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
30 |
251 | 31 void InitializeAwards(); |
32 void InitializeScrolls(); | |
33 void InitializeMerchants(); | |
34 void InitializeTransitions(); | |
35 void InitializeAutonotes(); | |
36 void InitializeQuests(); | |
307 | 37 bool CheckPortretAgainstSex(int portret_num, int sex); |
251 | 38 |
781 | 39 //----- (004459F9) -------------------------------------------------------- |
40 NPCData *__fastcall GetNPCData(signed int npcid) | |
41 { | |
42 unsigned int v1; // esi@1 | |
43 NPCData *result; // eax@5 | |
44 int v3; // esi@9 | |
45 int v4; // ecx@9 | |
46 //int v5; // edx@9 | |
47 //NPCData *v6; // eax@9 | |
2334 | 48 // char *v7; // ebx@14 |
49 // NPCData *v8; // edi@14 | |
781 | 50 char v9; // al@22 |
2334 | 51 // char v10; |
781 | 52 //std::string v10; // [sp-18h] [bp-2Ch]@4 |
2334 | 53 // int v11; |
781 | 54 //const char *v11; // [sp-8h] [bp-1Ch]@4 |
2334 | 55 // int v12; // [sp-4h] [bp-18h]@4 |
56 // int v13; | |
57 // char *v14; | |
781 | 58 //std::string *v13; // [sp+Ch] [bp-8h]@4 |
2334 | 59 // int a3; // [sp+13h] [bp-1h]@4 |
781 | 60 int i; |
61 | |
62 /*v1 = npcid; | |
63 if ( (npcid & 0x80000000u) == 0 ) | |
64 { | |
65 if ( (signed int)npcid < 5000 ) | |
66 { | |
67 if ( (signed int)npcid >= 501 ) | |
68 { | |
69 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0); | |
70 } | |
71 return &pNPCStats->pNewNPCData[v1]; | |
72 } | |
73 return &pNPCStats->array_13EF4[npcid - 5000]; | |
74 } | |
75 if ( (signed int)npcid >= 5000 ) | |
76 return &pNPCStats->array_13EF4[npcid - 5000]; | |
77 if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) | |
78 { | |
79 result = 0; | |
80 } | |
81 else | |
82 { | |
83 v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; | |
84 v4 = 0; | |
85 v5 = 0; | |
86 v6 = pParty->pHirelings; | |
87 do | |
88 { | |
89 if ( v6->pName ) | |
90 pTmpBuf[v4++] = v5; | |
91 ++v6; | |
92 ++v5; | |
93 } | |
94 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
95 v13 = 0; | |
96 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
97 { | |
98 v7 = &pTmpBuf[v4]; | |
99 v8 = pNPCStats->pNewNPCData; | |
100 do | |
101 { | |
102 if ( v8->uFlags & 0x80 | |
103 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) | |
104 && (!pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName)) ) | |
105 *v7++ = (char)v13 + 2; | |
106 v13 = (std::string *)((char *)v13 + 1); | |
107 ++v8; | |
108 } | |
109 while ( (signed int)v13 < (signed int)pNPCStats->uNumNewNPCs ); | |
110 } | |
111 v9 = pTmpBuf[v3]; | |
112 if ( (unsigned __int8)v9 >= 2u ) | |
113 result = &pNPCStats->pNPCData[(unsigned __int8)v9 + 499]; | |
114 else | |
115 result = &pParty->pHirelings[(unsigned __int8)v9]; | |
116 } | |
117 return result;*/ | |
118 v1 = npcid; | |
119 if ( npcid >= 0 ) | |
120 { | |
121 if ( npcid < 5000 ) | |
122 { | |
123 if ( npcid >= 501 ) | |
124 { | |
125 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0); | |
126 } | |
127 return &pNPCStats->pNewNPCData[v1];// - 1]; | |
128 } | |
129 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
130 } | |
131 | |
132 | |
133 if ( npcid >= 5000 ) | |
134 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
135 if (sDialogue_SpeakingActorNPC_ID >= 0) | |
136 { | |
137 result = 0; | |
138 } | |
139 else | |
140 { | |
141 v3 = abs(sDialogue_SpeakingActorNPC_ID) - 1; | |
142 v4 = 0; | |
143 | |
144 for (i = 0; i < 2; ++i) | |
145 { | |
146 if (pParty->pHirelings[i].pName) | |
147 pTmpBuf[v4++] = i; | |
148 } | |
149 | |
150 if (pNPCStats->uNumNewNPCs > 0) | |
151 { | |
152 for (i = 0; i < pNPCStats->uNumNewNPCs; ++i) | |
153 { | |
154 if (pNPCStats->pNewNPCData[i].Hired()) | |
155 { | |
156 if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) | |
157 { | |
158 if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName)) | |
159 pTmpBuf[v4++] = i + 2; | |
160 } | |
161 } | |
162 } | |
163 } | |
164 | |
165 v9 = pTmpBuf[v3]; | |
166 if ( v9 >= 2 ) | |
167 result = &pNPCStats->pNPCData[499 + v9]; | |
168 else | |
169 result = &pParty->pHirelings[v9]; | |
170 } | |
1099 | 171 return result; |
781 | 172 } |
173 | |
174 //----- (00445B2C) -------------------------------------------------------- | |
1094 | 175 struct NPCData * GetNewNPCData( signed int npcid, int* npc_indx ) |
176 { | |
177 | |
178 int* v3; // edi@1 | |
781 | 179 NPCData *result; // eax@5 |
180 int v5; // esi@9 | |
181 int v6; // ecx@9 | |
182 char v11; // al@23 | |
183 | |
1094 | 184 v3 = npc_indx; |
781 | 185 if ( npcid >= 0 ) |
186 { | |
187 if ( npcid < 5000 ) | |
188 { | |
189 if ( npcid >= 501 ) | |
190 { | |
1094 | 191 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0); |
781 | 192 } |
1094 | 193 *v3 = npcid; |
194 return &pNPCStats->pNewNPCData[npcid]; | |
781 | 195 } |
1094 | 196 *npc_indx = npcid - 5000; |
781 | 197 return &pNPCStats->pAdditionalNPC[npcid - 5000]; |
198 } | |
199 if ( npcid >= 5000 ) | |
1094 | 200 { |
201 *npc_indx = npcid - 5000; | |
202 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
203 } | |
781 | 204 if ( sDialogue_SpeakingActorNPC_ID >= 0 ) |
205 { | |
1094 | 206 *npc_indx = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
207 result = nullptr; |
781 | 208 } |
209 else | |
210 { | |
1094 | 211 v5 = abs(sDialogue_SpeakingActorNPC_ID) - 1; |
781 | 212 v6 = 0; |
1094 | 213 for (int i=0; i<2; ++i) |
781 | 214 { |
1094 | 215 if ( pParty->pHirelings[i].pName ) |
216 pTmpBuf[v6++] = i; | |
217 | |
218 } | |
219 for (int i=0; i< pNPCStats->uNumNewNPCs; ++i) | |
781 | 220 { |
1094 | 221 if ( pNPCStats->pNewNPCData[i].Hired() |
222 && (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName)) | |
223 && (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) ) | |
224 { | |
225 pTmpBuf[v6++]=i+2; | |
226 } | |
781 | 227 } |
228 v11 = pTmpBuf[v5]; | |
1094 | 229 |
230 if ( v11 >= 2u ) | |
781 | 231 { |
1094 | 232 *v3 = v11 - 2; |
233 result = &pNPCStats->pNewNPCData[v11 - 2]; | |
781 | 234 } |
235 else | |
236 { | |
1094 | 237 *v3 = v11; |
238 result = &pParty->pHirelings[v11]; | |
781 | 239 } |
240 } | |
241 return result; | |
242 } | |
243 | |
251 | 244 //----- (00476977) -------------------------------------------------------- |
291 | 245 void NPCStats::InitializeNPCText() |
251 | 246 { |
247 int i; | |
248 char* test_string; | |
249 unsigned char c; | |
250 bool break_loop; | |
251 unsigned int temp_str_len; | |
252 char* tmp_pos; | |
253 int decode_step; | |
254 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
255 free(pNPCTextTXT_Raw); |
251 | 256 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); |
257 strtok(pNPCTextTXT_Raw, "\r"); | |
258 | |
259 for (i=0; i<789; ++i) | |
260 { | |
261 test_string = strtok(NULL, "\r") + 1; | |
262 break_loop = false; | |
263 decode_step=0; | |
264 do | |
265 { | |
266 c = *(unsigned char*)test_string; | |
267 temp_str_len = 0; | |
268 while((c!='\t')&&(c>0)) | |
269 { | |
270 ++temp_str_len; | |
271 c=test_string[temp_str_len]; | |
272 } | |
273 tmp_pos=test_string+temp_str_len; | |
274 if (*tmp_pos == 0) | |
275 break_loop = true; | |
276 *tmp_pos = 0; | |
277 if (temp_str_len) | |
278 { | |
279 if ( decode_step == 1) | |
280 pNPCTopics[i].pText =RemoveQuotes(test_string); | |
281 } | |
282 else | |
283 { | |
284 break_loop = true; | |
285 } | |
286 ++decode_step; | |
287 test_string=tmp_pos+1; | |
288 } while ((decode_step<2)&&!break_loop); | |
289 } | |
290 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
291 free(pNPCTopicTXT_Raw); |
251 | 292 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); |
293 strtok(pNPCTopicTXT_Raw, "\r"); | |
294 | |
1661 | 295 for ( i = 1; i <= 579; ++i )//NPC topics count limit |
251 | 296 { |
297 test_string = strtok(NULL, "\r") + 1; | |
298 break_loop = false; | |
299 decode_step=0; | |
300 do | |
301 { | |
302 c = *(unsigned char*)test_string; | |
303 temp_str_len = 0; | |
304 while((c!='\t')&&(c>0)) | |
305 { | |
306 ++temp_str_len; | |
307 c=test_string[temp_str_len]; | |
308 } | |
309 tmp_pos=test_string+temp_str_len; | |
310 if (*tmp_pos == 0) | |
311 break_loop = true; | |
312 *tmp_pos = 0; | |
313 if (temp_str_len) | |
314 { | |
315 if ( decode_step == 1) | |
316 pNPCTopics[i].pTopic = RemoveQuotes(test_string); | |
317 } | |
318 else | |
319 { | |
320 break_loop = true; | |
321 } | |
322 ++decode_step; | |
323 test_string=tmp_pos+1; | |
324 } while ((decode_step<2)&&!break_loop); | |
325 } | |
326 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
327 free(pNPCDistTXT_Raw); |
251 | 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 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
381 free(pNPCDistTXT_Raw); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
382 pNPCDistTXT_Raw = nullptr; |
251 | 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 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); |
602 strtok(pNPCNamesTXT_Raw, "\r"); | |
603 | |
604 uNewlNPCBufPos = 0; | |
605 | |
606 for (i=0; i<540; ++i) | |
251 | 607 { |
291 | 608 test_string = strtok(NULL, "\r") + 1; |
609 break_loop = false; | |
610 decode_step=0; | |
611 do | |
251 | 612 { |
291 | 613 c = *(unsigned char*)test_string; |
614 temp_str_len = 0; | |
615 if (c=='\t') | |
251 | 616 { |
291 | 617 if ( (decode_step == 1)&&(!uNumNPCNames[1])) |
618 uNumNPCNames[1]=i; | |
251 | 619 } |
620 else | |
621 { | |
291 | 622 while((c!='\n')&&(c!='\t')&&(c>0)) |
623 { | |
624 ++temp_str_len; | |
625 c=test_string[temp_str_len]; | |
626 } | |
627 tmp_pos=test_string+temp_str_len; | |
628 if (*tmp_pos == 0) | |
629 break_loop = true; | |
630 | |
631 if (temp_str_len) | |
632 { | |
633 *tmp_pos = 0; | |
634 if ( decode_step == 0) | |
635 pNPCNames[i][0] =RemoveQuotes(test_string); | |
636 else if ( decode_step == 1) | |
637 pNPCNames[i][1] =RemoveQuotes(test_string); | |
638 } | |
639 else | |
640 { | |
641 if ( (decode_step == 1)&&(!uNumNPCNames[1])) | |
642 uNumNPCNames[1]=i; | |
643 } | |
251 | 644 } |
291 | 645 ++decode_step; |
646 test_string=tmp_pos+1; | |
647 } while ((decode_step<2)&&!break_loop); | |
648 } | |
649 uNumNPCNames[0] = i; | |
650 | |
651 pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); | |
652 strtok(pNPCProfTXT_Raw, "\r"); | |
653 strtok(NULL, "\r"); | |
654 strtok(NULL, "\r"); | |
655 strtok(NULL, "\r"); | |
656 | |
657 for (i=1; i<59; ++i) | |
658 { | |
659 test_string = strtok(NULL, "\r") + 1; | |
660 break_loop = false; | |
661 decode_step=0; | |
662 do | |
251 | 663 { |
667 | 664 //while (*test_string == '\t') // some steps are separated by multiple \t's |
665 //++test_string; | |
652 | 666 |
291 | 667 c = *(unsigned char*)test_string; |
668 temp_str_len = 0; | |
669 while((c!='\t')&&(c>0)) | |
251 | 670 { |
291 | 671 ++temp_str_len; |
672 c=test_string[temp_str_len]; | |
673 } | |
674 tmp_pos=test_string+temp_str_len; | |
675 if (*tmp_pos == 0) | |
676 break_loop = true; | |
677 *tmp_pos = 0; | |
678 if (temp_str_len) | |
679 { | |
680 switch(decode_step) | |
681 { | |
682 case 2: | |
683 pProfessions[i].uHirePrice = atoi(test_string); | |
684 break; | |
685 case 3: | |
686 pProfessions[i].pActionText = RemoveQuotes(test_string); | |
687 break; | |
688 case 4: | |
689 pProfessions[i].pBenefits= RemoveQuotes(test_string); | |
690 break; | |
691 case 5: | |
692 pProfessions[i].pJoinText = RemoveQuotes(test_string); | |
693 break; | |
694 case 6: | |
695 pProfessions[i].pDismissText = RemoveQuotes(test_string); | |
696 } | |
251 | 697 } |
291 | 698 else |
699 { | |
667 | 700 if (!decode_step) |
291 | 701 break_loop = true; |
702 } | |
703 ++decode_step; | |
704 test_string=tmp_pos+1; | |
705 } while ((decode_step<7)&&!break_loop); | |
251 | 706 } |
291 | 707 uNumNPCProfessions = 59; |
251 | 708 } |
709 | |
710 //----- (00477266) -------------------------------------------------------- | |
711 void NPCStats::Release() | |
712 { | |
1583 | 713 free(pNPCTopicTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
714 pNPCTopicTXT_Raw = nullptr; |
1583 | 715 free(pNPCTextTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
716 pNPCTextTXT_Raw = nullptr; |
1583 | 717 free(pNPCNewsTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
718 pNPCNewsTXT_Raw = nullptr; |
1583 | 719 free(pNPCProfTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
720 pNPCProfTXT_Raw = nullptr; |
1583 | 721 free(pNPCNamesTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
722 pNPCNamesTXT_Raw = nullptr; |
1583 | 723 free(pNPCDataTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
724 pNPCDataTXT_Raw = nullptr; |
1583 | 725 free(pNPCDistTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
726 pNPCDistTXT_Raw = nullptr; |
1583 | 727 free(pNPCGreetTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
728 pNPCGreetTXT_Raw = nullptr; |
1583 | 729 free(pNCPGroupTXT_Raw); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
730 pNCPGroupTXT_Raw = nullptr; |
251 | 731 } |
732 | |
733 //----- (0047730C) -------------------------------------------------------- | |
307 | 734 bool CheckPortretAgainstSex(int a1, int) |
251 | 735 { |
291 | 736 return true; |
251 | 737 } |
738 // 47730C: using guessed type int __stdcall const_1(int); | |
739 | |
740 //----- (0047732C) -------------------------------------------------------- | |
291 | 741 void NPCStats::InitializeAdditionalNPCs(NPCData *pNPCDataBuff, int npc_uid, int uLocation2D, int uMapId) |
251 | 742 { |
292 | 743 int rep_gen; |
291 | 744 int uNPCSex; // esi@1 |
745 int uGeneratedPortret; // ecx@23 | |
746 int test_prof_summ; // ecx@37 | |
747 int gen_profession; // eax@37 | |
748 int max_prof_cap; // edx@37 | |
2334 | 749 // signed int result; // eax@39 |
291 | 750 int uRace; // [sp+Ch] [bp-Ch]@1 |
751 bool break_gen; // [sp+10h] [bp-8h]@1 | |
752 signed int gen_attempts; // [sp+14h] [bp-4h]@1 | |
753 int uPortretMin; // [sp+24h] [bp+Ch]@1 | |
754 int uPortretMax; | |
755 | |
756 static const unsigned __int8 NPCSexGenTable[86] ={ | |
293 | 757 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
758 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, | |
759 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, | |
760 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
761 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }; | |
762 static const unsigned __int8 NPCRaceGenTable[86] ={ | |
763 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, | |
764 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
765 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, | |
766 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
767 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0}; | |
251 | 768 |
307 | 769 unsigned __int8 seed = (unsigned __int8)((double)(npc_uid - 1)/3.0); |
291 | 770 uNPCSex = NPCSexGenTable[seed]; |
771 uRace = NPCRaceGenTable[seed]; | |
772 pNPCDataBuff->uSex = uNPCSex; | |
773 pNPCDataBuff->pName = pNPCNames[rand() % uNumNPCNames[uNPCSex]][uNPCSex]; | |
774 | |
775 gen_attempts = 0; | |
776 break_gen = false; | |
251 | 777 |
291 | 778 do |
251 | 779 { |
293 | 780 switch ( uRace ) |
781 { | |
782 case 0: | |
783 if ( uNPCSex == 0 ) | |
291 | 784 { |
785 uPortretMin = 2; | |
786 uPortretMax = 100; | |
251 | 787 } |
788 else | |
789 { | |
293 | 790 uPortretMin = 201; |
791 uPortretMax = 250; | |
792 } | |
793 case 1: | |
794 if ( uNPCSex == 0 ) | |
795 { | |
796 uPortretMin = 400; | |
797 uPortretMax = 430; | |
798 } | |
799 else | |
800 { | |
801 uPortretMin = 460; | |
802 uPortretMax = 490; | |
803 } | |
804 break; | |
805 case 2: | |
806 if ( uNPCSex == 0 ) | |
807 { | |
808 uPortretMin = 500; | |
809 uPortretMax = 520; | |
810 } | |
811 else | |
812 { | |
813 uPortretMin = 530; | |
814 uPortretMax = 550; | |
815 } | |
816 break; | |
817 case 3: | |
818 if ( uNPCSex == 0 ) | |
819 { | |
820 uPortretMin = 300; | |
821 uPortretMax = 330; | |
822 } | |
823 else | |
824 { | |
825 uPortretMin = 360; | |
826 uPortretMax = 387; | |
251 | 827 } |
291 | 828 |
293 | 829 break; |
830 } | |
831 | |
291 | 832 uGeneratedPortret = uPortretMin + rand() % (uPortretMax - uPortretMin + 1); |
307 | 833 if ( CheckPortretAgainstSex(uGeneratedPortret, uNPCSex)) |
291 | 834 break_gen = true; |
835 ++gen_attempts; | |
836 if ( gen_attempts >= 4 ) | |
251 | 837 { |
291 | 838 uGeneratedPortret = uPortretMin; |
839 break_gen = true; | |
251 | 840 } |
841 } | |
291 | 842 while(!break_gen); |
251 | 843 |
293 | 844 pNPCDataBuff->uPortraitID = uGeneratedPortret; |
845 pNPCDataBuff->uFlags = 0; | |
846 pNPCDataBuff->fame = 0; | |
847 //generate reputation | |
848 rep_gen = rand() % 100 + 1; | |
251 | 849 |
293 | 850 if ( rep_gen >= 60 ) |
251 | 851 { |
293 | 852 if ( rep_gen >= 90 ) |
251 | 853 { |
293 | 854 if ( rep_gen >= 95 ) |
855 { | |
856 if ( rep_gen >= 98 ) | |
857 pNPCDataBuff->rep = -600; | |
858 else | |
859 pNPCDataBuff->rep = 400; | |
860 } | |
251 | 861 else |
293 | 862 pNPCDataBuff->rep = -300; |
251 | 863 } |
864 else | |
293 | 865 pNPCDataBuff->rep = 200; |
251 | 866 } |
867 else | |
293 | 868 pNPCDataBuff->rep = 0; |
291 | 869 |
293 | 870 max_prof_cap = rand() % pProfessionChance[uMapId].uTotalprofChance+1; |
871 test_prof_summ = 0; | |
872 gen_profession = 0; | |
251 | 873 |
293 | 874 if ( max_prof_cap > 0 ) |
875 { | |
876 do | |
877 test_prof_summ += pProfessionChance[uMapId].professionChancePerArea[gen_profession++]; | |
878 while ( test_prof_summ < max_prof_cap ); | |
879 } | |
880 pNPCDataBuff->uProfession = gen_profession - 1; | |
881 pNPCDataBuff->Location2D = uLocation2D; | |
882 pNPCDataBuff->field_24 = 1; | |
883 pNPCDataBuff->joins = 1; | |
659 | 884 pNPCDataBuff->evt_A = 0; |
885 pNPCDataBuff->evt_B = 0; | |
886 pNPCDataBuff->evt_C = 0; | |
887 pNPCDataBuff->evt_D = 0; | |
888 pNPCDataBuff->evt_E = 0; | |
889 pNPCDataBuff->evt_F = 0; | |
251 | 890 } |
891 | |
2229
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
892 |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
893 //----- (00495366) -------------------------------------------------------- |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
894 char *NPCStats::sub_495366_MispronounceName(unsigned __int8 firstLetter, unsigned __int8 genderId) |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
895 { |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
896 int pickedName; // edx@2 |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
897 |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
898 if ( firstLetter == dword_AE336C_LastMispronouncedNameFirstLetter) |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
899 pickedName = dword_AE3370_LastMispronouncedNameResult; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
900 else |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
901 { |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
902 dword_AE336C_LastMispronouncedNameFirstLetter = firstLetter; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
903 if ( this->uNumNPCNames[genderId] == 0 ) |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
904 pickedName = rand() % this->uNumNPCNames[(genderId + 1) % 2]; //originally without " + 1) % 2", but that would yield a div by zero |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
905 else |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
906 { |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
907 int rangeBottom = 0; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
908 int rangeTop = 0; |
2335 | 909 for ( uint i = 0; i < this->uNumNPCNames[genderId]; ++i ) |
2229
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
910 { |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
911 if (tolower(this->pNPCNames[i][genderId][0])) |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
912 { |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
913 if ( rangeBottom ) |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
914 rangeTop = i; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
915 else |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
916 rangeBottom = i; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
917 } |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
918 } |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
919 if ( rangeTop != 0 ) |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
920 pickedName = rangeBottom + rand() % (rangeTop - rangeBottom); |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
921 else |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
922 pickedName = rand() % this->uNumNPCNames[genderId]; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
923 } |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
924 } |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
925 dword_AE3370_LastMispronouncedNameResult = pickedName; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
926 return this->pNPCNames[pickedName][genderId]; |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
927 } |
10c909eb6766
dword_AE336C to NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter,
Grumpy7
parents:
2215
diff
changeset
|
928 |
257 | 929 //----- (00476387) -------------------------------------------------------- |
930 bool PartyHasDragon() | |
931 { | |
932 return pNPCStats->pNewNPCData[57].Hired(); | |
933 } | |
251 | 934 |
935 //----- (00476395) -------------------------------------------------------- | |
936 //0x26 Wizard eye at skill level 2 | |
1458 | 937 bool CheckHiredNPCSpeciality(unsigned int uProfession) |
1094 | 938 { |
939 | |
940 if ( bNoNPCHiring == 1 ) | |
941 return 0; | |
251 | 942 |
2335 | 943 for (uint i=0; i<pNPCStats->uNumNewNPCs; ++i ) |
1094 | 944 { |
945 if ( pNPCStats->pNewNPCData[i].uProfession == uProfession && | |
946 (pNPCStats->pNewNPCData[i].uFlags & 0x80) ) | |
947 return true; | |
948 } | |
949 if ( pParty->pHirelings[0].uProfession == uProfession || | |
950 pParty->pHirelings[1].uProfession == uProfession) | |
951 return true; | |
952 else | |
953 return false; | |
954 | |
955 } | |
251 | 956 |
957 //----- (004763E0) -------------------------------------------------------- | |
958 void InitializeAwards() | |
949 | 959 { |
251 | 960 int i; |
961 char* test_string; | |
962 unsigned char c; | |
963 bool break_loop; | |
964 unsigned int temp_str_len; | |
965 char* tmp_pos; | |
966 int decode_step; | |
967 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
968 free(pAwardsTXT_Raw); |
251 | 969 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); |
970 strtok(pAwardsTXT_Raw, "\r"); | |
971 | |
949 | 972 for (i=1; i<105; ++i) |
251 | 973 { |
974 test_string = strtok(NULL, "\r") + 1; | |
975 break_loop = false; | |
976 decode_step=0; | |
977 do | |
978 { | |
979 c = *(unsigned char*)test_string; | |
980 temp_str_len = 0; | |
981 while((c!='\t')&&(c>0)) | |
982 { | |
983 ++temp_str_len; | |
984 c=test_string[temp_str_len]; | |
985 } | |
986 tmp_pos=test_string+temp_str_len; | |
987 if (*tmp_pos == 0) | |
988 break_loop = true; | |
989 *tmp_pos = 0; | |
990 if (temp_str_len) | |
991 { | |
992 if (decode_step==1) | |
993 pAwards[i].pText=RemoveQuotes(test_string); | |
994 else if (decode_step==2) | |
949 | 995 pAwards[i].uPriority = atoi(test_string); |
251 | 996 } |
997 else | |
998 { | |
999 break_loop = true; | |
1000 } | |
1001 ++decode_step; | |
1002 test_string=tmp_pos+1; | |
1003 } while ((decode_step<3)&&!break_loop); | |
1004 } | |
1005 } | |
1006 // 7241C8: using guessed type int dword_7241C8; | |
1007 | |
1008 //----- (004764C2) -------------------------------------------------------- | |
1009 void InitializeScrolls() | |
1010 { | |
1011 | |
1012 int i; | |
1013 char* test_string; | |
1014 unsigned char c; | |
1015 bool break_loop; | |
1016 unsigned int temp_str_len; | |
1017 char* tmp_pos; | |
1018 int decode_step; | |
1019 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
1020 free(pScrollsTXT_Raw); |
251 | 1021 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); |
1022 strtok(pScrollsTXT_Raw, "\r"); | |
1023 for (i=0; i<82; ++i) | |
1024 { | |
1025 test_string = strtok(NULL, "\r") + 1; | |
1026 break_loop = false; | |
1027 decode_step=0; | |
1028 do | |
1029 { | |
1030 c = *(unsigned char*)test_string; | |
1031 temp_str_len = 0; | |
1032 while((c!='\t')&&(c>0)) | |
1033 { | |
1034 ++temp_str_len; | |
1035 c=test_string[temp_str_len]; | |
1036 } | |
1037 tmp_pos=test_string+temp_str_len; | |
1038 if (*tmp_pos == 0) | |
1039 break_loop = true; | |
1040 *tmp_pos = 0; | |
1041 if (temp_str_len) | |
1042 { | |
1043 if ( decode_step == 1) | |
1044 pScrolls[i]=RemoveQuotes(test_string); | |
1045 } | |
1046 else | |
1047 { | |
1048 break_loop = true; | |
1049 } | |
1050 ++decode_step; | |
1051 test_string=tmp_pos+1; | |
1052 } while ((decode_step<2)&&!break_loop); | |
1053 } | |
1054 } | |
1055 | |
1056 //----- (00476590) -------------------------------------------------------- | |
1057 void InitializeMerchants() | |
1058 { | |
1059 int i; | |
1060 char* test_string; | |
1061 unsigned char c; | |
1062 bool break_loop; | |
1063 unsigned int temp_str_len; | |
1064 char* tmp_pos; | |
1065 int decode_step; | |
1066 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
1067 free(pMerchantsTXT_Raw); |
251 | 1068 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); |
1069 strtok(pMerchantsTXT_Raw, "\r"); | |
1070 | |
1071 for (i=0; i<7; ++i) | |
1072 { | |
1073 test_string = strtok(NULL, "\r") + 1; | |
1074 break_loop = false; | |
1075 decode_step=0; | |
1076 do | |
1077 { | |
1078 c = *(unsigned char*)test_string; | |
1079 temp_str_len = 0; | |
1080 while((c!='\t')&&(c>0)) | |
1081 { | |
1082 ++temp_str_len; | |
1083 c=test_string[temp_str_len]; | |
1084 } | |
1085 tmp_pos=test_string+temp_str_len; | |
1086 if (*tmp_pos == 0) | |
1087 break_loop = true; | |
1088 *tmp_pos = 0; | |
1089 if (temp_str_len) | |
1090 { | |
1091 switch (decode_step) | |
1092 { | |
1093 case 1: | |
1094 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string); | |
1095 break; | |
1096 case 2: | |
1097 pMerchantsSellPhrases[i]=RemoveQuotes(test_string); | |
1098 break; | |
1099 case 3: | |
1100 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); | |
1101 break; | |
1102 case 4: | |
1103 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); | |
1104 break; | |
1105 } | |
1106 } | |
1107 else | |
1108 { | |
1109 break_loop = true; | |
1110 } | |
1111 ++decode_step; | |
1112 test_string=tmp_pos+1; | |
1113 } while ((decode_step<5)&&!break_loop); | |
1114 } | |
1115 | |
1116 } | |
1117 | |
1118 //----- (00476682) -------------------------------------------------------- | |
1119 void InitializeTransitions() | |
1120 { | |
1121 int i; | |
1122 char* test_string; | |
1123 unsigned char c; | |
1124 bool break_loop; | |
1125 unsigned int temp_str_len; | |
1126 char* tmp_pos; | |
1127 int decode_step; | |
1128 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
1129 free(pTransitionsTXT_Raw); |
251 | 1130 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); |
1131 strtok(pTransitionsTXT_Raw, "\r"); | |
1132 | |
1133 for (i=0; i<464; ++i) | |
1134 { | |
1135 test_string = strtok(NULL, "\r") + 1; | |
1136 break_loop = false; | |
1137 decode_step=0; | |
1138 do | |
1139 { | |
1140 c = *(unsigned char*)test_string; | |
1141 temp_str_len = 0; | |
1142 while((c!='\t')&&(c>0)) | |
1143 { | |
1144 ++temp_str_len; | |
1145 c=test_string[temp_str_len]; | |
1146 } | |
1147 tmp_pos=test_string+temp_str_len; | |
1148 if (*tmp_pos == 0) | |
1149 break_loop = true; | |
1150 *tmp_pos = 0; | |
1151 if (temp_str_len) | |
1152 { | |
1153 if ( decode_step == 1) | |
434 | 1154 pTransitionStrings[i + 1]=RemoveQuotes(test_string); |
251 | 1155 } |
1156 else | |
1157 { | |
1158 break_loop = true; | |
1159 } | |
1160 ++decode_step; | |
1161 test_string=tmp_pos+1; | |
1162 } while ((decode_step<2)&&!break_loop); | |
1163 } | |
1164 } | |
1165 | |
1166 //----- (00476750) -------------------------------------------------------- | |
1458 | 1167 void InitializeAutonotes() |
251 | 1168 { |
1169 int i; | |
1170 char* test_string; | |
1171 unsigned char c; | |
1172 bool break_loop; | |
1173 unsigned int temp_str_len; | |
1174 char* tmp_pos; | |
1175 int decode_step; | |
1176 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
1177 free(pAutonoteTXT_Raw); |
251 | 1178 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); |
1179 strtok(pAutonoteTXT_Raw, "\r"); | |
1180 | |
1181 for (i=0; i<195; ++i) | |
1182 { | |
1183 test_string = strtok(NULL, "\r") + 1; | |
1184 break_loop = false; | |
1185 decode_step=0; | |
1186 do | |
1187 { | |
1188 c = *(unsigned char*)test_string; | |
1189 temp_str_len = 0; | |
1190 while((c!='\t')&&(c>0)) | |
1191 { | |
1192 ++temp_str_len; | |
1193 c=test_string[temp_str_len]; | |
1194 } | |
1195 tmp_pos=test_string+temp_str_len; | |
1196 if (*tmp_pos == 0) | |
1197 break_loop = true; | |
1198 *tmp_pos = 0; | |
1199 if (temp_str_len) | |
1200 { | |
1201 switch (decode_step) | |
1202 { | |
1203 case 1: | |
1310 | 1204 pAutonoteTxt[i+1].pText=RemoveQuotes(test_string); |
251 | 1205 break; |
1206 case 2: | |
1207 { | |
1104 | 1208 if ( !_stricmp(test_string, "potion")) |
251 | 1209 { |
1310 | 1210 pAutonoteTxt[i+1].eType = AUTONOTE_POTION_RECEPIE; |
251 | 1211 break; |
1212 } | |
1104 | 1213 if ( !_stricmp(test_string, "stat") ) |
251 | 1214 { |
1310 | 1215 pAutonoteTxt[i+1].eType = AUTONOTE_STAT_HINT; |
251 | 1216 break; |
1217 } | |
1104 | 1218 if ( !_stricmp(test_string, "seer") ) |
251 | 1219 { |
1310 | 1220 pAutonoteTxt[i+1].eType = AUTONOTE_SEER; |
251 | 1221 break; |
1222 } | |
1104 | 1223 if ( !_stricmp(test_string, "obelisk") ) |
251 | 1224 { |
1310 | 1225 pAutonoteTxt[i+1].eType = AUTONOTE_OBELISK; |
251 | 1226 break; |
1227 } | |
1104 | 1228 if ( !_stricmp(test_string, "teacher") ) |
251 | 1229 { |
1310 | 1230 pAutonoteTxt[i+1].eType = AUTONOTE_TEACHER; |
251 | 1231 break; |
1232 } | |
1310 | 1233 pAutonoteTxt[i+1].eType =AUTONOTE_MISC; |
251 | 1234 break; |
1235 } | |
1236 } | |
1237 } | |
1238 else | |
1239 { | |
1240 break_loop = true; | |
1241 } | |
1242 ++decode_step; | |
1243 test_string=tmp_pos+1; | |
1244 } while ((decode_step<3)&&!break_loop); | |
1245 } | |
1246 } | |
1247 | |
1248 | |
1249 //----- (004768A9) -------------------------------------------------------- | |
1458 | 1250 void InitializeQuests() |
251 | 1251 { |
1252 int i; | |
1253 char* test_string; | |
1254 unsigned char c; | |
1255 bool break_loop; | |
1256 unsigned int temp_str_len; | |
1257 char* tmp_pos; | |
1258 int decode_step; | |
1259 | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
1260 free(pQuestsTXT_Raw); |
251 | 1261 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); |
1262 strtok(pQuestsTXT_Raw, "\r"); | |
1310 | 1263 memset(pQuestTable.data(),0, sizeof(pQuestTable)); |
251 | 1264 for (i=0; i<512; ++i) |
1265 { | |
1266 test_string = strtok(NULL, "\r") + 1; | |
1267 break_loop = false; | |
1268 decode_step=0; | |
1269 do | |
1270 { | |
1271 c = *(unsigned char*)test_string; | |
1272 temp_str_len = 0; | |
1273 while((c!='\t')&&(c>0)) | |
1274 { | |
1275 ++temp_str_len; | |
1276 c=test_string[temp_str_len]; | |
1277 } | |
1278 tmp_pos=test_string+temp_str_len; | |
1279 if (*tmp_pos == 0) | |
1280 break_loop = true; | |
1281 *tmp_pos = 0; | |
1282 if (temp_str_len) | |
1283 { | |
1284 if ( decode_step == 1) | |
1310 | 1285 pQuestTable[i+1] =RemoveQuotes(test_string); |
251 | 1286 } |
1287 else | |
1288 { | |
1289 break_loop = true; | |
1290 } | |
1291 ++decode_step; | |
1292 test_string=tmp_pos+1; | |
1293 } while ((decode_step<2)&&!break_loop); | |
1294 } | |
1295 } | |
1296 | |
1295 | 1297 //----- (004B2001) -------------------------------------------------------- |
1298 void __fastcall ClickNPCTopic(signed int uMessageParam) | |
1299 { | |
1300 //signed int v1; // eax@1 | |
1301 NPCData *pCurrentNPCInfo; // ebp@1 | |
1302 int pEventNumber; // ecx@8 | |
1303 Player *v4; // esi@20 | |
1304 //int v5; // eax@28 | |
1305 //int v6; // eax@31 | |
1306 //int v7; // eax@34 | |
1307 //int v8; // eax@37 | |
1308 //int v9; // eax@40 | |
1309 //unsigned int v10; // eax@43 | |
1310 char *v12; // eax@53 | |
1311 char *v13; // eax@56 | |
1312 char *v14; // eax@57 | |
1313 char *v15; // eax@58 | |
1314 //unsigned int v16; // ebp@62 | |
1315 char *v17; // ecx@63 | |
1316 char *v18; // eax@65 | |
2334 | 1317 // const char *v19; // ecx@68 |
1295 | 1318 //unsigned int v20; // eax@69 |
1319 signed int pPrice; // ecx@70 | |
1320 char *v22; // [sp-Ch] [bp-18h]@73 | |
1321 //int v23; // [sp-8h] [bp-14h]@49 | |
1322 char *v24; // [sp-8h] [bp-14h]@73 | |
1323 //int v25; // [sp-4h] [bp-10h]@49 | |
1324 | |
1325 uDialogueType = uMessageParam + 1; | |
1313 | 1326 pCurrentNPCInfo = HouseNPCData[pDialogueNPCCount -((dword_591080 != 0)?1:0 )];//- 1 |
1295 | 1327 if ( uMessageParam <= 24 ) |
1328 { | |
1329 switch ( uMessageParam ) | |
1330 { | |
1331 case 13: | |
1332 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
|
1333 current_npc_text = BuildDialogueString(current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); |
1295 | 1334 NPCHireableDialogPrepare(); |
1335 dialogue_show_profession_details = false; | |
1336 goto _return; | |
1337 case 19: | |
1338 pEventNumber = pCurrentNPCInfo->evt_A; | |
1339 break; | |
1340 case 20: | |
1341 pEventNumber = pCurrentNPCInfo->evt_B; | |
1342 break; | |
1343 case 21: | |
1344 pEventNumber = pCurrentNPCInfo->evt_C; | |
1345 break; | |
1346 case 22: | |
1347 pEventNumber = pCurrentNPCInfo->evt_D; | |
1348 break; | |
1349 case 23: | |
1350 pEventNumber = pCurrentNPCInfo->evt_E; | |
1351 break; | |
1352 case 24: | |
1353 pEventNumber = pCurrentNPCInfo->evt_F; | |
1354 break; | |
1355 default: | |
1356 goto _return; | |
1357 } | |
1358 /*switch ( pEventNumber ) | |
1359 { | |
1360 case 139: | |
1459 | 1361 OracleDialogue(); |
1295 | 1362 goto _return; |
1363 case 311: | |
1529 | 1364 CheckBountyRespawnAndAward(); |
1295 | 1365 goto _return; |
1366 }*/ | |
1367 if ( pEventNumber < 200 || pEventNumber > 310 ) | |
1368 { | |
1369 if ( pEventNumber < 400 || pEventNumber > 410 ) | |
1370 { | |
1371 if ( pEventNumber == 139 ) | |
1372 { | |
1459 | 1373 OracleDialogue(); |
1295 | 1374 } |
1375 else | |
1376 { | |
1377 if ( pEventNumber == 311 ) | |
1378 { | |
1529 | 1379 CheckBountyRespawnAndAward(); |
1295 | 1380 } |
1381 else | |
1382 { | |
1383 current_npc_text = 0; | |
1384 activeLevelDecoration = (LevelDecoration*)1; | |
1385 EventProcessor(pEventNumber, 0, 1); | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2344
diff
changeset
|
1386 activeLevelDecoration = nullptr; |
1295 | 1387 } |
1388 } | |
1389 } | |
1390 else | |
1391 { | |
1392 dword_F8B1D8 = uMessageParam; | |
1393 DrawJoinGuildWindow(pEventNumber - 400); | |
1394 } | |
1395 } | |
1396 else | |
1397 { | |
1582 | 1398 _4B3FE5_training_dialogue(pEventNumber); |
1295 | 1399 } |
1400 goto _return; | |
1401 } | |
1402 if ( uMessageParam != 76 ) | |
1403 { | |
1404 if ( uMessageParam == 77 ) | |
1405 { | |
1406 //v16 = pCurrentNPCInfo->uProfession; | |
2115 | 1407 __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 | 1408 if (dialogue_show_profession_details) |
2115 | 1409 v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText; |
1295 | 1410 else |
2115 | 1411 v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pBenefits; |
1295 | 1412 current_npc_text = v17; |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1313
diff
changeset
|
1413 v18 = BuildDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); |
1295 | 1414 dialogue_show_profession_details = ~dialogue_show_profession_details; |
1415 current_npc_text = v18; | |
1416 } | |
1417 else | |
1418 { | |
1419 if ( uMessageParam == 79 ) | |
1420 { | |
1421 if ( contract_approved ) | |
1422 { | |
1423 Party::TakeGold(gold_transaction_amount); | |
1424 if ( uActiveCharacter ) | |
1425 { | |
1426 v12 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1427 *(short *)v12 &= 0x3Fu; | |
2239
699bd6ee5ad0
dword_F8B1B0 to dword_F8B1B0_MasteryBeingTaught, some final touches to _4B254D_SkillMasteryTeacher
Grumpy7
parents:
2229
diff
changeset
|
1428 switch ( dword_F8B1B0_MasteryBeingTaught ) |
1295 | 1429 { |
1430 case 2: | |
1431 v15 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1432 *v15 |= 0x40u; | |
1433 break; | |
1434 case 3: | |
1435 v14 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1436 *v14 |= 0x80u; | |
1437 break; | |
1438 case 4: | |
1439 v13 = (char *)&pPlayers[uActiveCharacter]->pActiveSkills[dword_F8B1AC_award_bit_number]; | |
1440 v13[1] |= 1u; | |
1441 break; | |
1442 } | |
1443 pPlayers[uActiveCharacter]->PlaySound(SPEECH_85, 0); | |
1444 } | |
1445 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
1446 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1447 { | |
1448 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
1449 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
1450 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1451 ++pMessageQueue_50CBD0->uNumMessages; | |
1452 }*/ | |
1453 } | |
1454 } | |
1455 else | |
1456 { | |
1457 if ( uMessageParam == 82 && contract_approved ) //join guild | |
1458 { | |
1459 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
|
1460 v4 = pParty->pPlayers.data(); |
1295 | 1461 do |
1462 { | |
1463 v4->SetVariable(VAR_Award, dword_F8B1AC_award_bit_number); | |
1464 ++v4; | |
1465 } | |
1861
a86c60679949
changing most of party arrays to std::arrays, some minor cleanups in actor.cpp
Grumpy7
parents:
1843
diff
changeset
|
1466 while ( (signed int)v4 < (signed int)pParty->pHirelings.data() ); |
1295 | 1467 switch ( dword_F8B1D8 ) |
1468 { | |
1469 case 19: | |
1470 pEventNumber = pCurrentNPCInfo->evt_A; | |
1471 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1472 pCurrentNPCInfo->evt_A = 0; | |
1473 break; | |
1474 case 20: | |
1475 pEventNumber = pCurrentNPCInfo->evt_B; | |
1476 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1477 pCurrentNPCInfo->evt_B = 0; | |
1478 break; | |
1479 case 21: | |
1480 pEventNumber = pCurrentNPCInfo->evt_C; | |
1481 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1482 pCurrentNPCInfo->evt_C = 0; | |
1483 break; | |
1484 case 22: | |
1485 pEventNumber = pCurrentNPCInfo->evt_D; | |
1486 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1487 pCurrentNPCInfo->evt_D = 0; | |
1488 break; | |
1489 case 23: | |
1490 pEventNumber = pCurrentNPCInfo->evt_E; | |
1491 if ( pEventNumber >= 400 && pEventNumber <= 416 ) | |
1492 pCurrentNPCInfo->evt_E = 0; | |
1493 break; | |
1494 case 24: | |
1495 pEventNumber = pCurrentNPCInfo->evt_F; | |
1496 if ( pEventNumber >= 400 && pEventNumber <= 416) | |
1497 pCurrentNPCInfo->evt_F = 0; | |
1498 break; | |
1499 } | |
1500 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
1501 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1502 { | |
1503 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
1504 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
1505 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1506 ++pMessageQueue_50CBD0->uNumMessages; | |
1507 }*/ | |
1508 //v11 = uActiveCharacter; | |
1509 if ( uActiveCharacter ) | |
1510 { | |
1511 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_86, 0); | |
1512 goto _return; | |
1513 } | |
1514 } | |
1515 } | |
1516 } | |
1517 goto _return; | |
1518 } | |
1519 if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) | |
1520 { | |
1521 ShowStatusBarString(pGlobalTXT_LocalizationStrings[533], 2);// ""I cannot join you, you're party is full"" | |
1522 goto _return; | |
1523 } | |
2115 | 1524 if ( pCurrentNPCInfo->uProfession != 51 ) //burglars have no hiring price |
1295 | 1525 { |
2115 | 1526 __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 |
1527 pPrice = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].uHirePrice; | |
2335 | 1528 if ( pParty->uNumGold < (unsigned int)pPrice ) |
1295 | 1529 { |
1530 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); | |
1531 dialogue_show_profession_details = false; | |
1532 uDialogueType = 13; | |
2115 | 1533 current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText; |
1843
2e6d3cd052e0
some char* cast removal + adding const_casts where appropriate
Grumpy7
parents:
1828
diff
changeset
|
1534 current_npc_text = BuildDialogueString(current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); |
1295 | 1535 if ( uActiveCharacter ) |
1536 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); | |
1537 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); | |
1538 goto _return; | |
1539 } | |
1540 Party::TakeGold(pPrice); | |
1541 } | |
1542 //LOBYTE(v2->uFlags) |= 0x80u; | |
1543 pCurrentNPCInfo->uFlags |= 128; | |
1793
4dee76d79c78
dword_5B65CC to npcIdToDismissAfterDialogue, Party::field_709 to Party::hirelingScrollPosition
Grumpy7
parents:
1662
diff
changeset
|
1544 pParty->hirelingScrollPosition = 0; |
1295 | 1545 pParty->CountHirelings(); |
1546 if ( pParty->pHirelings[0].pName ) | |
1547 { | |
1548 memcpy(&pParty->pHirelings[1], pCurrentNPCInfo, sizeof(pParty->pHirelings[1])); | |
1549 v24 = pCurrentNPCInfo->pName; | |
1550 v22 = pParty->pHireling2Name; | |
1551 } | |
1552 else | |
1553 { | |
1861
a86c60679949
changing most of party arrays to std::arrays, some minor cleanups in actor.cpp
Grumpy7
parents:
1843
diff
changeset
|
1554 memcpy(pParty->pHirelings.data(), pCurrentNPCInfo, 0x4Cu); |
1295 | 1555 v24 = pCurrentNPCInfo->pName; |
1556 v22 = pParty->pHireling1Name; | |
1557 } | |
1558 strcpy(v22, v24); | |
1793
4dee76d79c78
dword_5B65CC to npcIdToDismissAfterDialogue, Party::field_709 to Party::hirelingScrollPosition
Grumpy7
parents:
1662
diff
changeset
|
1559 pParty->hirelingScrollPosition = 0; |
1295 | 1560 pParty->CountHirelings(); |
1561 PrepareHouse((HOUSE_ID)(int)window_SpeakInHouse->ptr_1C); | |
1562 dialog_menu_id = HOUSE_DIALOGUE_MAIN; | |
1563 | |
1564 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
1565 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1566 { | |
1567 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
1568 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
1569 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1570 ++pMessageQueue_50CBD0->uNumMessages; | |
1571 }*/ | |
1572 if ( uActiveCharacter ) | |
1573 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)61, 0); | |
1574 _return: | |
1575 pVideoPlayer->_4BF5B2();//HouseVideo | |
1576 } | |
1577 //----- (004B29F2) -------------------------------------------------------- | |
1578 const char * ContractSelectText( int pEventCode ) | |
1579 { | |
1580 static const int dialogue_base=110; | |
1581 contract_approved = 0; | |
1582 dword_F8B1AC_award_bit_number = pEventCode + 50; | |
1583 gold_transaction_amount = price_for_membership[pEventCode]; | |
1584 if ( pPlayers[uActiveCharacter]->CanAct() ) | |
1585 { | |
1460
ff2118028c71
renaming _guilds_member_bits to _achieved_awards_bits
Gloval
parents:
1411
diff
changeset
|
1586 if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits, dword_F8B1AC_award_bit_number) ) |
1295 | 1587 return pNPCTopics[dialogue_base+13].pText; |
1588 else | |
1589 { | |
2335 | 1590 if ( (unsigned int)gold_transaction_amount <= pParty->uNumGold ) |
1295 | 1591 { |
1592 contract_approved = 1; | |
1593 return pNPCTopics[pEventCode + dialogue_base].pText; | |
1594 } | |
1595 else | |
1596 return pNPCTopics[dialogue_base+14].pText; | |
1597 } | |
1598 } | |
1599 else | |
1600 return pNPCTopics[dialogue_base+12].pText; | |
1601 } | |
1602 //----- (004B40E6) -------------------------------------------------------- | |
1603 void NPCHireableDialogPrepare() | |
1604 { | |
1605 signed int v0; // ebx@1 | |
1606 NPCData *v1; // edi@1 | |
1607 | |
1608 v0 = 0; | |
1609 v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 | |
1610 pDialogueWindow->Release(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
1611 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 350, WINDOW_MainMenu, 0, 0); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
1612 pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, |
1295 | 1613 pGlobalTXT_LocalizationStrings[34], //"Cancel" |
1614 pIcons_LOD->GetTexture(uExitCancelTextureId), | |
1615 0); | |
1616 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); | |
1617 if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) ) | |
1618 { | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
1619 pDialogueWindow->CreateButton( 480, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Du, 0, |
1295 | 1620 pGlobalTXT_LocalizationStrings[407], 0);//"More Information" |
1621 v0 = 1; | |
1622 } | |
1623 pDialogueWindow->CreateButton( 0x1E0u, 30 * v0 + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Cu, 0, | |
1624 pGlobalTXT_LocalizationStrings[406], 0); //"Hire" | |
1625 pDialogueWindow->_41D08F_set_keyboard_control_group(v0 + 1, 1, 0, 2); | |
1626 dialog_menu_id = HOUSE_DIALOGUE_OTHER; | |
1627 } | |
1628 | |
1629 //----- (004B4224) -------------------------------------------------------- | |
1630 void _4B4224_UpdateNPCTopics( int _this ) | |
1631 { | |
1632 int num_menu_buttons; // ebx@1 | |
1633 int i; // ebp@5 | |
1634 // signed int v4; // ebp@9 | |
1635 int v6; // eax@16 | |
1636 int v8; // eax@21 | |
1637 int v10; // eax@26 | |
1638 int v12; // eax@31 | |
1639 int v14; // eax@36 | |
1640 int v16; // eax@41 | |
1641 NPCData *v17; // [sp+10h] [bp-4h]@4 | |
1642 | |
1643 num_menu_buttons = 0; | |
1644 pDialogueNPCCount = (_this + 1); | |
1645 if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) | |
1646 { | |
1647 pDialogueWindow->Release(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
1648 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); |
1295 | 1649 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName); |
1650 pBtn_ExitCancel = pDialogueWindow->CreateButton(566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// "Cancel" | |
1651 pBtn_YES = pDialogueWindow->CreateButton(486, 445, 75, 33, 1, 0, UIMSG_BF, 1, 'Y', sHouseName.data(), pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0); | |
1652 pDialogueWindow->CreateButton( pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63u, 73u, 1, 0, UIMSG_BF, 1u, 0x20u, sHouseName.data(), 0); | |
1653 pDialogueWindow->CreateButton(8, 8, 460, 344, 1, 0, UIMSG_BF, 1, 0x59u, sHouseName.data(), 0); | |
1654 } | |
1655 else | |
1656 { | |
1313 | 1657 v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0)?1:0 )];//+ 1 |
1295 | 1658 if ( dialog_menu_id == HOUSE_DIALOGUE_OTHER ) |
1659 { | |
1660 pDialogueWindow->Release(); | |
1661 } | |
1662 else | |
1663 { | |
1664 for ( i = 0; i < uNumDialogueNPCPortraits; ++i ) | |
1589 | 1665 HouseNPCPortraitsButtonsList[i]->Release(); |
1295 | 1666 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
1667 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 345, WINDOW_MainMenu, 0, 0); |
2022 | 1668 pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, |
1295 | 1669 pGlobalTXT_LocalizationStrings[74],// "End Conversation" |
1670 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); | |
2022 | 1671 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); |
1295 | 1672 if ( pDialogueNPCCount == 1 && dword_591080 ) |
1673 { | |
1411 | 1674 InitializaDialogueOptions(in_current_building_type); |
1295 | 1675 } |
1676 else | |
1677 { | |
1678 if ( v17->joins ) | |
1679 { | |
1680 num_menu_buttons = 1; | |
1681 pDialogueWindow->CreateButton(480u, 160u, 140u, 30, 1, 0, UIMSG_ClickNPCTopic, 0xDu, 0, "", 0); | |
1682 } | |
1683 if ( v17->evt_A) | |
1684 { | |
1685 if ( num_menu_buttons < 4 ) | |
1686 { | |
1687 v6 = NPC_EventProcessor(v17->evt_A); | |
1688 if ( v6 == 1 || v6 == 2 ) | |
1689 pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x13u, 0, "", 0); | |
1690 } | |
1691 } | |
1692 if ( v17->evt_B ) | |
1693 { | |
1694 if ( num_menu_buttons < 4 ) | |
1695 { | |
1696 v8 = NPC_EventProcessor(v17->evt_B); | |
1697 if ( v8 == 1 || v8 == 2 ) | |
1698 pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x14u, 0, "", 0); | |
1699 } | |
1700 } | |
1701 if ( v17->evt_C ) | |
1702 { | |
1703 if ( num_menu_buttons < 4 ) | |
1704 { | |
1705 v10 = NPC_EventProcessor(v17->evt_C); | |
1706 if ( v10 == 1 || v10 == 2 ) | |
1707 pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0x15u, 0, "", 0); | |
1708 } | |
1709 } | |
1710 | |
1711 if ( v17->evt_D ) | |
1712 { | |
1713 if ( num_menu_buttons < 4 ) | |
1714 { | |
1715 v12 = NPC_EventProcessor(v17->evt_D); | |
1716 if ( v12 == 1 || v12 == 2 ) | |
1717 pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x16u, 0, "", 0); | |
1718 } | |
1719 } | |
1720 if ( v17->evt_E ) | |
1721 { | |
1722 if ( num_menu_buttons < 4 ) | |
1723 { | |
1724 v14 = NPC_EventProcessor(v17->evt_E); | |
1725 if ( v14 == 1 || v14 == 2 ) | |
1726 pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x17u, 0, "", 0); | |
1727 } | |
1728 } | |
1729 if ( v17->evt_F ) | |
1730 { | |
1731 if ( num_menu_buttons < 4 ) | |
1732 { | |
1733 v16 = NPC_EventProcessor(v17->evt_F); | |
1734 if ( v16 == 1 || v16 == 2 ) | |
1735 pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x18u, 0, "", 0); | |
1736 } | |
1737 } | |
1738 pDialogueWindow->_41D08F_set_keyboard_control_group(num_menu_buttons, 1, 0, 2); | |
1739 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; | |
1740 } | |
1741 dialog_menu_id = HOUSE_DIALOGUE_MAIN; | |
1742 } | |
1743 | |
1744 } | |
1745 //----- (004466C4) -------------------------------------------------------- | |
1746 int NPC_EventProcessor(int npc_event_id, int entry_line) | |
1747 { | |
1748 signed int event_index; // ebp@1 | |
1749 int evt_seq_num; // esi@3 | |
1750 bool ready_to_exit; // [sp+Ch] [bp-Ch]@3 | |
1751 signed int npc_activity; // [sp+10h] [bp-8h]@3 | |
1752 int result; | |
1753 | |
1754 event_index = 0; | |
1755 if ( !npc_event_id ) | |
1756 return 0; | |
1757 evt_seq_num = entry_line; | |
1758 pSomeOtherEVT = pGlobalEVT.data(); | |
1759 uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents; | |
1760 memcpy(pSomeOtherEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); | |
1761 npc_activity = 1; | |
1762 ready_to_exit = false; | |
1763 if ( uSomeOtherEVT_NumEvents <= 0 ) | |
1764 return 2; | |
1765 do | |
1766 { | |
1767 if ( (pSomeOtherEVT_Events[event_index].uEventID == npc_event_id) && (pSomeOtherEVT_Events[event_index].event_sequence_num == evt_seq_num) ) | |
1768 { | |
1769 _evt_raw *_evt = (_evt_raw *)&pSomeOtherEVT[pSomeOtherEVT_Events[event_index].uEventOffsetInEVT]; | |
1770 switch(_evt->_e_type) | |
1771 { | |
1772 case EVENT_Exit: | |
1773 //exit | |
1774 if ( ready_to_exit ) | |
1775 result = npc_activity != 0; | |
1776 else | |
1777 result = 2; | |
1778 return result; | |
1779 break; | |
1780 case EVENT_OnCanShowDialogItemCmp: | |
1781 ready_to_exit = true; | |
1782 //v8 = (unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8); | |
1783 for(int i=0; i<4; ++i) | |
1784 { | |
1785 // if (pParty->pPlayers[i].CompareVariable((enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5] + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)), | |
1786 // v8)) | |
1787 if (pParty->pPlayers[i].CompareVariable((enum VariableType)EVT_WORD(_evt->v5), EVT_DWORD(_evt->v7))) | |
1788 { | |
1789 event_index = -1; | |
1790 evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; | |
1791 break; | |
1792 } | |
1793 } | |
1794 break; | |
1795 case EVENT_EndCanShowDialogItem : | |
1796 if ( ready_to_exit ) | |
1797 result = npc_activity != 0; | |
1798 else | |
1799 result = 2; | |
1800 return result; | |
1801 break; | |
1802 case EVENT_SetCanShowDialogItem : | |
1803 ready_to_exit = true; | |
1804 npc_activity = EVT_BYTE(_evt->v5); //(unsigned __int8)v7[5]; | |
1805 break; | |
1806 case EVENT_IsActorAssasinated : | |
1807 // if (IsActorAlive( (unsigned __int8)v7[5], | |
1808 // (unsigned __int8)v7[6] + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8), | |
1809 // (unsigned __int8)v7[10]) ) | |
1810 if (IsActorAlive( EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) | |
1811 { // drop linear sequense, going to new seq | |
1812 event_index = -1; | |
1813 evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; | |
1814 } | |
1815 break; | |
1816 } | |
1817 ++evt_seq_num; | |
1818 } | |
1819 ++event_index; | |
1820 } | |
1821 while ( event_index < uSomeOtherEVT_NumEvents ); | |
1822 if ( ready_to_exit ) | |
1823 result = npc_activity != 0; | |
1824 else | |
1825 result = 2; | |
1826 return result; | |
1827 } | |
1828 //----- (00445C8B) -------------------------------------------------------- | |
1829 int __fastcall GetGreetType(signed int SpeakingNPC_ID) | |
1830 { | |
1831 signed int v1; // ebx@1 | |
1832 int v3; // edi@6 | |
1833 int v4; // ecx@6 | |
1834 int v5; // edx@6 | |
1835 NPCData *v6; // eax@6 | |
1836 char *v7; // ebp@11 | |
1837 NPCData *v8; // esi@11 | |
1838 | |
1839 v1 = 0; | |
1840 if ( SpeakingNPC_ID >= 0 ) | |
1841 { | |
1842 if ( SpeakingNPC_ID < 5000 ) | |
1843 return 1;//QuestNPC_greet | |
1844 return 2;//HiredNPC_greet | |
1845 } | |
1846 if ( SpeakingNPC_ID >= 5000 ) | |
1847 return 2; | |
1848 v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; | |
1849 v4 = 0; | |
1850 v5 = 0; | |
1861
a86c60679949
changing most of party arrays to std::arrays, some minor cleanups in actor.cpp
Grumpy7
parents:
1843
diff
changeset
|
1851 v6 = pParty->pHirelings.data(); |
1295 | 1852 do |
1853 { | |
1854 if ( v6->pName ) | |
1855 pTmpBuf[v4++] = v5; | |
1856 ++v6; | |
1857 ++v5; | |
1858 } | |
1859 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
1860 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
1861 { | |
1862 v7 = &pTmpBuf[v4]; | |
1863 v8 = pNPCStats->pNewNPCData; | |
1864 do | |
1865 { | |
1866 if (v8->Hired() && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) ) | |
1867 { | |
1868 if ( !pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName) ) | |
1869 *v7++ = v1 + 2; | |
1870 } | |
1871 ++v1; | |
1872 ++v8; | |
1873 } | |
1874 while ( v1 < (signed int)pNPCStats->uNumNewNPCs ); | |
1875 } | |
1876 return ((unsigned __int8)pTmpBuf[v3] < 2) + 1; | |
1877 } | |
1878 //----- (00445308) -------------------------------------------------------- | |
1879 const char *GetProfessionActionText(int a1) | |
1880 { | |
1881 if ( a1 == 10 | |
1882 || a1 == 11 | |
1883 || a1 == 12 | |
1884 || a1 == 33 | |
1885 || a1 == 34 | |
1886 || a1 == 39 | |
1887 || a1 == 40 | |
1888 || a1 == 41 | |
1889 || a1 == 42 | |
1890 || a1 == 43 | |
1891 || a1 == 52 ) | |
1892 return pNPCStats->pProfessions[a1 - 1].pActionText; | |
1893 else | |
1894 return pNPCTopics[407].pTopic; | |
1895 } | |
2374 | 1896 |
1897 //----- (004BB756) -------------------------------------------------------- | |
1898 int UseNPCSkill(NPCProf profession) | |
1899 { | |
1900 switch (profession) | |
1901 { | |
1902 case Healer: | |
1903 { | |
1904 for (int i = 0; i < 4; ++i) | |
1905 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth(); | |
1906 } | |
1907 break; | |
1908 | |
1909 case ExpertHealer: | |
1910 { | |
1911 for (int i = 0; i < 4; ++i) | |
1912 { | |
1913 __debugbreak(); | |
1914 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth(); | |
1915 | |
1916 for (int j = 0; j < 14; ++j) | |
1917 pParty->pPlayers[i].pConditions[j] = 0; | |
1918 pParty->pPlayers[i].pConditions[Condition_Good] = 0; | |
1919 } | |
1920 } | |
1921 break; | |
1922 | |
1923 case MasterHealer: | |
1924 { | |
1925 for (int i = 0; i < 4; ++i) | |
1926 { | |
1927 __debugbreak(); //Ritor1:needed cleaned(Необходимо почистить) | |
1928 Player* player = &pParty->pPlayers[i]; | |
1929 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth(); | |
1930 | |
1931 int v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32); | |
1932 int v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31); | |
1933 memset(&pParty->pPlayers[i].pConditions, 0, sizeof(pParty->pPlayers[i].pConditions)); | |
1934 | |
1935 *(int *)&player->pActiveSkills[PLAYER_SKILL_SHIELD] = v5; | |
1936 *(int *)&player->pActiveSkills[PLAYER_SKILL_CHAIN] = v6; | |
1937 } | |
1938 } | |
1939 break; | |
1940 | |
1941 case Cook://Повар | |
1942 { | |
1943 if (pParty->uNumFoodRations >= 13) | |
1944 return 1; | |
1945 | |
1946 Party::GiveFood(1); | |
1947 } | |
1948 break; | |
1949 | |
1950 case Chef: | |
1951 { | |
1952 if (pParty->uNumFoodRations >= 13) | |
1953 return 1; | |
1954 | |
1955 if (pParty->uNumFoodRations == 13) | |
1956 Party::GiveFood(1); | |
1957 else | |
1958 Party::GiveFood(2); | |
1959 } | |
1960 break; | |
1961 | |
1962 case WindMaster: | |
1963 { | |
1964 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1965 { | |
1966 ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2);//Нельзя применить знание Полет в помещении! | |
1967 pAudioPlayer->PlaySound(SOUND_203, 0, 0, -1, 0, 0, 0, 0); | |
1968 } | |
1969 else | |
1970 { | |
1971 int v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); | |
1972 pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 60 * (256 * 2), 3, 1, v19, 0); | |
1973 pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1; | |
1974 pAudioPlayer->PlaySound(SOUND_11090, 0, 0, -1, 0, 0, 0, 0); | |
1975 } | |
1976 } | |
1977 break; | |
1978 | |
1979 case WaterMaster: | |
1980 { | |
1981 int v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); | |
1982 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 60 * (256 * (2 + 1)), 3, 0, v20, 0); | |
1983 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1; | |
1984 pAudioPlayer->PlaySound(SOUND_12040, 0, 0, -1, 0, 0, 0, 0); | |
1985 } | |
1986 break; | |
1987 | |
1988 case GateMaster: | |
1989 { | |
1990 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
1991 dword_50C9DC = 195; | |
1992 ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); | |
1993 } | |
1994 break; | |
1995 | |
1996 case Acolyte: _42777D_CastSpell_UseWand_ShootArrow(46, 0, 133, 0, 0); break; | |
1997 case Piper: _42777D_CastSpell_UseWand_ShootArrow(51, 0, 133, 0, 0); break; | |
1998 case FallenWizard: _42777D_CastSpell_UseWand_ShootArrow(86, 0, 133, 0, 0); break; | |
1999 | |
2000 case Teacher: | |
2001 case Instructor: | |
2002 case Armsmaster: | |
2003 case Weaponsmaster: | |
2004 case Apprentice: | |
2005 case Mystic: | |
2006 case Spellmaster: | |
2007 case Trader: | |
2008 case Merchant: | |
2009 case Scout: | |
2010 case Herbalist: | |
2011 case Apothecary: | |
2012 case Tinker: | |
2013 case Locksmith: | |
2014 case Fool: | |
2015 case ChimneySweep: | |
2016 case Porter: | |
2017 case QuarterMaster: | |
2018 case Factor: | |
2019 case Banker: | |
2020 case Horseman: | |
2021 case Bard: | |
2022 case Enchanter: | |
2023 case Cartographer: | |
2024 case Explorer: | |
2025 case Pirate: | |
2026 case Squire: | |
2027 case Psychic: | |
2028 case Gypsy: | |
2029 case Diplomat: | |
2030 case Duper: | |
2031 case Burglar: | |
2032 case Acolyte2: | |
2033 case Initiate: | |
2034 case Prelate: | |
2035 case Monk: | |
2036 case Sage: | |
2037 case Hunter: | |
2038 break; | |
2039 | |
2040 default: | |
2041 assert(false && "Invalid enum value"); | |
2042 } | |
2043 return 0; | |
2044 } |