|
- CREATE PROCEDURE RMS_TRYMAKEMYSTERYPILL
- @GameID varchar(14),
- @WindowKind int,
- @WindowIndex int,
- @RandomNumber int
- AS
- set nocount on
- declare @ItemCountLimit int, @CurrentItemCount int
- set @ItemCountLimit = 0
- begin transaction
- select @ItemCountLimit = ItemCountLimit from tblSpecialItemLimit1 where ItemKind = 6 and ItemIndex = 66
- set @CurrentItemCount = @ItemCountLimit
- set @RandomNumber=RAND() * 100000000
- set @RandomNumber=@RandomNumber%100
- select @CurrentItemCount = count(*) from tblSpecialItem1 where ItemKind = 6 and ItemIndex = 66
- if (@WindowKind = 1 and @WindowIndex >= 0 and @WindowIndex < 100) or (@WindowKind = 3 and @WindowIndex >= 0 and @WindowIndex < 8)
- begin
- declare @MakeMysteryPillError int
- set @MakeMysteryPillError = 1
- update tblGameID1 set SBonus = SBonus - 1, STotalBonus = STotalBonus - 1 where GameID = @GameID and SBonus >= 1 and STotalBonus >= 1
- if @@ROWCOUNT = 1 and @@ERROR = 0
- begin
- if @ItemCountLimit > @CurrentItemCount
- begin
- if @RandomNumber % 100 >= 50
- begin
- insert tblSpecialItem1 (ItemKind, ItemIndex, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex) values (6, 66, 1, 1, 100, 100, 0, @GameID, @WindowKind, @WindowIndex)
- set @MakeMysteryPillError = @@ERROR
- end
- end
- end
- declare @STotalBonus int
- set @STotalBonus = 0
- select @STotalBonus = STotalBonus from tblGameID1 where GameID = @GameID
- if @MakeMysteryPillError = 0
- begin
- insert tblBonus2Log1 (GameID, STotalBonus, Kind) values (@GameID, @STotalBonus, 2)
- end
- else
- begin
- insert tblBonus2Log1 (GameID, STotalBonus, Kind) values (@GameID, @STotalBonus, 3)
- end
- end
- commit transaction
- GO
复制代码
50为100减去该数字就是成功机率,例如设为0就是100%成功,设为100就是0%了
|
|