Exemple #1
0
        /*
         * 通过灵魂晶石来锻造提高武器的品质,每个等级锻造的成功率不一样。
         * 1--2,2--3,3--4,4--5的升级成功率都是100%。
         * 普通升良(0--1):30%成功
         * 良升上(1--2):12%成功
         * 上升精(2--3):6%成功
         * 精升极(3--4):4%成功
         *
         */
        private int RateSuccForQuality(GameStruct.RoleItemInfo item)
        {
            int iQuality = item.GetQuality();

            if (iQuality == 0)
            {
                return(30);
            }
            else if (iQuality == 1)
            {
                return(12);
            }
            else if (iQuality == 2)
            {
                return(6);
            }
            else if (iQuality == 3)
            {
                return(4);
            }
            //神器
            else if (iQuality == 4)
            {
                return(12);
            }
            else if (iQuality == 5)
            {
                return(6);
            }
            else if (iQuality == 6)
            {
                return(4);
            }
            return(-1);
        }
Exemple #2
0
        //宝石镶嵌
        public void GemSet(PlayerObject play, uint srcid, uint destid, byte index)
        {
            GameStruct.RoleItemInfo item    = play.GetItemSystem().FindItem(destid);
            GameStruct.RoleItemInfo srcitem = play.GetItemSystem().FindItem(srcid);
            if (item == null || srcitem == null)
            {
                return;
            }
            if (!srcitem.IsGem())
            {
                return;
            }
            if (item.GetGemCount() < index)
            {
                return;
            }
            if (item.GetGemType(index) != 255)
            {
                return;                                //已有宝石-- 要先拆除再镶嵌
            }
            play.GetItemSystem().DeleteItemByID(srcid);
            item.SetGemType(index, srcitem.GetGemType());

            play.GetItemSystem().UpdateItemInfo(destid);
        }
Exemple #3
0
        //装备打洞 参数:玩家对象,要打洞的道具id,打的洞序号[0为第一个洞]
        public void OpenGem(PlayerObject play, uint srcid, uint destid)
        {
            const int YUEGUANGBAOHE             = 723002; //月光宝盒id
            const int YUEGUANGBAOHEZENGQIANGBAN = 820300; //月光宝盒增强版 id
            const int SHENSHENGYUEGUANGBAOHE    = 742178; //神圣月光宝盒

            GameStruct.RoleItemInfo item    = play.GetItemSystem().FindItem(destid);
            GameStruct.RoleItemInfo srcitem = play.GetItemSystem().FindItem(srcid);
            if (item == null || srcitem == null)
            {
                return;
            }
            byte index = 0;

            switch (srcitem.itemid)
            {
            case YUEGUANGBAOHE:
            {
                if (item.GetGemCount() != 0)
                {
                    return;
                }
                index = 0;
                break;
            }

            case YUEGUANGBAOHEZENGQIANGBAN:
            {
                if (item.GetGemCount() != 1)
                {
                    return;
                }
                index = 1;
                break;
            }

            //第三个洞 2015.11.21 道具协议有bug。 先不开
            //11.21 开了
            case SHENSHENGYUEGUANGBAOHE:
            {
                if (item.GetGemCount() != 2)
                {
                    return;
                }
                index = 2;
                break;
            }

            //第三个洞其他协议打-- 这个不打。。-。- 2015.9.21
            default:
            {
                return;
            }
            }
            play.GetItemSystem().DeleteItemByID(srcid);
            item.OpenGem(index);
            play.GetItemSystem().UpdateItemInfo(item.id);
        }
Exemple #4
0
        public MsgPtichItemInfo(RoleItemInfo item,uint _ptich_obj_id,int _price,byte sell_byte,bool isRemote = false/*是否是远程摊位*/)
        {
            mMsgLen = 88;
            mParam = PacketProtoco.S_PTICH_ITEMINFO;

            //幻兽起始id
            if (item.typeid >= 2000000000)
            {
                postion = NetMsg.MsgItemInfo.ITEMPOSITION_EUDEMON_PACK;
                id = item.typeid;
                max_dura = cur_dura = 0;
            }
            else
            {
                id = item.id;
                postion = NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK;
                max_dura = cur_dura = (short)item.amount;//游戏当前损耗度无用
            }
            forgetname = item.forgename;
           
            ptich_obj_id = _ptich_obj_id;
            price = _price;
            base_item_id = item.itemid;

          //  { 98, 0, 84, 4, 110, 134, 61, 138, 67, 162, 1, 0, 14, 0, 0, 0, 118, 91, 16, 0, 0, 0, 0, 0, 3, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 198, 230, 210, 236, 202, 222, 79, 208, 205, 0, 0, 0 };
         
            gem1 = item.GetGemType(0);
            gem2 = item.GetGemType(1);
            gem3 = item.GetGemType(2);
            strong_lv = item.GetStrongLevel();
            soul_lv = (short)item.war_ghost_exp;
            di_attack = item.di_attack;
            shui_attack = item.shui_attack;
            huo_attack = item.huo_attack;
            feng_attack = item.feng_attack;

            if (isRemote)
            {
                if (sell_byte == NetMsg.MsgOperateItem.PTICH_SELL_ITEM_GAMEGOLD)
                {
                    tag = 5;
                }
                else
                {
                    tag = 4;
                }
                
            }
            else
            {
                if (sell_byte == NetMsg.MsgOperateItem.PTICH_SELL_ITEM_GAMEGOLD)
                {
                    tag = 3;
                }
                else tag = 1;
            }

        }
Exemple #5
0
        //添加掉落道具信息
        public void AddDropItemObj(uint itemid, short x, short y, uint ownerid = 0, int time = 120000, GameStruct.RoleItemInfo info = null, RoleData_Eudemon eudemon = null)
        {
            DropItemObject obj = new DropItemObject(itemid, x, y, ownerid, time);

            obj.SetRoleItemInfo(info);
            obj.SetRoleEudemonInfo(eudemon);
            AddObject(obj);
            obj.RefreshVisibleObject();
            //广播给玩家
            obj.BroadcastInfo();
        }
Exemple #6
0
        //提升装备品质
        public void EquipQuality(PlayerObject play, uint srcid, uint materialid)
        {
            const int LINGHUNJINGSHI = 1037160; //灵魂晶石ID
            const int LINGHUNWANG    = 1037169; //灵魂王
            const int SHENQIZHILEI   = 1037200; //神祈之泪
            // const int HUNWUSHENQIZHILEI = 1025754; //魂武神祈之泪
            const int MAX_QUALIY = 7;           //最高品质 神器

            GameStruct.RoleItemInfo item         = play.GetItemSystem().FindItem(srcid);
            GameStruct.RoleItemInfo materialitem = play.GetItemSystem().FindItem(materialid);
            if (item == null || materialitem == null)
            {
                return;
            }
            if (item.GetQuality() == MAX_QUALIY)
            {
                return;                                  //已达到最高品质
            }
            int  rand    = GameStruct.IRandom.Random(1, 100);
            bool bUpdate = false;

            if (!play.GetItemSystem().IsEquip(item.itemid))
            {
                return;                                             //不是装备就不提升了
            }
            NetMsg.MsgEquipOperationRet ret = new NetMsg.MsgEquipOperationRet();
            ret.Create(null, play.GetGamePackKeyEx());
            ret.srcid  = srcid;
            ret.destid = materialid;
            ret.type   = 196610;//{2,0,3,0}
            if (materialitem.itemid == LINGHUNJINGSHI ||
                materialitem.itemid == SHENQIZHILEI)
            {
                //检测是否有足够的灵魂晶石或者神祈之类
                if (!play.GetItemSystem().DeleteItemByID(materialid))
                {
                    return;
                }
                if (rand < this.RateSuccForQuality(item))
                {
                    item.UpQuality();
                    bUpdate = true;
                    ret.ret = 1;
                }
            }
            else if (materialitem.itemid == LINGHUNWANG &&
                     item.GetQuality() <= 4 /*极品武器以下可以用灵魂王升级*/)
            {
                //检测是否有足够的灵魂王
                if (!play.GetItemSystem().DeleteItemByID(materialid))
                {
                    return;
                }
                item.UpQuality();
                bUpdate = true;
                ret.ret = 1;
            }
            if (bUpdate)
            {
                //锻造者名称-
                if (item.forgename.Length == 0)
                {
                    item.forgename = play.GetName();
                }
                play.GetItemSystem().UpdateItemInfo(item.id);
            }
            play.SendData(ret.GetBuffer());
        }
Exemple #7
0
        //武器升级时的成功率

        /*
         * 武器类(包括武器,项链,手镯,戒指,鞋子等):
         * 该类物品TYPE的百位和十位实际上就是武器的等级,等级为0--22,一共可升级22次。但如果升级时在itemtype表中找不到对应的数据,则表示不能升级了(例如:450205,如果要升级则升级为450215,但因为数据库中没有450215的数据,所以表示该武器不能再升级了。)
         * 升级成功率:
         * 当等级<4时,升级成功率为100%
         * 当等级<7时,升级成功率为:35%
         * 当等级<10时,升级成功率为:20%
         * 当等级<13时,升级成功率为:10%
         * 当等级<16时,升级成功率为:7%
         * 当等级<19时,升级成功率为:4%
         * 当等级>=19时,升级成功率为:2%
         *
         * 装备类(包括衣服,帽子和盾牌):
         * 该类物品TYPE的十位表示等级,等级为0--9,一共可升级9次。但如果升级时在itemtype表中找不到对应的数据,则表示不能升级了。
         * 当等级<2时,升级成功率100%
         * 当等级<4时,升级成功率为:35%
         * 当等级<6时,升级成功率为:20%
         * 当等级<7时,升级成功率为:10%
         * 当等级<8时,升级成功率为:7%
         * 当等级<9时,升级成功率为:4%
         */
        private int RateSuccForEquipLevel(GameStruct.RoleItemInfo pEquipItem)
        {
            int nLevel = pEquipItem.GetLevel();

            if (pEquipItem.IsShield() || pEquipItem.IsArmor() || pEquipItem.IsHelmet())
            {
                if (nLevel >= 0 && nLevel < 2)
                {
                    return(100);
                }
                else if (nLevel >= 2 && nLevel < 4)
                {
                    return(35);
                }
                else if (nLevel >= 4 && nLevel < 6)
                {
                    return(20);
                }
                else if (nLevel >= 6 && nLevel < 7)
                {
                    return(10);
                }
                else if (nLevel >= 7 && nLevel < 8)
                {
                    return(7);
                }
                else if (nLevel >= 8 && nLevel < 9)
                {
                    return(4);
                }
            }
            else
            {
                if (nLevel >= 0 && nLevel < 4)
                {
                    return(100);
                }
                else if (nLevel >= 4 && nLevel < 7)
                {
                    return(35);
                }
                else if (nLevel >= 7 && nLevel < 10)
                {
                    return(20);
                }
                else if (nLevel >= 10 && nLevel < 13)
                {
                    return(10);
                }
                else if (nLevel >= 13 && nLevel < 16)
                {
                    return(7);
                }
                else if (nLevel >= 16 && nLevel < 19)
                {
                    return(4);
                }
                else if (nLevel >= 19 && nLevel < 22)
                {
                    return(2);
                }
            }
            return(0);
        }
Exemple #8
0
        //装备提升魔魂等级参数:玩家对象 道具基本id 道具id 是否百分百成功
        public void EquipStrong(PlayerObject play, uint srcid, uint materialid)
        {
            const int MOHUNJINGSHI = 1037150; //魔魂晶石id
            const int MOHUNZHIXIN  = 1037159; //魔魂之心id

            GameStruct.RoleItemInfo item         = play.GetItemSystem().FindItem(srcid);
            GameStruct.RoleItemInfo materialitem = play.GetItemSystem().FindItem(materialid);
            if (item == null || materialitem == null)
            {
                return;
            }
            if (item.GetStrongLevel() >= MAX_STRONGLEVEL)
            {
                return;
            }
            if (item.GetStrongLevel() >= mListStrong.Count)
            {
                return;
            }
            int  rand    = GameStruct.IRandom.Random(1, 100);
            bool bUpdate = false;

            NetMsg.MsgEquipOperationRet ret = new NetMsg.MsgEquipOperationRet();
            ret.Create(null, play.GetGamePackKeyEx());
            ret.srcid  = srcid;
            ret.destid = materialid;
            ret.type   = 196611;//{3,0,3,0}

            if (materialitem.itemid != MOHUNJINGSHI && item.GetStrongLevel() > 9)
            {
                return;                                                                   //大于9级后必须使用魔魂晶石提升等级
            }
            if (materialitem.itemid == MOHUNJINGSHI)
            {
                //检测是否有足够的魔魂晶石
                if (!play.GetItemSystem().DeleteItemByID(materialid))
                {
                    return;
                }
                if (rand < mListStrong[item.GetStrongLevel()].chance)
                {
                    item.UpStrongLevel(1);
                    bUpdate = true;
                    ret.ret = 1;
                }
                else
                {
                    ret.ret = 0;
                    //强化等级9以下不往下掉了 2016.1.24
                    if (item.GetStrongLevel() > 9 && item.DecStrongLevel())
                    {
                        bUpdate = true;
                    }
                }
            }
            else if (materialitem.itemid == MOHUNZHIXIN) //魔魂之心必成功
            {
                if (!play.GetItemSystem().DeleteItemByID(materialid))
                {
                    return;
                }
                item.UpStrongLevel(1);
                bUpdate = true;
                ret.ret = 1;
            }

            if (bUpdate)
            {
                play.GetItemSystem().UpdateItemInfo(item.id);
            }

            play.SendData(ret.GetBuffer());
        }
Exemple #9
0
        //幻魔晶石 装备升级
        public void EquipLevel(PlayerObject play, uint srcid, uint materialid)
        {
            const int HUANMOJINGSHI = 1037170; //幻魔晶石id
            const int HUANMOZHIXIN  = 1037179; //幻魔之心

            const int MAX_LEVEL_EQUIP1 = 9;    //其他装备的提升等级
            const int MAX_LEVEL_EQUIP2 = 25;   //武器的提升等级

            GameStruct.RoleItemInfo item         = play.GetItemSystem().FindItem(srcid);
            GameStruct.RoleItemInfo materialitem = play.GetItemSystem().FindItem(materialid);
            if (item == null || materialitem == null)
            {
                return;
            }
            bool bUpdate = false;

            NetMsg.MsgEquipOperationRet ret = new NetMsg.MsgEquipOperationRet();
            ret.Create(null, play.GetGamePackKeyEx());
            ret.srcid  = srcid;
            ret.destid = materialid;
            ret.type   = 196612;//{4,0,3,0}
            int l = RateSuccForEquipLevel(item);

            if (item.IsShield() || item.IsArmor() || item.IsHelmet())
            {
                if (item.GetLevel() > MAX_LEVEL_EQUIP1)
                {
                    return;
                }
                if (materialitem.itemid == HUANMOZHIXIN)
                {
                    if (!play.GetItemSystem().DeleteItemByID(materialid))
                    {
                        return;
                    }
                    item.UpLevel();
                    bUpdate = true;
                    ret.ret = 1;
                }
                else if (materialitem.itemid == HUANMOJINGSHI)
                {
                    if (!play.GetItemSystem().DeleteItemByID(materialid))
                    {
                        return;
                    }
                    if (GameStruct.IRandom.Random(1, 100) < l)
                    {
                        item.UpLevel();
                        bUpdate = true;
                        ret.ret = 1;
                    }
                }
            }
            else
            {
                if (item.GetLevel() > MAX_LEVEL_EQUIP2)
                {
                    return;
                }
                if (materialitem.itemid == HUANMOZHIXIN)
                {
                    if (!play.GetItemSystem().DeleteItemByID(materialid))
                    {
                        return;
                    }
                    item.UpLevel();
                    ret.ret = 1;
                    bUpdate = true;
                }
                else if (materialitem.itemid == HUANMOJINGSHI)
                {
                    if (!play.GetItemSystem().DeleteItemByID(materialid))
                    {
                        return;
                    }
                    if (GameStruct.IRandom.Random(1, 100) < l)
                    {
                        item.UpLevel();
                        ret.ret = 1;
                        bUpdate = true;
                    }
                }
            }

            if (bUpdate)
            {
                play.GetItemSystem().UpdateItemInfo(item.id);
            }
            play.SendData(ret.GetBuffer());
            return;
        }
Exemple #10
0
        //死亡
        //target 击杀者 this 被击杀者
        public void Die(BaseObject target)
        {
            ushort nAddPk       = 0; //击杀者需要增加pk值
            int    nMinDropItem = 0; //最小掉落道具概率,百分比
            int    nMaxDropItem = 0; //最大掉落装备概率,百分比
            int    nMinGold     = 0; //最小掉落金钱概率
            int    nMaxGold     = 0; //最大掉落金钱概率
            int    nExp         = 0; //减少的经验百分比

            switch (mnNameType)
            {
            case Define.PK_NAME_WHITE:
            {
                nAddPk       = 20;
                nMinDropItem = 10;        //百分之十
                nMaxDropItem = 50;        //百分之五十
                nMinGold     = 10;
                nMaxGold     = 50;
                nExp         = 1; //百分之一
                break;
            }

            case Define.PK_NAME_RED:
            {
                nAddPk       = 10;
                nMinDropItem = 50;         //百分之五十
                nMaxDropItem = 100;        //百分之一百
                nMinGold     = 50;
                nMaxGold     = 100;
                nExp         = 20;
                break;
            }

            case Define.PK_NAME_BLACK:
            {
                nMinDropItem = 100;
                nMaxDropItem = 100;
                nMinGold     = 100;
                nMaxGold     = 100;
                nExp         = 30;
                nAddPk       = 0;   //如果自身是黑名,击杀者无罪
                break;
            }
            }
            //自身是蓝名,击杀者无罪
            if (IsPKing())
            {
                nAddPk = 0;
            }
            int nDropItem = IRandom.Random(nMinDropItem, nMaxDropItem);
            int nDropGold = IRandom.Random(nMinGold, nMaxGold);

            int nItemCount = (int)((float)play.GetItemSystem().GetBagCount() * ((float)nDropItem / 100f)); //掉落的道具数量

            if (nItemCount > 0)
            {
                while (nItemCount > 0)
                {
                    int nIndex    = IRandom.Random(0, nItemCount);
                    int nAddIndex = 0;
                    foreach (GameStruct.RoleItemInfo itemobj in play.GetItemSystem().GetDicItem().Values)
                    {
                        if (itemobj.postion == NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK)
                        {
                            if (nAddIndex == nIndex)
                            {
                                play.GetItemSystem().DropItemBag(itemobj.id);
                                break;
                            }
                            nAddIndex++;
                        }
                    }
                    nItemCount--;
                }
            }
            //掉落金钱
            int nGoldCount = (int)((float)play.GetBaseAttr().gold *((float)nDropGold / 100));

            if (nGoldCount > 0)
            {
                play.GetItemSystem().DropGold(nGoldCount);
            }
            //减少经验
            long nDecExp = play.GetBaseAttr().exp *(nExp / 100);

            if (nDecExp > 0)
            {
                play.ChangeAttribute(UserAttribute.EXP, (int)-nDecExp);
            }

            if (nAddPk > 0 && target.type == OBJECTTYPE.PLAYER)
            {
                (target as PlayerObject).ChangeAttribute(GameStruct.UserAttribute.PK, nAddPk);
            }

            //清除pk状态
            this.SetPKIng(false);

            //如果死亡时是黑名- 进监狱 并且身上穿戴装备随机掉一件-百分之百哦 2015.11.15
            if (mnNameType == Define.PK_NAME_BLACK)
            {
                int nIndex = 0;
                while (true)
                {
                    byte rand = IRandom.Random(NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR, NetMsg.MsgItemInfo.ITEMPOSITION_SHOES);
                    if (rand == NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONL)
                    {
                        continue;                                                  //游戏里并没有左武器
                    }
                    GameStruct.RoleItemInfo role_item_info = play.GetItemSystem().GetEquipByPostion(rand);
                    if (role_item_info != null)
                    {
                        play.GetItemSystem().DropItemEquip(role_item_info.id);
                        break;
                    }
                    nIndex++;
                    if (nIndex >= 8)
                    {
                        break;
                    }
                }
                play.ChangeMap(Define.PK_PRISON_MAPID, Define.PRISON_MAP_X, Define.PRISON_MAP_Y);
            }
        }
Exemple #11
0
        //收摊
        //bSendData 是否回发收摊数据- 玩家下线就不发
        public void ShutPtich(PlayerObject play, bool bSendData = true)
        {
            if (play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_PTICH) == null)
            {
                return;
            }
            uint ptich_obj_id = GetPtichObjectTypeID(play.GetCurrentPtichID());

            if (ptich_obj_id == 0)
            {
                return;
            }

            for (int i = 0; i < mListPtichInfo[play.GetCurrentPtichID()].mSellItemList.Count; i++)
            {
                GameStruct.RoleItemInfo item = null;
                if (mListPtichInfo[play.GetCurrentPtichID()].mSellItemList[i].item_id >= IDManager.eudemon_start_id)
                {
                    RoleData_Eudemon eudemon = play.GetEudemonSystem().FindEudemon(
                        mListPtichInfo[play.GetCurrentPtichID()].mSellItemList[i].item_id);
                    if (eudemon == null)
                    {
                        continue;
                    }
                    item = play.GetItemSystem().FindItem(eudemon.itemid);
                }
                else
                {
                    item = play.GetItemSystem().FindItem(
                        mListPtichInfo[play.GetCurrentPtichID()].mSellItemList[i].item_id);
                }

                if (item != null)
                {
                    //放回到包裹
                    //放回到包裹或幻兽背包
                    if (item.typeid >= IDManager.eudemon_start_id)
                    {
                        item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_EUDEMON_PACK;
                    }
                    else
                    {
                        item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK;
                    }

                    if (bSendData)
                    {
                        PacketOut outpack = new PacketOut();
                        outpack.WriteInt16(28);
                        outpack.WriteInt16(1009);
                        outpack.WriteUInt32(item.id);
                        outpack.WriteUInt32(ptich_obj_id);
                        outpack.WriteInt32((byte)NetMsg.MsgOperateItem.PTICH_GETBACK_SELLITEM);
                        outpack.WriteInt32(0);
                        outpack.WriteInt32(0);
                        outpack.WriteInt32(0);
                        play.SendData(outpack.Flush(), true);
                    }
                }
            }
            mListPtichInfo[play.GetCurrentPtichID()].play = null;
            //移除地图对象
            play.GetGameMap().RemoveObj(mListPtichInfo[play.GetCurrentPtichID()].PtichObj);
            mListPtichInfo[play.GetCurrentPtichID()].PtichObj = null;
            mListPtichInfo[play.GetCurrentPtichID()].mSellItemList.Clear();
            if (bSendData)
            {
                PacketOut outpack = new PacketOut();
                outpack.WriteInt16(16);
                outpack.WriteInt16(2031);
                outpack.WriteUInt32(ptich_obj_id);
                outpack.WriteUInt32(play.GetTypeId());
                outpack.WriteInt32(2);
                play.SendData(outpack.Flush(), true);
            }
            //移除摆摊状态
            play.GetTimerSystem().DeleteStatus(GameStruct.RoleStatus.STATUS_PTICH);
        }
Exemple #12
0
        //摊位取回道具
        public void GetBackItem(PlayerObject play, uint item_id)
        {
            if (play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_PTICH) == null)
            {
                return;
            }
            uint ptich_obj_id = GetPtichObjectTypeID(play.GetCurrentPtichID());

            GameStruct.RoleItemInfo item = null;
            if (ptich_obj_id == 0)
            {
                return;
            }
            if (item_id >= IDManager.eudemon_start_id)
            {
                RoleData_Eudemon eudemon = play.GetEudemonSystem().FindEudemon(item_id);
                if (eudemon == null)
                {
                    return;
                }
                item = play.GetItemSystem().FindItem(eudemon.itemid);
                if (item == null)
                {
                    return;
                }
            }
            else
            {
                item = play.GetItemSystem().FindItem(item_id);
                if (item == null)
                {
                    return;
                }
            }

            int nPtichId = play.GetCurrentPtichID();

            for (int i = 0; i < mListPtichInfo[nPtichId].mSellItemList.Count; i++)
            {
                if (mListPtichInfo[nPtichId].mSellItemList[i].item_id == item_id)
                {
                    mListPtichInfo[nPtichId].mSellItemList.RemoveAt(i);
                    break;
                }
            }
            //放回到包裹或幻兽背包
            if (item_id >= IDManager.eudemon_start_id)
            {
                item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_EUDEMON_PACK;
            }
            else
            {
                item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK;
            }

            PacketOut outpack = new PacketOut();

            outpack.WriteInt16(28);
            outpack.WriteInt16(1009);
            outpack.WriteUInt32(item_id);
            outpack.WriteUInt32(ptich_obj_id);
            outpack.WriteInt32((byte)NetMsg.MsgOperateItem.PTICH_GETBACK_SELLITEM);
            outpack.WriteInt32(0);
            outpack.WriteInt32(0);
            outpack.WriteInt32(0);
            play.SendData(outpack.Flush(), true);
        }
Exemple #13
0
        //摊位出售道具
        public void SellItem(PlayerObject play, uint item_id, byte type, int price)
        {
            if (play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_PTICH) == null)
            {
                return;
            }
            uint ptich_obj_id = GetPtichObjectTypeID(play.GetCurrentPtichID());

            GameStruct.RoleItemInfo item = null;
            if (ptich_obj_id == 0)
            {
                return;
            }
            if (item_id >= IDManager.eudemon_start_id)
            {
                RoleData_Eudemon eudemon = play.GetEudemonSystem().FindEudemon(item_id);
                if (eudemon == null)
                {
                    return;
                }
                item = play.GetItemSystem().FindItem(eudemon.itemid);
                if (item == null)
                {
                    return;
                }
            }
            else
            {
                item = play.GetItemSystem().FindItem(item_id);
                if (item == null)
                {
                    return;
                }
            }

            if (ptich_obj_id == 0)
            {
                return;
            }
            //判断是否已经在出售摊位列表中- 反作弊
            int nPtichId = play.GetCurrentPtichID();

            for (int i = 0; i < mListPtichInfo[nPtichId].mSellItemList.Count; i++)
            {
                if (mListPtichInfo[nPtichId].mSellItemList[i].item_id == item_id)
                {
                    return;
                }
            }
            //摆摊出售道具已满
            if (mListPtichInfo[nPtichId].mSellItemList.Count >= GameBase.Config.Define.PTICH_SELL_MAX_COUNT)
            {
                return;
            }
            PacketOut outpack = new PacketOut();

            outpack.WriteInt16(28);
            outpack.WriteInt16(1009);
            outpack.WriteUInt32(item_id);
            outpack.WriteInt32(price);
            outpack.WriteInt32(type);
            outpack.WriteInt32(0);
            outpack.WriteInt32(0);
            outpack.WriteInt32(0);
            play.SendData(outpack.Flush(), true);
            //移到摊位状态
            item.postion = NetMsg.MsgItemInfo.ITEMPOSTION_PTICH_PACK;


            PtichSellItemInfo info = new PtichSellItemInfo();

            info.item_id   = item_id;
            info.price     = price;
            info.sell_type = type;
            mListPtichInfo[nPtichId].mSellItemList.Add(info);
            // {28,0,241,3,8,127,205,7,111,0,0,0,52,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
        }
        /*穿戴的装备是否符合穿戴条件
        level 等级
        profession 职业
        equip_pos 穿戴位置
        item_info 道具信息*/
        //2016.1.20
        //20多级以下的装备没有做判断- 暂时不写 2016.1.20
        public bool IsAccordWithEquip(byte level,byte profession, byte equip_pos, RoleItemInfo item_info)
        {
            uint nStartItemId = 0; //起始道具ID
            int nAddIndex = 0;  //索引总数- 就是该部位的装备所有数量
            switch (equip_pos)
            {
                case NetMsg.MsgItemInfo.ITEMPOSITION_HELMET: //头盔
                    {
                        switch (profession)
                        {
                            case JOB.WARRIOR: { nStartItemId = 111000; break; }
                            case JOB.MAGE: { nStartItemId = 115000; break; }
                            case JOB.POWER: { nStartItemId = 113000; break; }
                            case JOB.BLOODCLAN: { nStartItemId = 117000; break; }
                            case JOB.UNDEAD_MAGE: { nStartItemId = 119000; break; }
                            case JOB.DRAGONRIDE: { nStartItemId = 112000; break; }

                        }
                        nAddIndex = 14;
                        break;
                    }
                case NetMsg.MsgItemInfo.ITEMPOSITION_NECKLACE: //项链
                    {
                        switch (profession)
                        {
                            case JOB.WARRIOR: { nStartItemId = 121000; break; }
                            case JOB.MAGE: { nStartItemId = 125000; break; }
                            case JOB.POWER: { nStartItemId = 123000; break; }
                            case JOB.BLOODCLAN: { nStartItemId = 127000; break; }
                            case JOB.UNDEAD_MAGE: { nStartItemId = 129000; break; }
                            case JOB.DRAGONRIDE: { nStartItemId = 122000; break; }

                        }
                        nAddIndex = 14;
                        break;
                    }
                case NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR: //盔甲
                    {
                        switch (profession)
                        {
                            case JOB.WARRIOR: { nStartItemId = 131000; break; }
                            case JOB.MAGE: { nStartItemId = 135000; break; }
                            case JOB.POWER: { nStartItemId = 133000; break; }
                            case JOB.BLOODCLAN: { nStartItemId = 137000; break; }
                            case JOB.UNDEAD_MAGE: { nStartItemId = 139000; break; }
                            case JOB.DRAGONRIDE: { nStartItemId = 132000; break; }

                        }
                        nAddIndex = 14;
                        break;
                    }
                case NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONR: //武器
                    {
                        switch (profession)
                        {
                            case JOB.WARRIOR: {
                                if (item_info.itemid >= 420000) nStartItemId = 420000; //剑
                                else nStartItemId = 410000; //刀
                                break;}
                            case JOB.MAGE: { nStartItemId = 440000; break; }
                            case JOB.POWER: { nStartItemId = 490000; break; }
                            case JOB.BLOODCLAN: { nStartItemId = 450000; break; }
                            case JOB.UNDEAD_MAGE: { nStartItemId = 430000; break; }
                            case JOB.DRAGONRIDE: { nStartItemId = 480000; break; }

                        }
                        nAddIndex = 27;
                        break;
                    }

              case NetMsg.MsgItemInfo.ITEMPOSITION_TREASURE: //手镯
                    {
                        switch (profession)
                        {
                            case JOB.WARRIOR: { nStartItemId = 141000; break; }
                            case JOB.MAGE: { nStartItemId = 145000; break; }
                            case JOB.POWER: { nStartItemId = 143000; break; }
                            case JOB.BLOODCLAN: { nStartItemId = 147000; break; }
                            case JOB.UNDEAD_MAGE: { nStartItemId = 149010; break; }
                            case JOB.DRAGONRIDE: { nStartItemId = 142000; break; }

                        }
                        nAddIndex = 14;
                        break;
                    }
             case NetMsg.MsgItemInfo.ITEMPOSITION_SHOES: //鞋子
                    {
                        switch (profession)
                        {
                            case JOB.WARRIOR: { nStartItemId = 161000; break; }
                            case JOB.MAGE: { nStartItemId = 165000; break; }
                            case JOB.POWER: { nStartItemId = 163000; break; }
                            case JOB.BLOODCLAN: { nStartItemId = 167000; break; }
                            case JOB.UNDEAD_MAGE: { nStartItemId = 169000; break; }
                            case JOB.DRAGONRIDE: { nStartItemId = 162000; break; }

                        }
                        nAddIndex = 10;
                        break;
                    }

            }
            GameStruct.ItemTypeInfo type_info = null;
            for (int i = 0; i < nAddIndex; i++)
            {
                type_info = ConfigManager.Instance().GetItemTypeInfo(nStartItemId);

                if (type_info != null && type_info.req_level >= level)
                {
                    if (type_info.req_level == level)
                    {
                        break;
                    }
                    nStartItemId -= 10;
                    type_info =  ConfigManager.Instance().GetItemTypeInfo(nStartItemId);
                    break;
                }
                nStartItemId += 10;
            }

            if (type_info == null) return false;
            //符合穿戴需求
            GameStruct.ItemTypeInfo  _item_info = ConfigManager.Instance().GetItemTypeInfo(item_info.itemid);
            if(_item_info == null)return false;
            //道具名称一样-
            if (String.Compare(type_info.name, _item_info.name) == 0)
            {
                return true;
            }

            return false;
        }