private void InitializeTargetListViewItem() { PUnit wu = ObjectManager.MyPlayer.Target; var pairs = new NameValuePair[] {}; if (wu != null && wu.BaseAddress != 0) { if (wu.Type == 3) { pairs = GetTargetNameValuePairs(wu); } else if (wu.Type == 4) { var wpm = (PPlayer)wu; pairs = GetPlayerNameValuePairs(wpm); } } _wowTargetListViewItemArray = new ListViewItem[pairs.Length]; for (int i = 0; i < pairs.Length; i++) { var temp = new ListViewItem(pairs[i].Name); temp.SubItems.Add(pairs[i].Value); _wowTargetListViewItemArray[i] = temp; } listView2.Items.AddRange(_wowTargetListViewItemArray); }
/// <summary> /// Gets the closest attacker other than the PUnit specified. . /// </summary> /// <param name = "exclude">The PUnit to exclude.</param> /// <returns></returns> public static PUnit GetClosestAttackerExclude(PUnit exclude) { PUnit closestAttacker = null; try { List <PUnit> units = GetAttackers; foreach (PUnit u in units) { if (u.GUID != exclude.GUID) { if (closestAttacker == null) { closestAttacker = u; } else if (u.DistanceToSelf < closestAttacker.DistanceToSelf) { closestAttacker = u; } } } } catch (Exception) { } return(closestAttacker); }
private void Mostrarticket() { int Cantidad, ArtVendidos = 0;; double PUnit, Importe, sumar = 0; listDatos.Items.Add("\t\"" + NameTienda.ToUpper() + "\""); listDatos.Items.Add("TEL: " + TelTienda); listDatos.Items.Add("Nota de vta: " + NoVenta.ToString("D8")); listDatos.Items.Add("Fecha: " + DateTime.Now.ToShortDateString() + "\t Hora: " + DateTime.Now.ToString("hh:mm"));; listDatos.Items.Add("Atendido por: " + NameOperador); listDatos.Items.Add("Cantidad\tDescripción del producto"); listDatos.Items.Add("\t\tPrecio Unit.\tImporte"); listDatos.Items.Add("------------------------------------------------------------"); for (int i = 0; i < ListaProductos.Items.Count; i++) //Recorro la lista de productos vendidos y los imprimo en el formulario ticket { Cantidad = int.Parse(ListaProductos.Items[i].SubItems[1].Text); ArtVendidos += Cantidad; Importe = double.Parse(ListaProductos.Items[i].SubItems[3].Text, NumberStyles.Currency, CultureInfo.GetCultureInfo("en-US")); sumar += double.Parse(ListaProductos.Items[i].SubItems[3].Text, NumberStyles.Currency, CultureInfo.GetCultureInfo("en-US")); PUnit = Importe / Cantidad; listDatos.Items.Add(ListaProductos.Items[i].SubItems[1].Text + "\t" + ListaProductos.Items[i].SubItems[2].Text); listDatos.Items.Add("\t\t" + PUnit.ToString("C") + "\t\t" + ListaProductos.Items[i].SubItems[3].Text); } listDatos.Items.Add("------------------------------------------------------------"); listDatos.Items.Add("Total:\t\t\t\t" + sumar.ToString("C")); listDatos.Items.Add("Efectivo:\t\t\t\t" + Efectivo); listDatos.Items.Add(""); listDatos.Items.Add("Cambio:\t\t\t\t" + Cambio); listDatos.Items.Add("------------------------------------------------------------"); listDatos.Items.Add("Artículos vendidos:\t\t\t" + ArtVendidos); listDatos.Items.Add(Convert.ToDecimal(sumar).NumeroALetras().ToLower() + " M.N."); listDatos.Items.Add("------------------------------------------------------------"); listDatos.Items.Add("\t ¡EXCELENTE VENTA!"); ImprimirTicketTXT(); }
public override PullResult Pull(PUnit target) { //Logging.Debug("Pull started"); Buff(); PrePull(target); if (Behavior.UseAutoAttack) { target.InteractWithTarget(); } if (!MoveHelper.MoveToUnit(target, Behavior.PullDistance)) { return(PullResult.CouldNotPull); } if (Behavior.SendPet) { PetAttackKey.SendKey(); } foreach (Rule rule in Behavior.PullController.GetRules.Where(rule => rule.IsOk)) { target.Face(); rule.ExecuteAction(Behavior.GlobalCooldown); } // Logging.Debug("Pull done"); if (PPullBlackList.IsBlacklisted(target)) { return(PullResult.CouldNotPull); } return(PullResult.Success); }
private bool HasBuffByName(PUnit target, string buffIds) { string[] buffId = buffIds.Split(','); foreach (string s in buffId) { try { switch (OwnerCondition) { case BuffOwnerConditionEnum.Owner: if (target.HasBuff(s, true)) { return(true); } break; case BuffOwnerConditionEnum.NotOwner: if (target.HasBuff(s, false)) { return(true); } break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception) { //Logging.Write("Could not convert " + s + " to int when checking buffs - fix your BuffCondition: "); } } return(false); }
// ReSharper restore InconsistentNaming /// <summary> /// Determines whether the specified target is blacklisted. /// </summary> /// <param name = "target">The target.</param> /// <returns> /// <c>true</c> if the specified target is blacklisted; otherwise, <c>false</c>. /// </returns> public static bool IsBlacklisted(PUnit target) { try { lock (blacklist) { if (target != null && blacklist.ContainsKey("GUID" + target.GUID)) { TimeSpan diff = blacklist["GUID" + target.GUID] - DateTime.Now; if (diff.TotalSeconds > 0) { return(true); } Unblacklist(target); } } } catch (ThreadAbortException) { } catch (Exception e) { Logging.Write("PBlackList: " + e); } return(false); }
private void DoRotation() { List <Rule> rules = _rotation.Rules.GetRules; rules.Sort(); while (true) { try { if (ObjectManager.MyPlayer.HasTarget) { foreach (Rule rule in rules.Where(rule => rule.IsOk)) { PUnit pUnit = ObjectManager.MyPlayer.Target; if (pUnit.IsValid && pUnit.IsAlive) { rule.ExecuteAction(_rotation.GlobalCooldown); break; } } } Thread.Sleep(10); Application.DoEvents(); } catch (ThreadAbortException) { } catch (Exception e) { Logging.Write("Exception in rotation: " + e); } } }
private static bool IsValidTarget(PUnit unitTofind) { if (unitTofind.IsPlayer || unitTofind.IsTagged || unitTofind.IsDead || unitTofind.IsTotem) { return(false); } SubProfile currentProfile = GrindingEngine.CurrentProfile.GetSubProfile(); if (unitTofind.Level < currentProfile.MobMinLevel || unitTofind.Level > currentProfile.MobMaxLevel) { return(false); } if (currentProfile.Ignore != null) { if (currentProfile.Ignore.Any(tstIgnore => tstIgnore == unitTofind.Name)) { return(false); } } if (currentProfile.Factions != null) { if (currentProfile.Factions.Any(faction => unitTofind.Faction == faction)) { return(true); } } return(false); }
/// <summary> /// 让打架赛车面朝制定目标 /// </summary> /// <param name = "打架赛车的PUnit">The pos.</param> /// <returns></returns> public void MFace(PUnit mObj) { float face; if (LazyMath.NegativeAngle(AngleHorizontal - mObj.Facing) < Math.PI) { face = LazyMath.NegativeAngle(AngleHorizontal - mObj.Facing); bool moving = mObj.IsMoving; if (face > 1) { MoveHelper.ReleaseKeys(); moving = false; } FaceHorizontalWithTimer(face, "Left", moving); } else { face = LazyMath.NegativeAngle(mObj.Facing - AngleHorizontal); bool moving = mObj.IsMoving; if (face > 1) { MoveHelper.ReleaseKeys(); moving = false; } FaceHorizontalWithTimer(face, "Right", moving); } }
private void OnModuleLoaded(PUnit module) { st.ModulesLoading.Remove(module); if (st.ModulesLoading.Count <= 0) { StartGame(); } }
/// <summary> /// Unblacklists the specified target. /// </summary> /// <param name = "target">The target.</param> public static void Unblacklist(PUnit target) { if (target == null) { return; } lock (blacklist) { blacklist.Remove("GUID" + target.GUID); } Logging.Write("Removed: '" + target.GUID + " from badlist'"); }
private static void FindMobToPull() { while (true) { var tmpValidTargets = new List <PUnit>(); List <PUnit> units = ObjectManager.GetUnits; SubProfile currentSubprofile = GrindingEngine.CurrentProfile.GetSubProfile(); foreach (PUnit pUnit in units.Where(u => u.IsValid)) { try { if (IsValidTarget(pUnit) && !PPullBlackList.IsBlacklisted(pUnit) && !PBlackList.IsBlacklisted(pUnit) && pUnit.Target.Type != 4) { if (GrindingSettings.SkipMobsWithAdds) { List <PUnit> closeUnits = ObjectManager.CheckForMobsAtLoc(pUnit.Location, GrindingSettings. SkipAddsDistance, false); if (closeUnits.Count >= GrindingSettings.SkipAddsCount) { continue; } } PUnit unit = pUnit; if ( currentSubprofile.Spots.Any( s => unit.Location.DistanceFrom(s) < currentSubprofile.SpotRoamDistance)) { if (!pUnit.IsPet) //Do not move, takes a long time { tmpValidTargets.Add(pUnit); } } } } catch { } } IOrderedEnumerable <PUnit> sortednumQuery = from t in tmpValidTargets orderby t.Location.DistanceToSelf select t; ValidUnits = sortednumQuery.ToList(); Thread.Sleep(500); } }
/* * ConsiderAvoidAdds - Avoid Adds */ internal void ConsiderAvoidAdds(PUnit target) { bool petattacking = false; List <PUnit> closeUnits = ObjectManager.CheckForMobsAtLoc(target.Location, PveBehaviorSettings.SkipAddsDis + 5, false); if (closeUnits.Count == 0) { return; } PUnit closestAdd = GetClosestBesides(closeUnits, target); if (closestAdd == null) { return; } if (closestAdd.GUID == target.GUID) { return; } // Somebody is close enough to maybe jump in. If the monster is in front of us and close // enough, might be time to back it up. if (closestAdd.DistanceToSelf < Avoidaddsdistance) { Logging.Write("Possible add: " + closestAdd.Name + ": " + closestAdd.DistanceToSelf); _addBackup.Reset(); var futility = new Ticker(3000); closestAdd.Face(); MoveHelper.Backwards(true); if (ObjectManager.MyPlayer.HasLivePet) { petattacking = ObjectManager.MyPlayer.Pet.Target.IsValid; PetFollow.SendKey(); } while (!futility.IsReady) { Thread.Sleep(10); closestAdd.Face(); if (closestAdd.DistanceToSelf > Avoidaddsdistance + 6.0) // Slack space. { break; } } MoveHelper.Backwards(false); if (ObjectManager.MyPlayer.HasLivePet && petattacking) { PetAttackKey.SendKey(); } _addBackup.Reset(); } }
/* * internal static bool IsUsabelAction(int slot) * { * var foo = (uint)Pointers.ActionBar.IsUsableAction + (uint)slot * 0x04; * var isUsabelAction = Memory.Read<int>(ObjectManager.BaseAddressModule + foo); * foo = (uint)Pointers.ActionBar.IsUsableActionNoMana + (uint)slot * 0x04; * var isUsabelActionNoMana = Memory.Read<int>(ObjectManager.BaseAddressModule + foo); * * if (isUsabelAction == 0 && isUsabelActionNoMana == 0) * { * Logging.Write("Slot: " + slot + " is usabel"); * return true; * } * Logging.Write("Slot: " + slot + " is not usabel"); * return false; * } */ public static bool HasBuff(PUnit check, string name) { List <int> ids = GetIdsFromName(name); if (ObjectManager.Initialized) { if (check.HasBuff(ids)) { return(true); } } return(false); }
public void PrePull(PUnit target) { //Logging.Debug("Pre pull started"); if (target.DistanceToSelf > Behavior.PrePullDistance) { MoveHelper.MoveToUnit(target, Behavior.PrePullDistance); } foreach (Rule rule in Behavior.PrePullController.GetRules.Where(rule => rule.IsOk)) { rule.ExecuteAction(Behavior.GlobalCooldown); } //Logging.Debug("Pre pull done"); }
/// <summary> /// Blacklists the specified target. /// </summary> /// <param name = "target">The target.</param> /// <param name = "length">The length.</param> /// <param name = "writeText">if set to <c>true</c> [write text].</param> public static void Blacklist(PUnit target, uint length, bool writeText) { if (target == null) { return; } lock (blacklist) { blacklist["GUID" + target.GUID] = DateTime.Now.AddSeconds(length); } if (writeText) { Logging.Write("Added GUID: '" + target.GUID + "' to bad list for " + length + " seconds"); } }
public void UpdateTargetTabValues() { PUnit wu = ObjectManager.MyPlayer.Target; if (wu != null) { if (_wowTargetListViewItemArray != null && _wowTargetListViewItemArray.Length < 2) { InitializeTargetListViewItem(); } else { var targetPairs = new NameValuePair[] {}; if (wu.BaseAddress != 0) { if (wu.Type == 3) { targetPairs = GetTargetNameValuePairs(wu); } else if (wu.Type == 4) { var wpm = (PPlayer)wu; targetPairs = GetPlayerNameValuePairs(wpm); } if (_wowTargetListViewItemArray != null) { for (int j = 0; j < _wowTargetListViewItemArray.Length; j++) { try { _wowTargetListViewItemArray[j].SubItems.RemoveAt(1); _wowTargetListViewItemArray[j].SubItems.Add(targetPairs[j].Value); } catch { } } } } } } else { // erase the view when the target changes _wowTargetListViewItemArray = new ListViewItem[0]; listView2.Items.Clear(); } }
private static PUnit GetClosestBesides(IEnumerable <PUnit> list, PUnit ignore) { double closest = double.MaxValue; PUnit toReturn = null; foreach (PUnit pUnit in list) { if (pUnit.DistanceToSelf < closest && (ignore.GUID != pUnit.GUID) && !ignore.IsPet && !(pUnit.IsInCombat || pUnit.IsTargetingMe || pUnit.IsTargetingMyPet)) { closest = pUnit.DistanceToSelf; toReturn = pUnit; } } return(toReturn); }
public static void DoLootAfterCombat(PUnit unit) { if (GrindingSettings.Loot && !LazyLib.Wow.ObjectManager.ShouldDefend) { Thread.Sleep(500); if (!LazyLib.Wow.ObjectManager.MyPlayer.Target.IsValid && unit.IsLootable) { KeyHelper.SendKey("TargetLastTarget"); } Thread.Sleep(500); if (LazyLib.Wow.ObjectManager.MyPlayer.Target.IsValid) { DoWork(LazyLib.Wow.ObjectManager.MyPlayer.Target); } } }
public override void Combat(PUnit target) { if (Behavior.UseAutoAttack) { target.InteractWithTarget(); } if (Behavior.SendPet) { PetAttackKey.SendKey(); } //Logging.Debug("Combat started"); while (true) { try { if (target.DistanceToSelf > Behavior.CombatDistance) { MoveHelper.MoveToUnit(target, Behavior.CombatDistance); } } catch { } if (!ObjectManager.MyPlayer.IsValid || ObjectManager.MyPlayer.Target != target) { target.TargetHostile(); } if (PveBehaviorSettings.AvoidAddsCombat) { ConsiderAvoidAdds(target); } foreach (Rule rule in Behavior.CombatController.GetRules.Where(rule => rule.IsOk)) { if (target.IsValid && target.IsAlive) { if (!target.Location.IsFacing()) { target.Face(); } rule.ExecuteAction(Behavior.GlobalCooldown); break; } } Thread.Sleep(10); Application.DoEvents(); } }
public static Reaction GetReaction(PUnit localObj, PUnit mobObj) { try { if (localObj.Faction < 1 || mobObj.Faction < 1) { return(Reaction.Missing); } return(FindReactionFromFactions(localObj.Faction, mobObj.Faction)); } catch (Exception) { //Logging.Write("Exception when comparing: " + localObj.Name + " : " + mobObj.Name); return(Reaction.Missing); } }
private static void TrySpiritRess() { PUnit spirit = FindSpiritHealer(); if (spirit == null) { Thread.Sleep(8000); spirit = FindSpiritHealer(); if (spirit == null) { LazyHelpers.StopAll("Could not find spirit healer"); } } ApproachPosFlying.Approach(spirit.Location, 15); spirit.Face(); DoSpiritRess(spirit); }
private bool HasBuffId(PUnit target, string buffIds) { string[] buffId = buffIds.Split(','); foreach (string s in buffId) { try { switch (OwnerCondition) { case BuffOwnerConditionEnum.Owner: if (target.HasBuff(Convert.ToInt32(s), true)) { return(true); } break; case BuffOwnerConditionEnum.NotOwner: if (target.HasBuff(Convert.ToInt32(s), false)) { return(true); } break; case BuffOwnerConditionEnum.DoesNotMatter: if (target.HasBuff(Convert.ToInt32(s), false)) { return(true); } break; default: throw new ArgumentOutOfRangeException(); } } catch (ThreadAbortException) { } catch (Exception e) { Logging.Write("Error checking buff: " + e); } } return(false); }
private static void DoSpiritRess(PUnit vUnit) { Log("Going to accept ress sickness"); Ress(vUnit); Thread.Sleep(4000); if (ObjectManager.MyPlayer.IsDead || ObjectManager.MyPlayer.IsGhost) { Ress(vUnit); } if (ObjectManager.MyPlayer.IsDead || ObjectManager.MyPlayer.IsGhost) { Ress(vUnit); } if (!ObjectManager.MyPlayer.IsDead && !ObjectManager.MyPlayer.IsGhost) { return; } LazyHelpers.StopAll("Could not ress."); }
public static LazyLib.Wow.Reaction GetReaction(PUnit localObj, PUnit mobObj) { DBC <IntPtr> dbc = new DBC <IntPtr>((IntPtr)(uint)Pointers.Reaction.DBCPtrFactionTemplate); try { if ((localObj.Faction < 1) || (mobObj.Faction < 1)) { return(LazyLib.Wow.Reaction.Missing); } IntPtr rowPtr = dbc.GetRowPtr((int)localObj.Faction); IntPtr ptr2 = dbc.GetRowPtr((int)mobObj.Faction); return(CompareFactionHash((uint)((int)rowPtr), (uint)((int)ptr2))); } catch (Exception) { return(LazyLib.Wow.Reaction.Missing); } }
/// <summary> /// Gets the closest hostile unit /// </summary> /// <returns></returns> public static PUnit GetClosestUnit(List <PUnit> units) { PUnit toReturn = null; double distance = double.MaxValue; foreach (PUnit selectMonster in units) { if (!selectMonster.Reaction.Equals(Reaction.Hostile)) { continue; } if (selectMonster.Location.DistanceToSelf < distance) { toReturn = selectMonster; distance = selectMonster.Location.DistanceToSelf; } } return(toReturn); }
/// <summary> /// Targetings me or my pet. /// </summary> /// <param name = "u">The unit.</param> /// <returns></returns> public static bool TargetingMeOrPet(PUnit u) { if (u == null || MyPlayer == null) { return(false); } if (u.TargetGUID == MyPlayer.GUID) { return(true); } if (!MyPlayer.HasLivePet) { return(false); } if (u.TargetGUID == MyPlayer.PetGUID) { return(true); } return(false); }
private void BtnAddTrainerClick(object sender, EventArgs e) { if (ObjectManager.MyPlayer.Target != null) { PUnit tar = ObjectManager.MyPlayer.Target; var tr = new TrainerDialog(); tr.ShowDialog(); if (tr.Ok) { _pathProfile.NpcController.AddNpc(new VendorsEx(VendorType.Train, tar.Name, tar.Location, (TrainClass) Enum.Parse(typeof(TrainClass), tr.Class, true), tar.Entry)); LBTrainerCount.Text = _pathProfile.NpcController.Npc.Where(npc => npc.VendorType == VendorType.Train).ToList().Count. ToString(); } UpdateFields(_selected); } }
private static PUnit DefendAgainst() { PUnit defendUnit = null; if (ObjectManager.ShouldDefend) { if (!PBlackList.IsBlacklisted(ObjectManager.GetClosestAttacker)) { defendUnit = ObjectManager.GetClosestAttacker; } else { foreach (PUnit un in ObjectManager.GetAttackers.Where(un => !PBlackList.IsBlacklisted(un))) { defendUnit = un; } } return(defendUnit); } return(null); }
public virtual void LogicAttack(PUnit target) { try { DamageActions.Sort(); PAction pAction = (from a in DamageActions where a.IsWanted && (a.IsReady || a.WaitUntilReady) select a).FirstOrDefault(); if (pAction != null) { pAction.Execute(); } } catch (ThreadAbortException) { } catch (Exception e) { Log("Error in LogicAttack please check class code: " + e); } }