Advertisement
sorvani

rolls.mac

Feb 17th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.06 KB | None | 0 0
  1. |
  2. | rolls.mac
  3. |
  4. | Courtesy of the guild Fusion on PEQTGC
  5. |
  6. | Captures loot /ran rolls and outputs an organized list
  7. |
  8. | /say do winners to sort and output
  9. | can also /say /ran [your info here] and your info will be returned with the winners
  10. | can also /say /timer [timeinseconds] and the macro will automatically do winners when the timer expires
  11. | the /ran and /timer information can be placed on the same chatline ex: /say /ran 1k for thing /timer 30
  12. |
  13. |
  14.  
  15. #turbo 40
  16.  
  17. #Event Ran1 "**A Magic Die is rolled by #1#."
  18. #Event Ran2 "**It could have been any number from #1# to #2#, but this time it turned up a #3#."
  19. #Event Winners "#*#do winners#*#"
  20. #Event InfoLine "#1#/ran#2#'"
  21. #Event SetCountdown "#1#/timer#2#'"
  22.  
  23. Sub Main
  24.  
  25. /declare EventCounter int outer 0
  26. /declare DoWinners bool outer FALSE
  27. /declare CurrentRoller string outer NULL
  28. /declare RangeList string outer
  29. /declare SetCount int outer 0
  30. /declare InfoLine string outer
  31. /declare Countdown timer outer
  32. /declare Countdown10x int outer
  33. /declare Vocal bool outer TRUE
  34. /declare Links bool outer FALSE
  35. /declare AutoInfo string outer
  36. /declare LootNames string outer
  37.  
  38. /declare TempName string local
  39. /declare TempRoll int local
  40. /declare i int local
  41. /declare ii int local
  42. /declare NotSorted bool local TRUE
  43. /declare ForwardCount int local
  44. /declare ReverseCount int local
  45. /declare SortTime timer local
  46.  
  47.  
  48. /if (${Plugin[mq2linkdb].Name.Length}) /varset Links TRUE
  49.  
  50. /for i 0 to ${Math.Calc[${Macro.Params}-1].Int}
  51. /if (${Param${i}.Equal[quiet]}) {
  52. /varset Vocal FALSE
  53. } else /if (${Param${i}.Equal[nolinks]}) {
  54. /varset Links FALSE
  55. }
  56. /next i
  57.  
  58. /echo Rolls.mac - Ready to collect
  59. /if (${Vocal}) /docommand /say Rolls.mac Ready to collect
  60.  
  61. /if (${Corpse.Open} && ${Corpse.Items}) {
  62. /echo Open corpse detected, automatically assigning loot rolls...
  63. /for i 1 to ${Corpse.Items}
  64. /if (${LootNames.Find[_${Corpse.Item[${i}]}_]}) {
  65. /varcalc ItemNo${Corpse.Item[${i}].ID}Qty ${ItemNo${Corpse.Item[${i}].ID}Qty}+1
  66. /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}
  67. /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}]}]},
  68. } else {
  69. /varset LootNames ${LootNames}_${Corpse.Item[${i}]}_
  70. /varcalc SetCount ${SetCount}+1
  71. /declare Set${SetCount}MemberCount int outer 1
  72. /declare Set${SetCount}Range string outer 0-${SetCount}000
  73. /declare Set${SetCount}Names string outer |${Corpse.Item[${i}]}
  74. /declare Set${SetCount}Name1 string outer ${If[${Links},${LinkDB["${Corpse.Item[${i}]}"]},${Corpse.Item[${i}]}]}
  75. /declare ItemNo${Corpse.Item[${i}].ID}Qty int outer 1
  76. /declare ItemNo${Corpse.Item[${i}].ID}SetNo int outer ${SetCount}
  77. /declare Set${SetCount}Roll1 int outer ${Math.Calc[${SetCount}000+1].Int}
  78. /varset RangeList ${RangeList}_0-${SetCount}000_
  79. /varset AutoInfo ${AutoInfo} ${SetCount}k for ${If[${Links},${LinkDB["${Corpse.Item[${i}]}"]},${Corpse.Item[${i}]}]},
  80. }
  81. /next i
  82. /echo AutoInfo=${AutoInfo}
  83. /if (${Vocal}) /docommand /say Roll ${AutoInfo}
  84. }
  85.  
  86. :MainLoop
  87. /doevents
  88. /if (${DoWinners}) /goto :StartWinners
  89. /goto :MainLoop
  90.  
  91. :StartWinners
  92. /if (${InfoLine.Length}) {
  93. /echo ***InfoLine***: ${InfoLine}
  94. /if (${Vocal}) /docommand /say ***Info***: ${InfoLine}
  95. }
  96. /if (${SetCount}==0) {
  97. /if (${Vocal}) /docommand /say No rolls captured, ending
  98. /echo SetCount=${SetCount}
  99. /echo ending...
  100. /endmacro
  101. }
  102. /for i 1 to ${SetCount}
  103. /varset SortTime 3000
  104. /if (${Set${i}MemberCount}<2) /goto :PostSort
  105. /varset ForwardCount 0
  106. /varset ReverseCount 0
  107.  
  108. :SortLoop
  109. /varset NotSorted TRUE
  110. /for ii ${Math.Calc[${ReverseCount}+1].Int} to ${Math.Calc[${Set${i}MemberCount}-1-${ForwardCount}].Int}
  111. /if (${Set${i}Roll${ii}}<${Set${i}Roll${Math.Calc[${ii}+1].Int}}) {
  112. /varset TempName ${Set${i}Name${ii}}
  113. /varset TempRoll ${Set${i}Roll${ii}}
  114. /varset Set${i}Name${ii} ${Set${i}Name${Math.Calc[${ii}+1].Int}}
  115. /varset Set${i}Roll${ii} ${Set${i}Roll${Math.Calc[${ii}+1].Int}}
  116. /varset Set${i}Name${Math.Calc[${ii}+1].Int} ${TempName}
  117. /varset Set${i}Roll${Math.Calc[${ii}+1].Int} ${TempRoll}
  118. /varset NotSorted FALSE
  119. }
  120. /next ii
  121. /varcalc ForwardCount ${ForwardCount}+1
  122. /if (${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}<2) /goto :PostSort
  123. /echo ${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}
  124. /for ii ${Math.Calc[${Set${i}MemberCount}-1-${ForwardCount}].Int} downto ${Math.Calc[${ReverseCount}+1].Int}
  125. /if (${Set${i}Roll${ii}}<${Set${i}Roll${Math.Calc[${ii}+1].Int}}) {
  126. /varset TempName ${Set${i}Name${ii}}
  127. /varset TempRoll ${Set${i}Roll${ii}}
  128. /varset Set${i}Name${ii} ${Set${i}Name${Math.Calc[${ii}+1].Int}}
  129. /varset Set${i}Roll${ii} ${Set${i}Roll${Math.Calc[${ii}+1].Int}}
  130. /varset Set${i}Name${Math.Calc[${ii}+1].Int} ${TempName}
  131. /varset Set${i}Roll${Math.Calc[${ii}+1].Int} ${TempRoll}
  132. /varset NotSorted FALSE
  133. }
  134. /next ii
  135. /varcalc ReverseCount ${ReverseCount}+1
  136. /if (${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}<2) /goto :PostSort
  137. /echo ${Math.Calc[${Set${i}MemberCount}-(${ForwardCount}+${ReverseCount})].Int}
  138. /if (${NotSorted}) /goto :PostSort
  139. /goto :SortLoop
  140.  
  141. :PostSort
  142. /declare Set${i}Final string local
  143. /for ii 1 to ${Set${i}MemberCount}
  144. /varset Set${i}Final ${Set${i}Final} ${Set${i}Name${ii}}(${Set${i}Roll${ii}}),
  145. /next ii
  146. /echo ***${Set${i}Range}***:${Set${i}Final}
  147. /if (${Vocal}) /docommand /say ***${Set${i}Range}***:${Set${i}Final}
  148. /echo Range ${Set${i}Range} SortTime ${Math.Calc[(3000-${SortTime})/10].Deci} seconds
  149. /varset SortTime
  150. /next i
  151.  
  152. /return
  153.  
  154.  
  155. Sub Event_Ran1
  156.  
  157. /varcalc EventCounter ${EventCounter}+1
  158. /if (${CurrentRoller.Equal[NULL]}) {
  159. /varset CurrentRoller ${Param1}
  160. } else {
  161. /echo ERROR: CurrentRoller not NULL
  162. /echo ending
  163. /if (${Vocal}) /docommand /say Macro failure, ending
  164. /endmacro
  165. }
  166.  
  167. /return
  168.  
  169.  
  170. Sub Event_Ran2
  171.  
  172. /declare i int local
  173. /declare Actual int local ${Param3}
  174. /declare CurrentRange string local ${Param1}-${Param2}
  175. /declare CurrentSet int local
  176.  
  177. /varcalc EventCounter ${EventCounter}+1
  178. /if (${RangeList.Find[_${CurrentRange}_]}) {
  179. /for i 1 to ${SetCount}
  180. /if (${Set${i}Range.Equal[${CurrentRange}]}) /varset CurrentSet ${i}
  181. /next i
  182. /varcalc Set${CurrentSet}MemberCount ${Set${CurrentSet}MemberCount}+1
  183. /if (${Set${CurrentSet}Names.Find[${CurrentRoller}]}) {
  184. /varset CurrentRoller ${CurrentRoller}*
  185. } else {
  186. /varset Set${CurrentSet}Names ${Set${CurrentSet}Names}|${CurrentRoller}
  187. }
  188. /declare Set${CurrentSet}Name${Set${CurrentSet}MemberCount} string outer ${CurrentRoller}
  189. /declare Set${CurrentSet}Roll${Set${CurrentSet}MemberCount} int outer ${Actual}
  190. } else {
  191. /varcalc SetCount ${SetCount}+1
  192. /declare Set${SetCount}MemberCount int outer 1
  193. /declare Set${SetCount}Range string outer ${CurrentRange}
  194. /declare Set${SetCount}Names string outer |${CurrentRoller}
  195. /declare Set${SetCount}Name1 string outer ${CurrentRoller}
  196. /declare Set${SetCount}Roll1 int outer ${Actual}
  197. /varset RangeList ${RangeList}_${CurrentRange}_
  198. }
  199. /varset CurrentRoller NULL
  200.  
  201. /return
  202.  
  203.  
  204. Sub Event_Winners
  205.  
  206. /varset DoWinners TRUE
  207.  
  208. /return
  209.  
  210.  
  211. Sub Event_InfoLine
  212.  
  213. /if (${Param2.Find["/timer"]}) /varset Param2 ${Param2.Left[${Math.Calc[${Param2.Find["/timer"]}-1].Int}]}
  214. /varset InfoLine ${InfoLine} ${Param2}
  215. /echo InfoLine=${InfoLine}
  216. /if (${Vocal}) /docommand /say InfoLine now ''${InfoLine}''
  217.  
  218. /return
  219.  
  220.  
  221. Sub Event_SetCountdown
  222.  
  223. /declare IntTest int local 0
  224. /declare IntLocal int local
  225.  
  226. /varset IntTest ${Param2.Arg[1]}
  227. /if (${IntTest}==0) {
  228. /echo IntTest=0, Unable to set Countdown timer.
  229. /if (${Vocal}) /docommand /say Error setting countdown timer
  230. } else {
  231. /varset Countdown10x ${Math.Calc[${IntTest}/10].Int}
  232. /if (${Math.Calc[((${IntTest}/10)-${Countdown10x})*100].Int}==0) {
  233. /varcalc Countdown10x ${Countdown10x}-1
  234. /varset Countdown 100
  235. /echo Countdown=${Math.Calc[((${IntTest}/10)-${Countdown10x})*10].Int} + 10x ${Countdown10x} seconds
  236. /if (${Vocal}) /docommand /say Counting down from ${Math.Calc[(${Countdown10x}*10)+10].Int} seconds
  237. } else {
  238. /varset Countdown ${Math.Calc[((${IntTest}/10)-${Countdown10x})*100].Int}
  239. /echo Countdown=${Math.Calc[((${IntTest}/10)-${Countdown10x})*10].Int} + 10x ${Countdown10x} seconds
  240. /if (${Vocal}) /docommand /say Counting down from ${IntTest} seconds
  241. }
  242. }
  243.  
  244. /return
  245.  
  246.  
  247. Sub Event_Timer(Countdown)
  248.  
  249. /if (${Countdown10x}==0) {
  250. /varset DoWinners TRUE
  251. } else {
  252. /echo Countdown=${Math.Calc[${Countdown10x}*10].Int} seconds
  253. /if (${Vocal}) /docommand /say Countdown: ${Math.Calc[${Countdown10x}*10].Int} seconds
  254. /varcalc Countdown10x ${Countdown10x}-1
  255. /varset Countdown 100
  256. }
  257.  
  258. /return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement