annotate NPC.cpp @ 292:5586bb4e8395

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