I rewrote the procedure to fix some issues with the old procedure copying stats to items that were in the same pile.
QQ 2159926347
CREATE PROCEDURE RMS_DOITEMGROWTH
@GameID varchar (14),
@WindowKind int,
@WindowIndex int,
@ItemKind int,
@ItemIndex int,
@AttackGrade int,
@StrengthGrade int,
@SpiritGrade int,
@DexterityGrade int,
@PowerGrade int,
@NextItemKind int,
@NextItemIndex int,
@NextAttackGrade int,
@NextStrengthGrade int,
@NextSpiritGrade int,
@NextDexterityGrade int,
@NextPowerGrade int
AS
Set nocount on
Begin transaction
DECLARE @NextLevel real
DECLARE @ItemID int
DECLARE @RanditemNumber int
Declare @cnt int
DECLARE @Map int
DECLARE @X int
DECLARE @Y int
Declare @error int
SET @ ItemID = 0
Set @ cnt = 0
SET @ NextLevel = @ NextAttackGrade + @ NextStrengthGrade + @ NextSpiritGrade + @ NextDexterityGrade + @ NextPowerGrade
SELECT TOP 1 @ ItemID = ID, @ cnt = isnull (cnt, 0) FROM tblSpecialItem1 WHERE GameID = @ GameID AND WindowKind = @ WindowKind AND WindowIndex = @ WindowIndex AND
ItemKind = @ ItemKind AND ItemIndex = @ ItemIndex AND AttackGrade = @ AttackGrade AND StrengthGrade = @ StrengthGrade AND SpiritGrade = @ SpiritGrade AND DexterityGrade = @ DexterityGrade AND PowerGrade = @ PowerGrade AND Position = 1
IF @ItemID> 0
Begin
Select @Map = Map from tblGameID1 where GameID = @GameID
Select @X = X from tblGameID1 where GameID = @GameID
Select @Y = Y from tblGameID1 where GameID = @GameID
Set @ randitemnumber = cast (floor (rand () * 16) as int)
Set @ RanditemNumber = @ RanditemNumber% 100
If (@ randitemnumber = @ nextattackgrade)
Begin
If @cnt> 1
INSERT tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, AttackGrade, StrengthGrade, SpiritGrade, DexterityGrade, PowerGrade, Position, GameID, WindowKind, WindowIndex, Map, X, Y, TileKind, MiscTime, CNT)
VALUES (@ItemKind, @ItemIndex, 4, @AttackGrade, @StrengthGrade, @SpiritGrade, @DexterityGrade, @PowerGrade, 1, @GameID, @WindowKind, @WindowIndex, @Map, @X, @Y, 1, GetDate () , @cnt -1)
SET @Error = @@ Error
IF @Error = 0
BEGIN
Update tblspecialitem1 SET ItemKind = @ NextItemKind, ItemIndex = @ ItemIndex, AttackGrade = @ AttackGrade + 1, cnt = +1 WHERE ID = @ ItemID
End
If @ attackgrade = 3
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
Else
If @ attackgrade = 7
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
Else
If @ attackgrade = 11
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
Else
If @ attackgrade = 14
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
End
ElSE
BEGIN
If @cnt> 1
INSERT tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, AttackGrade, StrengthGrade, SpiritGrade, DexterityGrade, PowerGrade, Position, GameID, WindowKind, WindowIndex, Map, X, Y, TileKind, MiscTime, CNT)
VALUES (@ItemKind, @ItemIndex, 4, @AttackGrade, @StrengthGrade, @SpiritGrade, @DexterityGrade, @PowerGrade, @GameID, @WindowKind, @WindowIndex, @Map, @X, @Y, 1, GetDate () , @cnt -1)
SET @Error = @@ Error
IF @Error = 0
BEGIN
UPDATE tblSpecialItem1 SET ItemKind = @ nextItemKind, StrengthGrade = @ NextStrengthGrade, SpiritGrade = @ NextSpiritGrade, DexterityGrade = @ NextDexterityGrade, PowerGrade = @ NextPowerGrade, cnt = +1 WHERE ID = @ ItemID
END
END
End
Commit transaction
GO
QQ 2159926347
CREATE PROCEDURE RMS_DOITEMGROWTH
@GameID varchar (14),
@WindowKind int,
@WindowIndex int,
@ItemKind int,
@ItemIndex int,
@AttackGrade int,
@StrengthGrade int,
@SpiritGrade int,
@DexterityGrade int,
@PowerGrade int,
@NextItemKind int,
@NextItemIndex int,
@NextAttackGrade int,
@NextStrengthGrade int,
@NextSpiritGrade int,
@NextDexterityGrade int,
@NextPowerGrade int
AS
Set nocount on
Begin transaction
DECLARE @NextLevel real
DECLARE @ItemID int
DECLARE @RanditemNumber int
Declare @cnt int
DECLARE @Map int
DECLARE @X int
DECLARE @Y int
Declare @error int
SET @ ItemID = 0
Set @ cnt = 0
SET @ NextLevel = @ NextAttackGrade + @ NextStrengthGrade + @ NextSpiritGrade + @ NextDexterityGrade + @ NextPowerGrade
SELECT TOP 1 @ ItemID = ID, @ cnt = isnull (cnt, 0) FROM tblSpecialItem1 WHERE GameID = @ GameID AND WindowKind = @ WindowKind AND WindowIndex = @ WindowIndex AND
ItemKind = @ ItemKind AND ItemIndex = @ ItemIndex AND AttackGrade = @ AttackGrade AND StrengthGrade = @ StrengthGrade AND SpiritGrade = @ SpiritGrade AND DexterityGrade = @ DexterityGrade AND PowerGrade = @ PowerGrade AND Position = 1
IF @ItemID> 0
Begin
Select @Map = Map from tblGameID1 where GameID = @GameID
Select @X = X from tblGameID1 where GameID = @GameID
Select @Y = Y from tblGameID1 where GameID = @GameID
Set @ randitemnumber = cast (floor (rand () * 16) as int)
Set @ RanditemNumber = @ RanditemNumber% 100
If (@ randitemnumber = @ nextattackgrade)
Begin
If @cnt> 1
INSERT tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, AttackGrade, StrengthGrade, SpiritGrade, DexterityGrade, PowerGrade, Position, GameID, WindowKind, WindowIndex, Map, X, Y, TileKind, MiscTime, CNT)
VALUES (@ItemKind, @ItemIndex, 4, @AttackGrade, @StrengthGrade, @SpiritGrade, @DexterityGrade, @PowerGrade, 1, @GameID, @WindowKind, @WindowIndex, @Map, @X, @Y, 1, GetDate () , @cnt -1)
SET @Error = @@ Error
IF @Error = 0
BEGIN
Update tblspecialitem1 SET ItemKind = @ NextItemKind, ItemIndex = @ ItemIndex, AttackGrade = @ AttackGrade + 1, cnt = +1 WHERE ID = @ ItemID
End
If @ attackgrade = 3
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
Else
If @ attackgrade = 7
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
Else
If @ attackgrade = 11
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
Else
If @ attackgrade = 14
Begin
Update tblspecialitem1 set Itemindex = @ itemindex + 20, cnt = +1 where id = @ itemid
End
End
ElSE
BEGIN
If @cnt> 1
INSERT tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, AttackGrade, StrengthGrade, SpiritGrade, DexterityGrade, PowerGrade, Position, GameID, WindowKind, WindowIndex, Map, X, Y, TileKind, MiscTime, CNT)
VALUES (@ItemKind, @ItemIndex, 4, @AttackGrade, @StrengthGrade, @SpiritGrade, @DexterityGrade, @PowerGrade, @GameID, @WindowKind, @WindowIndex, @Map, @X, @Y, 1, GetDate () , @cnt -1)
SET @Error = @@ Error
IF @Error = 0
BEGIN
UPDATE tblSpecialItem1 SET ItemKind = @ nextItemKind, StrengthGrade = @ NextStrengthGrade, SpiritGrade = @ NextSpiritGrade, DexterityGrade = @ NextDexterityGrade, PowerGrade = @ NextPowerGrade, cnt = +1 WHERE ID = @ ItemID
END
END
End
Commit transaction
GO