Yet Another Timebomb Script

By Geckat on May 24, 2012

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
}

Comments

Sign in to comment.
Geckat   -  Jun 06, 2012

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.

 Respond  
Abcdefmonkey   -  May 29, 2012

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.

 Respond  
Geckat   -  May 27, 2012

Alright, thanks. It would mean some variables would be able to be local, if I recall, but only maybe one or two if any. Still need to fix the issue where aliases are necessary if I have multiple lines tied to one timer.

 Respond  
Sorasyn   -  May 27, 2012

Na, it'll compress space somewhat, and you can more easily pass data between the two I believe. Forgive me if I am wrong though, I don't code mSL anymore.

 Respond  
Geckat   -  May 27, 2012

Ah, that. Wouldn't the number of lines then be exactly the same? It would also trigger parts of the script every time someone sends text. I was under the impression this was a Bad Thing™.

 Respond  
Sorasyn   -  May 27, 2012

I meant making a universal text event and parse the trigger with incoming text events.

on *TEXT:*:#:{
   if ($1 == !cutwire) {
   }
   elseif ($1 == !timebomb) {
   }
}

etc.

 Respond  
Geckat   -  May 26, 2012

I'm not sure how I would do that, unless I've been misinformed on how timers work with each line. I take it you mean each series of text events would be combined, rather than every single text event in the script combined into a single one?

 Respond  
Sorasyn   -  May 26, 2012

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.

 Respond  
Geckat   -  May 25, 2012

Local variables wouldn't have allowed me to use aliases, which are necessary for the timers. In any case, unless the script screws up for some reason, all variables set are unset at the end of the script.

Thanks.

 Respond  
Sorasyn   -  May 25, 2012

Might try exploring other data saving options rather than global variables, they tend to be messy and stick around if you forget to unset them. I do agree, in that it's a twist off the usual time bomb you see floating around which is a nice change-up. All in all it looks like a solid piece.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.