Advertisement
LoveAbleElf

timebomb.tcl

Aug 27th, 2017
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.02 KB | None | 0 0
  1. ###############################################################################
  2. # Name: Timebomb
  3. # Author: jotham.read@gmail.com
  4. # Web Site: http://radiosaurus.sporkism.org
  5. # Eggdrop Version: 1.6.x
  6. # Description:
  7. #
  8. # This is a small TCL script for Eggdrop. Timebomb is a game where one person
  9. # asks the Eggdrop bot to plant a timebomb in another users pants. The target
  10. # user then needs to diffuse the bomb by cutting the correct wire, or be
  11. # kicked from the channel.
  12. #
  13. # To start the game a user must type:
  14. # bomb <nickname>
  15. # This will cause the target user to have a timebomb "stuffed in their pants"
  16. # once this occurs the user will have a number of seconds to diffuse the bomb.
  17. # Diffusing the bomb is done by typing:
  18. # cutwire <color>
  19. # The wire colors you can choose from are displayed when the bomb is planted.
  20. # This script will not allow bots (Users who are +b), or the bot running the
  21. # script, to be timebombed.
  22. #
  23. # I know it sounds very silly but it is a rather fun game.
  24. #
  25. ###############################################################################
  26.  
  27. bind pub - .bomb doTimebomb
  28. bind pub - .cutwire doCutWire
  29.  
  30. ###############################################################################
  31. # Configuration
  32. #
  33.  
  34. set gTimebombMinimumDuration 20
  35. set gTimebombMaximumDuration 60
  36. set gWireChoices "Red Orange Yellow Green Blue Indigo Violet Black White Grey Brown Pink Mauve Beige Aquamarine Chartreuse Bisque Crimson Fuchsia Gold Ivory Khaki Lavender Lime Magenta Maroon Navy Olive Plum Silver Tan Teal Turquoise"
  37. set gMaxWireCount 3
  38.  
  39. ###############################################################################
  40. # Internal Globals
  41. #
  42.  
  43. set gTheScriptVersion "0.4"
  44. set gTimebombActive 0
  45. set gTimerId 0
  46. set gTimebombTarget ""
  47. set gTimebombChannel ""
  48. set gCorrectWire ""
  49. set gNumberNames "zero one two three four five six seven eight nine ten eleven twelve"
  50.  
  51. ###############################################################################
  52.  
  53. proc note {msg} {
  54. putlog "% $msg"
  55. }
  56.  
  57. proc IRCKick {theNick theChannel theReason} {
  58. note "Kicking $theNick in $theChannel (Reason: $theReason)"
  59. putserv "KICK $theChannel $theNick :$theReason"
  60. }
  61.  
  62. proc IRCPrivMSG {theTarget messageString} {
  63. putserv "PRIVMSG $theTarget :$messageString"
  64. }
  65.  
  66. proc IRCAction {theTarget messageString} {
  67. putserv "PRIVMSG $theTarget :\001ACTION $messageString\001"
  68. }
  69.  
  70. proc MakeEnglishList {theList} {
  71. set theListLength [llength $theList]
  72. set returnString [lindex $theList 0]
  73. for {set x 1} {$x < $theListLength} {incr x} {
  74. if { $x == [expr $theListLength - 1] } {
  75. set returnString "$returnString and [lindex $theList $x]"
  76. } else {
  77. set returnString "$returnString, [lindex $theList $x]"
  78. }
  79. }
  80. return $returnString
  81. }
  82.  
  83. proc SelectWires {wireCount} {
  84. global gWireChoices
  85. set totalWireCount [llength $gWireChoices]
  86. set selectedWires ""
  87. for {set x 0} {$x < $wireCount} {incr x} {
  88. set currentWire [lindex $gWireChoices [expr int( rand() * $totalWireCount )]]
  89. if { [lsearch $selectedWires $currentWire] == -1 } {
  90. lappend selectedWires $currentWire
  91. } else {
  92. set x [expr $x - 1]
  93. }
  94. }
  95. return $selectedWires
  96. }
  97.  
  98. proc DetonateTimebomb {destroyTimer kickMessage} {
  99. global gTimebombTarget gTimerId gTimebombChannel gTimebombActive
  100. if { $destroyTimer } {
  101. killutimer $gTimerId
  102. }
  103. set gTimerId 0
  104. set gTimebombActive 0
  105. IRCKick $gTimebombTarget $gTimebombChannel $kickMessage
  106. }
  107.  
  108. proc DiffuseTimebomb {wireCut} {
  109. global gTimerId gTimebombActive gTimebombTarget gTimebombChannel
  110. killutimer $gTimerId
  111. set gTimerId 0
  112. set gTimebombActive 0
  113. IRCPrivMSG $gTimebombChannel "$gTimebombTarget cut the $wireCut wire. This has defused the bomb!"
  114. }
  115.  
  116. proc StartTimeBomb {theStarter theNick theChannel} {
  117. global gTimebombActive gTimebombTarget gTimerId gTimebombChannel gNumberNames gCorrectWire
  118. global gMaxWireCount gTimebombMinimumDuration gTimebombMaximumDuration
  119. if { $gTimebombActive == 1 } {
  120. note "Timebomb not started for $theStarter (Reason: timebomb already active)"
  121. if { $theChannel != $gTimebombChannel } {
  122. IRCPrivMSG $theChannel "I don't have a single bomb to spare. :-("
  123. } else {
  124. IRCAction $theChannel "points at the bulge in the back of $gTimebombTarget's pants."
  125. }
  126. } else {
  127. set timerDuration [expr $gTimebombMinimumDuration + [expr int(rand() * ($gTimebombMaximumDuration - $gTimebombMinimumDuration))]]
  128. set gTimebombTarget $theNick
  129. set gTimebombChannel $theChannel
  130. set numberOfWires [expr 1 + int(rand() * ( $gMaxWireCount - 0 ))]
  131. set listOfWires [SelectWires $numberOfWires]
  132. set gCorrectWire [lindex $listOfWires [expr int( rand() * $numberOfWires )]]
  133. set wireListAsEnglish [MakeEnglishList $listOfWires]
  134. set wireCountAsEnglish [lindex $gNumberNames $numberOfWires]
  135. IRCAction $theChannel "stuffs the bomb into $gTimebombTarget's pants. The display reads \[\002$timerDuration\002\] seconds."
  136. if { $numberOfWires == 1 } {
  137. IRCPrivMSG $theChannel "Diffuse the bomb by cutting the correct wire. There is $wireCountAsEnglish wire. It is $wireListAsEnglish."
  138. } else {
  139. IRCPrivMSG $theChannel "Diffuse the bomb by cutting the correct wire. There are $wireCountAsEnglish wires. They are $wireListAsEnglish."
  140. }
  141. note "Timebomb started by $theStarter (Bomb handed to $theNick it will detonate in $timerDuration seconds)"
  142. set gTimebombActive 1
  143. set gTimerId [utimer $timerDuration "DetonateTimebomb 0 {\002*BOOM!*\002}"]
  144. }
  145. }
  146.  
  147. ###############################################################################
  148. # Eggdrop command binds
  149. #
  150.  
  151. proc doCutWire {nick uhost hand chan arg} {
  152. global gTimebombActive gCorrectWire gTimebombTarget
  153. if { $gTimebombActive == 1 } {
  154. if { [string tolower $nick] == [string tolower $gTimebombTarget] } {
  155. if { [llength $arg] == 1 } {
  156. if { [string tolower $arg] == [string tolower $gCorrectWire] } {
  157. DiffuseTimebomb $gCorrectWire
  158. } else {
  159. DetonateTimebomb 1 "\002snip...*BOOM!*\002"
  160. }
  161. }
  162. }
  163. }
  164. }
  165.  
  166. proc doTimebomb {nick uhost hand chan arg} {
  167. global botnick
  168. set theNick $nick
  169. if { [llength $arg] == 1 } {
  170. set theNick [lindex [split $arg] 0]
  171. }
  172. if { [string tolower $theNick] == [string tolower $botnick] } {
  173. set theNick $nick
  174. IRCKick $theNick $chan "I will not tollerate this!"
  175. return
  176. }
  177. if { [validuser $theNick] == 1 } {
  178. if { [matchattr $theNick "+b"] == 1 } {
  179. set theNick $nick
  180. IRCKick $theNick $chan "I will not tollerate that!"
  181. return
  182. }
  183. }
  184. StartTimeBomb $nick $theNick $chan
  185. }
  186.  
  187. ###############################################################################
  188.  
  189. note "timebomb$gTheScriptVersion: loaded";
  190. note " with $gMaxWireCount wire maximum,"
  191. note " and time range of $gTimebombMinimumDuration to $gTimebombMaximumDuration seconds.";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement