-
Notifications
You must be signed in to change notification settings - Fork 1
/
Kronos.scar
159 lines (129 loc) · 4.36 KB
/
Kronos.scar
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
unit kronos.Kronos;
//----------------------------------------------------------------------------//
//-- Kronos Reflection Library --//
//----------------------------------------------------------------------------//
//-- In Greek mythology, Cronus or Kronos was the leader and the youngest --//
//-- of the first generation of Titans, divine descendants of Gaia, the --//
//-- earth, and Uranus, the sky. He overthrew his father and ruled during --//
//-- the mythological Golden Age, until he was overthrown by his own sons, --//
//-- Zeus, Hades, and Poseidon, and imprisoned in Tartarus. --//
//-- --//
//-- Kronos is the reflection library for the new SCAR 4: Titan. It is a --//
//-- pilot include designed to make use of the newly added object --//
//-- oriented programming features. This include is designed for speed and --//
//-- accuracy while maintaining easy coding practices for beginning --//
//-- programmers. We hope to make this a fun but powerful include for --//
//-- botters and scripters alike. --//
//-- --//
//-- Kronos is written and maintained by Drags111 with help and --//
//-- special thanks to: --//
//-- Benland100, Freddy1990 mormonman, pyroryan, Trilez, --//
//-- and The SRL Community --//
//-- --//
//----------------------------------------------------------------------------//
interface
uses
kronos.smart.SMART,
kronos.lib.core.Hooks,
kronos.lib.core.Globals,
kronos.lib.wrappers.Renderable,
kronos.lib.wrappers.Node,
kronos.lib.wrappers.NodeCache,
kronos.lib.wrappers.NodeList,
kronos.lib.wrappers.RSObject,
kronos.lib.wrappers.NPCDef,
Types;
procedure SetupKronos;
function IsRSReady: Boolean;
procedure CheckUnfreedObjects;
implementation
(*
SetupKronos
~~~~~~~~~~~
.. code-block:: pascal
procedure SetupKronos;
Initiates Kronos and sets up SMART.
.. note::
by Drags111
*)
procedure SetupKronos;
var
T: Integer;
begin
SmartSetup('http://world1.runescape.com/',
'plugin.js?param=o0,a0,m1', 765, 503, 's');
T := Time.SysTime;
while(not IsRSReady) and ((Time.SysTime - T) < 300000)do
Time.Wait(500);
end;
(*
IsRSReady
~~~~~~~~~
.. code-block:: pascal
function IsRSReady: Boolean;
Returns true if Runescape is done loading.
.. note::
by Drags111
*)
function IsRSReady: Boolean;
var
LoginIndex: Integer;
begin
LoginIndex := SmartGetFieldInt(0, hook_static_LoginIndex);
Result := LoginIndex >= 3;
end;
(*
CheckUnfreedObjects
~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
procedure CheckUnfreedObjects;
Checks for unfreed objects at the end of the script. Called in the finialization
of the Kronos unit.
.. note::
by Drags111
*)
procedure CheckUnfreedObjects;
var
I, H, C: Integer;
begin
C := 0;
if(UnfreedObjects.Count < 1)then
begin
Println('There are no unfreed objects!');
Exit;
end;
Println('There are '+ToStr(UnfreedObjects.Count)+' unfreed objects remaining.');
H := UnfreedObjects.Count -1;
for I := 0 to H do
begin
if(UnfreedObjects.Count <= 0)then
Exit;
Print('Freed Object['+ToStr(I)+'];');
try
if(UnfreedObjects[C] is TRenderable)then
Println(' Instance of TRenderable;')
else if(UnfreedObjects[C] is TNode)then
Println(' Instance of TNode;')
else if(UnfreedObjects[C] is TNodeCache)then
Println(' Instance of TNodeCache;')
else if(UnfreedObjects[C] is TNodeList)then
Println(' Instance of TNodeList;')
else if(UnfreedObjects[C] is TRSObjectDef)then
Println(' Instance of TRSObjectDef;')
else if(UnfreedObjects[C] is TNPCDef)then
Println(' Instance of TNPCDef;')
else if(UnfreedObjects[C] is TNPCDefLoader)then
Println(' Instance of TNPCDefLoader;')
else
Println('');
UnfreedObjects[C].Free;
except
Println(' Caught exception while freeing an object.');
C++;
end;
end;
end;
finalization
CheckUnfreedObjects;
UnfreedObjects.Free;
end.