1
+ # Built-ins
2
+ import inspect
3
+
4
+ # RO Modules
5
+ import roplus
6
+ import imgui
7
+
8
+ # In game modules
9
+ import data
10
+ import BigWorld
11
+
12
+
13
+ from pprint import pformat
14
+
15
+ class MainWindow (object ):
16
+
17
+ def __init__ (self , botInstance ):
18
+ self .bot = botInstance
19
+ self .visible = False
20
+ self .attr_search = (0 , '' )
21
+ self .debug_target_locked = False
22
+ roplus .registerCallback ('ROPlus.OnDrawGUI' , self .onDrawGuiCallback )
23
+
24
+ def show (self ):
25
+ self .visible = True
26
+
27
+ def onDrawGuiCallback (self , args ):
28
+ if self .visible :
29
+ if imgui .begin ('RODebug##debug_mainwindow' , (300 ,350 )):
30
+ player = BigWorld .player ()
31
+ imgui .columns (2 )
32
+ imgui .separator ()
33
+
34
+ # Player Name
35
+ imgui .text ('Name' )
36
+ imgui .nextColumn ()
37
+ imgui .text (player .playerName if player else 'Not ingame' )
38
+ imgui .nextColumn ()
39
+
40
+ # Player health
41
+ if hasattr (player , 'hp' ) and hasattr (player , 'mhp' ):
42
+ imgui .text ('Health' )
43
+ imgui .nextColumn ()
44
+ imgui .text ('{0} / {1}' .format (player .hp , player .mhp ))
45
+ imgui .nextColumn ()
46
+
47
+ # Player Mana
48
+ if hasattr (player , 'mp' ) and hasattr (player , 'mmp' ):
49
+ imgui .text ('Mana' )
50
+ imgui .nextColumn ()
51
+ imgui .text ('{0} / {1}' .format (player .mp , player .mmp ))
52
+ imgui .nextColumn ()
53
+
54
+ # Player EXP
55
+ if hasattr (player , 'exp' ) and hasattr (player , 'realLv' ):
56
+ imgui .text ('Experience' )
57
+ imgui .nextColumn ()
58
+ exp_label = '{0} / {1}' .format (player .exp , data .avatar_lv_data .data .get (player .realLv , {}).get ('upExp' , '?' ))
59
+ imgui .text (exp_label )
60
+ imgui .nextColumn ()
61
+
62
+ # Players current position
63
+ if hasattr (player , 'position' ):
64
+ imgui .text ('Position' )
65
+ imgui .nextColumn ()
66
+ imgui .text ('{0}' .format (player .position ))
67
+ # imgui.nextColumn()
68
+
69
+ imgui .columns (1 )
70
+
71
+ # Targetting Sections
72
+ imgui .separator ()
73
+ imgui .columns (2 )
74
+
75
+ if hasattr (player , 'targetLocked' ) and player .targetLocked :
76
+ target = player .targetLocked
77
+
78
+ # Draw some things about the target we have locked
79
+ imgui .text ('targetLocked' )
80
+ imgui .nextColumn ()
81
+ imgui .text ('{0}' .format (target ))
82
+ imgui .nextColumn ()
83
+
84
+ # target HP?
85
+ if hasattr (target , 'hp' ) and hasattr (target , 'mhp' ):
86
+ imgui .text ('Target Health' )
87
+ imgui .nextColumn ()
88
+ imgui .text ('{0} / {1}' .format (target .hp , target .mhp ))
89
+ imgui .nextColumn ()
90
+
91
+ # target Mana
92
+ if hasattr (target , 'mp' ) and hasattr (target , 'mmp' ):
93
+ imgui .text ('Target Mana' )
94
+ imgui .nextColumn ()
95
+ imgui .text ('{0} / {1}' .format (target .mp , target .mmp ))
96
+ imgui .nextColumn ()
97
+
98
+ # target Level
99
+ if hasattr (target , 'lv' ):
100
+ imgui .text ('Target Level' )
101
+ imgui .nextColumn ()
102
+ imgui .text ('{0}' .format (target .lv ))
103
+ imgui .nextColumn ()
104
+
105
+ # target current position
106
+ if hasattr (target , 'position' ):
107
+ imgui .text ('Target Position' )
108
+ imgui .nextColumn ()
109
+ imgui .text ('{0}' .format (target .position ))
110
+ imgui .nextColumn ()
111
+ else :
112
+ imgui .text ('No Target' )
113
+
114
+ imgui .columns (1 )
115
+ imgui .separator ()
116
+ if imgui .checkbox ('Debug Target Instead?' , self .debug_target_locked ):
117
+ self .debug_target_locked = not self .debug_target_locked
118
+
119
+ imgui .text ('Search Attributes: ' )
120
+ imgui .sameLine ()
121
+ self .attr_search = imgui .inputText ('' , '' )
122
+
123
+ # The real fun
124
+ if self .debug_target_locked :
125
+ if hasattr (player , 'targetLocked' ):
126
+ obj = player .targetLocked
127
+ else :
128
+ self .debug_target_locked = False
129
+ else :
130
+ obj = player # vars(player).items()
131
+ if True :
132
+ IGNORED_ATTRS = ['abilityData' ]
133
+ for item in dir (obj ):
134
+ if self .attr_search [0 ] and self .attr_search [1 ].lower () not in item .lower (): # If we're filtering results
135
+ continue
136
+ if hasattr (obj , item ):
137
+ value = getattr (obj , item )
138
+ if not (inspect .ismethod (value ) or inspect .isfunction (value )):
139
+ if item and value and not (item .startswith ('__' )) and item not in IGNORED_ATTRS :
140
+ try :
141
+ if isinstance (value , (dict , )):
142
+ imgui .text ('{0} = {1}' .format (item , pformat (value )).strip ())
143
+ else :
144
+ imgui .text ('{0} = {1}' .format (item , value ).strip ())
145
+ except :
146
+ imgui .text ('{0} = {1}' .format (item , '(failed)' ))
147
+ imgui .end ()
0 commit comments