annotate NPC.cpp @ 1138:f947bedb2859

Слияние
author Ritor1
date Sat, 01 Jun 2013 10:32:31 +0600
parents 5d5c78088274
children 29a8defbad9e
rev   line source
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 949
diff changeset
1
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
2
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
3 #include "Allocator.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
4 #include "texts.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
5 #include "LOD.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
6 #include "Autonotes.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
7 #include "Awards.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
8 #include "mm7_data.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
9 #include "MM7.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"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
12
629
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
13 int pDialogueNPCCount;
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
14 struct Texture *pDialogueNPCPortraits[6];
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
15 int uNumDialogueNPCPortraits; // weak
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
16 struct NPCStats *pNPCStats = nullptr;
59713bb36033 houses func moved to uihouses
Gloval
parents: 570
diff changeset
17
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
18 void InitializeAwards();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
19 void InitializeScrolls();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
20 void InitializeMerchants();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
21 void InitializeTransitions();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
22 void InitializeAutonotes();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
23 void InitializeQuests();
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
24 bool CheckPortretAgainstSex(int portret_num, int sex);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
25
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
26 //----- (004459F9) --------------------------------------------------------
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
27 NPCData *__fastcall GetNPCData(signed int npcid)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
28 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
29 unsigned int v1; // esi@1
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
30 NPCData *result; // eax@5
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
31 int v3; // esi@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
32 int v4; // ecx@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
33 //int v5; // edx@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
34 //NPCData *v6; // eax@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
35 char *v7; // ebx@14
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
36 NPCData *v8; // edi@14
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
37 char v9; // al@22
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
38 char v10;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
39 //std::string v10; // [sp-18h] [bp-2Ch]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
40 int v11;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
41 //const char *v11; // [sp-8h] [bp-1Ch]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
42 int v12; // [sp-4h] [bp-18h]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
43 int v13;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
44 char *v14;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
45 //std::string *v13; // [sp+Ch] [bp-8h]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
46 int a3; // [sp+13h] [bp-1h]@4
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
47 int i;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
48
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
49 /*v1 = npcid;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
50 if ( (npcid & 0x80000000u) == 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
51 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
52 if ( (signed int)npcid < 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
53 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
54 if ( (signed int)npcid >= 501 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
55 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
56 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
57 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
58 return &pNPCStats->pNewNPCData[v1];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
59 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
60 return &pNPCStats->array_13EF4[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
61 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
62 if ( (signed int)npcid >= 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
63 return &pNPCStats->array_13EF4[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
64 if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
65 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
66 result = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
67 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
68 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
69 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
70 v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
71 v4 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
72 v5 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
73 v6 = pParty->pHirelings;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
74 do
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
75 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
76 if ( v6->pName )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
77 pTmpBuf[v4++] = v5;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
78 ++v6;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
79 ++v5;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
80 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
81 while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
82 v13 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
83 if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
84 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
85 v7 = &pTmpBuf[v4];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
86 v8 = pNPCStats->pNewNPCData;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
87 do
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
88 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
89 if ( v8->uFlags & 0x80
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
90 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName))
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
91 && (!pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName)) )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
92 *v7++ = (char)v13 + 2;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
93 v13 = (std::string *)((char *)v13 + 1);
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
94 ++v8;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
95 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
96 while ( (signed int)v13 < (signed int)pNPCStats->uNumNewNPCs );
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
97 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
98 v9 = pTmpBuf[v3];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
99 if ( (unsigned __int8)v9 >= 2u )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
100 result = &pNPCStats->pNPCData[(unsigned __int8)v9 + 499];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
101 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
102 result = &pParty->pHirelings[(unsigned __int8)v9];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
103 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
104 return result;*/
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
105 v1 = npcid;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
106 if ( npcid >= 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
107 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
108 if ( npcid < 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
109 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
110 if ( npcid >= 501 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
111 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
112 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
113 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
114 return &pNPCStats->pNewNPCData[v1];// - 1];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
115 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
116 return &pNPCStats->pAdditionalNPC[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
117 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
118
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 return &pNPCStats->pAdditionalNPC[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
122 if (sDialogue_SpeakingActorNPC_ID >= 0)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
123 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
124 result = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
125 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
126 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
127 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
128 v3 = abs(sDialogue_SpeakingActorNPC_ID) - 1;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
129 v4 = 0;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
130
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
131 for (i = 0; i < 2; ++i)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
132 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
133 if (pParty->pHirelings[i].pName)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
134 pTmpBuf[v4++] = i;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
135 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
136
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
137 if (pNPCStats->uNumNewNPCs > 0)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
138 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
139 for (i = 0; i < pNPCStats->uNumNewNPCs; ++i)
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
140 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
141 if (pNPCStats->pNewNPCData[i].Hired())
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
142 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
143 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
144 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
145 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
146 pTmpBuf[v4++] = i + 2;
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 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
150 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
151
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
152 v9 = pTmpBuf[v3];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
153 if ( v9 >= 2 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
154 result = &pNPCStats->pNPCData[499 + v9];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
155 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
156 result = &pParty->pHirelings[v9];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
157 }
1099
94aff285558e Right click NPC fix
Grumpy7
parents: 1094
diff changeset
158 return result;
781
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 //----- (00445B2C) --------------------------------------------------------
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
162 struct NPCData * GetNewNPCData( signed int npcid, int* npc_indx )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
163 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
164
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
165 int* v3; // edi@1
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
166 NPCData *result; // eax@5
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
167 int v5; // esi@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
168 int v6; // ecx@9
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
169 char v11; // al@23
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
170
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
171 v3 = npc_indx;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
172 if ( npcid >= 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
173 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
174 if ( npcid < 5000 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
175 {
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
176 if ( npcid >= 501 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
177 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
178 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
179 }
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
180 *v3 = npcid;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
181 return &pNPCStats->pNewNPCData[npcid];
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
182 }
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
183 *npc_indx = npcid - 5000;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
184 return &pNPCStats->pAdditionalNPC[npcid - 5000];
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
185 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
186 if ( npcid >= 5000 )
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
187 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
188 *npc_indx = npcid - 5000;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
189 return &pNPCStats->pAdditionalNPC[npcid - 5000];
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
190 }
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
191 if ( sDialogue_SpeakingActorNPC_ID >= 0 )
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
192 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
193 *npc_indx = 0;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
194 result = NULL;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
195 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
196 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
197 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
198 v5 = abs(sDialogue_SpeakingActorNPC_ID) - 1;
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
199 v6 = 0;
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
200 for (int i=0; i<2; ++i)
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
201 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
202 if ( pParty->pHirelings[i].pName )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
203 pTmpBuf[v6++] = i;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
204
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
205 }
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
206 for (int i=0; i< pNPCStats->uNumNewNPCs; ++i)
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
207 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
208 if ( pNPCStats->pNewNPCData[i].Hired()
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
209 && (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
210 && (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
211 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
212 pTmpBuf[v6++]=i+2;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
213 }
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
214 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
215 v11 = pTmpBuf[v5];
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
216
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
217 if ( v11 >= 2u )
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
218 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
219 *v3 = v11 - 2;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
220 result = &pNPCStats->pNewNPCData[v11 - 2];
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
221 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
222 else
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
223 {
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
224 *v3 = v11;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
225 result = &pParty->pHirelings[v11];
781
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
226 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
227 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
228 return result;
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
229 }
d170f23f70d1 tidy, code moving
zipi
parents: 667
diff changeset
230
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
231 //----- (00476977) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
232 void NPCStats::InitializeNPCText()
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
233 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
234 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
235 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
236 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
237 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
238 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
239 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
240 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
241
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
242 if (pNPCTextTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
243 pAllocator->FreeChunk(pNPCTextTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
244 pNPCTextTXT_Raw =NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
245 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
246 strtok(pNPCTextTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
247
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
248 for (i=0; i<789; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
249 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
250 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
251 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
252 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
253 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
254 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
255 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
256 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
257 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
258 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
259 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
260 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
261 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
262 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
263 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
264 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
265 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
266 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
267 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
268 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
269 pNPCTopics[i].pText =RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
270 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
271 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
272 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
273 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
274 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
275 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
276 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
277 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
278 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
279
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
280 if (pNPCTopicTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
281 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
282 pNPCTopicTXT_Raw =NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
283 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
284 strtok(pNPCTopicTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
285
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
286 for (i=0; i<579; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
287 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
288 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
289 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
290 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
291 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
292 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
293 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
294 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
295 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
296 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
297 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
298 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
299 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
300 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
301 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
302 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
303 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
304 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
305 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
306 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
307 pNPCTopics[i].pTopic = RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
308 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
309 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
310 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
311 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
312 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
313 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
314 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
315 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
316 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
317
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
318 if (pNPCDistTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
319 pAllocator->FreeChunk(pNPCDistTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
320 pNPCDistTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
321 pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
322 strtok(pNPCDistTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
323 strtok(NULL, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
324
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
325 for (i=1; i<59; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
326 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
327 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
328 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
329 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
330 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
331 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
332 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
333 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
334 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
335 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
336 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
337 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
338 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
339 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
340 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
341 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
342 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
343 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
344 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
345 if ((decode_step>0)&&(decode_step<77))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
346 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
347 pProfessionChance[decode_step].professionChancePerArea[i]=atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
348 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
349 else if (decode_step==0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
350 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
351 pProfessionChance[0].professionChancePerArea[i]=10;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
352 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
353 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
354 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
355 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
356 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
357 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
358 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
359 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
360 } while ((decode_step<78)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
361 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
362
825
Ritor1
parents: 781
diff changeset
363 for ( i = 0; i < 77; ++i )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
364 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
365 pProfessionChance[i].uTotalprofChance=0;
825
Ritor1
parents: 781
diff changeset
366 for ( int ii = 1; ii < 59; ++ii )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
367 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
368 pProfessionChance[i].uTotalprofChance+=pProfessionChance[i].professionChancePerArea[ii];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
369 }
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
370 pProfessionChance[i].professionChancePerArea[0]=0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
371 pProfessionChance[i].professionChancePerArea[59]=0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
372 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
373
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
374 if (pNPCDistTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
375 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
376 pAllocator->FreeChunk(pNPCDistTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
377 pNPCDistTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
378 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
379 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
380
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
381 //----- (00476C60) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
382 void NPCStats::_476C60()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
383 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
384 for (unsigned int i = 1; i < uNumNewNPCs; ++i)
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
385 pNewNPCData[i].pName = pNPCUnicNames[i - 1];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
386
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
387 if (pParty->pHirelings[0].pName)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
388 pParty->pHirelings[0].pName = pParty->pHireling1Name;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
389 if (pParty->pHirelings[1].pName)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
390 pParty->pHirelings[1].pName = pParty->pHireling2Name;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
391 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
392
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
393 //----- (00476CB5) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
394 void NPCStats::InitializeNPCData()
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
395 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
396 int i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
397 char* test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
398 unsigned char c;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
399 bool break_loop;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
400 unsigned int temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
401 char* tmp_pos;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
402 int decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
403
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
404 pNPCDataTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
405 strtok(pNPCDataTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
406 strtok(NULL, "\r");
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
407
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
408 for (i=0; i<500; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
409 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
410 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
411 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
412 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
413 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
414 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
415 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
416 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
417 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
418 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
419 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
420 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
421 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
422 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
423 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
424 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
425 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
426 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
427 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
428 switch (decode_step)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
429 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
430 case 1:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
431 pNPCUnicNames[i] = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
432 pNPCData[i+1].pName=pNPCUnicNames[i];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
433 break;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
434 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
435 pNPCData[i+1].uPortraitID = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
436 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
437 case 6:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
438 pNPCData[i+1].Location2D = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
439 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
440 case 7:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
441 pNPCData[i+1].uProfession = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
442 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
443 case 8:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
444 pNPCData[i+1].greet = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
445 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
446 case 9:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
447 pNPCData[i+1].joins = (*test_string == 'y')?1:0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
448 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
449 case 10:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
450 pNPCData[i+1].evt_A = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
451 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
452 case 11:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
453 pNPCData[i+1].evt_B = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
454 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
455 case 12:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
456 pNPCData[i+1].evt_C = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
457 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
458 case 13:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
459 pNPCData[i+1].evt_D = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
460 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
461 case 14:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
462 pNPCData[i+1].evt_E = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
463 break;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
464 case 15:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
465 pNPCData[i+1].evt_F = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
466 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
467 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
468 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
469 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
470 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
471 } while ((decode_step<16)&&!break_loop);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
472 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
473 uNumNewNPCs = 501;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
474 pNPCGreetTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
475 strtok(pNPCGreetTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
476 for (i=0; i<205; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
477 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
478 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
479 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
480 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
481 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
482 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
483 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
484 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
485 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
486 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
487 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
488 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
489 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
490 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
491 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
492 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
493 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
494 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
495 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
496 switch (decode_step)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
497 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
498 case 1:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
499 pNPCGreetings[i].pGreeting1 = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
500 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
501 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
502 pNPCGreetings[i].pGreeting2 = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
503 break;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
504 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
505 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
506 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
507 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
508 } while ((decode_step<3)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
509 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
510
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
511 pNCPGroupTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
512 strtok(pNCPGroupTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
513
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
514 for (i=0; i<51; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
515 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
516 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
517 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
518 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
519 do
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
520 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
521 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
522 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
523 while((c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
524 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
525 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
526 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
527 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
528 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
529 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
530 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
531 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
532 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
533 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
534 if (decode_step==1)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
535 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
536 pGroups[i] = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
537 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
538 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
539 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
540 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
541 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
542 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
543
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
544 pNPCNewsTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcnews.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
545 strtok(pNPCNewsTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
546
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
547
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
548 for (i=0; i<51; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
549 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
550 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
551 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
552 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
553 do
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
554 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
555 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
556 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
557 while((c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
558 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
559 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
560 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
561 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
562 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
563 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
564 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
565 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
566 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
567 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
568 if (decode_step==1)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
569 pCatchPhrases[i] = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
570 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
571 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
572 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
573 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
574 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
575 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
576
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
577 //----- (0047702F) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
578 void NPCStats::Initialize()
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
579 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
580 int i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
581 char* test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
582 unsigned char c;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
583 bool break_loop;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
584 unsigned int temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
585 char* tmp_pos;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
586 int decode_step;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
587
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
588 InitializeNPCData();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
589 InitializeNPCText();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
590 InitializeQuests();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
591 InitializeAutonotes();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
592 InitializeAwards();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
593 InitializeTransitions();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
594 InitializeMerchants();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
595 InitializeScrolls();
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
596
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
597 pNPCNamesTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
598 pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
599 strtok(pNPCNamesTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
600
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
601 uNewlNPCBufPos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
602
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
603 for (i=0; i<540; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
604 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
605 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
606 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
607 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
608 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
609 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
610 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
611 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
612 if (c=='\t')
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
613 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
614 if ( (decode_step == 1)&&(!uNumNPCNames[1]))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
615 uNumNPCNames[1]=i;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
616 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
617 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
618 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
619 while((c!='\n')&&(c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
620 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
621 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
622 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
623 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
624 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
625 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
626 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
627
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
628 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
629 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
630 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
631 if ( decode_step == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
632 pNPCNames[i][0] =RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
633 else if ( decode_step == 1)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
634 pNPCNames[i][1] =RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
635 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
636 else
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
637 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
638 if ( (decode_step == 1)&&(!uNumNPCNames[1]))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
639 uNumNPCNames[1]=i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
640 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
641 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
642 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
643 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
644 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
645 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
646 uNumNPCNames[0] = i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
647
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
648 pNPCProfTXT_Raw = NULL;
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 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
711 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
712 pNPCTopicTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
713 pAllocator->FreeChunk(pNPCTextTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
714 pNPCTextTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
715 pAllocator->FreeChunk(pNPCNewsTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
716 pNPCNewsTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
717 pAllocator->FreeChunk(pNPCProfTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
718 pNPCProfTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
719 pAllocator->FreeChunk(pNPCNamesTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
720 pNPCNamesTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
721 pAllocator->FreeChunk(pNPCDataTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
722 pNPCDataTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
723 pAllocator->FreeChunk(pNPCDistTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
724 pNPCDistTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
725 pAllocator->FreeChunk(pNPCGreetTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
726 pNPCGreetTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
727 pAllocator->FreeChunk(pNCPGroupTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
728 pNCPGroupTXT_Raw = NULL;
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
251
48f21f569328 Npc related stuff separated
Gloval
parents:
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
257
Nomad
parents: 253
diff changeset
890 //----- (00476387) --------------------------------------------------------
Nomad
parents: 253
diff changeset
891 bool PartyHasDragon()
Nomad
parents: 253
diff changeset
892 {
Nomad
parents: 253
diff changeset
893 return pNPCStats->pNewNPCData[57].Hired();
Nomad
parents: 253
diff changeset
894 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
895
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
896 //----- (00476395) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
897 //0x26 Wizard eye at skill level 2
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
898 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
899 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
900
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
901 if ( bNoNPCHiring == 1 )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
902 return 0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
903
1094
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
904 for (int i=0; i<pNPCStats->uNumNewNPCs; ++i )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
905 {
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
906 if ( pNPCStats->pNewNPCData[i].uProfession == uProfession &&
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
907 (pNPCStats->pNewNPCData[i].uFlags & 0x80) )
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
908 return true;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
909 }
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
910 if ( pParty->pHirelings[0].uProfession == uProfession ||
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
911 pParty->pHirelings[1].uProfession == uProfession)
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
912 return true;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
913 else
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
914 return false;
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
915
c40d40027b77 npc some clean
Gloval
parents: 1016
diff changeset
916 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
917 // 6BE3C5: using guessed type char bNoNPCHiring;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
918
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
919 //----- (004763E0) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
920 void InitializeAwards()
949
Nomad
parents: 825
diff changeset
921 {
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
922 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
923 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
924 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
925 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
926 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
927 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
928 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
929
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
930 if ( pAwardsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
931 pAllocator->FreeChunk(pAwardsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
932 pAwardsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
933 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
934 strtok(pAwardsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
935
949
Nomad
parents: 825
diff changeset
936 for (i=1; i<105; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
937 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
938 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
939 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
940 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
941 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
942 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
943 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
944 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
945 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
946 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
947 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
948 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
949 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
950 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
951 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
952 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
953 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
954 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
955 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
956 if (decode_step==1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
957 pAwards[i].pText=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
958 else if (decode_step==2)
949
Nomad
parents: 825
diff changeset
959 pAwards[i].uPriority = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
960 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
961 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
962 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
963 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
964 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
965 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
966 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
967 } while ((decode_step<3)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
968 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
969 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
970 // 7241C8: using guessed type int dword_7241C8;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
971
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
972 //----- (004764C2) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
973 void InitializeScrolls()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
974 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
975
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
976 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
977 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
978 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
979 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
980 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
981 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
982 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
983
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
984 if ( pScrollsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
985 pAllocator->FreeChunk(pScrollsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
986 pScrollsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
987 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
988 strtok(pScrollsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
989 for (i=0; i<82; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
990 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
991 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
992 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
993 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
994 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
995 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
996 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
997 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
998 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
999 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1000 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1001 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1002 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1003 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1004 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1005 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1006 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1007 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1008 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1009 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1010 pScrolls[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1011 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1012 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1013 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1014 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1015 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1016 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1017 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1018 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1019 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1020 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1021
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1022 //----- (00476590) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1023 void InitializeMerchants()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1024 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1025 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1026 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1027 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1028 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1029 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1030 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1031 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1032
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1033 if ( pMerchantsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1034 pAllocator->FreeChunk(pMerchantsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1035 pMerchantsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1036 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1037 strtok(pMerchantsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1038
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1039 for (i=0; i<7; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1040 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1041 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1042 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1043 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1044 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1045 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1046 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1047 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1048 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1049 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1050 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1051 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1052 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1053 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1054 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1055 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1056 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1057 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1058 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1059 switch (decode_step)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1060 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1061 case 1:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1062 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1063 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1064 case 2:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1065 pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1066 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1067 case 3:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1068 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1069 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1070 case 4:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1071 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1072 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1073 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1074 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1075 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1076 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1077 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1078 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1079 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1080 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1081 } while ((decode_step<5)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1082 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1083
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1084 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1085
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1086 //----- (00476682) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1087 void InitializeTransitions()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1088 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1089 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1090 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1091 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1092 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1093 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1094 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1095 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1096
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1097 if ( pTransitionsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1098 pAllocator->FreeChunk(pTransitionsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1099 pTransitionsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1100 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1101 strtok(pTransitionsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1102
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1103 for (i=0; i<464; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1104 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1105 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1106 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1107 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1108 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1109 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1110 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1111 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1112 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1113 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1114 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1115 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1116 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1117 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1118 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1119 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1120 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1121 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1122 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1123 if ( decode_step == 1)
434
137c59c3dbc4 Temple of Moon and Dragon Lair can now be entered.
Nomad
parents: 353
diff changeset
1124 pTransitionStrings[i + 1]=RemoveQuotes(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1125 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1126 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1127 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1128 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1129 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1130 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1131 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1132 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1133 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1134 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1135
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1136 //----- (00476750) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1137 void __cdecl InitializeAutonotes()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1138 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1139 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1140 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1141 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1142 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1143 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1144 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1145 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1146
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1147 if ( pAutonoteTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1148 pAllocator->FreeChunk(pAutonoteTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1149 pAutonoteTXT_Raw = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1150 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1151 strtok(pAutonoteTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1152
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1153 for (i=0; i<195; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1154 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1155 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1156 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1157 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1158 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1159 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1160 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1161 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1162 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1163 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1164 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1165 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1166 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1167 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1168 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1169 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1170 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1171 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1172 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1173 switch (decode_step)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1174 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1175 case 1:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1176 pAutonoteTxt[i].pText=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1177 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1178 case 2:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1179 {
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1180 if ( !_stricmp(test_string, "potion"))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1181 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1182 pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1183 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1184 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1185 if ( !_stricmp(test_string, "stat") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1186 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1187 pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1188 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1189 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1190 if ( !_stricmp(test_string, "seer") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1191 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1192 pAutonoteTxt[i].eType = AUTONOTE_SEER;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1193 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1194 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1195 if ( !_stricmp(test_string, "obelisk") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1196 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1197 pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1198 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1199 }
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1099
diff changeset
1200 if ( !_stricmp(test_string, "teacher") )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1201 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1202 pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1203 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1204 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1205 pAutonoteTxt[i].eType =AUTONOTE_MISC;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1206 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1207 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1208 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1209 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1210 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1211 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1212 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1213 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1214 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1215 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1216 } while ((decode_step<3)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1217 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1218 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1219
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1220
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1221 //----- (004768A9) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1222 void __cdecl InitializeQuests()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1223 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1224 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1225 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1226 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1227 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1228 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1229 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1230 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1231
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1232 if ( pQuestsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1233 pAllocator->FreeChunk(pQuestsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1234 pQuestsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1235 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1236 strtok(pQuestsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1237
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1238 for (i=0; i<512; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1239 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1240 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1241 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1242 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1243 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1244 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1245 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1246 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1247 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1248 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1249 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1250 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1251 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1252 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1253 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1254 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1255 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1256 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1257 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1258 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1259 pQuestTable[i] =RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1260 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1261 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1262 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1263 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1264 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1265 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1266 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1267 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1268 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1269 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1270