Пример #1
0
 private void OnBaTiStateChange(GameClient client, bool active, BuffItemData buffItemData)
 {
     if (active)
     {
         if (buffItemData.buffVal >= 30L)
         {
             client.ClientData.DongJieStart   = 0L;
             client.ClientData.DongJieSeconds = 0;
             client.RoleBuffer.SetTempExtProp(47, 0.0, 0L);
             client.RoleBuffer.SetTempExtProp(2, 0.0, 0L);
             client.RoleBuffer.SetTempExtProp(18, 0.0, 0L);
             double moveCost = RoleAlgorithm.GetMoveSpeed(client);
             client.ClientData.MoveSpeed = moveCost;
             GameManager.ClientMgr.NotifyRoleStatusCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, 12, TimeUtil.NOW(), (int)(buffItemData.endTicks - buffItemData.startTicks), moveCost);
         }
         if (buffItemData.buffVal >= 50L)
         {
             buffItemData.buffValEx = BuffManager.GetZSPLHXZAttackInjurePercent(Global.GetAll9ClientsNum(client) - 1);
         }
     }
     else
     {
         if (buffItemData.buffId >= 30)
         {
             double moveCost = RoleAlgorithm.GetMoveSpeed(client);
             client.ClientData.MoveSpeed = moveCost;
             GameManager.ClientMgr.NotifyRoleStatusCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, 12, TimeUtil.NOW(), 0, moveCost);
         }
         if (buffItemData.buffVal >= 50L)
         {
             buffItemData.buffValEx = 0.0;
         }
     }
 }
        private int CalcElementDamage(IObject attacker, IObject defender, EElementDamageType eEDT, double dmgAddPercent = 0.0, double dmgSubPercent = 0.0, double penetAddPercent = 0.0)
        {
            double AtkPenetration = this.GetElementDamagePenetration(attacker, eEDT) + penetAddPercent;
            double DefPenetration = this.GetDeElementDamagePenetration(defender, eEDT);
            double AtkEnhance     = this.GetElementEnhance(attacker, eEDT);
            double DefReduce      = this.GetDeElementReduce(defender, eEDT);
            double rate           = 1.0 + (AtkPenetration - DefPenetration);
            double factor         = Global.GMax(0.0, 1.0 + AtkEnhance - DefReduce);

            factor = Global.GMin(2.0, factor);
            rate   = Global.GMax(0.01, rate);
            rate   = Global.GMin(1.0, rate);
            rate  *= factor;
            int nElementInjure = this.GetElementAttack(attacker, eEDT);

            nElementInjure = (int)((double)nElementInjure * rate);
            if (attacker.ObjectType == ObjectTypes.OT_CLIENT)
            {
                double percent = 1.0 + RoleAlgorithm.GetExtPropValue(attacker as GameClient, ExtPropIndexes.ElementInjurePercent);
                if (defender.ObjectType == ObjectTypes.OT_CLIENT)
                {
                    percent -= RoleAlgorithm.GetExtPropValue(defender as GameClient, ExtPropIndexes.ElementAttackInjurePercent);
                    percent -= dmgSubPercent;
                }
                percent       += dmgAddPercent;
                nElementInjure = (int)((double)nElementInjure * percent);
            }
            return((nElementInjure > 0) ? nElementInjure : 0);
        }
Пример #3
0
        /// <summary>
        /// 计算元素伤害
        /// </summary>
        /// <param name="attacker">攻击者</param>
        /// <param name="defender">防守者</param>
        /// <param name="eEDT">元素伤害类型</param>
        /// <returns>元素伤害</returns>
        private int CalcElementDamage(IObject attacker, IObject defender, EElementDamageType eEDT)
        {
            int nElementInjure = 0; // 造成的元素伤害

            // 攻击者的穿透百分比
            double AtkPenetration = GetElementDamagePenetration(attacker, eEDT);

            // 防守者的抗性百分比
            double DefPenetration = GetDeElementDamagePenetration(defender, eEDT);

            // 1 + 元素穿透 - 元素抗性
            double rate = 1 + (AtkPenetration - DefPenetration);

            // 穿透抗性比
            rate = Global.GMax(0.01, rate); // 最小1%
            rate = Global.GMin(1, rate);    // 最大100%

            // 获取元素固定伤害 [XSea 2015/5/29]
            nElementInjure = GetElementAttack(attacker, eEDT);

            //	最终元素伤害 = 元素伤害 *(1+攻方元素穿透-防方元素抗性)
            nElementInjure = (int)(nElementInjure * rate);

            if (attacker.ObjectType == ObjectTypes.OT_CLIENT)
            {
                nElementInjure = (int)(nElementInjure * (1 + RoleAlgorithm.GetExtPropValue(attacker as GameClient, ExtPropIndexes.ElementInjurePercent)));
            }

            return(nElementInjure);
        }
Пример #4
0
        /// <summary>
        /// 装备一级属性判断
        /// </summary>
        /// <param name="goodsData"></param>
        /// <returns></returns>
        public int EquipFirstPropCondition(GameClient client, SystemXmlItem systemGoods = null)
        {
            int nNeedStrength     = 0;      // 力量
            int nNeedIntelligence = 0;      // 智力
            int nNeedDexterity    = 0;      // 敏捷
            int nNeedConstitution = 0;      // 体力

            nNeedStrength     = systemGoods.GetIntValue("Strength");
            nNeedIntelligence = systemGoods.GetIntValue("Intelligence");
            nNeedDexterity    = systemGoods.GetIntValue("Dexterity");
            nNeedConstitution = systemGoods.GetIntValue("Constitution");

            if (nNeedStrength > 0 && nNeedStrength > RoleAlgorithm.GetStrength(client))
            {
                return(-1);
            }

            if (nNeedIntelligence > 0 && nNeedIntelligence > RoleAlgorithm.GetIntelligence(client))
            {
                return(-2);
            }

            if (nNeedDexterity > 0 && nNeedDexterity > RoleAlgorithm.GetDexterity(client))
            {
                return(-3);
            }

            if (nNeedConstitution > 0 && nNeedConstitution > RoleAlgorithm.GetConstitution(client))
            {
                return(-4);
            }

            return(1);
        }
Пример #5
0
        public double GetMerlinInjurePercent(IObject attacker, IObject defender, EMerlinSecretAttrType eType)
        {
            double val = 0.0;

            try
            {
                switch (eType)
                {
                case EMerlinSecretAttrType.EMSAT_FrozenP:
                    val += RoleAlgorithm.GetFrozenPercent(attacker);
                    break;

                case EMerlinSecretAttrType.EMSAT_PalsyP:
                    val += RoleAlgorithm.GetPalsyPercent(attacker);
                    break;

                case EMerlinSecretAttrType.EMSAT_SpeedDownP:
                    val += RoleAlgorithm.GetSpeedDownPercent(attacker);
                    break;

                case EMerlinSecretAttrType.EMSAT_BlowP:
                    val += RoleAlgorithm.GetBlowPercent(attacker);
                    break;
                }
                if (defender is Robot || defender is GameClient)
                {
                    switch (eType)
                    {
                    case EMerlinSecretAttrType.EMSAT_FrozenP:
                        val -= ((defender is GameClient) ? RoleAlgorithm.GetExtProp(defender as GameClient, 97) : (defender as Robot).DeFrozenPercent);
                        break;

                    case EMerlinSecretAttrType.EMSAT_PalsyP:
                        val -= ((defender is GameClient) ? RoleAlgorithm.GetExtProp(defender as GameClient, 98) : (defender as Robot).DePalsyPercent);
                        break;

                    case EMerlinSecretAttrType.EMSAT_SpeedDownP:
                        val -= ((defender is GameClient) ? RoleAlgorithm.GetExtProp(defender as GameClient, 99) : (defender as Robot).DeSpeedDownPercent);
                        break;

                    case EMerlinSecretAttrType.EMSAT_BlowP:
                        val -= ((defender is GameClient) ? RoleAlgorithm.GetExtProp(defender as GameClient, 100) : (defender as Robot).DeBlowPercent);
                        break;
                    }
                }
                return((val > 0.0) ? val : 0.0);
            }
            catch (Exception ex)
            {
                if (attacker is GameClient)
                {
                    GameClient client = attacker as GameClient;
                    if (null != client)
                    {
                        DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
                    }
                }
            }
            return((val > 0.0) ? val : 0.0);
        }
Пример #6
0
        public int EquipFirstPropCondition(GameClient client, SystemXmlItem systemGoods = null)
        {
            int nNeedStrength     = systemGoods.GetIntValue("Strength", -1);
            int nNeedIntelligence = systemGoods.GetIntValue("Intelligence", -1);
            int nNeedDexterity    = systemGoods.GetIntValue("Dexterity", -1);
            int nNeedConstitution = systemGoods.GetIntValue("Constitution", -1);
            int result;

            if (nNeedStrength > 0 && (double)nNeedStrength > RoleAlgorithm.GetStrength(client, true))
            {
                result = -1;
            }
            else if (nNeedIntelligence > 0 && (double)nNeedIntelligence > RoleAlgorithm.GetIntelligence(client, true))
            {
                result = -2;
            }
            else if (nNeedDexterity > 0 && (double)nNeedDexterity > RoleAlgorithm.GetDexterity(client, true))
            {
                result = -3;
            }
            else if (nNeedConstitution > 0 && (double)nNeedConstitution > RoleAlgorithm.GetConstitution(client, true))
            {
                result = -4;
            }
            else
            {
                result = 1;
            }
            return(result);
        }
Пример #7
0
        /// <summary>
        /// 获取伤害类型
        /// </summary>
        /// <param name="attacker">攻击者</param>
        /// <returns></returns>
        private EMerlinSecretAttrType GetMerlinInjureType(IObject attacker)
        {
            try
            {
                // 攻击者的概率 百分比
                double dSpeedDownRate = GetMerlinInjurePercent(attacker, EMerlinSecretAttrType.EMSAT_SpeedDownP);
                double dFrozenRate    = GetMerlinInjurePercent(attacker, EMerlinSecretAttrType.EMSAT_FrozenP);
                double dBlowRate      = GetMerlinInjurePercent(attacker, EMerlinSecretAttrType.EMSAT_BlowP);
                double dPalsyRate     = GetMerlinInjurePercent(attacker, EMerlinSecretAttrType.EMSAT_PalsyP);

                // 按优先顺序获取,减速、冰冻、重击、麻痹
                double[] rateArr = { dSpeedDownRate, dFrozenRate, dBlowRate, dPalsyRate };
                int      index   = RoleAlgorithm.GetRateIndexPercent(rateArr); // 总几率100
                switch (index)
                {
                case 0:     // 减速
                    return(EMerlinSecretAttrType.EMSAT_SpeedDownP);

                    break;

                case 1:     // 冰冻
                    return(EMerlinSecretAttrType.EMSAT_FrozenP);

                    break;

                case 2:     // 重击
                    return(EMerlinSecretAttrType.EMSAT_BlowP);

                    break;

                case 3:     // 麻痹
                    return(EMerlinSecretAttrType.EMSAT_PalsyP);

                    break;

                default:     // 无
                    return(EMerlinSecretAttrType.EMSAT_None);

                    break;
                }
            }
            catch (Exception ex)
            {
                if (attacker is GameClient)
                {
                    GameClient client = attacker as GameClient;
                    if (null != client)
                    {
                        DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
                    }
                }
            }

            return(EMerlinSecretAttrType.EMSAT_None);
        }
Пример #8
0
 private void UpdateBasePropCache(int BaseProp, PropsCacheItem item)
 {
     if (null != RoleAlgorithm.BaseListArray[BaseProp])
     {
         int count = RoleAlgorithm.BaseListArray[BaseProp].Count;
         for (int i = 0; i < count; i++)
         {
             double value = RoleAlgorithm.GetExtProp(item.Client, (int)RoleAlgorithm.BaseListArray[BaseProp][i]);
             item.ExtPropsCache[(int)RoleAlgorithm.BaseListArray[BaseProp][i]] = value;
         }
     }
 }
Пример #9
0
        public static double GetNegativeRate(IObject self, IObject obj, double baseRate, ExtPropIndexes extPropIndex, MagicActionIDs actionId)
        {
            int selfZhuanSheng = 0;

            if (self is GameClient)
            {
                selfZhuanSheng = (self as GameClient).ClientData.ChangeLifeCount;
                baseRate       = RoleAlgorithm.GetRoleNegativeRate(self as GameClient, baseRate, extPropIndex);
            }
            else if (self is Monster)
            {
                selfZhuanSheng = (self as Monster).MonsterInfo.ChangeLifeCount;
            }
            int objZhuanSheng = 0;

            if (obj is GameClient)
            {
                if ((obj as GameClient).buffManager.IsBuffEnabled(116))
                {
                    return(0.0);
                }
                if (actionId != MagicActionIDs.MU_ADD_JITUI && (obj as GameClient).buffManager.IsBuffEnabled(113))
                {
                    return(0.0);
                }
                if (CaiJiLogic.IsCaiJiState(obj as GameClient) && (extPropIndex == ExtPropIndexes.StateDingShen || extPropIndex == ExtPropIndexes.StateMoveSpeed || extPropIndex == ExtPropIndexes.StateJiTui || extPropIndex == ExtPropIndexes.StateHunMi))
                {
                    return(0.0);
                }
                objZhuanSheng = (obj as GameClient).ClientData.ChangeLifeCount;
            }
            else if (obj is Monster)
            {
                objZhuanSheng = (obj as Monster).MonsterInfo.ChangeLifeCount;
            }
            else if (obj is FakeRoleItem)
            {
                objZhuanSheng = (obj as FakeRoleItem).GetFakeRoleData().MyRoleDataMini.ChangeLifeCount;
            }
            double result;

            if (selfZhuanSheng > objZhuanSheng)
            {
                result = baseRate + 0.1 * Math.Pow((double)(selfZhuanSheng - objZhuanSheng), 2.0);
            }
            else
            {
                result = baseRate - 0.1 * Math.Pow((double)(selfZhuanSheng - objZhuanSheng), 2.0);
            }
            return(result);
        }
Пример #10
0
        public void OnRoleDead(GameClient client)
        {
            ExtData extData    = ExtDataManager.GetClientExtData(client);
            long    maxCdTicks = TimeUtil.NOW() + extData.HuiJiCdTime;

            if (maxCdTicks < extData.HuiJiCDTicks)
            {
                extData.HuiJiCDTicks = maxCdTicks;
                client.buffManager.SetStatusBuff(116, 0L, 0L, 0L);
                double moveCost = RoleAlgorithm.GetMoveSpeed(client);
                client.ClientData.MoveSpeed = moveCost;
                GameManager.ClientMgr.NotifyRoleStatusCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, 11, 0L, 0, moveCost);
            }
        }
Пример #11
0
        public EMagicSwordTowardType GetMagicSwordTowardType(GameClient client)
        {
            double meStrength     = RoleAlgorithm.GetStrength(client, true);
            double meIntelligence = RoleAlgorithm.GetIntelligence(client, true);
            EMagicSwordTowardType result;

            if (meStrength >= meIntelligence)
            {
                result = EMagicSwordTowardType.EMST_Strength;
            }
            else
            {
                result = EMagicSwordTowardType.EMST_Intelligence;
            }
            return(result);
        }
Пример #12
0
        private void _CheckSpeed(GameClient client, InterestingData.Item item, string[] fields)
        {
            double clientSpeed = Convert.ToDouble(fields[2]);

            client.InterestingData.Speed = clientSpeed;
            double calcSpeed = RoleAlgorithm.GetMoveSpeed(client);

            if (client.ClientData.HorseDbID > 0)
            {
                calcSpeed += Global.GetHorseSpeed(client);
            }
            if (clientSpeed > calcSpeed * 1.4)
            {
                item.InvalidCount++;
            }
        }
Пример #13
0
        /// <summary>
        /// 获取攻击方与受击方的“昏迷”状态命中之差
        /// </summary>
        public static double GetStateHunMi(IObject self, IObject obj, double selfBaseRate, double objBaseRate)
        {
            // 命中中跟转生等级有关
            double dSelfRealRate = 0.0;

            if (self is GameClient)
            {
                dSelfRealRate = selfBaseRate + RoleAlgorithm.GetRoleStateHunMi(self as GameClient, selfBaseRate);
            }
            else if (self is Monster)
            {
#if ___CC___FUCK___YOU___BB___
                //  dSelfRealRate = selfBaseRate + 0.1 * (self as Monster).MonsterInfo.ChangeLifeCount;
#else
                dSelfRealRate = selfBaseRate + 0.1 * (self as Monster).MonsterInfo.ChangeLifeCount;
#endif
            }
            else
            {
                dSelfRealRate = selfBaseRate;
            }

            double dObjRealRate = 0.0;
            if (obj is GameClient)
            {
                dObjRealRate = objBaseRate + RoleAlgorithm.GetRoleStateHunMi(obj as GameClient, objBaseRate);
            }
            else if (obj is Monster)
            {
#if ___CC___FUCK___YOU___BB___
                //dObjRealRate = objBaseRate + 0.1 * (obj as Monster).MonsterInfo.ChangeLifeCount;
#else
                dObjRealRate = objBaseRate + 0.1 * (obj as Monster).MonsterInfo.ChangeLifeCount;
#endif
            }
            else if (obj is FakeRoleItem)
            {
                dObjRealRate = selfBaseRate + 0.1 * (obj as FakeRoleItem).GetFakeRoleData().MyRoleDataMini.ChangeLifeCount;
            }
            else
            {
                dObjRealRate = 0.0;
            }

            return(dSelfRealRate - dObjRealRate);
        }
Пример #14
0
 public void OnHuiJiStateChange(GameClient client, bool active, int level = 0, int keepTicks = 0, double[] props = null)
 {
     if (active)
     {
         if (null != props)
         {
             client.ClientData.PropsCacheManager.SetExtProps(new object[]
             {
                 31,
                 props
             });
         }
         client.ClientData.DongJieStart   = 0L;
         client.ClientData.DongJieSeconds = 0;
         client.RoleBuffer.SetTempExtProp(47, 0.0, 0L);
         client.RoleBuffer.SetTempExtProp(2, 0.0, 0L);
         client.RoleBuffer.SetTempExtProp(18, 0.0, 0L);
         double moveCost = RoleAlgorithm.GetMoveSpeed(client);
         client.ClientData.MoveSpeed = moveCost;
         double[] actionParams = new double[]
         {
             (double)level,
             (double)keepTicks
         };
         Global.UpdateBufferData(client, BufferItemTypes.HuiJiHuTi, actionParams, 1, true);
         GameManager.ClientMgr.NotifyRoleStatusCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, 11, TimeUtil.NOW(), keepTicks, moveCost);
     }
     else
     {
         client.ClientData.PropsCacheManager.SetExtProps(new object[]
         {
             31,
             PropsCacheManager.ConstExtProps
         });
         double moveCost = RoleAlgorithm.GetMoveSpeed(client);
         client.ClientData.MoveSpeed = moveCost;
         double[] array = new double[2];
         array[0] = (double)level;
         double[] actionParams = array;
         Global.UpdateBufferData(client, BufferItemTypes.HuiJiHuTi, actionParams, 1, false);
         GameManager.ClientMgr.NotifyRoleStatusCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, 11, TimeUtil.NOW(), keepTicks, moveCost);
     }
 }
Пример #15
0
        /// <summary>
        /// 负面效果概率公式(击退,昏迷等)
        /// </summary>
        /// <param name="self"></param>
        /// <param name="obj"></param>
        /// <param name="baseRate"></param>
        /// <returns></returns>
        public static double GetNegativeRate(IObject self, IObject obj, double baseRate, ExtPropIndexes extPropIndex)
        {
            int selfZhuanSheng = 0;

            if (self is GameClient)
            {
                selfZhuanSheng = (self as GameClient).ClientData.ChangeLifeCount;
                baseRate       = RoleAlgorithm.GetRoleNegativeRate(self as GameClient, baseRate, extPropIndex);
            }
            else if (self is Monster)
            {
#if ___CC___FUCK___YOU___BB___
#else
                selfZhuanSheng = (self as Monster).MonsterInfo.ChangeLifeCount;
#endif
            }

            int objZhuanSheng = 0;
            if (obj is GameClient)
            {
                objZhuanSheng = (obj as GameClient).ClientData.ChangeLifeCount;
            }
            else if (obj is Monster)
            {
#if ___CC___FUCK___YOU___BB___
#else
                objZhuanSheng = (obj as Monster).MonsterInfo.ChangeLifeCount;
#endif
            }
            else if (obj is FakeRoleItem)
            {
                objZhuanSheng = (obj as FakeRoleItem).GetFakeRoleData().MyRoleDataMini.ChangeLifeCount;
            }

            if (selfZhuanSheng > objZhuanSheng)
            {
                return(baseRate + 0.1 * Math.Pow(selfZhuanSheng - objZhuanSheng, 2));
            }
            else
            {
                return(baseRate - 0.1 * Math.Pow(selfZhuanSheng - objZhuanSheng, 2));
            }
        }
Пример #16
0
        public void OnTimer(TimerEventObject eventObj)
        {
            GameClient client = eventObj.Client;

            if (client.ClientData.CurrentArmorV < client.ClientData.ArmorV)
            {
                if (!client.buffManager.IsBuffEnabled(114))
                {
                    double rate    = Global.Clamp((double)eventObj.DeltaTicks / 1000.0, 0.0, 5.0);
                    int    max     = (int)RoleAlgorithm.GetExtProp(client, 119);
                    int    recover = (int)((double)max * RoleAlgorithm.GetExtProp(client, 121) * rate);
                    client.ClientData.CurrentArmorV += recover;
                    if (client.ClientData.CurrentArmorV > max)
                    {
                        client.ClientData.CurrentArmorV = max;
                    }
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 4);
                }
            }
        }
Пример #17
0
        /// <summary>
        /// 获取伤害概率
        /// </summary>
        /// <param name="attacker">攻击者</param>
        /// <param name="eType">伤害类型</param>
        /// <returns></returns>
        public double GetMerlinInjurePercent(IObject attacker, EMerlinSecretAttrType eType)
        {
            double val = 0.0;

            try
            {
                // 根据类型获取角色伤害概率
                switch (eType)
                {
                case EMerlinSecretAttrType.EMSAT_FrozenP:     // 冰冻
                    val += RoleAlgorithm.GetFrozenPercent(attacker);
                    break;

                case EMerlinSecretAttrType.EMSAT_SpeedDownP:     // 减速
                    val += RoleAlgorithm.GetSpeedDownPercent(attacker);
                    break;

                case EMerlinSecretAttrType.EMSAT_PalsyP:     // 麻痹
                    val += RoleAlgorithm.GetPalsyPercent(attacker);
                    break;

                case EMerlinSecretAttrType.EMSAT_BlowP:     // 重击
                    val += RoleAlgorithm.GetBlowPercent(attacker);
                    break;
                }
                return(val);
            }
            catch (Exception ex)
            {
                if (attacker is GameClient)
                {
                    GameClient client = attacker as GameClient;
                    if (null != client)
                    {
                        DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
                    }
                }
            }
            return(val);
        }
        public double GetDeElementReduce(IObject attacker, EElementDamageType eEDT)
        {
            double val = 0.0;

            if (attacker is GameClient)
            {
                GameClient attackClient = attacker as GameClient;
                if (null == attackClient)
                {
                    return(val);
                }
                switch (eEDT)
                {
                case EElementDamageType.EEDT_Fire:
                    val = RoleAlgorithm.GetExtProp(attackClient, 112);
                    break;

                case EElementDamageType.EEDT_Water:
                    val = RoleAlgorithm.GetExtProp(attackClient, 113);
                    break;

                case EElementDamageType.EEDT_Lightning:
                    val = RoleAlgorithm.GetExtProp(attackClient, 114);
                    break;

                case EElementDamageType.EEDT_Soil:
                    val = RoleAlgorithm.GetExtProp(attackClient, 115);
                    break;

                case EElementDamageType.EEDT_Ice:
                    val = RoleAlgorithm.GetExtProp(attackClient, 116);
                    break;

                case EElementDamageType.EEDT_Wind:
                    val = RoleAlgorithm.GetExtProp(attackClient, 117);
                    break;
                }
            }
            return(val);
        }
Пример #19
0
 public void ResetArmor(GameClient client, bool reset = true)
 {
     if (client.ClientData.ArmorData.Armor > 0)
     {
         ExtData extData = ExtDataManager.GetClientExtData(client);
         lock (this.RuntimeData.Mutex)
         {
             ArmorStarInfo starInfo;
             if (this.RuntimeData.ArmorStarDict.Value.TryGetValue(client.ClientData.ArmorData.Armor, out starInfo) && starInfo.ArmorUpInfo != null)
             {
                 client.ClientData.PropsCacheManager.SetExtProps(new object[]
                 {
                     PropsSystemTypes.Armor,
                     starInfo.ExtPropValues
                 });
             }
         }
         client.ClientData.ArmorPercent = RoleAlgorithm.GetExtProp(client, 120);
         int max = (int)RoleAlgorithm.GetExtProp(client, 119);
         if (reset)
         {
             extData.ArmorCurrentV = extData.ArmorMaxV;
         }
         else if (max > extData.ArmorMaxV)
         {
             extData.ArmorCurrentV += max - extData.ArmorMaxV;
         }
         extData.ArmorMaxV = max;
         if (extData.ArmorMaxV != client.ClientData.ArmorV || extData.ArmorCurrentV != client.ClientData.CurrentArmorV)
         {
             client.ClientData.ArmorV        = extData.ArmorMaxV;
             client.ClientData.CurrentArmorV = extData.ArmorCurrentV;
             client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[]
             {
                 DelayExecProcIds.NotifyRefreshProps
             });
         }
     }
 }
Пример #20
0
        public bool TimerUpdateProps(long nowTicks, bool force = false)
        {
            bool ret = false;

            if (null != this.propCacheManager)
            {
                lock (this.mutex)
                {
                    if (!force && nowTicks < this.MinExpireTicks)
                    {
                        return(false);
                    }
                    this.MinExpireTicks = nowTicks + 10000L;
                    List <long> list = new List <long>();
                    foreach (KeyValuePair <long, TimedPropsData> kv in this.bufferDataDict)
                    {
                        long endTicks = kv.Value.endTicks;
                        if (endTicks < nowTicks)
                        {
                            list.Add(kv.Key);
                            this.UpdateTimedProps(kv.Value, false);
                            if (!ret)
                            {
                                ret = RoleAlgorithm.NeedNotifyClient((ExtPropIndexes)kv.Value.propsIndex);
                            }
                        }
                        else if (endTicks < this.MinExpireTicks)
                        {
                            this.MinExpireTicks = endTicks;
                        }
                    }
                    foreach (long key in list)
                    {
                        this.bufferDataDict.Remove(key);
                    }
                }
            }
            return(ret);
        }
Пример #21
0
        /// <summary>
        /// 获取攻击方与受击方的“定身”状态命中之差
        /// </summary>
        public static double GetStateDingShengRate(IObject self, IObject obj, double selfBaseRate, double objBaseRate)
        {
            // 命中中跟转生等级有关
            double dSelfRealRate = 0.0;

            if (self is GameClient)
            {
                dSelfRealRate = selfBaseRate + RoleAlgorithm.GetRoleStateDingSheng(self as GameClient, selfBaseRate);
            }
            else if (self is Monster)
            {
                dSelfRealRate = selfBaseRate + 0.1 * (self as Monster).MonsterInfo.ChangeLifeCount;
            }
            else
            {
                dSelfRealRate = selfBaseRate;
            }

            double dObjRealRate = 0.0;

            if (obj is GameClient)
            {
                dObjRealRate = objBaseRate + RoleAlgorithm.GetRoleStateDingSheng(obj as GameClient, objBaseRate);
            }
            else if (obj is Monster)
            {
                dObjRealRate = objBaseRate + 0.1 * (obj as Monster).MonsterInfo.ChangeLifeCount;
            }
            else if (obj is FakeRoleItem)
            {
                dObjRealRate = selfBaseRate + 0.1 * (obj as FakeRoleItem).GetFakeRoleData().MyRoleDataMini.ChangeLifeCount;
            }
            else
            {
                dObjRealRate = 0.0;
            }

            return(dSelfRealRate - dObjRealRate);
        }
Пример #22
0
        public void ActivationStarConstellationAll(GameClient client)
        {
            int nOccupation = client.ClientData.Occupation;
            Dictionary <int, Dictionary <int, StarConstellationDetailInfo> > dicTmp = null;

            if (this.m_StarConstellationDetailInfo.TryGetValue(nOccupation, out dicTmp) && dicTmp != null)
            {
                if (client.ClientData.RoleStarConstellationInfo == null)
                {
                    client.ClientData.RoleStarConstellationInfo = new Dictionary <int, int>();
                }
                foreach (KeyValuePair <int, Dictionary <int, StarConstellationDetailInfo> > kvp in dicTmp)
                {
                    TCPOutPacket         tcpOutPacket    = null;
                    string               strDbCmd        = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, kvp.Key, this.m_MaxStarSlotID);
                    TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 10166, strDbCmd, out tcpOutPacket, client.ServerId);
                    if (TCPProcessCmdResults.RESULT_FAILED != dbRequestResult)
                    {
                        Global.PushBackTcpOutPacket(tcpOutPacket);
                    }
                    client.ClientData.RoleStarConstellationInfo[kvp.Key] = this.m_MaxStarSlotID;
                    StarConstellationDetailInfo tmpInfo = null;
                    if (kvp.Value.TryGetValue(this.m_MaxStarSlotID, out tmpInfo) && null != tmpInfo.Propertyinfo)
                    {
                        this.ActivationStarConstellationProp(client, tmpInfo.Propertyinfo, 1);
                    }
                    this.ActivationStarConstellationExtendProp(client, kvp.Key);
                    GameManager.StarConstellationMgr.InitPlayerStarConstellationPorperty(client);
                }
                GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ActiveXingZuo));
                ProcessTask.ProcessRoleTaskVal(client, TaskTypes.XingZuoStar, -1);
                GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                client.ClientData.LifeV  = (int)RoleAlgorithm.GetMaxLifeV(client);
                client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client);
                GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                client.sendCmd <Dictionary <int, int> >(661, client.ClientData.RoleStarConstellationInfo, false);
            }
        }
        public double GetElementDamagePenetration(IObject attacker, EElementDamageType eEDT)
        {
            double val = 0.0;

            if (attacker is GameClient)
            {
                GameClient attackClient = attacker as GameClient;
                if (null == attackClient)
                {
                    return(val);
                }
                switch (eEDT)
                {
                case EElementDamageType.EEDT_Fire:
                    val += attackClient.ClientData.EquipProp.ExtProps[75];
                    val += attackClient.ClientData.PropsCacheManager.GetExtProp(75);
                    val += RoleAlgorithm.GetExtProp(attackClient, 118);
                    break;

                case EElementDamageType.EEDT_Water:
                    val += attackClient.ClientData.EquipProp.ExtProps[76];
                    val += attackClient.ClientData.PropsCacheManager.GetExtProp(76);
                    val += RoleAlgorithm.GetExtProp(attackClient, 118);
                    break;

                case EElementDamageType.EEDT_Lightning:
                    val += attackClient.ClientData.EquipProp.ExtProps[77];
                    val += attackClient.ClientData.PropsCacheManager.GetExtProp(77);
                    val += RoleAlgorithm.GetExtProp(attackClient, 118);
                    break;

                case EElementDamageType.EEDT_Soil:
                    val += attackClient.ClientData.EquipProp.ExtProps[78];
                    val += attackClient.ClientData.PropsCacheManager.GetExtProp(78);
                    val += RoleAlgorithm.GetExtProp(attackClient, 118);
                    break;

                case EElementDamageType.EEDT_Ice:
                    val += attackClient.ClientData.EquipProp.ExtProps[79];
                    val += attackClient.ClientData.PropsCacheManager.GetExtProp(79);
                    val += RoleAlgorithm.GetExtProp(attackClient, 118);
                    break;

                case EElementDamageType.EEDT_Wind:
                    val += attackClient.ClientData.EquipProp.ExtProps[80];
                    val += attackClient.ClientData.PropsCacheManager.GetExtProp(80);
                    val += RoleAlgorithm.GetExtProp(attackClient, 118);
                    break;
                }
            }
            else if (attacker is Robot)
            {
                Robot attackRobot = attacker as Robot;
                if (null == attackRobot)
                {
                    return(val);
                }
                switch (eEDT)
                {
                case EElementDamageType.EEDT_Fire:
                    val  = attackRobot.FirePenetration;
                    val += (attacker as Robot).ElementPenetration;
                    break;

                case EElementDamageType.EEDT_Water:
                    val  = attackRobot.WaterPenetration;
                    val += (attacker as Robot).ElementPenetration;
                    break;

                case EElementDamageType.EEDT_Lightning:
                    val  = attackRobot.LightningPenetration;
                    val += (attacker as Robot).ElementPenetration;
                    break;

                case EElementDamageType.EEDT_Soil:
                    val  = attackRobot.SoilPenetration;
                    val += (attacker as Robot).ElementPenetration;
                    break;

                case EElementDamageType.EEDT_Ice:
                    val  = attackRobot.IcePenetration;
                    val += (attacker as Robot).ElementPenetration;
                    break;

                case EElementDamageType.EEDT_Wind:
                    val  = attackRobot.WindPenetration;
                    val += (attacker as Robot).ElementPenetration;
                    break;
                }
            }
            return(Math.Max(val, 0.0));
        }
Пример #24
0
        private EMerlinSecretAttrType GetMerlinInjureType(IObject attacker, IObject defender, ref double percent)
        {
            try
            {
                double   dSpeedDownRate = this.GetMerlinInjurePercent(attacker, defender, EMerlinSecretAttrType.EMSAT_SpeedDownP);
                double   dFrozenRate    = this.GetMerlinInjurePercent(attacker, defender, EMerlinSecretAttrType.EMSAT_FrozenP);
                double   dBlowRate      = this.GetMerlinInjurePercent(attacker, defender, EMerlinSecretAttrType.EMSAT_BlowP);
                double   dPalsyRate     = this.GetMerlinInjurePercent(attacker, defender, EMerlinSecretAttrType.EMSAT_PalsyP);
                double[] rateArr        = new double[]
                {
                    dSpeedDownRate,
                    dFrozenRate,
                    dBlowRate,
                    dPalsyRate
                };
                switch (RoleAlgorithm.GetRateIndexPercent(rateArr))
                {
                case 0:
                    percent = DeControl.getInstance().OnControl(defender as GameClient, 58);
                    if (percent <= 0.0)
                    {
                        return(EMerlinSecretAttrType.EMSAT_None);
                    }
                    return(EMerlinSecretAttrType.EMSAT_SpeedDownP);

                case 1:
                    percent = DeControl.getInstance().OnControl(defender as GameClient, 56);
                    if (percent <= 0.0)
                    {
                        return(EMerlinSecretAttrType.EMSAT_None);
                    }
                    return(EMerlinSecretAttrType.EMSAT_FrozenP);

                case 2:
                    percent = DeControl.getInstance().OnControl(defender as GameClient, 59);
                    if (percent <= 0.0)
                    {
                        return(EMerlinSecretAttrType.EMSAT_None);
                    }
                    return(EMerlinSecretAttrType.EMSAT_BlowP);

                case 3:
                    percent = DeControl.getInstance().OnControl(defender as GameClient, 57);
                    if (percent <= 0.0)
                    {
                        return(EMerlinSecretAttrType.EMSAT_None);
                    }
                    return(EMerlinSecretAttrType.EMSAT_PalsyP);

                default:
                    return(EMerlinSecretAttrType.EMSAT_None);
                }
            }
            catch (Exception ex)
            {
                if (attacker is GameClient)
                {
                    GameClient client = attacker as GameClient;
                    if (null != client)
                    {
                        DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
                    }
                }
            }
            return(EMerlinSecretAttrType.EMSAT_None);
        }
Пример #25
0
        /// <summary>
        /// 激活星座信息
        /// </summary>
        public int ActivationStarConstellation(GameClient client, int nStarSiteID)
        {
            if (nStarSiteID < 1 || nStarSiteID > m_MaxStarSiteID)
            {
                return(-1);
            }

            if (client.ClientData.RoleStarConstellationInfo == null)
            {
                client.ClientData.RoleStarConstellationInfo = new Dictionary <int, int>();
            }

            int nStarSlot = 0;

            client.ClientData.RoleStarConstellationInfo.TryGetValue(nStarSiteID, out nStarSlot);

            if (nStarSlot >= m_MaxStarSlotID)
            {
                return(-1);
            }

            ++nStarSlot;

            int nOccupation = client.ClientData.Occupation;

            Dictionary <int, Dictionary <int, StarConstellationDetailInfo> > dicTmp = null;

            if (!m_StarConstellationDetailInfo.TryGetValue(nOccupation, out dicTmp) || dicTmp == null)
            {
                return(-2);
            }

            Dictionary <int, StarConstellationDetailInfo> dicTmpInfo = null;

            if (!dicTmp.TryGetValue(nStarSiteID, out dicTmpInfo) || dicTmpInfo == null)
            {
                return(-2);
            }

            StarConstellationDetailInfo tmpInfo = null;

            if (!dicTmpInfo.TryGetValue(nStarSlot, out tmpInfo) || tmpInfo == null)
            {
                return(-2);
            }

            int nNeeChangeLife = 0;

            nNeeChangeLife = tmpInfo.ChangeLifeLimit;
            int nNeedLev       = tmpInfo.LevelLimit;
            int nReqUnionLevel = Global.GetUnionLevel(nNeeChangeLife, nNeedLev);

            if (Global.GetUnionLevel(client.ClientData.ChangeLifeCount, client.ClientData.Level) < nReqUnionLevel)
            {
                return(-3);
            }

            int nGoods = tmpInfo.NeedGoodsID;
            int nNum   = tmpInfo.NeedGoodsNum;

            if (nGoods > 0 && nNum > 0)
            {
                GoodsData goods = null;
                goods = Global.GetGoodsByID(client, nGoods);

                if (goods == null || goods.GCount < nNum)
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                             StringUtil.substitute(Global.GetLang("所需物品不足")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox);

                    return(-5);
                }
            }

            int nNeedStarSoul = tmpInfo.NeedStarSoul;

            if (nNeedStarSoul > 0)
            {
                if (nNeedStarSoul > client.ClientData.StarSoul)
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                             StringUtil.substitute(Global.GetLang("星魂不足")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox);
                    return(-9);
                }
            }

            int nNeedMoney = tmpInfo.NeedJinBi;

            if (nNeedMoney > 0)
            {
                if (!Global.SubBindTongQianAndTongQian(client, nNeedMoney, "激活星座"))
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                             StringUtil.substitute(Global.GetLang("金币不足")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox);

                    return(-10);
                }
            }


            if (nGoods > 0 && nNum > 0)
            {
                bool usedBinding     = false;
                bool usedTimeLimited = false;

                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool,
                                                          Global._TCPManager.TcpOutPacketPool, client, nGoods, nNum, false, out usedBinding, out usedTimeLimited))
                {
                    return(-6);
                }
            }

            if (nNeedStarSoul > 0)
            {
                GameManager.ClientMgr.ModifyStarSoulValue(client, -nNeedStarSoul, "激活星座", true, true);
                //client.ClientData.StarSoul -= nNeedStarSoul;

                //if (client.ClientData.StarSoul < 0)
                //    client.ClientData.StarSoul = 0;

                //Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.StarSoul, client.ClientData.StarSoul, true);

                //GameManager.ClientMgr.NotifySelfParamsValueChange(client, RoleCommonUseIntParamsIndexs.StarSoulValue, client.ClientData.StarSoul);
            }

            // 概率
            int nRate = 0;

            nRate = Global.GetRandomNumber(1, 10001);

            if (nRate > tmpInfo.SuccessRate)
            {
                GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                         StringUtil.substitute(Global.GetLang("激活星位失败")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox);
                return(-100);
            }

            // 通知DB
            TCPOutPacket tcpOutPacket = null;
            string       strDbCmd     = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, nStarSiteID, nStarSlot);

            TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                                             (int)TCPGameServerCmds.CMD_DB_UPDATESTARCONSTELLATION, strDbCmd, out tcpOutPacket, client.ServerId);

            if (TCPProcessCmdResults.RESULT_FAILED == dbRequestResult)
            {
                return(-7);
            }
            Global.PushBackTcpOutPacket(tcpOutPacket);
            PropertyInfo tmpProp = null;

            tmpProp = tmpInfo.Propertyinfo;

            if (tmpProp == null)
            {
                return(-8);
            }

            client.ClientData.RoleStarConstellationInfo[nStarSiteID] = nStarSlot;

            ActivationStarConstellationProp(client, tmpProp);

            /*int nCount = 0;
             *
             * if (!client.ClientData.StarConstellationCount.TryGetValue(nStarSiteID, out nCount))
             * {
             ++nCount;
             *  client.ClientData.StarConstellationCount.Add(nStarSiteID, nCount);
             * }
             * else
             * {
             ++client.ClientData.StarConstellationCount[nStarSiteID];
             * }*/

            if (0 == nStarSlot % 12)
            {
                ActivationStarConstellationExtendProp(client, nStarSiteID);

                // 星座属性 [8/4/2014 LiaoWei]
                GameManager.StarConstellationMgr.InitPlayerStarConstellationPorperty(client);
            }

            // 七日活动
            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ActiveXingZuo));

            GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
            client.ClientData.LifeV  = (int)RoleAlgorithm.GetMaxLifeV(client);
            client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client);
            GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

            return(1);
        }
Пример #26
0
 public void AutoMaigcSwordFirstAddPoint(GameClient client, EMagicSwordTowardType eType)
 {
     if (null == client)
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("client不存在,服务器无法根据参数表配置第一次给魔剑士加点", new object[0]), null, true);
     }
     else if (this.IsMagicSword(client))
     {
         if (eType == EMagicSwordTowardType.EMST_Strength || eType == EMagicSwordTowardType.EMST_Intelligence)
         {
             int nRoleID = client.ClientData.RoleID;
             try
             {
                 string MagicSwordInitAttrStr;
                 if (eType == EMagicSwordTowardType.EMST_Strength)
                 {
                     MagicSwordInitAttrStr = GameManager.systemParamsList.GetParamValueByName("LiMJS");
                 }
                 else
                 {
                     MagicSwordInitAttrStr = GameManager.systemParamsList.GetParamValueByName("ZhiMJS");
                 }
                 string[] MagicSwordInitAttrArr = MagicSwordInitAttrStr.Split(new char[]
                 {
                     ','
                 });
                 if (MagicSwordInitAttrArr.Length != 4)
                 {
                     LogManager.WriteLog(LogTypes.Error, string.Format("魔剑士读取初始加点失败,无法创建魔剑士, RoleID={0}", nRoleID), null, true);
                 }
                 else
                 {
                     int nPoint = 0;
                     for (int i = 0; i < MagicSwordInitAttrArr.Length; i++)
                     {
                         nPoint += int.Parse(MagicSwordInitAttrArr[i]);
                     }
                     int nTotal        = Global.GetRoleParamsInt32FromDB(client, "TotalPropPoint");
                     int nStrength     = Global.GetRoleParamsInt32FromDB(client, "PropStrength");
                     int nIntelligence = Global.GetRoleParamsInt32FromDB(client, "PropIntelligence");
                     int nDexterity    = Global.GetRoleParamsInt32FromDB(client, "PropDexterity");
                     int nConstitution = Global.GetRoleParamsInt32FromDB(client, "PropConstitution");
                     int nRemainPoint  = nTotal - nStrength - nIntelligence - nDexterity - nConstitution;
                     if (nRemainPoint < nPoint)
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("魔剑士初始加点不足,无法创建魔剑士, RoleID={0}", nRoleID), null, true);
                     }
                     else
                     {
                         client.ClientData.PropStrength += int.Parse(MagicSwordInitAttrArr[0]);
                         Global.SaveRoleParamsInt32ValueToDB(client, "PropStrength", client.ClientData.PropStrength, true);
                         client.ClientData.PropIntelligence += int.Parse(MagicSwordInitAttrArr[1]);
                         Global.SaveRoleParamsInt32ValueToDB(client, "PropIntelligence", client.ClientData.PropIntelligence, true);
                         client.ClientData.PropDexterity += int.Parse(MagicSwordInitAttrArr[2]);
                         Global.SaveRoleParamsInt32ValueToDB(client, "PropDexterity", client.ClientData.PropDexterity, true);
                         client.ClientData.PropConstitution += int.Parse(MagicSwordInitAttrArr[3]);
                         Global.SaveRoleParamsInt32ValueToDB(client, "PropConstitution", client.ClientData.PropConstitution, true);
                         client.ClientData.LifeV  = (int)RoleAlgorithm.GetMaxLifeV(client);
                         client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client);
                         if (client.ClientData.CurrentLifeV > client.ClientData.LifeV)
                         {
                             client.ClientData.CurrentLifeV = client.ClientData.LifeV;
                         }
                         if (client.ClientData.CurrentMagicV > client.ClientData.MagicV)
                         {
                             client.ClientData.CurrentMagicV = client.ClientData.MagicV;
                         }
                         GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                         GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                     }
                 }
             }
             catch (Exception ex)
             {
                 DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
             }
         }
     }
 }
Пример #27
0
        public int ActivationStarConstellation(GameClient client, int nStarSiteID)
        {
            int result;

            if (nStarSiteID < 1 || nStarSiteID > this.m_MaxStarSiteID)
            {
                result = -1;
            }
            else
            {
                if (client.ClientData.RoleStarConstellationInfo == null)
                {
                    client.ClientData.RoleStarConstellationInfo = new Dictionary <int, int>();
                }
                int nStarSlot = 0;
                client.ClientData.RoleStarConstellationInfo.TryGetValue(nStarSiteID, out nStarSlot);
                if (nStarSlot >= this.m_MaxStarSlotID)
                {
                    result = -1;
                }
                else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.GamePayerRolePartXingZuo, false))
                {
                    result = -1;
                }
                else
                {
                    nStarSlot++;
                    int nOccupation = client.ClientData.Occupation;
                    Dictionary <int, Dictionary <int, StarConstellationDetailInfo> > dicTmp = null;
                    if (!this.m_StarConstellationDetailInfo.TryGetValue(nOccupation, out dicTmp) || dicTmp == null)
                    {
                        result = -2;
                    }
                    else
                    {
                        Dictionary <int, StarConstellationDetailInfo> dicTmpInfo = null;
                        if (!dicTmp.TryGetValue(nStarSiteID, out dicTmpInfo) || dicTmpInfo == null)
                        {
                            result = -2;
                        }
                        else
                        {
                            StarConstellationDetailInfo tmpInfo = null;
                            if (!dicTmpInfo.TryGetValue(nStarSlot, out tmpInfo) || tmpInfo == null)
                            {
                                result = -2;
                            }
                            else
                            {
                                int nNeeChangeLife = tmpInfo.ChangeLifeLimit;
                                int nNeedLev       = tmpInfo.LevelLimit;
                                int nReqUnionLevel = Global.GetUnionLevel(nNeeChangeLife, nNeedLev, false);
                                if (Global.GetUnionLevel(client.ClientData.ChangeLifeCount, client.ClientData.Level, false) < nReqUnionLevel)
                                {
                                    result = -3;
                                }
                                else
                                {
                                    int nGoods = tmpInfo.NeedGoodsID;
                                    int nNum   = tmpInfo.NeedGoodsNum;
                                    if (nGoods > 0 && nNum > 0)
                                    {
                                        GoodsData goods = Global.GetGoodsByID(client, nGoods);
                                        if (goods == null || goods.GCount < nNum)
                                        {
                                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(533, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                            return(-5);
                                        }
                                    }
                                    int nNeedStarSoul = tmpInfo.NeedStarSoul;
                                    if (nNeedStarSoul > 0)
                                    {
                                        if (nNeedStarSoul > client.ClientData.StarSoul)
                                        {
                                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(534, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                            return(-9);
                                        }
                                    }
                                    int nNeedMoney = tmpInfo.NeedJinBi;
                                    if (nNeedMoney > 0)
                                    {
                                        if (!Global.SubBindTongQianAndTongQian(client, nNeedMoney, "激活星座"))
                                        {
                                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(535, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                            return(-10);
                                        }
                                    }
                                    if (nGoods > 0 && nNum > 0)
                                    {
                                        bool usedBinding     = false;
                                        bool usedTimeLimited = false;
                                        if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nGoods, nNum, false, out usedBinding, out usedTimeLimited, false))
                                        {
                                            return(-6);
                                        }
                                    }
                                    if (nNeedStarSoul > 0)
                                    {
                                        GameManager.ClientMgr.ModifyStarSoulValue(client, -nNeedStarSoul, "激活星座", true, true);
                                    }
                                    int nRate = Global.GetRandomNumber(1, 10001);
                                    if (nRate > tmpInfo.SuccessRate)
                                    {
                                        GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(536, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                        result = -100;
                                    }
                                    else
                                    {
                                        TCPOutPacket         tcpOutPacket    = null;
                                        string               strDbCmd        = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, nStarSiteID, nStarSlot);
                                        TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 10166, strDbCmd, out tcpOutPacket, client.ServerId);
                                        if (TCPProcessCmdResults.RESULT_FAILED == dbRequestResult)
                                        {
                                            result = -7;
                                        }
                                        else
                                        {
                                            Global.PushBackTcpOutPacket(tcpOutPacket);
                                            PropertyInfo tmpProp = tmpInfo.Propertyinfo;
                                            if (tmpProp == null)
                                            {
                                                result = -8;
                                            }
                                            else
                                            {
                                                client.ClientData.RoleStarConstellationInfo[nStarSiteID] = nStarSlot;
                                                this.ActivationStarConstellationProp(client, tmpProp, 1);
                                                if (0 == nStarSlot % 12)
                                                {
                                                    this.ActivationStarConstellationExtendProp(client, nStarSiteID);
                                                    GameManager.StarConstellationMgr.InitPlayerStarConstellationPorperty(client);
                                                }
                                                GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ActiveXingZuo));
                                                ProcessTask.ProcessRoleTaskVal(client, TaskTypes.XingZuoStar, -1);
                                                GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                                client.ClientData.LifeV  = (int)RoleAlgorithm.GetMaxLifeV(client);
                                                client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client);
                                                GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                                result = 1;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Пример #28
0
        public ShenQiData LevelUpShenQiData(GameClient client, int useBaoJi)
        {
            ShenQiData result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.ShenQi, false))
            {
                result = new ShenQiData
                {
                    UpResultType = -1
                };
            }
            else
            {
                ShenQiData data = client.ClientData.shenQiData;
                try
                {
                    if (null == data)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 注入失败,获取角色神器数据错误,角色id:{0}", client.ClientData.RoleID), null, true);
                        return(new ShenQiData
                        {
                            UpResultType = 0
                        });
                    }
                    ArtifactItem artifactItem = null;
                    lock (this.ShenQiRunTimeData.Mutex)
                    {
                        this.ShenQiRunTimeData.ArtifactXmlDict.TryGetValue(data.ShenQiID, out artifactItem);
                    }
                    if (null == artifactItem)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 注入失败,获取角色神器数据配置项错误,角色id:{0}, ShenQiID:{1}", client.ClientData.RoleID, data.ShenQiID), null, true);
                        return(new ShenQiData
                        {
                            UpResultType = 0
                        });
                    }
                    if (client.ClientData.ShenLiJingHuaPoints < artifactItem.CostShenLiJingHua)
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -2
                        });
                    }
                    int GoldGoodsNum = 0;
                    if (artifactItem.CostGoldGoodsID > 0)
                    {
                        GoldGoodsNum = Global.GetTotalGoodsCountByID(client, artifactItem.CostGoldGoodsID);
                    }
                    if (client.ClientData.YinLiang < artifactItem.CostGoldCoin && (artifactItem.CostGoldGoodsNum <= 0 || GoldGoodsNum < artifactItem.CostGoldGoodsNum))
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -4
                        });
                    }
                    if (useBaoJi > 0 && client.ClientData.UserMoney < artifactItem.CostDiamond && !HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, artifactItem.CostDiamond))
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -3
                        });
                    }
                    GameManager.ClientMgr.ModifyShenLiJingHuaPointsValue(client, -artifactItem.CostShenLiJingHua, "神器注入_精华", true, true);
                    if (artifactItem.CostGoldGoodsNum > 0 && GoldGoodsNum >= artifactItem.CostGoldGoodsNum)
                    {
                        bool oneUseBind      = false;
                        bool oneUseTimeLimit = false;
                        if (Global.UseGoodsBindOrNot(client, artifactItem.CostGoldGoodsID, artifactItem.CostGoldGoodsNum, true, out oneUseBind, out oneUseTimeLimit) < 1)
                        {
                            return(new ShenQiData
                            {
                                UpResultType = -4
                            });
                        }
                    }
                    else if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, artifactItem.CostGoldCoin, "神器注入_金币", false))
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -4
                        });
                    }
                    if (useBaoJi > 0)
                    {
                        if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, artifactItem.CostDiamond, "神器注入_钻石", true, true, false, DaiBiSySType.ShenQiXiTong))
                        {
                            return(new ShenQiData
                            {
                                UpResultType = -4
                            });
                        }
                    }
                    int   rate     = 0;
                    int   r        = Global.GetRandomNumber(0, 101);
                    int[] addProps = null;
                    for (int i = 0; i < artifactItem.QiangHuaRate.Length; i++)
                    {
                        rate += artifactItem.QiangHuaRate[i];
                        if (r <= rate)
                        {
                            addProps       = artifactItem.QiangHuaArray[i];
                            data.BurstType = i;
                            if (useBaoJi > 0 && 0 == i)
                            {
                                addProps       = artifactItem.QiangHuaArray[1];
                                data.BurstType = 1;
                            }
                            break;
                        }
                    }
                    data.LifeAdd      += addProps[0];
                    data.LifeAdd       = ((data.LifeAdd > artifactItem.PropArray[0]) ? artifactItem.PropArray[0] : data.LifeAdd);
                    data.AttackAdd    += addProps[1];
                    data.AttackAdd     = ((data.AttackAdd > artifactItem.PropArray[1]) ? artifactItem.PropArray[1] : data.AttackAdd);
                    data.DefenseAdd   += addProps[2];
                    data.DefenseAdd    = ((data.DefenseAdd > artifactItem.PropArray[2]) ? artifactItem.PropArray[2] : data.DefenseAdd);
                    data.ToughnessAdd += addProps[3];
                    data.ToughnessAdd  = ((data.ToughnessAdd > artifactItem.PropArray[3]) ? artifactItem.PropArray[3] : data.ToughnessAdd);
                    if (data.LifeAdd < artifactItem.PropArray[0] || data.DefenseAdd < artifactItem.PropArray[2] || data.AttackAdd < artifactItem.PropArray[1] || data.ToughnessAdd < artifactItem.PropArray[3])
                    {
                        data.UpResultType = 1;
                    }
                    else if (this.ShenQiRunTimeData.ArtifactXmlDict.ContainsKey(data.ShenQiID + 1))
                    {
                        data.UpResultType = 2;
                        data.ShenQiID++;
                        data.LifeAdd      = 0;
                        data.AttackAdd    = 0;
                        data.DefenseAdd   = 0;
                        data.ToughnessAdd = 0;
                    }
                    else
                    {
                        data.UpResultType = 3;
                    }
                    data.ShenLiJingHuaLeft = client.ClientData.ShenLiJingHuaPoints;
                    List <int> props = new List <int>();
                    props.AddRange(new int[]
                    {
                        data.ShenQiID,
                        data.LifeAdd,
                        data.AttackAdd,
                        data.DefenseAdd,
                        data.ToughnessAdd
                    });
                    Global.SaveRoleParamsIntListToDB(client, props, "36", true);
                    client.ClientData.shenQiData = data;
                    this.UpdateRoleShenQiProps(client);
                    this.UpdateRoleTouhgnessProps(client);
                    if (data.UpResultType == 2 || data.UpResultType == 3)
                    {
                        this.UpdateRoleGodProps(client);
                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, "神像", "神器升阶", client.ClientData.RoleName, "系统", "增加", 1, client.ClientData.ZoneID, client.strUserID, data.ShenQiID, client.ServerId, null);
                    }
                    GameManager.logDBCmdMgr.AddDBLogInfo(-1, "韧性", "神器注入_韧性", client.ClientData.RoleName, "系统", "增加", addProps[3], client.ClientData.ZoneID, client.strUserID, Convert.ToInt32(RoleAlgorithm.GetExtProp(client, 101)), client.ServerId, null);
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 升级角色神器数据错误 roleid={0} ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
                    return(data);
                }
                result = data;
            }
            return(result);
        }
Пример #29
0
 public void UpdateRoleTouhgnessProps(GameClient client)
 {
     try
     {
         double toughness = RoleAlgorithm.GetExtProp(client, 101);
         if (toughness >= 1.0)
         {
             List <ToughnessItem> toughnessList = null;
             lock (this.ShenQiRunTimeData.Mutex)
             {
                 toughnessList = this.ShenQiRunTimeData.ToughnessXmlList;
             }
             if (toughnessList != null && toughnessList.Count >= 1)
             {
                 int index;
                 for (index = toughnessList.Count - 1; index >= 0; index--)
                 {
                     if (toughness >= (double)toughnessList[index].Toughness)
                     {
                         break;
                     }
                 }
                 ToughnessItem toughnessItem = (index >= 0) ? toughnessList[index] : null;
                 if (null != toughnessItem)
                 {
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         51,
                         toughnessItem.DeLucky
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         52,
                         toughnessItem.DeFatalAttack
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         53,
                         toughnessItem.DeDoubleAttack
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         64,
                         toughnessItem.DeSavagePercent
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         65,
                         toughnessItem.DeColdPercent
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         66,
                         toughnessItem.DeRuthlessPercent
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         97,
                         toughnessItem.DeFrozenPercent
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         98,
                         toughnessItem.DePalsyPercent
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         99,
                         toughnessItem.DeSpeedDownPercent
                     });
                     client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[]
                     {
                         27,
                         100,
                         toughnessItem.DeBlowPercent
                     });
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 更新角色韧性加成错误 roleid={0} ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
     }
 }