protected override int GetNextSpawnInterval() { var rand = new AsyncRandom(); if (rand.Next(0, 2) == 0) { return((int)((Interval - (rand.NextDouble() * Interval / 4)) * 1000)); } return((int)((Interval + (rand.NextDouble() * Interval / 4)) * 1000)); }
public FightSpellCastCriticalEnum RollCriticalDice(SpellLevelRecord spell) { AsyncRandom asyncRandom = new AsyncRandom(); FightSpellCastCriticalEnum result = FightSpellCastCriticalEnum.NORMAL; if (spell.CriticalHitProbability != 0u && asyncRandom.Next((int)this.CalculateCriticRate(spell.CriticalHitProbability)) == 0) { result = FightSpellCastCriticalEnum.CRITICAL_HIT; } return(result); }
public FightSpellCastCriticalEnum RollCriticalDice(WeaponRecord weapon) { AsyncRandom asyncRandom = new AsyncRandom(); FightSpellCastCriticalEnum result = FightSpellCastCriticalEnum.NORMAL; int num = (int)this.CalculateCriticRate(weapon.CriticalHitProbability) / 6; if (weapon.CriticalHitProbability != 0 && asyncRandom.Next(num) == 0) { result = FightSpellCastCriticalEnum.CRITICAL_HIT; } return(result); }
public static string GetRandomString(int length) { var random = new AsyncRandom(); string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; StringBuilder result = new StringBuilder(length); for (int i = 0; i < length; i++) { result.Append(characters[random.Next(characters.Length)]); } return(result.ToString()); }
/// <summary> /// Spawn les groupes de monstres d'une carte. /// </summary> /// <param name="map"></param> public void SpawnMonsters(MapRecord map) { AsyncRandom random = new AsyncRandom(); if (map.MonsterSpawnsSubArea.Length > 0) { for (sbyte groupId = 0; groupId < random.Next(1, MaxMonsterGroupPerMap + 1); groupId++) { AddGeneratedMonsterGroup(map.Instance, map.MonsterSpawnsSubArea, true); } } }
public TaxCollectorNpc(int globalId, int contextId, ObjectPosition position, Guild guild, string callerName) { AsyncRandom asyncRandom = new AsyncRandom(); this.m_contextId = contextId; this.Position = position; this.Guild = guild; this.Bag = new TaxCollectorBag(this); this.m_record = new WorldMapTaxCollectorRecord { Id = globalId, Map = this.Position.Map, Cell = (int)this.Position.Cell.Id, Direction = (int)this.Position.Direction, FirstNameId = (short)asyncRandom.Next(1, 154), LastNameId = (short)asyncRandom.Next(1, 253), GuildId = guild.Id, CallerName = callerName, Date = System.DateTime.Now }; this.IsRecordDirty = true; }
public FightSpellCastCriticalEnum RollCriticalDice(WeaponTemplate weapon) { AsyncRandom asyncRandom = new AsyncRandom(); FightSpellCastCriticalEnum result = FightSpellCastCriticalEnum.NORMAL; if (weapon.CriticalHitProbability != 0u && asyncRandom.Next(100) < this.CalculateCriticRate((uint)weapon.CriticalHitProbability)) { result = FightSpellCastCriticalEnum.CRITICAL_HIT; } return(result); }
protected override int GetNextSpawnInterval() { AsyncRandom asyncRandom = new AsyncRandom(); int result; if (asyncRandom.Next(0, 2) == 0) { result = (int)(((double)base.Interval - asyncRandom.NextDouble() * (double)base.Interval / 4.0) * 1000.0); } else { result = (int)(((double)base.Interval + asyncRandom.NextDouble() * (double)base.Interval / 4.0) * 1000.0); } return(result); }
public override EffectBase GenerateEffect(EffectGenerationContext context, EffectGenerationType type = EffectGenerationType.Normal) { var rand = new AsyncRandom(); if (type == EffectGenerationType.MaxEffects && Template.Operator == "+") { return(new EffectInteger(Id, Template.Operator != "-" ? ValueMax : ValueMin, this)); } if (type == EffectGenerationType.MinEffects) { return(new EffectInteger(Id, Template.Operator != "-" ? ValueMin : ValueMax, this)); } return(new EffectInteger(Id, (short)rand.Next(ValueMin, ValueMax + 1), this)); }
public override IEnumerable <DroppedItem> RollLoot(int teamPp, int dropBonusPercent) { if (this.Alive) { return(new DroppedItem[0]); } AsyncRandom asyncRandom = new AsyncRandom(); List <DroppedItem> list = new List <DroppedItem>(); int prospectingSum = this.OposedTeam().GetFighters <CharacterFighter>().Sum(entry => entry.Stats.Prospecting.TotalInContext()); IEnumerable <MonsterDrop> monsterDroppableItems = from droppableItem in this.Template.Drops where prospectingSum >= droppableItem.ProspectingLock && !droppableItem.HasCriteria select droppableItem; foreach (MonsterDrop droppableItem in monsterDroppableItems) { int attempts = 0; while (attempts < droppableItem.Count && (droppableItem.DropLimit <= 0 || !this.m_dropsCount.ContainsKey(droppableItem) || this.m_dropsCount[droppableItem] < droppableItem.DropLimit)) { double randomDropThreshold = asyncRandom.Next(0, 100) + asyncRandom.NextDouble(); double randomDropChance = FormulasProvider.Instance.AdjustDropChance(teamPp, droppableItem, this.GradeId, this.Fight.AgeBonus, dropBonusPercent); // Probability to drop if (randomDropChance >= randomDropThreshold) { // Item dropped, add it to list list.Add(new DroppedItem(droppableItem.ItemId, 1u)); // Update the map for while conditions if (!this.m_dropsCount.ContainsKey(droppableItem)) { this.m_dropsCount.Add(droppableItem, 1); } else { Dictionary <MonsterDrop, int> dropsCount; MonsterDrop key; (dropsCount = this.m_dropsCount)[key = droppableItem] = dropsCount[key] + 1; } } attempts++; } } return(list); }
public override IEnumerable <DroppedItem> RollLoot(IFightResult looter, int dropBonusPercent) { IEnumerable <DroppedItem> result; if (Alive) { result = new DroppedItem[0]; } else { AsyncRandom asyncRandom = new AsyncRandom(); List <DroppedItem> list = new List <DroppedItem>(); int prospectingSum = base.OposedTeam().GetFighters <CharacterFighter>().Sum((CharacterFighter entry) => entry.Stats.Prospecting.TotalInContext()); foreach (var current in from droppableItem in base.Template.Drops where prospectingSum >= droppableItem.ProspectingLock && !droppableItem.HasCriteria select droppableItem) { int num = 0; while (num < current.Count && (current.DropLimit <= 0 || !this.m_dropsCount.ContainsKey(current) || this.m_dropsCount[current] < current.DropLimit)) { var deci = asyncRandom.NextDouble(); double num2 = (double)asyncRandom.Next(0, 100) + deci; double num3 = FormulasProvider.Instance.AdjustDropChance(looter, current, GradeId, (int)base.Fight.AgeBonus, dropBonusPercent); if (num3 >= num2) { list.Add(new DroppedItem(current.ItemId, 1u)); if (!this.m_dropsCount.ContainsKey(current)) { this.m_dropsCount.Add(current, 1); } else { System.Collections.Generic.Dictionary <MonsterDrop, int> dropsCount; MonsterDrop key; (dropsCount = this.m_dropsCount)[key = current] = dropsCount[key] + 1; } } num++; } } result = list; } return(result); }
public static IEnumerable <T> Shuffle <T>(this IEnumerable <T> enumerable) { var rand = new AsyncRandom(); var elements = enumerable.ToArray(); // Note i > 0 to avoid final pointless iteration for (var i = elements.Length - 1; i > 0; i--) { // Swap element "i" with a random earlier element it (or itself) var swapIndex = rand.Next(i + 1); var tmp = elements[i]; elements[i] = elements[swapIndex]; elements[swapIndex] = tmp; } // Lazily yield (avoiding aliasing issues etc) return(elements); }
public override System.Collections.Generic.IEnumerable <DroppedItem> RollLoot(IFightResult looter, int challengeBonus) { System.Collections.Generic.IEnumerable <DroppedItem> result; if (!base.IsDead()) { result = new DroppedItem[0]; } else { AsyncRandom asyncRandom = new AsyncRandom(); System.Collections.Generic.List <DroppedItem> list = new System.Collections.Generic.List <DroppedItem>(); int prospectingSum = base.OpposedTeam.GetAllFighters <CharacterFighter>().Sum((CharacterFighter entry) => entry.Stats[PlayerFields.Prospecting].Total); foreach (DroppableItem current in from droppableItem in this.Monster.Template.DroppableItems where prospectingSum >= droppableItem.ProspectingLock select droppableItem) { int num = 0; while (num < current.RollsCounter && (current.DropLimit <= 0 || !this.m_dropsCount.ContainsKey(current) || this.m_dropsCount[current] < current.DropLimit)) { double num2 = (double)asyncRandom.Next(0, 100) + asyncRandom.NextDouble(); double num3 = FightFormulas.AdjustDropChance(looter, current, this.Monster, this.Fight.GetFightBonus()); if (num3 >= num2) { list.Add(new DroppedItem((int)current.ItemId, 1u)); if (!this.m_dropsCount.ContainsKey(current)) { this.m_dropsCount.Add(current, 1); } else { System.Collections.Generic.Dictionary <DroppableItem, int> dropsCount; DroppableItem key; (dropsCount = this.m_dropsCount)[key = current] = dropsCount[key] + 1; } } num++; } } result = list; } return(result); }
public static T[] Random <T>(this IEnumerable <T> enumerable, int count) { T[] array = new T[count]; int lenght = enumerable.Count(); if (lenght <= 0) { return(new T[0]); } var random = new AsyncRandom(); for (int i = 0; i < count; i++) { array[i] = enumerable.ElementAt(random.Next(lenght)); } return(array); }
public int RollMonsterGrade(int minGrade, int maxGrade) { var difficulty = Difficulty; if (!MonsterGroupLengthProb.ContainsKey(difficulty)) { difficulty = Difficulty.Normal; } var threshold = MonsterGroupLengthProb[difficulty].Skip(minGrade - 1).Take(maxGrade - minGrade + 1).ToArray(); var sum = threshold.Sum(); var rand = new AsyncRandom(); var roll = rand.NextDouble(0, sum); double l = 0; for (var i = 0; i < threshold.Length; i++) { l += threshold[i]; if (!(roll <= l)) { continue; } // in case of additional grades if (i < threshold.Length - 1 || maxGrade <= threshold.Length) { return(i + 1); } var secondRoll = rand.Next(0, maxGrade - threshold.Length + 1); return(i + secondRoll + 1); } return(1); }
public override EffectBase GenerateEffect(EffectGenerationContext context, EffectGenerationType type = EffectGenerationType.Normal) { AsyncRandom asyncRandom = new AsyncRandom(); EffectBase result; if (type == EffectGenerationType.MaxEffects) { result = new EffectInteger(base.Id, (base.Template.Operator != "-") ? this.ValueMax : this.ValueMin, this); } else { if (type == EffectGenerationType.MinEffects) { result = new EffectInteger(base.Id, (base.Template.Operator != "-") ? this.ValueMin : this.ValueMax, this); } else { result = new EffectInteger(base.Id, (short)asyncRandom.Next((int)this.ValueMin, (int)(this.ValueMax + 1)), this); } } return(result); }
public override EffectBase GenerateEffect(EffectGenerationContext context, EffectGenerationType type = EffectGenerationType.Normal) { AsyncRandom asyncRandom = new AsyncRandom(); short num = (this.m_dicenum >= this.m_diceface) ? this.m_dicenum : this.m_diceface; short num2 = (this.m_dicenum <= this.m_diceface) ? this.m_dicenum : this.m_diceface; EffectBase result; if (type == EffectGenerationType.MaxEffects) { result = new EffectInteger(base.Id, (base.Template.Operator != "-") ? num : num2, this); } else { if (type == EffectGenerationType.MinEffects) { result = new EffectInteger(base.Id, (base.Template.Operator != "-") ? num2 : num, this); } else { if (num2 == 0) { if (num == 0) { result = new EffectInteger(base.Id, this.m_value, this); } else { result = new EffectInteger(base.Id, num, this); } } else { result = new EffectInteger(base.Id, (short)asyncRandom.Next((int)num2, (int)(num + 1)), this); } } } return(result); }
public void GenerateDamages() { if (!this.Generated) { switch (this.EffectGenerationType) { case EffectGenerationType.MaxEffects: this.Amount = this.BaseMaxDamages; break; case EffectGenerationType.MinEffects: this.Amount = this.BaseMinDamages; break; default: { AsyncRandom asyncRandom = new AsyncRandom(); this.Amount = asyncRandom.Next(this.BaseMinDamages, this.BaseMaxDamages + 1); break; } } } }
public override IEnumerable <DroppedItem> RollLoot(IFightResult looter) { // have to be dead before if (!IsDead()) { return(new DroppedItem[0]); } var random = new AsyncRandom(); var items = new List <DroppedItem>(); var prospectingSum = OpposedTeam.GetAllFighters <CharacterFighter>().Sum(entry => entry.Stats[PlayerFields.Prospecting].Total); var droppedGroups = new List <int>(); foreach (var droppableItem in Monster.Template.DroppableItems.Where(droppableItem => prospectingSum >= droppableItem.ProspectingLock).Shuffle()) { if (droppedGroups.Contains(droppableItem.DropGroup)) { continue; } if (looter is TaxCollectorProspectingResult && droppableItem.TaxCollectorCannotLoot) { continue; } for (var i = 0; i < droppableItem.RollsCounter; i++) { if (droppableItem.DropLimit > 0 && m_dropsCount.ContainsKey(droppableItem) && m_dropsCount[droppableItem] >= droppableItem.DropLimit) { break; } var chance = (random.Next(0, 100) + random.NextDouble()); var dropRate = FightFormulas.AdjustDropChance(looter, droppableItem, Monster, Fight.AgeBonus); if (!(dropRate >= chance)) { continue; } if (droppableItem.DropGroup != 0) { droppedGroups.Add(droppableItem.DropGroup); } items.Add(new DroppedItem(droppableItem.ItemId, 1)); if (!m_dropsCount.ContainsKey(droppableItem)) { m_dropsCount.Add(droppableItem, 1); } else { m_dropsCount[droppableItem]++; } } } return(items); }
public static GameRolePlayGroupMonsterInformations GetActorInformations(MapRecord map, MonsterGroup group) { var random = new AsyncRandom(); var firstMonster = group.Monsters[0]; var firstMonsterTemplate = MonsterRecord.GetMonster(firstMonster.MonsterId); var light = new MonsterInGroupLightInformations(firstMonsterTemplate.Id, (sbyte)random.Next(1, 6)); List <MonsterInGroupInformations> monstersinGroup = new List <MonsterInGroupInformations>(); for (int i = 1; i < group.Monsters.Count; i++) { var mob = group.Monsters[i]; var template = MonsterRecord.GetMonster(mob.MonsterId); monstersinGroup.Add(new MonsterInGroupInformations(mob.MonsterId, mob.ActualGrade, template.RealLook.ToEntityLook())); } var staticInfos = new GroupMonsterStaticInformations(light, monstersinGroup); return(new GameRolePlayGroupMonsterInformations(group.MonsterGroupId, firstMonsterTemplate.RealLook.ToEntityLook(), new EntityDispositionInformations((short)group.CellId, 3), false, false, false, staticInfos, group.AgeBonus, 0, 0)); }
public sbyte RandomGrade(AsyncRandom random) { sbyte value = (sbyte)(random.Next(1, Grades.Count + 1)); return(value); }
public override void Start() { base.Start(); Thread.Sleep(3000); Interop.CenterProcessWindow(LeagueConstants.LoL_GAME_PROCESS); Summoner.LockCamera(); Thread.Sleep(1000); Bot.LeftClick(PixelsConstants.SHOP_BUTTON); Thread.Sleep(500); Bot.RightClick(PixelsConstants.SHOP_ITEM1); Thread.Sleep(1000); Bot.RightClick(PixelsConstants.SHOP_ITEM2); Thread.Sleep(500); Keyboard.KeyPress(Keys.Escape); Thread.Sleep(5000); Summoner.Talk("Hi team"); Summoner.MaxE(); Thread.Sleep(500); Summoner.MaxQ(); Thread.Sleep(500); Summoner.MaxZ(); Thread.Sleep(500); Summoner.Move(PixelsConstants.HOWLING_ABYSS_BUSH1); Summoner.Wait(20); bool playing = true; while (playing) { if (!Interop.IsProcessOpen(Pattern.ProcessName)) { playing = false; Pattern.OnProcessClosed(); } else { if (Side == Side.Blue) { Summoner.Move(PixelsConstants.HOWLING_ABYSS_BLUE_T1); } else { Summoner.Move(PixelsConstants.HOWLING_ABYSS_RED_T1); } Thread.Sleep(2000); Point blueSideAim = new Point(1085, 431); Point redSideAim = new Point(790, 590); Point target = Side == Side.Blue ? blueSideAim : redSideAim; Summoner.Q(); Thread.Sleep(500); Mouse.Move(target.X, target.Y); Summoner.E(); Thread.Sleep(500); Mouse.Move(target.X, target.Y); Summoner.Z(); Thread.Sleep(500); Mouse.Move(target.X, target.Y); Summoner.R(); if (Side == Side.Blue) { Summoner.Move(PixelsConstants.HOWLING_ABYSS_REDNEXUS); } else { Summoner.Move(PixelsConstants.HOWLING_ABYSS_BLUENEXUS); } Thread.Sleep(3000); AsyncRandom rd = new AsyncRandom(); int shiftX = rd.Next(-3, 3); int shiftY = rd.Next(-3, 3); var closeRandomPt = new Point(Summoner.Position.X + shiftX, Summoner.Position.Y + shiftY); Bot.RightClick(closeRandomPt); Thread.Sleep(1000); Summoner.Summoner1(); Summoner.Summoner2(); } } }
public override void Start() { string[] greetings = { "hi team gl", "gl guys", "glhf", "glgl", "have fun", "good luck have fun", "good luck", "GL&HF", "hope no1 will be afk gl guys", "nice gl" }; Random rand = new Random(); int index = rand.Next(greetings.Length); // base.Start(); Thread.Sleep(3000); //Interop.CenterProcessWindow(LeagueConstants.LoL_GAME_PROCESS); Interop.Set0x0Position(LeagueConstants.LOL_GAME_PROCESS); Summoner.LockCamera(); Thread.Sleep(1000); Bot.LeftClick(PixelsConstants.SHOP_BUTTON); Thread.Sleep(500); Bot.RightClick(PixelsConstants.SHOP_ITEM1); Thread.Sleep(1000); Bot.RightClick(PixelsConstants.SHOP_ITEM2); Thread.Sleep(500); Keyboard.KeyPress(Keys.Escape); Thread.Sleep(5000); Summoner.Talk($"{greetings[index]}"); Summoner.MaxE(); Thread.Sleep(500); Summoner.MaxQ(); Thread.Sleep(500); Summoner.MaxZ(); Thread.Sleep(500); Summoner.Move(PixelsConstants.HOWLING_ABYSS_BUSH1); Summoner.Wait(20); bool playing = true; while (playing) { if (!Interop.IsProcessOpen(Pattern.ProcessName)) { playing = false; Pattern.OnProcessClosed(); } else { if (Side == Side.Blue) { Summoner.Move(PixelsConstants.HOWLING_ABYSS_BLUE_T1); } else { Summoner.Move(PixelsConstants.HOWLING_ABYSS_RED_T1); } Thread.Sleep(2000); // dodac randomizacje punktow do rzucania skilli Point blueSideAim = new Point(1085, 431); Point redSideAim = new Point(790, 590); // Point target = Side == Side.Blue ? blueSideAim : redSideAim; Summoner.Q(); Thread.Sleep(500); Mouse.Move(target.X, target.Y); Summoner.E(); Thread.Sleep(500); Mouse.Move(target.X, target.Y); Summoner.Z(); Thread.Sleep(500); Mouse.Move(target.X, target.Y); Summoner.R(); if (Side == Side.Blue) { Summoner.Move(PixelsConstants.HOWLING_ABYSS_REDNEXUS); } else { Summoner.Move(PixelsConstants.HOWLING_ABYSS_BLUENEXUS); } Thread.Sleep(3000); AsyncRandom rd = new AsyncRandom(); int shiftX = rd.Next(-3, 3); int shiftY = rd.Next(-3, 3); var closeRandomPt = new Point(Summoner.Position.X + shiftX, Summoner.Position.Y + shiftY); Bot.RightClick(closeRandomPt); Thread.Sleep(1000); Summoner.Summoner1(); Summoner.Summoner2(); } } }
public override uint GetDroppedKamas() { AsyncRandom asyncRandom = new AsyncRandom(); return((uint)asyncRandom.Next(base.Template.MinDroppedKamas, base.Template.MaxDroppedKamas + 1)); }
public void GeneratePVMLoot() { if ((Fighter as CharacterFighter).HasLeft) { return; } #region VariableDefinitions WorldClient client = (Fighter as CharacterFighter).Client; AsyncRandom random = new AsyncRandom(); FightPvM pvmfight = Fighter.Fight as FightPvM; #endregion #region Kamas & Items Generation List <DroppedItem> m_drops = new List <DroppedItem>(); foreach (var monster in pvmfight.MonsterGroup.Monsters) { var template = MonsterRecord.GetMonster(monster.MonsterId); var grade = template.GetGrade(monster.ActualGrade); #region kamas int droppedKamas = random.Next(template.MinKamas, template.MaxKamas + 1); FightLoot.kamas += (uint)(droppedKamas * ConfigurationManager.Instance.KamasDropRatio); #endregion #region items List <CharacterFighter> charactersFighters = Fighter.Team.GetFighters().FindAll(x => x is CharacterFighter).ConvertAll <CharacterFighter>(x => (CharacterFighter)x); int prospectingSum = charactersFighters.Sum((CharacterFighter entry) => entry.Client.Character.StatsRecord.Prospecting); foreach (var item in template.Drops.FindAll(x => x.ProspectingLock <= prospectingSum)) { int D = random.Next(0, 201); double dropchancePercent = item.GetDropRate(monster.ActualGrade) + pvmfight.MonsterGroup.AgeBonus / 5 + client.Character.StatsRecord.Prospecting / 100; if (D <= dropchancePercent) { var alreadyDropped = m_drops.FirstOrDefault(x => x.GID == item.ObjectId); if (alreadyDropped == null) { uint dropMax = GetQuantityDropMax(); uint Q = (uint)random.Next(1, (int)(dropMax + 1)); if (Q > item.Count) { Q = 1; } m_drops.Add(new DroppedItem(item.ObjectId, Q)); } else { alreadyDropped.Quantity++; } } } #endregion } #endregion client.Character.AddKamas((int)FightLoot.kamas); foreach (var item in m_drops) { FightLoot.objects.Add(item.GID); FightLoot.objects.Add((ushort)item.Quantity); client.Character.Inventory.Add(item.GID, item.Quantity, false, false); } #region Experience Provider List <MonsterData> monsters = new List <MonsterData>(); foreach (var monster in pvmfight.MonsterGroup.Monsters) { var grade = MonsterRecord.GetMonster(monster.MonsterId).GetGrade(monster.ActualGrade); monsters.Add(new MonsterData(grade.Level, (int)grade.GradeXp)); } var team = Fighter.Team.GetFighters().FindAll(x => x is CharacterFighter).ConvertAll <CharacterFighter>(x => (CharacterFighter)x);; ExperienceFormulas formulas = new ExperienceFormulas(); formulas.InitXpFormula(new PlayerData(client.Character.Record.Level, client.Character.StatsRecord.Wisdom), monsters, team.ConvertAll <GroupMemberData>(x => new GroupMemberData(x.Client.Character.Record.Level, false)), pvmfight.MonsterGroup.AgeBonus); if (client.Character.Record.Level >= 200) { formulas._xpSolo = 0; } client.Character.AddXp((ulong)formulas._xpSolo); PlayerLevel = client.Character.Record.Level; var expdatas = new FightResultExperienceData(true, true, true, true, false, false, false, client.Character.Record.Exp, ExperienceRecord.GetExperienceForLevel(client.Character.Record.Level), ExperienceRecord.GetExperienceForLevel((uint)client.Character.Record.Level + 1), (int)formulas._xpSolo, 0, 0, 0); AdditionalDatas.Add(expdatas); #endregion client.Character.Inventory.Refresh(); client.Character.RefreshShortcuts(); }
public override uint GetDroppedKamas() { var random = new AsyncRandom(); return((uint)random.Next(Monster.Template.MinDroppedKamas, Monster.Template.MaxDroppedKamas + 1)); }