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