forked from apoguita/Py4GW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountData.py
More file actions
489 lines (409 loc) · 23 KB
/
AccountData.py
File metadata and controls
489 lines (409 loc) · 23 KB
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
from turtle import title
from PyParty import Hero
from Py4GWCoreLib import ImGui, ColorPalette, TITLE_TIERS, TITLE_NAME, GLOBAL_CACHE, TITLE_CATEGORIES
from Py4GWCoreLib import ProfessionShort, Campaign, Routines, Utils
import PyImGui
import PyPlayer
import PyAgent
import PySkillbar
from PyPlayer import PyTitle
from typing import Optional, Dict, List, Tuple
import account_data_src
from account_data_src.rank_data_src import RankData
from account_data_src.faction_data_src import FactionData
from account_data_src.experience_data_src import ExperienceData
from account_data_src.title_data_src import TitleData
from account_data_src.quest_data_src import QuestData
MODULE_NAME = "Account Info"
class AgentData:
class GeneralData:
def __init__(self, agent_id:int):
self.agent_id: int = agent_id
self.owner_id: int = 0
self.hero_id: int = 0 #need to implement
self.login_number: int = 0
self.player_number: int = 0
self.name: str = ""
self.name_requested: bool = False
self.professions: Tuple[int, int] = (0,0)
self.level: int = 0
self.energy_data: tuple[float, float, int] = (0.0, 0.0, 0) #energy, max_energy, energy_pips
self.hp_data: tuple[float, float, float] = (0.0, 0.0, 0.0) #hp, max_hp, hp_regen
self.dager_status: int = 0
self.weapon_type: int = 0
self.attributes: list[PyAgent.AttributeClass] = []
self.model_id: int = 0
self.coords: Tuple[float, float, float] = (0.0, 0.0, 0.0)
self.zplane: int = 0
self.rotation_angle: float = 0.0
self.velocity_vector: Tuple[float, float] = (0.0, 0.0)
self.can_be_viewed_in_party_window: bool = False
self.overcast: float = 0.0
def update(self):
self.owner_id = GLOBAL_CACHE.Agent.GetOwnerID(self.agent_id)
self.login_number = GLOBAL_CACHE.Agent.GetLoginNumber(self.agent_id)
self.player_number = GLOBAL_CACHE.Agent.GetPlayerNumber(self.agent_id)
if not self.name_requested:
GLOBAL_CACHE.Agent.RequestName(self.agent_id)
self.name_requested = True
if self.name_requested and self.name == "":
if GLOBAL_CACHE.Agent.IsNameReady(self.agent_id):
self.name = GLOBAL_CACHE.Agent.GetName(self.agent_id)
self.professions = GLOBAL_CACHE.Agent.GetProfessionIDs(self.agent_id)
self.level = GLOBAL_CACHE.Agent.GetLevel(self.agent_id)
energy = GLOBAL_CACHE.Agent.GetEnergy(self.agent_id)
max_energy = GLOBAL_CACHE.Agent.GetMaxEnergy(self.agent_id)
energy_pips = GLOBAL_CACHE.Agent.GetEnergyPips(self.agent_id)
self.energy_data = (energy, max_energy, energy_pips)
hp = GLOBAL_CACHE.Agent.GetHealth(self.agent_id)
max_hp = GLOBAL_CACHE.Agent.GetMaxHealth(self.agent_id)
hp_regen = GLOBAL_CACHE.Agent.GetHealthRegen(self.agent_id)
self.hp_data = (hp, max_hp, hp_regen)
self.dager_status = GLOBAL_CACHE.Agent.GetDaggerStatus(self.agent_id)
self.weapon_type = GLOBAL_CACHE.Agent.GetWeaponType(self.agent_id)[0]
self.attributes = GLOBAL_CACHE.Agent.GetAttributes(self.agent_id)
self.model_id = GLOBAL_CACHE.Agent.GetModelID(self.agent_id)
x,y,z = GLOBAL_CACHE.Agent.GetXYZ(self.agent_id)
self.coords = (x,y,z)
self.zplane = GLOBAL_CACHE.Agent.GetZPlane(self.agent_id)
self.rotation_angle = GLOBAL_CACHE.Agent.GetRotationAngle(self.agent_id)
self.velocity_vector = GLOBAL_CACHE.Agent.GetVelocityXY(self.agent_id)
self.can_be_viewed_in_party_window = GLOBAL_CACHE.Agent.CanBeViewedInPartyWindow(self.agent_id)
self.overcast = GLOBAL_CACHE.Agent.GetOvercast(self.agent_id)
class Flags:
def __init__(self):
self.is_moving: bool = False
self.is_knocked_down: bool = False
self.is_bleeding: bool = False
self.is_crippled: bool = False
self.is_deep_wounded: bool = False
self.is_poisoned: bool = False
self.is_conditioned: bool = False
self.is_enchanted: bool = False
self.is_hexed: bool = False
self.is_degen_hexed: bool = False
self.is_dead: bool = False
self.is_weapon_spelled: bool = False
self.is_in_combat_stance: bool = False
self.is_aggressive: bool = False
self.is_attacking: bool = False
self.is_casting: bool = False
self.is_idle: bool = False
self.is_martial: bool = False
self.is_caster: bool = False
self.is_melee: bool = False
self.is_ranged: bool = False
def update(self, agent_id:int):
self.is_moving = GLOBAL_CACHE.Agent.IsMoving(agent_id)
self.is_knocked_down = GLOBAL_CACHE.Agent.IsKnockedDown(agent_id)
self.is_bleeding = GLOBAL_CACHE.Agent.IsBleeding(agent_id)
self.is_crippled = GLOBAL_CACHE.Agent.IsCrippled(agent_id)
self.is_deep_wounded = GLOBAL_CACHE.Agent.IsDeepWounded(agent_id)
self.is_poisoned = GLOBAL_CACHE.Agent.IsPoisoned(agent_id)
self.is_conditioned = GLOBAL_CACHE.Agent.IsConditioned(agent_id)
self.is_enchanted = GLOBAL_CACHE.Agent.IsEnchanted(agent_id)
self.is_hexed = GLOBAL_CACHE.Agent.IsHexed(agent_id)
self.is_degen_hexed = GLOBAL_CACHE.Agent.IsDegenHexed(agent_id)
self.is_dead = GLOBAL_CACHE.Agent.IsDead(agent_id)
self.is_weapon_spelled = GLOBAL_CACHE.Agent.IsWeaponSpelled(agent_id)
self.is_in_combat_stance = GLOBAL_CACHE.Agent.IsInCombatStance(agent_id)
self.is_aggressive = GLOBAL_CACHE.Agent.IsAggressive(agent_id)
self.is_attacking = GLOBAL_CACHE.Agent.IsAttacking(agent_id)
self.is_casting = GLOBAL_CACHE.Agent.IsCasting(agent_id)
self.is_idle = GLOBAL_CACHE.Agent.IsIdle(agent_id)
self.is_martial = GLOBAL_CACHE.Agent.IsMartial(agent_id)
self.is_caster = GLOBAL_CACHE.Agent.IsCaster(agent_id)
self.is_melee = GLOBAL_CACHE.Agent.IsMelee(agent_id)
self.is_ranged = GLOBAL_CACHE.Agent.IsRanged(agent_id)
class SkillbarData:
def __init__(self):
self.agent_id: int = 0
self.disabled: int = 0
self.casting: int = 0
self.casting_skill_id: int = 0
self.skills: dict[int,tuple[int, PySkillbar.SkillbarSkill]] = {} #slot, (skill_id, skill_data)
def update(self):
self.agent_id = GLOBAL_CACHE.SkillBar.GetAgentID()
self.disabled = GLOBAL_CACHE.SkillBar.GetDisabled()
self.casting = GLOBAL_CACHE.SkillBar.GetCasting()
self.casting_skill_id = GLOBAL_CACHE.Agent.GetCastingSkill(self.agent_id)
for i in range(1,9):
skill_data = GLOBAL_CACHE.SkillBar.GetSkillBySlot(i)
if skill_data:
self.skills[i] = (skill_data.id.id, skill_data)
def __init__(self):
self.agent_id: int = GLOBAL_CACHE.Player.GetAgentID()
self.general_data = AgentData.GeneralData(self.agent_id)
self.flags = AgentData.Flags()
self.skillbar_data = AgentData.SkillbarData()
class PlayerData:
def __init__(self):
self.target_id: int = 0
self.observing_id: int = 0
self.player_uuid: Tuple[int, int, int, int] = (0,0,0,0)
self.missions_completed: List[int] = []
self.missions_bonus: List[int] = []
self.missions_completed_hm: List[int] = []
self.missions_bonus_hm: List[int] = []
self.controlled_minions: List[Tuple[int, int]] = []
self.learnable_character_skills: List[int] = []
self.unlocked_character_skills: List[int] = []
self.show_details: dict[str, bool] = {}
def update(self):
self.target_id = GLOBAL_CACHE.Player.GetTargetID()
self.observing_id = GLOBAL_CACHE.Player.GetObservingID()
self.player_uuid = GLOBAL_CACHE.Player.GetPlayerUUID()
self.missions_completed = GLOBAL_CACHE.Player.GetMissionsCompleted()
self.missions_bonus = GLOBAL_CACHE.Player.GetMissionsBonusCompleted()
self.missions_completed_hm = GLOBAL_CACHE.Player.GetMissionsCompletedHM()
self.missions_bonus_hm = GLOBAL_CACHE.Player.GetMissionsBonusCompletedHM()
self.controlled_minions = GLOBAL_CACHE.Player.GetControlledMinions()
self.learnable_character_skills = GLOBAL_CACHE.Player.GetLearnableCharacterSkills()
self.unlocked_character_skills = GLOBAL_CACHE.Player.GetUnlockedCharacterSkills()
def draw_content(self):
PyImGui.text(f"Target ID: {self.target_id}")
PyImGui.text(f"Observing ID: {self.observing_id}")
PyImGui.text(f"Player UUID:")
PyImGui.same_line(0,-1)
for i, uuid_part in enumerate(self.player_uuid):
PyImGui.text(f"{uuid_part}")
if i < len(self.player_uuid) - 1:
PyImGui.same_line(0,-1)
if PyImGui.collapsing_header("Missions Completed", PyImGui.TreeNodeFlags.NoFlag):
self.show_details["missions_not_completed"] = PyImGui.checkbox("Show Not Completed Missions", self.show_details.get("missions_not_completed", False))
expanded_flags = [] # list of (map_id, completed)
bits_per_entry = 32
for i, mission_status in enumerate(self.missions_completed):
base_map_id = i * bits_per_entry
# explode bits
for bit in range(bits_per_entry):
map_id = base_map_id + bit
completed = (mission_status >> bit) & 1
expanded_flags.append((map_id, completed))
map_status = "Completed" if completed else "Not Completed"
# show depending on filter
if self.show_details["missions_not_completed"] or completed:
status_txt = "Completed" if completed else "Not Completed"
PyImGui.text_colored(
f"MapID {map_id} - {GLOBAL_CACHE.Map.GetMapName(map_id)} - {status_txt}",
Utils.TrueFalseColor(bool(completed))
)
if PyImGui.button("copy to clipboard"):
# flatten only completed map IDs for convenience
completed_ids = [mid for mid, flag in expanded_flags if flag]
PyImGui.set_clipboard_text(", ".join(map(str, completed_ids)))
if PyImGui.collapsing_header("Missions Bonus Completed", PyImGui.TreeNodeFlags.NoFlag):
self.show_details["missions_bonus_not_completed"] = PyImGui.checkbox(
"Show Not Completed Bonus", self.show_details.get("missions_bonus_not_completed", False)
)
expanded_flags = []
bits_per_entry = 32
for i, mission_status in enumerate(self.missions_bonus):
base_map_id = i * bits_per_entry
for bit in range(bits_per_entry):
map_id = base_map_id + bit
completed = (mission_status >> bit) & 1
expanded_flags.append((map_id, completed))
map_status = "Completed" if completed else "Not Completed"
if self.show_details["missions_bonus_not_completed"] or completed:
status_txt = "Completed" if completed else "Not Completed"
PyImGui.text_colored(
f"MapID {map_id} - {GLOBAL_CACHE.Map.GetMapName(map_id)} - {status_txt}",
Utils.TrueFalseColor(bool(completed))
)
if PyImGui.button("copy to clipboard##missions_bonus"):
completed_ids = [mid for mid, flag in expanded_flags if flag]
PyImGui.set_clipboard_text(", ".join(map(str, completed_ids)))
if PyImGui.collapsing_header("Missions Completed HM", PyImGui.TreeNodeFlags.NoFlag):
self.show_details["missions_hm_not_completed"] = PyImGui.checkbox(
"Show Not Completed Missions (HM)", self.show_details.get("missions_hm_not_completed", False)
)
expanded_flags = []
bits_per_entry = 32
for i, mission_status in enumerate(self.missions_completed_hm):
base_map_id = i * bits_per_entry
for bit in range(bits_per_entry):
map_id = base_map_id + bit
completed = (mission_status >> bit) & 1
expanded_flags.append((map_id, completed))
map_status = "Completed" if completed else "Not Completed"
if self.show_details["missions_hm_not_completed"] or completed:
status_txt = "Completed" if completed else "Not Completed"
PyImGui.text_colored(
f"MapID {map_id} - {GLOBAL_CACHE.Map.GetMapName(map_id)} - {status_txt}",
Utils.TrueFalseColor(bool(completed))
)
if PyImGui.button("copy to clipboard##missions_completed_hm"):
completed_ids = [mid for mid, flag in expanded_flags if flag]
PyImGui.set_clipboard_text(", ".join(map(str, completed_ids)))
if PyImGui.collapsing_header("Missions Bonus Completed HM", PyImGui.TreeNodeFlags.NoFlag):
self.show_details["missions_bonus_hm_not_completed"] = PyImGui.checkbox("Show Not Completed Bonus (HM)", self.show_details.get("missions_bonus_hm_not_completed", False))
expanded_flags = []
bits_per_entry = 32
for i, mission_status in enumerate(self.missions_bonus_hm):
base_map_id = i * bits_per_entry
for bit in range(bits_per_entry):
map_id = base_map_id + bit
completed = (mission_status >> bit) & 1
expanded_flags.append((map_id, completed))
if self.show_details["missions_bonus_hm_not_completed"] or completed:
status_txt = "Completed" if completed else "Not Completed"
PyImGui.text_colored(
f"MapID {map_id} - {GLOBAL_CACHE.Map.GetMapName(map_id)} - {status_txt}",
Utils.TrueFalseColor(bool(completed))
)
if PyImGui.button("copy to clipboard##missions_bonus_hm"):
completed_ids = [mid for mid, flag in expanded_flags if flag]
PyImGui.set_clipboard_text(", ".join(map(str, completed_ids)))
if PyImGui.collapsing_header("Controlled Minions", PyImGui.TreeNodeFlags.NoFlag):
for agent_id, minion_count in self.controlled_minions:
PyImGui.text(f"Agent ID: {agent_id} - Minion Count: {minion_count}")
if PyImGui.collapsing_header("Learnable Character Skills", PyImGui.TreeNodeFlags.NoFlag):
for skill_id in self.learnable_character_skills:
PyImGui.text(f"Skill ID: {skill_id}")
if PyImGui.collapsing_header("Unlocked Character Skills", PyImGui.TreeNodeFlags.NoFlag):
self.show_details["show_locked_skills"] = PyImGui.checkbox(
"Show Locked Skills",
self.show_details.get("show_locked_skills", False)
)
bits_per_entry = 32
expanded_flags = []
show_locked = self.show_details["show_locked_skills"]
for i, skill_mask in enumerate(self.unlocked_character_skills):
base_skill_id = i * bits_per_entry
for bit in range(bits_per_entry):
skill_id = base_skill_id + bit
unlocked = (skill_mask >> bit) & 1
expanded_flags.append((skill_id, unlocked))
if show_locked or unlocked:
PyImGui.text_colored(
f"Skill ID {skill_id} - {GLOBAL_CACHE.Skill.GetName(skill_id)}",
Utils.TrueFalseColor(bool(unlocked))
)
if PyImGui.button("copy to clipboard##unlocked_skills"):
unlocked_ids = [sid for sid, flag in expanded_flags if flag]
PyImGui.set_clipboard_text(", ".join(map(str, unlocked_ids)))
class AccountInfo:
#region AccountData
class AccountData:
def __init__(self, account_name: str ="", account_email: str ="", available_characters: List[PyPlayer.LoginCharacterInfo] = []):
self.account_name: str = account_name
self.account_email: str = account_email
self.available_characters: List[PyPlayer.LoginCharacterInfo] = available_characters
def draw_content(self):
PyImGui.text(f"Account Name: {self.account_name}")
PyImGui.text(f"Account Email: {self.account_email}")
PyImGui.text("Available Characters:")
if PyImGui.begin_table("##char_table", 6, PyImGui.TableFlags.Borders | PyImGui.TableFlags.RowBg):
# Headers
table_flags = PyImGui.TableFlags.NoFlag
PyImGui.table_setup_column("Lvl",table_flags, init_width_or_weight=60.0)
PyImGui.table_setup_column("Name",table_flags, init_width_or_weight=300.0)
PyImGui.table_setup_column("Map",table_flags, init_width_or_weight=300.0)
PyImGui.table_setup_column("Profs",table_flags, init_width_or_weight=115.0)
PyImGui.table_setup_column("Campaign",table_flags, init_width_or_weight=230.0)
PyImGui.table_setup_column("Type",table_flags, init_width_or_weight=60.0)
PyImGui.table_headers_row()
# Rows
for char in self.available_characters:
PyImGui.table_next_row()
# Level
PyImGui.table_set_column_index(0)
PyImGui.text(str(char.level))
# Name
PyImGui.table_set_column_index(1)
PyImGui.text(char.player_name)
# Map
PyImGui.table_set_column_index(2)
PyImGui.text(GLOBAL_CACHE.Map.GetMapName(char.map_id))
# Professions
PyImGui.table_set_column_index(3)
primary = ProfessionShort(char.primary).name
secondary = ProfessionShort(char.secondary).name
PyImGui.text(f"{primary}/{secondary}")
# Campaign
PyImGui.table_set_column_index(4)
PyImGui.text(Campaign(char.campaign).name)
# Type
PyImGui.table_set_column_index(5)
PyImGui.text("PvP" if char.is_pvp else "PvE")
PyImGui.end_table()
#region AccountInfo
def __init__(self):
self.account_data = AccountInfo.AccountData()
self.rank_data = RankData()
self.faction_data = FactionData()
self.experience = ExperienceData()
self.title_data = TitleData()
self.fetch_and_handle_quests = False
self.quest_data = QuestData()
self.player_data = PlayerData()
def update(self):
account_name = GLOBAL_CACHE.Player.GetAccountName()
account_email = GLOBAL_CACHE.Player.GetAccountEmail()
available_characters = GLOBAL_CACHE.Player.GetLoginCharacters()
self.account_data = AccountInfo.AccountData(account_name, account_email, available_characters)
self.rank_data.update()
self.faction_data.update()
self.experience.update()
self.title_data.update()
if self.fetch_and_handle_quests:
self.quest_data.update()
self.player_data.update()
def draw_content(self, window_width: float, window_height: float):
if PyImGui.begin_tab_bar("AccountInfoTabs"):
if PyImGui.begin_tab_item("Faction"):
if PyImGui.begin_child("FactionsChild", (0, 0), False, PyImGui.WindowFlags.NoFlag):
if PyImGui.collapsing_header("Rank Data", PyImGui.TreeNodeFlags.NoFlag):
self.rank_data.draw_content()
self.faction_data.draw_content()
PyImGui.end_child()
PyImGui.end_tab_item()
if PyImGui.begin_tab_item("Titles"):
if PyImGui.begin_child("TitlesChild", (0, 0), False, PyImGui.WindowFlags.NoFlag):
self.title_data.draw_content()
PyImGui.end_child()
PyImGui.end_tab_item()
if PyImGui.begin_tab_item("Account"):
if PyImGui.begin_child("AccountChild", (0, 0), False, PyImGui.WindowFlags.NoFlag):
self.account_data.draw_content()
PyImGui.end_child()
PyImGui.end_tab_item()
if PyImGui.begin_tab_item("Quest Log"):
if PyImGui.begin_child("QuestLogChild", (0, 0), False, PyImGui.WindowFlags.NoFlag):
self.fetch_and_handle_quests = PyImGui.checkbox("Fetch and Handle Quests", self.fetch_and_handle_quests)
if self.fetch_and_handle_quests:
self.quest_data.draw_content(window_width, window_height)
PyImGui.end_child()
PyImGui.end_tab_item()
if PyImGui.begin_tab_item("Player Data"):
if PyImGui.begin_child("PlayerDataChild", (0, 0), False, PyImGui.WindowFlags.NoFlag):
self.experience.draw_content()
self.player_data.draw_content()
PyImGui.end_child()
PyImGui.end_tab_item()
PyImGui.end_tab_bar()
#PLAYER agent
#morale
#party morale = []
def draw_window(account_info: AccountInfo):
MIN_WIDTH = 400
MIN_HEIGHT = 600
if PyImGui.begin(MODULE_NAME):
window_size = PyImGui.get_window_size()
new_width = max(window_size[0], MIN_WIDTH)
new_height = max(window_size[1], MIN_HEIGHT)
# only update size if it changed
if new_width != window_size[0] or new_height != window_size[1]:
PyImGui.set_window_size(new_width, new_height, PyImGui.ImGuiCond.Always)
# child region adjusts automatically
if PyImGui.begin_child("AccountInfoChild", (new_width - 20, 0), True, PyImGui.WindowFlags.NoFlag):
account_info.draw_content(new_width, new_height)
PyImGui.end_child()
PyImGui.end()
account_info = AccountInfo()
def main():
account_info.update()
draw_window(account_info)
if __name__ == "__main__":
main()