namespace Turbo.Plugins.LightningMod { using Turbo.Plugins.Default; using SharpDX.DirectInput; using System.Linq; using Turbo.Plugins.glq; public class DemonHunterStrafeHungeringArrowPlugin : 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; } private bool isStrafeDH = false; private IPlayerSkill skillStrafe = null; private IPlayerSkill skillHungeringArrow = null; private IWatch DelayTimer; private IMonster Monster = null; private bool isZhuisao = false; private int delaytime = 0; public DemonHunterStrafeHungeringArrowPlugin() { Enabled = true; } 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(); } public void OnKeyEvent(IKeyEvent keyEvent) { if (ToggleKeyEvent.Matches(keyEvent) && keyEvent.IsPressed && isStrafeDH) { if(Running) { Running = false; upStrafe(); DelayTimer.Stop(); return; } else { Running = true; DelayTimer.Start(); return; } } if (zhuisao.Matches(keyEvent) && keyEvent.IsPressed && isStrafeDH) { if (Running) { isZhuisao = !isZhuisao; return; } } } 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&Devouring"; str_running2 = "Strafeing&Devouring," + zhuisao + "to switch to normal mode," + ToggleKeyEvent + "to stop"; str_tip = "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_HungeringArrow) && Hud.Game.Me.GetSetItemCount(791249) >= 6 ;//获取自己是扫射冰吞扫射DH if (isStrafeDH) { skillStrafe = Hud.Game.Me.Powers.UsedDemonHunterPowers.Strafe; skillHungeringArrow = Hud.Game.Me.Powers.UsedDemonHunterPowers.HungeringArrow; } 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.Render.MinimapUiElement.Visible || Hud.Render.WorldMapUiElement.Visible) { upStrafe(); return; } if (!Hud.Game.Me.IsDead && !Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.Generic_ActorGhostedBuff.Sno) && !Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.DemonHunter_Strafe.Sno, 0)) { Hud.Interaction.StopContinuousAction(skillStrafe.Key); Hud.Interaction.StartContinuousAction(skillStrafe.Key, skillStrafe.Key == ActionKey.LeftSkill);//按下扫射 Hud.Interaction.ShiftUp(); } if (isZhuisao) { DoHungeringArrow(); } else { if (Hud.Game.ActorQuery.OnScreenMonsterCount == 0) { if(PublicClassPlugin.GetBuffCount(Hud, 484289, 10) <= 16) DoHungeringArrow(); } else { if (PublicClassPlugin.GetBuffCount(Hud, 484289, 10) <= 19) DoHungeringArrow(); } } } } private void DoHungeringArrow() { if (DelayTimer.ElapsedMilliseconds > 30 && !(Hud.Interaction.IsHotKeySet(ActionKey.Move) && Hud.Interaction.IsContinuousActionStarted(ActionKey.Move))) { Hud.Interaction.DoAction(skillHungeringArrow.Key, skillHungeringArrow.Key == ActionKey.LeftSkill);//释放冰吞箭 if (skillHungeringArrow.Key == ActionKey.LeftSkill) { Hud.Interaction.ShiftUp(); } DelayTimer.Restart(); } } } }