annotate NPC.cpp @ 683:d4497b76a863

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