Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Designed for general use, by fright01.
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Diagnostics;
- using System.IO;
- using System.Xml.Serialization;
- using D3;
- namespace info
- {
- public class Program
- {
- static bool
- /* Set true to enable -- false to disable */
- /* User Display Options: */
- GoldEarned = true
- , GoldPerHour = true
- , GoldPerRun = true
- , CurrRunTime = true
- , AvgRunTime = true
- , TotalPlayTime = true
- , NumRuns = true
- , NumDeaths = true
- /* End of User Display Options */;
- static Stopwatch timer = new Stopwatch();
- static long startTime = -1;
- static long currTime = -1;
- static long playTime = -1;
- static long runStart = -1;
- static long runEnd = -1;
- static long runTime = -1;
- static double avgRunTime = 0.0;
- static int startGold = -1;
- static int currGold = -1;
- static int earnGold = -1;
- static double goldPerHour = -1.0;
- static double goldPerRun = -1.0;
- static int deaths = 0;
- static int runs = 0;
- static bool alive = false;
- static bool inGame = false;
- public static void Main(string[] args)
- {
- timer.Start();
- Game.Print("KnowItAll has been successfully loaded.");
- Game.OnTickEvent += new TickEventHandler(Game_OnTickEvent);
- Game.OnDrawEvent += new DrawEventHandler(Game_OnDrawEvent);
- }
- private static void Game_OnTickEvent(EventArgs e)
- {
- if (startTime == -1)
- startTime = timer.ElapsedMilliseconds;
- currTime = timer.ElapsedMilliseconds;
- playTime = currTime - startTime;
- if (Ingame() && Me.Gold > 0)
- {
- if (startGold == -1)
- startGold = Me.Gold;
- currGold = Me.Gold;
- earnGold = currGold - startGold;
- goldPerHour = (double)earnGold / ((double)playTime / (double)3600000);
- }
- if (Ingame() && Me.WorldId > 0 && Me.Life == 0 && alive)
- {
- deaths++;
- alive = false;
- }
- else if (Ingame() && Me.WorldId > 0 && Me.Life != 0)
- {
- alive = true;
- }
- if (inGame && !Game.Ingame)
- {
- avgRunTime = (avgRunTime * runs + runTime) / (runs + 1);
- runs++;
- goldPerRun = ((double)earnGold) / runs;
- inGame = false;
- }
- else if (!inGame && Game.Ingame)
- {
- runStart = timer.ElapsedMilliseconds;
- runEnd = timer.ElapsedMilliseconds;
- inGame = true;
- }
- if (inGame)
- runEnd = timer.ElapsedMilliseconds;
- runTime = runEnd - runStart;
- }
- static void Game_OnDrawEvent(EventArgs e)
- {
- List<String> messages = new List<String>();
- if (earnGold > 0)
- {
- if (GoldEarned)
- messages.Add("Gold Earned: " + earnGold.ToString("#,##0.##") + "{icon:gold}");
- if (GoldPerHour)
- messages.Add("Gold per Hour: " + goldPerHour.ToString("#,##0.##") + "{icon:gold}");
- }
- if (earnGold > 0 && runs > 0)
- {
- if (GoldPerRun)
- messages.Add("Gold per Run: " + goldPerRun.ToString("#,##0.##") + "{icon:gold}");
- }
- if (runTime > 0)
- {
- if (CurrRunTime)
- messages.Add("Current Run Time: " + FormatTimeMsec(runTime));
- }
- if (runs > 0)
- {
- if (AvgRunTime)
- messages.Add("Average Run Time: " + FormatTimeMsec(avgRunTime));
- if (NumRuns)
- messages.Add("Runs Completed: " + runs);
- }
- if (TotalPlayTime)
- messages.Add("Total Play Time: " + FormatTimeMsec(playTime));
- if (NumDeaths)
- messages.Add("Died: " + deaths);
- DrawMessages(messages);
- }
- static string FormatTimeMsec(double _timeSpan)
- {
- return String.Format("{0}.{1}:{2}:{3}", TimeSpan.FromMilliseconds(_timeSpan).Days, TimeSpan.FromMilliseconds(_timeSpan).Hours.ToString("D2"), TimeSpan.FromMilliseconds(_timeSpan).Minutes.ToString("D2"), TimeSpan.FromMilliseconds(_timeSpan).Seconds.ToString("D2"));
- }
- static void DrawMessages(List<String> messages)
- {
- float x = 30.0f;
- float y = 5.0f;
- uint fontId = 0x16A;
- uint fontSize = 0x12;
- uint fontColor = 0xFFFFFFFF;
- foreach (String str in messages)
- {
- Draw.DrawText(x, y, fontId, fontSize, fontColor, str);
- y += fontSize;
- }
- }
- static bool Ingame()
- {
- return Game.Ingame && Me.LevelArea.ToString() != "Axe_Bad_Data";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement