Example #1
0
        /// <summary>
        /// Performs the attack
        /// </summary>
        /// <returns>
        /// a result of the attack
        /// </returns>
        public override ICombatResult CalculateAttack()
        {
            int randomNumber = this.Random.Next(100);
            if (randomNumber < (this.GetFinalHitChance() - Target.BaseEvadeChance))
            {
                ICombatResult result = new HitResult { InflictedDamage = Attacker.BaseDamage, AbsorbedDamage = Target.BaseArmor };
                return result;
            }

            return new MissResult();
        }
Example #2
0
        public ArcBounds(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            ICanvas canvas,
            IArc arc,
            double size,
            double offset)
        {
            _arc = arc;
            _size = size;
            _offset = offset;
            _canvas = canvas;

            _hitResult = HitResult.None;

            InitBounds(nativeConverter, canvasFactory);
        }
Example #3
0
        public static float TargetAvoidanceChance(int attackerLevel, float spellPenetration, HitResult avoidanceType, int targetLevel)
        {
            switch (avoidanceType)
            {

                case HitResult.Miss:   return StatConversion.WHITE_MISS_CHANCE_CAP[  targetLevel - attackerLevel];
                case HitResult.Dodge : return StatConversion.WHITE_DODGE_CHANCE_CAP[ targetLevel - attackerLevel];
                case HitResult.Parry : return StatConversion.WHITE_PARRY_CHANCE_CAP[ targetLevel - attackerLevel];
                case HitResult.Glance: return StatConversion.WHITE_GLANCE_CHANCE_CAP[targetLevel - attackerLevel];
                case HitResult.Block : return StatConversion.WHITE_BLOCK_CHANCE_CAP[ targetLevel - attackerLevel];
                case HitResult.Resist:
                    // Patial resists don't belong in the combat table, they are a damage multiplier (reduction)
                    // The Chance to get any Partial Resist
                    float partialChance = 1.0f - StatConversion.GetResistanceTable(attackerLevel, targetLevel, 0.0f, spellPenetration)[0];
                    return partialChance;
                default: return 0.0f;
            }
        }
Example #4
0
 public static float TargetAvoidanceChance(Player player, HitResult avoidanceType)
 {
     switch (avoidanceType)
     {
         case HitResult.Miss:
             return StatConversion.WHITE_MISS_CHANCE_CAP[player.BossOpts.Level - 85];
         case HitResult.Dodge:
             return StatConversion.YELLOW_DODGE_CHANCE_CAP[player.BossOpts.Level - 85];
         case HitResult.Parry:
             return StatConversion.YELLOW_PARRY_CHANCE_CAP[player.BossOpts.Level - 85];
         case HitResult.Glance:
             return 0.06f + ((player.BossOpts.Level - player.Character.Level) * 0.06f);
         case HitResult.Crit:
             return -StatConversion.NPC_LEVEL_CRIT_MOD[player.BossOpts.Level - player.Character.Level]; // StatConversion returns as negative
         default:
             return 0.0f;
     }
 }
Example #5
0
 protected override double HealthIncreaseFor(HitResult result) => base.HealthIncreaseFor(result) * 2;
Example #6
0
    private void SearchInDirection(DetectionDirection direction, Vector3 dirVector, float range, ref HitResult result)
    {
        RaycastHit2D hit = Physics2D.Raycast(transform.position + dirVector, dirVector, range, 0b1100000000);

        if (hit.collider)
        {
            if (hit.collider.gameObject.tag == "Player" ||
                hit.collider.gameObject.tag == "Item")
            {
                result.resultDirection = direction;
                result.hitPos          = hit.collider.bounds.center;
                result.hitDir          = hit.collider.gameObject.transform.right;
                result.hitObj          = hit.collider.gameObject.tag;
            }
        }
    }
Example #7
0
 public HitTestEventArgs(Point location, HitResult hitResult)
 {
     Location  = location;
     HitResult = hitResult;
 }
Example #8
0
 public static bool IsScorable(this HitResult result) => result >= HitResult.Miss && result < HitResult.IgnoreMiss;
Example #9
0
 public static bool AffectsAccuracy(this HitResult result)
 => IsScorable(result) && !IsBonus(result);
 public HitTestEventArgs(Point location, HitResult hitResult) {
   Location = location;
   HitResult = hitResult;
 }
Example #11
0
 public bool Contains(double x, double y)
 {
     if (_polygonStart.Contains(x, y))
     {
         _hitResult = HitResult.Start;
         return true;
     }
     else if (_polygonPoint1.Contains(x, y))
     {
         _hitResult = HitResult.Point1;
         return true;
     }
     else if (_polygonPoint2.Contains(x, y))
     {
         _hitResult = HitResult.Point2;
         return true;
     }
     else if (_polygonPoint3.Contains(x, y))
     {
         _hitResult = HitResult.Point3;
         return true;
     }
     else if (ConvexHullAsPolygonContains(x, y)) //_polygonBezier.Contains(x, y)
     {
         _hitResult = HitResult.Bezier;
         return true;
     }
     _hitResult = HitResult.None;
     return false;
 }
Example #12
0
 public void TestIsScorable(HitResult hitResult, bool expectedReturnValue)
 {
     Assert.AreEqual(expectedReturnValue, hitResult.IsScorable());
 }
Example #13
0
 public void TestAffectsAccuracy(HitResult hitResult, bool expectedReturnValue)
 {
     Assert.AreEqual(expectedReturnValue, hitResult.AffectsAccuracy());
 }
Example #14
0
 public void TestMinResults(HitResult hitResult, HitResult expectedMinResult)
 {
     Assert.AreEqual(expectedMinResult, new TestJudgement(hitResult).MinResult);
 }
Example #15
0
        public void TestFourVariousResultsOneMiss(ScoringMode scoringMode, HitResult hitResult, HitResult maxResult, int expectedScore)
        {
            var minResult = new TestJudgement(hitResult).MinResult;

            IBeatmap fourObjectBeatmap = new TestBeatmap(new RulesetInfo())
            {
                HitObjects = new List <HitObject>(Enumerable.Repeat(new TestHitObject(maxResult), 4))
            };

            scoreProcessor.Mode.Value = scoringMode;
            scoreProcessor.ApplyBeatmap(fourObjectBeatmap);

            for (int i = 0; i < 4; i++)
            {
                var judgementResult = new JudgementResult(fourObjectBeatmap.HitObjects[i], new Judgement())
                {
                    Type = i == 2 ? minResult : hitResult
                };
                scoreProcessor.ApplyResult(judgementResult);
            }

            Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(expectedScore).Within(0.5d));
        }
Example #16
0
 public TestJudgement(HitResult maxResult = HitResult.Perfect)
 {
     MaxResult = maxResult;
 }
Example #17
0
 /// <summary>
 /// Retrieves the numeric score representation of a <see cref="HitResult"/>.
 /// </summary>
 /// <param name="result">The <see cref="HitResult"/> to find the numeric score representation for.</param>
 /// <returns>The numeric score representation of <paramref name="result"/>.</returns>
 protected virtual int NumericResultFor(HitResult result) => result > HitResult.Miss ? 1 : 0;
Example #18
0
        public static float GetDRAvoidanceChance(Character character, Stats stats, HitResult avoidanceType, uint TargetLevel)
        {
            /*
            float defSkill = stats.Defense;
            // Let's make sure we don't run off the bottom w/ a negative defense rating.
            stats.DefenseRating = Math.Max(stats.DefenseRating, 0f);
            float defSkillMod = (GetDefenseFromRating(stats.DefenseRating, character.Class) * DEFENSE_RATING_AVOIDANCE_MULTIPLIER);
            float baseAvoid = (defSkill - (TargetLevel * 5)) * DEFENSE_RATING_AVOIDANCE_MULTIPLIER;
            float modifiedAvoid = defSkillMod;
            float finalAvoid = 0f; // I know it breaks my lack of redundancy rule, but it helps w/ readability.
            int iClass = (int)character.Class;
            */

            float baseAvoid = (character.Level - TargetLevel) * LEVEL_AVOIDANCE_MULTIPLIER;
            float modifiedAvoid = 0.0f;
            float finalAvoid    = 0.0f;
            int iClass          = (int)character.Class;

            switch (avoidanceType)
            {
                case HitResult.Dodge:
                    if ((character.Class == CharacterClass.DeathKnight) || (character.Class == CharacterClass.Paladin) || (character.Class == CharacterClass.Warrior))
                        baseAvoid += (stats.Dodge * 100f);
                    else
                        baseAvoid += ((stats.Dodge + GetDodgeFromAgility(stats.BaseAgility, character.Class)) * 100f);
                    // Assuring we don't run off the bottom w/ negative dodge rating.
                    stats.DodgeRating = Math.Max(stats.DodgeRating, 0f);
                    modifiedAvoid += ((GetDodgeFromAgility((stats.Agility - stats.BaseAgility), character.Class) +
                                    GetDodgeFromRating(stats.DodgeRating)) * 100f);
                    modifiedAvoid = DRMath(CAP_DODGE_INV[iClass], DR_COEFFIENT[iClass], modifiedAvoid);
                    // Don't run off the bottom if we have negative dodge
                    finalAvoid = Math.Max(baseAvoid + modifiedAvoid, 0);
                    finalAvoid = Math.Min(finalAvoid, CAP_DODGE[iClass]);
                    break;
                case HitResult.Parry:
                    baseAvoid += stats.Parry * 100f;
                    // Assuring we don't run off the bottom w/ negative parry rating.
                    stats.ParryRating = Math.Max(stats.ParryRating, 0f);
                    if (character.Class == CharacterClass.DeathKnight) stats.ParryRating += (stats.Strength - BaseStats.GetBaseStats(character).Strength) * 0.25f;
                    modifiedAvoid += (GetParryFromRating(stats.ParryRating) * 100f);
                    modifiedAvoid = DRMath(CAP_PARRY_INV[iClass], DR_COEFFIENT[iClass], modifiedAvoid);
                    finalAvoid = Math.Max(baseAvoid + modifiedAvoid, 0);
                    finalAvoid = Math.Min(finalAvoid, CAP_PARRY[iClass]);
                    break;
                case HitResult.Miss:
                    // Base Miss rate according is 5%
                    // However, this can be talented up (e.g. Frigid Dreadplate, NE racial, etc.) 
                    baseAvoid += stats.Miss * 100f;
                    modifiedAvoid = DRMath( (1f/CAP_MISSED[iClass]), DR_COEFFIENT[iClass], modifiedAvoid );
                    // Factoring in the Miss Cap. 
                    modifiedAvoid = Math.Min(CAP_MISSED[iClass], modifiedAvoid);
                    finalAvoid = Math.Max(baseAvoid + modifiedAvoid, 0);
                    finalAvoid = Math.Min(finalAvoid, CAP_MISSED[iClass]);
                    break;
                case HitResult.Block:
                    // Base Block is 5%
                    baseAvoid += stats.Block * 100f;
                    // Assuring we don't run off the bottom w/ negative block rating.
                    stats.BlockRating = Math.Max(stats.BlockRating, 0f);
                    modifiedAvoid += (GetBlockFromRating(stats.BlockRating) * 100f);
                    finalAvoid = Math.Max(baseAvoid + modifiedAvoid, 0);
                    break;
                case HitResult.Crit:
                    // Resilience doesn't change crit chance anymore.
                    //modifiedAvoid -= (GetCritReductionFromResilience(stats.Resilience) * 100f);
                    finalAvoid = baseAvoid + modifiedAvoid;
                    break;
            }

            // Many of the base values are whole numbers, so need to get it back to decimal. 
            // May want to look at making this more consistant in the future.
            finalAvoid = finalAvoid / 100.0f;
            return finalAvoid;
        }
Example #19
0
        public PinBounds(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            ICanvas canvas,
            IPin pin,
            double size,
            double offset)
        {
            _pin = pin;
            _size = size;
            _offset = offset;
            _canvas = canvas;

            _hitResult = HitResult.None;

            InitBounds(nativeConverter, canvasFactory);
        }
Example #20
0
        public RectangleBounds(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            ICanvas canvas,
            IRectangle rectangle,
            double size,
            double offset)
        {
            _rectangle = rectangle;
            _size = size;
            _offset = offset;
            _canvas = canvas;

            _hitResult = HitResult.None;

            InitBounds(nativeConverter, canvasFactory);
        }
Example #21
0
 public TestJudgement(HitResult maxResult)
 {
     MaxResult = maxResult;
 }
Example #22
0
 public TestHitObject(HitResult maxResult)
 {
     this.maxResult = maxResult;
 }
Example #23
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (_mouseDown)
            {
                switch (_hitResult)
                {
                case HitResult.InsideFrame:
                    _frame = CalculateNewFrame(e.X - _translate.X, e.Y - _translate.Y);
                    break;

                case HitResult.None:
                    _frame = CalculateNewFrame(e.X, e.Y);
                    break;

                case HitResult.SizeNW:
                    _frame = new Rectangle(e.X, e.Y, _frame.Right - e.X, _frame.Bottom - e.Y);
                    break;

                case HitResult.SizeNE:
                    _frame = new Rectangle(_frame.X, e.Y, e.X - _frame.X, _frame.Bottom - e.Y);
                    break;

                case HitResult.SizeSW:
                    _frame = new Rectangle(e.X, _frame.Y, _frame.Right - e.X, e.Y - _frame.Y);
                    break;

                case HitResult.SizeSE:
                    _frame = new Rectangle(_frame.X, _frame.Y, e.X - _frame.X, e.Y - _frame.Y);
                    break;
                }


                Invalidate();
            }
            else
            {
                _hitResult = HitTest(e.X, e.Y);
                if (_hitResult == HitResult.SizeNW || _hitResult == HitResult.SizeSE)
                {
                    if (_oldCursor == null)
                    {
                        _oldCursor = Cursor;
                    }
                    Cursor = Cursors.SizeNWSE;
                }
                else if (_hitResult == HitResult.SizeNE || _hitResult == HitResult.SizeSW)
                {
                    if (_oldCursor == null)
                    {
                        _oldCursor = Cursor;
                    }

                    Cursor = Cursors.SizeNESW;
                }
                else if (_oldCursor != null)
                {
                    Cursor     = _oldCursor;
                    _oldCursor = null;
                }
            }
        }
Example #24
0
 // Initial function taken from the ProtWarrior Module.
 // Then using table found on EJ:
 // http://elitistjerks.com/f31/t29453-combat_ratings_level_80_a/
 // creating updated Avoidance Chance w/ DR build in formula.
 /// <summary>
 /// 
 /// </summary>
 /// <param name="character">Character in question.</param>
 /// <param name="stats">Stats object... total stats of the character.</param>
 /// <param name="avoidanceType">What type of hit is the target doing on the character?</param>
 /// <param name="TargetLevel">Level of the target being fought</param>
 /// <returns>A % value where .50 == 50%</returns>
 public static float GetDRAvoidanceChance(Character character, Stats stats, HitResult avoidanceType, int TargetLevel) { return GetDRAvoidanceChance(character, stats, avoidanceType, (uint)TargetLevel); }
Example #25
0
 public static string GetRPHitEffect(HitResult result, string resource)
 {
     return(RP_HIT_EFFECT_FOLDER + GetStringFromHitResult(result) + @"/" + resource);
 }
Example #26
0
 public static bool IsBasic(this HitResult result)
 => IsScorable(result) && !IsTick(result) && !IsBonus(result);
Example #27
0
 private TextColumn createStatisticsColumn(HitResult hitResult, int count) => new TextColumn(hitResult.GetDescription(), smallFont, bottom_columns_min_width)
 {
     Text = count.ToString()
 };
Example #28
0
        public static bool IsValidHitResult(this HitResult result, HitResult minResult, HitResult maxResult)
        {
            if (result == HitResult.None)
            {
                return(false);
            }

            if (result == minResult || result == maxResult)
            {
                return(true);
            }

            Debug.Assert(minResult <= maxResult);
            return(result > minResult && result < maxResult);
        }
Example #29
0
 private void addJudgementAssert(OsuHitObject hitObject, HitResult result)
 {
     AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}",
               () => judgementResults.Single(r => r.HitObject == hitObject).Type == result);
 }
Example #30
0
 [Obsolete("Has no effect. Use ToNumericResult(HitResult) (standardised across all rulesets).")] // Can be made non-virtual 20210328
 protected virtual int NumericResultFor(HitResult result) => ToNumericResult(result);
Example #31
0
 private void addJudgementAssert(string name, Func <OsuHitObject> hitObject, HitResult result)
 {
     AddAssert($"{name} judgement is {result}",
               () => judgementResults.Single(r => r.HitObject == hitObject()).Type == result);
 }
Example #32
0
 protected override int NumericResultFor(HitResult result) => SCORE_PER_TICK;
Example #33
0
 public override bool IsHitResultAllowed(HitResult result) => result == HitResult.Great || result == HitResult.Miss;
Example #34
0
        public LineBounds(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            ICanvas canvas,
            ILine line,
            double size,
            double offset)
        {
            _line = line;
            _size = size;
            _offset = offset;
            _canvas = canvas;

            _hitResult = HitResult.None;

            InitBounds(nativeConverter, canvasFactory);
        }
Example #35
0
        public EllipseBounds(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            ICanvas canvas,
            IEllipse ellipse,
            double size,
            double offset)
        {
            _ellipse = ellipse;
            _size = size;
            _offset = offset;
            _canvas = canvas;

            _hitResult = HitResult.None;

            InitBounds(nativeConverter, canvasFactory);
        }
Example #36
0
 public bool Contains(double x, double y)
 {
     if (_polygonPoint.Contains(x, y))
     {
         _hitResult = HitResult.Point;
         return true;
     }
     _hitResult = HitResult.None;
     return false;
 }
Example #37
0
 protected override int NumericResultFor(HitResult result) => 20;
Example #38
0
        public TextBounds(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            ICanvas canvas,
            IText text,
            double size,
            double offset)
        {
            _text = text;
            _size = size;
            _offset = offset;
            _canvas = canvas;

            _hitResult = HitResult.None;

            InitBounds(nativeConverter, canvasFactory);
        }
Example #39
0
        public static float AvoidanceChance(Character character, Stats stats, HitResult avoidanceType, int targetLevel)
        {
            float avoidanceChance = StatConversion.GetDRAvoidanceChance(character, stats, avoidanceType, targetLevel);

            if (avoidanceType == HitResult.Block) { avoidanceChance += (8f + StatConversion.GetMasteryFromRating(stats.MasteryRating, CharacterClass.Paladin)) * 0.0225f; }

            return avoidanceChance;
        }
Example #40
0
 protected abstract int GetStatistic(HitResult result);
Example #41
0
 public static float AvoidanceChance(Player player, HitResult avoidanceType)
 {
     switch (avoidanceType)
     {
         case HitResult.Crit:
             return StatConversion.GetDRAvoidanceChance(player.Character, player.Stats, avoidanceType, player.BossOpts.Level) + (player.Talents.BastionOfDefense * 0.03f);
         case HitResult.CritBlock:
             return Lookup.BonusMasteryBlockPercentage(player) + player.Stats.CriticalBlock;
         default:
             return Math.Max(0.0f, StatConversion.GetDRAvoidanceChance(player.Character, player.Stats, avoidanceType, player.BossOpts.Level));
     }
 }
Example #42
0
 public bool Contains(double x, double y)
 {
     if (_polygonPoint1.Contains(x, y))
     {
         _hitResult = HitResult.Point1;
         return true;
     }
     else if (_polygonPoint2.Contains(x, y))
     {
         _hitResult = HitResult.Point2;
         return true;
     }
     else if (_polygonArc.Contains(x, y))
     {
         _hitResult = HitResult.Arc;
         return true;
     }
     _hitResult = HitResult.None;
     return false;
 }
Example #43
0
 public DefaultJudgementPiece(HitResult result)
 {
     Result = result;
     Origin = Anchor.Centre;
 }
Example #44
0
 public override void OnHit(HitInfo info, HitResult hitResult)
 {
 }
Example #45
0
 public int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
Example #46
0
 public static bool IncreasesCombo(this HitResult result)
 => AffectsCombo(result) && IsHit(result);
Example #47
0
 public static bool BreaksCombo(this HitResult result)
 => AffectsCombo(result) && !IsHit(result);
 /// <summary>
 ///
 /// </summary>
 /// <param name="hitResult"></param> 
 /// <param name="prevHitResult"></param>
 /// <returns></returns> 
 internal static bool IsOutside(HitResult hitResult, HitResult prevHitResult) 
 {
     // ISSUE-2004/10/08-XiaoTu For Polygon and Circle, ((HitResult.Behind == hitResult) && (HitResult.InFront == prevHitResult)) 
     // cannot be true.
     return ((HitResult.Left == hitResult)
         || ((HitResult.Behind == hitResult) && (HitResult.InFront == prevHitResult)));
 } 
Example #49
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (_mouseDown)
            {
                switch (_hitResult)
                {
                    case HitResult.InsideFrame:
                        _frame = CalculateNewFrame(e.X - _translate.X, e.Y - _translate.Y);
                        break;

                    case HitResult.None:
                        _frame = CalculateNewFrame(e.X, e.Y);
                        break;

                    case HitResult.SizeNW:
                        _frame = new Rectangle(e.X, e.Y, _frame.Right - e.X, _frame.Bottom - e.Y);
                        break;

                    case HitResult.SizeNE:
                        _frame = new Rectangle(_frame.X, e.Y, e.X - _frame.X, _frame.Bottom - e.Y);
                        break;

                    case HitResult.SizeSW:
                        _frame = new Rectangle(e.X, _frame.Y, _frame.Right - e.X, e.Y - _frame.Y);
                        break;

                    case HitResult.SizeSE:
                        _frame = new Rectangle(_frame.X, _frame.Y, e.X - _frame.X, e.Y - _frame.Y);
                        break;
                }


                Invalidate();
            }
            else
            {
                _hitResult = HitTest(e.X, e.Y);
                if (_hitResult == HitResult.SizeNW || _hitResult == HitResult.SizeSE)
                {
                    if (_oldCursor == null)
                        _oldCursor = Cursor;
                    Cursor = Cursors.SizeNWSE;
                }
                else if (_hitResult == HitResult.SizeNE || _hitResult == HitResult.SizeSW)
                {
                    if (_oldCursor == null)
                        _oldCursor = Cursor;

                    Cursor = Cursors.SizeNESW;
                }
                else if (_oldCursor != null)
                {
                    Cursor = _oldCursor;
                    _oldCursor = null;
                }
            }
        }