CREATE PROCEDURE dbo.RMS_PICKUPITEM
@ItemKind int,
@ItemIndex int,
@ItemDurability int,
@ItemAttackGrade int,
@ItemStrengthGrade int,
@ItemSpiritGrade int,
@ItemDexterityGrade int,
@ItemPowerGrade int,
@ItemCount int,
@FromPosition int,
@Map int,
@X int,
@Y int,
@TileKind int,
@ToPosition int,
@GameID varchar(14),
@WindowKind int,
@WindowIndex int
AS
set nocount on
declare @TempItemCount int,
@ItemID int,@NewItemDurability int
select @TempItemCount = -1
begin transaction
select top 1 @ItemID = ID from tblSpecialItem1 where ItemKind = @ItemKind and ItemIndex = @ItemIndex and ItemDurability = @ItemDurability and AttackGrade = @ItemAttackGrade and StrengthGrade = @ItemStrengthGrade and SpiritGrade = @ItemSpiritGrade and DexterityGrade = @ItemDexterityGrade and PowerGrade = @ItemPowerGrade and Position = @FromPosition and Map = @Map and X = @X and Y = @Y and TileKind = @TileKind
if ((@ItemID between 50 and 100) and @ItemDurability = 4) set @NewItemDurability = -1
else set @NewItemDurability = @ItemDurability
if @FromPosition = 0 and @ToPosition = 1 and ((@WindowKind = 1 and @WindowIndex >= 0 and @WindowIndex < 100) or (@WindowKind = 3 and @WindowIndex >= 0 and @WindowIndex < 8))
begin
select @TempItemCount = count(*) from tblSpecialItem1 where Position = @ToPosition and GameID = @GameID and (ItemKind != @ItemKind or ItemIndex != @ItemIndex or ItemDurability != @ItemDurability or AttackGrade != @ItemAttackGrade or StrengthGrade != @ItemStrengthGrade or SpiritGrade != @ItemSpiritGrade or DexterityGrade != @ItemDexterityGrade or PowerGrade != @ItemPowerGrade) and WindowKind = @WindowKind and WindowIndex = @WindowIndex
if @TempItemCount = 0
begin
declare @SQLStatement varchar(1024)
set @SQLStatement = *update tblSpecialItem1 set Position = * + convert(varchar, @ToPosition) + *, GameID = *** + @GameID + ***, WindowKind = * + convert(varchar, @WindowKind) + *,ItemDurability = * + convert(varchar,@NewItemDurability) + *, WindowIndex = * + convert(varchar, @WindowIndex) + * where ID in (select top * + convert(varchar, @ItemCount) + * ID from tblSpecialItem1 where ItemKind = * + convert(varchar, @ItemKind) + * and ItemIndex = * + convert(varchar, @ItemIndex) + * and ItemDurability = * + convert(varchar, @ItemDurability) + * and AttackGrade = * + convert(varchar,@ItemAttackGrade ) + * and StrengthGrade = * + convert(varchar, @ItemStrengthGrade) + * and SpiritGrade = * + convert(varchar, @ItemSpiritGrade) + * and DexterityGrade = * + convert(varchar, @ItemDexterityGrade) + * and PowerGrade = * + convert(varchar, @ItemPowerGrade) + * and Position = * + convert(varchar, @FromPosition) + * and Map = * + convert(varchar, @Map) + * and X = * + convert(varchar, @X) + * and Y = * + convert(varchar, @Y) + * and TileKind = * + convert(varchar, @TileKind) + *)*
exec (@SQLStatement)
end
end
else if @FromPosition = 0 and @ToPosition = 1 and @WindowKind = 0 and @ItemKind=6 and (@ItemIndex=198 or @ItemIndex=199 or @ItemIndex=201 or @ItemIndex=202 or @ItemIndex=203)
begin
declare @Time datetime
insert tb
lsp
ecialitem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime,AttackGrade,StrengthGrade,SpiritGrade,DexterityGrade,PowerGrade) values (6, @ItemIndex, 4, 2, 1, 100, 100, 1, @GameID, 3, 7, @Time, 0, 0, 0, 0, 0)
declare @SQLStatement2 varchar(1024)
set @SQLStatement2 = *update tblSpecialItem1 set Position = * + convert(varchar, @ToPosition) + *, GameID = *** + @GameID + ***, WindowKind = * + convert(varchar, @WindowKind) + *,ItemDurability = * + convert(varchar,@NewItemDurability) + *, WindowIndex = * + convert(varchar, @WindowIndex) + * where ID in (select top * + convert(varchar, @ItemCount) + * ID from tblSpecialItem1 where ItemKind = * + convert(varchar, @ItemKind) + * and ItemIndex = * + convert(varchar, @ItemIndex) + * and ItemDurability = * + convert(varchar, @ItemDurability) + * and AttackGrade = * + convert(varchar,@ItemAttackGrade ) + * and StrengthGrade = * + convert(varchar, @ItemStrengthGrade) + * and SpiritGrade = * + convert(varchar, @ItemSpiritGrade) + * and DexterityGrade = * + convert(varchar, @ItemDexterityGrade) + * and PowerGrade = * + convert(varchar, @ItemPowerGrade) + * and Position = * + convert(varchar, @FromPosition) + * and Map = * + convert(varchar, @Map) + * and X = * + convert(varchar, @X) + * and Y = * + convert(varchar, @Y) + * and TileKind = * + convert(varchar, @TileKind) + *)*
exec (@SQLStatement2)
end
commit transaction
GO