-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b09bb6c
commit 4bfeb05
Showing
80 changed files
with
7,132 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
.vs | ||
[Pp]ackages | ||
[Oo]bj | ||
[Bb]in | ||
*.user | ||
.git | ||
.gita | ||
!Binaries/*.zip | ||
Binaries | ||
*.lnk | ||
|
||
*.db | ||
League-of-Legends-Bot/Binaries/LeagueAI.zip | ||
League-of-Legends-Bot/ServiceLeagueAI/Data/LeagueAI.Libraries.Embed.dll | ||
Data | ||
ServiceLeagueAI.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
using LeagueAI.Libraries.Entities; | ||
using LeagueAI.Libraries.Game; | ||
using LeagueAI.Libraries.Helper; | ||
using LeagueAI.Libraries.Interfaces; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Text; | ||
using System.Threading; | ||
|
||
namespace LeagueAI.Libraries.Api | ||
{ | ||
public sealed class ActivePlayerApi : BaseApiMember<GameApi> | ||
{ | ||
private readonly Dictionary<string, string> upgradeSkillMap; | ||
public ActivePlayerApi(GameApi api) : base(api) | ||
{ | ||
// Khởi tạo thứ tự cộng kỹ năng | ||
if (File.Exists(DEFINE.ConfigPath)) | ||
{ | ||
var content = ""; | ||
using (FileStream fileStream = new FileStream(DEFINE.ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) | ||
{ | ||
using (StreamReader streamReader = new StreamReader(fileStream, Encoding.Default)) | ||
{ | ||
content = streamReader.ReadToEnd(); | ||
} | ||
} | ||
JObject jobj = JObject.Parse(content); | ||
Dictionary<string, string> dictation = jobj?["SettingGame"]?["upgrandSkillMap"]?.ToObject<Dictionary<string, string>>(); | ||
upgradeSkillMap = dictation; | ||
return; | ||
} | ||
|
||
upgradeSkillMap = new Dictionary<string, string>() | ||
{ | ||
{ "1", "Q" }, | ||
{ "2", "W" }, | ||
{ "3", "E" }, | ||
{ "4", "Q" }, | ||
{ "5", "W" }, | ||
{ "6", "R" }, | ||
{ "7", "Q" }, | ||
{ "8", "W" }, | ||
{ "9", "Q" }, | ||
{ "10", "W" }, | ||
{ "11", "R" }, | ||
{ "12", "Q" }, | ||
{ "13", "W" }, | ||
{ "14", "E" }, | ||
{ "15", "E" }, | ||
{ "16", "R" }, | ||
{ "17", "E" }, | ||
{ "18", "E" }, | ||
{ "19", "Q" }, | ||
{ "20", "W" }, | ||
{ "21", "E" }, | ||
{ "22", "R" }, | ||
}; | ||
} | ||
|
||
public IEntity GetNearEnemyPosition() | ||
{ | ||
var handle = Program.GameHandle; | ||
if (handle == null || handle == IntPtr.Zero) return null; | ||
|
||
// Lấy toạ độ của kẻ địch đang tấn công | ||
Point? target = ScreenHelper.GetColorPosition(DEFINE.ColorEnemyFocus.ToColorRGB().Value, handle); | ||
if (target != null) return new Minion(new Point(target.Value.X, target.Value.Y)); | ||
|
||
// Lấy toạ độ của kẻ địch trên màn hinh | ||
target = ScreenHelper.GetColorPosition(DEFINE.ColorEnemyLevelBox.ToColorRGB().Value, handle, deviantX: 30, deviantY: 30); | ||
if (target != null) return new Minion(new Point(target.Value.X, target.Value.Y)); | ||
|
||
// Lấy toạ độ của creep địch | ||
target = ScreenHelper.GetColorPosition(DEFINE.ColorEnemyCreep.ToColorRGB().Value, handle); | ||
if (target != null) return new Minion(new Point(target.Value.X, target.Value.Y)); | ||
|
||
return null; | ||
} | ||
|
||
public void TryCastSpellOnTarget( | ||
string skill, | ||
int delay | ||
) | ||
{ | ||
// Tung kỹ năng vào vị trí kẻ địch gần nhất | ||
IEntity target = GetNearEnemyPosition(); | ||
|
||
if (target == null) return; | ||
|
||
skill = skill.ToUpper(); | ||
InputHelper.MoveMouse(target.Position.X, target.Position.Y); | ||
InputHelper.PressKey(skill, delay); | ||
Thread.Sleep(BotApi.IDLE_DELAY); | ||
} | ||
|
||
public void TryNormalAttack(char keyAttack = 'a', int delay = 100) | ||
{ | ||
IEntity target = GetNearEnemyPosition(); | ||
|
||
if (target == null) return; | ||
|
||
InputHelper.PressKey(keyAttack.ToString(), delay); | ||
InputHelper.MoveMouse(target.Position.X, target.Position.Y); | ||
Thread.Sleep(BotApi.IDLE_DELAY); | ||
} | ||
|
||
public void UpgradeSpell( | ||
string skill | ||
) | ||
{ | ||
// Lên cấp skill bằng phím tắt ctrl + skill | ||
InputHelper.KeyDown("ControlKey", 50); | ||
InputHelper.KeyDown(skill, 50); | ||
Thread.Sleep(BotApi.IDLE_DELAY); | ||
InputHelper.KeyUp(skill, 50); | ||
InputHelper.KeyUp("ControlKey", 50); | ||
Thread.Sleep(BotApi.IDLE_DELAY); | ||
} | ||
|
||
public void UpgradeSpellOnLevelUp(double level = -1) | ||
{ | ||
if (level <= 0) | ||
return; | ||
|
||
if (upgradeSkillMap.TryGetValue(level.ToString(), out string skill)) | ||
UpgradeSpell(skill); | ||
} | ||
|
||
public double GetHealthPercent() | ||
{ | ||
// Lấy ra % máu hiện tại. | ||
ChampionStat stats = GameLCU.GetStats(); | ||
if (stats?.currentHealth != null | ||
&& stats?.maxHealth != null) | ||
{ | ||
return (stats?.currentHealth ?? 10) / (stats?.maxHealth ?? 100); | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
public double GetManaPercent() | ||
{ | ||
// Lấy ra % mana hiện tại. | ||
ChampionStat stats = GameLCU.GetStats(); | ||
if (stats?.resourceValue != null | ||
&& stats?.resourceMax != null) | ||
{ | ||
return (stats?.resourceValue ?? 10) / (stats?.resourceMax ?? 100); | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
public double GetLevel() => GameLCU.GetPlayerLevel(); | ||
|
||
public double GetGolds() => GameLCU.GetPlayerGolds(); | ||
|
||
public List<Item> GetItemBuyed(string summonerName) => GameLCU.GetPlayerItems(summonerName); | ||
|
||
public string GetName() => GameLCU.GetPlayerName(); | ||
|
||
public bool IsDead() => GameLCU.IsPlayerDead(); | ||
|
||
public void Recall(int delay) | ||
{ | ||
InputHelper.PressKey("B", 50); | ||
Thread.Sleep(delay); | ||
} | ||
|
||
public void TryCastSpellOnTarget(char skill, int delay) => TryCastSpellOnTarget(skill.ToString(), delay); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using LeagueAI.Libraries.Interfaces; | ||
|
||
namespace LeagueAI.Libraries.Api | ||
{ | ||
public abstract class BaseApiMember<T> where T : IApi | ||
{ | ||
protected T Api { get; private set; } | ||
|
||
|
||
public BaseApiMember(T api) | ||
{ | ||
Api = api; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using LeagueAI.Libraries.Enums; | ||
using LeagueAI.Libraries.Helper; | ||
using LeagueAI.Libraries.Interfaces; | ||
using System.Threading; | ||
|
||
namespace LeagueAI.Libraries.Api | ||
{ | ||
public sealed class BotApi : IApi | ||
{ | ||
public static int IDLE_DELAY { get; set; } = 150; | ||
|
||
public void Log(object message) | ||
{ | ||
Logger.WriteLine(message); | ||
} | ||
public void Warn(object message) | ||
{ | ||
Logger.WriteLine(message, EMessageState.WARNING); | ||
} | ||
public void Error(object message) | ||
{ | ||
Logger.WriteLine(message, EMessageState.ERROR); | ||
} | ||
public void Wait(int ms) | ||
{ | ||
Thread.Sleep(ms); | ||
} | ||
public void ExecutePattern(string name) | ||
{ | ||
PatternsUlti.Execute(name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using InputManager; | ||
using LeagueAI.Libraries.Helper; | ||
using System.Drawing; | ||
using System.Threading; | ||
|
||
namespace LeagueAI.Libraries.Api | ||
{ | ||
public sealed class CameraApi : BaseApiMember<GameApi> | ||
{ | ||
public bool isLocked { get; set; } | ||
public CameraApi(GameApi api) : base(api) | ||
{ | ||
isLocked = false; | ||
} | ||
|
||
public void Toggle() | ||
{ | ||
// Khoá/mở camera | ||
string key = Configuration.Instance.SettingGame?.hotKeys?.evtCameraLockToggle?.ToString() ?? "y"; | ||
key = key?.Replace("[", "")?.Replace("]", "")?.ToUpper(); | ||
InputHelper.PressKey(key, 50); | ||
isLocked = !isLocked; | ||
} | ||
|
||
public void LockAlly( | ||
int allyIndice | ||
) | ||
{ | ||
// Khoá camera vào đồng minh | ||
string key = "F" + allyIndice; | ||
InputHelper.KeyUp(key, 50); | ||
InputHelper.KeyDown(key, 50); | ||
Thread.Sleep(BotApi.IDLE_DELAY); | ||
} | ||
|
||
public void PingComing() | ||
{ | ||
// Ping đang tới | ||
var startPoint = new Point(DEFINE.TargetClick[0], DEFINE.TargetClick[1]); | ||
var endPoint = new Point(DEFINE.TargetClick[0] + 100, DEFINE.TargetClick[1]); | ||
|
||
Mouse.Move(startPoint.X, startPoint.Y); | ||
InputHelper.PressKey("V", 100); | ||
Mouse.ButtonDown(Mouse.MouseKeys.Left); | ||
Thread.Sleep(200); | ||
Mouse.Move(endPoint.X, endPoint.Y); | ||
Thread.Sleep(100); | ||
Mouse.ButtonUp(Mouse.MouseKeys.Left); | ||
Thread.Sleep(BotApi.IDLE_DELAY); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using LeagueAI.Libraries.Helper; | ||
using System.Drawing; | ||
using System.Threading; | ||
using System.Windows.Forms; | ||
|
||
namespace LeagueAI.Libraries.Api | ||
{ | ||
public sealed class ChatApi : BaseApiMember<GameApi> | ||
{ | ||
public ChatApi(GameApi api) : base(api) { } | ||
|
||
public void TalkInGame(string message, int delayPressKey = 40, int delay = 200) | ||
{ | ||
Thread.Sleep(300); | ||
|
||
InputHelper.PressKey(Keys.Enter, delay); | ||
InputHelper.InputWords(message, delayPressKey, delay); | ||
InputHelper.PressKey(Keys.Enter, delay); | ||
} | ||
|
||
public void TalkInClient(string message, int delayPressKey = 20, int delay = 200) | ||
{ | ||
Thread.Sleep(1500); | ||
|
||
var locationSafe = DEFINE.ColorBoxChatBanPick; | ||
var color = Color.FromArgb(locationSafe[0], locationSafe[1], locationSafe[2]); | ||
|
||
var handle = Program.ClientHandle; | ||
if (handle == null || handle == System.IntPtr.Zero) return; | ||
|
||
Point? target = ScreenHelper.GetColorPosition(color, handle, deviantX: 0, deviantY: 0); | ||
if (target == null) return; | ||
|
||
InputHelper.LeftClick(target.Value.X, target.Value.Y, delay); | ||
InputHelper.InputWords(message, delayPressKey, delay); | ||
InputHelper.PressKey(Keys.Enter, delay); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using LeagueAI.Libraries.Entities; | ||
using LeagueAI.Libraries.Enums; | ||
using LeagueAI.Libraries.Game; | ||
using LeagueAI.Libraries.Helper; | ||
using LeagueAI.Libraries.Interfaces; | ||
using System.Threading; | ||
|
||
namespace LeagueAI.Libraries.Api | ||
{ | ||
public sealed class ClientApi : IApi | ||
{ | ||
public void WaitClientOpen( | ||
int timeout = 60 | ||
) | ||
{ | ||
while (!IsClientOpen()) | ||
{ | ||
if (timeout <= 0) | ||
{ | ||
Logger.WriteLine(DEFINE.NotOpenGameClientYetLog, EMessageState.ERROR); | ||
Program.Exit(1); | ||
} | ||
timeout -= 5; | ||
Thread.Sleep(5000); | ||
} | ||
} | ||
|
||
public bool IsClientOpen() => ClientLCU.IsClientOpen(); | ||
|
||
public void Initialize() => ClientLCU.Initialize(); | ||
public void BringToFont() => ClientLCU.BringToFont(); | ||
public void CenterScreen() => ClientLCU.CenterScreen(); | ||
public void CloseClient() => ClientLCU.CloseClient(); | ||
public void KillProcessRenderUxClient() => ClientLCU.KillProcessRenderUxClient(); | ||
|
||
public void OpenClient() => ClientLCU.OpenClient(); | ||
|
||
public Summoner LoadSummoner() => ClientLCU.GetCurrentSummoner(); | ||
|
||
public void CreateLobby(EQueueRoom queueId) => ClientLCU.CreateLobby(queueId); | ||
|
||
public ESearchMatchResult SearchMatch() => ClientLCU.SearchMatch(); | ||
|
||
public void Reconnect() => ClientLCU.Reconnect(); | ||
|
||
public void AcceptMatch() => ClientLCU.AcceptMatch(); | ||
|
||
public bool IsMatchFound() => ClientLCU.IsMatchFound(); | ||
|
||
public EGameflowPhase GetGameflowPhase() => ClientLCU.GetGameflowPhase(); | ||
|
||
public EChampionPickResult PickChampion(EChampion champion) => ClientLCU.PickChampion(champion); | ||
public bool PickSkin(Summoner player) => ClientLCU.PickSkin(player); | ||
public string HonorPlayer() => ClientLCU.PostHonorAfterGameDone(); | ||
} | ||
} |
Oops, something went wrong.