|
USE [SRO_VT_SHARD] GO /****** Object: StoredProcedure [dbo].[_ADD_FLAG] Script Date: 01/24/2015 16:57:28 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= CREATE PROCEDURE [dbo].[_ADD_FLAG] @CharID Int As
-- This Procedure created by [iLegend] for several uses. -- Main of them is adding item for both gender by 1 scroll, etc. -- You can change values and parameters as u want. -- For change to add the item to inventory : -- Work with this Parameter. Slot = @Empty_Slot and change every _InventoryForAvatar to _Inventory -- ================================================================================================
Declare @RefObjID Int = (Select RefObjID From [SRO_VT_SHARD].[dbo].[_Char] Where CharID = @CharID) Declare @ID64 Int = (Select MAX (ID64) FROM [SRO_VT_SHARD].[dbo].[_Items]) +1 Declare @ItemID Int = (Select ItemID From [SRO_VT_SHARD].[dbo].[_InventoryForAvatar] Where CharID = @CharID and Slot = 3) Declare @RefItemID Int Declare @FreeItemID Bigint Declare @Inv_Capacity int Declare @Empty_Slot Int Declare @SN Bigint = (Select LatestItemSerial From [SRO_VT_SHARD].[dbo].[_LatestItemSerial]) Select @FreeItemID = MAX (ItemID) From [SRO_VT_SHARD].[dbo].[_ItemPool] With (Nolock) Where InUse = 0 Set @Inv_Capacity = (Select InventorySize From [SRO_VT_SHARD].[dbo].[_Char] Where CharID = @CharID) Select Top 1 @Empty_Slot = Slot From [SRO_VT_SHARD].[dbo].[_Inventory] With (Nolock) Where CharID = @CharID and Slot >= 13 and Slot < @Inv_Capacity and ItemID = 0 Order By Slot -- IF Char Gender = [M] -- ===================== IF (@RefObjID between 1907 and 1919) or (@RefObjID between 14875 and 14887) Begin -- Step 1 : *If item exist in the selected slot. -- Actions : -- 1- Update the exist item by a new parameters that we want. -- ================================================================= IF (@ItemID > 0) Begin Update [SRO_VT_SHARD].[dbo].[_Items] Set OptLevel = 0 , CreaterName = 'iLegend' , MagParamNum = 2 , MagParam1 = 30064771305 , MagParam2 = 30064771304 Where ID64 = @ItemID End -- Step 2 : *If item not exist in the selected slot and free item is exist from dbo._ItemPool. -- Actions : -- 1- Update the free item by a new parameters that we want. -- 2- Update dbo.ItemPool for change the free item to InUse Item. -- 3- Update the free slot item to the updated item that we do. -- ================================================================= IF (@ItemID = 0) and (@FreeItemID > 0) Begin Set @RefItemID = 9374 -- Male Item ID Update [SRO_VT_SHARD].[dbo].[_Items] Set RefItemID=@RefItemID,OptLevel=0,Variance=0,Data=0,CreaterName='iLegend',MagParamNum=2,MagParam1=30064771305,MagParam2=30064771304,MagParam3=NULL,MagParam4=NULL,MagParam5=NULL,MagParam6=NULL,MagParam7=NULL,MagParam8=NULL,MagParam9=NULL,MagParam10=NULL,MagParam11=NULL,MagParam12=NULL Where ID64 = @FreeItemID Update [SRO_VT_SHARD].[dbo].[_ItemPool] Set InUse = 1 Where ItemID = @FreeItemID Update [SRO_VT_SHARD].[dbo].[_InventoryForAvatar] Set ItemID = @FreeItemID Where CharID = @CharID and Slot = 3 End -- Step 3 : *If item not exist in the selected slot and item free is not exist from dbo._ItemPool. -- Actions : -- 1- Create new item in dbo._Items by a new parameters that we want. -- 2- Create a line in dbo.ItemPool for make the new item to InUse Item. -- 3- Update the free slot item to the created item that we create. -- ================================================================= IF (@ItemID = 0) and (@FreeItemID = 0) Begin Exec [SRO_VT_SHARD].[dbo].[_GetLatestItemSerial] @SN Set @RefItemID = 9374 -- Male Item ID SET IDENTITY_INSERT [SRO_VT_SHARD].[dbo].[_Items] ON Insert InTo [SRO_VT_SHARD].[dbo].[_Items] (ID64,RefItemID,OptLevel,Variance,Data,CreaterName,MagParamNum,MagParam1,MagParam2,MagParam3,MagParam4,MagParam5,MagParam6,MagParam7,MagParam8,MagParam9,MagParam10,MagParam11,MagParam12,Serial64) Values (@ID64,@RefItemID,0,0,0,'iLegend',2,30064771305,30064771304,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,@SN) SET IDENTITY_INSERT [SRO_VT_SHARD].[dbo].[_Items] OFF Insert InTo [SRO_VT_SHARD].[dbo].[_ItemPool] Values (@ID64,1) Update [SRO_VT_SHARD].[dbo].[_InventoryForAvatar] Set ItemID = @ID64 Where CharID = @CharID and Slot = 3 End End Else -- IF Char Gender = [F] -- ===================== IF (@RefObjID Between 1920 and 1932) Or (@RefObjID Between 14888 and 14900) Begin -- Step 1 : *If item exist in the selected slot. -- Actions : -- 1- Update the exist item by a new parameters that we want. -- ================================================================= IF (@ItemID > 0) Begin Update [SRO_VT_SHARD].[dbo].[_Items] Set OptLevel = 0 , CreaterName = 'iLegend' , MagParamNum = 2 , MagParam1 = 30064771305 , MagParam2 = 30064771304 Where ID64 = @ItemID End -- Step 2 : *If item not exist in the selected slot and free item is exist from dbo._ItemPool. -- Actions : -- 1- Update the free item by a new parameters that we want. -- 2- Update dbo.ItemPool for change the free item to InUse Item. -- 3- Update the free slot item to the updated item that we do. -- ================================================================= IF (@ItemID = 0) and (@FreeItemID > 0) Begin Set @RefItemID = 9375 Update [SRO_VT_SHARD].[dbo].[_Items] Set RefItemID=@RefItemID,OptLevel=0,Variance=0,Data=0,CreaterName='iLegend',MagParamNum=2,MagParam1=30064771305,MagParam2=30064771304,MagParam3=NULL,MagParam4=NULL,MagParam5=NULL,MagParam6=NULL,MagParam7=NULL,MagParam8=NULL,MagParam9=NULL,MagParam10=NULL,MagParam11=NULL,MagParam12=NULL Where ID64 = @FreeItemID -- Female Item ID Update [SRO_VT_SHARD].[dbo].[_ItemPool] Set InUse = 1 Where ItemID = @FreeItemID Update [SRO_VT_SHARD].[dbo].[_InventoryForAvatar] Set ItemID = @FreeItemID Where CharID = @CharID and Slot = 3 End -- Step 3 : *If item not exist in the selected slot and item free is not exist from dbo._ItemPool. -- Actions : -- 1- Create new item in dbo._Items by a new parameters that we want. -- 2- Create a line in dbo.ItemPool for make the new item to InUse Item. -- 3- Update the free slot item to the created item that we create. -- ================================================================= IF (@ItemID = 0) and (@FreeItemID = 0) Begin Exec [SRO_VT_SHARD].[dbo].[_GetLatestItemSerial] @SN Set @RefItemID = 9375 -- Female Item ID SET IDENTITY_INSERT [SRO_VT_SHARD].[dbo].[_Items] ON Insert InTo [SRO_VT_SHARD].[dbo].[_Items] (ID64,RefItemID,OptLevel,Variance,Data,CreaterName,MagParamNum,MagParam1,MagParam2,MagParam3,MagParam4,MagParam5,MagParam6,MagParam7,MagParam8,MagParam9,MagParam10,MagParam11,MagParam12,Serial64) Values (@ID64,@RefItemID,0,0,0,'iLegend',2,30064771305,30064771304,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,@SN) SET IDENTITY_INSERT [SRO_VT_SHARD].[dbo].[_Items] OFF Insert InTo [SRO_VT_SHARD].[dbo].[_ItemPool] Values (@ID64,1) Update [SRO_VT_SHARD].[dbo].[_InventoryForAvatar] Set ItemID = @ID64 Where CharID = @CharID and Slot = 3 End End
|