I know there are tons of these out there, but we've gone through like four of them and all of them leave us going, at some point, "Well, that's kind of stupid." So I finally got tired of doing productive things and wrote my own. Huzzah.
Simply put, anyone can slap a bomb on anyone in the channel. The person who's been bombed has to choose one of four wires on the bomb to cut before the 30-second timer runs out. If they get it right, they're safe. If not, they get kicked from the channel with a satisfying explosion. Ditto if they let the timer run out.
This script differs from other timebomb scripts in that, after 20 seconds have elapsed, anyone can rush in to the person's aid. This makes it more fun when someone gets bombed but either isn't around to defuse themselves or are too stupid to understand the ridiculously easy syntax to do so. If they get the wrong wire, though, they both get asploded, to add a sense of true heroism.
Please note that this script does actually kick your users and basically let them kick each other. So if your channel isn't well-moderated, or if for some reason you don't pass around kicks as if they were STIs (ie you have a serious channel), this probably isn't a script for you.
The syntax is !timebomb NICK
The rest is easy. Have fun.
on *:TEXT:!timebomb*:#: {
if ($nick == $me) {
msg $chan Er, no.
halt
}
if ($2 !ison $chan) {
msg $chan $2 isn't here...
halt
}
if (%bombed) {
msg $chan There is already a timebomb active!
halt
}
.describe $chan straps a live bomb to $2 $+ 's chest! A timer on it reads4 00:30...
set %bombed $2
set %bombchan $chan
msg $chan Tearing off the plating reveals four wires: 4red, 2blue, 8yellow and 3green.
msg $chan $+ $2 $+ , try to deactivate the bomb: type !cutwire 4co12lo3ur and brace yourself!
.timer1 1 20 bombtime
.timer3 1 30 timeup
}
alias timeup {
if %bombed {
msg %bombchan *beep* *beep*
.kick %bombchan %bombed *BOOOOOOOM*
unsetbomb
}
}
alias bombtime {
if %bombed {
msg %bombchan 10 seconds left! Someone help %bombed $+ !
set %bombtime 1
}
}
on *:TEXT:!cutwire*:#: {
if $nick == %bombed || %bombtime == 1 {
if $2 != red && $2 != blue && $2 != yellow && $2 != green {
msg $chan $nick $+ , there is no $+(",$2,") wire! Choose red, blue, yellow, or green!
halt
}
set %wire $replace($rand(1,4),1,red,2,blue,3,yellow,4,green)
set %chosewire $2
.timer1 off
.timer3 off
if ($nick == %bombed) {
msg $chan $nick grips the $2 wire in a pair of wire cutters...
}
else {
msg $chan $nick heroically leaps to %bombed $+ 's rescue and tears off the $2 wire!
set %saviour $nick
}
.timer2 1 2 cutwire
}
}
alias cutwire {
.timer 1 4 msg %bombchan *beep* *beep*
if %chosewire == %wire {
.timer 1 6 msg %bombchan fsst-
.timer 1 6 msg %bombchan The bomb was defused! 14I'll get you next time...
}
else {
if (%saviour != %bombed) {
.timer 1 6 .kick %bombchan %saviour *BOOOOOOOM*
}
.timer 1 6 .kick %bombchan %bombed *BOOOOOOOM*
}
.timer 1 7 unsetbomb
}
alias unsetbomb {
unset %bombed
unset %bombtime
unset %bombchan
unset %wire
unset %chosewire
unset %saviour
.timers off
}
If you modify it to make it more efficient, that would be phenomenal. You should definitely let me have a look in that case so I can learn from it; I'm still very much just an occasional hobbyist :) . Thanks!
In future scripts I'll look into merging text events. It just seems weird to me that having a script always trigger on every text event, even if it's only one line, would be more efficient. I'll also look into hash. It's something I've never seen or heard of.
Geckat, it wouldn't trigger bigger parts of the code necessarily. I did have a game bot on the SwiftIRC network running for two years that used 1.5k lines of coding and it was on 1 ON TEXT event. I just used regex to differentiate between the triggers. :)
Also, from the looks of it, the coding isn't too bad. I would've probably used hash for saving the data though. Hmm, if I find some time soon, I'll look into modifying the code, with your permission of course.
Good job either way.
You could combine all your text events into one, which would allow for some use of local variables. Pending usage of your aliases, meaning if the alias is used twice or less, you could cut out the aliases and use the code segments themselves.
In short, it could be done with a little restructuring and optimizing of your code.