private async Task <bool> RunAutoFight(CancellationToken token) { Func <bool> died = () => Game.IsVisible(UIds.ALLIANCE_BATTLE_SELECT_NEW_CHARACTER_AND_CONTINUE); Func <bool> battleEnded = () => Game.IsVisible(UIds.ALLIANCE_BATTLE_ENDED_MESSAGE); Func <bool> cleared = () => Game.IsVisible(UIds.ALLIANCE_BATTLE_CLEAR_MESSAGE); Func <bool> threeCharsRequired = () => Game.IsVisible(UIds.ALLIANCE_BATTLE_NOTICE_THREE_CHARACTERS_REQUIRED); var autoFight = new AutoFight(Game, Repository, Settings, died, battleEnded, cleared, threeCharsRequired); var autoFightTask = autoFight.Run(token); // TODO: is timeout fallback even necessary? if (await Task.WhenAny(autoFightTask, Task.Delay(300 * 1000, token)) == autoFightTask) { await autoFightTask; // catch exception if thrown... if (Game.IsVisible(UIds.ALLIANCE_BATTLE_SELECT_NEW_CHARACTER_AND_CONTINUE)) { Game.Click(UIds.ALLIANCE_BATTLE_SELECT_NEW_CHARACTER_AND_CONTINUE_CANCEL); await Task.Delay(2000, token); } return(true); } return(false); }
internal async Task RunNormalMode(CancellationToken token) { if (await StartContentBoardMission(MissionName) == null) { Logger.LogError($"Failed to go to {MissionName}"); return; } await WaitUntilVisible(UIds.ALLIANCE_BATTLE_MODE_HEADER, token); if (!await WaitUntilVisible(UIds.ALLIANCE_BATTLE_NORMAL_MODE_READY, token)) { Logger.LogError("Normal mode not available."); return; } await Task.Delay(1000, token); Game.Click(UIds.ALLIANCE_BATTLE_NORMAL_MODE_READY); if (!await WaitUntilVisible(UIds.ALLIANCE_BATTLE_NORMAL_MODE_START, token)) { Logger.LogError("Normal mode start button not available."); return; } await SelectHeroes(); Game.Click(UIds.ALLIANCE_BATTLE_NORMAL_MODE_START); await Task.Delay(1000, token); if (Game.IsVisible(UIds.ALLIANCE_BATTLE_NOTICE_THREE_CHARACTERS_REQUIRED)) { Game.Click(UIds.GENERIC_MISSION_NOTICE_DISCONNECTED_OK); await Task.Delay(1000, token); await SelectHeroes(); await Task.Delay(1000, token); Game.Click(UIds.ALLIANCE_BATTLE_NORMAL_MODE_START); } if (!await HandleStartNotices()) { Logger.LogError("Failed to start mission..."); return; } var autoFight = new AutoFight(Game, Repository, Settings); await autoFight.Run(token); await Task.Delay(1000, token); Game.Click(UIds.ALLIANCE_BATTLE_END_SCREEN_HOME); await Task.Delay(1000, token); await HandleHeroicQuestNotice(); }
private async Task Fight(CancellationToken token, bool useCoopSkill) { Func <bool> chestDropped = () => { return(Game.IsVisible(UIds.WBI_SUPPLY_CHEST)); }; Func <bool> disconnected = () => { return(Game.IsVisible(UIds.GENERIC_MISSION_NOTICE_DISCONNECTED)); }; var fightBot = new AutoFight(Game, Repository, Settings, 90, chestDropped, disconnected); fightBot.UseCoopSkill = useCoopSkill; await fightBot.Run(token); if (Game.IsVisible(UIds.GENERIC_MISSION_NOTICE_DISCONNECTED)) { Game.Click(UIds.GENERIC_MISSION_NOTICE_DISCONNECTED_OK); await Task.Delay(4000, token); Logger.LogInformation("Restarting because of disconnect"); Game.Click(UIds.WBI_HERO_START_MISSION); await Fight(token, useCoopSkill); } else { await Task.Delay(2000, token); Game.Click(UIds.WBI_NEXT_RUN); } }
// Use this for initialization void Start() { actor = gameObject.GetComponent <sdGameActor>(); if (actor == null) { actor = gameObject.GetComponent <sdGameMonster>(); } if (actor != null) { auto = actor.AutoFightSystem; //walkPath = auto.GetCurrentPath(); } renderobj = new GameObject(); renderobj.name = gameObject.name + "_AI_Path"; renderobj.transform.position = Vector3.zero; renderobj.transform.rotation = Quaternion.identity; renderobj.AddComponent <MeshFilter>(); MeshRenderer r = renderobj.AddComponent <MeshRenderer>(); Shader shader = Shader.Find("SDShader/SelfIllum_Object"); r.material = new Material(shader); Vector4 color = new Vector4(Random.Range(0.1f, 1.0f), Random.Range(0.1f, 1.0f), Random.Range(0.1f, 1.0f)); r.material.SetVector("_Color", color); }
protected async Task <bool> RunMissionCore(CancellationToken token) { if (!await WaitUntilVisible(UIds.GENERIC_MISSION_START, token)) { return(false); } await Task.Delay(1000, token); Game.Click(UIds.GENERIC_MISSION_START); await Task.Delay(1000, token); if (Game.IsVisible(UIds.GENERIC_MISSION_ITEM_LIMIT_REACHED_NOTICE)) { Game.Click(UIds.GENERIC_MISSION_ITEM_LIMIT_REACHED_NOTICE_OK_BUTTON); } if (!await OnGameStart()) { await RunCore(token); return(true); } var autoFight = new AutoFight(Game, Repository, Settings, () => Game.IsVisible(UIds.EPIC_QUEST_ENDSCREEN_HOME_BUTTON_IMAGE)); await autoFight.Run(token); if (!await WaitUntilVisible(UIds.EPIC_QUEST_ENDSCREEN_HOME_BUTTON_IMAGE, token, 20, 0.5f)) { Game.OnError(new ElementNotFoundError(Repository[UIds.EPIC_QUEST_ENDSCREEN_HOME_BUTTON_IMAGE])); Logger.LogError("Button to navigate to home screen did not appear."); return(false); } await Task.Delay(3000, token); if (Game.IsVisible(UIds.EPIC_QUEST_ENDSCREEN_NOTICE_ALL_ENTRIES_USED)) { Game.Click(UIds.EPIC_QUEST_ENDSCREEN_NOTICE_ALL_ENTRIES_USED_OK_BUTTON); await Task.Delay(1000, token); } if (!await ClickWhenVisible(UIds.EPIC_QUEST_ENDSCREEN_HOME_BUTTON_IMAGE)) { Logger.LogError("Home button did not appear."); return(false); } await Task.Delay(3000, token); return(true); }
private async Task <bool> RunAutoFight(CancellationToken token) { var autoFight = new AutoFight(Game, Repository, Settings, () => Game.IsVisible(UIds.DANGER_ROOM_HIGHEST_EXCLUSIV_SKILL_COUNT)); var autoFightTask = autoFight.Run(token); if (await Task.WhenAny(autoFightTask, Task.Delay(300 * 1000, token)) == autoFightTask) { await autoFightTask; // catch exception if thrown... return(true); } return(false); }
public override bool TakeAction() { receipt = RequestInviteFightResult.OK; GameSession session = GameSession.Get(destuid); UserBasisCache dest = UserHelper.FindUserBasis(destuid); if (dest == null) { receipt = RequestInviteFightResult.Offine; return(true); } //if (dest.ServerID != 0) //{ // if (session == null || !session.Connected) // { // receipt = RequestInviteFightResult.Offine; // return true; // } //} else if (dest.UserStatus == UserStatus.Inviteing) { receipt = RequestInviteFightResult.HadInvite; return(true); } else if (dest.UserStatus == UserStatus.Fighting) { receipt = RequestInviteFightResult.Fighting; return(true); } GetBasis.UserStatus = UserStatus.Inviteing; GetBasis.InviteFightDestUid = destuid; AutoFight.FightBot fbot = new AutoFight.FightBot() { UserId = dest.UserID, InviteTime = DateTime.Now, PlayerUserId = Current.UserId, DestUserId = destuid }; AutoFight.AddFightBot(fbot); dest.UserStatus = UserStatus.Inviteing; PushMessageHelper.InviteFightNotification(session, Current.UserId); return(true); }
public CrossGate() { Player = new Role(this); SpeedFight = new SpeedFight(this); SpeedUp = new SpeedUp(this); Movement = new Movement(this); Bag = new Bag(this); Calls = new Calls(this); AutoFight = new AutoFight(this); FuntionThread = new FuntionThread(this); Pet = new Pet[5] { new Pet(this, 0), new Pet(this, 1), new Pet(this, 2), new Pet(this, 3), new Pet(this, 4) }; Scripts = new Scripts(this); }
public override void OnPointerDown(PointerEventData eventData) { OnDrag(eventData); var goe = RoleMgr.GetInstance().GetMainRole(); AutoFight fightAi = goe.GetComponent <UnityMMO.AutoFight>(); if (fightAi != null) { fightAi.enabled = false; } var moveQuery = goe.GetComponent <UnityMMO.MoveQuery>(); if (moveQuery != null) { moveQuery.StopFindWay(); } }
private async Task HandleHeroicQuestEndFight(CancellationToken token) { await ClickWhenVisible(UIds.HEROIC_QUEST_QUEST_INFO_GOTO); await Task.Delay(2000); await ClickWhenVisible(UIds.HEROIC_QUEST_END_QUEST_START); await ClickWhenVisible(UIds.HEROIC_QUEST_END_QUEST_SKIP); Func <bool> homeVisible = () => Game.IsVisible(UIds.HEROIC_QUEST_END_QUEST_HOME); var authFight = new AutoFight(Game, Repository, Settings, homeVisible); await authFight.Run(token); await Task.Delay(1000); await ClickWhenVisible(UIds.HEROIC_QUEST_END_QUEST_HOME); await ClickWhenVisible(UIds.HEROIC_QUEST_END_QUEST_SKIP); await HandleHeroicQuestNotice(); await GoToMainScreen(); }
protected override async Task RunCore(CancellationToken token) { var status = await StartContentBoardMission("LEGENDARY BATTLE"); if (status == null) { Logger.LogError("Could not find legendary battle"); return; } if (status.Completed) { Logger.LogInformation("Already completed"); return; } if (ClearCount > status.Available) { Logger.LogError($"Cannot run {ClearCount} times. Only {status.Available} available"); return; } else { Logger.LogDebug($"Trying to clear legendary battle {ClearCount} times."); } await Task.Delay(1000); bool found = false; // TODO: implement search for mission via drag for (int y = 0; y < 4; y++) { var mission = Repository["LEGENDARY_BATTLE_NAME_DYN", 0, y]; var missionText = Game.GetText(mission); if (missionText.Similarity(BattleName) > 0.75) // Accept small changes. TODO: figure out if this is sufficent. { found = true; Game.Click(mission); break; } } if (!found) { Logger.LogError($"Failed to find mission {BattleName}."); Game.OnError(new ElementNotFoundError(Repository["LEGENDARY_BATTLE_NAME_DYN"])); } await Task.Delay(1000); Game.Click("LEGENDARY_BATTLE_NORMAL_MODE_BUTTON"); Logger.LogDebug("Starting normal mode"); await Task.Delay(1000); var enter = Repository["LEGENDARY_BATTLE_MISSION_ENTER", 0, 0]; if (!await WaitUntilVisible(enter)) { Logger.LogError("Enter button did not appear"); Game.OnError(new ElementNotFoundError(enter)); return; } Game.Click(enter); Logger.LogDebug("Entering mission"); for (int i = 0; i < ClearCount; i++) { Logger.LogDebug($"Running mission (1/{status.Available})"); await Task.Delay(3000); Logger.LogDebug("Starting mission."); Game.Click("LEGENDARY_BATTLE_MISSION_START"); await Task.Delay(1000, token); if (Game.IsVisible(UIds.LEGENDARY_BATTLE_CHARACTER_NOTICE_IGNORE)) { Logger.LogDebug("Ignoring character requirement message"); Game.Click(UIds.LEGENDARY_BATTLE_CHARACTER_NOTICE_IGNORE); } Logger.LogDebug("Waiting for skip into button"); if (await WaitUntilVisible("LEGENDARY_BATTLE_MISSION_SKIP_INTRO", 10)) { Game.Click("LEGENDARY_BATTLE_MISSION_SKIP_INTRO"); } Logger.LogDebug("Starting auto fight"); Func <bool> end = () => Game.IsVisible("LEGENDARY_BATTLE_MISSION_SUCCESS"); var fightBot = new AutoFight(Game, Repository, Settings, end); await fightBot.Run(token); await Task.Delay(1000); Logger.LogDebug("Starting auto fight finished. Repeating run."); Game.Click("LEGENDARY_BATTLE_ENDSCREEN_REPEAT_RUN"); } await Task.Delay(2000); // Handle heroic quest notices. await GoToMainScreen(); }
public override bool TakeAction() { GetBasis.UserStatus = UserStatus.MainUi; GameSession destSession = GameSession.Get(destuid); UserBasisCache destBasis = UserHelper.FindUserBasis(destuid); UserAttributeCache destAttribute = UserHelper.FindUserAttribute(destuid); if (destSession == null || !destSession.Connected || destBasis == null || destBasis.UserStatus != UserStatus.Inviteing || destBasis.InviteFightDestUid != Current.UserId) { return(true); } AutoFight.RemoveFightBot(destuid); if (result == EventStatus.Bad) { destBasis.UserStatus = UserStatus.MainUi; destBasis.InviteFightDestUid = 0; PushMessageHelper.RefuseInviteFightNotification(destSession, GetBasis.NickName); } else {// 切磋开始通知 GetBasis.UserStatus = UserStatus.Fighting; destBasis.UserStatus = UserStatus.Fighting; EventStatus retresult = EventStatus.Good; float diff = (float)GetAttribute.FightValue / destAttribute.FightValue; if (diff > 1.1f) { retresult = EventStatus.Good; } else if (diff < 0.9f) { retresult = EventStatus.Bad; } else { if (diff >= 1.0f) { retresult = random.Next(1000) < 8000 ? EventStatus.Good : EventStatus.Bad; } else { retresult = random.Next(1000) < 8000 ? EventStatus.Bad : EventStatus.Good; } } if (retresult == EventStatus.Bad) { PushMessageHelper.StartInviteFightNotification(Current, destuid, EventStatus.Bad); PushMessageHelper.StartInviteFightNotification(destSession, Current.UserId, EventStatus.Good); } else { PushMessageHelper.StartInviteFightNotification(Current, destuid, EventStatus.Good); PushMessageHelper.StartInviteFightNotification(destSession, Current.UserId, EventStatus.Bad); } } return(true); }
protected override async Task RunCore(CancellationToken token) { var status = await StartContentBoardMission("SQUAD BATTLE"); if (status.Completed) { Logger.LogInformation("Already completed..."); return; } await Task.Delay(2000); if (Game.IsVisible(UIds.SQUAD_BATTLE_RANK_DROP)) { Game.Click(UIds.SQUAD_BATTLE_RANK_DROP); } int leastPoints = int.MaxValue; int leastPointsX = 0; int leastPointsY = 1; // first row is 1 not 0. for (int y = 1; y < 4; y++) { for (int x = 0; x < 2; x++) { var pointsStr = Game.GetText(Repository[$"SQUAD_BATTLE_POINTS_{y}_ROW", x, 0]); var trimStr = "Point(s)"; if (pointsStr.Contains(trimStr)) { var pointSubString = pointsStr.Substring(0, pointsStr.Length - trimStr.Length).TrimEnd(); if (int.TryParse(pointSubString, NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var points)) { if (points < leastPoints) { leastPointsX = x; leastPointsY = y; leastPoints = points; Logger.LogDebug($"Found new least points. {points} {leastPointsX}/{leastPointsY}"); } } } Logger.LogDebug(pointsStr); } } var chosenOpponent = Repository[$"SQUAD_BATTLE_SELECTION_{leastPointsY}_ROW", leastPointsX, 0]; Game.Click(chosenOpponent); await Task.Delay(2000); await SelectHeroes(); Game.Click(UIds.SQUAD_BATTLE_START_BATTLE); await Task.Delay(1000); if (Game.IsVisible(UIds.SQUAD_BATTLE_ALL_SLOTS_MUST_BE_FILLED)) { Game.Click(UIds.SQUAD_BATTLE_ALL_SLOTS_MUST_BE_FILLED_OK); await Task.Delay(1000); await SelectHeroes(); Game.Click(UIds.SQUAD_BATTLE_START_BATTLE); } Func <bool> endCondition = () => Game.IsVisible(UIds.SQUAD_BATTLE_END_BATTLE_MESSAGE); Func <bool> summaryBattlePoints = () => Game.IsVisible(UIds.SQUAD_BATTLE_SUMMARY_OVERALL_BATTLEPOINTS); var fightBot = new AutoFight(Game, Repository, Settings, endCondition, summaryBattlePoints); await fightBot.Run(token); await Task.Delay(2000); if (!await ClickWhenVisible(UIds.SQUAD_BATTLE_SUMMARY_OVERALL_BATTLEPOINTS, 10)) { Logger.LogError("Rank up/down notification did not appear. Did we already run this mode?"); return; } await Task.Delay(3000); if (Game.IsVisible(UIds.SQUAD_BATTLE_SUMMARY_OVERALL_BATTLEPOINTS)) { Logger.LogDebug("Clicking one more time... (SQUAD_BATTLE_SUMMARY_OVERALL_BATTLEPOINTS)"); Game.Click(UIds.SQUAD_BATTLE_SUMMARY_OVERALL_BATTLEPOINTS); } await Task.Delay(3000); if (!await ClickWhenVisible(UIds.SQUAD_BATTLE_END_HOME_BUTTON)) { Game.OnError(new ElementNotFoundError(Repository[UIds.SQUAD_BATTLE_END_HOME_BUTTON])); Logger.LogError("Rank up/down notification did not appear."); return; } await Task.Delay(2000); }
// Update is called once per frame void Update() { List <Vector3> newPath = null; if (auto == null) { if (actor != null) { auto = actor.AutoFightSystem; } } if (auto != null) { newPath = auto.GetCurrentPath(); } if (newPath != null) { t += Time.deltaTime; if (t > 1.0f) { lastCount = 0; t = 0.0f; } if (newPath.Count > 0 && lastCount != newPath.Count) { renderobj.transform.position = newPath[0]; MeshFilter mf = renderobj.GetComponent <MeshFilter>(); Vector3 Y = new Vector3(0, 1, 0); int vertexcount = (newPath.Count - 1) * 4; if (vertex.Length < vertexcount) { vertex = new Vector3[vertexcount]; } face = new int[(newPath.Count - 1) * 6]; Vector3 vOffset = new Vector3(0, 0.05f, 0); for (int i = 0; i < newPath.Count - 1; i++) { Vector3 v0 = newPath[i] + vOffset - renderobj.transform.position; Vector3 v1 = newPath[i + 1] + vOffset - renderobj.transform.position; Vector3 dir = (v1 - v0).normalized; Vector3 right = Vector3.Cross(Y, dir); vertex[i * 4] = v1 - right * 0.1f; vertex[i * 4 + 1] = v1 + right * 0.1f; vertex[i * 4 + 2] = v0 - right * 0.1f; vertex[i * 4 + 3] = v0 + right * 0.1f; face[i * 6] = i * 4; face[i * 6 + 1] = i * 4 + 1; face[i * 6 + 2] = i * 4 + 2; face[i * 6 + 3] = i * 4 + 2; face[i * 6 + 4] = i * 4 + 1; face[i * 6 + 5] = i * 4 + 3; } //mf.mesh.vertexCount = vertex.Length; mf.mesh.vertices = vertex; mf.mesh.triangles = face; // mf.mesh.t //mf.mesh. } } }