From b9be9657c6d2a0fca0bb163f88fcd996cacbf5f2 Mon Sep 17 00:00:00 2001 From: Peter Lomason Date: Sat, 13 Jul 2024 13:51:45 -0400 Subject: [PATCH 1/2] Total stat init order bugfix. Routine to stop if game closes. --- double_chest_farm.ahk | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/double_chest_farm.ahk b/double_chest_farm.ahk index 3eb923f..c1d5dc3 100644 --- a/double_chest_farm.ahk +++ b/double_chest_farm.ahk @@ -46,6 +46,8 @@ SetMouseDelay, -1 #Include %A_ScriptDir%/Gdip_all.ahk pToken := Gdip_Startup() +SetTimer, script_close, 1000 + global DEBUG := false ; Data Initialization @@ -73,6 +75,21 @@ global DEBUG := false } } + ; total stats + global TOTAL_FARM_TIME := 0 + global TOTAL_RUNS := 0 + global TOTAL_CHESTS := 0 + global TOTAL_EXOTICS := 0 + + global CURRENT_FARM_START_TIME := 0 + global CURRENT_RUNS := 0 + global CURRENT_CHESTS := 0 + global CURRENT_EXOTICS := 0 + + ; other global vars + global CHEST_OPENED := false + global EXOTIC_DROP := false + read_ini() ; =================================== ; @@ -144,13 +161,6 @@ global DEBUG := false show_gui() global GUI_VISIBLE := true - ; fun info global vars - ; showing stats - global TOTAL_FARM_TIME := 0 - global TOTAL_RUNS := 0 - global TOTAL_CHESTS := 0 - global TOTAL_EXOTICS := 0 - ; update the total ui stuff with loaded stats total_time_afk_ui.update_content("Time AFK - " format_timestamp(TOTAL_FARM_TIME, true, true, true, false)) total_runs_ui.update_content("Runs - " TOTAL_RUNS) @@ -160,20 +170,6 @@ global DEBUG := false total_average_loop_time_ui.update_content("Average Loop Time - " format_timestamp((TOTAL_FARM_TIME)/TOTAL_RUNS, false, true, true, true, 2)) total_missed_chests_percent_ui.update_content("Percent Chests Missed - " Round(100 - ((TOTAL_CHESTS)/((TOTAL_RUNS)*2))*100, 2) "%") - global CURRENT_FARM_START_TIME := 0 - global CURRENT_RUNS := 0 - global CURRENT_CHESTS := 0 - global CURRENT_EXOTICS := 0 - - ; hidden stats (im too lazy to actually track these rn, but ideally it could be used to identify if one of the chests is more inconsistent than others) - global TOTAL_GROUP_4_CHESTS := [0, 0, 0, 0, 0, 0] ; 16, 17, 18, 19, 20, no chest - global TOTAL_SUCCESSFUL_GROUP_4_CHESTS := [0, 0, 0, 0, 0] - global MESSED_UP_RUNS := 0 - - ; other global vars - global CHEST_OPENED := false - global EXOTIC_DROP := false - update_chest_ui() ; =================================== ; @@ -1507,6 +1503,19 @@ check_tabbed_out: } } +script_close: +{ + IfWinNotExist, Destiny 2 + { + for key, value in key_binds + send, % "{" value " Up}" + ; save all the stats to the afk_chest_stats.ini file + write_ini() + ExitApp + } + return +} + ; Popup Dialog Functions ; =================================== ; build_dropdown_string(options, selected) { From 3903b123ef8d78fcdc53bdfcac4f67d7718be1a0 Mon Sep 17 00:00:00 2001 From: Peter Lomason Date: Sat, 13 Jul 2024 14:24:01 -0400 Subject: [PATCH 2/2] Adjust script_close routine for OnExit addition. --- double_chest_farm.ahk | 2 -- 1 file changed, 2 deletions(-) diff --git a/double_chest_farm.ahk b/double_chest_farm.ahk index c642a50..5ea18b5 100644 --- a/double_chest_farm.ahk +++ b/double_chest_farm.ahk @@ -1510,8 +1510,6 @@ script_close: { for key, value in key_binds send, % "{" value " Up}" - ; save all the stats to the afk_chest_stats.ini file - write_ini() ExitApp } return