private void AfterReload() { _afterReload = null; if (FightUtils.StopAttacking(this)) { StopAttack(); return; } AnimationUtils.PlayAnimation("Attack", Avatar , attackPhase: AttackPhase, singleVariation: false , playImediatly: true , accessory: Weapon, accessoryName: "Axe" , accessory2: Shield, accessory2Name: "Shield"); AxeHitArea.gameObject.SetActive(true); AxeHitArea.Reset(); var animTime = AnimationUtils.GetAnimationLength(Avatar, "Attack_Body_" + AttackPhase.Value, basedOnSpeed: true); Timer._.InternalWait(AfterAttack, animTime); // _afterAttack = Game.WaitForSeconds(animTime, AfterAttack); // StartCoroutine(_afterAttack); }
private void ViewFight(FightInfo f) { //var s = new StringBuilder(); //var writer = new StringWriter(s); //f.WriteNotes(writer); //LogInfo(s.ToString()); lvPlayers.BeginUpdate(); lvPlayers.Items.Clear(); var top = f.Participants.Max(x => x.OutboundHitSum); // show participants that did damage foreach (var p in f.Participants.Where(x => x.OutboundHitSum > 0)) { var item = lvPlayers.Items.Add(p.Name); item.SubItems.Add(p.Class); item.SubItems.Add(FightUtils.FormatNum(p.OutboundHitSum)); item.SubItems.Add(((double)p.OutboundHitSum / top).ToString("P0")); item.SubItems.Add(p.Duration.ToString() + 's'); item.SubItems.Add(FightUtils.FormatNum(p.OutboundHitSum / f.Duration)); //var damage = String.Join(", ", p.AttackTypes.Take(4).Select(x => $"{(double)x.HitSum / p.OutboundHitSum:P0} {x.Type}")); var notes = String.Join(", ", p.AttackTypes.Take(4).Select(x => $"{FightUtils.FormatNum(x.HitSum / f.Duration)} {x.Type}")); var other = p.AttackTypes.Skip(4).Sum(x => x.HitSum); if (other > 0) { notes += $", {FightUtils.FormatNum(other / f.Duration)} other"; } if (p.Buffs.Any(x => x.Name == BuffTracker.DEATH)) { notes = "DIED - " + notes; } item.SubItems.Add(notes); } lvPlayers.EndUpdate(); }
private void AfterReload() { _afterReload = null; if (FightUtils.StopAttacking(this)) { StopAttack(); return; } Arrow.gameObject.SetActive(false); AnimationUtils.PlayAnimation( "Attack", Avatar , playImediatly: true , accessory: Cape, accessoryName: "Body" , accessory2: Bow, accessory2Name: "Bow" ); var animTime = AnimationUtils.GetAnimationLength(Avatar, "Attack_Body", basedOnSpeed: true); var arrowExpirationTime = animTime / 6; Timer._.InternalWait(FireProjectile, arrowExpirationTime); // _fireProjectile = Game.WaitForSeconds(arrowExpirationTime, FireProjectile); // StartCoroutine(_fireProjectile); Timer._.InternalWait(AfterAttack, animTime); // _afterAttack = Game.WaitForSeconds(animTime, AfterAttack); // StartCoroutine(_afterAttack); }
private void FireProjectile() { Arrow.gameObject.SetActive(false); if (Arrows == null) { Arrows = new List <Projectile>(); } int? projectileIndex = null; Projectile arrowP = FightUtils.GetAvailableProjectile(Arrows, CreateArrow, _onHit, FightUtils.OppositeTeam(Intell.IAm), ref projectileIndex); if (arrowP == null && projectileIndex != null) { arrowP = Arrows[projectileIndex.Value]; } else { Arrows.Add(arrowP); projectileIndex = Arrows.Count; } var pos = Intell._attackController.GetEnemyTargetPosition(); // fire projectile arrowP.Fire(pos, transform.eulerAngles); }
private void FireProjectile() { if (Projectiles == null) { Projectiles = new List <Projectile>(); } for (var i = 0; i < 3; i++) { int? projectileIndex = null; Projectile sharpnell = FightUtils.GetAvailableProjectile(Projectiles, CreateShrapnell, _onHit, FightUtils.OppositeTeam(Intell.IAm), ref projectileIndex); if (sharpnell == null && projectileIndex != null) { sharpnell = Projectiles[projectileIndex.Value]; } else { Projectiles.Add(sharpnell); projectileIndex = Projectiles.Count; } // Debug.Log( // __debug.DebugList<GameObject>(ShrapnellPos, "ShrapnellPos", (go) => // { // return go.name; // }) // ); if (__list.isNilOrEmpty(ShrapnellPos) == false) { sharpnell.Fire( transform.TransformPoint(ShrapnellPos[i].transform.position), transform.eulerAngles); } } }
public void EnemyInRange(GameObject unitGo = null) { if (unitGo == null) { return; } var unit = unitGo.GetComponent <Unit>(); if (unit.Stats.IsDead) { return; } _targetEnemyIndex = unit._unit.Index; _targetEnemyTeam = unit.Intell.IAm; //Debug.Log(gameObject.name + ": enemy (" + TargetEnemy.gameObject.name + ") is in range."); _moveController.StopMoving(false); _unit.Attack(); FightUtils.FaceEnemy(unitGo.transform.position, transform, onlyY: false); Intell.AtackSensor.gameObject.SetActive(false); }
public void configureBot() { var level = (byte)Stats.GetStat <Level>(); CharacterData[typeof(GeneralStats)] = FightUtils.getRandomGenStats(GetCharData <GeneralStats>(), level); Items = FightUtils.getRandomItemsByLevel(Items, level); Stats = FightUtils.getRandomStatsByLevel(Stats, level); }
private void AfterAttack() { _afterAttack = null; if (FightUtils.StopAttacking(this)) { StopAttack(); return; } InternalAttack(); }
public void Init(Unit.OnHit onHit) { _onHit = onHit; _intell.UnitPrimaryState = UnitPrimaryState.Idle; if (Stats.AttackSpeed == 0) { Stats.AttackSpeed = FightUtils.GetDefaultAttackSpeed(Avatar, "Reload_Body", "Attack_Body"); } AttackSpeedChanged(); }
public void Init(Unit.OnHit onHit) { _onHit = onHit; Intell.SetPrimaryState(UnitPrimaryState.Idle, changeState: true); Arrow.gameObject.SetActive(false); if (Stats.AttackSpeed == 0) { Stats.AttackSpeed = FightUtils.GetDefaultAttackSpeed(Avatar, "Reload_Body", "Attack_Body"); } AttackSpeedChanged(); }
public void Init(Unit.OnHit onHit) { _intell.UnitPrimaryState = UnitPrimaryState.Idle; AxeHitArea.Init(onHit, Intell.IAm == IAm.Ally ? IAm.Enemy.ToString() : IAm.Ally.ToString()); AxeHitArea.gameObject.SetActive(false); if (Stats.AttackSpeed == 0) { Stats.AttackSpeed = FightUtils.GetDefaultAttackSpeed(Avatar, "Reload_Body_2", "Attack_Body_2"); } AttackSpeedChanged(); }
private void lvFights_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { var f = GetListViewFight(e.ItemIndex); e.Item = new ListViewItem(); e.Item.Text = f.Name; e.Item.SubItems.Add(f.Zone); e.Item.SubItems.Add(f.UpdatedOn.ToLocalTime().ToString()); e.Item.SubItems.Add(FightUtils.FormatNum(f.HP)); e.Item.SubItems.Add(f.Duration.ToString() + "s"); e.Item.SubItems.Add(FightUtils.FormatNum(f.HP / f.Duration)); e.Item.SubItems.Add(f.Party + ": " + f.Participants.Count); fightStatus.TryGetValue(f.ID, out string status); e.Item.SubItems.Add(status ?? "-"); }
private void AttackSpeedChanged() { _previousAttackAttackSpeed = Stats.AttackSpeed; var animationSpeed = FightUtils.CalculateAtackSpeed( ref Avatar , "Reload_Body", "Attack_Body" , Stats.AttackSpeed //, debug: true ); float animationWeight = 0f; AnimationUtils.SetAnimationOptions(ref Avatar, "Reload_Body", animationSpeed, animationWeight); }
public void makeAMove(int targetId) { // var timer = new Stopwatch(); // timer.Start(); // var delayInMs = RngUtil.intRange(0, (int)moveReplyMaxDelayInMs); // while (timer.ElapsedMilliseconds < delayInMs) continue; var newMove = new FightMove { PeerObjectId = this.ObjectId, AttackSpot = FightUtils.getRandomHit(), BlockSpots = FightUtils.getRandomBlock(), TargetObjectId = targetId }; CurrentFight.AddMoveSendPkg(this, newMove); }
public void makeAMove() { if (CurrentFight.hasMovesAgainstAll(this)) { return; } var newMove = new FightMove { PeerObjectId = this.ObjectId, AttackSpot = FightUtils.getRandomHit(), BlockSpots = FightUtils.getRandomBlock(), SkillId = 0, TargetObjectId = Target.ObjectId }; DebugUtils.Logp(DebugUtils.Level.INFO, CLASSNAME, "makeAMove", "bot submitting a move"); CurrentFight.AddMoveSendPkg(this, newMove); }
private void AttackSpeedChanged() { _previousAttackAttackSpeed = Stats.AttackSpeed; var animationWeight = 0f; for (var i = 1; i <= 3; i++) { var animationSpeed = FightUtils.CalculateAtackSpeed( ref Avatar , "Reload_Body_" + i, "Attack_Body_" + i , Stats.AttackSpeed ); AnimationUtils.SetAnimationOptions(ref Shield, "Reload_Shield_" + i, animationSpeed, animationWeight); AnimationUtils.SetAnimationOptions(ref Shield, "Attack_Shield_" + i, animationSpeed, animationWeight); AnimationUtils.SetAnimationOptions(ref Weapon, "Reload_Axe_" + i, animationSpeed, animationWeight); AnimationUtils.SetAnimationOptions(ref Weapon, "Attack_Axe_" + i, animationSpeed, animationWeight); } }
private void AfterReload() { _afterReload = null; if (FightUtils.StopAttacking(this)) { StopAttack(); return; } AnimationUtils.PlayAnimation( "Attack", Avatar ); FireProjectile(); var animTime = Avatar["Attack_Body"].length; Timer._.InternalWait(AfterAttack, animTime); // _afterAttack = Game.WaitForSeconds(animTime, AfterAttack); // StartCoroutine(_afterAttack); }
private void AfterAttack() { _afterAttack = null; AxeHitArea.gameObject.SetActive(false); if (FightUtils.StopAttacking(this)) { StopAttack(); return; } if (AttackPhase.Value == 3) { AttackPhase = 1; } else { AttackPhase++; } InternalAttack(); }
static void Main(string[] args) { LoadSettings(); Application.Init(); Colors.Base.Normal = Application.Driver.MakeAttribute(Color.Green, Color.Black); Colors.ColorSchemes.Add("Highlight", new ColorScheme() { Normal = Application.Driver.MakeAttribute(Color.BrightGreen, Color.Black) }); var win = new Window() { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill(), }; Application.Top.Add(win); //var win = Application.Top; var searchLabel = new Label() { X = 0, Y = 0, Text = "Search:", }; win.Add(searchLabel); var searchField = new TextField() { X = Pos.Right(searchLabel) + 1, Y = 0, Width = Dim.Sized(20), Height = 1, }; win.Add(searchField); var searchCount = new Label() { X = Pos.Right(searchField) + 1, Y = 0, }; win.Add(searchCount); var alwaysLabel = new Label() { X = Pos.Right(searchCount) + 3, Y = 0, Text = "Always Show:", }; win.Add(alwaysLabel); var alwaysField = new TextField() { X = Pos.Right(alwaysLabel) + 1, Y = 0, Width = Dim.Sized(20), Height = 1, TabStop = false, }; win.Add(alwaysField); var modeLabel = new Label() { X = Pos.Right(alwaysField) + 3, Y = 0, Text = "Mode:", }; win.Add(modeLabel); var modeRadio = new RadioGroup() { X = Pos.Right(modeLabel) + 1, Y = 0, Width = Dim.Sized(20), RadioLabels = new NStack.ustring[] { "Total ", "DPS ", "%Total " }, HorizontalSpace = 2, DisplayMode = DisplayModeLayout.Horizontal, TabStop = false, // annoying when tabbing between search and fights SelectedItem = settings.Mode, }; win.Add(modeRadio); //var fightSource = new FightDataSource(fightList); //var fightView = new ListView(fightSource) var fightView = new ListView(fightList) { X = 0, Y = 2, Width = Dim.Fill(), Height = Dim.Percent(50), //Height = 18, }; win.Add(fightView); // the bottom portion of the screen will contain "slots" for individual player information var slots = new List <View>(); for (var i = 0; i < 6; i++) { var slotView = new FrameView() { X = 0 + (i * 25), Y = Pos.Bottom(fightView) + 1, Width = 25, Height = Dim.Fill(), }; var slotText = new Label() { X = 0, Y = 0, Height = 10, Width = Dim.Fill(), Text = "..." }; slotView.Add(slotText); win.Add(slotView); slots.Add(slotText); } var status = new StatusBar() { Visible = true, Items = new StatusItem[] { new StatusItem(Key.Null, "...", () => { }), new StatusItem(Key.Null, "...", () => { }), new StatusItem(Key.Null, "Alt+Enter to toggle full screen", () => { }) }, Text = "Ready..." }; Application.Top.Add(status); searchField.KeyDown += (key) => { if (key.KeyEvent.Key == Key.Esc) { searchField.Text = ""; } }; searchField.TextChanged += (_) => { var s = searchField.Text.ToString(); if (String.IsNullOrEmpty(s)) { fightListSource = null; fightView.SetSource(fightList); searchCount.Text = ""; } else { fightListSource = fightList.Where(x => x.IsMatch(s)).ToList(); fightView.SetSource(fightListSource); fightView.OnSelectedChanged(); searchCount.Text = $"{fightListSource.Count} matches"; } }; alwaysField.TextChanged += (_) => { fightView.OnSelectedChanged(); }; modeRadio.SelectedItemChanged += (args) => { fightView.OnSelectedChanged(); }; fightView.SelectedItemChanged += (args) => { var list = fightListSource ?? fightList; if (args.Item >= list.Count) { return; } var f = list[args.Item].Info; //status.Items[2].Title = DateTime.Now.ToString() + " " + f.Name + " " + f.Participants[0].OutboundHitSum; var mode = modeRadio.SelectedItem; var players = f.Participants.Take(slots.Count).ToList(); var always = alwaysField.Text.ToString().Split(',', StringSplitOptions.RemoveEmptyEntries); if (always.Length > 0) { players = f.Participants .Select((x, i) => new { Always = always.Contains(x.Name, StringComparer.InvariantCultureIgnoreCase) && x.OutboundHitSum > 0, Index = i, Player = x }) .OrderBy(x => !x.Always).ThenBy(x => x.Index) .Take(slots.Count) .OrderBy(x => x.Index) // restore order after take() keeps the "always" entries .Select(x => x.Player) .ToList(); } for (var i = 0; i < slots.Count; i++) { slots[i].Text = ""; if (i >= players.Count) { continue; } var p = players[i]; if (p.OutboundHitSum == 0) { continue; } var text = new StringBuilder(); text.AppendLine($"{p.Name} - {p.Class}"); if (mode == 0) { text.AppendLine($"{FightUtils.FormatNum(p.OutboundHitSum)}"); } else if (mode == 1) { text.AppendLine($"{FightUtils.FormatNum(p.OutboundHitSum / f.Duration)} DPS"); } else if (mode == 2) { text.AppendLine($"{((double)p.OutboundHitSum / f.HP).ToString("P1")} of Total"); text.AppendLine($"{((double)p.OutboundHitSum / f.TopHitSum).ToString("P1")} vs Top Player"); } text.AppendLine("---"); foreach (var dmg in p.AttackTypes) { if (mode == 0) { text.AppendLine($"{Clip(dmg.Type, 15),-15} {FightUtils.FormatNum(dmg.HitSum),6}"); } else if (mode == 1) { text.AppendLine($"{Clip(dmg.Type, 15),-15} {FightUtils.FormatNum(dmg.HitSum / f.Duration),6}"); } else if (mode == 2) { text.AppendLine($"{Clip(dmg.Type, 15),-15} {((double)dmg.HitSum / p.OutboundHitSum).ToString("P0"),6}"); } } text.AppendLine("---"); foreach (var spell in p.Spells.Where(x => x.HitSum > 0 && x.Type == "hit")) { if (mode == 0) { text.AppendLine($"{Clip(spell.Name, 15),-15} {FightUtils.FormatNum(spell.HitSum),6}"); } else if (mode == 1) { text.AppendLine($"{Clip(spell.Name, 15),-15} {FightUtils.FormatNum(spell.HitSum / f.Duration),6}"); } else if (mode == 2) { text.AppendLine($"{Clip(spell.Name, 15),-15} {((double)spell.HitSum / p.OutboundHitSum).ToString("P0"),6}"); } } slots[i].Text = text.ToString(); slots[i].SuperView.ColorScheme = always.Contains(p.Name, StringComparer.InvariantCultureIgnoreCase) ? Colors.ColorSchemes["Highlight"] : Colors.Base; } }; var path = settings.Path; if (args.Length > 1 && File.Exists(args[1])) { path = args[1]; } if (File.Exists(path)) { alwaysField.Text = LogOpenEvent.FromFileName(path)?.Player ?? ""; status.Items[2].Title = path; _ = OpenLog(path); //status.Items[2].Title = ""; } Func <Exception, bool> errorHandler = (Exception e) => { MessageBox.ErrorQuery("Error", e.Message + "\n", "OK"); return(true); }; var menu = new MenuBar(new MenuBarItem[] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_Open", "", () => { var open = new OpenDialog(); open.AllowedFileTypes = new[] { ".txt" }; open.Message = "Select a file starting with: eqlog_"; open.LayoutStyle = LayoutStyle.Computed; open.AllowsMultipleSelection = false; if (File.Exists(settings.Path)) { open.DirectoryPath = Path.GetDirectoryName(settings.Path); } Application.Run(open); if (!open.Canceled) { fightView.SelectedItem = 0; path = open.FilePath.ToString(); alwaysField.Text = LogOpenEvent.FromFileName(path)?.Player ?? ""; status.Items[2].Title = path; _ = OpenLog(path); } }), new MenuItem("_Quit", "", () => { Application.RequestStop(); }) }), }); Application.Top.Add(menu); Application.MainLoop.AddTimeout(TimeSpan.FromMilliseconds(100), (_) => { var count = 0; while (fightQueue.TryDequeue(out FightInfo f) && count++ < 50) { //fightList.Add(f); // oldest to newest fightList.Insert(0, new FightInfoRow(f)); // newest to oldest } if (count > 0) { status.Items[0].Title = $"{fightList.Count} fights"; fightView.OnSelectedChanged(); //status.SetNeedsDisplay(); //fightView.SetNeedsDisplay(); if (logReader != null) { status.Items[1].Title = $"{logReader.Percent:P0} in {logReader.Elapsed:F1}s"; } } return(true); });