Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- |
- | rolls.mac
- |
- | Courtesy of the guild Fusion on PEQTGC
- |
- | Captures loot /ran rolls and outputs an organized list
- |
- | /say do winners to sort and output
- | can also /say /ran [your info here] and your info will be returned with the winners
- | can also /say /timer [timeinseconds] and the macro will automatically do winners when the timer expires
- | the /ran and /timer information can be placed on the same chatline ex: /say /ran 1k for thing /timer 30
- |
- |
- #turbo 40
- #Event Ran1 "**A Magic Die is rolled by #1#."
- #Event Ran2 "**It could have been any number from #1# to #2#, but this time it turned up a #3#."
- #Event Winners "#*#do winners#*#"
- #Event InfoLine "#1#/ran#2#'"
- #Event SetCountdown "#1#/timer#2#'"
- Sub Main
- /declare EventCounter int outer 0
- /declare DoWinners bool outer FALSE
- /declare CurrentRoller string outer NULL
- /declare RangeList string outer
- /declare SetCount int outer 0
- /declare InfoLine string outer
- /declare Countdown timer outer
- /declare Countdown10x int outer
- /declare Vocal bool outer TRUE
- /declare Links bool outer FALSE
- /declare AutoInfo string outer
- /declare LootNames string outer
- /declare TempName string local
- /declare TempRoll int local
- /declare i int local
- /declare ii int local
- /declare NotSorted bool local TRUE
- /declare ForwardCount int local
- /declare ReverseCount int local
- /declare SortTime timer local
- /if (${Plugin[mq2linkdb].Name.Length}) /varset Links TRUE
- /for i 0 to ${Math.Calc[${Macro.Params}-1].Int}
- /if (${Param${i}.Equal[quiet]}) {
- /varset Vocal FALSE
- } else /if (${Param${i}.Equal[nolinks]}) {
- /varset Links FALSE
- }
- /next i
- /echo Rolls.mac - Ready to collect
- /if (${Vocal}) /docommand /say Rolls.mac Ready to collect
- /if (${Corpse.Open} && ${Corpse.Items}) {
- /echo Open corpse detected, automatically assigning loot rolls...
- /for i 1 to ${Corpse.Items}
- /if (${LootNames.Find[_${Corpse.Item[${i}]}_]}) {
- /varcalc ItemNo${Corpse.Item[${i}].ID}Qty ${ItemNo${Corpse.Item[${i}].ID}Qty}+1
- /varset Set${ItemNo${Corpse.Item[${i}].ID}SetNo}Name1 ${If[${Links},${LinkDB["${Corpse.Item[${i}]}"]},${Corpse.Item[${i}]}]} x${ItemNo${Corpse.Item[${i}].ID}Qty}
- /varset AutoInfo ${AutoInfo} ${ItemNo${Corpse.Item[${i}].ID}SetNo}k for ${If[${Links},${LinkDB["${Corpse.Item[${ItemNo${Corpse.Item[${i}].ID}SetNo}]}"]},${Corpse.Item[${ItemNo${Corpse.Item[${i}].ID}SetNo}]}]},
- } else {
- /varset LootNames ${LootNames}_${Corpse.Item[${i}]}_
- /varcalc SetCount ${SetCount}+1
- /declare Set${SetCount}MemberCount int outer 1
- /declare Set${SetCount}Range string outer 0-${SetCount}000
- /declare Set${SetCount}Names string outer |${Corpse.Item[${i}]}
- /declare Set${SetCount}Name1 string outer ${If[${Links},${LinkDB["${Corpse.Item[${i}]}"]},${Corpse.Item[${i}]}]}
- /declare ItemNo${Corpse.Item[${i}].ID}Qty int outer 1
- /declare ItemNo${Corpse.Item[${i}].ID}SetNo int outer ${SetCount}
- /declare Set${SetCount}Roll1 int outer ${Math.Calc[${SetCount}000+1].Int}
- /varset RangeList ${RangeList}_0-${SetCount}000_
- /varset AutoInfo ${AutoInfo} ${SetCount}k for ${If[${Links},${LinkDB["${Corpse.Item[${i}]}"]},${Corpse.Item[${i}]}]},
- }
- /next i
- /echo AutoInfo=${AutoInfo}
- /if (${Vocal}) /docommand /say Roll ${AutoInfo}
- }
- :MainLoop
- /doevents
- /if (${DoWinners}) /goto :StartWinners
- /goto :MainLoop
- :StartWinners
- /if (${InfoLine.Length}) {
- /echo ***InfoLine***: ${InfoLine}
- /if (${Vocal}) /docommand /say ***Info***: ${InfoLine}
- }
- /if (${SetCount}==0) {
- /if (${Vocal}) /docommand /say No rolls captured, ending
- /echo SetCount=${SetCount}
- /echo ending...
- /endmacro
- }
- /for i 1 to ${SetCount}
- /varset SortTime 3000
- /if (${Set${i}MemberCount}<2) /goto :PostSort
- /varset ForwardCount 0
- /varset ReverseCount 0
- :SortLoop
- /varset NotSorted TRUE
- /for ii ${Math.Calc[${ReverseCount}+1].Int} to ${Math.Calc[${Set${i}MemberCount}-1-${ForwardCount}].Int}
- /if (${Set${i}Roll${ii}}<${Set${i}Roll${Math.Calc[${ii}+1].Int}}) {
- /varset TempName ${Set${i}Name${ii}}
- /varset TempRoll ${Set${i}Roll${ii}}
- /varset Set${i}Name${ii} ${Set${i}Name${Math.Calc[${ii}+1].Int}}
- /varset Set${i}Roll${ii} ${Set${i}Roll${Math.Calc[${ii}+1].Int}}
- /varset Set${i}Name${Math.Calc[${ii}+1].Int} ${TempName}
- /varset Set${i}Roll${Math.Calc[${ii}+1].Int} ${TempRoll}
- /varset NotSorted FALSE
- }
- /next ii
- /varcalc ForwardCount ${ForwardCount}+1
- /if (${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}<2) /goto :PostSort
- /echo ${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}
- /for ii ${Math.Calc[${Set${i}MemberCount}-1-${ForwardCount}].Int} downto ${Math.Calc[${ReverseCount}+1].Int}
- /if (${Set${i}Roll${ii}}<${Set${i}Roll${Math.Calc[${ii}+1].Int}}) {
- /varset TempName ${Set${i}Name${ii}}
- /varset TempRoll ${Set${i}Roll${ii}}
- /varset Set${i}Name${ii} ${Set${i}Name${Math.Calc[${ii}+1].Int}}
- /varset Set${i}Roll${ii} ${Set${i}Roll${Math.Calc[${ii}+1].Int}}
- /varset Set${i}Name${Math.Calc[${ii}+1].Int} ${TempName}
- /varset Set${i}Roll${Math.Calc[${ii}+1].Int} ${TempRoll}
- /varset NotSorted FALSE
- }
- /next ii
- /varcalc ReverseCount ${ReverseCount}+1
- /if (${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}<2) /goto :PostSort
- /echo ${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}
- /if (${NotSorted}) /goto :PostSort
- /goto :SortLoop
- :PostSort
- /declare Set${i}Final string local
- /for ii 1 to ${Set${i}MemberCount}
- /varset Set${i}Final ${Set${i}Final} ${Set${i}Name${ii}}(${Set${i}Roll${ii}}),
- /next ii
- /echo ***${Set${i}Range}***:${Set${i}Final}
- /if (${Vocal}) /docommand /say ***${Set${i}Range}***:${Set${i}Final}
- /echo Range ${Set${i}Range} SortTime ${Math.Calc[(3000-${SortTime})/10].Deci} seconds
- /varset SortTime
- /next i
- /return
- Sub Event_Ran1
- /varcalc EventCounter ${EventCounter}+1
- /if (${CurrentRoller.Equal[NULL]}) {
- /varset CurrentRoller ${Param1}
- } else {
- /echo ERROR: CurrentRoller not NULL
- /echo ending
- /if (${Vocal}) /docommand /say Macro failure, ending
- /endmacro
- }
- /return
- Sub Event_Ran2
- /declare i int local
- /declare Actual int local ${Param3}
- /declare CurrentRange string local ${Param1}-${Param2}
- /declare CurrentSet int local
- /varcalc EventCounter ${EventCounter}+1
- /if (${RangeList.Find[_${CurrentRange}_]}) {
- /for i 1 to ${SetCount}
- /if (${Set${i}Range.Equal[${CurrentRange}]}) /varset CurrentSet ${i}
- /next i
- /varcalc Set${CurrentSet}MemberCount ${Set${CurrentSet}MemberCount}+1
- /if (${Set${CurrentSet}Names.Find[${CurrentRoller}]}) {
- /varset CurrentRoller ${CurrentRoller}*
- } else {
- /varset Set${CurrentSet}Names ${Set${CurrentSet}Names}|${CurrentRoller}
- }
- /declare Set${CurrentSet}Name${Set${CurrentSet}MemberCount} string outer ${CurrentRoller}
- /declare Set${CurrentSet}Roll${Set${CurrentSet}MemberCount} int outer ${Actual}
- } else {
- /varcalc SetCount ${SetCount}+1
- /declare Set${SetCount}MemberCount int outer 1
- /declare Set${SetCount}Range string outer ${CurrentRange}
- /declare Set${SetCount}Names string outer |${CurrentRoller}
- /declare Set${SetCount}Name1 string outer ${CurrentRoller}
- /declare Set${SetCount}Roll1 int outer ${Actual}
- /varset RangeList ${RangeList}_${CurrentRange}_
- }
- /varset CurrentRoller NULL
- /return
- Sub Event_Winners
- /varset DoWinners TRUE
- /return
- Sub Event_InfoLine
- /if (${Param2.Find["/timer"]}) /varset Param2 ${Param2.Left[${Math.Calc[${Param2.Find["/timer"]}-1].Int}]}
- /varset InfoLine ${InfoLine} ${Param2}
- /echo InfoLine=${InfoLine}
- /if (${Vocal}) /docommand /say InfoLine now ''${InfoLine}''
- /return
- Sub Event_SetCountdown
- /declare IntTest int local 0
- /declare IntLocal int local
- /varset IntTest ${Param2.Arg[1]}
- /if (${IntTest}==0) {
- /echo IntTest=0, Unable to set Countdown timer.
- /if (${Vocal}) /docommand /say Error setting countdown timer
- } else {
- /varset Countdown10x ${Math.Calc[${IntTest}/10].Int}
- /if (${Math.Calc[((${IntTest}/10)-${Countdown10x})*100].Int}==0) {
- /varcalc Countdown10x ${Countdown10x}-1
- /varset Countdown 100
- /echo Countdown=${Math.Calc[((${IntTest}/10)-${Countdown10x})*10].Int} + 10x ${Countdown10x} seconds
- /if (${Vocal}) /docommand /say Counting down from ${Math.Calc[(${Countdown10x}*10)+10].Int} seconds
- } else {
- /varset Countdown ${Math.Calc[((${IntTest}/10)-${Countdown10x})*100].Int}
- /echo Countdown=${Math.Calc[((${IntTest}/10)-${Countdown10x})*10].Int} + 10x ${Countdown10x} seconds
- /if (${Vocal}) /docommand /say Counting down from ${IntTest} seconds
- }
- }
- /return
- Sub Event_Timer(Countdown)
- /if (${Countdown10x}==0) {
- /varset DoWinners TRUE
- } else {
- /echo Countdown=${Math.Calc[${Countdown10x}*10].Int} seconds
- /if (${Vocal}) /docommand /say Countdown: ${Math.Calc[${Countdown10x}*10].Int} seconds
- /varcalc Countdown10x ${Countdown10x}-1
- /varset Countdown 100
- }
- /return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement