annotate NPC.cpp @ 377:243418228760

GetIdentifiedName
author Gloval
date Fri, 22 Feb 2013 22:27:45 +0400
parents 95be2dcecadf
children 137c59c3dbc4 eaadcb39312f
rev   line source
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1 #include <string.h>
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
2 #include <stdlib.h>
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
3
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
4 #include "Allocator.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
5 #include "texts.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
6 #include "Party.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
7 #include "LOD.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
8 #include "Autonotes.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
9 #include "Awards.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
10 #include "mm7_data.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
11 #include "MM7.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
12 #include "NPC.h"
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
13
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
14
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
15 void InitializeAwards();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
16 void InitializeScrolls();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
17 void InitializeMerchants();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
18 void InitializeTransitions();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
19 void InitializeAutonotes();
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
20 void InitializeQuests();
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
21 bool CheckPortretAgainstSex(int portret_num, int sex);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
22
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
23 //----- (00476977) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
24 void NPCStats::InitializeNPCText()
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
25 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
26 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
27 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
28 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
29 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
30 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
31 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
32 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
33
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
34 if (pNPCTextTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
35 pAllocator->FreeChunk(pNPCTextTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
36 pNPCTextTXT_Raw =NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
37 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
38 strtok(pNPCTextTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
39
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
40 for (i=0; i<789; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
41 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
42 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
43 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
44 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
45 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
46 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
47 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
48 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
49 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
50 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
51 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
52 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
53 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
54 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
55 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
56 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
57 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
58 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
59 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
60 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
61 pNPCTopics[i].pText =RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
62 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
63 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
64 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
65 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
66 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
67 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
68 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
69 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
70 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
71
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
72 if (pNPCTopicTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
73 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
74 pNPCTopicTXT_Raw =NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
75 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
76 strtok(pNPCTopicTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
77
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
78 for (i=0; i<579; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
79 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
80 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
81 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
82 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
83 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
84 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
85 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
86 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
87 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
88 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
89 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
90 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
91 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
92 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
93 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
94 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
95 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
96 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
97 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
98 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
99 pNPCTopics[i].pTopic = RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
100 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
101 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
102 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
103 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
104 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
105 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
106 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
107 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
108 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
109
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
110 if (pNPCDistTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
111 pAllocator->FreeChunk(pNPCDistTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
112 pNPCDistTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
113 pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
114 strtok(pNPCDistTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
115 strtok(NULL, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
116
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
117 for (i=1; i<59; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
118 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
119 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
120 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
121 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
122 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
123 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
124 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
125 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
126 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
127 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
128 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
129 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
130 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
131 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
132 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
133 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
134 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
135 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
136 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
137 if ((decode_step>0)&&(decode_step<77))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
138 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
139 pProfessionChance[decode_step].professionChancePerArea[i]=atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
140 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
141 else if (decode_step==0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
142 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
143 pProfessionChance[0].professionChancePerArea[i]=10;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
144 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
145 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
146 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
147 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
148 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
149 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
150 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
151 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
152 } while ((decode_step<78)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
153 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
154
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
155 for (i=0; i<78; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
156 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
157 pProfessionChance[i].uTotalprofChance=0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
158 for (int ii=1; ii<59; ++ii)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
159 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
160 pProfessionChance[i].uTotalprofChance+=pProfessionChance[i].professionChancePerArea[ii];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
161 }
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
162 pProfessionChance[i].professionChancePerArea[0]=0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
163 pProfessionChance[i].professionChancePerArea[59]=0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
164 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
165
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
166 if (pNPCDistTXT_Raw)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
167 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
168 pAllocator->FreeChunk(pNPCDistTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
169 pNPCDistTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
170 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
171 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
172
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
173 //----- (00476C60) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
174 void NPCStats::_476C60()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
175 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
176 for (unsigned int i = 1; i < uNumNewNPCs; ++i)
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
177 pNewNPCData[i].pName = pNPCUnicNames[i - 1];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
178
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
179 if (pParty->pHirelings[0].pName)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
180 pParty->pHirelings[0].pName = pParty->pHireling1Name;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
181 if (pParty->pHirelings[1].pName)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
182 pParty->pHirelings[1].pName = pParty->pHireling2Name;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
183 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
184
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
185 //----- (00476CB5) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
186 void NPCStats::InitializeNPCData()
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
187 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
188 int i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
189 char* test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
190 unsigned char c;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
191 bool break_loop;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
192 unsigned int temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
193 char* tmp_pos;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
194 int decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
195
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
196 pNPCDataTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
197 strtok(pNPCDataTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
198 strtok(NULL, "\r");
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
199
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
200 for (i=0; i<500; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
201 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
202 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
203 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
204 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
205 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
206 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
207 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
208 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
209 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
210 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
211 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
212 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
213 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
214 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
215 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
216 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
217 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
218 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
219 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
220 switch (decode_step)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
221 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
222 case 1:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
223 pNPCUnicNames[i] = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
224 pNPCData[i+1].pName=pNPCUnicNames[i];
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
225 break;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
226 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
227 pNPCData[i+1].uPortraitID = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
228 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
229 case 6:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
230 pNPCData[i+1].Location2D = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
231 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
232 case 7:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
233 pNPCData[i+1].uProfession = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
234 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
235 case 8:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
236 pNPCData[i+1].greet = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
237 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
238 case 9:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
239 pNPCData[i+1].joins = (*test_string == 'y')?1:0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
240 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
241 case 10:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
242 pNPCData[i+1].evt_A = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
243 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
244 case 11:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
245 pNPCData[i+1].evt_B = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
246 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
247 case 12:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
248 pNPCData[i+1].evt_C = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
249 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
250 case 13:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
251 pNPCData[i+1].evt_D = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
252 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
253 case 14:
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
254 pNPCData[i+1].evt_E = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
255 break;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
256 case 15:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
257 pNPCData[i+1].evt_F = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
258 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
259 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
260 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
261 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
262 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
263 } while ((decode_step<16)&&!break_loop);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
264 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
265 uNumNewNPCs = 501;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
266 pNPCGreetTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
267 strtok(pNPCGreetTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
268 for (i=0; i<205; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
269 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
270 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
271 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
272 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
273 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
274 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
275 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
276 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
277 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
278 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
279 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
280 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
281 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
282 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
283 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
284 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
285 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
286 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
287 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
288 switch (decode_step)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
289 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
290 case 1:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
291 pNPCGreetings[i].pGreeting1 = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
292 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
293 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
294 pNPCGreetings[i].pGreeting2 = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
295 break;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
296 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
297 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
298 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
299 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
300 } while ((decode_step<3)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
301 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
302
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
303 pNCPGroupTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
304 strtok(pNCPGroupTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
305
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
306 for (i=0; i<51; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
307 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
308 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
309 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
310 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
311 do
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
312 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
313 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
314 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
315 while((c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
316 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
317 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
318 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
319 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
320 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
321 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
322 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
323 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
324 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
325 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
326 if (decode_step==1)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
327 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
328 pGroups[i] = atoi(test_string);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
329 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
330 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
331 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
332 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
333 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
334 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
335
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
336 pNPCNewsTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcnews.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
337 strtok(pNPCNewsTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
338
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
339
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
340 for (i=0; i<51; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
341 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
342 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
343 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
344 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
345 do
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
346 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
347 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
348 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
349 while((c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
350 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
351 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
352 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
353 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
354 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
355 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
356 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
357 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
358 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
359 { //i+1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
360 if (decode_step==1)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
361 pCatchPhrases[i] = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
362 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
363 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
364 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
365 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
366 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
367 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
368
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
369 //----- (0047702F) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
370 void NPCStats::Initialize()
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
371 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
372 int i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
373 char* test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
374 unsigned char c;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
375 bool break_loop;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
376 unsigned int temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
377 char* tmp_pos;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
378 int decode_step;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
379
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
380 InitializeNPCData();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
381 InitializeNPCText();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
382 InitializeQuests();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
383 InitializeAutonotes();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
384 InitializeAwards();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
385 InitializeTransitions();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
386 InitializeMerchants();
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
387 InitializeScrolls();
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
388
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
389 pNPCNamesTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
390 pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
391 strtok(pNPCNamesTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
392
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
393 uNewlNPCBufPos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
394
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
395 for (i=0; i<540; ++i)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
396 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
397 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
398 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
399 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
400 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
401 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
402 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
403 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
404 if (c=='\t')
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
405 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
406 if ( (decode_step == 1)&&(!uNumNPCNames[1]))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
407 uNumNPCNames[1]=i;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
408 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
409 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
410 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
411 while((c!='\n')&&(c!='\t')&&(c>0))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
412 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
413 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
414 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
415 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
416 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
417 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
418 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
419
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
420 if (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 = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
423 if ( decode_step == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
424 pNPCNames[i][0] =RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
425 else if ( decode_step == 1)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
426 pNPCNames[i][1] =RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
427 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
428 else
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
429 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
430 if ( (decode_step == 1)&&(!uNumNPCNames[1]))
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
431 uNumNPCNames[1]=i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
432 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
433 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
434 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
435 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
436 } while ((decode_step<2)&&!break_loop);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
437 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
438 uNumNPCNames[0] = i;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
439
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
440 pNPCProfTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
441 pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
442 strtok(pNPCProfTXT_Raw, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
443 strtok(NULL, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
444 strtok(NULL, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
445 strtok(NULL, "\r");
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
446
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
447 for (i=1; i<59; ++i)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
448 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
449 test_string = strtok(NULL, "\r") + 1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
450 break_loop = false;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
451 decode_step=0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
452 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
453 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
454 c = *(unsigned char*)test_string;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
455 temp_str_len = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
456 while((c!='\t')&&(c>0))
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
457 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
458 ++temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
459 c=test_string[temp_str_len];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
460 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
461 tmp_pos=test_string+temp_str_len;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
462 if (*tmp_pos == 0)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
463 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
464 *tmp_pos = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
465 if (temp_str_len)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
466 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
467 switch(decode_step)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
468 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
469 case 2:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
470 pProfessions[i].uHirePrice = atoi(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
471 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
472 case 3:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
473 pProfessions[i].pActionText = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
474 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
475 case 4:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
476 pProfessions[i].pBenefits= RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
477 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
478 case 5:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
479 pProfessions[i].pJoinText = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
480 break;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
481 case 6:
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
482 pProfessions[i].pDismissText = RemoveQuotes(test_string);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
483 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
484 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
485 else
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
486 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
487 if (!decode_step)
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
488 break_loop = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
489 }
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
490 ++decode_step;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
491 test_string=tmp_pos+1;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
492 } while ((decode_step<7)&&!break_loop);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
493 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
494 uNumNPCProfessions = 59;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
495 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
496
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
497 //----- (00477266) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
498 void NPCStats::Release()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
499 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
500 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
501 pNPCTopicTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
502 pAllocator->FreeChunk(pNPCTextTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
503 pNPCTextTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
504 pAllocator->FreeChunk(pNPCNewsTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
505 pNPCNewsTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
506 pAllocator->FreeChunk(pNPCProfTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
507 pNPCProfTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
508 pAllocator->FreeChunk(pNPCNamesTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
509 pNPCNamesTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
510 pAllocator->FreeChunk(pNPCDataTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
511 pNPCDataTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
512 pAllocator->FreeChunk(pNPCDistTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
513 pNPCDistTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
514 pAllocator->FreeChunk(pNPCGreetTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
515 pNPCGreetTXT_Raw = NULL;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
516 pAllocator->FreeChunk(pNCPGroupTXT_Raw);
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
517 pNCPGroupTXT_Raw = NULL;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
518 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
519
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
520 //----- (0047730C) --------------------------------------------------------
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
521 bool CheckPortretAgainstSex(int a1, int)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
522 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
523 return true;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
524 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
525 // 47730C: using guessed type int __stdcall const_1(int);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
526
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
527 //----- (0047732C) --------------------------------------------------------
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
528 void NPCStats::InitializeAdditionalNPCs(NPCData *pNPCDataBuff, int npc_uid, int uLocation2D, int uMapId)
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
529 {
292
5586bb4e8395 build fix
Gloval
parents: 291
diff changeset
530 int rep_gen;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
531 int uNPCSex; // esi@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
532 int uGeneratedPortret; // ecx@23
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
533 int test_prof_summ; // ecx@37
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
534 int gen_profession; // eax@37
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
535 int max_prof_cap; // edx@37
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
536 signed int result; // eax@39
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
537 int uRace; // [sp+Ch] [bp-Ch]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
538 bool break_gen; // [sp+10h] [bp-8h]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
539 signed int gen_attempts; // [sp+14h] [bp-4h]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
540 int uPortretMin; // [sp+24h] [bp+Ch]@1
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
541 int uPortretMax;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
542
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
543 static const unsigned __int8 NPCSexGenTable[86] ={
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
544 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
545 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
546 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
547 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
548 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 };
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
549 static const unsigned __int8 NPCRaceGenTable[86] ={
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
550 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
551 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
552 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
553 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
554 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0};
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
555
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
556 unsigned __int8 seed = (unsigned __int8)((double)(npc_uid - 1)/3.0);
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
557 uNPCSex = NPCSexGenTable[seed];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
558 uRace = NPCRaceGenTable[seed];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
559 pNPCDataBuff->uSex = uNPCSex;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
560 pNPCDataBuff->pName = pNPCNames[rand() % uNumNPCNames[uNPCSex]][uNPCSex];
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
561
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
562 gen_attempts = 0;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
563 break_gen = false;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
564
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
565 do
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
566 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
567 switch ( uRace )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
568 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
569 case 0:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
570 if ( uNPCSex == 0 )
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
571 {
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
572 uPortretMin = 2;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
573 uPortretMax = 100;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
574 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
575 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
576 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
577 uPortretMin = 201;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
578 uPortretMax = 250;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
579 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
580 case 1:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
581 if ( uNPCSex == 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
582 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
583 uPortretMin = 400;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
584 uPortretMax = 430;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
585 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
586 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
587 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
588 uPortretMin = 460;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
589 uPortretMax = 490;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
590 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
591 break;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
592 case 2:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
593 if ( uNPCSex == 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
594 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
595 uPortretMin = 500;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
596 uPortretMax = 520;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
597 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
598 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
599 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
600 uPortretMin = 530;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
601 uPortretMax = 550;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
602 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
603 break;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
604 case 3:
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
605 if ( uNPCSex == 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
606 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
607 uPortretMin = 300;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
608 uPortretMax = 330;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
609 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
610 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
611 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
612 uPortretMin = 360;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
613 uPortretMax = 387;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
614 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
615
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
616 break;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
617 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
618
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
619 uGeneratedPortret = uPortretMin + rand() % (uPortretMax - uPortretMin + 1);
307
72faa54ff319 Events stuff moved to its file
Gloval
parents: 293
diff changeset
620 if ( CheckPortretAgainstSex(uGeneratedPortret, uNPCSex))
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
621 break_gen = true;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
622 ++gen_attempts;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
623 if ( gen_attempts >= 4 )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
624 {
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
625 uGeneratedPortret = uPortretMin;
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
626 break_gen = true;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
627 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
628 }
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
629 while(!break_gen);
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
630
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
631 pNPCDataBuff->uPortraitID = uGeneratedPortret;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
632 pNPCDataBuff->uFlags = 0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
633 pNPCDataBuff->fame = 0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
634 //generate reputation
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
635 rep_gen = rand() % 100 + 1;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
636
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
637 if ( rep_gen >= 60 )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
638 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
639 if ( rep_gen >= 90 )
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
640 {
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
641 if ( rep_gen >= 95 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
642 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
643 if ( rep_gen >= 98 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
644 pNPCDataBuff->rep = -600;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
645 else
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
646 pNPCDataBuff->rep = 400;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
647 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
648 else
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
649 pNPCDataBuff->rep = -300;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
650 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
651 else
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
652 pNPCDataBuff->rep = 200;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
653 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
654 else
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
655 pNPCDataBuff->rep = 0;
291
0ea5fbd16edb NPC mostly done
Gloval
parents: 257
diff changeset
656
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
657 max_prof_cap = rand() % pProfessionChance[uMapId].uTotalprofChance+1;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
658 test_prof_summ = 0;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
659 gen_profession = 0;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
660
293
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
661 if ( max_prof_cap > 0 )
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
662 {
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
663 do
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
664 test_prof_summ += pProfessionChance[uMapId].professionChancePerArea[gen_profession++];
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
665 while ( test_prof_summ < max_prof_cap );
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
666 }
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
667 pNPCDataBuff->uProfession = gen_profession - 1;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
668 pNPCDataBuff->Location2D = uLocation2D;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
669 pNPCDataBuff->field_24 = 1;
27670273a6ff little fix npc gen
Gloval
parents: 292
diff changeset
670 pNPCDataBuff->joins = 1;
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
671 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
672
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
673
257
Nomad
parents: 253
diff changeset
674 //----- (00476387) --------------------------------------------------------
Nomad
parents: 253
diff changeset
675 bool PartyHasDragon()
Nomad
parents: 253
diff changeset
676 {
Nomad
parents: 253
diff changeset
677 return pNPCStats->pNewNPCData[57].Hired();
Nomad
parents: 253
diff changeset
678 }
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
679
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
680 //----- (00476395) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
681 //0x26 Wizard eye at skill level 2
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
682 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
353
95be2dcecadf Partial refactor for Player::GetActualSkillLevel
Nomad
parents: 307
diff changeset
683 {
251
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
684 bool result; // eax@2
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
685 signed int v2; // esi@3
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
686 char *v3; // eax@4
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
687
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
688 if ( bNoNPCHiring == 1 )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
689 return 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
690 v2 = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
691 if ( (signed int)pNPCStats->uNumNewNPCs <= 0 )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
692 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
693 LABEL_8:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
694 result = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
695 if ( pParty->pHirelings[0].uProfession != uProfession )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
696 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
697 LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
698 return result;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
699 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
700 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
701 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
702 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
703 v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
704 while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
705 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
706 ++v2;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
707 v3 += 76;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
708 if ( v2 >= (signed int)pNPCStats->uNumNewNPCs )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
709 goto LABEL_8;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
710 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
711 result = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
712 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
713 ++result;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
714 return result;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
715 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
716 // 6BE3C5: using guessed type char bNoNPCHiring;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
717
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
718 //----- (004763E0) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
719 void InitializeAwards()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
720 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
721
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
722 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
723 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
724 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
725 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
726 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
727 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
728 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
729
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
730 if ( pAwardsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
731 pAllocator->FreeChunk(pAwardsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
732 pAwardsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
733 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
734 strtok(pAwardsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
735
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
736 for (i=1; i<104; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
737 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
738 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
739 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
740 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
741 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
742 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
743 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
744 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
745 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
746 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
747 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
748 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
749 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
750 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
751 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
752 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
753 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
754 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
755 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
756 if (decode_step==1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
757 pAwards[i].pText=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
758 else if (decode_step==2)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
759 pAwards[i].uSort=atoi(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
760 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
761 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
762 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
763 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
764 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
765 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
766 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
767 } while ((decode_step<3)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
768 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
769
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
770 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
771 // 7241C8: using guessed type int dword_7241C8;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
772
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
773 //----- (004764C2) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
774 void InitializeScrolls()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
775 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
776
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
777 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
778 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
779 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
780 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
781 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
782 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
783 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
784
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
785 if ( pScrollsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
786 pAllocator->FreeChunk(pScrollsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
787 pScrollsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
788 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
789 strtok(pScrollsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
790 for (i=0; i<82; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
791 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
792 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
793 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
794 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
795 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
796 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
797 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
798 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
799 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
800 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
801 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
802 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
803 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
804 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
805 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
806 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
807 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
808 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
809 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
810 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
811 pScrolls[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
812 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
813 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
814 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
815 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
816 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
817 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
818 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
819 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
820 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
821 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
822
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
823
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
824 //----- (00476590) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
825 void InitializeMerchants()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
826 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
827 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
828 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
829 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
830 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
831 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
832 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
833 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
834
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
835 if ( pMerchantsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
836 pAllocator->FreeChunk(pMerchantsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
837 pMerchantsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
838 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
839 strtok(pMerchantsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
840
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
841 for (i=0; i<7; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
842 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
843 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
844 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
845 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
846 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
847 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
848 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
849 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
850 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
851 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
852 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
853 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
854 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
855 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
856 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
857 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
858 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
859 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
860 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
861 switch (decode_step)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
862 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
863 case 1:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
864 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
865 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
866 case 2:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
867 pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
868 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
869 case 3:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
870 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
871 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
872 case 4:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
873 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
874 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
875 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
876 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
877 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
878 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
879 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
880 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
881 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
882 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
883 } while ((decode_step<5)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
884 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
885
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
886 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
887
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
888 //----- (00476682) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
889 void InitializeTransitions()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
890 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
891 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
892 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
893 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
894 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
895 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
896 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
897 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
898
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
899 if ( pTransitionsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
900 pAllocator->FreeChunk(pTransitionsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
901 pTransitionsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
902 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
903 strtok(pTransitionsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
904
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
905 for (i=0; i<464; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
906 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
907 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
908 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
909 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
910 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
911 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
912 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
913 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
914 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
915 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
916 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
917 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
918 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
919 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
920 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
921 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
922 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
923 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
924 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
925 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
926 pTransitionStrings[i]=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
927 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
928 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
929 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
930 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
931 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
932 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
933 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
934 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
935 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
936 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
937
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
938 //----- (00476750) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
939 void __cdecl InitializeAutonotes()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
940 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
941 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
942 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
943 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
944 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
945 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
946 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
947 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
948
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
949 if ( pAutonoteTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
950 pAllocator->FreeChunk(pAutonoteTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
951 pAutonoteTXT_Raw = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
952 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
953 strtok(pAutonoteTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
954
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
955 for (i=0; i<195; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
956 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
957 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
958 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
959 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
960 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
961 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
962 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
963 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
964 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
965 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
966 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
967 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
968 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
969 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
970 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
971 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
972 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
973 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
974 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
975 switch (decode_step)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
976 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
977 case 1:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
978 pAutonoteTxt[i].pText=RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
979 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
980 case 2:
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
981 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
982 if ( !_strcmpi(test_string, "potion"))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
983 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
984 pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
985 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
986 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
987 if ( !_strcmpi(test_string, "stat") )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
988 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
989 pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
990 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
991 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
992 if ( !_strcmpi(test_string, "seer") )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
993 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
994 pAutonoteTxt[i].eType = AUTONOTE_SEER;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
995 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
996 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
997 if ( !_strcmpi(test_string, "obelisk") )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
998 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
999 pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1000 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1001 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1002 if ( !_strcmpi(test_string, "teacher") )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1003 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1004 pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1005 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1006 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1007 pAutonoteTxt[i].eType =AUTONOTE_MISC;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1008 break;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1009 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1010 }
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<3)&&!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
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1023 //----- (004768A9) --------------------------------------------------------
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1024 void __cdecl InitializeQuests()
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1025 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1026 int i;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1027 char* test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1028 unsigned char c;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1029 bool break_loop;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1030 unsigned int temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1031 char* tmp_pos;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1032 int decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1033
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1034 if ( pQuestsTXT_Raw )
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1035 pAllocator->FreeChunk(pQuestsTXT_Raw);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1036 pQuestsTXT_Raw = NULL;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1037 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1038 strtok(pQuestsTXT_Raw, "\r");
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1039
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1040 for (i=0; i<512; ++i)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1041 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1042 test_string = strtok(NULL, "\r") + 1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1043 break_loop = false;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1044 decode_step=0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1045 do
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1046 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1047 c = *(unsigned char*)test_string;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1048 temp_str_len = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1049 while((c!='\t')&&(c>0))
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1050 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1051 ++temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1052 c=test_string[temp_str_len];
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1053 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1054 tmp_pos=test_string+temp_str_len;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1055 if (*tmp_pos == 0)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1056 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1057 *tmp_pos = 0;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1058 if (temp_str_len)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1059 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1060 if ( decode_step == 1)
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1061 pQuestTable[i] =RemoveQuotes(test_string);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1062 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1063 else
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1064 {
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1065 break_loop = true;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1066 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1067 ++decode_step;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1068 test_string=tmp_pos+1;
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1069 } while ((decode_step<2)&&!break_loop);
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1070 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1071 }
48f21f569328 Npc related stuff separated
Gloval
parents:
diff changeset
1072