Ejemplo n.º 1
0
        public bool __CriticalAttack(ObjectCreature pTarget)
        {
            LogManager.LogAssert(m_pHolder);
            LogManager.LogAssert(m_pSpellInfo);

            /*一次攻击行为的暴击判定率P的计算公式为:
             *  P = p - b / (〖a((A + X) / (B + X))〗^k + c) + A^'-B'
             *  其中A为攻击方暴击最终值,B为防御方最终韧性值,A’为攻击方暴击最终率,B’为防御方韧性最终率。
             *  X、a、b、c、k、p 分别为暴击率计算系数,配置在10_config表中。*/
            float nParamX = DataTemplate.GetInstance().m_GameConfig.getCritical_X();
            float nParama = DataTemplate.GetInstance().m_GameConfig.getCritical_a();
            float nParamb = DataTemplate.GetInstance().m_GameConfig.getCritical_b();
            float nParamc = DataTemplate.GetInstance().m_GameConfig.getCritical_c();
            float nParamk = DataTemplate.GetInstance().m_GameConfig.getCritical_k();
            float nParamp = DataTemplate.GetInstance().m_GameConfig.getCritical_p();

            double fParam = (m_pHolder.GetCritical() + nParamX) / (pTarget.GetTenacity() + nParamX);

            fParam = Math.Pow(fParam, nParamk);
            int fHit = (int)((nParamp - nParamb / (nParama * fParam + nParamc) + m_pHolder.GetCriticalRate() - pTarget.GetTenacityRate()) * 10000L);

            fHit = Math.Min((int)(DataTemplate.GetInstance().m_GameConfig.getCritical_max() * 10000f), fHit);
            //System.Random ran = new System.Random();
            //int nRand = ran.Next(1, 10000);

            int iRnd = System.DateTime.Now.Millisecond;

            System.Random randomCoor = new System.Random(iRnd);
            int           nRand      = randomCoor.Next(1, 10000);

            if (nRand <= fHit)
            {
                return(true);
            }
            return(false);
        }