Ain't hard to implement as an SQL side only.
Code:
declare $LinesCC int = (select count(*) from $MainTable where ScrollObjID = $ItemRefID)
if ($LinesCC > 0)
begin
declare $idx int = 1
declare $LuckTable table (ItemCode varchar(128), ItemCount int, ItemOptLevel int)
while ($idx <= $LinesCC)
begin
declare $Ratio int = 0
select $Ratio = Ratio from $MainTable where ScrollObjID = $ItemRefID and ID = $idx
if ($Ratio > 0)
begin
INSERT INTO $LuckTable
select MT.ItemCode, MT.ItemCount, MT.ItemOptLevel from $MainTable MT cross join
(select top 100 ROW_NUMBER() over(order by (select 1)) from sys.columns ) D(n) --Max ratio: 100
where ScrollObjID = $ItemRefID and ID = $idx and D.n <= MT.Ratio;
end
set $idx = $idx + 1
end
if ((select count(*) from $LuckTable) > 0)
begin
declare $RandomItemCode varchar(128), $RandomItemCount int, $RandomItemOptLevel int
select TOP 1 $RandomItemCode = LT.ItemCode, $RandomItemCount = LT.ItemCount, $RandomItemOptLevel = LT.ItemOptLevel from $LuckTable LT order by NEWID();
-- reward
end
end
While:
Code:
$MainTable table (ID int IDENTITY(1,1) NOT NULL, ScrollObjID int, ItemCode varchar(128), ItemCount int, ItemOptLevel int, Ratio int)
Hope Microsoft won't come to complain about my code, I am not an SQL coder, I am just giving this guy a hint to implement that thing.