コード例 #1
0
        public unsafe void GiveMine(TPlayObject PlayObject, string[] @Params)
        {
            string     sMINEName  = @Params.Length > 0 ? @Params[0] : "";
            int        nMineCount = @Params.Length > 0 ? int.Parse(@Params[1]) : 0;
            int        nDura      = @Params.Length > 0 ? int.Parse(@Params[2]) : 0;
            TUserItem *UserItem   = null;
            TStdItem * StdItem;

            if ((sMINEName == "") || ((sMINEName != "") && (sMINEName[0] == '?')) || (nMineCount <= 0))
            {
                if (M2Share.g_Config.boGMShowFailMsg)
                {
                    PlayObject.SysMsg(string.Format(GameMsgDef.g_sGameCommandParamUnKnow, this.Attributes.Name, GameMsgDef.g_sGameCommandGIVEMINEHelpMsg), TMsgColor.c_Red, TMsgType.t_Hint);
                }
                return;
            }
            if (nDura <= 0)// 如纯度不填,则随机给纯度
            {
                nDura = HUtil32.Random(18) + 3;
            }
            for (int I = 0; I < nMineCount; I++)
            {
                UserItem = (TUserItem *)Marshal.AllocHGlobal(sizeof(TUserItem));
                if (UserEngine.CopyToUserItemFromName(sMINEName, UserItem))
                {
                    StdItem = UserEngine.GetStdItem(UserItem->wIndex);
                    if ((StdItem != null) && (StdItem->StdMode == 43))
                    {
                        if (PlayObject.IsAddWeightAvailable(StdItem->Weight * nMineCount))
                        {
                            UserItem->Dura = Convert.ToUInt16(Convert.ToInt16(nDura * 1000));
                            if (UserItem->Dura > UserItem->DuraMax)
                            {
                                UserItem->Dura = UserItem->DuraMax;
                            }
                            PlayObject.m_ItemList.Add((IntPtr)UserItem);
                            PlayObject.SendAddItem(UserItem);
                            if (StdItem->NeedIdentify == 1)
                            {
                                M2Share.AddGameDataLog("5" + "\09" + PlayObject.m_sMapName + "\09" + PlayObject.m_nCurrX + "\09" + PlayObject.m_nCurrY + "\09" +
                                                       PlayObject.m_sCharName + "\09" + HUtil32.SBytePtrToString(StdItem->Name, StdItem->NameLen) + "\09" + UserItem->MakeIndex + "\09" + UserItem->Dura + "/" + UserItem->DuraMax + "\09" + PlayObject.m_sCharName);
                            }
                        }
                    }
                }
                else
                {
                    Marshal.FreeHGlobal((IntPtr)UserItem);
                    break;
                }
            }
        }
コード例 #2
0
        public unsafe void CmdMakeItem(string[] @Params, TPlayObject PlayObject)
        {
            if (@Params == null)
            {
                return;
            }
            TUserItem *UserItem;
            TStdItem * StdItem;
            string     sItemName = @Params.Length > 0 ? @Params[0] : "";                 //物品名称
            int        nCount    = @Params.Length > 1 ? Convert.ToInt32(@Params[1]) : 1; //数量
            string     sParam    = @Params.Length > 2 ? @Params[2] : "";                 //可选参数(持久力)

            if ((sItemName == ""))
            {
                if (M2Share.g_Config.boGMShowFailMsg)
                {
                    PlayObject.SysMsg(string.Format(GameMsgDef.g_sGameCommandParamUnKnow, this.Attributes.Name, GameMsgDef.g_sGamecommandMakeHelpMsg), TMsgColor.c_Red, TMsgType.t_Hint);
                }
                return;
            }
            if ((nCount <= 0))
            {
                nCount = 1;
            }
            if ((nCount > 10))
            {
                nCount = 10;
            }
            if ((PlayObject.m_btPermission < this.Attributes.nPermissionMax))
            {
                if (!M2Share.CanMakeItem(sItemName))
                {
                    PlayObject.SysMsg(GameMsgDef.g_sGamecommandMakeItemNameOrPerMissionNot, TMsgColor.c_Red, TMsgType.t_Hint);
                    return;
                }
                if (M2Share.g_CastleManager.InCastleWarArea(PlayObject) != null) // 攻城区域,禁止使用此功能
                {
                    PlayObject.SysMsg(GameMsgDef.g_sGamecommandMakeInCastleWarRange, TMsgColor.c_Red, TMsgType.t_Hint);
                    return;
                }
                if (!PlayObject.InSafeZone())
                {
                    PlayObject.SysMsg(GameMsgDef.g_sGamecommandMakeInSafeZoneRange, TMsgColor.c_Red, TMsgType.t_Hint);
                    return;
                }
                nCount = 1;
            }
            for (int I = 0; I < nCount; I++)
            {
                if (PlayObject.m_ItemList.Count >= Grobal2.MAXBAGITEM)
                {
                    return;
                }
                UserItem = (TUserItem *)Marshal.AllocHGlobal(sizeof(TUserItem));
                if (UserEngine.CopyToUserItemFromName(sItemName, UserItem))
                {
                    StdItem = UserEngine.GetStdItem(UserItem->wIndex);
                    if ((StdItem->Price >= 15000) && !M2Share.g_Config.boTestServer && (PlayObject.m_btPermission < 5))
                    {
                        Marshal.FreeHGlobal((IntPtr)UserItem);
                        UserItem = null;
                    }
                    else
                    {
                        if (HUtil32.Random(M2Share.g_Config.nMakeRandomAddValue) == 0)
                        {
                            UserEngine.RandomUpgradeItem(UserItem);
                        }
                    }
                    if (PlayObject.m_btPermission >= this.Attributes.nPermissionMax)
                    {
                        UserItem->MakeIndex = M2Share.GetItemNumberEx();// 制造的物品另行取得物品ID
                    }
                    PlayObject.m_ItemList.Add((IntPtr)UserItem);
                    PlayObject.SendAddItem(UserItem);
                    if ((PlayObject.m_btPermission >= 6))
                    {
                        M2Share.MainOutMessage("[制造物品] " + PlayObject.m_sCharName + " " + sItemName + "(" + (UserItem->MakeIndex).ToString() + ")");
                    }
                    if (StdItem->NeedIdentify == 1)
                    {
                        M2Share.AddGameDataLog("5" + "\09" + PlayObject.m_sMapName + "\09" + (PlayObject.m_nCurrX).ToString() + "\09" + (PlayObject.m_nCurrY).ToString()
                                               + "\09" + PlayObject.m_sCharName + "\09" + HUtil32.SBytePtrToString(StdItem->Name, StdItem->NameLen) + "\09" + (UserItem->MakeIndex).ToString() + "\09" + "(" +
                                               (HUtil32.LoWord(StdItem->DC)).ToString() + "/" + (HUtil32.HiWord(StdItem->DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem->MC)).ToString()
                                               + "/" + (HUtil32.HiWord(StdItem->MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem->SC)).ToString() + "/" + (HUtil32.HiWord(StdItem->SC)).ToString()
                                               + ")" + "(" + (HUtil32.LoWord(StdItem->AC)).ToString() + "/" + (HUtil32.HiWord(StdItem->AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem->MAC))
                                               .ToString() + "/" + (HUtil32.HiWord(StdItem->MAC)).ToString() + ")" + (UserItem->btValue[0]).ToString()
                                               + "/" + (UserItem->btValue[1]).ToString() + "/" + (UserItem->btValue[2]).ToString() + "/" + (UserItem->btValue[3]).ToString()
                                               + "/" + (UserItem->btValue[4]).ToString() + "/" + (UserItem->btValue[5]).ToString() + "/" + (UserItem->btValue[6]).ToString()
                                               + "/" + (UserItem->btValue[7]).ToString() + "/" + (UserItem->btValue[8]).ToString() + "/" + (UserItem->btValue[14]).ToString()
                                               + "\09" + PlayObject.m_sCharName);
                    }
                }
                else
                {
                    Marshal.FreeHGlobal((IntPtr)UserItem);
                    UserItem = null;
                    PlayObject.SysMsg(string.Format(GameMsgDef.g_sGamecommandMakeItemNameNotFound, sItemName), TMsgColor.c_Red, TMsgType.t_Hint);
                    break;
                }
            }
        }