-
Notifications
You must be signed in to change notification settings - Fork 1
/
stealthpage.pas
221 lines (209 loc) · 5.93 KB
/
stealthpage.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
unit stealthpage;
interface
implementation
const
StealthPageAccessKey = '11111111111111111111111111111111';
StealthPageURL = 'http://stealthpage.appspot.com';
var
timer,refreshPeriod,lastRecordedJournalLine : integer;
iniFile,initialSkills : TMemIniFile;
{ реализация процедур и функций }
function time() : Integer;
begin
if(timer > 100 * 10 * refreshPeriod) then
begin
timer := 0;
Result:= 1;
end
else
begin
timer := timer + 100;
Result:= 0;
end;
end;
function GetSkillList() : TStringList;
var skills : TStringList;
begin
skills := TstringList.Create;
skills.Add('Alchemy');
skills.Add('Anatomy');
skills.Add('Animal Lore');
skills.Add('Animal Taming');
skills.Add('Archery');
skills.Add('Arms Lore');
skills.Add('Begging');
skills.Add('Blacksmithing');
skills.Add('Bowcraft');
skills.Add('Bushido');
skills.Add('Camping');
skills.Add('Carpentry');
skills.Add('Cartography');
skills.Add('Chivalry');
skills.Add('Cooking');
skills.Add('Detect Hidden');
skills.Add('Enticement');
skills.Add('Evaluate Intelligence');
skills.Add('Fencing');
skills.Add('Fishing');
skills.Add('Focus');
skills.Add('Forensic Evaluation');
skills.Add('Healing');
skills.Add('Herding');
skills.Add('Hiding');
skills.Add('Inscription');
skills.Add('Item ID');
skills.Add('Lockpicking');
skills.Add('Lumberjacking');
skills.Add('Mace Fighting');
skills.Add('Magery');
skills.Add('Magic Resistance');
skills.Add('Meditation');
skills.Add('Mining');
skills.Add('Musicianship');
skills.Add('Necromancy');
skills.Add('Ninjitsu');
skills.Add('Parrying');
skills.Add('Peacemaking');
skills.Add('Poisoning');
skills.Add('Provocation');
skills.Add('Remove Trap');
skills.Add('Snooping');
skills.Add('Spirit Speak');
skills.Add('Stealing');
skills.Add('Stealth');
skills.Add('Swordsmanship');
skills.Add('Tactics');
skills.Add('Tailoring');
skills.Add('Taste Identification');
skills.Add('Tinkering');
skills.Add('Tracking');
skills.Add('Veterinary');
skills.Add('Wrestling');
Result := skills;
end;
procedure WriteNotEmptySkills(iniFile : TMemIniFile);
var skillList : TStringList;
i : integer;
begin
skillList := GetSkillList();
for i:= 0 to skillList.Count-1 do
begin
if GetSkillValue(skillList[i]) > 0 then
iniFile.WriteFloat('Skills',skillList[i],GetSkillValue(skillList[i]));
end;
skillList.Free;
end;
procedure WriteSkillIncrease(iniFile : TMemIniFile);
var skills : TStringList;
i: integer;
skillVal, initialSkillVal : double;
begin
skills := TStringList.Create;
iniFile.ReadSection('Skills', skills);
for i:=0 to skills.Count-1 do
begin
skillVal := iniFile.ReadFloat('Skills',skills[i],0);
initialSkillVal := initialSkills.ReadFloat('Skills',skills[i],0);
iniFile.WriteFloat('SkillsIncrease', skills[i], skillVal-initialSkillVal);
end;
skills.Free;
end;
procedure WriteLastJournalMessages(iniFile : TMemIniFile);
var i, tmpLastMessageId : integer;
begin
i := HighJournal;
tmpLastMessageId := lastRecordedJournalLine+1;
lastRecordedJournalLine := i;
iniFile.EraseSection('Journal');
while tmpLastMessageId <= i do
begin
iniFile.WriteString('Journal', IntToStr(tmpLastMessageId), Journal(tmpLastMessageId));
tmpLastMessageId := tmpLastMessageId + 1;
end;
end;
procedure WriteStats(iniFile : TMemIniFile);
var idead,iconn : integer;
begin
if Connected then
begin
iconn :=1;
end
else
begin
iconn :=0;
end;
if Dead then
begin
idead :=1;
end
else
begin
idead :=0;
end;
iniFile.WriteString('Stats','name', CharName);
iniFile.WriteString('Stats','coordx', IntToStr(GetX(Self)));
iniFile.WriteString('Stats','coordy', IntToStr(GetY(Self)));
iniFile.WriteString('Stats','coordz', IntToStr(GetZ(Self)));
iniFile.WriteString('Stats','direction', IntToStr(GetDirection(Self)));
iniFile.WriteString('Stats','connected',IntToStr(iconn));
iniFile.WriteString('Stats','dead',IntToStr(idead));Dead
iniFile.WriteString('Stats','str',IntToStr(Str));
iniFile.WriteString('Stats','dex',IntToStr(Dex));
iniFile.WriteString('Stats','int',IntToStr(Int));
iniFile.WriteString('Stats','life',IntToStr(Life));
iniFile.WriteString('Stats','maxlife',IntToStr(MaxLife));
iniFile.WriteString('Stats','stam',IntToStr(Stam));
iniFile.WriteString('Stats','maxstam',IntToStr(MaxStam));
iniFile.WriteString('Stats','mana',IntToStr(Mana));
iniFile.WriteString('Stats','maxmana',IntToStr(MaxMana));
end;
procedure SendData(iniFile : TMemIniFile);
var strings, PostList : TStringList;
res, tmpString, iniData : string;
i, j : integer;
begin
strings := TStringList.Create;
PostList := TStringList.Create;
PostList.Add('AccessKey='+StealthPageAccessKey);
iniFile.GetStrings(strings);
for i:= 0 to strings.Count-1 do
begin
tmpString := strings[i];
for j:=1 to Length(tmpString) do
begin
if(tmpString[j]='=') then StrSet('`', j, tmpString);
end;
iniData := iniData + '|n|' + tmpString;
end;
PostList.Add('Ini='+iniData);
res := HTTP_Post(StealthPageURL, PostList);
AddToSystemJournal(res);
end;
procedure StealthPageMain;
var lines: TStringList;
i: integer;
begin
if(time() = 1) then
begin
WriteStats(iniFile);
WriteNotEmptySkills(iniFile);
WriteSkillIncrease(iniFile);
WriteLastJournalMessages(iniFile);
lines := TStringList.Create;
iniFile.getStrings(lines);
//for i:= 0 to lines.Count-1 do
//AddToSystemJournal(lines[i]);
lines.Free;
SendData(iniFile);
end;
end;
begin
AddToSystemJournal('stealthpage init');
refreshPeriod := 10;//sec
iniFile := TMemIniFile.Create('no.ini');
initialSkills := TMemIniFile.Create('no2.ini');
WriteNotEmptySkills(initialSkills);
lastRecordedJournalLine := HighJournal;
SetEventProc(evTimer2, 'StealthPageMain');
AddToSystemJournal('stealthpage init done');
end.