-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_arrays_objects_and_npc_definitions.py
70 lines (65 loc) · 2.35 KB
/
test_arrays_objects_and_npc_definitions.py
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
# Copyright 2020 by Brett J. Moan
#
# This file is part of pyautoeios.
#
# pyautoeios is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyautoeios is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyautoeios. If not, see <https://www.gnu.org/licenses/>.
import pyautoeios as pyauto
from pyautoeios._internal.rs_client import RSClient
from pyautoeios._internal import hooks
from pyautoeios._internal.rs_structures import RSObjectArray
from pyautoeios._internal.rs_npc import RSNPC
import pyautoeios as pyauto
from pyautoeios._internal.rs_player import me
pyauto.inject_clients()
client = pyauto.clients[0]
pyauto.pair_client(client)
rs_client = RSClient(client, None)
# indices = rs_client.npc_indices()
# shrunk = [i for i in indices if i]
# print(shrunk)
# npcs_ref, npcs_size = client.get_array_with_size(None, hooks.CLIENT_LOCALNPCS)
# print(f"{npcs_ref = }, {npcs_size = }")
# npcs = RSObjectArray(client, npcs_ref, npcs_size, indices=shrunk)
# print(f"{npcs = }, {npcs.elements = }")
# client.get_array_indices()
# result_type = ctypes.c_void_p * len(shrunk)
# foo = ctypes.cast(npcs._elements, ctypes.POINTER(result_type))
# print(f"{foo = } {foo.contents = } {foo.contents[:] = }")
# npc_array = []
# for i in foo.contents[:]:
# if i:
# print(f"{i = }")
# npc = RSNPC(client, i)
# print(f"{npc = }")
# definition = npc.definition()
# print(f"{definition = }")
# if definition:
# npc_array.append({
# "name": definition.name(),
# "oid" : definition.oid(),
# })
npcs = rs_client.all_npcs()
# npc = npcs[0]
# definition = npc.definition()
npc_array = []
for npc in rs_client.all_npcs():
definition = npc.definition()
if definition:
npc_array.append(
{
"name": definition.name(),
"oid": definition.oid(),
}
)
print(npc_array)