Skip to content

Commit

Permalink
Initial project commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny 'Riketta' Chugaev committed Jul 2, 2018
1 parent cc46ae6 commit bfc26ae
Show file tree
Hide file tree
Showing 17 changed files with 1,313 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Data/Main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"Name": "Main",
"Actions": [
{
"Description": "Fishing",
"Key": "N1",
"Trigger": "Fish",
"GCD": 300,
"CastTime": 22000,
"Interval": 0
},
{
"Description": "Oversized Bobber",
"Key": "N2",
"Trigger": "Interval",
"GCD": 1500,
"CastTime": 1500,
"Interval": 1800
},
{
"Description": "Arcane Lure",
"Key": "N3",
"Trigger": "Interval",
"GCD": 1500,
"CastTime": 0,
"Interval": 600
},
{
"Description": "Ancient Vrykul Ring",
"Key": "N4",
"Trigger": "Interval",
"GCD": 1500,
"CastTime": 2,
"Interval": 1800
},
{
"Description": "Throw Oodelfjisk",
"Key": "N5",
"Trigger": "PostFish",
"GCD": 1500,
"CastTime": 0,
}
]
}
Binary file added Data/default.bmp
Binary file not shown.
Binary file added Data/fishhook.bmp
Binary file not shown.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,100 @@
# Warcraft Fishman
## Description
Simple fishing bot that emulates user input via keyboard and mouse. No injection or other dangerous detectable moves.
It works well and have pretty high accuracy. Uses presets to manage different actions.

## Recomendations
- Game should be launched in windowed fullscreen mode
- Use first person view camera
- Also absence of other selectable objects (NPCs, for example) in background would be good, but not necessary
- Use default GCD = 1500 for each action in your presets (except fishing action, it has 300 ms GCD)
- Use "Oversized Bobber" if you fishing pools, but default bobber have a bit higher accuracy in water without pools
- Bobber should stay in front of pool on its border (closer to you), because little fishes have higher priority for cursor targeting and bot can't detect bobbers positioning.
- Water horizont (absolute, like in ocean) should be around 20-25% from top
- Have at least 50 FPS

## Presets
### Preset configuration:
- **Name**: feel free to use anything, but take into account that this name used as filename when bot saves config.
So don't use special characters such as: ", <, >, |, :, *, ?, \, /

### Action configuration:
**Event types**:
- **None**: actions with such type will be ignored. Don't use it in real presets
- **Fish**: fishing action as it is. Should be only one action of this type per preset
- **Once**: called once before first fishing iteration. Usage examples: equip rod, open bag, zoom-in camera
- **PreFish**: called once before each fishing iterations. Usage examples:
- **PostFish**: called after each successful fishing iteration. Usage examples: throw fish with macro (/cast Oodelfjisk)
- **Interval**: called once in Interval (check this field). First call works same as PreFish. Usage examples: update lures, update Oversized Bobber, etc

**Fields**:
- **Description**: just name or description of action
- **Key**: any key from https://www.pinvoke.net/default.aspx/Enums.VirtualKeys in string representation. For example: N1, N2, Q, E, F3, Numpad1
- **Trigger**: one of events described earlier
- **GCD**: global spell cooldown in milliseconds. Default 1500. Recommended to use default value. Default value for Fish event 300
- **CastTime**: spell cast time in milliseconds. 0 means instant
- **Interval**: inverval in seconds between action calls. Used only with Interval event type.

### Example (Data\Main.json)
~~~~
{
"Name": "Main",
"Actions": [
{
"Description": "Fishing",
"Key": "N1",
"Trigger": "Fish",
"GCD": 300,
"CastTime": 22000,
"Interval": 0
},
{
"Description": "Oversized Bobber",
"Key": "N2",
"Trigger": "Interval",
"GCD": 1500,
"CastTime": 1500,
"Interval": 1800
},
{
"Description": "Arcane Lure",
"Key": "N3",
"Trigger": "Interval",
"GCD": 1500,
"CastTime": 0,
"Interval": 600
},
{
"Description": "Ancient Vrykul Ring",
"Key": "N4",
"Trigger": "Interval",
"GCD": 1500,
"CastTime": 2,
"Interval": 1800
},
{
"Description": "Throw Oodelfjisk",
"Key": "N5",
"Trigger": "PostFish",
"GCD": 1500,
"CastTime": 0,
}
]
}
~~~~

## Dump mode (--dump)
Saves icons once per second.
Capture by yourself fishing icon (fishhook) and default icon (hand), and save it as **fishhook.bmp** and **default.bmp**.

## Command-line interface
* -s, --save: saves default preset into file that can be used as preset reference.
* -p, --preset: path to selected preset. Example: --preset margoss.json
* -d, --dump: runs in dump mode. Use it alone.
* --help: display help screen.
* --version: display version information.

## Author
Developed by Riketta ([email protected] / github.com/riketta).
Based on https://github.com/trenus/Bots.WoW.Fishing by Trenus.
The original project was rewritten from scratch and has only a few original functions.
25 changes: 25 additions & 0 deletions Warcraft Fishman.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2043
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Warcraft Fishman", "Warcraft Fishman\Warcraft Fishman.csproj", "{04749C38-2717-4545-9D95-D51EA0FC9EDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{04749C38-2717-4545-9D95-D51EA0FC9EDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04749C38-2717-4545-9D95-D51EA0FC9EDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04749C38-2717-4545-9D95-D51EA0FC9EDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04749C38-2717-4545-9D95-D51EA0FC9EDF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D9999F14-DF9D-4600-B86F-F68F81362B8C}
EndGlobalSection
EndGlobal
112 changes: 112 additions & 0 deletions Warcraft Fishman/Action.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Fishman
{
class Action
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

public static Action Fish = new Action() { Key = WinApi.VirtualKeys.N1, CastTime = 22 * 1000, Description = "Fishing", Trigger = Event.Fish, GCD = 250 };

public enum Event
{
/// <summary>Default value. Events with such trigger type will be ignored</summary>
None,
/// <summary>Fishing action as it is. Should be only one action of such type per <see cref="Preset"/></summary>
Fish,
/// <summary>Call action once before first fishing iteration. For example: equip rod</summary>
Once,
/// <summary>Call action before fishing iteration</summary>
PreFish,
/// <summary>Call action after fishing iteration. For example: throw rare fish into water macros</summary>
PostFish,
/// <summary>Call action once in <see cref="Action.Interval"/>. For example: update lure</summary>
Interval
}

/// <summary>Description or name of action. Unnecessary field</summary>
public string Description = "";
/// <summary>Use this field for manual mapping action button. Unnecessary field. Default: one of N2-N9 numeric buttons</summary>
[JsonConverter(typeof(StringEnumConverter))]
public WinApi.VirtualKeys Key = WinApi.VirtualKeys.None;
/// <summary>Trigger type that defines how action can be called. Necessary field. Default: <see cref="Event.None"/></summary>
[JsonConverter(typeof(StringEnumConverter))]
public Event Trigger = Event.None;
/// <summary>Global spell cooldown in milliseconds</summary>
public int GCD = 1500;
/// <summary>Cast time in milliseconds. 0 if instant. Don't use it for GCD. Unnecessary field. Default: 0</summary>
public int CastTime = 0;
/// <summary>Event call interval in seconds. Used only with <see cref="Event.Interval"/>. Necessary field</summary>
public int Interval = 0;
/// <summary>Date of last event invoke. Used in <see cref="Event.Interval"/> event type</summary>
[JsonIgnore]
DateTime LastInvoke = DateTime.MinValue;


/// <summary>
/// Do described action
/// </summary>
/// <param name="hWnd">Main WoW Window Handle</param>
public void Invoke(IntPtr hWnd)
{
logger.Info("[{0}] {1}", Trigger, ToString());

switch (Trigger)
{
case Event.Once:
case Event.PreFish:
case Event.PostFish:
case Event.Fish:
PressKey(hWnd);
Sleep();
break;

case Event.Interval:
// if action already should be called or if it should be called while next fishing action - call it now
if (DateTime.Now.AddMilliseconds(Fish.CastTime) > LastInvoke.AddSeconds(Interval))
{
logger.Info("Calling event");
PressKey(hWnd);
Sleep();
}
break;

case Event.None:
default:
throw new Exception("Invalid trigger type to invoke current action");
}

LastInvoke = DateTime.Now;
}

private void Sleep()
{
if (Trigger != Event.Fish)
{
int sleep = GCD + CastTime;
logger.Info("Waiting for {0} milliseconds", sleep);
Thread.Sleep(sleep);
}
}

private void PressKey(IntPtr hWnd)
{
logger.Debug("Pressing key \"{0}\"", Key);
DeviceManager.PressKey(hWnd, Key);
}

public override string ToString()
{
return string.Format("Description: \"{0}\"; GCD: {1}; Trigger: {2}; Key: \"{3}\"; Cast time: {4}; Interval: {5}", Description, GCD / 1000f, Trigger, Key, CastTime / 1000f, Interval);
}
}
}
6 changes: 6 additions & 0 deletions Warcraft Fishman/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
21 changes: 21 additions & 0 deletions Warcraft Fishman/Arguments.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommandLine;

namespace Fishman
{
class Arguments
{
[Option('s', "save", HelpText = "Saves default preset into file")]
public bool IsSave { get; set; }

[Option('p', "preset", HelpText = "Path to selected preset. Example: margoss.json")]
public string Preset { get; set; }

[Option('d', "dump", HelpText = "Runs in dump mode. Use it alone.")]
public bool IsDump { get; set; }
}
}
Loading

0 comments on commit bfc26ae

Please sign in to comment.