public EM_SPELL_RESULT __HitLogic(ObjectCreature pTarget) { LogManager.LogAssert(m_pHolder); LogManager.LogAssert(m_pSpellInfo); // 目标是友方 直接命中 [3/9/2015 Zmy] if (pTarget.GetGroupType() == m_pHolder.GetGroupType()) { return(EM_SPELL_RESULT.EM_SPELL_RESULT_NORMAL); } /*if ((pTarget.IsInFightState(EM_CARD_FIGHT_STATE_IDLE))||(pTarget.IsInFightState(EM_CARD_FIGHT_STATE_IMM))) * { * return EM_SPELL_RESULT_MISS; * }*/ /*一次攻击行为的命中判定率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.getDodge_X(); float nParama = DataTemplate.GetInstance().m_GameConfig.getDodge_a(); float nParamb = DataTemplate.GetInstance().m_GameConfig.getDodge_b(); float nParamc = DataTemplate.GetInstance().m_GameConfig.getDodge_c(); float nParamk = DataTemplate.GetInstance().m_GameConfig.getDodge_k(); float nParamp = DataTemplate.GetInstance().m_GameConfig.getDodge_p(); double fParam = (m_pHolder.GetHit() + nParamX) / (pTarget.GetDodge() + nParamX); fParam = Math.Pow(fParam, nParamk); int fHit = (int)((nParamp - nParamb / (nParama * fParam + nParamc) + m_pHolder.GetHitRate() - pTarget.GetDodgeRate()) * 10000L); fHit = Math.Max((int)(DataTemplate.GetInstance().m_GameConfig.getDodge_min() * 10000f), fHit); // System.Random ran = new System.Random(); // int nRand = ran.Next(1, 10000); //取系统时间的毫秒数为随机种子!规避伪随机导致的结果相同[9/22/2015 Zmy] int iRnd = System.DateTime.Now.Millisecond; System.Random randomCoor = new System.Random(iRnd); int nRand = randomCoor.Next(1, 10000); if (nRand <= fHit) { return(EM_SPELL_RESULT.EM_SPELL_RESULT_NORMAL); } return(EM_SPELL_RESULT.EM_SPELL_RESULT_MISS); }