Just another bomb script

By Cados on Sep 25, 2010

I haven't posted or wrote anything in a while and gotten a bit rusty with MSL but I'm back with my first script in a while...even if it is common. And sorry for it being long, forgot a few ways to shorten it.

on *:TEXT:!bomb*:#:{
  if ($2 == $null) {
    goto self
  }
  else {
    goto other
  }
  :self
  set %bomb on
  set %bomb.time $rand(15,40)
  set %bomb.nick $nick
  set %bomb.color $rand(1,5)
  .msg # %bomb.nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
  .timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
  halt
  :other
  set %bomb on
  set %bomb.time $rand(15,40)
  set %bomb.nick $2
  set %bomb.color $rand(1,5)
  if ($2 !ison #) { .msg # $2 is not on #. | halt }
  else {
    .msg # $nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
    .timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
    halt
  }
}
on *:TEXT:*:#:{
  if ($nick == %bomb.nick) {
    if (Red == $$1 && %bomb.color == 1) { .msg # Congrats %bomb.nick $+  , you defused the bomb! | .timerbomb off | halt }
    elseif (%bomb.color == 1 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 1 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 1 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 1 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    if (Blue == $$1 && %bomb.color == 2) { .msg # Congrats %bomb.nick $+  , you defused the bomb! | .timerbomb off | halt }
    elseif (%bomb.color == 2 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }    
    elseif (%bomb.color == 2 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 2 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 2 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    if (Yellow == $$1 && %bomb.color == 3) { .msg # Congrats %bomb.nick $+  , you defused the bomb! | .timerbomb off | halt }
    elseif (%bomb.color == 3 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 3 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 3 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 3 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    if (Green == $$1 && %bomb.color == 4) { .msg # Congrats %bomb.nick $+  , you defused the bomb! | .timerbomb off | halt }
    elseif (%bomb.color == 4 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 4 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 4 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 4 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    if (Pink == $$1 && %bomb.color == 5) { .msg # Congrats %bomb.nick $+  , you defused the bomb! | .timerbomb off | halt }
    elseif (%bomb.color == 1 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 1 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 1 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    elseif (%bomb.color == 1 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
    .timerbomb off
  }
}

Comments

Sign in to comment.
gooshie   -  Oct 01, 2010

jaytea
i agree

 Respond  
jaytea   -  Oct 01, 2010

not only is it undocumented, it is more than likely unintended too. as tempting as it can be to showcase one's knowledge of little known esoteric parser quirks, we must remember that there is a time and a place for such things :P it's not advisable to demonstrate usage of those quirks without further explanation and a word of caution.

it is not easy to infer, even with context, the meaning of $(,code), the help file does not explain its tendency to evaluate twice when used that way, and it's something that could very likely be fixed in a later version.

once upon a time it was discovered that $(,,code) evaluated 'code' and returned an overall result of $null. this was before /noop and $regsubex() existed, /.echo -q was considered longer and more cumbersome, and $(,, ) appeared to provide a convenient way to use identifiers like $regsub() and $findfile() inline while discarding their result. and it was until, without warning, it was modified to behave similar to $(, code). this broke quite a few scripts and served as a warning: do not get in the habit of using undocumented features, especially if perfectly documented and more readable alternatives exist!

 Respond  
gooshie   -  Sep 30, 2010

oic... another one of those non-standard undocumented save a keystroke things..

 Respond  
WorldDMT   -  Sep 30, 2010

$(,%var) = $(%var,2)

 Respond  
gooshie   -  Sep 29, 2010

WorldDMT
Yes, very good with the $6. Wish I had thunk of it.
Btw, you still need $($+($,%bomb.color),2) and you
still have blue messpalled above.

 Respond  
WorldDMT   -  Sep 29, 2010

@gooshie:
u r right but no need to set a local variable just add $1 to tokenize :)

tokenize 32 red blue yellow green pink $1
if $(,$+($,%bomb.color)) == $6 {

PS: i edit the code above

 Respond  
gooshie   -  Sep 28, 2010

WorldDMT
Btw, should have been $($+($,%bomb.color),2) but still wont work
because after tokenize $1 will always == red
Would need a local variable to make it work.

    var %1 $1
    tokenize 32 red blue yellow green pink
    if $($+($,%bomb.color),2) == %1 {
 Respond  
napa182   -  Sep 27, 2010

PunkTuReD you act like learning Regex is hard...
but i can see where you are coming from only if the regex used is unreadable , but the one used is easy to understand an read.
=/

 Respond  
PuNkTuReD   -  Sep 27, 2010

i love when a script is posted.... and the poster obviously has no grasp of regex...
and people post full on regex codes with no explaination of how or why they work...
good way to help fellow scriptors guys...
spot on...
10/10 for all the help.....

 Respond  
gooshie   -  Sep 27, 2010
alias -l pwr2kck if $iif($pos(~&@%,$left($nick($1,$me).pnick,1),1),$v1,9) < $iif($pos(~&@%,$left($nick($1,$2).pnick,1),1),$v1,9) { return $true }
on $*:TEXT:/^(!BOMB.*|Red|Blue|Yellow|Green|Pink)$/iS:#:{
  tokenize 32 $regml(1)
  if !$timer(bomb) && $1 == !bomb {
    if $2 == $me { .msg # Nice try $nick $+ , but I $iif($r(0,1),wasn't scripted,didn't fall off the script truck) yesterday! | halt }
    set %bomb.chan #
    set %bomb.time $r(15,40)
    set %bomb.nick $iif($2,$2,$nick)
    set %bomb.color $gettok(Red|Blue|Yellow|Green|Pink,$r(1,5),124)
    if %bomb.nick !ison # { .msg # $2 is not on # $+ . | halt }
    .msg # %bomb.nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: Red, Blue, Yellow, Green, Pink.
    .timerbomb 1 %bomb.time $!iif($pwr2kck(%bomb.chan,%bomb.nick),kick,msg) # %bomb.nick ~~~~BOOOOOOOM YOU DIED~~~~
  }
  elseif $timer(bomb) && $nick == %bomb.nick {
    if $1 == %bomb.color {
      .msg # Congrats %bomb.nick $+ , you defused the bomb!
      .timerbomb off
    }
    else { .msg # Too bad... | .timerbomb -e }
  }
}
____________________________________________________________________________________________________________________________________________________________
 Respond  
WorldDMT   -  Sep 27, 2010

i think this can be like this

on *:text:*:#:{
  if $1 == !bomb {
    set %bomb.time $r(15,40)
    set %bomb.nick $iif($2,$2,$nick)
    set %bomb.color $r(1,5)
    if $2 !ison # { .msg # $2 is not on #. | halt }
    .msg # %bomb.nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
    .timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
  }
  elseif $nick == %bomb.nick {
    tokenize 32 red bleue yellow green pink $1
    if $(,$+($,%bomb.color)) == $6 {
      .msg # Congrats %bomb.nick $+ , you defused the bomb!
      .timerbomb off
    }
    else {
      .msg # Too bad...
      .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~
      .timerbomb off
    }
     unset %bomb.*
  }
}

PS: not tested i dont have mIRC here

 Respond  
sk68   -  Sep 26, 2010

lol, that movie was amazing.

 Respond  
gooshie   -  Sep 26, 2010

The funny thing about the original code is that if you said anything other than one of the five colors then it would turn off the bomb timer. I guess it's like in 'War Games', the only winning move is not to play.

 Respond  
gooshie   -  Sep 26, 2010

Good job Napa.
I'm just gonna restate that as the total script and make use of .timer -e
and eliminate one of the set variables. Also, need ops to use kick command.

on @*:TEXT:!bomb*:#:{
  set %bomb.time $r(15,40)
  set %bomb.color $gettok(Red|Blue|Yellow|Green|Pink,$r(1,5),124)
  if $2 {
    if ($2 !ison #) { .msg # $2 is not on #. | halt }
    set %bomb.nick $2
  }
  else { set %bomb.nick $nick }
  .msg # %bomb.nick has just had a bomb placed in front of them. $&
      They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
  .timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
}
on $*:TEXT:/^(Red|Blue|Yellow|Green|Pink)$/iS:#:{
  if ($nick = %bomb.nick) {
    $iif($regml(1) = %bomb.color,.msg # Congrats %bomb.nick $+ , you defused the bomb!,.timerbomb -e)
    .timerbomb off
  }
}
_______________________________________________________________________________________________________
 Respond  
napa182   -  Sep 25, 2010

way too much redundancy within the snippet....

you can set the color var like

set %bomb.color $gettok(Red|Blue|Yellow|Green|Pink,$r(1,5),124)

then do the defused part something like this

on $*:TEXT:/^(Red|Blue|Yellow|Green|Pink)$/iS:#:{
  if ($nick = %bomb.nick) {
    $iif($regml(1) = %bomb.color,.msg # Congrats $&
      $+(%bomb.nick,$chr(44)) you defused the bomb!,kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~)
    .timerbomb off
    unset %bomb.*
  }
}
 Respond  
Cados   -  Sep 25, 2010

Tried, it read anything.

 Respond  
sk68   -  Sep 25, 2010

ew, goto :S also you could probably eliminate 3/4 of the elseifs just by using else >w>

 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.