Hello community,
I recently saw users asking for a way to let their characters start equipped, since this is not possible by using the existing BaseItemsDefs table. Today I am releasing a way of doing it, which can also replace the BaseItemsDefs table but having more possibilities to realize your ideas.
If you are interested in this you might thought about a way of doing this before. The only problem I can imagine you could have had is the ItemUID. Since we want to insert one, or even multiple rows into the CharItems table we need to insert a new ItemUID as well, but there is no function to get an ItemUID. So how do we get a new ItemUID? There are several ways to get an uniqueidentifier, you will see my way few lines below. Since there is no function to call I decided to create my own, it surely is the most efficient way. Just execute the following querys to create my function and you can easily get a new UID whenever you want.
Secondly, I created a table to store all the data in. You can specify the item, its links, craftname and even more. I named it BaseGearsDefs, because of the reason mentioned at the beginning. In fact, you can do even more with it than it was meant to do (Starting with equipped gears). The query can be found below.
If you want to add a new row to it you have to fill in content in each column except the craftname one, if you do not want to add rerolls or let your players start with enchanted items leave this clear. The Level column should be interesting for servers with an instant leveling system only - If you enter 60 in the column for example, only characters whose starter level is 60 will have it equipped or in their inventory, depending on your setup. For those without instant leveling, logically write a 1 in it. About preparations, we are done now. Next we will take use of this and implement it in our usp_Create_Char_R procedure (located in PS_GameData).
Paste the upper code right after the following line at the nearly end of your proc:
Best regards,
Philipp.
I recently saw users asking for a way to let their characters start equipped, since this is not possible by using the existing BaseItemsDefs table. Today I am releasing a way of doing it, which can also replace the BaseItemsDefs table but having more possibilities to realize your ideas.
If you are interested in this you might thought about a way of doing this before. The only problem I can imagine you could have had is the ItemUID. Since we want to insert one, or even multiple rows into the CharItems table we need to insert a new ItemUID as well, but there is no function to get an ItemUID. So how do we get a new ItemUID? There are several ways to get an uniqueidentifier, you will see my way few lines below. Since there is no function to call I decided to create my own, it surely is the most efficient way. Just execute the following querys to create my function and you can easily get a new UID whenever you want.
Code:
USE PS_GameData GO CREATE VIEW NewID AS SELECT NewID() AS NewID
Code:
USE [PS_GameData] GO /****** Object: UserDefinedFunction [dbo].[ItemUID] Script Date: 31.07.2013 00:03:25 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Euphoria Dev Team -- ============================================= CREATE FUNCTION [dbo].[ItemUID] () RETURNS BIGINT AS BEGIN DECLARE @ItemUID BIGINT NEWUID: SET @ItemUID = ABS(CAST(HASHBYTES('SHA1',CAST((SELECT NewID FROM PS_GameData.dbo.NewID) AS NVARCHAR(MAX))) AS BIGINT)) IF EXISTS(SELECT * FROM PS_GameData.dbo.CharItems WHERE ItemUID = @ItemUID) OR EXISTS(SELECT * FROM PS_GameData.dbo.GuildStoredItems WHERE ItemUID = @ItemUID) OR EXISTS(SELECT * FROM PS_GameData.dbo.MarketItems WHERE ItemUID = @ItemUID) OR EXISTS(SELECT * FROM PS_GameData.dbo.UserStoredItems WHERE ItemUID = @ItemUID) GOTO NEWUID RETURN @ItemUID END GO
Code:
USE [PS_GameDefs] GO /****** Object: Table [dbo].[BaseGearsDefs] Script Date: 31.07.2013 22:00:04 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[BaseGearsDefs]( [Family] [tinyint] NOT NULL, [Job] [tinyint] NOT NULL, [Level] [int] NOT NULL, [Bag] [smallint] NOT NULL, [Slot] [smallint] NOT NULL, [ItemID] [int] NOT NULL, [Type] [tinyint] NOT NULL, [TypeID] [tinyint] NOT NULL, [Gem1] [tinyint] NOT NULL, [Gem2] [tinyint] NOT NULL, [Gem3] [tinyint] NOT NULL, [Gem4] [tinyint] NOT NULL, [Gem5] [tinyint] NOT NULL, [Gem6] [tinyint] NOT NULL, [Craftname] [varchar](20) NULL, [Quality] [int] NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO
Code:
INSERT INTO CharItems SELECT @CharID AS CharID,ItemID,dbo.ItemUID() AS ItemUID,Type,TypeID,Bag,Slot,Quality,Gem1,Gem2,Gem3,Gem4,Gem5,Gem6,Craftname,1 AS COUNT,GETDATE() AS Maketime,'S' AS Maketype,0 AS Del FROM PS_GameDefs.dbo.BaseGearsDefs WHERE Family = @Family AND Job = @Job AND Level = @Level
Code:
SET @CharID = IDENT_CURRENT('Chars')
Philipp.