Ejemplo n.º 1
0
        //玩家与玩家pk
        private static uint AdjustDamage(PlayerObject attack, PlayerObject def, bool isMagicAck = false/*是否是魔法伤害*/)
        {
            int attack_soul = attack.GetFightSoul();
            int def_soul = def.GetFightSoul();
            int dif = attack_soul - def_soul;
            int nSoulAddAtk = 0;
              int nSoulAddDef = 0;
            if(dif > 0)
            {
                //一点战斗力+一百点伤害
                nSoulAddAtk = dif * 100;
            }else
            {
                //一点战斗力 +一百点防御
                nSoulAddDef = Math.Abs(dif) * 100;
            }

            int nMaxRand = 50 + attack.GetLuck();
            int nAtk = 0;
            if (IRandom.Random(0, 100) < nMaxRand)
            {
                if (isMagicAck &&
                    attack.GetBaseAttr().profession == JOB.MAGE)
                {
                    nAtk = attack.GetMinAck() +
                IRandom.Random(0, attack.GetMaxMagixAck() - attack.GetMagicAck()) ;
                }
                else
                {
                    nAtk = attack.GetMaxAck() +
                 IRandom.Random(0, attack.GetMaxAck() - attack.GetMinAck()) ;
                }

            }
            else
            {
                if (isMagicAck &&
                  attack.GetBaseAttr().profession == JOB.MAGE)
                {
                    nAtk = attack.GetMinAck() + IRandom.Random(0, attack.GetMagicAck() - attack.GetMagicAck()) ;
                }
                else
                {
                    nAtk = attack.GetMinAck() + IRandom.Random(0, attack.GetMaxAck() - attack.GetMinAck()) ;
                }

            }
            nAtk += nSoulAddAtk;
            int nDef = 0;
            if (isMagicAck)
            {
               nDef = def.GetMagicDefense();
            }
            else
            {
               nDef = def.GetDefense();
            }
            nDef += nSoulAddDef;
            int nDamage = nAtk - nDef;

            if (attack.type == OBJECTTYPE.PLAYER)
            {
                nDamage += attack.GetLevel() / 10;
            }

            if (nDamage <= 0)
            {
                nDamage = IRandom.Random(1, 100) >= 50  ? 1 : 0;
                if (!isMagicAck) nDamage = 1;
             }

            return (uint)nDamage;
        }