Exemplo n.º 1
0
        public static bool ResolveStrike(Unit defender, Unit attacker)          //TODO this will need to be fixed to allow for mights to alter dice rolls
        //PercentNeededToDamage(defender, defenderEffectiveness, attacker, attackerEffectiveness);

        {
            double luck   = (rand.NextDouble() + .5);
            double lander = (attacker.Strength * luck - Math.Sqrt(defender.GetDefense()));

            Trace.WriteLine(attacker.Player.Name + "'s " + attacker.Name + " swung at " + defender.Player.Name + "'s " + defender.Name + " and got a lander of: " + lander + " with luck: " + luck);
            bool landsDmg = lander >= 0;

            //bool landsDmg = (attacker.Strength * (rand.NextDouble() + .5) - Math.Sqrt(defender.GetDefense())) >= 0;
            if (landsDmg)
            {
                //double defenderEffectiveness = EffectivenessRate(defender);
                double attackerEffectiveness = EffectivenessRate(attacker);

                //effectiveness is compounding with defensivewon strengtheffectiveness bonus
                //drop sensitivity of one of them or make effectiveness only relevant for strengthbonus calculation. make effectivestrength = strength + func(x,z)

                double effectiveStrength = attackerEffectiveness * attacker.Strength;
                double defenderDefense   = defender.GetDefense();
                //if(effectiveStrength > defenderDefense) {//(1.5*(x-z)/z)^.6+(x-z)/z
                //	effectiveStrength += Math.Pow(1.5 * (effectiveStrength - defenderDefense) / defenderDefense, .6) + (effectiveStrength - defenderDefense) / defenderDefense;
                //}else {//.1*z*(x-z)^.6
                //	effectiveStrength += -.1 * defenderDefense * Math.Pow((effectiveStrength - defenderDefense), .6);
                //}
                if (effectiveStrength > defenderDefense)                 //(1.5*(x-z)/z)^.6+(x-z)/z
                {
                    effectiveStrength = attacker.Strength + Math.Pow(1.5 * (effectiveStrength - defenderDefense) / defenderDefense, .6) + (effectiveStrength - defenderDefense) / defenderDefense;
                }
                else                                                                                                                    //.1*z*(x-z)^.6
                {
                    effectiveStrength = attacker.Strength - .1 * defenderDefense * Math.Pow((defenderDefense - effectiveStrength), .6); //switched order due to -2^.6 beging imaginary
                }
                //effectiveStrength = effectiveStrength + (effectiveStrength - defenderDefense) / defenderDefense - Math.Pow((defenderDefense - effectiveStrength) / effectiveStrength, .6) * 1.5;

                Trace.WriteLine(attacker.Player.Name + "'s " + attacker.Name + " is fighting at " + attackerEffectiveness * 100 + "% and got " + effectiveStrength + " effective strength");
                return(ResolveStrike(defender, attacker.Strength, effectiveStrength));
                //based on some stat (fighting) skew normal distribution to be to higher or lower?
            }
            return(false);
        }        //TODO allow loser to also deal minimum dmg?
Exemplo n.º 2
0
        //public static bool ResolveStrike(int strength,int defense) {//TODO this will need to be fixed to allow for mights to alter dice rolls
        //	return RandomBoolByPercent(Config.WoundChart[strength][defense]);
        //}
        public static bool ResolveStrike(Unit defender, int strength, double effectiveStrength)
        {
            double defenderDefense = defender.GetDefense();
            //x+.05*x^2+.005x^3
            //x-.05*z+(x^2)/z+(.1*x^3)/z+5/z		note: this function assumes a max def of 10
            double minimunDamage = effectiveStrength + .05 * Math.Pow(effectiveStrength, 2) + .005 * Math.Pow(effectiveStrength, 3);
            double maxDamage     = effectiveStrength - .05 * defenderDefense + .75 * Math.Pow(effectiveStrength, 2) / defenderDefense + .075 * Math.Pow(effectiveStrength, 3) / defenderDefense + 5.0 / defenderDefense;

            double damagePercent = GetBellCurveModifiedPercent();
            double damageDelt    = (maxDamage - minimunDamage) * damagePercent + minimunDamage;

            defender.Health -= (int)Math.Round(damageDelt);
            Trace.WriteLine("Min: " + minimunDamage + ", Max: " + maxDamage + ", %dmg: " + damagePercent + ", landed: " + damageDelt);
            return(defender.Health <= 0);
        }