Skip to content

Commit

Permalink
Full Auto Implementation + Refactored OCR Scaling + Prep'd for Future…
Browse files Browse the repository at this point in the history
… Optimization
  • Loading branch information
random-facades committed Feb 7, 2020
1 parent 2e762da commit 7632ffd
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 71 deletions.
137 changes: 137 additions & 0 deletions Log Examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
PROCEDURE:
Load Interface/ProjectionsCountdown AND Interface/ProjectionRewardChoice
LOAD Overlay/OverlayBackground
SHOW rewards


EXAMPLES
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
854.794 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
854.796 Script [Info]: Initialize timer true 5
854.796 Sys [Info]: Created /Lotus/Interface/ProjectionRewardChoice.swf

859.797 Script [Info]: Countdown timer expired
859.797 Script [Info]: Relic timer closed
859.797 Script [Info]: Pause countdown done
859.798 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf

859.832 Script [Info]: Relic rewards initialized
859.832 Sys [Info]: Created /Lotus/Interface/Backgrounds/Overlay/OverlayBackground.swf

860.258 Script [Info]: Relic timer closed
860.258 Script [Info]: Got rewards
860.258 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
860.258 Sys [Info]: Found 8 items to load (0ms) [Heap: 1,015,631,776/1,065,877,504 Footprint: 1,655,758,848 Handles: 811]
860.260 Script [Info]: Initialize timer nil 15
860.275 Sys [Info]: Finished load of Flyweight batch [0.00s and 0 frames at 0 ms/frame avg, 0 ms/update peak, 0.00s IO wait], 3 item(s)
860.275 Sys [Info]: Resource load completed (3 root types) in one pass and 0.0s (I/O ~= 0.0%, inherited 4 of 8)
860.275 Sys [Info]: Frames issuing: 0, frames loading: 0, frames retiring: 0
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
520.249 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
520.251 Script [Info]: Initialize timer true 5
520.251 Sys [Info]: Created /Lotus/Interface/ProjectionRewardChoice.swf

525.250 Script [Info]: Countdown timer expired
525.250 Script [Info]: Relic timer closed
525.250 Script [Info]: Pause countdown done
525.251 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf

525.266 Script [Info]: Relic rewards initialized
525.266 Sys [Info]: Created /Lotus/Interface/Backgrounds/Overlay/OverlayBackground.swf

525.419 Script [Info]: _PlayersChanged. 4 member(s) left

525.422 Script [Info]: Relic timer closed
525.422 Script [Info]: Got rewards
525.423 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
525.423 Sys [Info]: Found 13 items to load (0ms) [Heap: 1,014,875,328/1,034,944,512 Footprint: 1,616,355,328 Handles: 811]
525.426 Script [Info]: Initialize timer nil 15
525.434 Sys [Info]: Finished load of Flyweight batch [0.00s and 0 frames at 0 ms/frame avg, 0 ms/update peak, 0.00s IO wait], 3 item(s)
525.434 Sys [Info]: Resource load completed (4 root types) in one pass and 0.0s (I/O ~= 0.0%, inherited 6 of 13)
525.434 Sys [Info]: Frames issuing: 0, frames loading: 0, frames retiring: 0
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
4799.093 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
4799.095 Sys [Info]: Created /Lotus/Interface/ProjectionRewardChoice.swf

4799.123 Script [Info]: Relic rewards initialized
4799.123 Sys [Info]: Created /Lotus/Interface/Backgrounds/Overlay/OverlayBackground.swf

4799.266 Script [Info]: _PlayersChanged. 4 member(s) left
4799.292 Script [Info]: Combat -> idle

4800.793 Script [Info]: Relic timer closed
4800.793 Script [Info]: Got rewards
4800.793 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
4800.793 Sys [Info]: Found 9 items to load (0ms) [Heap: 1,298,610,496/1,327,693,824 Footprint: 2,181,083,136 Handles: 811]
4800.795 Script [Info]: Initialize timer nil 15
4800.798 Sys [Info]: Finished load of Flyweight batch [0.00s and 0 frames at 0 ms/frame avg, 0 ms/update peak, 0.00s IO wait], 2 item(s)
4800.798 Sys [Info]: Resource load completed (3 root types) in one pass and 0.0s (I/O ~= 0.0%, inherited 5 of 9)
4800.798 Sys [Info]: Frames issuing: 0, frames loading: 0, frames retiring: 0
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
6397.222 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
6397.224 Sys [Info]: Created /Lotus/Interface/ProjectionRewardChoice.swf

6397.227 Script [Info]: Relic rewards initialized
6397.227 Sys [Info]: Created /Lotus/Interface/Backgrounds/Overlay/OverlayBackground.swf

6397.393 Script [Info]: _PlayersChanged. 4 member(s) left

6397.583 Script [Info]: Relic timer closed
6397.583 Script [Info]: Got rewards
6397.583 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
6397.583 Sys [Info]: Found 10 items to load (0ms) [Heap: 1,236,719,392/1,327,235,072 Footprint: 2,078,171,136 Handles: 826]
6397.586 Script [Info]: Initialize timer nil 15
6397.615 Sys [Info]: Finished load of Flyweight batch [0.00s and 0 frames at 0 ms/frame avg, 0 ms/update peak, 0.00s IO wait], 2 item(s)
6397.615 Sys [Info]: Resource load completed (4 root types) in one pass and 0.0s (I/O ~= 0.0%, inherited 5 of 10)
6397.615 Sys [Info]: Frames issuing: 0, frames loading: 0, frames retiring: 0
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
8333.783 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
8333.785 Sys [Info]: Created /Lotus/Interface/ProjectionRewardChoice.swf

8333.791 Script [Info]: Relic rewards initialized
8333.792 Sys [Info]: Created /Lotus/Interface/Backgrounds/Overlay/OverlayBackground.swf

8333.877 Script [Info]: Relic timer closed
8333.877 Script [Info]: Got rewards
8333.877 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
8333.877 Sys [Info]: Found 10 items to load (0ms) [Heap: 1,178,607,424/1,319,632,896 Footprint: 2,064,498,688 Handles: 874]
8333.879 Script [Info]: Initialize timer nil 15
8333.892 Sys [Info]: Finished load of Flyweight batch [0.00s and 0 frames at 0 ms/frame avg, 0 ms/update peak, 0.00s IO wait], 2 item(s)
8333.892 Sys [Info]: Resource load completed (3 root types) in one pass and 0.0s (I/O ~= 0.0%, inherited 5 of 10)
8333.892 Sys [Info]: Frames issuing: 0, frames loading: 0, frames retiring: 0
8333.948 Script [Info]: _PlayersChanged. 4 member(s) left
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
12853.282 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
12853.284 Sys [Info]: Created /Lotus/Interface/ProjectionRewardChoice.swf

12853.296 Script [Info]: Relic rewards initialized
12853.296 Sys [Info]: Created /Lotus/Interface/Backgrounds/Overlay/OverlayBackground.swf

12853.450 Script [Info]: _PlayersChanged. 4 member(s) left

12853.764 Script [Info]: Relic timer closed
12853.764 Script [Info]: Got rewards
12853.765 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
12853.765 Sys [Info]: Found 8 items to load (0ms) [Heap: 1,165,989,664/1,318,256,640 Footprint: 2,049,720,320 Handles: 852]
12853.768 Script [Info]: Initialize timer nil 15
12853.795 Sys [Info]: Finished load of Flyweight batch [0.00s and 0 frames at 0 ms/frame avg, 0 ms/update peak, 0.00s IO wait], 3 item(s)
12853.795 Sys [Info]: Resource load completed (4 root types) in one pass and 0.0s (I/O ~= 0.0%, inherited 4 of 8)
12853.795 Sys [Info]: Frames issuing: 0, frames loading: 0, frames retiring: 0
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
13227.665 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
13227.668 Sys [Info]: Created /Lotus/Interface/ProjectionRewardChoice.swf

13227.679 Script [Info]: Relic rewards initialized
13227.679 Sys [Info]: Created /Lotus/Interface/Backgrounds/Overlay/OverlayBackground.swf

13227.850 Script [Info]: _PlayersChanged. 4 member(s) left

13228.014 Script [Info]: Relic timer closed
13228.014 Script [Info]: Got rewards
13228.015 Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf
13228.015 Sys [Info]: Found 9 items to load (0ms) [Heap: 1,114,093,248/1,315,635,200 Footprint: 2,072,850,432 Handles: 835]
13228.018 Script [Info]: Initialize timer nil 15
13228.045 Sys [Info]: Finished load of Flyweight batch [0.00s and 0 frames at 0 ms/frame avg, 0 ms/update peak, 0.00s IO wait], 3 item(s)
13228.045 Sys [Info]: Resource load completed (4 root types) in one pass and 0.0s (I/O ~= 0.0%, inherited 4 of 9)
13228.045 Sys [Info]: Frames issuing: 0, frames loading: 0, frames retiring: 0
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
92 changes: 54 additions & 38 deletions WFInfoCS/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ private void LoadDucats()
if (!marketItems.TryGetValue(elem["item"].ToString(), out string item_name))
{
Main.AddLog("Unknwon market id: " + elem["item"].ToObject<string>());
}
else
} else
{

item_name = item_name.Split('|')[0];
Expand Down Expand Up @@ -275,12 +274,10 @@ public void CheckDucats()
if (rarity.Key.Contains("rare"))
{
marketData[name]["ducats"] = 100;
}
else if (rarity.Key.Contains("un"))
} else if (rarity.Key.Contains("un"))
{
marketData[name]["ducats"] = 45;
}
else
} else
{
marketData[name]["ducats"] = 15;
}
Expand Down Expand Up @@ -315,8 +312,7 @@ private void LoadMarketItem(string item_name, string url)
if (!ducats.TryGetValue("ducats", out JToken temp))
{
ducat = "0";
}
else
} else
{
ducat = temp.ToObject<string>();
}
Expand All @@ -336,8 +332,7 @@ private bool LoadDropData(bool force = false)
if (File.Exists(eqmtDataPath))
{
equipmentData = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(eqmtDataPath));
}
else
} else
{
equipmentData = new JObject();
}
Expand Down Expand Up @@ -437,27 +432,23 @@ private bool LoadDropData(bool force = false)
if (name.Contains("Kubrow"))
{
name = name.Replace("Kubrow ", "");
}
else
} else
{
name = name.Replace("Prime", "Prime Collar");
}
}
else if (!name.Contains("Prime Blueprint") && !name.Contains("Forma"))
} else if (!name.Contains("Prime Blueprint") && !name.Contains("Forma"))
{
name = name.Replace(" Blueprint", "");
}

if (split[1].Contains("2."))
{
relicData[era][relic]["rare1"] = name;
}
else if (split[1].Contains("11"))
} else if (split[1].Contains("11"))
{
relicData[era][relic]["uncommon" + numberOfUncommon.ToString()] = name;
numberOfUncommon += 1;
}
else
} else
{
relicData[era][relic]["common" + numberOfCommon.ToString()] = name;
numberOfCommon += 1;
Expand Down Expand Up @@ -500,12 +491,10 @@ private bool LoadDropData(bool force = false)
if (name.Contains("Harness"))
{
equipmentData[prime]["type"] = "Archwing";
}
else if (name.Contains("Chassis"))
} else if (name.Contains("Chassis"))
{
equipmentData[prime]["type"] = "Warframe";
}
else if (name.Contains("Carapace") || name.Contains("Collar Blueprint"))
} else if (name.Contains("Carapace") || name.Contains("Collar Blueprint"))
{
equipmentData[prime]["type"] = "Companion";
}
Expand Down Expand Up @@ -609,8 +598,7 @@ private void MarkEquipmentUnvaulted(string era, string name)
if (equipmentData.TryGetValue(eqmt, out JToken temp))
{
equipmentData[eqmt]["parts"][str]["vaulted"] = false;
}
else
} else
{
Console.WriteLine("Cannot find: " + eqmt + " in equipmentData");
}
Expand Down Expand Up @@ -645,8 +633,7 @@ private bool LoadEquipmentRequirements(bool force = false)
if (item["tags"].ToObject<List<String>>().Contains("Vaulted"))
{
vaulted = true;
}
else
} else
{
vaulted = false;
}
Expand Down Expand Up @@ -679,8 +666,7 @@ private bool LoadEquipmentRequirements(bool force = false)
{"owned", 0},
{"vaulted", vaulted}
};
}
else
} else
{
requirements[fullName]["count"] = component["itemCount"].ToObject<Int32>();
requirements[fullName]["vaulted"] = vaulted;
Expand All @@ -699,8 +685,7 @@ private bool LoadEquipmentRequirements(bool force = false)
// Need additional copy of item
JToken subItem = requirements[component["name"].ToObject<String>()];
subItem["count"] = subItem["count"].ToObject<Int32>() + 1;
}
else
} else
{
bool subVaulted = searchResult.ToObject<JObject>()["tags"].ToObject<List<String>>().Contains("Vaulted");

Expand All @@ -712,8 +697,7 @@ private bool LoadEquipmentRequirements(bool force = false)
{"owned", 0},
{"vaulted", subVaulted}
};
}
else
} else
{
requirements[component["name"].ToObject<String>()]["count"] = component["itemCount"].ToObject<Int32>();
requirements[component["name"].ToObject<String>()]["vaulted"] = subVaulted;
Expand Down Expand Up @@ -1012,8 +996,7 @@ public int LevenshteinDistanceSecond(string str1, string str2, int limit = -1)
} while (!(maxX && maxY));

num = d[n, m] - 1;
}
else
} else
{
num = n + m;
}
Expand Down Expand Up @@ -1165,13 +1148,46 @@ public string GetRelicName(string string1)
///
///

private Task autoThread;

private void LogChanged(object sender, string line)
{
Console.WriteLine(line);
if (line.Contains("Sys [Info]: Created /Lotus/Interface/ProjectionsCountdown.swf"))
if (autoThread == null || autoThread.IsCompleted)
{
Console.WriteLine("Found relics");
Task.Factory.StartNew(() => OCR.ProcessRewardScreen());
if (autoThread != null)
{
autoThread.Dispose();
autoThread = null;
}

if (line.Contains("Pause countdown done") || line.Contains("Got rewards"))
{
autoThread = Task.Factory.StartNew(() =>
{
var watch = Stopwatch.StartNew();
long stop = watch.ElapsedMilliseconds + 5000;
long wait = watch.ElapsedMilliseconds;
OCR.updateWindow();
int diff;
while (watch.ElapsedMilliseconds < stop)
{
if (watch.ElapsedMilliseconds > wait)
{
wait += Settings.autoDelay;
OCR.GetTheme(out diff);
if (diff < 5)
{
while (watch.ElapsedMilliseconds < wait) ;
OCR.ProcessRewardScreen();
break;
}
}
}
watch.Stop();
});
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions WFInfoCS/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public MainWindow()
Settings.settingsObj["Auto"] = false;
Settings.auto = (bool)Settings.settingsObj.GetValue("Auto");

if (!Settings.settingsObj.TryGetValue("AutoDelay", out _))
Settings.settingsObj["AutoDelay"] = 250L;
Settings.autoDelay = (long)Settings.settingsObj.GetValue("AutoDelay");

if (!Settings.settingsObj.TryGetValue("Scaling", out _))
Settings.settingsObj["Scaling"] = 100.0;
Settings.scaling = Convert.ToInt32(Settings.settingsObj.GetValue("Scaling"));
Expand Down
Loading

0 comments on commit 7632ffd

Please sign in to comment.