예제 #1
0
        public static ExtData GetClientExtData(GameClient client)
        {
            ExtData result;

            if (client.extData != null)
            {
                result = client.extData;
            }
            else
            {
                int roleId = client.ClientData.RoleID;
                lock (ExtDataManager.Mutex)
                {
                    ExtData extData;
                    if (!ExtDataManager.ExtDataDict.TryGetValue(roleId, out extData))
                    {
                        extData = new ExtData();
                        ExtDataManager.ExtDataDict[roleId] = extData;
                    }
                    client.extData = extData;
                    result         = extData;
                }
            }
            return(result);
        }
예제 #2
0
        public void ClearBianShen(GameClient client)
        {
            ExtData extData    = ExtDataManager.GetClientExtData(client);
            long    maxCdTicks = TimeUtil.NOW();

            if (maxCdTicks < extData.BianShenToTicks)
            {
                extData.BianShenToTicks = 0L;
                extData.BianShenCDTicks = maxCdTicks + extData.BianShenCdTime;
                extData.skillIDList     = null;
                client.buffManager.SetStatusBuff(121, 0L, 0L, 0L);
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
 public static void WriteZhanLiLogs(GameClient client)
 {
     try
     {
         if (client.ClientData.ChangeLifeCount >= 4)
         {
             bool    writeZhanLiLogs = false;
             long    nowTicks        = TimeUtil.NOW();
             long    nowZhanLi       = (long)client.ClientData.CombatForce;
             int     offsetDay       = TimeUtil.GetOffsetDayNow();
             ExtData extData         = ExtDataManager.GetClientExtData(client);
             lock (extData.ZhanLiLogged)
             {
                 if (extData.OffsetDay != offsetDay)
                 {
                     extData.LastZhanLi              = 0L;
                     extData.ZhanLiWriteten          = 0L;
                     extData.OffsetDay               = offsetDay;
                     extData.ZhanLiLogNextWriteTicks = nowTicks + (long)Global.GetRandomNumber(20000, 180000);
                     extData.ZhanLiLogged.Clear();
                 }
                 else if (extData.ZhanLiWriteten < nowZhanLi && extData.ZhanLiLogNextWriteTicks < nowTicks)
                 {
                     extData.ZhanLiLogNextWriteTicks = nowTicks + 5000L;
                     if (extData.LastZhanLi != nowZhanLi)
                     {
                         extData.LastZhanLi = nowZhanLi;
                     }
                     else if (!extData.ZhanLiLogged.Contains((long)client.ClientData.CombatForce))
                     {
                         writeZhanLiLogs        = true;
                         extData.ZhanLiWriteten = nowZhanLi;
                         extData.ZhanLiLogged.Add((long)client.ClientData.CombatForce);
                     }
                 }
             }
             if (writeZhanLiLogs)
             {
                 StringBuilder sb = new StringBuilder();
                 Global.PrintSomeProps(client, ref sb);
                 LogManager.WriteLog(LogTypes.Alert, sb.ToString(), null, true);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
예제 #5
0
        private bool ProcessExecuteHuiJiHuTiCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int     result   = 0;
            long    nowTicks = TimeUtil.NOW();
            ExtData extData  = ExtDataManager.GetClientExtData(client);

            if (nowTicks < extData.HuiJiCDTicks)
            {
                result = -2007;
            }
            else if (!this.IsGongNengOpened(client))
            {
                result = -12;
            }
            else
            {
                long     cdTime       = 0L;
                int      durationTime = 0;
                double[] props        = null;
                lock (this.RuntimeData.Mutex)
                {
                    EmblemStarInfo starInfo;
                    if (!this.RuntimeData.EmblemStarDict.Value.TryGetValue(client.ClientData.HuiJiData.huiji, out starInfo))
                    {
                        result = -20;
                        goto IL_150;
                    }
                    EmblemUpInfo upInfo = starInfo.EmblemUpInfo;
                    if (null == upInfo)
                    {
                        result = -20;
                        goto IL_150;
                    }
                    cdTime       = (long)upInfo.CDTime;
                    durationTime = upInfo.DurationTime;
                    props        = upInfo.ExtPropTempValues;
                }
                extData.HuiJiCDTicks = nowTicks + (long)durationTime + cdTime;
                extData.HuiJiCdTime  = cdTime;
                client.buffManager.SetStatusBuff(116, nowTicks, (long)durationTime, 0L);
                this.OnHuiJiStateChange(client, true, client.ClientData.HuiJiData.huiji, durationTime, props);
                Global.RemoveBufferData(client, 119);
                ZuoQiManager.getInstance().RoleDisMount(client, true);
            }
IL_150:
            client.sendCmd <int>(nID, result, false);
            return(true);
        }
예제 #6
0
        public void OnInitGame(GameClient client)
        {
            if (client.ClientData.HuiJiData == null)
            {
                client.ClientData.HuiJiData = new RoleHuiJiData();
            }
            bool resetCD = false;

            int[] array = this.RuntimeData.EmblemFull;
            if (array != null && array[0] > 0)
            {
                for (int i = 1; i < array.Length; i++)
                {
                    if (array[i] == client.ClientData.MapCode)
                    {
                        resetCD = true;
                        break;
                    }
                }
            }
            ExtData extData = ExtDataManager.GetClientExtData(client);

            this.InitDataByTask(client);
            lock (this.RuntimeData.Mutex)
            {
                EmblemStarInfo starInfo;
                if (this.RuntimeData.EmblemStarDict.Value.TryGetValue(client.ClientData.HuiJiData.huiji, out starInfo) && starInfo.EmblemUpInfo != null)
                {
                    client.ClientData.PropsCacheManager.SetExtProps(new object[]
                    {
                        PropsSystemTypes.HuiJiHuTi,
                        starInfo.ExtPropValues
                    });
                    if (resetCD)
                    {
                        extData.HuiJiCDTicks = 0L;
                    }
                    else
                    {
                        extData.HuiJiCDTicks = TimeUtil.NOW() + (long)starInfo.EmblemUpInfo.CDTime;
                    }
                    extData.HuiJiCdTime = (long)starInfo.EmblemUpInfo.CDTime;
                }
            }
        }
예제 #7
0
        public bool CanUseMagic(GameClient client, int skillID)
        {
            ExtData    extData = ExtDataManager.GetClientExtData(client);
            List <int> list    = extData.skillIDList;

            if (client.buffManager.IsBuffEnabled(121))
            {
                if (list != null && list.Contains(skillID))
                {
                    return(true);
                }
            }
            else if (list == null || !list.Contains(skillID))
            {
                return(true);
            }
            return(false);
        }
예제 #8
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
             });
         }
     }
 }
예제 #9
0
        public void OnInitGame(GameClient client)
        {
            RoleBianShenData BianShenData = client.ClientData.BianShenData;

            if (BianShenData == null)
            {
                BianShenData = (client.ClientData.BianShenData = new RoleBianShenData());
            }
            bool resetCD = false;

            int[] array = this.RuntimeData.BianShenFull;
            if (array != null && array[0] > 0)
            {
                for (int i = 1; i < array.Length; i++)
                {
                    if (array[i] == client.ClientData.MapCode)
                    {
                        resetCD = true;
                        break;
                    }
                }
            }
            ExtData extData = ExtDataManager.GetClientExtData(client);

            this.InitDataByTask(client);
            if (BianShenData.BianShen > 0)
            {
                extData.BianShenToTicks = 0L;
                extData.skillIDList     = null;
                lock (this.RuntimeData.Mutex)
                {
                    List <BianShenStarInfo> list;
                    if (this.RuntimeData.BianShenUpDict.TryGetValue(client.ClientData.Occupation, out list) && BianShenData.BianShen < list.Count)
                    {
                        BianShenStarInfo starInfo = list[BianShenData.BianShen];
                        if (null != starInfo)
                        {
                            client.ClientData.PropsCacheManager.SetExtProps(new object[]
                            {
                                PropsSystemTypes.BianShen,
                                starInfo.ExtPropValues
                            });
                            if (resetCD)
                            {
                                extData.BianShenCDTicks = 0L;
                            }
                            else
                            {
                                long nowTicks   = TimeUtil.NOW();
                                long maxCdTicks = nowTicks + extData.BianShenCdTime;
                                if (maxCdTicks < extData.BianShenCDTicks)
                                {
                                    extData.BianShenCDTicks = maxCdTicks;
                                }
                                if (nowTicks < extData.BianShenCDTicks)
                                {
                                    GameManager.ClientMgr.NotifySkillCDTime(client, -1, extData.BianShenCDTicks, true);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #10
0
        private bool ProcessExecuteBianShenCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int  result   = 0;
            long nowTicks = TimeUtil.NOW();

            if (!this.CanBianShenByMap(client))
            {
                result = -21;
            }
            else if (client.ClientData.IsDongJie())
            {
                result = -500;
            }
            else
            {
                ExtData extData = ExtDataManager.GetClientExtData(client);
                if (nowTicks < extData.BianShenCDTicks)
                {
                    result = -2007;
                }
                else if (!this.IsGongNengOpened(client) || client.ClientData.HideGM > 0)
                {
                    result = -12;
                }
                else
                {
                    ZuoQiManager.getInstance().RoleDisMount(client, true);
                    long             cdTime       = (long)(this.RuntimeData.BianShenCDSecs * 1000);
                    int              durationTime = 0;
                    int              skillLevel   = 1;
                    double[]         props        = null;
                    List <int>       skillIDList  = null;
                    BianShenStarInfo starInfo;
                    lock (this.RuntimeData.Mutex)
                    {
                        if (!this.RuntimeData.BianShenStarDict.Value.TryGetValue(client.ClientData.BianShenData.BianShen, out starInfo))
                        {
                            result = -20;
                            goto IL_4E7;
                        }
                        skillLevel = starInfo.Level;
                    }
                    string strCostList = "";
                    long   dayAndCount = client.ClientData.MoneyData[147];
                    int    dayid       = (int)(dayAndCount / 10000L);
                    int    dayCount    = (int)(dayAndCount % 10000L);
                    if (dayid != TimeUtil.GetOffsetDayNow())
                    {
                        dayCount = 0;
                        dayid    = TimeUtil.GetOffsetDayNow();
                    }
                    if (dayCount < this.RuntimeData.FreeNum)
                    {
                        dayCount++;
                        dayAndCount = (long)(dayid * 10000 + dayCount);
                        client.ClientData.MoneyData[147] = dayAndCount;
                        Global.SaveRoleParamsInt64ValueToDB(client, "10216", dayAndCount, true);
                        GameManager.ClientMgr.NotifySelfPropertyValue(client, 147, dayAndCount);
                    }
                    else if (!GoodsUtil.CostGoodsList(client, this.RuntimeData.NeedGoods, false, ref strCostList, "变身"))
                    {
                        result = -6;
                        goto IL_4E7;
                    }
                    int       damageType = OccupationUtil.GetOccuDamageType(client.ClientData.OccupationIndex);
                    GoodsData goodsData  = client.UsingEquipMgr.GetGoodsDataByCategoriy(client, 28);
                    if (null != goodsData)
                    {
                        FashionBagData fashionBagData = FashionManager.getInstance().GetFashionBagData(client, goodsData);
                        if (fashionBagData != null && fashionBagData.FasionTab == 7)
                        {
                            if (damageType == 1)
                            {
                                skillIDList = fashionBagData.MagicSkill;
                            }
                            else
                            {
                                skillIDList = fashionBagData.AttackSkill;
                            }
                            durationTime = fashionBagData.BianShenDuration;
                            if (fashionBagData.BianShenEffect > 0)
                            {
                                lock (this.RuntimeData.Mutex)
                                {
                                    FashionEffectInfo info;
                                    if (this.RuntimeData.FashionEffectInfoDict.Value.TryGetValue(fashionBagData.BianShenEffect, out info))
                                    {
                                        props = info.ExtPropValues;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        durationTime = starInfo.Duration;
                        if (damageType == 1)
                        {
                            skillIDList = starInfo.MagicSkill;
                        }
                        else
                        {
                            skillIDList = starInfo.AttackSkill;
                        }
                    }
                    if (null != skillIDList)
                    {
                        lock (client.ClientData.SkillDataList)
                        {
                            using (List <int> .Enumerator enumerator = skillIDList.GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    int       skillID     = enumerator.Current;
                                    SkillData mySkillData = client.ClientData.SkillDataList.Find((SkillData x) => x.SkillID == skillID);
                                    if (null == mySkillData)
                                    {
                                        SkillData skillData = new SkillData();
                                        skillData.SkillID    = skillID;
                                        skillData.SkillLevel = skillLevel;
                                        client.ClientData.SkillDataList.Add(skillData);
                                    }
                                    else if (mySkillData.SkillLevel != skillLevel)
                                    {
                                        mySkillData.SkillLevel = skillLevel;
                                    }
                                }
                            }
                        }
                    }
                    extData.skillIDList     = skillIDList;
                    extData.BianShenCDTicks = nowTicks + cdTime + (long)(durationTime * 1000);
                    extData.BianShenCdTime  = cdTime;
                    extData.BianShenToTicks = nowTicks + (long)(durationTime * 1000);
                    client.buffManager.SetStatusBuff(121, nowTicks, (long)(durationTime * 1000), 0L);
                    this.OnBianShenStateChange(client, true, client.ClientData.BianShenData.BianShen, durationTime, props);
                    GameManager.ClientMgr.NotifySkillCDTime(client, -1, extData.BianShenCDTicks, false);
                }
            }
IL_4E7:
            client.sendCmd <int>(nID, result, false);
            return(true);
        }
예제 #11
0
        public void AddSkillCoolDownForClient(GameClient client, int skillID)
        {
            SystemXmlItem systemMagic = null;

            if (GameManager.SystemMagicQuickMgr.MagicItemsDict.TryGetValue(skillID, out systemMagic))
            {
                long nowTicks  = TimeUtil.NOW();
                int  cdTime    = Global.GMax(0, systemMagic.GetIntValue("CDTime", -1));
                int  pubCDTime = Global.GMax(0, systemMagic.GetIntValue("PubCDTime", -1));
                if (cdTime <= 0)
                {
                    int nParentMagicID = systemMagic.GetIntValue("ParentMagicID", -1);
                    if (nParentMagicID > 0)
                    {
                        if (GameManager.SystemMagicQuickMgr.MagicItemsDict.TryGetValue(nParentMagicID, out systemMagic))
                        {
                            cdTime = Global.GMax(0, systemMagic.GetIntValue("CDTime", -1));
                        }
                    }
                }
                long delayTicks = Data.MaxServerClientTimeDiff;
                if (client.ClientData.CurrentMagicCode == skillID)
                {
                    delayTicks = nowTicks - client.ClientData.CurrentMagicTicks;
                }
                if (cdTime > 0)
                {
                    cdTime *= 1000;
                    if (client.ClientData.CurrentMagicCode == skillID && client.ClientData.CurrentMagicCDSubPercent > 0.0)
                    {
                        cdTime = Convert.ToInt32((double)cdTime * (1.0 - client.ClientData.CurrentMagicCDSubPercent));
                        cdTime = (int)Math.Max((long)cdTime, delayTicks);
                        int nextMagicID = systemMagic.GetIntValue("NextMagicID", -1);
                        if (nextMagicID <= 0)
                        {
                            client.ClientData.CurrentMagicCDSubPercent = 0.0;
                        }
                    }
                    Global.AddCoolDownItem(this.SkillCoolDownDict, skillID, nowTicks, (long)cdTime - delayTicks);
                    if (systemMagic.GetStringValue("HorseSkill") == "1")
                    {
                        ExtData extData = ExtDataManager.GetClientExtData(client);
                        extData.ZuoQiSkillCDTicks = nowTicks + (long)cdTime - delayTicks;
                        extData.ZuoQiSkillCdTime  = (long)cdTime - delayTicks;
                    }
                }
                if (pubCDTime > 0)
                {
                    client.ClientData.CurrentMagicActionEndTicks = nowTicks - delayTicks + (long)pubCDTime;
                    if (null != client.ClientData.SkillDataList)
                    {
                        for (int i = 0; i < client.ClientData.SkillDataList.Count; i++)
                        {
                            SkillData skillData = client.ClientData.SkillDataList[i];
                            if (null != skillData)
                            {
                                Global.AddCoolDownItem(this.SkillCoolDownDict, skillData.SkillID, nowTicks, (long)pubCDTime - delayTicks);
                            }
                        }
                    }
                }
            }
        }