namespace Turbo.Plugins.LightningMod { using System.Linq; using System; using Turbo.Plugins.Default; using SharpDX.DirectInput; using Turbo.Plugins.glq; public class DemonHunterBolasPlugin : BasePlugin, IInGameTopPainter, IKeyEventHandler { public IKeyEvent ToggleKeyEvent { get; set; } public IKeyEvent zhuisao { get; set; } public IFont InfoFont1 { get; private set; } public IFont InfoFont2 { get; private set; } public IFont InfoFont3 { get; private set; } private string str_running1; private string str_running2; private string str_tip; public bool Running { get; private set; } public int dongneng { get; set; } private bool isStrafeDH = false; private IPlayerSkill skillStrafe = null; private IPlayerSkill skillBolas = null; private IWatch DelayTimer; private IWatch DelayTimer2; private IMonster Monster = null; private bool isZhuisao = false; private int delaytime = 0; private IUiElement ChatUI; public DemonHunterBolasPlugin() { Enabled = true; dongneng = 19; } public override void Load(IController hud) { base.Load(hud); ToggleKeyEvent = Hud.Input.CreateKeyEvent(true, Key.F3, false, false, false); zhuisao = Hud.Input.CreateKeyEvent(true, Key.F4, false, false, false); InfoFont1 = Hud.Render.CreateFont("tahoma", 8, 255, 200, 200, 0, true, false, 255, 0, 0, 0, true); InfoFont2 = Hud.Render.CreateFont("tahoma", 8, 255, 0, 255, 0, true, false, 255, 0, 0, 0, true); InfoFont3 = Hud.Render.CreateFont("tahoma", 8, 255, 255, 0, 0, true, false, 255, 0, 0, 0, true); DelayTimer = Hud.Time.CreateWatch(); DelayTimer2 = Hud.Time.CreateWatch(); ChatUI = Hud.Render.GetUiElement("Root.NormalLayer.chatentry_dialog_backgroundScreen.chatentry_content.chat_editline"); } public void OnKeyEvent(IKeyEvent keyEvent) { if (ToggleKeyEvent.Matches(keyEvent) && keyEvent.IsPressed && isStrafeDH) { if(Running) { Running = false; upStrafe(); DelayTimer.Stop(); DelayTimer2.Stop(); } else { Running = true; DelayTimer.Start(); DelayTimer2.Start(); } } if (zhuisao.Matches(keyEvent) && keyEvent.IsPressed && isStrafeDH) { if (Running) { isZhuisao = !isZhuisao; } } } private void upStrafe() { if (skillStrafe != null && Hud.Interaction.IsContinuousActionStarted(skillStrafe.Key)) { Hud.Interaction.StopContinuousAction(skillStrafe.Key);//弹起扫射 } } public void PaintTopInGame(ClipState clipState) { if (clipState != ClipState.AfterClip) return; if (Hud.CurrentLanguage == Language.zhCN) { str_running1 = "正在扫射," + ToggleKeyEvent + "键停止," + zhuisao + "键开启索扫模式"; str_running2 = "正在追扫模式," + zhuisao + "键切换普通模式,"+ ToggleKeyEvent + "键停止"; str_tip = ToggleKeyEvent + "键开始扫射和吞噬箭"; } else if (Hud.CurrentLanguage == Language.zhTW) { str_running1 = "正在掃射," + ToggleKeyEvent + "鍵停止," + zhuisao + "鍵開啟索掃模式"; str_running2 = "正在追掃模式," + zhuisao + "鍵切換普通模式," + ToggleKeyEvent + "鍵停止"; str_tip = ToggleKeyEvent + "鍵開始掃射和吞噬箭"; } else { str_running1 = "Strafeing," + ToggleKeyEvent + " to stop," + zhuisao + " to switch to Strafeing&Bolas"; str_running2 = "Strafeing&Devouring," + zhuisao + " to switch to normal mode," + ToggleKeyEvent + " to stop"; str_tip = ToggleKeyEvent + " Key to cast Strafe and Devouring Arrow"; } isStrafeDH = Hud.Game.Me.HeroClassDefinition.HeroClass == HeroClass.DemonHunter && Hud.Game.Me.Powers.UsedSkills.Any(s => s.SnoPower == Hud.Sno.SnoPowers.DemonHunter_Strafe) && Hud.Game.Me.Powers.UsedSkills.Any(s => s.SnoPower == Hud.Sno.SnoPowers.DemonHunter_Bolas) && Hud.Game.Me.GetSetItemCount(791249) >= 6 ;//获取自己是扫射冰吞扫射DH if (isStrafeDH) { skillStrafe = Hud.Game.Me.Powers.UsedDemonHunterPowers.Strafe; skillBolas = Hud.Game.Me.Powers.UsedDemonHunterPowers.Bolas; } if (Hud.Game.IsInTown) { if(Running) { Running = false; upStrafe(); } return; } if (isStrafeDH) { if (Running) { if(isZhuisao) { InfoFont3.DrawText(str_running2, Hud.Game.Me.FloorCoordinate.ToScreenCoordinate().X - InfoFont3.GetTextLayout(str_running2).Metrics.Width / 2, Hud.Game.Me.FloorCoordinate.ToScreenCoordinate().Y, true); } else { InfoFont2.DrawText(str_running1, Hud.Game.Me.FloorCoordinate.ToScreenCoordinate().X - InfoFont2.GetTextLayout(str_running1).Metrics.Width / 2, Hud.Game.Me.FloorCoordinate.ToScreenCoordinate().Y, true); } } else { InfoFont1.DrawText(str_tip, Hud.Game.Me.FloorCoordinate.ToScreenCoordinate().X - InfoFont1.GetTextLayout(str_tip).Metrics.Width / 2, Hud.Game.Me.FloorCoordinate.ToScreenCoordinate().Y, true); } } else { return; } if (Running) { if (Hud.Game.IsLoading || Hud.Game.IsPaused || Hud.Game.IsInTown || !Hud.Game.IsInGame || !Hud.Window.IsForeground || (!Hud.Render.MinimapUiElement.Visible) || Hud.Render.WorldMapUiElement.Visible || ChatUI.Visible || Hud.Render.ActMapUiElement.LastVisibleSystemTick > DateTime.Now.Ticks - (500 * 10000) || Hud.Render.WorldMapUiElement.LastVisibleSystemTick > DateTime.Now.Ticks - (500 * 10000) || Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.Generic_IdentifyAllWithCast.Sno) || Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.Generic_IdentifyWithCast.Sno) || Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.Generic_IdentifyWithCastLegendary.Sno) || Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.Generic_AxeOperateGizmo.Sno)//悬赏任务读条 || Hud.Game.Me.AnimationState == AcdAnimationState.Transform || Hud.Game.Me.AnimationState == AcdAnimationState.CastingPortal || Hud.Game.Me.IsDead || Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.Generic_ActorGhostedBuff.Sno) || Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.Crusader_SteedCharge.Sno) ) { upStrafe(); return; } if (!Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.DemonHunter_Strafe.Sno, 0) && DelayTimer2.IsRunning && DelayTimer2.ElapsedMilliseconds > 50) { Hud.Interaction.StopContinuousAction(skillStrafe.Key); Hud.Interaction.StartContinuousAction(skillStrafe.Key, skillStrafe.Key == ActionKey.LeftSkill);//按下扫射 if(skillStrafe.Key == ActionKey.LeftSkill) Hud.Interaction.StandStillUp(); DelayTimer2.Restart(); } if (isZhuisao) { DoBolas(); } else { if (Hud.Game.ActorQuery.OnScreenMonsterCount == 0) { if(PublicClassPlugin.GetBuffCount(Hud, 484289, 10) <= 16) DoBolas(); } else { if (PublicClassPlugin.GetBuffCount(Hud, 484289, 10) <= dongneng) DoBolas(); } } } } private void DoBolas() { if (DelayTimer.ElapsedMilliseconds > 30 && !(Hud.Interaction.IsHotKeySet(ActionKey.Move) && Hud.Interaction.IsContinuousActionStarted(ActionKey.Move)) && !PublicClassPlugin.isHoverValidActor(Hud)) { Hud.Interaction.DoActionAutoShift(skillBolas.Key);//释放冰吞箭 DelayTimer.Restart(); } } } }