public static bool IsAFK(this AIHeroClient target) { var unit = TrackedUnits.FirstOrDefault(s => s.Unit.IdEquals(target)); if (unit?.Unit == null) { return(false); } if (unit.Unit.IsEnemy) { return(Core.GameTickCount - unit.LastVisibleTick > 180000f); // not visible for more than 3 minutes } return(Core.GameTickCount - unit.LastCommandTick > 5000f); // Last command more than 5 seconds }
private static void Obj_AI_Base_OnBasicAttack(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { if (sender == null || args.Target == null) { return; } var unit = TrackedUnits.FirstOrDefault(s => s.Unit.IdEquals(sender)); if (unit == null) { TrackedUnits.Add(new UnitTrack(sender)); return; } unit.Target = args.Target; unit.LastCommandTick = Core.GameTickCount; unit.AttackStartTick = Core.GameTickCount; }
private static void Obj_AI_Base_OnNewPath(Obj_AI_Base sender, GameObjectNewPathEventArgs args) { if (sender == null) { return; } var unit = TrackedUnits.FirstOrDefault(s => s.Unit.IdEquals(sender)); if (unit == null) { TrackedUnits.Add(new UnitTrack(sender)); return; } var validPath = args.Path.LastOrDefault().Distance(sender) > 75 + sender.BoundingRadius; if (validPath) { unit.LastCommandTick = Core.GameTickCount; } }
public static UnitTrack TrackedUnit(this Obj_AI_Base unit) { return(TrackedUnits.FirstOrDefault(u => u.Unit.IdEquals(unit))); }