internal bool FightDecideFunction(PawnView monster) { var damageToMonster = (((double)Self.totalAttack / monster.TotalDefence) * MinDamage); if (damageToMonster >= monster.Health) { return(true); } var damageToSelf = (((double)monster.TotalAttack / Self.totalDefence) * MaxDamage); if (damageToSelf > Self.health) { return(false); } var safety = SafetyDecide; if (Self.level.Monsters.Count() == 1) { safety = SafetyLastLevelDecide; } var avgDamageToSelf = (((double)monster.TotalAttack / Self.totalDefence) * AvgDamage); if (avgDamageToSelf * safety < Self.health) { return(true); } else { return(false); } }
private bool SelectTargetMonster(ref PawnView target) { if (target.HasValue) { return(true); } if (Self.level.Monsters.Any(Self.IsInAttackRange)) { target = Self.level.Monsters .Where(Self.IsInAttackRange) .OrderBy(m => m.Health) .ThenBy(m => m.Attack) .ThenBy(m => m.Defence) .First(); return(true); } else { target = Self.level.Monsters .OrderBy(m => Self.playerLocation.Distance(m.Location)) .ThenBy(m => m.Health) .ThenBy(m => m.Attack) .ThenBy(m => m.Defence) .FirstOrDefault(); return(target.HasValue); } }
private void ResetTarget(ref PawnView target) { if (target.IsDestroyed || level.Monsters.Any(m => playerLocation.Distance(m.Location) <= ResetDistance && m.Location != targetMonster.Location)) { target = default(PawnView); } }
public static bool IsBetter(this ItemView item, PawnView me) { var ab = me.TotalAttack - me.Attack; var db = me.TotalDefence - me.Defence; var tb = Math.Max(ab, db); var itb = Math.Max(item.AttackBonus, item.DefenceBonus); return(tb < itb || tb == itb && (ab + db) < (item.AttackBonus + item.DefenceBonus)); }
public MonsterFightInfo(PawnView monster, PawnView slave) { Info = monster; // худший вариант для раба, лучший для моба DamageToSlave = monster.TotalAttack * monster.Attack / slave.TotalDefence; DamageFromSlave = (int)(slave.TotalAttack * slave.Attack * 0.9 / monster.TotalDefence); HitsToKillSlave = slave.Health / DamageToSlave; HitsToDeath = monster.Health / DamageFromSlave; IsSaveToKill = HitsToKillSlave > HitsToDeath - 1; }
private Turn Attack(LevelView levelView, PawnView monster) { if (monster.HasValue) { return(Turn.Attack(monster.Location - levelView.Player.Location)); } var nearbyMonster = GetNearbyMonster(levelView, monster.Location); if (nearbyMonster.HasValue) { return(Turn.Attack(nearbyMonster.Location - levelView.Player.Location)); } return(null); }
private int CalculateMonsterInfluence(PawnView monster, Location location, int influenceSeed) { if (levelView.GetHealthPackAt(location).HasValue) { return(0); } if (monster.Location.IsInRange(location, 1)) { return(influenceSeed); } var offsetToMonster = monster.Location - location; return(influenceSeed / (int)Math.Pow(2, offsetToMonster.Size() - 1)); }
internal bool IsInAttackRange(PawnView other) { return(playerLocation.IsInAttackRange(other.Location)); }
public static int PawnHealphInSeconds(this PawnView defender, IList <PawnView> attacker, double radius = 5) { var aDPS = attacker.Select(m => m.PawnDPS(defender)).Sum(); return((int)Math.Floor(defender.Health / (aDPS == 0 ? 1 : aDPS)) + attacker.Min(a => a.Location.Distance(defender.Location))); }
public static int PawnHealphInSeconds(this PawnView defender, PawnView attacker) { var aDPS = attacker.PawnDPS(defender); return((int)Math.Floor(defender.Health / (aDPS == 0 ? 1 : aDPS))); }
public static double PawnDPS(this PawnView attacker, PawnView defender) { var dps = (attacker.TotalAttack / defender.TotalDefence) * BaseDamage; return(dps < 0 ? 0 : dps); }