annotate NPC.cpp @ 2469:8516bb27d7f0

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