Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.86 KB | None | 0 0
  1. set playchan "#roulette"
  2. set startingbullets ""
  3. set maxbullets ""
  4. set currentbullets ""
  5. set bullets ""
  6. set currentposition 0
  7. set currentplayer ""
  8. set passable false
  9. set players ""
  10. set chamber ""
  11. set gathering false
  12. set currentplayerpos 0
  13. set singleplayer true
  14. set timerset false
  15.  
  16. set BangUsers {
  17. "SpikeS[MR]"
  18. "SpikeSpiegel[MR]"
  19. "IzzyCreamCheese"
  20. "Spiral[MR]"
  21. "Heartbeat[MR]"
  22. "Bob"
  23. }
  24.  
  25. set roulettecmd "!roulette"
  26. set joincmd "!join"
  27. set shootcmd "!pew"
  28. set passcmd "!pass"
  29.  
  30. bind pub - !roulette roulette:start
  31. bind pub - !join roulette:join
  32. bind pub - !pew roulette:pew
  33. bind pub - !bang roulette:bang
  34. bind pub - !pass roulette:pass
  35. #BANG IS EXCLUSIVELY MADE IN HONOR OF SPIKEY BOY. Only specific people will have access to it. For now Those people are : Me (duh), IzzyCreamCheese (Can't disrespect the boss), Spiral[MR], SpikeSpiegel[MR], SpikeS[MR]
  36. #Default message for pew if it has a bullet: <Nick> squeezes the gun tightly and pulls the trigger... <Dramatic pause> <On a new line> <Nick> blew their brains out!
  37. #The BANG message and when it has a bullet: <Nick> knows how to handle a gun. They point it at their forehead... <Dramatic pause> <On a new line> A shot echoed through the air, as if thunder struck down. "Cheater!" was heard coming from the referee, followed by the sound of <Victim Nick>'s corpse stumbling down to the ground.
  38.  
  39. # The !roulette <chamber> <bullets> part of the game.
  40. proc roulette:start {nick host handle chan arg} {
  41. global chamber maxbullets currentbullets startingbullets currentplayer players gathering playchan timerset roulettecmd
  42. set tempchamber [lindex [split $arg] 0]
  43. set tempmaxbullets [lindex [split $arg] 1]
  44. set check1 false
  45. set check2 false
  46. if {$playchan == $chan} {
  47. if {$currentplayer == ""} {
  48. if {$tempchamber == "" || $tempmaxbullets == ""} {
  49. putquick "PRIVMSG $chan :The command is \002$roulettecmd <chamber size> <bullets>\002."
  50. return
  51. }
  52. if {[string is integer $tempchamber] && [string is integer $tempmaxbullets] && $tempchamber >= $tempmaxbullets } {
  53. if {$tempchamber > 20 || $tempchamber <= 0} {
  54. putquick "PRIVMSG $chan :Use your brain. Possible chamber values are <1-20>."
  55. return
  56. } else { set check1 true }
  57.  
  58. if {$tempmaxbullets > 20 || $tempmaxbullets<1} {
  59. putquick "PRIVMSG $chan :Use your brain. Possible bullet values are <1-20>."
  60. return
  61. } else { set check1 true }
  62. if {[string is true $check1] && [string is true $check2] && [string is false $gathering]} {
  63. set gathering true
  64. set chamber $tempchamber
  65. set maxbullets $tempmaxbullets
  66. set currentbullets $tempmaxbullets
  67. set startingbullets $tempmaxbullets
  68. add $nick
  69. set gathering true
  70. putquick "PRIVMSG $chan test"
  71. #putquick "PRIVMSG $chan :A game of russian roulette has started. The chamber will have a size of \002$chamber\002, bearing \002$maxbullets\002 bullets. Type \002$joincmd\002 to join!"
  72. if {[string is false $timerset]} {starttimer}
  73.  
  74. }
  75. } else { putquick "PRIVMSG $chan :Invalid input. \002$roulettecmd <1-20> <1-20>\002. Bullets (the second given number) must be equal or less than the chamber size, obviously." }
  76. } else { putquick "PRIVMSG $chan :Sorry, but there is a game currently in progress. It is \002$currentplayer\002's turn to act." }
  77. }
  78. }
  79. # Helpful proc for addition
  80. proc add {nick} {
  81. global players chamber playchan timerset
  82. if {[lsearch -exact $players $nick]>=0} {
  83. putquick "PRIVMSG $nick :I know you can't wait to blow your brains out, but have some patience! (You are already signed up...)"
  84. # NEED TO ADD CODE BELOW FOR TIMER CHECK.... or implement it in a function which does part of the things done below. (Probably will have to move them...)
  85. } else { if {[llength $players]>= $chamber} {
  86. putquick "PRIVMSG $playchan :Max players reached, starting the game!"
  87. set timerset false
  88. gamestart
  89. } else {
  90. lappend players $nick
  91. putquick "PRIVMSG $playchan :\002$nick\002 has joined the fray."
  92. }}
  93. }
  94.  
  95. #Timer <Experimental>
  96. proc starttimer {} {
  97. global timerset playchan
  98. set timerset true
  99. after 60000
  100. if {[string is true $timerset]} {
  101. putquick "PRIVMSG $playchan :60 seconds have passed, the game of russian roullete shall now commence."
  102. gamestart
  103. }
  104. }
  105.  
  106. #Game start, as I might need to start it from the timer function too, or whatever I end up using for the "time" check
  107. proc gamestart {} {
  108. global players gathering currentplayer chamber maxbullets bullets shootcmd startingbullets singleplayer playchan
  109. set gathering false
  110. set currentplayer [lindex $players [rand [llength $players]]]
  111. if {[llength $players]>1} { set singleplayer false }
  112. for {set x 0} {$x<$chamber} {incr x} {
  113. lappend bullets 0
  114. }
  115. while {$maxbullets} {
  116. set random [rand $startingbullets]
  117. if {[lindex $bullets $random] != 1} {
  118. set bullets [lreplace $bullets $random $random 1]
  119. incr maxbullets -1
  120. }
  121. }
  122. putquick "PRIVMSG $playchan :It is currently \002$currentplayer\002's turn to act. Type \002$shootcmd\002 to shoot."
  123. }
  124.  
  125. #The !join part of the game.
  126. proc roulette:join {nick host handle chan arg} {
  127. global players currentplayer gathering playchan roulettecmd
  128. if {$chan == $playchan} {
  129. if {[string is true $gathering]} { add $nick } else {
  130. if {$currentplayer == ""} { putquick "PRIVMSG $chan :To join, you must first setup a game, using \002$roulettecmd\002." } else {
  131. putquick "PRIVMSG $nick :There is a game currently in progress, \002$nick\002. Are you blind?"
  132. }
  133. }}
  134. }
  135.  
  136. #The part that ends the game
  137. proc endgame {} {
  138. global startingbullets maxbullets currentbullets bullets currentposition currentplayer passable players chamber gathering currentplayerpos singleplayer timerset playchan
  139. set startingbullets ""
  140. set maxbullets ""
  141. set currentbullets ""
  142. set bullets ""
  143. set currentposition 0
  144. set currentplayer ""
  145. set passable false
  146. set players ""
  147. set chamber ""
  148. set gathering false
  149. set currentplayerpos 0
  150. set singleplayer true
  151. set timerset false
  152. putquick "PRIVMSG $playchan :The game of russian roulette has ended."
  153. }
  154.  
  155. #The !pew part of the game.
  156. proc roulette:pew {nick host handle chan arg} {
  157. global players currentplayer currentposition chamber maxbullets bullets shootcmd passcmd passable currentplayerpos singleplayer playchan
  158. if ($chan == $playchan) {
  159. if {$currentplayer == $nick} {
  160. putquick "PRIVMSG $chan :\002$nick\002 squeezes the gun tightly and pulls the trigger..."
  161. after 3000
  162. if {[lindex $bullets $currentposition]!=1} {
  163. putquick "PRIVMSG $chan :Nothing happened. Type \002$passcmd\002 to pass, or \002$shootcmd\002 to continue shooting."
  164. incr currentposition
  165. set passable true
  166. return
  167. } else {
  168. set temp [lsearch -exact $players $currentplayer]
  169. set players [lreplace $players $temp $temp]
  170. set passable false
  171. incr currentbullets -1
  172. #NEED TO DECIDE IF THEY WILL PLAY TILL BULLETS RUN OUT, OR PLAY TILL LAST MAN STANDING. BEFORE I DECIDE THAT, I CANNOT MOVE PAST THIS LINE.
  173. if {$players == "" && $currentbullets == 0} {
  174. putquick "PRIVMSG $chan :Boohoo, you didn't manage to prevail the odds you set yourself."
  175. endgame
  176. return 0
  177. }
  178. puthelp "PRIVMSG $chan :\002$currentplayer\002 blew their brains out!"
  179. set currentplayer [lindex $players $currentplayerpos]
  180. incr currentposition
  181. if {[llength $players] == 1 && [string is false $singleplayer]} {
  182. puthelp "PRIVMSG $chan :\002$currentplayer\002 prevailed the odds!"
  183. endgame
  184. return 0
  185. }
  186. if {$currentbullets == 0 && [string is false $singleplayer]} {
  187. printwinners
  188. return 0
  189. }
  190. if {$currentbullets ==0 && [string is true $singleplayer]} {puthelp "PRIVMSG $chan :\002$currentplayer\002 prevailed the odds!"}
  191. puthelp "PRIVMSG $chan :The gun has been passed to \002$currentplayer\002. Type \002$shootcmd\002 to shoot."
  192. return
  193. }
  194. }
  195. }
  196. }
  197.  
  198. #The !pass part of the game
  199. proc roulette:pass {nick host handle chan arg} {
  200. global players currentplayer currentposition chamber maxbullets bullets shootcmd passcmd currentplayerpos playchan
  201. if {$playchan == $chan} {
  202. if {$currentplayer == $nick && [string is true $passable]} {
  203. if {[llength $players]==1} {
  204. putquick "PRIVMSG $chan :You cannot pass to yourself, idiot."
  205. return 0
  206. }
  207. incr currentplayerpos
  208. if {$currentplayerpos > [llength $players]} {set currentplayerpos 0}
  209. set currentplayer [lindex $players $currentplayerpos]
  210. puthelp "PRIVMSG $chan :The gun has been passed to \002$currentplayer\002."
  211. }
  212. }
  213. }
  214.  
  215. #Printing the winners.
  216. proc printwinners {} {
  217. global players playchan
  218. set winners "/002[lindex $players 0]/002"
  219. set temp [lsearch -exact $players [lindex $players 0]]
  220. set players [lreplace $players $temp $temp]
  221. while {$players} {
  222. set winners "$winners, /002[lindex $players 0]/002"
  223. set temp [lsearch -exact $players [lindex $players 0]]
  224. set players [lreplace $players $temp $temp]
  225. }
  226. puthelp "PRIVMSG $playchan :$winners have prevailed the odds!"
  227. endgame
  228. }
  229.  
  230. #The !bang part of the game
  231. proc roulette:bang {nick host handle chan arg} {
  232. global players currentplayer currentposition chamber maxbullets bullets shootcmd passcmd currentplayerpos BangUsers playchan
  233. if {$playchan == $chan} {
  234. if {$currentplayer == $nick && [lsearch -inline -exact $BangUsers $nick]!= ""} {
  235. puthelp "PRIVMSG $chan :\002$nick\002 knows how to handle a gun. They point it at their forehead..."
  236. set temp [lsearch -exact $BangUsers $nick]
  237. set BangUsers [lreplace $BangUsers $temp $temp]
  238. incr currentposition
  239. set passable true
  240. after 3000
  241. if {[lindex $bullets $currentposition]!=1} {
  242. putquick "PRIVMSG $chan :Nothing happened. Type \002$passcmd\002 to pass, or \002$shootcmd\002 to continue shooting."
  243. return
  244. } else {
  245. if {[llength $players]==1} {
  246. puthelp "PRIVMSG $chan :A shot echoed through the air, as if thunder struck down. 'Cheater!' was heard coming from the referee."
  247. set currentbullets -1
  248. return 0
  249. }
  250.  
  251. if {$currentplayerpos+1 > [llength $players]} {set currentplayerpos 0}
  252. set temp [lindex $players $currentplayerpos+1]
  253. set players [lreplace $players $temp $temp]
  254. incr currentbullets -1
  255. #NEED TO DECIDE IF THEY WILL PLAY TILL BULLETS RUN OUT, OR PLAY TILL LAST MAN STANDING. BEFORE I DECIDE THAT, I CANNOT MOVE PAST THIS LINE.
  256. puthelp "PRIVMSG $chan :A shot echoed through the air, as if thunder struck down. 'Cheater!' was heard coming from the referee, followed by the sound of \002$temp\002's corpse stumbling down to the ground."
  257. if {[llength $players] == 1 && [string is false $singleplayer]} {
  258. puthelp "PRIVMSG $chan :\002$currentplayer\002 prevailed the odds!"
  259. endgame
  260. return 0
  261. }
  262. if {$currentbullets == 0 && [string is false $singleplayer]} {
  263. printwinners
  264. return 0
  265. }
  266. if {$currentbullets ==0 && [string is true $singleplayer]} {puthelp "PRIVMSG $chan :\002$currentplayer\002 prevailed the odds!"}
  267. puthelp "PRIVMSG $chan :The gun is still in \002$currentplayer\002's possession. Type \002$shootcmd\002 to shoot or \002$passcmd\002 to pass."
  268. return
  269. }
  270. }
  271. }
  272. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement